# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Soul Engine Ace - Soul Liquid Music Player
# Author: Soulpour777
# Version 1.0
# Script Category: Custom Scenes
# Included in Soul Engine Ace
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Description: Creates a customizable music player for your games. The music
# player allows a simple play and stop as well as free space to add graphics.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Needed Files:
# Place the Music_BG, Music_Wave and Music_Layout on the Graphics\Systems
# folder. For your custom music, place them under Audio\BGM folder.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Script Calls:
# To call up the Music Player, do this on a script call:
# SceneManager.call(Scene_MusicMenu)
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# The script is currently installed on the Menu Command.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Terms of Use:
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# For Non-Commercial Use:
# You are free to use the script on any non-commercial projects.
# You are free to adapt the script. Any modifications are allowed as long
# as it is provided as a note on the script.
# Credits to SoulPour777 for the script.
# Preserve the Script Header.
# Claiming the script as your own is prohibited.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

#==============================================================================
# ** Soulpour
#------------------------------------------------------------------------------
# This module holds all Soulpour configurations.
#==============================================================================
module Soulpour
# What is the name of the music player in your menu?
Menu_Name = "Soul Music"
#--------------------------------------------------------------------------
# * Music Configuration Variable Module
#--------------------------------------------------------------------------
module MusicConfig
# Width of the Window Displayer
Displayer_Hieght = 200
# New Width of the Displayer
Display_Width = 400
# X Location of the Displayer
Display_X = 78
# Y Location of the Displauer
Display_Y = 45
# Opacity of the Displayer
DisplayOpacity = 100
# Height of the Displayer
DisplayHeight = 100
# Opacity of the Window
Window_Opacity = 35
# Y Location of the Window
Window_Y = 272
# Height of the Window
Window_Height = 160
end

#--------------------------------------------------------------------------
# * Music Player Module
#--------------------------------------------------------------------------
module MusicPlayer

#--------------------------------------------------------------------------
# * Music Names
# Here, indicate which music is to be played. Custom music is to be placed
# under the BGM folder.
#--------------------------------------------------------------------------
Music_Info = {
"Stop" => { :song_command => RPG::BGM, },
"Praise the King" => { :song_command => RPG::BGM.new("Theme2", 100, 100), },
"Holy Land" => { :song_command => RPG::BGM.new("Theme3", 100, 100), },
"Dragonsing" => { :song_command => RPG::BGM.new("Theme4", 100, 100), },
"Dragonsong" => { :song_command => RPG::BGM.new("Dungeon1", 100, 100), },
"Creepy Cave" => { :song_command => RPG::BGM.new("Dungeon2", 100, 100), },
"Caverns of No Return" => { :song_command => RPG::BGM.new("Dungeon3", 100, 100), },
"Dark Raid" => { :song_command => RPG::BGM.new("Dungeon4", 100, 100), },
"Crawl" => { :song_command => RPG::BGM.new("Dungeon5", 100, 100), },
"Queen Shall Be Saved" => { :song_command => RPG::BGM.new("Scene2", 100, 100), },
"King's Claim" => { :song_command => RPG::BGM.new("Scene3", 100, 100), },
"Dragon Return" => { :song_command => RPG::BGM.new("Scene4", 100, 100), },
}

end

end
#==============================================================================
# ** Window_MusicDisplayer
#------------------------------------------------------------------------------
# This class performs the window that displays the displayer.
#==============================================================================
class Window_MusicDisplayer < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, fitting_height(1))
refresh
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return Soulpour::MusicConfig::Display_Width
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
end
#--------------------------------------------------------------------------
# * Open Window
#--------------------------------------------------------------------------
def open
refresh
super
end

end


#==============================================================================
# ** Window_MusicCommand
#------------------------------------------------------------------------------
# This command window appears on the menu screen for the Music Player.
#==============================================================================

class Window_MusicCommand < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0)
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return Graphics.width
end

#--------------------------------------------------------------------------
# * Get Window Height
#--------------------------------------------------------------------------
def window_height
return Graphics.height - 50
end

