[VXAce] Volume Control - Wersja do druku
Ultima Forum
[VXAce] Volume Control - Wersja do druku

+- Ultima Forum (https://forum.ultimateam.pl)
+-- Dział: RPG Maker (/Forum-RPG-Maker)
+--- Dział: Wsparcie (/Forum-Wsparcie)
+--- Wątek: [VXAce] Volume Control (/Thread-VXAce-Volume-Control)



Volume Control - helio108 - 22-12-13 17:03

Na Ultimie jest skrypt Volume Control i właśnie jego tyczy się moje pytanie
Jak ustawić żeby Okno Volume Control wyświetlało się w ekranie tytułowym?
Proszę o szybką odpowiedź.



RE: Volume Control - Ayene - 22-12-13 22:12

Zamień skrypt na poniższy:
Kod:
# encoding: utf-8
#===============================================================================​​
# ˇ Volume Control For RGSS3
#-------------------------------------------------------------------------------
#@2011/12/01@Ru/‚Ţ‚Á‚­Ru
#-------------------------------------------------------------------------------
# English Translation By:
# Elemental Crisis (http://RPGMakerVXAce.com AND http://RPGCrisis.net)
#
# Bug fixes and menu bars added by Kal.
# BGS fix by NS.
# Empty BGM & BGS fix by Ayene.
#-------------------------------------------------------------------------------
#@Adds the ability to change volume control.
#
#@The following methods are added to the Audio Module
#@Audio.volBGM cc Maximum BGM volume setting.
#@Audio.volBGS cc Maximum BGS volume setting.
#@Audio.volSE  cc Maximum SE volume setting.
#@Audio.volME  cc Maximum ME volume setting.
#@Audio.volBGM=Number cc Set BGM maximum volume (0-100)
#@Audio.volBGM=Number cc Set BGS maximum volume (0-100)
#@Audio.volSE=Number  cc Set SE maximum volume (0-100)
#@Audio.volME=Number  cc Set ME maximum volume (0-100)
#
#@Volume control is added to the main menu.
#
#-------------------------------------------------------------------------------
# Known Issues
#@Created before VXAce's official release so unable to properly test.
#-------------------------------------------------------------------------------

#==============================================================================
# ś Settings
#==============================================================================
module HZM_VXA
  module AudioVol
        # Display Volume Control on Main Menu?
        # true  cc Display.
        # false cc 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 cc Variation of Left/Right Keys.
        # ADD_VOL_HIGH   cc Variation of LR Key.
        ADD_VOL_NORMAL = 5
        ADD_VOL_HIGH   = 25
  
        # Use bars or numbers.
        # :bars  => use bars
        # :numbers  => use numbers
        DISPLAY = :bars
  
        # Bar display options.
        # The higher BAR_X the more to the right the bar is drawn.
        # BAR_WIDTH sets the width of the bar.
        # Y_ADJUST allows you to precisely adjust the y value (how high or low
        # the bar is rendered).
        BAR_X      = 55  
        BAR_WIDTH   = 70
        Y_ADJUST        = -3
  end
end

#==============================================================================
# Ş @ Settings Above @ Ş
# «    Script Below    «
#==============================================================================
# Additonal Methods.
# class << Audio means we open up the Audio module and all methods defined
# get defined on self (that is, the Audio module itself)
class << Audio

  def volBGM=(vol)
        @hzmVolBGM = normalize_volume(vol)
  end

  def volBGS=(vol)
        @hzmVolBGS = normalize_volume(vol)
  end

  def volSE=(vol)
        @hzmVolSE = normalize_volume(vol)
  end

  def volME=(vol)
        @hzmVolME = normalize_volume(vol)
  end

  def volBGM
        @hzmVolBGM.nil? ? @hzmVolBGM = 100 : @hzmVolBGM
  end

  def volBGS
        @hzmVolBGS.nil? ? @hzmVolBGS = 100 : @hzmVolBGS
  end

  def volSE
        @hzmVolSE.nil? ? @hzmVolSE = 100 : @hzmVolSE
  end

  def volME
        @hzmVolME.nil? ? @hzmVolME = 100 : @hzmVolME
  end

  # Make sure volume does not go over 100 or under 0.
  def normalize_volume(vol)
        vol = 100 if vol > 100
        vol = 0   if vol < 0
        vol
  end  
  # Playback
  alias hzm_Vol_Audio_bgm_play bgm_play
  def bgm_play(filename, volume=100, pitch=100, pos=0)
        volume = self.volBGM * volume.to_f / 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, pos=0)
        volume = self.volBGS * volume.to_f / 100
        hzm_Vol_Audio_bgs_play(filename, volume, pitch, pos)
  end

  alias hzm_Vol_Audio_se_play se_play
  def se_play(filename, volume=100, pitch=100)
        volume = self.volSE * volume.to_f / 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.to_f / 100
        hzm_Vol_Audio_me_play(filename, volume, pitch)
  end
