Allemov

Liczba postów: 75
Dołączył: 29-07-13
Pomógł: 2

|
RE: Zmiana głośności muzyki gry w menu
(12-11-14 02:16)Ayene napisał(a): Sprawdź to:
#==============================================================================
# ** Scene_Volume by Ayene
#
# * $scene = Scene_Volume.new
#==============================================================================
module RPG
#--------------------------------------------------------------------------
# * SE
#--------------------------------------------------------------------------
class SE < AudioFile
def play
unless @name.empty?
Audio.se_play("Audio/SE/" + @name, $game_config.se_volume, @pitch)
end
end
end
#--------------------------------------------------------------------------
# * ME
#--------------------------------------------------------------------------
class ME < AudioFile
def play
unless @name.empty?
Audio.me_play("Audio/ME/" + @name, $game_config.se_volume, @pitch)
end
end
end
#--------------------------------------------------------------------------
# * BGM
#--------------------------------------------------------------------------
class BGM < AudioFile
@@last = BGM.new
def play
if @name.empty?
Audio.bgm_stop
@@last = BGM.new
else
Audio.bgm_play("Audio/BGM/" + @name, $game_config.bgm_volume, @pitch)
@@last = self
end
end
end
#--------------------------------------------------------------------------
# * BGS
#--------------------------------------------------------------------------
class BGS < AudioFile
@@last = BGS.new
def play
if @name.empty?
Audio.bgs_stop
@@last = BGS.new
else
Audio.bgs_play("Audio/BGS/" + @name, $game_config.bgm_volume, @pitch)
@@last = self
end
end
end
end
class Bitmap
#--------------------------------------------------------------------------
# * Gradient Volume Bar
#--------------------------------------------------------------------------
def gradient_bar_volume(x, y, w, color1, color2, rate)
fill_rect(x + 1, y, w + 2, 14, Color.new(106, 106, 106, 255))
(1..6).each {|i|
color = Color.new(color2.red*i/6, color2.green*i/6, color2.blue*i/6, 255)
fill_rect(x + 2, y + i, w, 14 - i * 2, color)
color = Color.new(color1.red*i/6, color1.green*i/6, color1.blue*i/6, 255)
fill_rect(x + 2, y + i, rate, 14 - i * 2, color)}
end
end
class Game_Config
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :bgm_volume
attr_accessor :se_volume
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@bgm_volume = 80
@se_volume = 60
end
#--------------------------------------------------------------------------
# * Save Configuration
#--------------------------------------------------------------------------
def config_save
file = File.open("Config.rvdata", "wb")
Marshal.dump($game_config, file)
file.close
end
end
class Sprite_Volume < Sprite
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(view, bar)
super(view)
self.bitmap = Bitmap.new(410, 58)
self.z = 1000
refresh(bar)
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose
super
end
#--------------------------------------------------------------------------
# * Frame Refresh
#--------------------------------------------------------------------------
def refresh(vol)
self.bitmap.clear
rate = (vol < 100 ? vol * 100 / 100 : 100)
color1 = Color.new(231, 255, 30, 255)
color2 = Color.new(0, 0, 80, 255)
self.bitmap.gradient_bar_volume(0, 32, 100, color1, color2, rate)
text = sprintf("%d%", vol)
self.bitmap.draw_text(116, 22, 120, 32, text)
end
end
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
alias aye_vol_sctitle_crgmob create_game_objects
def create_game_objects
aye_vol_sctitle_crgmob
filename = "Config.rvdata"
if FileTest.exist?(filename)
file = File.open(filename, "rb")
$game_config = Marshal.load(file)
file.close
else
$game_config = Game_Config.new
end
end
end
class Scene_Volume < Scene_Base
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
def start
super
create_command_window
end
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
def terminate
super
@command_window.dispose
@volume_bgm.dispose
@volume_se.dispose
end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
com = ["BGM", "SE"]
@command_window = Window_Command.new(320, com)
@command_window.x = 110
@command_window.y = 108
@volume_bgm = Sprite_Volume.new(nil, $game_config.bgm_volume)
@volume_bgm.y = 96
@volume_bgm.x = 240
@volume_se = Sprite_Volume.new(nil, $game_config.se_volume)
@volume_se.y = @volume_bgm.y + Window_Base::WLH
@volume_se.x = 240
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
command_selection
end
#--------------------------------------------------------------------------
# * Command Selection
#--------------------------------------------------------------------------
def command_selection
@command_window.update
case @command_window.index
when 0
if Input.press?(Input::LEFT) and $game_config.bgm_volume > 0
$game_config.bgm_volume -= 1
@volume_bgm.refresh($game_config.bgm_volume)
elsif Input.press?(Input::RIGHT) and $game_config.bgm_volume < 100
$game_config.bgm_volume += 1
@volume_bgm.refresh($game_config.bgm_volume)
end
when 1
if Input.press?(Input::LEFT) and $game_config.se_volume > 0
$game_config.se_volume -= 1
@volume_se.refresh($game_config.se_volume)
elsif Input.press?(Input::RIGHT) and $game_config.se_volume < 100
$game_config.se_volume += 1
@volume_se.refresh($game_config.se_volume)
end
end
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
return_scene
end
end
#--------------------------------------------------------------------------
# * Return Scene
#--------------------------------------------------------------------------
def return_scene
Sound.play_decision
$game_config.config_save
$game_map.autoplay
$scene = Scene_Map.new
end
end
Wkleiłem, żaden błąd nie wyskakuje, ale menu nigdzie nie ma.
Umieściłem skrypt w złym miejscu, czy mam gdzieś umieścić odnośnik do niego?
|
|