Da
Ally
Nome Script: Controllo Volume
Versione: 1.0.0
Autore/i: Ru/むっくRu, Elemental Crisis (traduzione inglese)
Informazioni:
Questo script permette di controllare le impostazioni del volume di gioco.
Istruzioni:
Inserite lo script sotto Material.
Script:
#===============================================================================
# ¡ Volume Control For RGSS3
#-------------------------------------------------------------------------------
#@2011/12/01@[member='Rusjbhlmi']/‚Þ‚Á‚Ru
#-------------------------------------------------------------------------------
# English Translation By: Elemental Crisis (http://RPGMakerVXAce.com)
#-------------------------------------------------------------------------------
#@Adds the ability to change volume control.
#
#@œ The following methods are added to the Audio Module
#@Audio.volBGM cc Maximum BGM volume setting.
#@Audio.volBGS cc Maximum BGS volume setting.
#@Audio.volSE cc Maximum SE volume setting.
#@Audio.volME cc Maximum ME volume setting.
#@Audio.volBGM=”’l ccSet BGM maximum volume (0-100)
#@Audio.volBGM=”’l cc Set BGS maximum volume (0-100)
#@Audio.volSE=”’l cc Set SE maximum volume (0-100)
#@Audio.volME=”’l cc Set ME maximum volume (0-100)
#
#@œ Volume control is added to the main menu.
#
#-------------------------------------------------------------------------------
# yKnown Issuesz
#@Created before VXAce's official release so unable to properly test.
#-------------------------------------------------------------------------------
#==============================================================================
# œ Settings
#==============================================================================
module HZM_VXA
module AudioVol
# Display Volume Control on Main Menu?
# @true cc Display.
# @false cc Don't Display.
MENU_FLAG = true
# Volume Control Name in Main Menu.
MENU_NAME = "Volume Settings"
# Volume Control Settings Name.
CONFIG_BGM_NAME = "BGM"
CONFIG_BGS_NAME = "BGS"
CONFIG_SE_NAME = "SE"
CONFIG_ME_NAME = "ME"
CONFIG_EXIT_NAME = "Exit"
# Volume Change Variation.
# ADD_VOL_NORMAL cc Variation of Left/Right Keys.
# ADD_VOL_HIGH cc Variation of LR Key.
ADD_VOL_NORMAL = 5
ADD_VOL_HIGH = 25
end
end
#==============================================================================
# ª @ Settings Above @ ª
# « Script Below «
#==============================================================================
# Additonal Methods.
module Audio
def self.volBGM=(vol)
vol=100 if vol>100
vol=0 if vol<0
@hzmVolBGM = vol
end
def self.volBGS=(vol)
vol=100 if vol>100
vol=0 if vol<0
@hzmVolBGS = vol
end
def self.volSE=(vol)
vol=100 if vol>100
vol=0 if vol<0
@hzmVolSE = vol
end
def self.volME=(vol)
vol=100 if vol>100
vol=0 if vol<0
@hzmVolME = vol
end
def self.volBGM
@hzmVolBGM = 100 if @hzmVolBGM == nil
return @hzmVolBGM
end
def self.volBGS
@hzmVolBGS = 100 if @hzmVolBGS == nil
return @hzmVolBGS
end
def self.volSE
@hzmVolSE = 100 if @hzmVolSE == nil
return @hzmVolSE
end
def self.volME
@hzmVolME = 100 if @hzmVolME == nil
return @hzmVolME
end
end
# Playback
class << Audio
alias hzm_Vol_Audio_bgm_play bgm_play
def bgm_play(filename, volume=100, pitch=100, pos=0)
volume = self.volBGM * volume / 100
hzm_Vol_Audio_bgm_play(filename, volume, pitch, pos)
end
alias hzm_Vol_Audio_bgs_play bgs_play
def bgs_play(filename, volume=100, pitch=100)
volume = self.volBGS * volume / 100
hzm_Vol_Audio_bgs_play(filename, volume, pitch)
end
alias hzm_Vol_Audio_se_play se_play
def se_play(filename, volume=100, pitch=100)
volume = self.volSE * volume / 100
hzm_Vol_Audio_se_play(filename, volume, pitch)
end
alias hzm_Vol_Audio_me_play me_play
def me_play(filename, volume=100, pitch=100)
volume = self.volME * volume / 100
hzm_Vol_Audio_me_play(filename, volume, pitch)
end
end
# Add To Menu.
if HZM_VXA::AudioVol::MENU_FLAG
class Window_MenuCommand
alias hzm_Vol_Window_MenuCommand_add_original_commands add_original_commands
def add_original_commands
hzm_Vol_Window_MenuCommand_add_original_commands
add_command(HZM_VXA::AudioVol::MENU_NAME, :hzm_vxa_vol)
end
end
class Scene_Menu
alias hzm_Vol_create_command_window create_command_window
def create_command_window
hzm_Vol_create_command_window
@command_window.set_handler(:hzm_vxa_vol, method(:hzm_vxa_vol))
end
def hzm_vxa_vol
SceneManager.call(HZM_VXA::AudioVol::Scene_VolConfig)
end
end
end
# Volume Chage Window
module HZM_VXA
module AudioVol
class Window_VolConfig < Window_Command
def initialize
super(0, 0)
self.x = (Graphics.width - self.window_width)/2
self.y = (Graphics.height - self.window_height)/2
end
def make_command_list
add_command(HZM_VXA::AudioVol::CONFIG_BGM_NAME, :bgm)
add_command(HZM_VXA::AudioVol::CONFIG_BGS_NAME, :bgs)
add_command(HZM_VXA::AudioVol::CONFIG_SE_NAME, :se)
add_command(HZM_VXA::AudioVol::CONFIG_ME_NAME, :me)
add_command(HZM_VXA::AudioVol::CONFIG_EXIT_NAME, :cancel)
end
def draw_item(index)
super
return unless index < 4
case index
when 0
vol = Audio.volBGM
when 1
vol = Audio.volBGS
when 2
vol = Audio.volSE
when 3
vol = Audio.volME
end
draw_text(item_rect_for_text(index), vol, 2)
end
def volAdd(index, val)
case index
when 0
Audio.volBGM += val
now = RPG::BGM.last
Audio.bgm_play('Audio/BGM/' + now.name, now.volume, now.pitch, now.pos) if now
when 1
Audio.volBGS += val
when 2
Audio.volSE += val
when 3
Audio.volME += val
end
Sound.play_cursor
redraw_item(index)
end
def cursor_left(wrap = false)
volAdd(@index, -HZM_VXA::AudioVol::ADD_VOL_NORMAL)
end
def cursor_right(wrap = false)
volAdd(@index, HZM_VXA::AudioVol::ADD_VOL_NORMAL)
end
def cursor_pageup
volAdd(@index, -HZM_VXA::AudioVol::ADD_VOL_HIGH)
end
def cursor_pagedown
volAdd(@index, HZM_VXA::AudioVol::ADD_VOL_HIGH)
end
end
class Scene_VolConfig < Scene_MenuBase
def start
super
@command_window = Window_VolConfig.new
@command_window.viewport = @viewport
@command_window.set_handler(:cancel, method(:return_scene))
end
def terminate
super
@command_window.dispose
end
end
end
end
# Reading/Saving
class << DataManager
alias hzm_Vol_make_save_contents make_save_contents
def make_save_contents
contents = hzm_Vol_make_save_contents
contents[:hzm_vxa_vol] = {
:bgm => Audio.volBGM,
:bgs => Audio.volBGS,
:se => Audio.volSE,
:me => Audio.volME
}
contents
end
alias hzm_Vol_extract_save_contents extract_save_contents
def extract_save_contents(contents)
hzm_Vol_extract_save_contents(contents)
Audio.volBGM = contents[:hzm_vxa_vol][:bgm]
Audio.volBGS = contents[:hzm_vxa_vol][:bgs]
Audio.volSE = contents[:hzm_vxa_vol][:se]
Audio.volME = contents[:hzm_vxa_vol][:me]
end
end