Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Sound Test Scene ~ Customisable Version
- # Version: 1.0
- # Author: DiamondandPlatinum3
- # Date: June 18, 2013
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # Description:
- #
- # This script creates a new scene in your menu which allows you to listen to
- # music that is played in your game. It also allows for some customisation to
- # be made when playing a sound, such as modifying Volume, Pitch and/or Position.
- # Music can also be locked until a certain Event Switch is turned on.
- #
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #------------------------------------------------------------------------------
- # Instructions:
- #
- # ~ Go into the Script and Modify the Editable Region as Needed
- #
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- module DiamondandPlatinum3
- module SoundTestScene
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # -=
- # Editable Region //// ==
- # =-
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # The Text that is displayed for the Option in the Menu
- MenuCommandText = "Sound Test"
- # Text to be displayed on the help window when Selecting a Sound
- SoundSelectHelpWindowTextLine1 = "Select a Sound"
- SoundSelectHelpWindowTextLine2 = "Press 'Esc or X' to Exit"
- # Text to be displayed on the help window when Hovering over the 'Play Sound' Option
- PlaySoundOptionHelpWindowTextLine1 = "Select To Play Sound"
- PlaySoundOptionHelpWindowTextLine2 = "(Default Settings)"
- # Text to be displayed on the help window when Hovering over the 'Volume' Option
- VolumeOptionHelpWindowTextLine1 = "Select To Play Sound"
- VolumeOptionHelpWindowTextLine2 = "(At Specific Volume)"
- # Text to be displayed on the help window when Hovering over the 'Pitch' Option
- PitchOptionHelpWindowTextLine1 = "Select To Play Sound"
- PitchOptionHelpWindowTextLine2 = "(At Specific Pitch)"
- # Text to be displayed on the help window when Hovering over the 'Position' Option
- PositionOptionHelpWindowTextLine1 = "Select To Play Sound At Specific Position"
- PositionOptionHelpWindowTextLine2 = "(Only works for WAV & OGG Files)"
- # Text to be displayed on the help window when inputting a value in the NuberInput Window
- NumberInputHelpWindowTextLine1 = "Input A Value"
- NumberInputHelpWindowTextLine2 = ""
- # Filename of background Image to be displayed when using the scene (Located in Pictures Folder)
- BackgroundSpriteFilename = "SoundTest_BackgroundImage"
- #--------------------------------------
- Sounds = { # <= Do Not Touch
- #--------------------------------------
- # Exact Filename of BGM you want to Have in the Scene
- "Airship" =>
- {
- :display_name => "Airship Theme", # Display Name of Sound
- :default_volume => 100, # Deault Volume
- :default_pitch => 100, # Default Pitch
- :conditional_switch => 0, # Conditional Switch (Must be on before sound will be available, unless event switch is Zero)
- :info_line1 => "Author: Enterbrain", # Info Line1, can be anything you want to say about the Individual Sound
- :info_line2 => "Used As: Airship Theme", # Info Line2, can be anything you want to say about the Individual Sound
- :info_line3 => "", # Info Line3, can be anything you want to say about the Individual Sound
- :info_line4 => "From: RPG Maker VX Ace RTP", # Info Line4, can be anything you want to say about the Individual Sound
- },
- # Rinse, Repeat. Keep Doing this until all your desired SoundFiles are Available to be played
- "Battle1" =>
- {
- :display_name => "Battle Theme 1",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Normal Battle Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Battle2" =>
- {
- :display_name => "Battle Theme 2",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Normal Battle Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Battle3" =>
- {
- :display_name => "Battle Theme 3",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Mini-Boss Battle Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Battle4" =>
- {
- :display_name => "Battle Theme 4",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Normal Battle Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Battle5" =>
- {
- :display_name => "Battle Theme 5",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Normal Battle Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Battle6" =>
- {
- :display_name => "Battle Theme 6",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Normal Battle Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Battle7" =>
- {
- :display_name => "Battle Theme 7",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Normal Battle Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Battle8" =>
- {
- :display_name => "Battle Theme 8",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Boss Battle Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Battle9" =>
- {
- :display_name => "Battle Theme 9",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Final Boss Battle Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Dungeon1" =>
- {
- :display_name => "Dungeon Theme 1",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: BootCamp Cave Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Dungeon2" =>
- {
- :display_name => "Dungeon Theme 2",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Heavy Rain Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Dungeon3" =>
- {
- :display_name => "Dungeon Theme 3",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Underground Base Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Dungeon4" =>
- {
- :display_name => "Dungeon Theme 4",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Thought Before War Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Dungeon5" =>
- {
- :display_name => "Dungeon Theme 5",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Magical Cavern Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Dungeon6" =>
- {
- :display_name => "Dungeon Theme 6",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Following a Trail Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Dungeon7" =>
- {
- :display_name => "Dungeon Theme 7",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Climbing the Heavens Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Dungeon8" =>
- {
- :display_name => "Dungeon Theme 8",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Descending to the Ground Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Dungeon9" =>
- {
- :display_name => "Dungeon Theme 9",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Last Dungeon Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Field1" =>
- {
- :display_name => "Field Map Theme 1",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Starting Your Journey Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Field2" =>
- {
- :display_name => "Field Map Theme 2",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: World Map Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Field3" =>
- {
- :display_name => "Field Map Theme 3",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: The Heroes of this Tale Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Field4" =>
- {
- :display_name => "Field Map Theme 4",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: A World in Chaos Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Scene1" =>
- {
- :display_name => "Custom Scene Theme 1",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: In Danger Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Scene2" =>
- {
- :display_name => "Custom Scene Theme 2",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Villain Appears Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Scene3" =>
- {
- :display_name => "Custom Scene Theme 3",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Villain Two Appears Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Scene4" =>
- {
- :display_name => "Custom Scene Theme 4",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Found a New Friend Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Scene5" =>
- {
- :display_name => "Custom Scene Theme 5",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: HeartWarming Discussion Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Scene6" =>
- {
- :display_name => "Custom Scene Theme 6",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Happiness Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Ship" =>
- {
- :display_name => "Ship Theme",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Riding in a Ship Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Theme1" =>
- {
- :display_name => "Custom Theme 1",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: We are a Team Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Theme2" =>
- {
- :display_name => "Custom Theme 2",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Fallen Heroes Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Theme3" =>
- {
- :display_name => "Custom Theme 3",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Art Museum Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Theme4" =>
- {
- :display_name => "Custom Theme 4",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Ending Credits Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Theme5" =>
- {
- :display_name => "Custom Theme 1",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Supporters Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Town1" =>
- {
- :display_name => "Town Theme 1",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Hero's Home Town Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Town2" =>
- {
- :display_name => "Town Theme 2",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Capital City Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Town3" =>
- {
- :display_name => "Town Theme 3",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Scummy Area of Town Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Town4" =>
- {
- :display_name => "Town Theme 4",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Elderly Village Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Town5" =>
- {
- :display_name => "Town Theme 5",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Peaceful Village Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Town6" =>
- {
- :display_name => "Town Theme 6",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: A Town for Adventurer's Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- "Town7" =>
- {
- :display_name => "Town Theme 7",
- :default_volume => 100,
- :default_pitch => 100,
- :conditional_switch => 0,
- :info_line1 => "Author: Enterbrain",
- :info_line2 => "Used As: Mermaid Village Theme",
- :info_line3 => "",
- :info_line4 => "From: RPG Maker VX Ace RTP",
- },
- # If you want to add more Sounds, you may do so above this Line, just
- # copy-paste the above format and change things as needed.
- #///////////////////////
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # \/
- # End of Editable Region /\
- # \/
- #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- #---------------------------------------------------------
- # No touchie past here unless you know what you are
- # doing. Failure to heed this warning could cause your
- # computer to yell and scream at you.
- #
- # Edit at your own risk.
- #--------------------------------------------------------
- }
- end
- end
- #==============================================================================
- # ** SoundTestSound
- #------------------------------------------------------------------------------
- # This is a class which hold Individual Sound Information for Play
- #==============================================================================
- class SoundTestSound
- include DiamondandPlatinum3::SoundTestScene
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :name
- attr_accessor :volume
- attr_accessor :pitch
- #--------------------------------------------------------------------------
- # * Intialize
- #--------------------------------------------------------------------------
- def initialize( name, volume, pitch )
- @name = name
- @volume = volume
- @pitch = pitch
- end
- #--------------------------------------------------------------------------
- # * Play Sound
- #--------------------------------------------------------------------------
- def play()
- RPG::BGM.stop()
- RPG::BGM.new( name, volume, pitch ).play
- end
- #--------------------------------------------------------------------------
- # * Play Sound at Position
- #--------------------------------------------------------------------------
- def play_at_position( position )
- RPG::BGM.stop()
- RPG::BGM.new( name, volume, pitch ).play( position )
- end
- #--------------------------------------------------------------------------
- # * Play Sound ( Default )
- #--------------------------------------------------------------------------
- def default_play()
- RPG::BGM.stop()
- RPG::BGM.new( name, Sounds[name][:default_volume], Sounds[name][:default_pitch] ).play
- end
- end
- #==============================================================================
- # ** Scene_SoundTest
- #------------------------------------------------------------------------------
- # This Clas Holds the Scene Information for the SoundTest
- #==============================================================================
- class Scene_SoundTest < Scene_Base
- include DiamondandPlatinum3::SoundTestScene
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- super()
- save_current_bgm()
- create_background_image()
- create_soundtestfiles_array()
- create_command_windows()
- create_help_window()
- create_soundinfo_window()
- create_numberinput_window()
- set_input_variables()
- setup_scene_intro_animation()
- # Current Selected Sound
- @current_sound_symbol = nil
- end
- #--------------------------------------------------------------------------
- # * Post-Start Processing
- #--------------------------------------------------------------------------
- def post_start
- super()
- animate_intro_scene()
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super()
- update_window_info_text()
- update_help_text()
- update_scene_changes()
- update_user_input()
- end
- #--------------------------------------------------------------------------
- # * Pre-Termination Processing
- #--------------------------------------------------------------------------
- def pre_terminate
- super()
- @current_map_bgm.replay()
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- @sound_select_cmmdwindow.dispose() unless @sound_select_cmmdwindow.disposed?
- @sound_play_cmmdwindow.dispose() unless @sound_play_cmmdwindow.disposed?
- @help_window.dispose() unless @help_window.disposed?
- @sound_info_window.dispose() unless @sound_info_window.disposed?
- @numberinput_window.dispose() unless @numberinput_window.disposed?
- unless @background_image.disposed?
- @background_image.bitmap.dispose()
- @background_image.dispose()
- end
- super()
- end
- #--------------------------------------------------------------------------
- # * Save Current BGM
- #--------------------------------------------------------------------------
- def save_current_bgm()
- # Get Current BGM
- @current_map_bgm = RPG::BGM.last
- RPG::BGM.stop()
- end
- #--------------------------------------------------------------------------
- # * Create Background Image
- #--------------------------------------------------------------------------
- def create_background_image()
- @background_image = Sprite.new()
- @background_image.bitmap = Cache.picture(BackgroundSpriteFilename)
- @background_image.x = 0
- @background_image.y = 0
- @background_image.z = 1
- @background_image.zoom_x = (Graphics.width.to_f / @background_image.bitmap.width)
- @background_image.zoom_y = (Graphics.height.to_f / @background_image.bitmap.height)
- end
- #--------------------------------------------------------------------------
- # * Create SoundTest Files Array
- #--------------------------------------------------------------------------
- def create_soundtestfiles_array()
- @soundfiles_hash = {}
- Sounds.each_key do |key_name|
- @soundfiles_hash[ key_name ] = SoundTestSound.new( key_name, Sounds[key_name][:default_volume], Sounds[key_name][:default_pitch] )
- end
- end
- #--------------------------------------------------------------------------
- # * Create Command Windows
- #--------------------------------------------------------------------------
- def create_command_windows()
- # Setting Up Command Window for Sounds
- command_window_ypos = 72
- @sound_select_cmmdwindow = Window_SoundTest_SoundCommand.new(0, command_window_ypos)
- @sound_select_cmmdwindow.height = Graphics.height - command_window_ypos
- set_soundcommand_window_handlers()
- # Setting Up Command Window for Play Sound
- @sound_play_cmmdwindow = Window_SoundTest_PlayCommand.new(Graphics.width * 0.5, command_window_ypos)
- @sound_play_cmmdwindow.deactivate()
- set_soundplay_window_handlers()
- end
- #--------------------------------------------------------------------------
- # * Set Command Handlers
- #--------------------------------------------------------------------------
- def set_soundcommand_window_handlers
- Sounds.each_key do |key_name|
- @sound_select_cmmdwindow.set_handler(key_name.to_sym, method(:deactivate_soundcommand_window))
- end
- end
- #--------------------------------------------------------------------------
- # * Set SoundPlay Handlers
- #--------------------------------------------------------------------------
- def set_soundplay_window_handlers
- @sound_play_cmmdwindow.set_handler(:play_sound, method(:playsound_command))
- @sound_play_cmmdwindow.set_handler(:volume, method(:playsound_at_volume))
- @sound_play_cmmdwindow.set_handler(:pitch, method(:playsound_at_pitch))
- @sound_play_cmmdwindow.set_handler(:position, method(:playsound_at_position))
- end
- #--------------------------------------------------------------------------
- # * Create Help Window
- #--------------------------------------------------------------------------
- def create_help_window()
- # Setting up Help Window
- @help_window = Window_Help.new()
- @help_window.set_text(SoundSelectHelpWindowTextLine1 + "\n" + SoundSelectHelpWindowTextLine2)
- end
- #--------------------------------------------------------------------------
- # * Create SoundInfo Window
- #--------------------------------------------------------------------------
- def create_soundinfo_window()
- # Setting up Sound Info Window
- @sound_info_window = Window_SoundInfo.new()
- @sound_info_window.x = Graphics.width * 0.5
- @sound_info_window.y = 192
- @sound_info_window.openness = 255
- end
- #--------------------------------------------------------------------------
- # * Create NumberInput Window
- #--------------------------------------------------------------------------
- def create_numberinput_window()
- # Setting Up Number Input
- @numberinput_window = Window_SoundTest_NumberInput.new()
- @numberinput_window.z = 200
- end
- #--------------------------------------------------------------------------
- # * Set Input Variables
- #--------------------------------------------------------------------------
- def set_input_variables()
- @user_currently_inputting_value = false
- @currently_entering_volume_value = false
- @currently_entering_pitch_value = false
- @currently_entering_position_value = false
- end
- #--------------------------------------------------------------------------
- # * Setup Scene Intro Animation
- #--------------------------------------------------------------------------
- def setup_scene_intro_animation()
- @background_image.opacity = 0
- @sound_select_cmmdwindow.x -= 500
- @sound_play_cmmdwindow.x += 500
- @help_window.y -= 400
- @sound_info_window.y += 300
- end
- #--------------------------------------------------------------------------
- # * Animate Intro Sequence
- #--------------------------------------------------------------------------
- def animate_intro_scene()
- while( true )
- bool1 = animate_sceneintro_background_image()
- bool2 = animate_sceneintro_soundselectcmmdwindow()
- bool3 = animate_sceneintro_soundplaycmmdwindow()
- bool4 = animate_sceneintro_helpwindow()
- bool5 = animate_sceneintro_soundinfowindow()
- Graphics.update()
- break if bool1 && bool2 && bool3 && bool4 && bool5
- end
- end
- #--------------------------------------------------------------------------
- # * Animate BackgroundImage Opacity for Intro Sequence
- #--------------------------------------------------------------------------
- def animate_sceneintro_background_image()
- return true if @background_image.opacity == 255
- @background_image.opacity += 5
- return @background_image.opacity == 255
- end
- #--------------------------------------------------------------------------
- # * Animate SoundSelectCommand Window for Intro Sequence
- #--------------------------------------------------------------------------
- def animate_sceneintro_soundselectcmmdwindow()
- return true if @sound_select_cmmdwindow.x == 0
- @sound_select_cmmdwindow.x += 20
- return @sound_select_cmmdwindow.x == 0
- end
- #--------------------------------------------------------------------------
- # * Animate SoundPlayCommand Window for Intro Sequence
- #--------------------------------------------------------------------------
- def animate_sceneintro_soundplaycmmdwindow()
- return true if @sound_play_cmmdwindow.x == (Graphics.width * 0.5)
- @sound_play_cmmdwindow.x -= 20
- return @sound_play_cmmdwindow.x == (Graphics.width * 0.5)
- end
- #--------------------------------------------------------------------------
- # * Animate Help Window for Intro Sequence
- #--------------------------------------------------------------------------
- def animate_sceneintro_helpwindow()
- return true if @help_window.y == 0
- @help_window.y += 10
- return @help_window.y == 0
- end
- #--------------------------------------------------------------------------
- # * Animate Sound Info Window
- #--------------------------------------------------------------------------
- def animate_sceneintro_soundinfowindow()
- return true if @sound_info_window.y == 192
- @sound_info_window.y -= 6
- return @sound_info_window.y == 192
- end
- #--------------------------------------------------------------------------
- # * Deactivate Sound Command Windows
- #--------------------------------------------------------------------------
- def deactivate_soundcommand_windows()
- @sound_select_cmmdwindow.deactivate()
- @sound_play_cmmdwindow.deactivate()
- end
- #--------------------------------------------------------------------------
- # * Deactivate Sound Command Window
- #--------------------------------------------------------------------------
- def deactivate_soundcommand_window()
- @sound_select_cmmdwindow.deactivate()
- @sound_play_cmmdwindow.activate()
- end
- #--------------------------------------------------------------------------
- # * Deactivate SoundPlay Command Window
- #--------------------------------------------------------------------------
- def deactivate_soundplaycommand_window()
- @sound_select_cmmdwindow.activate()
- @sound_play_cmmdwindow.deactivate()
- end
- #--------------------------------------------------------------------------
- # * Update Info Window Text
- #--------------------------------------------------------------------------
- def update_window_info_text()
- if @current_sound_symbol != @sound_select_cmmdwindow.current_symbol
- @current_sound_symbol = @sound_select_cmmdwindow.current_symbol
- text = Sounds[@current_sound_symbol.to_s][:info_line1].gsub("\n", "") + "\n"
- text += Sounds[@current_sound_symbol.to_s][:info_line2].gsub("\n", "") + "\n"
- text += Sounds[@current_sound_symbol.to_s][:info_line3].gsub("\n", "") + "\n"
- text += Sounds[@current_sound_symbol.to_s][:info_line4].gsub("\n", "")
- @sound_info_window.draw_text_soundinfo(text)
- end
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help_text()
- # If SoundSelect Command Window is Active
- if @sound_select_cmmdwindow.active
- @help_window.set_text(SoundSelectHelpWindowTextLine1 + "\n" + SoundSelectHelpWindowTextLine2)
- # If NumberInput Window is Active
- elsif @numberinput_window.active
- @help_window.set_text(NumberInputHelpWindowTextLine1 + "\n" + NumberInputHelpWindowTextLine2)
- # If Hovering Over PlaySound
- elsif @sound_play_cmmdwindow.current_symbol == :play_sound
- @help_window.set_text(PlaySoundOptionHelpWindowTextLine1 + "\n" + PlaySoundOptionHelpWindowTextLine2)
- # If Hovering Over Volume Input
- elsif @sound_play_cmmdwindow.current_symbol == :volume
- @help_window.set_text(VolumeOptionHelpWindowTextLine1 + "\n" + VolumeOptionHelpWindowTextLine2)
- # If Hovering Over Pitch Input
- elsif @sound_play_cmmdwindow.current_symbol == :pitch
- @help_window.set_text(PitchOptionHelpWindowTextLine1 + "\n" + PitchOptionHelpWindowTextLine2)
- # If Hovering Over Position Input
- else
- @help_window.set_text(PositionOptionHelpWindowTextLine1 + "\n" + PositionOptionHelpWindowTextLine2)
- end
- end
- #--------------------------------------------------------------------------
- # * Update Scene Changes
- #--------------------------------------------------------------------------
- def update_scene_changes()
- return_scene() if Input.trigger?(:B) && @sound_select_cmmdwindow.active
- deactivate_soundplaycommand_window() if Input.trigger?(:B) && @sound_play_cmmdwindow.active
- end
- #--------------------------------------------------------------------------
- # * Update User Input
- #--------------------------------------------------------------------------
- def update_user_input()
- if @user_currently_inputting_value && @numberinput_window.completed
- receive_volume_value() if @currently_entering_volume_value
- receive_pitch_value() if @currently_entering_pitch_value
- receive_position_value() if @currently_entering_position_value
- end
- end
- #--------------------------------------------------------------------------
- # * Play Sound Command
- #--------------------------------------------------------------------------
- def playsound_command()
- @soundfiles_hash[@current_sound_symbol.to_s].default_play()
- @sound_play_cmmdwindow.activate()
- end
- #--------------------------------------------------------------------------
- # * Play Sound 'At Volume' Command
- #--------------------------------------------------------------------------
- def playsound_at_volume()
- deactivate_soundcommand_windows()
- @user_currently_inputting_value = true
- @currently_entering_volume_value = true
- number = @soundfiles_hash[@current_sound_symbol.to_s].volume
- @numberinput_window.start( number, 3 )
- end
- #--------------------------------------------------------------------------
- # * Play Sound 'At Pitch' Command
- #--------------------------------------------------------------------------
- def playsound_at_pitch()
- deactivate_soundcommand_windows()
- @user_currently_inputting_value = true
- @currently_entering_pitch_value = true
- number = @soundfiles_hash[@current_sound_symbol.to_s].pitch
- @numberinput_window.start( number, 3 )
- end
- #--------------------------------------------------------------------------
- # * Play Sound 'At Position' Command
- #--------------------------------------------------------------------------
- def playsound_at_position()
- @currently_entering_position_value = true
- @user_currently_inputting_value = true
- deactivate_soundcommand_windows()
- @numberinput_window.start( 0, 9 )
- end
- #--------------------------------------------------------------------------
- # * Receive Volume Value
- #--------------------------------------------------------------------------
- def receive_volume_value()
- if @numberinput_window.processed_ok
- @soundfiles_hash[@current_sound_symbol.to_s].volume = @numberinput_window.result
- @soundfiles_hash[@current_sound_symbol.to_s].play()
- end
- @sound_play_cmmdwindow.activate()
- set_input_variables()
- end
- #--------------------------------------------------------------------------
- # * Receive Pitch Value
- #--------------------------------------------------------------------------
- def receive_pitch_value()
- if @numberinput_window.processed_ok
- @soundfiles_hash[@current_sound_symbol.to_s].pitch = @numberinput_window.result
- @soundfiles_hash[@current_sound_symbol.to_s].play()
- end
- @sound_play_cmmdwindow.activate()
- set_input_variables()
- end
- #--------------------------------------------------------------------------
- # * Receive Position Value
- #--------------------------------------------------------------------------
- def receive_position_value()
- if @numberinput_window.processed_ok
- @soundfiles_hash[@current_sound_symbol.to_s].play_at_position( @numberinput_window.result )
- end
- @sound_play_cmmdwindow.activate()
- set_input_variables()
- end
- end
- #==============================================================================
- # ** Window_MenuCommand
- #------------------------------------------------------------------------------
- # This command window appears on the menu screen.
- #==============================================================================
- class Window_MenuCommand < Window_Command
- #--------------------------------------------------------------------------
- # * Add Exit Game to Command List
- #--------------------------------------------------------------------------
- alias dp3_soundtestscene_windowmenucommd_addgameendcmmd_ofa add_game_end_command
- #--------------------------------------------------------------------------
- def add_game_end_command
- add_command(DiamondandPlatinum3::SoundTestScene::MenuCommandText, :sound_test)
- dp3_soundtestscene_windowmenucommd_addgameendcmmd_ofa()
- end
- end
- #==============================================================================
- # ** Scene_Menu
- #------------------------------------------------------------------------------
- # This class performs the menu screen processing.
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- alias dp3_soundtestscene_scenemenu_creatcmmdwind_ofa create_command_window
- #--------------------------------------------------------------------------
- def create_command_window
- dp3_soundtestscene_scenemenu_creatcmmdwind_ofa() # Call original Method
- @command_window.set_handler(:sound_test, method(:command_soundtest))
- end
- #--------------------------------------------------------------------------
- # * Command Sound Test
- #--------------------------------------------------------------------------
- def command_soundtest
- SceneManager.call(Scene_SoundTest)
- end
- end
- #==============================================================================
- # ** SoundTest_Command
- #------------------------------------------------------------------------------
- # The Command Window that is used when selecting a sound
- #==============================================================================
- class Window_SoundTest_SoundCommand < Window_Command
- include DiamondandPlatinum3::SoundTestScene
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width * 0.5
- end
- #--------------------------------------------------------------------------
- # * Make Command List
- #--------------------------------------------------------------------------
- def make_command_list
- Sounds.each_key do |key_name|
- switch_id = Sounds[key_name][:conditional_switch]
- next unless $game_switches[switch_id] || switch_id == 0
- add_command(Sounds[key_name][:display_name], key_name.to_sym)
- end
- end
- end
- #==============================================================================
- # ** PlaySound_Command
- #------------------------------------------------------------------------------
- # The Command Window that is used for playing a sound
- #==============================================================================
- class Window_SoundTest_PlayCommand < Window_Command
- include DiamondandPlatinum3::SoundTestScene
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width * 0.5
- end
- #--------------------------------------------------------------------------
- # * Make Command List
- #--------------------------------------------------------------------------
- def make_command_list
- add_command("Play Sound", :play_sound)
- add_command("Volume", :volume)
- add_command("Pitch", :pitch)
- add_command("Position", :position)
- end
- end
- #==============================================================================
- # ** Window_SoundInfo
- #------------------------------------------------------------------------------
- # This message window is used to display Sound Information
- #==============================================================================
- class Window_SoundInfo < Window_Message
- #--------------------------------------------------------------------------
- # * Set Font
- #--------------------------------------------------------------------------
- def set_font
- contents.font.size = 18
- end
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width * 0.5
- end
- #--------------------------------------------------------------------------
- # * Get Window Height
- #--------------------------------------------------------------------------
- def window_height
- return Graphics.height - 192
- end
- #--------------------------------------------------------------------------
- # * Draw Text
- #--------------------------------------------------------------------------
- def draw_text_soundinfo(text)
- contents.clear
- set_font()
- draw_text_ex(0, 0, word_wrapping(text))
- end
- #--------------------------------------------------------------------------
- # * Draw Text with Control Characters
- #--------------------------------------------------------------------------
- def draw_text_ex(x, y, text)
- text = convert_escape_characters(text)
- pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
- process_character(text.slice!(0, 1), text, pos) until text.empty?
- end
- #--------------------------------------------------------------------------
- # * Wait After Output of One Character
- #--------------------------------------------------------------------------
- def wait_for_one_character
- end
- #--------------------------------------------------------------------------
- # * Word Wrapping
- #--------------------------------------------------------------------------
- def word_wrapping(text, pos = 0)
- # Current Text Position
- current_text_position = 0
- for i in 0..(text.length - 1)
- if text[i] == "\n"
- current_text_position = 0
- next
- end
- # Current Position += character width
- current_text_position += contents.text_size(text[i]).width
- # If Current Position > Window Width
- if (pos + current_text_position) >= (contents.width)
- # Then Format the Sentence to fit Line
- current_element = i
- while(text[current_element] != " ")
- break if current_element == 0
- current_element -= 1
- end
- temp_text = ""
- for j in 0..(text.length - 1)
- temp_text += text[j]
- temp_text += "\n" if j == current_element
- end
- text = temp_text
- i = current_element
- current_text_position = 0
- end
- end
- return text
- end
- end
- #==============================================================================
- # ** Window_NumberInput
- #------------------------------------------------------------------------------
- # This window is used for the event command [Input Number].
- #==============================================================================
- class Window_SoundTest_NumberInput < Window_NumberInput
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_reader :result # The Result of User Input
- attr_reader :completed # User Finished Input Processing?
- attr_reader :processed_ok # User Did not Cancel User Input?
- #--------------------------------------------------------------------------
- # * Initialize
- #--------------------------------------------------------------------------
- def initialize()
- super( self )
- @result = 0
- @completed = true
- @processed_ok = false
- end
- #--------------------------------------------------------------------------
- # * Start Input Processing
- #--------------------------------------------------------------------------
- def start( number, digits )
- @digits_max = digits
- @number = number
- @index = 0
- @completed = false
- update_placement
- create_contents
- refresh
- open
- activate
- end
- #--------------------------------------------------------------------------
- # * Update Window Position
- #--------------------------------------------------------------------------
- def update_placement
- self.width = @digits_max * 20 + padding * 2
- self.height = fitting_height(1)
- self.x = (Graphics.width - width) / 2
- self.y = 192
- end
- #--------------------------------------------------------------------------
- # * Processing When OK Button Is Pressed
- #--------------------------------------------------------------------------
- def process_ok
- Sound.play_ok
- @result = @number
- @completed = true
- @processed_ok = true
- deactivate
- close
- end
- #--------------------------------------------------------------------------
- # * Processing When Cancel Button Is Pressed
- #--------------------------------------------------------------------------
- def process_cancel
- Sound.play_cancel
- @completed = true
- @processed_ok = false
- deactivate
- close
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement