#============================================================================== # ■ XP-RGSS-59 魔法屋 [window] by Claimh #============================================================================== #============================================================================== # ■ Window_SkillShopCmd #============================================================================== class Window_SkillShopCmd < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 64, 480, 64) self.contents = Bitmap.new(width - 32, height - 32) @commands = ["#{$data_system.words.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, 32, @commands[index]) end end #============================================================================== # ■ Window_SkillShopList #============================================================================== class Window_SkillShopList < Window_Selectable attr_accessor :help_window2 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(list) super(0, 128, 400, 480-128) @data = list @item_max = @data.size self.contents = Bitmap.new(width - 32, [height - 32, @item_max * 32].max) 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 * 32 d = data_i(i) e = d.enable self.contents.fill_rect(Rect.new(0, y, self.contents.width, 32), 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, 32, d.price.to_s, 2) end #-------------------------------------------------------------------------- # ● アイテム名の描画 #-------------------------------------------------------------------------- def draw_item_name(item, x, y, enable=true) return if item == nil bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), enable ? 255 : 128) self.contents.draw_text(x + 28, y, 212, 32, item.name) 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 = 80 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(400, 128, 240, 480-128) @item_max = $game_party.actors.size self.contents = Bitmap.new(width - 32, [height - 32, @item_max * 32].max) self.contents.font.color = normal_color make_move_actor if SkillShop::USE_MA @enable = [] for i in 0...@item_max @enable[i] = true end @skill = nil refresh self.index = -1 self.active = false end def make_move_actor @actor_sprite = [] # スプライト張替え for i in 0...@item_max x = 456 y = i * LH + 220 @actor_sprite[i] = Sprite_MoveActor.new(nil, $game_party.actors[i]) @actor_sprite[i].x = x @actor_sprite[i].y = y @actor_sprite[i].z = 160 @actor_sprite[i].move_type = 0 @actor_sprite[i].move_stop = true @actor_sprite[i].setup end end def del_move_actor for i in 0...@item_max @actor_sprite[i].dispose end end #-------------------------------------------------------------------------- # ● 消去 #-------------------------------------------------------------------------- def dispose super del_move_actor if SkillShop::USE_MA end #-------------------------------------------------------------------------- # ● 選択中アクター情報 #-------------------------------------------------------------------------- def actor return $game_party.actors[@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.actors[@index] if actor.skill_learn?(@skill.id) 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.actors[i] unless @skill.nil? if actor.skill_learn?(@skill.id) @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 + 120, y, @enable[i] ? 255 : 128) if SkillShop::USE_MA @actor_sprite[i].move_stop = !@enable[i] else draw_actor_graphic(actor, x+36, y + 76, @enable[i]) end draw_actor_class(actor, x + 80, y + 26) self.contents.draw_text(x + 80, y + 52, 160, 32, text) unless @skill.nil? end #-------------------------------------------------------------------------- # ● グラフィックの描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_actor_graphic(actor, x, y, enable=true) bitmap = RPG::Cache.character(actor.character_name, actor.character_hue) cw = bitmap.width / 4 ch = bitmap.height / 4 src_rect = Rect.new(0, 0, 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, 120, 32, actor.name) end #-------------------------------------------------------------------------- # ● クラスの描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_actor_class(actor, x, y) self.contents.draw_text(x, y, 236, 32, 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, 32, "Lv") self.contents.font.color = normal_color self.contents.font.color.alpha = alpha self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2) end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect super if @index < 0 or !self.active self.cursor_rect.empty else self.cursor_rect.set(0, @index * LH, self.width - 32, LH) end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super if self.active act_update if SkillShop::USE_MA end def act_update for sprite in @actor_sprite sprite.update unless sprite.nil? or sprite.disposed? end 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 (640-w)/2 end #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(xx(240), 200, 240, 64) self.contents = Bitmap.new(width - 32, height - 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, 32) self.contents.draw_text(0, 0, w, 32, 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