# ▽△▽ XRXSv53. マテリアル合成メニュー ▽△▽ # # publish 2011/ 1/ 9 # update - /10c # # ※動作にはXRXSV26.MeLT_Item「マテリアルソート+」が必要です。 # #============================================================================== # カスタマイズポイント #============================================================================== module XRXSV53 # # 合成1回につき消費するアイテムID #  ( 0 を指定すると合成し放題です。) # ComposerItemID = 0 # # [用語] # S_Base = "合成ベース" S_Compose = "材料" S_GO = "合成実行!" S_NO = "合成材料選択中…" S_Select = "%s に %s を合成!" S_Done = "ができました!" HelpTextGO= "選択したアイテムの合成を実行します。" S_Lack = "合成に必要なアイテムが足りません。" end #============================================================================== # マテリアル合成画面 #============================================================================== class Scene_MateiralCompose < Scene_Base #-------------------------------------------------------------------------- # 開始処理 #-------------------------------------------------------------------------- def start super create_menu_background @actor = $game_party.members[0] if @actor @actorstatus_window = Window_SkillStatus.new(0, 0, @actor) end @help_window = Window_HelpEX.new @help_window.y = Graphics.height - @help_window.height @help_window.z -= 3 @material_windowset = Windowset_Material.new(180) @material_windowset.help_window = @help_window @set_window = Window_ComposeMaterialSet.new @set_window.help_window = @help_window @material_windowset.active = false @number_window = Window_MaterialComposeItemNumber.new @enable_type = 2 @material_windowset.enable_type(@enable_type) end def return_scene $scene = Scene_Map.new end #-------------------------------------------------------------------------- # 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @actorstatus_window.dispose if @actorstatus_window @help_window.dispose @set_window.dispose @number_window.dispose @material_windowset.dispose end #-------------------------------------------------------------------------- # フレーム更新 #-------------------------------------------------------------------------- def update super if @result_window update_result return elsif @aplly_window update_aplly return end @set_window.update @material_windowset.update update_menu_background if @material_windowset.active update_material_selection else update_set end end #-------------------------------------------------------------------------- # 確認と実行の更新 #-------------------------------------------------------------------------- def update_result if Input.trigger?(Input::C) or Input.trigger?(Input::B) Sound.play_decision @result_window.dispose @result_window = nil end end def update_aplly @aplly_window.update if Input.trigger?(Input::B) or (Input.trigger?(Input::C) and @aplly_window.index == 1) Sound.play_cancel @aplly_window.dispose @aplly_window = nil elsif Input.trigger?(Input::C) and @aplly_window.index == 0 Sound.play_use_item # item = $data_items[XRXSV53::ComposerItemID] if item $game_party.lose_item(item, 1) end # material1 = @set_window.item1.material material2 = @set_window.item2.material material1.compose(material2) $game_party.lose_item(@set_window.item2, 1) @set_window.clear @material_windowset.full_refresh @result_window = Window_MaterialComposeResult.new(material1.item) @aplly_window.dispose @aplly_window = nil @number_window.refresh end end #-------------------------------------------------------------------------- # セット箇所選択の更新 #-------------------------------------------------------------------------- def update_set if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::C) if @set_window.index <= 1 Sound.play_decision @material_windowset.active = true @material_windowset.index = 0 @set_window.active = false if @enable_type != @set_window.index + 2 @enable_type = @set_window.index + 2 @material_windowset.enable_type(@enable_type) end elsif @set_window.ok? item = $data_items[XRXSV53::ComposerItemID] if item number = $game_party.item_number(item) if number <= 0 Sound.play_buzzer @result_window = Window_MaterialComposeResult.new(false) return end end Sound.play_decision @aplly_window = Window_MaterialComposeAplly.new(@set_window.item1, @set_window.item2) @aplly_window.openness = 0 @aplly_window.open else Sound.play_buzzer end end end #-------------------------------------------------------------------------- # マテリアル選択の更新 #-------------------------------------------------------------------------- def update_material_selection if Input.trigger?(Input::B) Sound.play_cancel @material_windowset.page_reset! @material_windowset.index = -1 @material_windowset.active = false @set_window.active = true @set_window.update_help elsif Input.trigger?(Input::C) if (@set_window.index == 0 and not @material_windowset.item.material.composable?) or (@set_window.index == 1 and not @material_windowset.item.material.compose_usable?) Sound.play_buzzer return end Sound.play_decision if @set_window.set_data(@material_windowset.item) @material_windowset.page_reset! @material_windowset.active = false @material_windowset.index = -1 @set_window.active = true else Sound.play_buzzer end end end end #============================================================================== # 合成マテリアルセットウィンドウ #============================================================================== class Window_ComposeMaterialSet < Window_Selectable def initialize(x = -8, y = 96, w = 192, h = WLH * 5 + 32) super(x, y, w, h) @item_max = 3 self.index = 0 @ok = false @set_item = [] refresh end def ok? @ok end def clear @set_item.clear @ok = false refresh end def item1 return @set_item[0] end def item2 return @set_item[1] end def item return @set_item[self.index] end def set_data(item) i = (self.index == 0 ? 1 : 0) return false if @set_item[i] == item @set_item[self.index] = item @ok = (@set_item[0] and @set_item[1]) refresh return true end def refresh w = self.contents.width - 32 self.contents.clear self.contents.font.color = system_color self.contents.draw_text(0, 0, w, WLH, XRXSV53::S_Base) self.contents.draw_text(0, WLH*2, w, WLH, XRXSV53::S_Compose) draw_item(0) draw_item(1) draw_item(2) end def draw_item(index) if index == 2 w = self.contents.width - 32 if @ok self.contents.font.color = system_color self.contents.draw_text(0, WLH*4, w, WLH, XRXSV53::S_GO) else self.contents.font.color = normal_color self.contents.font.color.alpha = 128 self.contents.draw_text(0, WLH*4, w, WLH, XRXSV53::S_NO) end else rect = item_rect(index) self.contents.clear_rect(rect) item = @set_item[index] if item != nil draw_item_name(item, rect.x, rect.y) else self.contents.draw_text(rect.x + 24, rect.y, 128, WLH, "---") end end end def item_rect(index) rect = Rect.new(0, 0, contents.width - 12, WLH) case index when 0 rect.x = 12 rect.y = WLH * 1 when 1 rect.x = 12 rect.y = WLH * 3 when 2 rect.x = 0 rect.y = WLH * 4 end return rect end def update_help case self.index when 2 @help_window.set_text(XRXSV53::HelpTextGO) when 0, 1 item = self.item if item @help_window.set(item) else @help_window.set_text("") end end end #-------------------------------------------------------------------------- # アイテムの描画 (サイズダウン) #-------------------------------------------------------------------------- def draw_item_name(item, x, y, enabled = true) if item != nil 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, 120, WLH, item.name) self.contents.font = original_font end end end #============================================================================== # 「合成実行」確認ウィンドウ #============================================================================== class Window_MaterialComposeAplly < Window_Command def initialize(item1, item2) str1 = sprintf(XRXSV53::S_Select, item1.name, item2.name) str2 = "やめる" super(512, [str1, str2]) self.x = (Graphics.width - self.width ) / 2 self.y = (Graphics.height - self.height) / 2 + 32 end end #============================================================================== # 「合成実行」結果表示ウィンドウ #============================================================================== class Window_MaterialComposeResult < Window_Base def initialize(obj) super(0, 0, 352, 56) if obj == false self.contents.draw_text(0, 0, 320, WLH, XRXSV53::S_Lack) else draw_item_name(obj, 0, 0) self.contents.draw_text(192, 0, 128, WLH, XRXSV53::S_Done) end self.x = (Graphics.width - self.width ) / 2 self.y = (Graphics.height - self.height) / 2 end end #============================================================================== # 合成道具残り数ウィンドウ #============================================================================== class Window_MaterialComposeItemNumber < Window_ComposeMaterialSet def initialize super(-8, 256, 192, 56) self.index = -1 self.active = false end def refresh self.contents.clear item = $data_items[XRXSV53::ComposerItemID] if item draw_item_name(item, 0, 0) rect = Rect.new(0,0, self.contents.width, self.contents.height) number = $game_party.item_number(item) str = sprintf("x%2d", number) self.contents.font.size = 18 text_rect = self.contents.text_size(str) w = text_rect.width * 3 / 4 rect.x += rect.width - w rect.width = w self.contents.draw_text(rect, str, 2) else self.visible = false end end end