end
# Add To Menu.
if HZM_VXA::AudioVol::MENU_FLAG
class Window_TitleCommand < Window_Command
        alias hzm_Vol_Window_MenuCommand_add_original_commands make_command_list
        def make_command_list
          hzm_Vol_Window_MenuCommand_add_original_commands
          add_command(HZM_VXA::AudioVol::MENU_NAME, :hzm_vxa_vol)  
        end
  end
  class Scene_Title < Scene_Base

        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 Change 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
          
                # Draws vol as a number or as a bar.
                if DISPLAY == :bars
                  y = (index * line_height) + Y_ADJUST
                  draw_gauge(BAR_X, y, BAR_WIDTH, vol / 100.0, normal_color, normal_color)
                else
                  draw_text(item_rect_for_text(index), vol, 2)
                end
          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.name.empty?
                when 1
                  Audio.volBGS += val
                  now = RPG::BGS.last
                  Audio.bgs_play('Audio/BGS/' + now.name, now.volume, now.pitch, now.pos) if !now.name.empty?
                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



RE: Volume Control - helio108 - 22-12-13 22:37

Hm.
A da się tak żeby on wbił nad wyjście?
Bo na samym dole dziwnie wygląda.


RE: Volume Control - Ayene - 22-12-13 22:42

Da radę. Zamień ponownie skrypt na poniższy:
Kod:
# encoding: utf-8
#===============================================================================​​
# ˇ Volume Control For RGSS3
#-------------------------------------------------------------------------------
#@2011/12/01@Ru/‚Ţ‚Á‚­Ru
#-------------------------------------------------------------------------------
# English Translation By:
# Elemental Crisis (http://RPGMakerVXAce.com AND http://RPGCrisis.net)
#
# Bug fixes and menu bars added by Kal.
# BGS fix by NS.
# Empty BGM & BGS fix by Ayene.
#-------------------------------------------------------------------------------
#@Adds the ability to change volume control.
#
#@The following methods are added to the Audio Module
#@Audio.volBGM cc Maximum BGM volume setting.
#@Audio.volBGS cc Maximum BGS volume setting.
#@Audio.volSE  cc Maximum SE volume setting.
#@Audio.volME  cc Maximum ME volume setting.
#@Audio.volBGM=Number cc Set BGM maximum volume (0-100)
#@Audio.volBGM=Number cc Set BGS maximum volume (0-100)
#@Audio.volSE=Number  cc Set SE maximum volume (0-100)
#@Audio.volME=Number  cc Set ME maximum volume (0-100)
#
#@Volume control is added to the main menu.
#
#-------------------------------------------------------------------------------
# Known Issues
#@Created before VXAce's official release so unable to properly test.
#-------------------------------------------------------------------------------

