# ▼▲▼ メルト・サウンド・ベース 1. マテリアルカンパス ▼▲▼ # by 桜雅 在土 # # update 2006/ 5/19 # #============================================================================== # カスタマイズポイント #============================================================================== module XRXS_MeLT_Sound # # 背景設定 # SHOW_MAP = true # 背景にマップを表示 BG = "ItemBack" # 背景画像 (Titles) BG_OPACITY = 200 # 背景不透明度 # # 縁取り色 # HEMCOLOR = Color.new(0,80,80,255) # # 表示トランジション # TRANS_TIME = 20 TRANS_NAME = "" # # ファイル名と題名の関連付け # TITLE_HASH = {} # # ファイル名とコメントの関連付け # COMMENT_HASH = {} # # ファイル名と条件(現在スイッチのみ)の関連付け # SWITCH_HASH = {} # # サウンドテストに入れないファイル # REMOVE_FILES = [] end #============================================================================== # ■ Game_Temp #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :soundtest_calling # バトル 呼び出しフラグ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :melt_sound_initialize :initialize def initialize melt_sound_initialize @soundtest_calling = false end end #============================================================================== # ■ Interpreter #============================================================================== class Interpreter #-------------------------------------------------------------------------- # ● 注釈イベントの実行 #-------------------------------------------------------------------------- if self.class.method_defined?("command_108") alias :melt_aound_command_108 :command_108 def command_108 if @parameters[0] == "サウンドテスト" soundtest_call return true end melt_aound_command_108 end end #-------------------------------------------------------------------------- # ● サウンドテストの呼び出し #-------------------------------------------------------------------------- def soundtest_call if $scene.is_a?(Scene_Map) $game_temp.call_soundtest = true $scene.call_soundtest end end end #============================================================================== # ■ Scene_Map #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● サウンドテストの呼び出し #-------------------------------------------------------------------------- def call_soundtest # プレイヤーの姿勢を矯正 Game.player.straighten # サウンドテスト画面に切り替え GameData.scene = Scene_Sound.new end end #============================================================================== # ■ Scene_Menu #============================================================================== class Scene_Menu #-------------------------------------------------------------------------- # ● フレーム更新 (コマンドウィンドウがアクティブの場合) #-------------------------------------------------------------------------- alias :melt_sound_update_command :update_command def update_command # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) $game_map.autoplay # メニュー呼び出しフラグをクリア $game_temp.menu_calling = false # @windows.each{|window| window.slideout! } @slideout_count = 8 @slideout_next_scene = Scene_Map $game_temp.menu_index = 0 return else melt_sound_update_command end end end #============================================================================== # ■ Scene_Sound #============================================================================== class Scene_Sound #-------------------------------------------------------------------------- # ○ ウィンドウの作成 #-------------------------------------------------------------------------- def make_windows @bg_sprite = Spriteset_Map.new if XRXS_MeLT_Sound::SHOW_MAP sprite = Sprite.new sprite.bitmap = RPG::Cache.title(XRXS_MeLT_Sound::BG) sprite.z = 1 sprite.opacity = XRXS_MeLT_Sound::BG_OPACITY @sprites.push(sprite) end def dispose_windows @bg_sprite.dispose if @bg_sprite != nil end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main @volume = 100 @pitch = 100 # アイテムウィンドウを作成 @sound_window = Window_SoundTest.new @help_window = Window_SoundHelp.new @soundmenu_window = Window_SoundMenu.new @sound_window.help_window = @help_window @slideout_count = 0 @slidewait_count = 0 # 追加ウィンドウの作成 @windows = [@sound_window, @help_window, @soundmenu_window] @sprites = [] make_windows # トランジション実行 Graphics.transition(XRXS_MeLT_Sound::TRANS_TIME, XRXS_MeLT_Sound::TRANS_NAME) # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $data_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 } @sprites.each{|sprite| sprite.update } # スライドウェイト if @slidewait_count > 0 @slidewait_count -= 1 return end # スライドアウト if @slideout_count > 0 @slideout_count -= 1 if @slideout_count == 0 # 前の画面に切り替え if $game_temp.call_soundtest $game_temp.call_soundtest = false $scene = Scene_Map.new else $scene = Scene_Menu.new(XRXS_MeLT.commands.index($scene.class)) end end return end # サウンドウィンドウがアクティブの場合: update_sound を呼ぶ if @sound_window.active update_sound return end # ターゲットウィンドウがアクティブの場合: update_target を呼ぶ if @soundmenu_window.active update_target return end end #-------------------------------------------------------------------------- # ● フレーム更新 (サウンドウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_sound # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # メニュー外から呼び出した場合、その場でBGMを戻す if $game_temp.call_soundtest $game_map.autoplay end @slideout_count = 5 @help_window.slideout! @soundmenu_window.slideout! return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 条件が無いか、条件を満たしていれば if XRXS_MeLT_Sound::SWITCH_HASH.include?(@sound_window.name) if $game_switches[XRXS_MeLT_Sound::SWITCH_HASH[@sound_window.name]] # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 演奏 Audio.bgm_play("Audio/BGM/" + @sound_window.name, @volume, @pitch) else # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) end else # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 演奏 Audio.bgm_play("Audio/BGM/" + @sound_window.name, @volume, @pitch) end return end # A ボタンが押された場合 if Input.trigger?(Input::A) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) @slidewait_count = 5 # ターゲットウィンドウをアクティブ化 @sound_window.active = false @help_window.slideout! @soundmenu_window.visible = true @soundmenu_window.active = true @soundmenu_window.index = 0 @soundmenu_window.slidein! return end end #-------------------------------------------------------------------------- # ● フレーム更新 (ターゲットウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_target # B ボタンが押された場合 if Input.trigger?(Input::B) or Input.trigger?(Input::A) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # ターゲットウィンドウを消去 @sound_window.active = true @soundmenu_window.visible = false @soundmenu_window.active = false @help_window.slidein! @soundmenu_window.slideout! @slidewait_count = 5 return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 条件が無いか、条件を満たしていれば if XRXS_MeLT_Sound::SWITCH_HASH.include?(@sound_window.name) if $game_switches[XRXS_MeLT_Sound::SWITCH_HASH[@sound_window.name]] # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 演奏 Audio.bgm_play("Audio/BGM/" + @sound_window.name, @volume, @pitch) else # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) end else # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 演奏 Audio.bgm_play("Audio/BGM/" + @sound_window.name, @volume, @pitch) end return end # R ボタンが押された場合 if Input.trigger?(Input::R) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) if @soundmenu_window.index == 0 @volume = [100, @volume + 5].min else @pitch = [450, @pitch + 5].min end @soundmenu_window.refresh(@volume, @pitch) end # L ボタンが押された場合 if Input.trigger?(Input::L) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) if @soundmenu_window.index == 0 @volume = [0, @volume - 5].max else @pitch = [5, @pitch - 5].max end @soundmenu_window.refresh(@volume, @pitch) end end end #============================================================================== # □ Window_SoundTest #============================================================================== class Window_SoundTest < Window_Selectable #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(8, 0, 288, 480) @column_max = 1 self.opacity = 0 refresh self.index = 0 end #-------------------------------------------------------------------------- # ○ アイテムの取得 #-------------------------------------------------------------------------- def name return @data[self.index] end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = Dir.entries("Audio/BGM") @data.delete(".") @data.delete("..") @data -= XRXS_MeLT_Sound::REMOVE_FILES @data.sort!{|a, b| a.downcase <=> b.downcase} # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.size = 18 for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) self.contents.font.color = Color.new(80,64,0,255) if XRXS_MeLT_Sound::SWITCH_HASH.include?(@data[index]) if XRXS_MeLT_Sound::TITLE_HASH.include?(@data[index]) item_name = XRXS_MeLT_Sound::TITLE_HASH[@data[index]] else item_name = @data[index] end unless $game_switches[XRXS_MeLT_Sound::SWITCH_HASH[@data[index]]] item_name = item_name.gsub(/./){"?"} end else if XRXS_MeLT_Sound::TITLE_HASH.include?(@data[index]) item_name = XRXS_MeLT_Sound::TITLE_HASH[@data[index]] else item_name = @data[index] end end self.contents.draw_text(0, index * 32, 256, 32, item_name, 0) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set(name) end end #============================================================================== # ■ Window_SoundMenu #============================================================================== class Window_SoundMenu < Window_Selectable #-------------------------------------------------------------------------- # --- ウィンドウスライディングを搭載 --- #-------------------------------------------------------------------------- include XRXS_WindowSliding #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(352, 0, 224, 160) self.contents = Bitmap.new(width - 32, height - 32) self.z += 10 @white = Color.new(0, 0, 0, 0) self.contents.font.color = Color.new(222,222,255,255) @column_max = 1 @item_max = 2 @slide_x_speed = -8 self.opacity = 0 self.visible = false self.active = false # 固定部分は最初に描画 self.contents.draw_hemming_text(0, 0, 192, 32, "Volume", 1, XRXS_MeLT_Sound::HEMCOLOR) self.contents.draw_text(0, 32, 32, 32, "<") self.contents.draw_text(160, 32, 32, 32, ">") self.contents.draw_hemming_text(0, 64, 192, 32, "Pitch", 1, XRXS_MeLT_Sound::HEMCOLOR) self.contents.draw_text(0, 96, 32, 32, "<") self.contents.draw_text(160, 96, 32, 32, ">") # リフレッシュ refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(volume = 100, pitch = 100) self.contents.fill_rect(32, 32, 128, 32, @white) self.contents.fill_rect(32, 96, 128, 32, @white) self.contents.draw_hemming_text(32, 32, 128, 32, volume.to_s, 1) self.contents.draw_hemming_text(32, 96, 128, 32, pitch.to_s, 1) end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect if self.index == 0 self.cursor_rect.set(32, 32, 128, 32) else self.cursor_rect.set(32, 96, 128, 32) end end def slidein! self.x = 352 self.contents_opacity = 0 @slidein_count = 4 @slideout_count = 0 end end # ▼▲▼ メルト・サウンド プラグインA1 : メモランダム ▼▲▼ # # update 2006/ 5/18 # #============================================================================== # 説明文に改行機能を搭載 #============================================================================== #============================================================================== # □ Window_SoundHelp #============================================================================== class Window_SoundHelp < Window_Base #-------------------------------------------------------------------------- # --- ウィンドウスライディングを搭載 --- #-------------------------------------------------------------------------- include XRXS_WindowSliding #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(288, 96, 360, 288) self.opacity = 0 @slide_x_speed = -8 # コンテンツキャッシュ機構 @contents_cache = {} end def set(name) # アイテムが無いときはクリアして終了 return self.contents = nil if name == nil # if @contents_cache[name] == nil bitmap = Bitmap.new(width - 32, height - 32) # 条件が無いか、条件を満たしていれば if XRXS_MeLT_Sound::SWITCH_HASH.include?(name) if $game_switches[XRXS_MeLT_Sound::SWITCH_HASH[name]] if XRXS_MeLT_Sound::COMMENT_HASH.include?(name) descriptions = XRXS_MeLT_Sound::COMMENT_HASH[name].split(/\n/) for i in 0..8 text = descriptions[i] break if text.nil? bitmap.draw_hemming_text(16, 32 + 24 * i, 328, 24, text, 0, XRXS_MeLT_Sound::HEMCOLOR) end end end else if XRXS_MeLT_Sound::COMMENT_HASH.include?(name) descriptions = XRXS_MeLT_Sound::COMMENT_HASH[name].split(/\n/) for i in 0..8 text = descriptions[i] break if text.nil? bitmap.draw_hemming_text(16, 32 + 24 * i, 328, 24, text, 0, XRXS_MeLT_Sound::HEMCOLOR) end end end @contents_cache[name] = bitmap end self.contents = @contents_cache[name] end def slidein! @slidein_count = 4 @slideout_count = 0 end def dispose @contents_cache.values.each{|bitmap| bitmap.dispose } super end end