| 赞 | 62 |
| VIP | |
| 好人卡 | |
| 积分 | 65 |
| 经验 | |
| 最后登录 | 2025-2-24 |
| 在线时间 | 1275 小时 |
百合控
- 梦石
- 0
- 星屑
- 6548
- 在线时间
- 1275 小时
- 注册时间
- 2013-8-21
- 回帖
- 3522

|
发表于 2013-11-3 11:20:27
|
显示全部楼层
本帖最后由 余烬之中 于 2014-7-25 12:44 编辑
本来打算通过system来访问注册表获取音频文件以及拓展名…………
想想还是没有必要 就算可以访问RTP 如果作者忘记打包音频还是没有用
需要自行设置的是一开始的比特率,因为这东西貌似不是固定的…… 改成了设置每个声音的长度
以及音效组@group
可以通过事件来增添列表 你应该看得懂 但是还是解释一下:Smomo.segroup(operator, first = nil, second = nil)
这是唯一的操作方法
operator的取值:
:get
获取当前的@group,另外两个参数没有意义
:append
向first组中新增项second
:delete
删除first组中的second
如果second为nil或false 则删除first整个组
如果first为nil或false 则删除所有组中的second
两个都为nil或false 报错没商量
:init
调用init方法
:reset
调用reset方法
其他
报错
简单的测试了一下 应该没有问题 就算有我最近也不能来修……
我是代码以下代码[pre lang="ruby" line="1"]$smomo ||= {}
$smomo["SoundGroup"] = true
#==============================================================================
# ** Smomo::SEGroup
#==============================================================================
module Smomo
module SEGroup
#=============================== settings begin ===============================#
Supported = %W{ OGG WMA MP3 WAV MID }
# append as you like
Length = {
# "sound" => length(flame),
"Absorb1" => 120,
"Absorb2" => 120,
"Applause1" => 100,
"Applause2" => 100,
"Autodoor" => 80,
"Blind" => 150,
"Cursor1" => 100,
"Cursor2" => 100,
}
#================================ settings end ================================#
module_function
#--------------------------------------------------------------------------
# * Initialize SE groups
#--------------------------------------------------------------------------
def init
#=============================== settings begin ===============================#
@group = {
# group-name => ["sound 1", "sound 2", ...],
:absorb => ["Absorb1" , "Absorb2" ],
:applause => ["Applause1", "Applause2"],
:group_one => ["Autodoor" , "Blind" ],
:cursor => ["Cursor1" , "Cursor2" ],
}
#================================ settings end ================================#
reset
end
#--------------------------------------------------------------------------
# * Reset
#--------------------------------------------------------------------------
def reset
@Time = {}
@group.each_key{|sym| @time[sym] = Time.now}
end
#--------------------------------------------------------------------------
# * OK to play?
#--------------------------------------------------------------------------
def check(se)
return Time.now > @time[se]
end
#--------------------------------------------------------------------------
# * Set the time to end
#--------------------------------------------------------------------------
def set_time(file, se)
raise Errno::ENOENT, "Sound File Must Be In Game Folder!" if no_file? file
raise Errno::EINVAL, "Must Set The Length!" if !Length[file].is_a? Integer
@time[se] = Time.now + Length[file] / 60.0
end
#--------------------------------------------------------------------------
# * Sound file in game folder?
#--------------------------------------------------------------------------
def no_file?(file)
file = 'Audio/SE/' + file
Supported.each{|e| break e if FileTest.exist?(file + "." + e)}.is_a? Array
end
#--------------------------------------------------------------------------
# * Dynamic configuration changes
#--------------------------------------------------------------------------
def function(operator, first = nil, second = nil)
case operator
when :get
@group
when :append
@group[first].push second
@group[first].uniq!
when :delete
first ? second ? @group[first].delete(second) : @group.delete(first):
@group.each{|group| group.delete second}
when :init
init
when :reset
reset
else
raise ArgumentError, "Invalid Operator!"
end
end
end
module_function
#--------------------------------------------------------------------------
# * Entry
#--------------------------------------------------------------------------
def segroup(*args)
Smomo::SEGroup.function(*args)
end
end
Smomo.segroup :init
#==============================================================================
# ** RPG::SE
#==============================================================================
class RPG::SE
#--------------------------------------------------------------------------
# * Alias method: play
#--------------------------------------------------------------------------
alias :mo_segroup_play :play
def play
mo_segroup_play if mo_segroup_playOK?
end
#--------------------------------------------------------------------------
# * OK to play?
#--------------------------------------------------------------------------
def mo_segroup_playOK?
current = Smomo.segroup(:get).each do |key, group|
break key if group.include? @name
end
return true if current.is_a? Hash
Smomo::SEGroup.check(current) &&
Smomo::SEGroup.set_time(@name, current)
end
#--------------------------------------------------------------------------
# * Alias method: stop
#--------------------------------------------------------------------------
class << self
alias :mo_segroup_stop :stop
def stop
mo_segroup_stop
Smomo::SEGroup.reset
end
end
end unless RPG::SE.respond_to? :mo_segroup_stop[/pre] |
|