#==============================================================================
# ś Settings
#==============================================================================
module HZM_VXA
  module AudioVol
        # Display Volume Control on Main Menu?
        # true  cc Display.
        # false cc 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 cc Variation of Left/Right Keys.
        # ADD_VOL_HIGH   cc Variation of LR Key.
        ADD_VOL_NORMAL = 5
        ADD_VOL_HIGH   = 25
  
        # Use bars or numbers.
        # :bars  => use bars
        # :numbers  => use numbers
        DISPLAY = :bars
  
        # Bar display options.
        # The higher BAR_X the more to the right the bar is drawn.
        # BAR_WIDTH sets the width of the bar.
        # Y_ADJUST allows you to precisely adjust the y value (how high or low
        # the bar is rendered).
        BAR_X      = 55  
        BAR_WIDTH   = 70
        Y_ADJUST        = -3
  end
end

#==============================================================================
# Ş @ Settings Above @ Ş
# «    Script Below    «
#==============================================================================
# Additonal Methods.
# class << Audio means we open up the Audio module and all methods defined
# get defined on self (that is, the Audio module itself)
class << Audio

  def volBGM=(vol)
        @hzmVolBGM = normalize_volume(vol)
  end

  def volBGS=(vol)
        @hzmVolBGS = normalize_volume(vol)
  end

  def volSE=(vol)
        @hzmVolSE = normalize_volume(vol)
  end

  def volME=(vol)
        @hzmVolME = normalize_volume(vol)
  end

  def volBGM
        @hzmVolBGM.nil? ? @hzmVolBGM = 100 : @hzmVolBGM
  end

  def volBGS
        @hzmVolBGS.nil? ? @hzmVolBGS = 100 : @hzmVolBGS
  end

  def volSE
        @hzmVolSE.nil? ? @hzmVolSE = 100 : @hzmVolSE
  end

  def volME
        @hzmVolME.nil? ? @hzmVolME = 100 : @hzmVolME
  end

  # Make sure volume does not go over 100 or under 0.
  def normalize_volume(vol)
        vol = 100 if vol > 100
        vol = 0   if vol < 0
        vol
  end  
  # Playback
  alias hzm_Vol_Audio_bgm_play bgm_play
  def bgm_play(filename, volume=100, pitch=100, pos=0)
        volume = self.volBGM * volume.to_f / 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, pos=0)
        volume = self.volBGS * volume.to_f / 100
        hzm_Vol_Audio_bgs_play(filename, volume, pitch, pos)
  end

  alias hzm_Vol_Audio_se_play se_play
  def se_play(filename, volume=100, pitch=100)
        volume = self.volSE * volume.to_f / 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.to_f / 100
        hzm_Vol_Audio_me_play(filename, volume, pitch)
  end
end
# Add To Menu.
if HZM_VXA::AudioVol::MENU_FLAG
class Window_TitleCommand < Window_Command
        
    def make_command_list
      add_command(Vocab::new_game, :new_game)
      add_command(Vocab::continue, :continue, continue_enabled)
      add_command(HZM_VXA::AudioVol::MENU_NAME, :hzm_vxa_vol)  
      add_command(Vocab::shutdown, :shutdown)
    end      
        
  end
  class Scene_Title < Scene_Base

        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 Change 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
          
                # Draws vol as a number or as a bar.
                if DISPLAY == :bars
                  y = (index * line_height) + Y_ADJUST
                  draw_gauge(BAR_X, y, BAR_WIDTH, vol / 100.0, normal_color, normal_color)
                else
                  draw_text(item_rect_for_text(index), vol, 2)
                end
          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.name.empty?
                when 1
                  Audio.volBGS += val
                  now = RPG::BGS.last
                  Audio.bgs_play('Audio/BGS/' + now.name, now.volume, now.pitch, now.pos) if !now.name.empty?
                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



RE: Volume Control - helio108 - 22-12-13 22:47

Dzięki Ayene!
Mam u Cb dług wdzięczności (Tak naprawde to nie, poprostu tak pisze Xp).