| 赞 | 91 |
| VIP | |
| 好人卡 | |
| 积分 | 104 |
| 经验 | |
| 最后登录 | 2024-6-24 |
| 在线时间 | 5019 小时 |
无限の剣制
- 梦石
- 0
- 星屑
- 10445
- 在线时间
- 5019 小时
- 注册时间
- 2013-2-28
- 回帖
- 4942
 
|
发表于 2017-2-10 10:18:05
|
显示全部楼层
本帖最后由 VIPArcher 于 2017-2-10 10:22 编辑
- #==============================================================================
- # ○サウンドコンフィグ
- # for RGSS3
- # 巫女瓜 / Space not far
- # [url]http://muspell.raindrop.jp/[/url]
- # タイトル画面に音量調節機能を追加します。
- #==============================================================================
-
- module SoundConfig
- FileName = "SoundConfig.rvdata2" # 音量調節の保存先
- Span = 5 # 音量調節間隔。100の約数を推奨
- Position = 0 # 位置 0:左上 1:右上 2:左下 3:右下
- end
-
- module RPG
- #==============================================================================
- # ■ AudioFile
- #==============================================================================
- class AudioFile
- alias snf_volume_initialize initialize unless $@
- def initialize(name = "", volume = 100, pitch = 100)
- snf_volume_initialize(name, volume, pitch)
- @base_volume = @volume
- end
- #--------------------------------------------------------------------------
- # ● 音量変更
- #--------------------------------------------------------------------------
- def volume_change
- @base_volume = @volume if @base_volume.nil?
- @volume = (@base_volume * correction_value / 100)
- end
- #--------------------------------------------------------------------------
- # ● 音量補正値の取得
- #--------------------------------------------------------------------------
- def correction_value
- if self.is_a?(RPG::BGM) or self.is_a?(RPG::ME) or self.is_a?(RPG::BGS)
- return SoundConfig.load(0)
- elsif self.is_a?(RPG::SE)
- return SoundConfig.load(1)
- end
- return 100
- end
- end
- class BGS < AudioFile
- alias snf_volume_play play unless $@
- def play(pos = 0)
- volume_change
- snf_volume_play(pos)
- end
- end
-
- class BGM < AudioFile
- alias snf_volume_play play unless $@
- def play(pos = 0)
- volume_change
- snf_volume_play(pos)
- end
- end
- class SE < AudioFile
- alias snf_volume_play play unless $@
- def play
- volume_change
- snf_volume_play
- end
- end
- class ME < AudioFile
- alias snf_volume_play play unless $@
- def play
- volume_change
- snf_volume_play
- end
- end
- end
-
- class Scene_Volume < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● 開始処理
- #--------------------------------------------------------------------------
- def start
- super
- create_soundconfig
- end
- #--------------------------------------------------------------------------
- # ● 生成背景
- #--------------------------------------------------------------------------
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- end
- #--------------------------------------------------------------------------
- # ● 释放背景
- #--------------------------------------------------------------------------
- def dispose_background
- @background_sprite.dispose
- @sprite_sound.dispose
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- if Input.repeat?(:LEFT)
- vol = [bgm_vol - volume_span, 0].max
- SoundConfig.save(0, vol)
- Sound.play_cursor
- refresh_soundconfig
- RPG::BGM::last.play
- end
- if Input.repeat?(:RIGHT)
- vol = [bgm_vol + volume_span, 100].min
- SoundConfig.save(0, vol)
- Sound.play_cursor
- refresh_soundconfig
- RPG::BGM::last.play
- end
- if Input.repeat?(:L)
- vol = [se_vol - volume_span, 0].max
- SoundConfig.save(1, vol)
- Sound.play_cursor
- refresh_soundconfig
- end
- if Input.repeat?(:R)
- vol = [se_vol + volume_span, 100].min
- SoundConfig.save(1, vol)
- Sound.play_cursor
- refresh_soundconfig
- end
- if Input.repeat?(:B)
- return_scene
- end
- end
- #--------------------------------------------------------------------------
- # @ スプライト作成
- #--------------------------------------------------------------------------
- def create_soundconfig
- @sprite_sound = Sprite.new
- @sprite_sound.bitmap = Bitmap.new(Graphics.width, Graphics.height)
- @sprite_sound.z = 150
- refresh_soundconfig
- end
- def bgm_vol
- return SoundConfig.load(0)
- end
- def se_vol
- return SoundConfig.load(1)
- end
- def volume_span
- return SoundConfig::Span
- end
- def refresh_soundconfig
- @sprite_sound.bitmap.clear
- @sprite_sound.bitmap.font.size = 12
- @sprite_sound.bitmap.font.name = "MS ゴシック"
- case SoundConfig::Position
- when 0 #左上
- align = 0
- y = 4
- when 1 #右上
- align = 2
- y = 4
- when 2 #左下
- align = 0
- y = Graphics.height - 40
- when 3 #右下
- align = 2
- y = Graphics.height - 40
- end
- @sprite_sound.bitmap.draw_text(4, y, Graphics.width - 8, 12, sprintf(" ← BGM %03d% →" , bgm_vol.to_s), align)
- @sprite_sound.bitmap.draw_text(4, y + 12, Graphics.width - 8, 12, sprintf(" Q SE %03d% W" , se_vol.to_s), align)
- @sprite_sound.bitmap.draw_text(4, y + 24, Graphics.width - 8, 12, " 按 B 返回地图", align)
- end
- end
-
- module SoundConfig
- def self.save(index, value)
- data = self.loaddata
- data[index] = value
- file = File.open(FileName, "wb")
- Marshal.dump(data, file)
- file.close
- end
- def self.load(index)
- data = self.loaddata
- value = data[index] if data
- if value.nil?
- value = 100
- self.save(index, value)
- end
- return value
- end
- def self.loaddata
- if FileTest.exist?(FileName)
- file = File.open(FileName, "r")
- data = Marshal.load(file)
- file.close
- else
- data = []
- end
- return data
- end
- end
复制代码 瞎改未测试,用下面事件脚本转到这个音量界面- SceneManager.call(Scene_Volume)
复制代码 |
评分
-
查看全部评分
|