#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: # Missing Audio Replacer # Version: 1.00 # Author : LiTTleDRAgo #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=: ($imported ||= {})[:drg_missing_audio_replacer] = 1.00 #============================================================================== # ** Audio #------------------------------------------------------------------------------ # This class handles audio. Background music, etc. is managed here #============================================================================== class << Audio #-------------------------------------------------------------------------- # * CONFIGURATION #-------------------------------------------------------------------------- BGM_REPLACE = { 'Title_Music' => ['064-Slow07'], } BGS_REPLACE = { 'Rain' => ['005-Rain01', '006-Rain02'], } ME_REPLACE = { 'Battle_Victory' => ['001-Victory01'], } SE_REPLACE = { 'Cat' => ['067-Animal02'], 'Horse' => ['071-Animal06'], } #-------------------------------------------------------------------------- # * CONFIGURATION END #-------------------------------------------------------------------------- @@sound_check = {} #-------------------------------------------------------------------------- # * Play Background Music # bgm : background music to be played #-------------------------------------------------------------------------- [:bgm,:bgs,:me,:se].each do |method| $@ || alias_method(:"#{method}_exist_play", :"#{method}_play") define_method(:"#{method}_play") do |*bgm| bgm[0] = sound_exist?(File.basename(bgm[0]), method) || '' send(:"#{method}_exist_play",*bgm) rescue send(:"#{method}_stop") end end #-------------------------------------------------------------------------- # * Determine if Audio Exist #-------------------------------------------------------------------------- def sound_exist?(sound,type) key = [sound,type] return @@sound_check[key] if @@sound_check[key] != nil all_sound = [sound] + (eval("#{type.to_s.upcase}_REPLACE")[sound] || []) @@sound_check[key] = all_sound.map {|s| "Audio/#{type}/#{s}"}.find do |s| [se_exist_play(s, 0, 0), se_stop] rescue false end || false end end