#============================================================================== # ■ VXAce-RGSS3-37 調合屋 [ウィンドウクラス] by Claimh #============================================================================== #============================================================================== # ■ Window_MixtureCmd #============================================================================== class Window_MixtureCmd < Window_HorzCommand attr_reader :window_width #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(y, width) @window_width = width super(0, y) end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max item_max end #-------------------------------------------------------------------------- # ● コマンドリストの作成 #-------------------------------------------------------------------------- def make_command_list add_command("アイテムの調合", :mix) add_command(Vocab::ShopCancel, :cancel) end end #============================================================================== # ■ Window_MixtureList #============================================================================== class Window_MixtureList < Window_Selectable attr_accessor :info_window #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(y, width) @data = $game_system.mix.make_list data_refresh super(0, y, width, Graphics.height - y) refresh end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max @data.size end #-------------------------------------------------------------------------- # ● データリフレッシュ #-------------------------------------------------------------------------- def data_refresh @data.each {|d| d.update_status} self end #-------------------------------------------------------------------------- # ● 項目描画 #-------------------------------------------------------------------------- def draw_item(i) d = data_i(i) r = item_rect(i) change_color(normal_color, d.enable?) draw_item_name(d.obj, r.x, r.y, d.enable?) draw_text(r.x, r.y, contents_width - 8, line_height, d.price.to_s, 2) end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? data.enable? end #-------------------------------------------------------------------------- # ● 決定ボタンが押されたときの処理 #-------------------------------------------------------------------------- def process_ok call_handler(:alert) unless current_item_enabled? super end #-------------------------------------------------------------------------- # ● アイテム取得 #-------------------------------------------------------------------------- def data_i(i) return nil if i < 0 return @data[i] end def data return data_i(@index) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(data.nil? ? "" : data.obj.description) @info_window.data = data unless @info_window.nil? end end #============================================================================== # ■ Window_MixtureInfo #============================================================================== class Window_MixtureInfo < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y) @num = 1 @data = nil super(x, y, Graphics.width - x, Graphics.height - y) end def refresh_num @num = 0 self.num = 1 end def num=(n) return if @num == n @num = n refresh end def data=(d) return if @data == d @data = d refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear return if @data.nil? h = line_height change_color(system_color) draw_text(4, h*0, 200, h, "所持数:") draw_text(4, h*1, 200, h, "調合材料:") change_color(normal_color) draw_text(contents_width-100-4, 0, 100, h, @data.num.to_s, 2) @data.cond.each_index do |i| d = @data.cond[i] draw_item(20, h * 2 + i * h, d) end end #-------------------------------------------------------------------------- # ● アイテム描画 #-------------------------------------------------------------------------- def draw_item(x, y, d) enable = d.enable?(@num) change_color(normal_color, enable) draw_item_name(d.obj, x, y, enable) self.contents.draw_text(x+230, y, 32, line_height, "×") self.contents.draw_text(contents_width-100-4, y, 100, line_height, (d.num*@num).to_s, 2) end end #============================================================================== # ■ Window_MixtureNumber #============================================================================== class Window_MixtureNumber < Window_Selectable attr_reader :number #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(y, width) @item = nil @max = 1 @price = 0 @number = 1 super(20, y + 50, width - 20*2, fitting_height(3)) hide.z = 200 end #-------------------------------------------------------------------------- # ● アイテム、最大個数、価格の設定 #-------------------------------------------------------------------------- def set(data) @data = data @max = data.enable_num @price = data.price @number = 1 show.activate.refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh h = line_height contents.clear draw_item_name(@data.obj, 4, 0) change_color(normal_color) draw_text(178, h, 32, h, "×") draw_text(contents_width-32-4, h, 32, h, @number.to_s, 2) # 合計価格と通貨単位を描画 total_price = @price * @number draw_currency_value(total_price, Vocab.currency_unit, 44, h*2, contents.width - 48) cursor_rect.set(contents_width-28, h, 28, h) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super if active last_number = @number update_number if @number != last_number Sound.play_cursor refresh end end end #-------------------------------------------------------------------------- # ● 個数の更新 #-------------------------------------------------------------------------- def update_number change_number(1) if Input.repeat?(:RIGHT) change_number(-1) if Input.repeat?(:LEFT) change_number(10) if Input.repeat?(:UP) change_number(-10) if Input.repeat?(:DOWN) end #-------------------------------------------------------------------------- # ● 個数の変更 #-------------------------------------------------------------------------- def change_number(amount) @number = [[@number + amount, @max].min, 1].max end #-------------------------------------------------------------------------- # ● 決定ボタンが押されたときの処理 #-------------------------------------------------------------------------- def process_ok if current_item_enabled? Mixture::SUCCESS_SE.nil? ? Sound.play_shop : Mixture::SUCCESS_SE.play Input.update deactivate call_ok_handler else Sound.play_buzzer end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.num = @number end end #============================================================================== # ■ Window_MixtureCaution #============================================================================== class Window_MixtureCaution < Window_Base include Mixture::MesCmd WAIT_TIME = 40 # 表示ウェイト時間[frame] FADE_F = WAIT_TIME / 4 def xx(w) (Graphics.width - w) / 2 end #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(xx(240), 160, 240, fitting_height(1)) @wait = 0 hide.z = 600 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def set_text(type, item=nil) return unless Mixture::MESSAGE case type when M_S_C; text = "#{item.name}を調合しました" when M_N_P; text = "所持金が足りません" when M_N_I; text = "材料が足りません" when M_N_N; text = "これ以上、持てません" else; p "bad arg", type; return end w = text_size(text).width self.width = w + standard_padding * 2 self.x = xx(self.width) self.contents.dispose self.contents = Bitmap.new(w, line_height) draw_text(0, 0, w, line_height, text, 1) @wait = WAIT_TIME show self.opacity = self.contents_opacity = 255 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def update return unless visible super @wait -= 1 if @wait < FADE_F self.opacity = self.contents_opacity = 255 / FADE_F * @wait hide if @wait == 0 end end end