# ▼▲▼ MeLT.メニューレイアウトテンプレート ▼▲▼ # # update 2007/ 7/22 # #============================================================================== # カスタマイズポイント #============================================================================== module XRXS_MeLT # # 表示トランジション # TRANS_TIME = 8 TRANS_NAME = "" #"Graphics/Transitions/013-Square01" # [メニューコマンド] COMMANDS = [ "アイテム", Scene_Item, "スキル", Scene_Skill, "装備", Scene_Equip, "ステータス", Scene_Status, "セーブ", Scene_Save, "ゲーム終了", Scene_End ] # アクター選択を用いないシーン ACTOR_INDEX_DISADAPTED = [Scene_Item, Scene_Save, Scene_End] # # カーソルファイル名 (Windowskin) # CURSOR_SKIN = "MenuCursor" CURSOR_SKIN2 = "MenuCursor2" # # 背景設定 # USE_MAP = true # 背景にマップを表示 BG_TITLE = "MenuBack" # 背景画像 (Titles) B_OPACITY = 160 # 背景不透明度 # # サイドコマンド # SIDE_KEY = nil # Input::RIGHT など キー指定で有効。nilで無効化 SIDE_SCENE = nil # nil でパーティ入れ替え, シーンも指定可 # # [アクター立ち絵ファイル名] # ( アクターID=>ファイル名 ハッシュ # 例:2=>"Stand_2", など) # STAND_NAMES = { } end #============================================================================== # 立ち絵ファイル名の取得 #============================================================================== class Game_Actor < Game_Battler def stand_name return XRXS_MeLT::STAND_NAMES[self.id].to_s end end #============================================================================== # メニューカーソル一時記憶 / MeLT設定 #============================================================================== class Game_Temp attr_accessor :menu_index end module XRXS_MeLT # メニューコマンド シーン/文字 def self.commands set = [] for i in 0...COMMANDS.size/2 set.push(COMMANDS[i * 2 + 1]) end return set end def self.captions set = [] for i in 0...COMMANDS.size/2 set.push(COMMANDS[i * 2]) end return set end end #============================================================================== # --- メニューレイアウト 拡張定義 --- #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # ○ ウィンドウの作成 #-------------------------------------------------------------------------- def make_windows # @bg_sprite = Spriteset_Map.new if XRXS_MeLT::USE_MAP sprite = Sprite.new sprite.bitmap = RPG::Cache.title(XRXS_MeLT::BG_TITLE) sprite.z = 1 sprite.opacity = XRXS_MeLT::B_OPACITY @sprites.push(sprite) end def dispose_windows @bg_sprite.dispose if @bg_sprite != nil end end #============================================================================== # ■ Scene_Menu #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(menu_index = 0) @menu_index = $game_temp.menu_index.to_i end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # コマンドウィンドウを作成 @command_window = Window_MenuCommand.new @command_window.index = @menu_index # ステータスウィンドウを作成 @status_window = Window_MenuStatus.new # 初期化 @slideout_count= 0 @next_scene_actor_index = nil # カーソルの作成 @cursor2 = Sprite_MenuCursor.new(XRXS_MeLT::CURSOR_SKIN2) @cursor2.visible = false @cursor = Sprite_MenuCursor.new(XRXS_MeLT::CURSOR_SKIN) @sprites = [@cursor2, @cursor] # ウィンドウを作成 @windows = [] @windows.push(@command_window) @windows.push(@status_window) make_windows # トランジション実行 Graphics.transition(XRXS_MeLT::TRANS_TIME, XRXS_MeLT::TRANS_NAME) # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @windows.each{|window| window.dispose } @sprites.each{|sprite| sprite.dispose } dispose_windows end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ウィンドウを更新 @windows.each{|window| window.update } # アクティブなウィンドウを検索 active_window = nil for window in @windows if window.active active_window = window break end end # カーソル位置の更新 @cursor.visible = (active_window != nil) if active_window != nil cursor_dx = active_window.x + active_window.cursor_rect.x cursor_dy = active_window.y + active_window.cursor_rect.y + active_window.cursor_rect.height / 2 distance_x = (cursor_dx - @cursor.x) distance_y = (cursor_dy - @cursor.y) speed = 24 if distance_x.abs <= speed @cursor.x = cursor_dx else sign = (distance_x >= 0 ? 1 : -1) @cursor.x += speed * sign end if distance_y.abs <= speed @cursor.y = cursor_dy else sign = (distance_y >= 0 ? 1 : -1) @cursor.y += speed * sign end @cursor.visible = false if active_window.index == -1 end # スライドアウト if @slideout_count > 0 @slideout_count -= 1 if @slideout_count == 0 # 画面を切り替え if @next_scene_actor_index == nil $scene = @slideout_next_scene.new else $scene = @slideout_next_scene.new(@next_scene_actor_index) end end return end # コマンドウィンドウがアクティブの場合: update_command を呼ぶ if @command_window.active update_command return end # ステータスウィンドウがアクティブの場合: update_status を呼ぶ if @status_window.active update_status return end end #-------------------------------------------------------------------------- # ● フレーム更新 (コマンドウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_command # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # @windows.each{|window| window.slideout! } @slideout_count = 8 @slideout_next_scene = Scene_Map $game_temp.menu_index = 0 return end # C ボタンかサイドキーが押された場合 if Input.trigger?(Input::C) or (XRXS_MeLT::SIDE_KEY != nil and Input.trigger?(XRXS_MeLT::SIDE_KEY)) # パーティ人数が 0 人で、セーブ、ゲーム終了以外のコマンドの場合 if $game_party.actors.size == 0 and @command_window.index < 4 # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 押されたキーによってシーンを取得 if Input.trigger?(Input::C) scene = XRXS_MeLT.commands[@command_window.index] else scene = XRXS_MeLT::SIDE_SCENE index = XRXS_MeLT.commands.index(XRXS_MeLT::SIDE_SCENE) @command_window.index = index == nil ? -1 : index end # パーティ入れ替えの場合 if scene == nil # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # ステータスウィンドウをアクティブにする @command_window.active = false @command_window.decide! @status_window.active = true @status_window.index = 0 return end # セーブ禁止の場合 if scene == Scene_Save and $game_system.save_disabled # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 指定シーンへの切り替え if not XRXS_MeLT::ACTOR_INDEX_DISADAPTED.include?(scene) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # ステータスウィンドウをアクティブにする @command_window.active = false @command_window.decide! @status_window.active = true @status_window.index = 0 elsif scene != nil # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # メニューインデックスの保持 $game_temp.menu_index = @command_window.index # 画面を切り替え @windows.each{|window| window.slideout! } @slideout_count = 8 @slideout_next_scene = scene end return end end #-------------------------------------------------------------------------- # ● フレーム更新 (ステータスウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_status # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # if @status_window.index2 == -1 # コマンドウィンドウをアクティブにする @command_window.active = true @command_window.cancel! @command_window.index = 0 if @command_window.index == -1 @status_window.active = false @status_window.index = -1 @next_scene_actor_index = nil else @status_window.index = @status_window.index2 @status_window.index2 = -1 @cursor2.visible = false end return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 指定されたシーンの取得 scene = @command_window.index == -1 ? nil : XRXS_MeLT.commands[@command_window.index] # nil ならばメニューでのメンバー入れ替え if scene == nil # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) if @status_window.index2 == -1 @status_window.index2 = @status_window.index @cursor2.x = @status_window.x + @status_window.cursor_rect.x @cursor2.y = @status_window.y + @status_window.cursor_rect.y + @status_window.cursor_rect.height / 2 @cursor2.visible = true else @cursor2.visible = false # メンバーの入れ替え二人目の決定と入れ替えの実行 actor2 = $game_party.actors[@status_window.index] actor = $game_party.actors[@status_window.index2] $game_party.actors[@status_window.index2] = actor2 $game_party.actors[@status_window.index] = actor @status_window.index = @status_window.index2 @status_window.index2 = -1 # プレイヤーをリフレッシュ $game_player.refresh # ステータスウィンドウをリフレッシュ @status_window.refresh end return end # このアクターの行動制限が 2 以上の場合 if scene == Scene_Skill and $game_party.actors[@status_window.index].restriction >= 2 # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end @next_scene_actor_index = @status_window.index # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # メニューインデックスの保持 $game_temp.menu_index = @command_window.index # 画面を切り替え @windows.each{|window| window.slideout! } @slideout_count = 8 @slideout_next_scene = scene return end end end #============================================================================== # --- カーソルスプライト --- #============================================================================== class Sprite_MenuCursor < Sprite def initialize(skin) super() self.bitmap = RPG::Cache.windowskin(skin) self.ox = self.bitmap.rect.width - 20 self.oy = self.bitmap.rect.height / 2 - 16 self.x = -64 self.y = 64 self.z = 205 end end #============================================================================== # --- XRXS. ウィンドウスライディング機構 --- #============================================================================== module XRXS_WindowSliding def initialize(x, y, w, h) super(x, y, w, h) self.contents_opacity = 0 @slidein_count = 4 @slideout_count = 0 @slide_x_speed = 8 @slide_y_speed = 0 @slide_x_limit = nil @slide_objects = [self] end def update super if @slidein_count > 0 @slidein_count -= 1 for object in @slide_objects object.x += @slide_x_speed object.y += @slide_y_speed object.x = [object.x, @slide_x_limit].min if @slide_x_limit != nil case object when Window object.contents_opacity += 64 when Sprite object.opacity += 64 end end elsif @slideout_count > 0 @slideout_count -= 1 for object in @slide_objects object.x -= @slide_x_speed object.y -= @slide_y_speed case object when Window object.contents_opacity -= 64 when Sprite object.opacity -= 64 end end end end def slideout! @slidein_count = 0 @slideout_count = 4 end end #============================================================================== # □ Bitmapライブラリ --- draw_hemming_text --- □ #============================================================================== class Bitmap def draw_hemming_text(x, y, w, h, text, align = 0, black_color = Color.new(0,0,0,255)) original_color = self.font.color.dup self.font.color = black_color self.draw_text(x , y , w, h, text, align) self.draw_text(x , y+2, w, h, text, align) self.draw_text(x+2, y+2, w, h, text, align) self.draw_text(x+2, y , w, h, text, align) self.font.color = original_color self.draw_text(x+1, y+1, w, h, text, align) end end #============================================================================== # □ Bitmapライブラリ --- blt_number --- □ #============================================================================== class Bitmap def blt_number(x, y, skin, number, opacity = 224) a_width = skin.rect.width / 10 rect = Rect.new(0, 0, a_width, skin.rect.height) # numbers = [ number/10000000%10,number/1000000%10,number/100000%10,number/10000%10, number/1000%10, number/100%10, number/10%10, number%10 ] display = false for i in 0...numbers.size n = numbers[i] display |= (n != 0 or i == numbers.size - 1) if display rect.x = n * a_width self.blt(x - (8-i) * a_width, y - skin.rect.height, skin, rect, opacity) end #x += a_width end end end