#============================================================================== # ■ XP-RGSS-56 鍛冶屋 [ウィンドウクラス] by Claimh #============================================================================== #============================================================================== # ■ Window_BsCmd #============================================================================== class Window_BsCmd < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 64, 480, 64) self.contents = Bitmap.new(width - 32, height - 32) end def enable self.active = self.visible = true end def disable self.active = self.visible = false end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) x = 4 + index * self.width / @column_max self.contents.draw_text(x, 0, 300, 32, @commands[index]) end end #============================================================================== # ■ Window_BsSysCmd #============================================================================== class Window_BsSysCmd < Window_BsCmd #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super @commands = Blacksmith.sys_cmd @item_max = @column_max = @commands.size refresh self.index = 0 end def fix? return (Blacksmith::SYS_CMD.size == 1) end def exit? return (Blacksmith::SYS_CMD[@index] == 2) end def sys return Blacksmith::SYS_CMD[@index] end end #============================================================================== # ■ Window_BsModCmd #============================================================================== class Window_BsModCmd < Window_BsCmd #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(sys=0) super() self.sys = sys end def sys=(s) @commands = Blacksmith.mod_cmd(s) @item_max = @column_max = @commands.size refresh self.index = 0 end def fix? return (Blacksmith::MOD_CMD.size == 1) end def exit? return (Blacksmith::MOD_CMD[@index] == 2) end def mod return Blacksmith::MOD_CMD[@index] end end #============================================================================== # ■ Sprite_BsTAG #============================================================================== class Sprite_BsTAG < Sprite W = 100 H = 14 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, z, tag) super(Viewport.new(x, y, W, H)) self.viewport.z = z self.bitmap = Bitmap.new(W, H) self.bitmap.font.size = 12 self.bitmap.font.color = Color.new(192, 224, 255, 255) refresh(tag) end def refresh(tag) self.bitmap.clear self.bitmap.draw_text(0, 0, W, H, tag) end end #============================================================================== # ■ Window_BsCtg #============================================================================== class Window_BsCtg < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 64, 480, 64) self.contents = Bitmap.new(width - 32, height - 32) self.z = 200 self.visible = false @type = 0 @index = 0 @index_s = [0, 0] @fix = false end def fix? return @fix end #-------------------------------------------------------------------------- # ● 変更 #-------------------------------------------------------------------------- def change(t) @index_s[@type] = Blacksmith::S_INDEX ? @index : 0 @type = t ct = t == 0 ? Blacksmith::W_CT : Blacksmith::A_CT @commands = [] for i in 0...ct.size @commands[i] = ct[i][0] end @item_max = @column_max = @commands.size refresh @index = @index_s[t] self.cursor_rect.set(@index * self.width / @column_max, 0, 32, 32) @fix = (@type == 0 ? Blacksmith::W_CT.size : Blacksmith::A_CT.size) == 1 self.visible = !@fix end def shift_l draw_item(@index, 128, true) @index = (@index - 1 + @item_max) % @item_max draw_item(@index, 255, true) self.cursor_rect.set(@index * self.width / @column_max, 0, 32, 32) end def shift_r draw_item(@index, 128, true) @index = (@index + 1) % @item_max draw_item(@index, 255, true) self.cursor_rect.set(@index * self.width / @column_max, 0, 32, 32) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_item(i, i == @index ? 255 : 128) end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index, opacity=255, clear=false) x = 4 + index * self.width / @column_max if clear rect = Rect.new(x, 4, 24, 24) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) end bitmap = RPG::Cache.icon(@commands[index]) self.contents.blt(x, 4, bitmap, Rect.new(0, 0, 24, 24), opacity) end end #============================================================================== # ■ Window_BsList #============================================================================== class Window_BsList < Window_Selectable attr_accessor :pt_window attr_accessor :sts_window #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(sys=0, mod=0, ctg=0) super(0, 128, 640-120, 224) @dmy_win = Window_Base.new(x, y, width, height) self.z = 200 @sprite_p = Sprite_BsTAG.new(self.x+350, self.y+2, self.z+10, "価格") @sprite_n = Sprite_BsTAG.new(self.x+440, self.y+2, self.z+10, "所持数") @data = [nil, nil, nil, nil] @tmp_bit = Bitmap.new(1, 1) @bitmap = [[],[],[],[]] @index_s = [[],[],[],[]] @sys = @mod = @ctg = -1 change_t(sys*2+mod, ctg) @pt_window = @sts_window = nil disable end def enable @dmy_win.visible = false self.active = self.visible = @sprite_p.visible = @sprite_n.visible = true end def disable @dmy_win.visible = true self.active = self.visible = @sprite_p.visible = @sprite_n.visible = false end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def dispose super for t in 0...@bitmap.size dispose_bitmap(t) end @dmy_win.dispose @sprite_p.dispose @sprite_n.dispose end def dispose_bitmap(t) return if @bitmap[t].nil? or @bitmap[t].empty? for b in @bitmap[t] unless b.nil? b.dispose b = nil end end end #-------------------------------------------------------------------------- # ● 動作タイプ #-------------------------------------------------------------------------- C_W=0;C_A=1;S_W=2;S_A=3 def type return (@sys*2 + @mod) end def type=(t) @sys = t / 2 @mod = t % 2 @sprite_p.refresh(@sys==0 ? "価格" : "装備") end def category(t) case t when Blacksmith::C_W, Blacksmith::S_W; return Blacksmith::W_CT.size when Blacksmith::C_A, Blacksmith::S_A; return Blacksmith::A_CT.size end return 0 end def sys_create? return (@sys == 0) end #-------------------------------------------------------------------------- # ● モード切り替え #-------------------------------------------------------------------------- def change_t(t, c=0) if self.type != t push_index(self.type, @ctg) self.type = t @ctg = c refresh_data(t) if @data[t].nil? self.contents = @bitmap[t][c] @item_max = @data[t][c].size pop_index(t, c) else change_c(c) end end def change_c(c) if @ctg != c push_index(self.type, @ctg) t = self.type @ctg = c self.contents = @bitmap[t][c] @item_max = @data[t][c].size pop_index(t, c) else pop_index(self.type, c) end end def pop_index(t, c) self.index = (@index_s[t][c] < 0 ? 0 : @index_s[t][c]) end def push_index(t, c) return if t < 0 or c < 0 @index_s[t][c] = Blacksmith::S_INDEX ? @index : 0 end #-------------------------------------------------------------------------- # ● データ初期化 #-------------------------------------------------------------------------- def refresh_data(t) case t when C_W; @data[t] = $game_system.bs.c_w.make_list when C_A; @data[t] = $game_system.bs.c_a.make_list when S_W; @data[t] = $game_system.bs.s_w.make_list when S_A; @data[t] = $game_system.bs.s_a.make_list end refresh_t_bitmap(t) end #-------------------------------------------------------------------------- # ● ビットマップ初期化 #-------------------------------------------------------------------------- def refresh_t_bitmap(t) dispose_bitmap(t) @bitmap[t] = [] @index_s[t] = [] for c in 0...category(t) refresh_bitmap(t, c) end end #-------------------------------------------------------------------------- # ● カテゴリビットマップ初期化 #-------------------------------------------------------------------------- def refresh_bitmap(t, c) num = @data[t][c].size num = num == 0 ? 1 : num @bitmap[t][c].dispose unless @bitmap[t][c].nil? @bitmap[t][c] = Bitmap.new(self.width - 32, num * 32) @bitmap[t][c].font.color = normal_color @index_s[t][c] = -1 refresh(t, c) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(t, c) self.contents = @bitmap[t][c] @item_max = @data[t][c].size for i in 0...@item_max draw_i(t, c, i) end end #-------------------------------------------------------------------------- # ● 差分リフレッシュ #-------------------------------------------------------------------------- def diff_refresh for t in 0...@bitmap.size refresh_data(t) unless @data[t].nil? end t = self.type c = @ctg self.contents = @bitmap[t][c] @item_max = @data[t][c].size self.index = @index >= @data[t][c].size ? (@data[t][c].size-1) : @index end #-------------------------------------------------------------------------- # ● 項目描画 #-------------------------------------------------------------------------- def draw_i(t, c, i) itm = data_i(t, c, i) op = itm.enable? ? 255 : 128 self.contents.font.color.alpha = op x = 4 y = i * 32 draw_item_name(itm.obj, x, y, op) if t / 2 == 0 # create self.contents.draw_text(x+170, y, 200, 32, itm.price.to_s, 2) self.contents.draw_text(x+270, y, 200, 32, itm.num.to_s, 2) else if itm.equip_actors.size > 0 self.contents.draw_text(x+170, y, 200, 32, "[E]", 2) end self.contents.draw_text(x+270, y, 200, 32, itm.num.to_s, 2) end end #-------------------------------------------------------------------------- # ● アイテム名の描画 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, opacity=255) return if item == nil bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name) end #-------------------------------------------------------------------------- # ● アイテム取得 #-------------------------------------------------------------------------- def item_list return @data[self.type][@ctg] end def data_i(t, c, i) return nil if i < 0 or i >= @data[t][c].size return @data[t][c][i] end def data return data_i(self.type, @ctg, @index) end def item_i(t, c, i) return nil if i < 0 or i >= @data[t][c].size return @data[t][c][i].obj end def item return item_i(self.type, @ctg, @index) end #-------------------------------------------------------------------------- # ● 有効Index? #-------------------------------------------------------------------------- def enable_i?(t, c, i) d = data_i(t, c, i) return (d.nil? ? false : d.enable?) end def enable? return enable_i?(self.type, @ctg, @index) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(item == nil ? "" : item.description) @pt_window.item = @sts_window.item = self.data end end #============================================================================== # ■ Window_BsSList #============================================================================== class Window_BsSList < Window_Selectable attr_accessor :pt_window attr_accessor :sts_window OFFSET = 20 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @b_win = Window_BsSListBack.new super(@b_win.x+OFFSET, @b_win.y + 32, @b_win.width-OFFSET, @b_win.height-32) self.z = @b_win.z + 10 @data = nil @pt_window = @sts_window = nil self.opacity = 0 disable end def dispose @b_win.dispose super end def disable self.active = self.visible = @b_win.visible = false end #-------------------------------------------------------------------------- # ● 起動 #-------------------------------------------------------------------------- def startup(data) self.active = self.visible = @b_win.visible = true if @data != data @data = data @slist = @data.make_slist @item_max = @slist.size self.contents.dispose unless self.contents.nil? self.contents = Bitmap.new(self.width - 32, (@item_max+1) * 32) self.contents.font.color = normal_color refresh end self.index = 0 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh @b_win.refresh(@data.obj) self.contents.clear for i in 0...@item_max draw_i(i) end end #-------------------------------------------------------------------------- # ● 項目描画 #-------------------------------------------------------------------------- def draw_i(i) itm = data_i(i) op = enable_i?(i) ? 255 : 128 self.contents.font.color.alpha = op x = 4 y = i * 32 draw_item_name(itm.obj, x, y, op) self.contents.draw_text(x+170-OFFSET, y, 200, 32, itm.price.to_s, 2) self.contents.draw_text(x+270-OFFSET, y, 200, 32, itm.num.to_s, 2) end #-------------------------------------------------------------------------- # ● アイテム名の描画 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, opacity=255) return if item == nil bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name) end #-------------------------------------------------------------------------- # ● アイテム取得 #-------------------------------------------------------------------------- def data_i(i) return nil if i < 0 return @slist[i] end def data return data_i(@index) end def item_i(i) return nil if i < 0 return @slist[i].obj end def item return item_i(@index) end #-------------------------------------------------------------------------- # ● 有効Index? #-------------------------------------------------------------------------- def enable_i?(i) return data_i(i).enable? end def enable? return enable_i?(@index) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(item == nil ? "" : item.description) @pt_window.item = @sts_window.item = self.data end end #============================================================================== # ■ Window_BsSListBack #============================================================================== class Window_BsSListBack < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 128, 640-120, 224) self.z = 300 @sprite_p = Sprite_BsTAG.new(self.x+350, self.y+2, self.z+10, "価格") @sprite_n = Sprite_BsTAG.new(self.x+440, self.y+2, self.z+10, "所持数") self.contents = Bitmap.new(width - 32, 32) self.contents.font.color = normal_color end def dispose super @sprite_p.dispose @sprite_n.dispose end def visible=(v) super(v) @sprite_p.visible = @sprite_n.visible = v end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(item) self.contents.clear self.draw_item_name(item, 4, 0) end end #============================================================================== # ■ Window_BsActors #============================================================================== class Window_BsActors < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(640-120, 128, 120, 224) @hh = (height - 32) / 4 @item = 0 @index = -1 @enable = [] @item_max = $game_party.actors.size self.contents = Bitmap.new(width - 32, [height - 32, row_max * @hh].max) self.item = nil end def enable? return false if @index < 0 or @enable[@index].nil? return @enable[@index] end def actor return nil if @index < 0 return $game_party.actors[@index] end #-------------------------------------------------------------------------- # ● アイテムの設定 # item : 新しいアイテム #-------------------------------------------------------------------------- def item=(item) if @item != item @item = item refresh end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(list=[]) self.contents.clear for i in 0...$game_party.actors.size actor = $game_party.actors[i] y = i * @hh e = @item.nil? ? false : actor.equippable?(@item.obj) e = list.include?(i) if e and !list.empty? @enable[i] = e draw_actor_graphic(actor, 4, y, e ? 255 : 128) next if @item.nil? or !e case @item.obj when RPG::Weapon diff = actor.v_equip(0, @item.obj.id, 0) - actor.atk draw_item_diff(28, y, diff, e) when RPG::Armor kind = @item.obj.kind + 1 diff = actor.v_equip(kind, @item.obj.id, 1) - actor.pdef diff += actor.v_equip(kind, @item.obj.id, 2) - actor.mdef draw_item_diff(28, y, diff, e) end end end #-------------------------------------------------------------------------- # ● グラフィックの描画 #-------------------------------------------------------------------------- def draw_actor_graphic(actor, x, y, opacity=255) bitmap = RPG::Cache.character(actor.character_name, actor.character_hue) src_rect = Rect.new(0, 0, bitmap.width / 4, bitmap.height / 4) self.contents.blt(x, y, bitmap, src_rect, opacity) end #-------------------------------------------------------------------------- # ● 装備差分値の描画 #-------------------------------------------------------------------------- def draw_item_diff(x, y, change, able) if !able self.contents.font.color = normal_color self.contents.font.color.alpha = 128 elsif change > 0 self.contents.font.color = crisis_color elsif change < 0 self.contents.font.color = normal_color self.contents.font.color.alpha = 128 else self.contents.font.color = normal_color end self.contents.draw_text(x, y, self.contents.width-x-4, @hh, sprintf("%+d", change), 2) end #-------------------------------------------------------------------------- # ● 先頭の行の取得 #-------------------------------------------------------------------------- def top_row # ウィンドウ内容の転送元 Y 座標を、1 行の高さ 32 で割る return self.oy / @hh end #-------------------------------------------------------------------------- # ● 先頭の行の設定 # row : 先頭に表示する行 #-------------------------------------------------------------------------- def top_row=(row) # row が 0 未満の場合は 0 に修正 if row < 0 row = 0 end # row が row_max - 1 超の場合は row_max - 1 に修正 if row > row_max - 1 row = row_max - 1 end # row に 1 行の高さ 32 を掛け、ウィンドウ内容の転送元 Y 座標とする self.oy = row * @hh end #-------------------------------------------------------------------------- # ● 1 ページに表示できる行数の取得 #-------------------------------------------------------------------------- def page_row_max # ウィンドウの高さから、フレームの高さ 32 を引き、1 行の高さ 32 で割る return (self.height - 32) / @hh end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect # カーソル位置が 0 未満の場合 if @index < 0 self.cursor_rect.empty return end # 現在の行を取得 row = @index / @column_max # 現在の行が、表示されている先頭の行より前の場合 if row < self.top_row # 現在の行が先頭になるようにスクロール self.top_row = row end # 現在の行が、表示されている最後尾の行より後ろの場合 if row > self.top_row + (self.page_row_max - 1) # 現在の行が最後尾になるようにスクロール self.top_row = row - (self.page_row_max - 1) end # カーソルの幅を計算 cursor_width = self.width / @column_max - 32 # カーソルの座標を計算 x = @index % @column_max * (cursor_width + 32) y = @index / @column_max * @hh - self.oy # カーソルの矩形を更新 self.cursor_rect.set(x, y, cursor_width, @hh) end end #============================================================================== # ■ Window_BsStatus #============================================================================== class Window_BsStatus < Window_Base M_ITEM = 0 # アイテムステータス M_PARTY = 1 # パーティーステータス M_ACTOR = 2 # アクターステータス PATTERN = Blacksmith::ST_PTN # 切り替えの並び順 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(type=0) super(0, 480-128, 640, 128) self.contents = Bitmap.new(width - 32, height - 32) @item = nil @type = type mode_reset(type) refresh end def fix? return (PATTERN.size <= 1) end #-------------------------------------------------------------------------- # ● アイテムの設定 # item : 新しいアイテム #-------------------------------------------------------------------------- def item=(item) if @item != item @item = item refresh end end #-------------------------------------------------------------------------- # ● モードチェンジ #-------------------------------------------------------------------------- def change_mode if @mode == M_ACTOR @actor_idx += 1 if @actor_idx == $game_party.actors.size @actor_idx = 0 next_mode_t end refresh else next_mode_t refresh end end def mode_reset(type) @mode = M_ITEM @type = type next_mode if @type == 1 and !fix? @actor_idx = 0 end def next_mode_t next_mode next_mode if @type == 1 and @mode == M_ITEM and !fix? end def next_mode @mode = PATTERN[((PATTERN.index(@mode) + 1) % PATTERN.size)] end #-------------------------------------------------------------------------- # ● アイテム名の描画 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, opacity=255) return if item == nil bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear return if @item == nil case @mode when M_PARTY; refresh_party when M_ACTOR; refresh_actor when M_ITEM; refresh_item end end #-------------------------------------------------------------------------- # ● リフレッシュ : M_PARTY #-------------------------------------------------------------------------- def refresh_party item = @item.obj # 装備品追加情報 for i in 0...$game_party.actors.size # アクターを取得 actor = $game_party.actors[i] x = 154*i case item when RPG::Item draw_actor_name(actor, x, 0) draw_actor_hp(actor, x, 32) draw_actor_sp(actor, x, 64) when RPG::Weapon, RPG::Armor # 装備可能なら通常文字色に、不可能なら無効文字色に設定 able = actor.equippable?(item) self.contents.font.color = normal_color self.contents.font.color.alpha = able ? 255 : 128 # アクターの名前を描画 self.contents.draw_text(x, 0, 120, 32, actor.name) next unless able if @item.obj.is_a?(RPG::Weapon) diff = actor.v_equip(0, @item.obj.id, 0) - actor.atk draw_item_diff(x, 32, $data_system.words.atk, diff, able) elsif @item.obj.is_a?(RPG::Armor) kind = @item.obj.kind + 1 pdiff = actor.v_equip(kind, @item.obj.id, 1) - actor.pdef mdiff = actor.v_equip(kind, @item.obj.id, 2) - actor.mdef draw_item_diff(x, 32, $data_system.words.pdef, pdiff, able) draw_item_diff(x, 64, $data_system.words.mdef, mdiff, able) end end end end def draw_item_diff(x, y, word, change, able) self.contents.font.color = system_color self.contents.font.color.alpha = able ? 255 : 128 self.contents.draw_text(x, y, 112, 32, word) if !able self.contents.font.color = normal_color self.contents.font.color.alpha = 128 elsif change > 0 self.contents.font.color = crisis_color elsif change < 0 self.contents.font.color = normal_color self.contents.font.color.alpha = 128 else self.contents.font.color = normal_color end self.contents.draw_text(x+22, y, 112, 32, sprintf("%+d", change), 2) end #-------------------------------------------------------------------------- # ● リフレッシュ : M_ACTOR #-------------------------------------------------------------------------- def refresh_actor actor = $game_party.actors[@actor_idx] able = @item.obj.is_a?(RPG::Item) ? true : actor.equippable?(@item.obj) type = @item.obj.is_a?(RPG::Item) ? -1 : (@item.obj.is_a?(RPG::Weapon) ? 0 : (@item.obj.kind + 1) ) self.contents.font.color = normal_color self.contents.font.color.alpha = able ? 255 : 128 self.contents.draw_text(0, 0, 120, 32, actor.name) case @item.obj when RPG::Item draw_actor_level(actor, 154, 0) when RPG::Weapon draw_item_name($data_weapons[actor.weapon_id], 154, 0, able ? 255 : 128) when RPG::Armor case @item.obj.kind when 0; item1 = $data_armors[actor.armor1_id] when 1; item1 = $data_armors[actor.armor2_id] when 2; item1 = $data_armors[actor.armor3_id] when 3; item1 = $data_armors[actor.armor4_id] end draw_item_name(item1, 154, 0, able ? 255 : 128) end pos = [ [0, 32], [154, 32], [154, 64], [308, 32], [308, 64], [462, 32], [462, 64] ] word = [$data_system.words.atk, $data_system.words.pdef, $data_system.words.mdef, $data_system.words.str, $data_system.words.dex, $data_system.words.agi, $data_system.words.int, ] now = [ actor.atk, actor.pdef, actor.mdef, actor.str, actor.dex, actor.agi, actor.int ] new = able ? [ actor.v_equip(type, @item.obj.id, 0), actor.v_equip(type, @item.obj.id, 1), actor.v_equip(type, @item.obj.id, 2), actor.v_equip(type, @item.obj.id, 3), actor.v_equip(type, @item.obj.id, 4), actor.v_equip(type, @item.obj.id, 5), actor.v_equip(type, @item.obj.id, 6) ] : now for i in 0...pos.size draw_item_diff2(pos[i][0], pos[i][1], word[i], able, now[i], new[i]) end end def draw_item_diff2(x, y, word, able, now, new) self.contents.font.color = system_color self.contents.font.color.alpha = able ? 255 : 128 self.contents.draw_text(x, y, 112, 32, word) if !able self.contents.font.color = normal_color self.contents.font.color.alpha = 128 elsif now < new self.contents.font.color = crisis_color elsif now > new self.contents.font.color = normal_color self.contents.font.color.alpha = 128 else self.contents.font.color = normal_color end self.contents.draw_text(x+22, y, 112, 32, new.to_s, 2) end #-------------------------------------------------------------------------- # ● リフレッシュ : M_ITEM #-------------------------------------------------------------------------- def refresh_item return if @type == 1 self.contents.font.color = normal_color w = self.contents.width / 2 for i in 0...@item.size x = 4 + (i / 3) % 2 * w y = i % 3 * 32 op = @item.cond[i].enable ? 255 : 128 self.contents.font.color.alpha = op draw_item_name(@item.cond[i].obj, x, y, op) self.contents.draw_text(x+190, y, 96, 32, "×") self.contents.draw_text(x+w-8-60-96, y, 96, 32, @item.cond[i].num.to_s, 2) self.contents.draw_text(x+250, y, 96, 32, ":") self.contents.draw_text(x+w-8-8-96, y, 96, 32, @item.cond[i].pt_num.to_s, 2) end end end #============================================================================== # ■ Window_BsItemInfo #============================================================================== class Window_BsItemInfo < Window_Base #---------------------------------------------------------------------------- TEXT_H = 32 # 文字高さ ES_W = 4 # 属性・ステート間隔 SCOPE = ["なし", "敵単体", "敵全体", "味方単体", "味方全体", "味方単体蘇生", "味方全体蘇生", "使用者"] #OCCASION = ["常時使用可能", "戦闘のみ", "マップ上のみ", "使用不可"] # 属性・ステート表示方法(true:アイコン false:文字) USE_ICON = Blacksmith::USE_ICON #---------------------------------------------------------------------------- # 属性・ステート用アイコン(USE_ICON=trueの時のみ) ELE_ICON = Blacksmith::ELE_ICON STT_ICON = Blacksmith::STT_ICON # 表示しない属性 ELE_NOT_SHOW = Blacksmith::ELE_NOT_SHOW # 表示しないステート STT_NOT_SHOW = Blacksmith::STT_NOT_SHOW # 表示最大数(属性) ELE_MAX = Blacksmith::ELE_MAX # 表示最大数(ステート) STT_MAX = Blacksmith::STT_MAX #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(160, 64, 480, 288) self.contents = Bitmap.new(width - 32, height - 32) self.back_opacity = 200 self.visible = false self.z = 700 @data = nil end def item=(data) return if @data == data @data = data refresh(data) end #-------------------------------------------------------------------------- # ● リフレッシュ # data : RPG::Item / RPG::Weapon / RPG::Armor / RPG::Skill #-------------------------------------------------------------------------- def refresh(data) self.contents.clear return if data.nil? draw_item_name(data, indent(0), 0) #self.contents.draw_text(indent(1), TEXT_H, contents.width-indent(1), TEXT_H, data.description) #self.contents.fill_rect(0, TEXT_H*2, contents.width, 2, Color.new(255,255,255,128)) case data when RPG::Item; draw_item_info(data) when RPG::Weapon; draw_weapon_info(data) when RPG::Armor; draw_armor_info(data) end end #-------------------------------------------------------------------------- # ● Line計算 #-------------------------------------------------------------------------- def line(n) return TEXT_H * n + 4 end #-------------------------------------------------------------------------- # ● インデント #-------------------------------------------------------------------------- def indent(n) case n when 0; return 4 when 1; return 24 when 2; return 24+96 when 3; return 248 when 4; return 248+96 when 5; return 160 end return 0 end #-------------------------------------------------------------------------- # ● アイコン描画(Graphics/Icons内の画像を表示) #-------------------------------------------------------------------------- def draw_icon(x, y, file_name) return 0 if file_name.nil? or file_name == "" bit = RPG::Cache.icon(file_name) src_rect = Rect.new(0, 0, bit.width, bit.height) yy = (TEXT_H - bit.height) / 2 self.contents.blt(x, y+yy, bit, src_rect) return bit.width + ES_W end #-------------------------------------------------------------------------- # ● 属性描画 #-------------------------------------------------------------------------- def draw_elements(elements, x, y) cnt = 0 xx = 0 for id in elements next if ELE_NOT_SHOW.include?(id) break if cnt == ELE_MAX if USE_ICON xx += draw_icon(x+xx, y, ELE_ICON[id]) else rect = self.contents.text_size($data_system.elements[id]) break if (x+xx+rect.width) > contents.width self.contents.draw_text(x+xx, y, rect.width, TEXT_H, $data_system.elements[id]) xx += rect.width + ES_W end cnt += 1 end end #-------------------------------------------------------------------------- # ● ステート描画 #-------------------------------------------------------------------------- def draw_states(states, x, y) cnt = 0 xx = 0 for id in states next if STT_NOT_SHOW.include?(id) break if cnt == STT_MAX if USE_ICON xx += draw_icon(x+xx, y, STT_ICON[id]) else rect = self.contents.text_size($data_states[id].name) break if (x+xx+rect.width) > contents.width self.contents.draw_text(x+xx, y, rect.width, TEXT_H, $data_states[id].name) xx += rect.width + ES_W end cnt += 1 end end #-------------------------------------------------------------------------- # ● Item情報描画 # data : アイテム(RPG::Item) #-------------------------------------------------------------------------- def draw_item_info(data) # 消耗品 if data.consumable self.contents.font.color = system_color self.contents.draw_text(300, 0, 200, TEXT_H, "【消耗品】") end l = 1 # 行 # 範囲と命中率 if data.scope != 0 self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 200, TEXT_H, "範囲") if data.hit < 100 self.contents.draw_text(indent(3), line(l), 200, TEXT_H, "命中率") end self.contents.font.color = normal_color self.contents.draw_text(indent(2), line(l), 200, TEXT_H, SCOPE[data.scope]) if data.hit < 100 self.contents.draw_text(indent(4), line(l), 200, TEXT_H, data.hit.to_s+" %") end l += 1 end # HP/SP増減、パラメータ変化 hpspparam = false sys_l = l hp = "#{$data_system.words.hp}" sp = "#{$data_system.words.sp}" if data.recover_hp_rate != 0 hpspparam = true pm = data.recover_hp_rate >= 0 ? "回復" : "ダメージ" text = "最大#{hp}の#{data.recover_hp_rate.abs}%#{pm}" self.contents.draw_text(indent(2), line(l), 300, TEXT_H, text) l += 1 end if data.recover_hp != 0 hpspparam = true pm = data.recover_hp >= 0 ? "回復" : "ダメージ" text = "#{hp} #{data.recover_hp.abs}#{pm}" self.contents.draw_text(indent(2), line(l), 300, TEXT_H, text) l += 1 end if data.recover_sp_rate != 0 hpspparam = true pm = data.recover_sp_rate >= 0 ? "回復" : "ダメージ" text = "最大#{sp}の#{data.recover_sp_rate.abs}%#{pm}" self.contents.draw_text(indent(2), line(l), 300, TEXT_H, text) l += 1 end if data.recover_sp != 0 hpspparam = true pm = data.recover_sp >= 0 ? "回復" : "ダメージ" text = "#{sp} #{data.recover_sp.abs}#{pm}" self.contents.draw_text(indent(2), line(l), 300, TEXT_H, text) l += 1 end if data.parameter_type != 0 # パラメータ変化効果あり hpspparam = true param = ["なし", "最大#{hp}", "最大#{sp}", $data_system.words.str, $data_system.words.dex, $data_system.words.agi, $data_system.words.int][data.parameter_type] pm = data.parameter_points >= 0 ? "+" : "-" text = "#{param} #{pm}#{data.parameter_points}" self.contents.draw_text(indent(2), line(l), 300, TEXT_H, text) l += 1 end if hpspparam self.contents.font.color = system_color self.contents.draw_text(indent(1), line(sys_l), 100, TEXT_H, "効果") end # 属性 unless data.element_set.empty? self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 100, TEXT_H, "属性") self.contents.font.color = normal_color draw_elements(data.element_set, indent(2), line(l)) l += 1 end # 付与ステート unless data.plus_state_set.empty? self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 140, TEXT_H, "付与ステート") self.contents.font.color = normal_color draw_states(data.plus_state_set, indent(5), line(l)) l += 1 end # 解除ステート unless data.minus_state_set.empty? self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 140, TEXT_H, "解除ステート") self.contents.font.color = normal_color draw_states(data.minus_state_set, indent(5), line(l)) l += 1 end end #-------------------------------------------------------------------------- # ● Weapon情報描画 # data : 武器(RPG::Weapon) #-------------------------------------------------------------------------- def draw_weapon_info(data) self.contents.font.color = system_color self.contents.draw_text(300, 0, 200, TEXT_H, "【#{$data_system.words.weapon}】") self.contents.draw_text(indent(1), line(1), 200, TEXT_H, $data_system.words.atk) #self.contents.draw_text(indent(3), line(1), 200, TEXT_H, "命中率") self.contents.font.color = normal_color self.contents.draw_text(indent(2), line(1), 50, TEXT_H, data.atk.to_s, 2) #self.contents.draw_text(indent(4), line(1), 200, TEXT_H, data.hit.to_s) # 100%固定なので表示しない list = [] list.push([$data_system.words.pdef, data.pdef]) list.push([$data_system.words.mdef, data.mdef]) list.push([$data_system.words.str, data.str_plus]) list.push([$data_system.words.dex, data.dex_plus]) list.push([$data_system.words.agi, data.agi_plus]) list.push([$data_system.words.int, data.int_plus]) i = 0 l = 1 for pram in list l += 1 if i == 0 self.contents.font.color = system_color self.contents.draw_text(indent(1+i), line(l), 200, TEXT_H, pram[0]) self.contents.font.color = normal_color self.contents.draw_text(indent(2+i), line(l), 50, TEXT_H, pram[1].to_s, 2) i = (i == 2 ? 0 : 2) end l += 1 # 属性 unless data.element_set.empty? self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 100, TEXT_H, "属性") self.contents.font.color = normal_color draw_elements(data.element_set, indent(2), line(l)) l += 1 end # 付与ステート unless data.plus_state_set.empty? self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 140, TEXT_H, "付与ステート") self.contents.font.color = normal_color draw_states(data.plus_state_set, indent(5), line(l)) l += 1 end # 解除ステート unless data.minus_state_set.empty? self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 140, TEXT_H, "解除ステート") self.contents.font.color = normal_color draw_states(data.minus_state_set, indent(5), line(l)) l += 1 end end #-------------------------------------------------------------------------- # ● Armor情報描画 # data : 防具(RPG::Armor) #-------------------------------------------------------------------------- def draw_armor_info(data) self.contents.font.color = system_color kind = [$data_system.words.armor1, $data_system.words.armor2, $data_system.words.armor3, $data_system.words.armor4][data.kind] self.contents.draw_text(300, 0, 200, TEXT_H, "【#{kind}】") self.contents.draw_text(indent(1), line(1), 200, TEXT_H, $data_system.words.pdef) self.contents.draw_text(indent(3), line(1), 200, TEXT_H, $data_system.words.mdef) self.contents.font.color = normal_color self.contents.draw_text(indent(2), line(1), 50, TEXT_H, data.pdef.to_s, 2) self.contents.draw_text(indent(4), line(1), 50, TEXT_H, data.mdef.to_s, 2) l = 2 # 行 self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 200, TEXT_H, "回避修正") self.contents.font.color = normal_color self.contents.draw_text(indent(2), line(l), 50, TEXT_H, data.eva.to_s, 2) # 能力補正 i = 0 # インデント補正 list = [] list.push([$data_system.words.str, data.str_plus]) list.push([$data_system.words.dex, data.dex_plus]) list.push([$data_system.words.agi, data.agi_plus]) list.push([$data_system.words.int, data.int_plus]) for pram in list l += 1 if i == 0 self.contents.font.color = system_color self.contents.draw_text(indent(1+i), line(l), 200, TEXT_H, pram[0]) self.contents.font.color = normal_color self.contents.draw_text(indent(2+i), line(l), 50, TEXT_H, pram[1].to_s, 2) i = (i == 2 ? 0 : 2) end l += 1 # オートステート if data.auto_state_id != 0 self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 140, TEXT_H, "オートステート") self.contents.font.color = normal_color draw_states([data.auto_state_id], indent(5), line(l)) l += 1 end # 属性防御 unless data.guard_element_set.empty? self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 100, TEXT_H, "属性防御") self.contents.font.color = normal_color draw_elements(data.guard_element_set, indent(2), line(l)) l += 1 end # ステート防御 unless data.guard_state_set.empty? self.contents.font.color = system_color self.contents.draw_text(indent(1), line(l), 140, TEXT_H, "ステート防御") self.contents.font.color = normal_color draw_states(data.guard_state_set, indent(5), line(l)) l += 1 end end end #============================================================================== # ■ Window_BsYesNo #============================================================================== class Window_BsYesNo < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super((640-240)/2, 180, 240, 100) self.contents = Bitmap.new(width - 32, height - 32) @commands = ["はい", "いいえ"] @column_max = @item_max = @commands.size refresh disable self.z = 500 end def enable self.visible = true self.active = true self.index = 1 end def disable self.visible = false self.active = false end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.draw_text(4, 0, 200, 32, "装備しますか?") for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) x = 4 + index * self.width / @column_max self.contents.draw_text(x, 36, 100, 32, @commands[index]) end #-------------------------------------------------------------------------- # ● 1 ページに表示できる行数の取得 #-------------------------------------------------------------------------- def page_row_max # ウィンドウの高さから、フレームの高さ 32 を引き、1 行の高さ 32 で割る return 1 end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect # カーソル位置が 0 未満の場合 if @index < 0 self.cursor_rect.empty return end # 現在の行を取得 row = @index / @column_max # 現在の行が、表示されている先頭の行より前の場合 if row < self.top_row # 現在の行が先頭になるようにスクロール self.top_row = row end # 現在の行が、表示されている最後尾の行より後ろの場合 if row > self.top_row + (self.page_row_max - 1) # 現在の行が最後尾になるようにスクロール self.top_row = row - (self.page_row_max - 1) end # カーソルの幅を計算 cursor_width = self.width / @column_max - 32 # カーソルの座標を計算 x = @index % @column_max * (cursor_width + 32) y = @index / @column_max * 32 - self.oy + 36 # カーソルの矩形を更新 self.cursor_rect.set(x, y, cursor_width, 32) end end #============================================================================== # ■ Window_BsCaution #============================================================================== class Window_BsCaution < Window_Base include Blacksmith::MesCmd WAIT_TIME = 40 # 表示ウェイト時間[frame] FADE_F = WAIT_TIME / 4 def xx(w) return (640-w)/2 end #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(xx(240), 200, 240, 64) self.contents = Bitmap.new(width - 32, height - 32) @wait = 0 @callback = nil self.z = 600 self.visible = false end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def set_text(type, item=nil) return unless Blacksmith::MESSAGE case type when M_S_C; text = "#{item.name}を生成しました" when M_S_S; text = "#{item.name}に強化しました" when M_N_P; text = "所持金が足りません" when M_N_I; text = "素材が足りません" when M_N_N; text = "これ以上、持てません" when M_E_N: text = "装備できません" when M_E_D; text = "#{item.name}の装備を外しました" when M_E_C; text = "#{item.name}の装備を変更しました" when M_O_I; text = "所持品に入れました" else; p "bad arg", type; return end w = self.contents.text_size(text).width self.width = w + 32 self.x = xx(self.width) self.contents.dispose self.contents = Bitmap.new(w, 32) self.contents.draw_text(0, 0, w, 32, text) @wait = WAIT_TIME self.visible = true self.opacity = self.contents_opacity = 255 set_callback(nil) end #-------------------------------------------------------------------------- # ● Callback登録 #-------------------------------------------------------------------------- def set_callback(callback=nil) if Blacksmith::MESSAGE @callback = callback elsif !callback.nil? # メッセージ表示しない場合はその場で実行 $scene.callback(callback) end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def update super @wait -= 1 if @wait < FADE_F self.opacity = self.contents_opacity = 255 / FADE_F * @wait if @wait == 0 self.visible = false $scene.callback(@callback) unless @callback.nil? set_callback(nil) end end end end