# ▽△▽ XRXSv51. リサイクルショップ ▽△▽ # # publish 2011/ 1/ 4 # update - /11b # #============================================================================== # カスタマイズポイント #============================================================================== module XRXSV51 # # トラッシュの売却は、基本価格の何%にする? # TrashPriceRate = 20 # # リサイクルに必要な素材数 # NeedtoFix = 2 # # ラピッド売却モードを有効にする? # RapidSelling = true # # 価格 0 のアイテムはリサイクル素材消費を禁止する? # EssentialItemDecomposeBan = true # # 店員フェイスネーム-インデックス( "" を指定すると非表示) # FaceS = "People1-4" Messages = [] Messages[2] = "いらっしゃいませー。" Messages[5] = "ほかに何か御用はございますか?" Messages[6] = "リサイクルしたい素材を選んでください。" Messages[7] = "材料として使う素材を選んでください。" Messages[9] = "リサイクルを実行します。よろしいですか?" Messages[3] = "お売りいただく素材を選んでください。" Messages[10]= "即座に引き取らせていただきます。" Messages[4] = "買取価格は %d %s ですが、よろしいですか?" # # コマンド配列 # 0 : リサイクル 1:売却 # CommandIDs = [0, 1] CommandSTRs = [ "リサイクル", "売却" ] # # 用語 # S_Fixs = "リサイクル対象" S_Uses = "消耗材料" S_Yes = "はい。" S_No = "いいえ。" S_Done = "を手に入れました" end #============================================================================== # リサイクルショップコマンド #============================================================================== class Window_SlideCommand < Window_Command end class Window_RecycleCommand < Window_SlideCommand def initialize @clear_style = ((XRXSV10::BG_NAME rescue "").size >= 1) commands = [] @command_ids = XRXSV51::CommandIDs for id in @command_ids commands.push(XRXSV51::CommandSTRs[id]) end super(160, commands) self.x = -12 self.y = (@clear_style ? 72 : 56) end def command_id return @command_ids[self.index] end end #============================================================================== # ■ Scene_RecycleShop #============================================================================== class Scene_RecycleShop < Scene_Base #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_menu_background @message_type = $game_temp.shop_message_type.to_i @clear_style = @menuback2_sprite != nil @gold_window = Window_RecycleGold.new @setup_window = Window_RecycleSetup.new if @clear_style # else @back_window = Window_ShopBack.new end create_command_window @message_window = Window_ShopMessage.new @message_window.z += 5 @trash_window = Window_Trash.new @trash_window.index = -1 @trash_window.active = false @last_command_index = -2 update_check_command_index_change show_message_at(2) @confirming = false @step = 0 end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background dispose_command_window @message_window.dispose @setup_window.dispose @gold_window.dispose @trash_window.dispose @back_window.dispose if @back_window != nil end #-------------------------------------------------------------------------- # メッセージの表示 #-------------------------------------------------------------------------- def show_message_at(id) str = XRXSV51::Messages[id].to_s if str.size >= 1 face_s = XRXSV51::FaceS if face_s.size >= 1 $game_message.face_name = face_s[0, face_s.size - 2] $game_message.face_index = [(face_s[face_s.size-1, 1].to_i - 1), 0].max end case id when 4 n = @trash_window.material.price * XRXSV51::TrashPriceRate / 100 str = sprintf(str, n, Vocab.gold) end $game_message.texts.push(str) if XRXSV51::RapidSelling and id == 3 $game_message.texts.push(XRXSV51::Messages[10].to_s) end end end def show_message_choice choice1 = XRXSV51::S_Yes choice2 = XRXSV51::S_No n = $game_message.texts.size $game_message.choice_start = n $game_message.texts.push(choice1) $game_message.texts.push(choice2) $game_message.choice_max = 2 end #-------------------------------------------------------------------------- # ● コマンドウィンドウの作成 #-------------------------------------------------------------------------- def create_command_window @command_window = Window_RecycleCommand.new end #-------------------------------------------------------------------------- # ● コマンドウィンドウの解放 #-------------------------------------------------------------------------- def dispose_command_window @command_window.dispose end #-------------------------------------------------------------------------- # メッセージの中止 #-------------------------------------------------------------------------- def terminate_message @message_window.finish_message @message_window.terminate_message end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super update_menu_background if @result_window update_result return end @message_window.update unless Input.trigger?(Input::C) @gold_window_update @command_window.update update_check_command_index_change if @confirming case @command_window.command_id when 0 update_input_choice_for_recycle when 1 update_input_choice_for_sell end elsif @trash_window.active @trash_window.update case @command_window.command_id when 0 update_trash_selection_for_recycle when 1 update_trash_selection_for_sell end elsif @command_window.active update_command_selection end end def update_check_command_index_change if @last_command_index != @command_window.index @last_command_index = @command_window.index case @command_window.command_id when 0 @trash_window.set_mode(0) @setup_window.visible = true when 1 @trash_window.set_mode(2) @setup_window.visible = false end end end def update_result @result_window.update if Input.trigger?(Input::C) Sound.play_decision @result_window.dispose @result_window = nil end end #-------------------------------------------------------------------------- # フレーム更新 - 選択肢 - リサイクル #-------------------------------------------------------------------------- def update_input_choice_for_recycle #return unless @message_window.active if Input.trigger?(Input::B) or (Input.trigger?(Input::C) and @message_window.index == 1) Sound.play_cancel terminate_message @message_window.active = false @confirming = false @setup_window.one_cancel @step -= 1 show_message_at(7) elsif Input.trigger?(Input::C) and @message_window.index == 0 Sound.play_use_item terminate_message end_item_selection material = @setup_window.do_recycle! @trash_window.refresh @trash_window.index = 0 @trash_window.index = -1 @gold_window.refresh @confirming = false @result_window = Window_RecycleMenuResult.new(material.item) @result_window.openness = 0 @result_window.open show_message_at(5) end end #-------------------------------------------------------------------------- # アイテムトラッシュ選択の更新 - リサイクル #-------------------------------------------------------------------------- def update_trash_selection_for_recycle if Input.trigger?(Input::B) Sound.play_cancel terminate_message case @step when 1 end_item_selection show_message_at(5) else @setup_window.one_cancel @step -= 1 if @step == 1 show_message_at(6) @trash_window.set_mode(0) else show_message_at(7) end end elsif Input.trigger?(Input::C) material = @trash_window.material if not @setup_window.set_ok?(material) Sound.play_buzzer return end Sound.play_decision terminate_message case @step when 1 @setup_window.set_for_fix(material) @trash_window.set_mode(1) else @setup_window.set_materials(material) end @step += 1 if @step >= XRXSV51::NeedtoFix + 2 show_message_at(9) show_message_choice @confirming = true else show_message_at(7) end end end #-------------------------------------------------------------------------- # フレーム更新 - 選択肢 - 売却 #-------------------------------------------------------------------------- def update_input_choice_for_sell #return unless @message_window.active if Input.trigger?(Input::B) or (Input.trigger?(Input::C) and @message_window.index == 1) Sound.play_cancel terminate_message @message_window.active = false @confirming = false show_message_at(3) elsif Input.trigger?(Input::C) and @message_window.index == 0 terminate_message go_sell! @confirming = false show_message_at(3) end end def go_sell! Sound.play_shop material = @trash_window.material n = material.price * XRXSV51::TrashPriceRate / 100 $game_party.trash.delete(material) $game_party.gain_gold(n) @trash_window.refresh @gold_window.refresh end #-------------------------------------------------------------------------- # アイテムトラッシュ選択の更新 - 売却 #-------------------------------------------------------------------------- def update_trash_selection_for_sell if Input.trigger?(Input::B) Sound.play_cancel end_item_selection terminate_message show_message_at(5) elsif Input.trigger?(Input::C) material = @trash_window.material if material and material.original_item.price >= 1 if XRXSV51::RapidSelling go_sell! else terminate_message show_message_at(4) show_message_choice @confirming = true end else Sound.play_buzzer end end end #-------------------------------------------------------------------------- # ● コマンド選択の更新 #-------------------------------------------------------------------------- def update_command_selection if Input.trigger?(Input::B) Sound.play_cancel terminate_message return_scene elsif Input.trigger?(Input::C) terminate_message Sound.play_decision @command_window.decide! rescue nil @command_window.active = false case @command_window.command_id when 0 # リサイクル @trash_window.active = true @trash_window.index = 0 @step = 1 show_message_at(6) when 1 # 売却 @trash_window.active = true @trash_window.index = 0 show_message_at(3) when 2 end end end def return_scene $scene = Scene_Map.new end #-------------------------------------------------------------------------- # アイテムリスト選択の終了 #-------------------------------------------------------------------------- def end_item_selection @command_window.cancel! rescue nil @command_window.active = true @trash_window.active = false @trash_window.index = -1 end end #============================================================================== # 専用メッセージウィンドウ #============================================================================== class Window_ShopMessage < Window_Message def input_choice end end module XRXSV51_PartyGainMaterialBase def gain_material(material) gain_item(material.original_item, 1) end end class Game_Party < Game_Unit include XRXSV51_PartyGainMaterialBase end #============================================================================== # リサイクル準備ウィンドウ #============================================================================== class Window_RecycleSetup < Window_Base def initialize h = 32 + 24 * (3 + XRXSV51::NeedtoFix) super(384, 96, 180, h) @material_fix = nil @materials = [] refresh end def set_for_fix(material) @material_fix = material refresh end def set_materials(material) @materials.push(material) refresh end def one_cancel if @materials.size >= 1 @materials.pop else @material_fix = nil end refresh end def refresh w = self.contents.width - 8 self.contents.clear self.contents.font.color = system_color self.contents.draw_text(0, 0, w, WLH, XRXSV51::S_Fixs) self.contents.draw_text(0, WLH * 2, w, WLH, XRXSV51::S_Uses) self.contents.font.color = normal_color if @material_fix draw_item_name(@material_fix.item, 4, WLH) else self.contents.draw_text(28, WLH, w - 28, WLH, "---") end for i in 0...XRXSV51::NeedtoFix material = @materials[i] if material draw_item_name(material.item, 4, WLH * (3 + i)) else self.contents.draw_text(28, WLH * (3 + i), w - 28, WLH, "---") end end end def do_recycle! for material in @materials + [@material_fix] $game_party.trash.delete(material) end $game_party.gain_material(@material_fix) material = @material_fix @material_fix = nil @materials.clear refresh return material end #-------------------------------------------------------------------------- # アイテムの描画 (サイズダウン) #-------------------------------------------------------------------------- def draw_item_name(item, x, y, enabled = true) if item != nil width = [self.contents.text_size(item.name).width, 120].min draw_icon(item.icon_index, x, y, enabled) original_font = self.contents.font.dup self.contents.font.size = 18 self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(x + 24, y, width, WLH, item.name) self.contents.font = original_font end end #-------------------------------------------------------------------------- # マテリアルセット可能か?(既に素材に選択しているものや、素材利用禁止な重要もの) #-------------------------------------------------------------------------- def set_ok?(material) return false if material == nil return false if material == @material_fix return false if @materials.include?(material) return false if @material_fix and (XRXSV51::EssentialItemDecomposeBan and material.price == 0) return true end end #============================================================================== # トラッシュリストウィンドウ #============================================================================== class Window_Trash < Window_Item #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(144, 104, 256, WLH * 6 + 32) @column_max = 1 @mode = 0 refresh self.opacity = 0 end #-------------------------------------------------------------------------- # ▼ アイテムをリストに含めるかどうか #-------------------------------------------------------------------------- def include?(item) return false if item == nil return true end #-------------------------------------------------------------------------- # ▼ アイテムを許可状態で表示するかどうか #-------------------------------------------------------------------------- def enable?(item) case @mode when 1, 2 return (item.price >= 1) end return true end #-------------------------------------------------------------------------- # マテリアルの取得 #-------------------------------------------------------------------------- def material return $game_party.trash[self.index] end #-------------------------------------------------------------------------- # モードの変更 # (0:リサイクルベース、1:リサイクル消費、2:売却) #-------------------------------------------------------------------------- def set_mode(n) @mode = n refresh end #-------------------------------------------------------------------------- # ▼ リフレッシュ #-------------------------------------------------------------------------- def refresh @column_max = 1 @data = [] for material in $game_party.trash next unless include?(material) @data.push(material.item) end @data.push(nil) if @data.size == 0 @item_max = @data.size self.index = @item_max - 1 if self.index >= @item_max case @mode when 2 self.width = 352 else self.width = 256 end create_contents for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) item = @data[index] if item != nil enabled = enable?(item) rect.width -= 4 draw_item_name(item, rect.x, rect.y, enabled) if @mode == 2 value = item.price * XRXSV51::TrashPriceRate / 100 if value >= 1 draw_currency_value(value, rect.x, rect.y, rect.width) end end end end end #============================================================================== # 金額表示 #============================================================================== class Window_RecycleGold < Window_Selectable def initialize super(160,64,256,72) self.opacity = 0 self.contents.font.size = 14 refresh end def refresh s = Vocab::Money n = $game_party.gold w = self.contents.width h = self.contents.height / 2 rect = Rect.new(0, 0, w, h) self.contents.clear_rect(rect) self.contents.font.color = system_color self.contents.draw_text(rect.x, rect.y, 56, h, s) self.contents.draw_text(rect.x + 128, rect.y, 32, h, Vocab.gold, 2) self.contents.font.color = normal_color self.contents.draw_number_s(rect.x + 56, rect.y, 72, h, n, 2) end end #============================================================================== # 結果表示ウィンドウ #============================================================================== class Window_RecycleMenuResult < Window_Base def initialize(obj) super(0, 0, 352, 56) if obj draw_item_name(obj, 0, 0) self.contents.draw_text(192, 0, 128, WLH, XRXSV51::S_Done) end self.x = (Graphics.width - self.width ) / 2 self.y = (Graphics.height - self.height) / 2 end end