#============================================================================== # ■ VX-RGSS2-19 魔法屋 [window] by Claimh #============================================================================== #============================================================================== # ■ Window_SkillShopCmd #============================================================================== class Window_SkillShopCmd < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, WLH + 32, 544-160, WLH + 32) @commands = ["#{$data_system.terms.skill}の購入", "やめる"] @item_max = @column_max = @commands.size refresh self.index = 0 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 / 2 self.contents.draw_text(x, 0, 300, WLH, @commands[index]) end end #============================================================================== # ■ Window_SkillShopList #============================================================================== class Window_SkillShopList < Window_Selectable attr_accessor :help_window2 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(list) super(0, (WLH+32)*2, 304, 416-(WLH+32)*2) @data = list @item_max = @data.size create_contents self.contents.font.color = normal_color @help_window2 = nil refresh self.index = -1 self.active = false end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def diff_refresh for i in 0...@item_max d = data_i(i) e = d.enable if e != d.enable? draw_i(i, true) end end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_i(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_i(i, clear=false) y = i * WLH d = data_i(i) e = d.enable self.contents.fill_rect(Rect.new(0, y, self.contents.width, WLH), Color.new(0, 0, 0, 0)) if clear self.contents.font.color.alpha = e ? 255 : 128 draw_item_name(d.obj, 4, y, e) self.contents.draw_text(self.contents.width-100-4, y, 100, WLH, d.price.to_s, 2) end #-------------------------------------------------------------------------- # ● データ取得 #-------------------------------------------------------------------------- def data_i(i) return nil if i < 0 return @data[i] end def data return data_i(@index) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help d = data @help_window.set_text(d.nil? ? "" : d.obj.description) @help_window2.set_skill(d) unless @help_window2.nil? end end #============================================================================== # ■ Window_SkillShopActor #============================================================================== class Window_SkillShopActor < Window_Selectable LH = 68 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(304, (WLH+32)*2, 544-304, 416-(WLH+32)*2) @item_max = $game_party.members.size create_contents self.contents.font.color = normal_color @enable = [] for i in 0...@item_max @enable[i] = true end @skill = nil refresh self.index = -1 self.active = false end #-------------------------------------------------------------------------- # ● 選択中アクター情報 #-------------------------------------------------------------------------- def actor return $game_party.members[@index] end def enable return @enable[@index] end #-------------------------------------------------------------------------- # ● 選択スキルの変更 #-------------------------------------------------------------------------- def set_skill(skill) if @skill != skill @skill = skill refresh end end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_i(i) end end def message actor = $game_party.members[@index] if actor.skill_learn?(@skill.obj) return SkillShop::MesCmd::M_N_N elsif !@skill.learn?(actor) return SkillShop::MesCmd::M_N_S end end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_i(i, clear=false) x = 4 y = i * LH actor = $game_party.members[i] unless @skill.nil? if actor.skill_learn?(@skill.obj) @enable[i] = false text = "[習得済み]" elsif !@skill.learn?(actor) @enable[i] = false text = "[習得不可]" else @enable[i] = true text = "[未修得]" end else @enable[i] = false end self.contents.font.color.alpha = @enable[i] ? 255 : 128 self.contents.fill_rect(Rect.new(0, y, self.contents.width, LH), Color.new(0, 0, 0, 0)) if clear draw_actor_name(actor, x, y) draw_actor_level(actor, x + 140, y, @enable[i] ? 255 : 128) draw_actor_graphic(actor, x+36, y + 60, @enable[i]) draw_actor_class(actor, x + 80, y + 22) self.contents.draw_text(x + 80, y + 22*2, 160, WLH, text) unless @skill.nil? end #-------------------------------------------------------------------------- # ● グラフィックの描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_actor_graphic(actor, x, y, enable=true) return if actor.character_name == nil bitmap = Cache.character(actor.character_name) sign = actor.character_name[/^[\!\$]./] if sign != nil and sign.include?('$') cw = bitmap.width / 3 ch = bitmap.height / 4 else cw = bitmap.width / 12 ch = bitmap.height / 8 end n = actor.character_index src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch) self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect, enable ? 255 : 128) end #-------------------------------------------------------------------------- # ● 名前の描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_actor_name(actor, x, y) self.contents.draw_text(x, y, 108, WLH, actor.name) end #-------------------------------------------------------------------------- # ● クラスの描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_actor_class(actor, x, y) self.contents.draw_text(x, y, 108, WLH, actor.class.name) end #-------------------------------------------------------------------------- # ● レベルの描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_actor_level(actor, x, y, alpha=255) self.contents.font.color = system_color self.contents.font.color.alpha = alpha self.contents.draw_text(x, y, 32, WLH, Vocab::level_a) self.contents.font.color = normal_color self.contents.font.color.alpha = alpha self.contents.draw_text(x + 32, y, 24, WLH, actor.level, 2) end #-------------------------------------------------------------------------- # ● ウィンドウ内容の作成 #-------------------------------------------------------------------------- def create_contents self.contents.dispose self.contents = Bitmap.new(width - 32, [height - 32, row_max * LH].max) end #-------------------------------------------------------------------------- # ● 先頭の行の取得 #-------------------------------------------------------------------------- def top_row return self.oy / LH end #-------------------------------------------------------------------------- # ● 先頭の行の設定 # row : 先頭に表示する行 #-------------------------------------------------------------------------- def top_row=(row) row = 0 if row < 0 row = row_max - 1 if row > row_max - 1 self.oy = row * LH end #-------------------------------------------------------------------------- # ● 1 ページに表示できる行数の取得 #-------------------------------------------------------------------------- def page_row_max return (self.height - 32) / LH end #-------------------------------------------------------------------------- # ● 項目を描画する矩形の取得 # index : 項目番号 #-------------------------------------------------------------------------- def item_rect(index) rect = Rect.new(0, 0, 0, 0) rect.width = (contents.width + @spacing) / @column_max - @spacing rect.height = LH rect.x = index % @column_max * (rect.width + @spacing) rect.y = index / @column_max * LH return rect end end #============================================================================== # ■ Window_SkillShopCaution #============================================================================== class Window_SkillShopCaution < Window_Base include SkillShop::MesCmd WAIT_TIME = 40 # 表示ウェイト時間[frame] FADE_F = WAIT_TIME / 4 def xx(w) return (544-w)/2 end #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(xx(240), 160, 240, WLH+32) @wait = 0 self.z = 600 self.visible = false end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def set_text(type, item=nil) return unless SkillShop::MESSAGE case type when M_S_C; text = "#{item.name}を習得しました" when M_N_P; text = "所持金が足りません" when M_N_S; text = "習得できません" when M_N_N; 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, WLH) self.contents.draw_text(0, 0, w, WLH, text) @wait = WAIT_TIME self.visible = true self.opacity = self.contents_opacity = 255 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def update super @wait -= 1 if @wait < FADE_F self.opacity = self.contents_opacity = 255 / FADE_F * @wait self.visible = false if @wait == 0 end end end