#--------------------------------------------------------------------------
# * Get Number of Lines to Show
#--------------------------------------------------------------------------
def visible_line_number
item_max
end
#--------------------------------------------------------------------------
# * Create Command List
#--------------------------------------------------------------------------
def make_command_list
add_main_commands
end
#--------------------------------------------------------------------------
# * Add Main Commands to List
#--------------------------------------------------------------------------
def add_main_commands
Soulpour::MusicPlayer::Music_Info.each_key { |i|
add_command(i, :song_command)
}
end

end

#==============================================================================
# ** Scene_MusicMenu
#------------------------------------------------------------------------------
# This class performs the Music Menu.
#==============================================================================

class Scene_MusicMenu < Scene_MenuBase
#--------------------------------------------------------------------------
# * Start Processing
#--------------------------------------------------------------------------
def start
super
create_command_window
create_background
create_window_display
end

#--------------------------------------------------------------------------
# * Create Window Display
#--------------------------------------------------------------------------
def create_window_display
@window_display = Window_MusicDisplayer.new
@window_display.width = Soulpour::MusicConfig::Display_Width
@window_display.x = Soulpour::MusicConfig::Display_X
@window_display.y = Soulpour::MusicConfig::Display_Y
@window_display.height = Soulpour::MusicConfig::Displayer_Hieght
@window_display.opacity = Soulpour::MusicConfig::DisplayOpacity
end

#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
@music_window = Window_MusicCommand.new
@music_window.opacity = Soulpour::MusicConfig::Window_Opacity
@music_window.y = Soulpour::MusicConfig::Window_Y
@music_window.height = Soulpour::MusicConfig::Window_Height
@music_window.set_handler(:song_command, method(:command_song))
end

#--------------------------------------------------------------------------
# * Create Background
#--------------------------------------------------------------------------
def create_background
@music_background = Plane.new
@music_background.bitmap = Cache.system("Music_BG")
@music_background.z = 20
@music_layout = Plane.new
@music_layout.bitmap = Cache.system ("Music_Layout")
@music_layout.z = 80
@music_wave = Plane.new
@music_wave.bitmap = Cache.system("Music_Wave")
@music_wave.opacity = 45
@music_wave.z = 120
end

#--------------------------------------------------------------------------
# * Dispose Background
#--------------------------------------------------------------------------
def dispose_background
@music_layout.dispose
@music_background.dispose
@music_wave.dispose
end

#--------------------------------------------------------------------------
# * Update Frame (Basic)
#--------------------------------------------------------------------------
def update_basic
@music_wave.ox += 1
command_return if Input.trigger?(:B)
super
end

#--------------------------------------------------------------------------
# * Command Return
#--------------------------------------------------------------------------
def command_return
RPG::BGM.stop
Sound.play_cancel
return_scene
end

# ------------------------------------------------------------------
# Command Song
# ------------------------------------------------------------------
def command_song
case
when @music_window.index == 0
Soulpour::MusicPlayer::Music_Info[Soulpour::MusicPlayer::Music_Info.keys].stop
when @music_window.index != 0
Soulpour::MusicPlayer::Music_Info[Soulpour::MusicPlayer::Music_Info.keys].play
end
@music_window.activate
end

end

#==============================================================================
# ** Window_MenuCommand
#------------------------------------------------------------------------------
# This command window appears on the menu screen.
#==============================================================================

class Window_MenuCommand < Window_Command
#--------------------------------------------------------------------------
# * Original Commands
#--------------------------------------------------------------------------
alias soul_command_add_original_commands_music add_original_commands
def add_original_commands
soul_command_add_original_commands_music
add_command(Soulpour::Menu_Name, :soul_music, main_commands_enabled)
end
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
alias soul_command_create_command_window_music create_command_window
def create_command_window
soul_command_create_command_window_music
@command_window.set_handler(:soul_music, method(:command_soul_music))
end

#--------------------------------------------------------------------------
# * Create Sutom Command
#--------------------------------------------------------------------------
def command_soul_music
SceneManager.call(Scene_MusicMenu)
end

end