#==============================================================================
# ** Juan's Option Menu
#------------------------------------------------------------------------------
# Juan
# Version 2.0
# Type: Custom Component System
# Date 9/21/08
# Date Last Updated 1/31/09
#==============================================================================
#
# This work is protected by the following license:
# #----------------------------------------------------------------------------
# #
# # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #
# # You are free:
# #
# # to Share - to copy, distribute and transmit the work
# # to Remix - to adapt the work
# #
# # Under the following conditions:
# #
# # Attribution. You must attribute the work in the manner specified by the
# # author or licensor (but not in any way that suggests that they endorse you
# # or your use of the work).
# #
# # Noncommercial. You may not use this work for commercial purposes.
# #
# # Share alike. If you alter, transform, or build upon this work, you may
# # distribute the resulting work only under the same or similar license to
# # this one.
# #
# # - For any reuse or distribution, you must make clear to others the license
# # terms of this work. The best way to do this is with a link to this web
# # page.
# #
# # - Any of the above conditions can be waived if you get permission from the
# # copyright holder.
# #
# # - Nothing in this license impairs or restricts the author's moral rights.
# #
# #----------------------------------------------------------------------------
#
# Compatibility:
# This script is independent so it doesn't modify anything.
# Compatable with the Sdk
# Compatable with Dream for music files
# Compatable and Supports Tons of add-ons by Blizzard
#
#
#Features:
#
# -> Change Bgm volume
# -> Change Sfx volume
#
#Version History
#
#Version 1.0
#-> This script was first made
#Version 2.0
#-> Completely Rewritten
#-> Less Code
#-> Added Full scene option
#-> The option help window now works.
#
#
#Instructions
# Configurate everything in Juan_Configuration module.
# To call the option menu use $scene = Scene_Option.new
#
#
#
#FAQ (Frequently Asked Questions):
#None so far
#
#
#Credits
#Blizzard
#Wcw
#Susy
#
#
#Author's Notes
#Credit me and enjoy
#Any bugs or need help
#Report them here:
#http://forum.chaos-project.com/index.php?topic=782.0
#or
#Email me
#Juanito119@yahoo.com
#Thats it
#enjoy
#==============================================================================
# module Juan_Configuration
#==============================================================================
module Juan_Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Option Menu Opacity
Option_Menu_Opacity = 200
#True or false if you want to see the mapground
Map_Background = true
end
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#==============================================================================
# Game_System
#==============================================================================
class Game_System
attr_accessor :bgm_volume
attr_accessor :sfx_volume
alias init_juan_cms_later initialize
def initialize
init_juan_cms_later
@bgm_volume = 100
@sfx_volume = 100
end
if $dream_music
def bgm_play(bgm)
@playing_bgm = bgm
if bgm != nil && bgm.name != ''
vol = correction(@bgm_volume)
dream_ed = bgm.clone
dream_ed.volume = dream_ed.volume * vol / 100
DREAM.play_encrypted_audio('Audio/BGM/', dream_ed, 0)
else
Audio.bgm_stop
end
Graphics.frame_reset
end
def bgs_play(bgs)
@playing_bgs = bgs
if bgs != nil && bgs.name != ''
vol = correction(@sfx_volume)
dream_ed = bgs.clone
dream_ed.volume = dream_ed.volume * vol / 100
DREAM.play_encrypted_audio('Audio/BGS/', dream_ed, 1)
else
Audio.bgs_stop
end
Graphics.frame_reset
end
def me_play(me)
if me != nil && me.name != ''
vol = correction(@bgm_volume)
dream_ed = me.clone
dream_ed.volume = dream_ed.volume * vol / 100
DREAM.play_encrypted_audio('Audio/ME/', dream_ed, 2)
else
Audio.me_stop
end
Graphics.frame_reset
end
def se_play(se)
if se != nil && se.name != ''
vol = correction(@sfx_volume)
dream_ed = se.clone
dream_ed.volume = dream_ed.volume * vol / 100
DREAM.play_encrypted_audio('Audio/SE/', dream_ed, 3)
end
end
else
def bgm_play(bgm)
@playing_bgm = bgm
if bgm != nil && bgm.name != ''
vol = correction(@bgm_volume)
Audio.bgm_play('Audio/BGM/' + bgm.name , bgm.volume * vol / 100, bgm.pitch)
else
Audio.bgm_stop
end
Graphics.frame_reset
end
def bgs_play(bgs)
@playing_bgs = bgs
if bgs != nil && bgs.name != ''
vol = correction(@sfx_volume)
Audio.bgs_play('Audio/BGS/' + bgs.name, bgs.volume * vol / 100, bgs.pitch)
else
Audio.bgs_stop
end
Graphics.frame_reset
end
def me_play(me)
if me != nil && me.name != ''
vol = correction(@bgm_volume)
Audio.me_play('Audio/ME/' + me.name, me.volume * vol / 100, me.pitch)
else
Audio.me_stop
end
Graphics.frame_reset
end
def se_play(se)
if se != nil && se.name != ''
vol = correction(@sfx_volume)
Audio.se_play('Audio/SE/' + se.name, se.volume * vol / 100, se.pitch)
end
end
end
def correction(volume)
case volume
when 100 then return 100
when 95 then return 97
when 90 then return 95
when 85 then return 92
when 80 then return 90
when 75 then return 87
when 70 then return 85
when 65 then return 82
when 60 then return 80
when 55 then return 77
when 50 then return 75
when 45 then return 72
when 40 then return 70
when 35 then return 65
when 30 then return 60
when 25 then return 55
when 20 then return 50
when 15 then return 40
when 10 then return 35
when 5 then return 25
end
return 0
end
end
#==============================================================================
# ** Window_Option
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Window_Option < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 50)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = Juan_Configuration::Option_Menu_Opacity
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update(option_text)
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, -9, 600, 32, option_text, 0)
self.contents.font.color = normal_color
end
end
#==============================================================================
# ** Window_Option_Info1
#------------------------------------------------------------------------------
# This window displays option menu information on the option menu screen.
#==============================================================================
class Window_Option_Info < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 160)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = Juan_Configuration::Option_Menu_Opacity
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, 'Bgm Volume')
self.contents.draw_text(4, 64, 120, 32, 'Sfx Volume')
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_system.bgm_volume.to_s, 2)
self.contents.draw_text(4, 96, 120, 32, $game_system.sfx_volume.to_s, 2)
end
end
#==============================================================================
# ** Window_Bgm_Volume
#------------------------------------------------------------------------------
# This window displays bgm volume on the option screen.
#==============================================================================
class Window_Bgm_Volume < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = Juan_Configuration::Option_Menu_Opacity
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, 'Bgm Volume')
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_system.bgm_volume.to_s, 2)
end
end
#==============================================================================
# ** Window_Sfx_Volume
#------------------------------------------------------------------------------
# This window displays sfx volume on the option screen.
#==============================================================================
class Window_Sfx_Volume < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = Juan_Configuration::Option_Menu_Opacity
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, 'Sfx Volume')
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_system.sfx_volume.to_s, 2)
end
end
#==============================================================================
# ** Scene_Option
#------------------------------------------------------------------------------
# This class performs option menu screen processing.
#==============================================================================
class Scene_Option
#--------------------------------------------------------------------------
# * Object Initialization
# option_menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(option_menu_index = 0)
@option_menu_index = option_menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
s1 = 'Bgm Volume'
s2 = 'Sfx Volume'
@command_window = Window_Command.new(160, [s1, s2])
@command_window.x = 0
@command_window.y = 50
@command_window.opacity = Juan_Configuration::Option_Menu_Opacity
# Make option info window
@option_window = Window_Option.new
@option_window.x = 0
@option_window.y = 0
@option_window.z = 200
# Make option window information 1
@window_option_info = Window_Option_Info.new
@window_option_info.x = 160
@window_option_info.y = 50
@window_option_info.z = 200
# Make spriteset
@spriteset = Spriteset_Map.new if Juan_Configuration::Map_Background
# Execute transition
Graphics.transition
# Main loop
loop {
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Option Frame update
option_update
# Abort loop if screen is changed
if $scene != self
break
end
}
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@option_window.dispose
@window_option_info.dispose
@spriteset.dispose if Juan_Configuration::Map_Background
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@window_option_info.update
@spriteset.update if Juan_Configuration::Map_Background
# If command window is active: call update_command
if @command_window.active
update_command
return
end
end
#--------------------------------------------------------------------------
# * Option Window Frame Update
#--------------------------------------------------------------------------
def option_update
# Branch by command window cursor position
case @command_window.index
when 0 # bgm volume
@option_window.update('Change the bgm volume.')
when 1 # sfx volume
@option_window.update('Change the sfx volume.')
else
@option_window.update('Unknown option.')
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0:
$scene = Scene_Bgm_Volume.new
when 1:
$scene = Scene_Sfx_Volume.new
end
return
end
end
end
#==============================================================================
# ** Scene_Bgm_Volume
#------------------------------------------------------------------------------
# This class performs options bgm changing processing.
#==============================================================================
class Scene_Bgm_Volume
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = '0%'
s2 = '25%'
s3 = '50%'
s4 = '75%'
s5 = '100%'
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.index = @menu_index
@command_window.opacity = Juan_Configuration::Option_Menu_Opacity
@bgm_volume_window = Window_Bgm_Volume.new
@bgm_volume_window.x = 160
@bgm_volume_window.y = 0
# Make spriteset
@spriteset = Spriteset_Map.new if Juan_Configuration::Map_Background
# Execute transition
Graphics.transition
# Main loop
loop {
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
break if $scene != self
}
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@spriteset.dispose if Juan_Configuration::Map_Background
@bgm_volume_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@spriteset.update if Juan_Configuration::Map_Background
@bgm_volume_window.update
# If command window is active: call update_command
if @command_window.active
update_command
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Option.new
# If C button was pressed
elsif Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # bgm volume 100
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to bgm volume to 0
$game_system.bgm_volume = 0
# Switch to bgm volume scene
$scene = Scene_Bgm_Volume.new
when 1 # bgm volume 100
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to bgm volume to 25
$game_system.bgm_volume = 25
# Switch to bgm volume scene
$scene = Scene_Bgm_Volume.new(1)
when 2 # bgm volume 100
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to bgm volume to 50
$game_system.bgm_volume = 50
# Switch to bgm volume scene
$scene = Scene_Bgm_Volume.new(2)
when 3 # bgm volume 100
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to bgm volume to 75
$game_system.bgm_volume = 75
# Switch to bgm volume scene
$scene = Scene_Bgm_Volume.new(3)
when 4 # bgm volume 100
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to bgm volume to 100
$game_system.bgm_volume = 100
# Switch to bgm volume scene
$scene = Scene_Bgm_Volume.new(4)
end
end
end
end
#==============================================================================
# ** Scene_Sfx_Volume
#------------------------------------------------------------------------------
# This class performs options sfx changing processing.
#==============================================================================
class Scene_Sfx_Volume
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = '0%'
s2 = '25%'
s3 = '50%'
s4 = '75%'
s5 = '100%'
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5])
@command_window.index = @menu_index
@command_window.opacity = Juan_Configuration::Option_Menu_Opacity
@sfx_volume_window = Window_Sfx_Volume.new
@sfx_volume_window.x = 160
@sfx_volume_window.y = 0
# Make spriteset
@spriteset = Spriteset_Map.new if Juan_Configuration::Map_Background
# Execute transition
Graphics.transition
# Main loop
loop {
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
break if $scene != self
}
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@sfx_volume_window.dispose
@spriteset.dispose if Juan_Configuration::Map_Background
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@sfx_volume_window.update
@spriteset.update if Juan_Configuration::Map_Background
# If command window is active: call update_command
if @command_window.active
update_command
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Option.new(2)
# If C button was pressed
elsif Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # sfx volume 0
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to sfx volume to 0
$game_system.sfx_volume = 0
# Switch to sfx scene
$scene = Scene_Sfx_Volume.new
when 1 # sfx volume 25
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to sfx volume to 25
$game_system.sfx_volume = 25
# Switch to sfx scene
$scene = Scene_Sfx_Volume.new(1)
when 2 # sfx voulme 50
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to sfx volume to 50
$game_system.sfx_volume = 50
# Switch to sfx scene
$scene = Scene_Sfx_Volume.new(2)
when 3 # sfx volume 75
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to sfx volume to 75
$game_system.sfx_volume = 75
# Switch to sfx scene
$scene = Scene_Sfx_Volume.new(3)
when 4 # sfx voulme 100
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to sfx volume to 100
$game_system.sfx_volume = 100
# Switch to sfx scene
$scene = Scene_Sfx_Volume.new(4)
end
end
end
end