#============================================================================== # ○サウンドテスト Ver1.00 # for RGSS2 # 西瓜 / Space not far # http://muspell.raindrop.jp/ # BGM、BGSが試聴できるシステムです。 #============================================================================== # イベントコマンドのスクリプトなどに # $scene = Scene_SoundTest.new と記述してください。 module SNF SOUNDLIST = [] SOUNDLIST[0] = ["通常戦闘" , RPG::BGM.new("Battle1", 80, 100), "ザコ戦闘のBGM"] SOUNDLIST[1] = ["フィールド", RPG::BGM.new("Field1", 80, 100), "青い空白い雲"] SOUNDLIST[2] = ["最初の街", RPG::BGM.new("Town1", 80, 100), "のどかな雰囲気"] SOUNDLIST[3] = ["飛行船", RPG::BGM.new("Airship", 80, 100), "空を飛ぶ乗り物"] SOUNDLIST[4] = ["嵐", RPG::BGS.new("Storm", 80, 100), "落とされた吊り橋"] SOUNDLIST[5] = ["ギャグ", RPG::ME.new("Gag", 80, 100), "オチ"] SOUNDLIST[6] = ["猫", RPG::SE.new("cat", 80, 100), "にゃあ"] # SOUNDLIST[n] = [曲タイトル, RPG::BGM.new(ファイル名, 音量, ピッチ), 解説] # という形式で記述してください。 # SOUNDLISTの番号は必ず0から順番にお入れください。 # BGS、ME、SEを再生させたい場合はRPG::BGM.newのBGMを書き換えること。 SOUND_HEAD = "サウンドテスト" # 上部に表示するタイトル SOUND_BOTTOM = "ききたい曲を選んでね" # 最初に下部に表示されるテキスト SOUNDICON = 134 # 曲のアイコンのインデックス(表示しない場合0) SOUND_COLUMN_MAX = 2 # 表示桁数(必ず1以上) SOUND_RETURN = Scene_Map.new # サウンドテストから戻るシーン LASTSOUND_COLOR = Color.new(255, 255, 208) # 現在流れているBGMの文字色(赤, 緑, 青) end class Scene_SoundTest < Scene_Base #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_menu_background $game_temp.map_bgm = RPG::BGM.last $game_temp.map_bgs = RPG::BGS.last @viewport = Viewport.new(0, 0, 544, 416) @head_window = Window_SoundHead.new @head_window.viewport = @viewport @help_window = Window_SoundHelp.new @help_window.viewport = @viewport @sound_window = Window_SoundTest.new(0, 56, 544, 280) @sound_window.viewport = @viewport @sound_window.help_window = @help_window @sound_window.active = true end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @viewport.dispose @help_window.dispose @sound_window.dispose @head_window.dispose end #-------------------------------------------------------------------------- # ● 元の画面へ戻る #-------------------------------------------------------------------------- def return_scene $scene = SNF::SOUND_RETURN $game_temp.map_bgm.play $game_temp.map_bgs.play end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super update_menu_background @sound_window.update if @sound_window.active update_sound_selection end end #-------------------------------------------------------------------------- # ● BGM選択の更新 #-------------------------------------------------------------------------- def update_sound_selection if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::C) @item = @sound_window.item Sound.play_decision determine_sound end end #-------------------------------------------------------------------------- # ● BGMの決定 #-------------------------------------------------------------------------- def determine_sound RPG::BGS.stop RPG::BGM.stop RPG::ME.stop RPG::SE.stop @item[1].play @sound_window.refresh(@sound_window.index) @help_window.set_text(@item) end end class Window_SoundTest < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # width : ウィンドウの幅 # height : ウィンドウの高さ #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) @column_max = (SNF::SOUND_COLUMN_MAX > 0) ? SNF::SOUND_COLUMN_MAX : 1 self.index = 0 refresh end #-------------------------------------------------------------------------- # ● BGMの取得 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(last_sound = -1) @data = [] @last_sound = last_sound for sound in SNF::SOUNDLIST @data.push(sound) end @item_max = @data.size 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) sound = @data[index] enabled = true last = true if @last_sound == index if sound != nil rect.width -= 4 draw_sound_name(sound, rect.x, rect.y, enabled, last) end end #-------------------------------------------------------------------------- # ● BGM名の描画 #-------------------------------------------------------------------------- def draw_sound_name(sound, x, y, enabled = true, last = false) if sound != nil draw_icon(SNF::SOUNDICON, x, y, enabled) if SNF::SOUNDICON != 0 self.contents.font.color = last ? SNF::LASTSOUND_COLOR : normal_color self.contents.font.color.alpha = enabled ? 255 : 128 x += (SNF::SOUNDICON != 0) ? 24 : 4 self.contents.draw_text(x, y, 172, WLH, sound[0]) end end end class Window_SoundHelp < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 336, 544, WLH * 2 + 32) set_text_start end #-------------------------------------------------------------------------- # ● テキスト設定 #-------------------------------------------------------------------------- def set_text(item) self.contents.clear self.contents.font.color = system_color self.contents.draw_text(4, 0, self.width - 40, WLH, item[0], 0) self.contents.font.color = normal_color self.contents.draw_text(16, WLH, self.width - 40, WLH, item[2], 0) end def set_text_start self.contents.clear self.contents.font.color = normal_color self.contents.draw_text(0, WLH / 2, self.width - 40, WLH, SNF::SOUND_BOTTOM, 1) end end class Window_SoundHead < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 544, WLH + 32) refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.color = normal_color self.contents.draw_text(4, 0, 544, WLH, SNF::SOUND_HEAD, 0) end end