mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Removed unused audio utilities and audio-recording (e.g. for Chatter)
This commit is contained in:
@@ -1,17 +1,3 @@
|
||||
class Thread
|
||||
def Thread.exclusive
|
||||
old_critical = Thread.critical
|
||||
begin
|
||||
Thread.critical = true
|
||||
return yield
|
||||
ensure
|
||||
Thread.critical = old_critical
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def getPlayMusic
|
||||
return MiniRegistry.get(MiniRegistry::HKEY_CURRENT_USER,
|
||||
"SOFTWARE\\Enterbrain\\RGSS","PlayMusic",true)
|
||||
@@ -29,7 +15,7 @@ class AudioContext
|
||||
|
||||
def initialize
|
||||
init = Win32API.new("audio.dll", "AudioContextInitialize", '', 'l')
|
||||
@context=init.call()
|
||||
@context=init.call
|
||||
end
|
||||
|
||||
def dispose
|
||||
@@ -59,17 +45,6 @@ def at_exit(&block)
|
||||
$AtExitProcs.push(Proc.new(&block))
|
||||
end
|
||||
|
||||
#####################################
|
||||
# Works around a problem with FileTest.exist
|
||||
# if directory contains accent marks
|
||||
if !defined?(safeExists?)
|
||||
def safeExists?(f)
|
||||
ret=false
|
||||
File.open(f,"rb") { ret=true } rescue nil
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
module AudioState
|
||||
@@ -147,7 +122,7 @@ module AudioState
|
||||
def self.volume; @volume; end
|
||||
|
||||
def self.waitingBGM=(value);
|
||||
Thread.exclusive { @waitingBGM=value; }
|
||||
@waitingBGM = value
|
||||
end
|
||||
|
||||
def self.volume=(value); @volume=value; end
|
||||
@@ -171,7 +146,7 @@ def Audio_bgm_pitch
|
||||
end
|
||||
|
||||
def Audio_bgm_play(name, volume, pitch, position = 0)
|
||||
volume=0 if !getPlayMusic()
|
||||
volume=0 if !getPlayMusic
|
||||
begin
|
||||
filename = canonicalize(RTP.getAudioPath(name))
|
||||
if AudioState.meActive?
|
||||
@@ -196,7 +171,7 @@ def Audio_bgm_fade(ms)
|
||||
AudioState::AudioContextFadeOut.call(AudioState.context,ms.to_i)
|
||||
end
|
||||
|
||||
def Audio_bgm_stop()
|
||||
def Audio_bgm_stop
|
||||
begin
|
||||
AudioState::AudioContextStop.call(AudioState.context)
|
||||
AudioState.waitingBGM=nil
|
||||
@@ -222,7 +197,7 @@ def Audio_bgm_set_volume(volume)
|
||||
end
|
||||
|
||||
def Audio_me_play(name, volume, pitch, position = 0)
|
||||
volume=0 if !getPlayMusic()
|
||||
volume=0 if !getPlayMusic
|
||||
begin
|
||||
filename = canonicalize(RTP.getAudioPath(name))
|
||||
if AudioState.bgmActive?
|
||||
@@ -246,12 +221,12 @@ def Audio_me_fade(ms)
|
||||
AudioState::AudioContextFadeOut.call(AudioState.meContext,ms)
|
||||
end
|
||||
|
||||
def Audio_me_stop()
|
||||
def Audio_me_stop
|
||||
AudioState::AudioContextStop.call(AudioState.meContext)
|
||||
end
|
||||
|
||||
def Audio_bgs_play(name, volume, pitch, position = 0)
|
||||
volume=0 if !getPlaySound()
|
||||
volume=0 if !getPlaySound
|
||||
begin
|
||||
filename = canonicalize(RTP.getAudioPath(name))
|
||||
AudioState::AudioContextPlay.call(AudioState.bgsContext,filename,
|
||||
@@ -265,12 +240,12 @@ def Audio_bgs_fade(ms)
|
||||
AudioState::AudioContextFadeOut.call(AudioState.bgsContext,ms)
|
||||
end
|
||||
|
||||
def Audio_bgs_stop()
|
||||
def Audio_bgs_stop
|
||||
AudioState::AudioContextStop.call(AudioState.bgsContext)
|
||||
end
|
||||
|
||||
def Audio_se_play(name, volume, pitch, position = 0)
|
||||
volume=0 if !getPlaySound()
|
||||
volume=0 if !getPlaySound
|
||||
begin
|
||||
filename = canonicalize(RTP.getAudioPath(name))
|
||||
AudioState::AudioContextSEPlay.call(AudioState.seContext,filename,
|
||||
@@ -280,7 +255,7 @@ def Audio_se_play(name, volume, pitch, position = 0)
|
||||
end
|
||||
end
|
||||
|
||||
def Audio_se_stop()
|
||||
def Audio_se_stop
|
||||
AudioState::AudioContextStop.call(AudioState.seContext)
|
||||
end
|
||||
|
||||
@@ -334,7 +309,7 @@ if safeExists?("audio.dll")
|
||||
end
|
||||
|
||||
def self.bgm_stop
|
||||
Audio_bgm_stop()
|
||||
Audio_bgm_stop
|
||||
end
|
||||
|
||||
def self.bgm_position
|
||||
@@ -350,7 +325,7 @@ if safeExists?("audio.dll")
|
||||
end
|
||||
|
||||
def self.me_stop
|
||||
Audio_me_stop()
|
||||
Audio_me_stop
|
||||
end
|
||||
|
||||
def self.bgs_play(name,volume=80,pitch=100)
|
||||
@@ -362,7 +337,7 @@ if safeExists?("audio.dll")
|
||||
end
|
||||
|
||||
def self.bgs_stop
|
||||
Audio_bgs_stop()
|
||||
Audio_bgs_stop
|
||||
end
|
||||
|
||||
=begin
|
||||
@@ -371,8 +346,169 @@ if safeExists?("audio.dll")
|
||||
end
|
||||
|
||||
def self.se_stop
|
||||
Audio_se_stop()
|
||||
Audio_se_stop
|
||||
end
|
||||
=end
|
||||
end
|
||||
end # safeExists?("audio.dll")
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Methods that determine the duration of an audio file.
|
||||
#===============================================================================
|
||||
def getOggPage(file)
|
||||
fgetdw = proc { |file|
|
||||
(file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0))
|
||||
}
|
||||
dw = fgetdw.call(file)
|
||||
return nil if dw != 0x5367674F
|
||||
header = file.read(22)
|
||||
bodysize = 0
|
||||
hdrbodysize = (file.read(1)[0] rescue 0)
|
||||
hdrbodysize.times do
|
||||
bodysize += (file.read(1)[0] rescue 0)
|
||||
end
|
||||
ret = [header, file.pos, bodysize, file.pos + bodysize]
|
||||
return ret
|
||||
end
|
||||
|
||||
# internal function
|
||||
def oggfiletime(file)
|
||||
fgetdw = proc { |file|
|
||||
(file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0))
|
||||
}
|
||||
fgetw = proc { |file|
|
||||
(file.eof? ? 0 : (file.read(2).unpack("v")[0] || 0))
|
||||
}
|
||||
pages = []
|
||||
page = nil
|
||||
loop do
|
||||
page = getOggPage(file)
|
||||
break if !page
|
||||
pages.push(page)
|
||||
file.pos = page[3]
|
||||
end
|
||||
return -1 if pages.length == 0
|
||||
curserial = nil
|
||||
i = -1
|
||||
pcmlengths = []
|
||||
rates = []
|
||||
for page in pages
|
||||
header = page[0]
|
||||
serial = header[10, 4].unpack("V")
|
||||
frame = header[2, 8].unpack("C*")
|
||||
frameno = frame[7]
|
||||
frameno = (frameno << 8) | frame[6]
|
||||
frameno = (frameno << 8) | frame[5]
|
||||
frameno = (frameno << 8) | frame[4]
|
||||
frameno = (frameno << 8) | frame[3]
|
||||
frameno = (frameno << 8) | frame[2]
|
||||
frameno = (frameno << 8) | frame[1]
|
||||
frameno = (frameno << 8) | frame[0]
|
||||
if serial != curserial
|
||||
curserial = serial
|
||||
file.pos = page[1]
|
||||
packtype = (file.read(1)[0] rescue 0)
|
||||
string = file.read(6)
|
||||
return -1 if string != "vorbis"
|
||||
return -1 if packtype != 1
|
||||
i += 1
|
||||
version = fgetdw.call(file)
|
||||
return -1 if version != 0
|
||||
rates[i] = fgetdw.call(file)
|
||||
end
|
||||
pcmlengths[i] = frameno
|
||||
end
|
||||
ret = 0.0
|
||||
for i in 0...pcmlengths.length
|
||||
ret += pcmlengths[i].to_f / rates[i]
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
# Gets the length of an audio file in seconds. Supports WAV, MP3, and OGG files.
|
||||
def getPlayTime(filename)
|
||||
if safeExists?(filename)
|
||||
return [getPlayTime2(filename), 0].max
|
||||
elsif safeExists?(filename + ".wav")
|
||||
return [getPlayTime2(filename + ".wav"), 0].max
|
||||
elsif safeExists?(filename + ".mp3")
|
||||
return [getPlayTime2(filename + ".mp3"), 0].max
|
||||
elsif safeExists?(filename + ".ogg")
|
||||
return [getPlayTime2(filename + ".ogg"), 0].max
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
def getPlayTime2(filename)
|
||||
return -1 if !safeExists?(filename)
|
||||
time = -1
|
||||
fgetdw = proc { |file|
|
||||
(file.eof? ? 0 : (file.read(4).unpack("V")[0] || 0))
|
||||
}
|
||||
fgetw = proc { |file|
|
||||
(file.eof? ? 0 : (file.read(2).unpack("v")[0] || 0))
|
||||
}
|
||||
File.open(filename, "rb") { |file|
|
||||
file.pos = 0
|
||||
fdw = fgetdw.call(file)
|
||||
if fdw == 0x46464952 # "RIFF"
|
||||
filesize = fgetdw.call(file)
|
||||
wave = fgetdw.call(file)
|
||||
return -1 if wave != 0x45564157 # "WAVE"
|
||||
fmt = fgetdw.call(file)
|
||||
return -1 if fmt != 0x20746d66 # "fmt "
|
||||
fmtsize = fgetdw.call(file)
|
||||
format = fgetw.call(file)
|
||||
channels = fgetw.call(file)
|
||||
rate = fgetdw.call(file)
|
||||
bytessec = fgetdw.call(file)
|
||||
return -1 if bytessec == 0
|
||||
bytessample = fgetw.call(file)
|
||||
bitssample = fgetw.call(file)
|
||||
data = fgetdw.call(file)
|
||||
return -1 if data != 0x61746164 # "data"
|
||||
datasize = fgetdw.call(file)
|
||||
time = (datasize*1.0)/bytessec
|
||||
return time
|
||||
elsif fdw == 0x5367674F # "OggS"
|
||||
file.pos = 0
|
||||
time = oggfiletime(file)
|
||||
return time
|
||||
end
|
||||
file.pos = 0
|
||||
# Find the length of an MP3 file
|
||||
while true
|
||||
rstr = ""
|
||||
ateof = false
|
||||
while !file.eof?
|
||||
if (file.read(1)[0] rescue 0) == 0xFF
|
||||
begin
|
||||
rstr = file.read(3)
|
||||
rescue
|
||||
ateof = true
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
break if ateof || !rstr || rstr.length != 3
|
||||
if rstr[0] == 0xFB
|
||||
t = rstr[1] >> 4
|
||||
next if t == 0 || t == 15
|
||||
freqs = [44100, 22050, 11025, 48000]
|
||||
bitrates = [32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320]
|
||||
bitrate = bitrates[t]
|
||||
t = (rstr[1] >> 2) & 3
|
||||
freq = freqs[t]
|
||||
t = (rstr[1] >> 1) & 1
|
||||
filesize = FileTest.size(filename)
|
||||
frameLength = ((144000 * bitrate) / freq) + t
|
||||
numFrames = filesize / (frameLength + 4)
|
||||
time = (numFrames * 1152.0 / freq)
|
||||
break
|
||||
end
|
||||
end
|
||||
}
|
||||
return time
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -270,57 +270,24 @@ end
|
||||
|
||||
|
||||
|
||||
# A safer version of RPG::Cache, this module loads bitmaps that keep an internal
|
||||
# reference count. Each call to dispose decrements the reference count and the
|
||||
# bitmap is freed when the reference count reaches 0.
|
||||
class Thread
|
||||
def Thread.exclusive
|
||||
old_thread_status = Thread.critical
|
||||
begin
|
||||
Thread.critical = true
|
||||
return yield
|
||||
ensure
|
||||
Thread.critical = old_thread_status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class BitmapWrapper < Bitmap
|
||||
attr_reader :refcount
|
||||
|
||||
@@disposedBitmaps={}
|
||||
@@keys={}
|
||||
=begin
|
||||
@@final = lambda { |id|
|
||||
Thread.exclusive {
|
||||
if @@disposedBitmaps[id]!=true
|
||||
File.open("debug.txt","ab") { |f|
|
||||
f.write("Bitmap finalized without being disposed: #{@@keys[id]}\r\n")
|
||||
}
|
||||
end
|
||||
@@disposedBitmaps[id]=nil
|
||||
}
|
||||
}
|
||||
=end
|
||||
attr_reader :refcount
|
||||
|
||||
def dispose
|
||||
return if self.disposed?
|
||||
@refcount-=1
|
||||
if @refcount==0
|
||||
super
|
||||
#Thread.exclusive { @@disposedBitmaps[__id__]=true }
|
||||
end
|
||||
super if @refcount==0
|
||||
end
|
||||
|
||||
def initialize(*arg)
|
||||
super
|
||||
@refcount=1
|
||||
#Thread.exclusive { @@keys[__id__]=arg.inspect+caller(1).inspect }
|
||||
#ObjectSpace.define_finalizer(self,@@final)
|
||||
end
|
||||
|
||||
def resetRef # internal
|
||||
def resetRef
|
||||
@refcount=1
|
||||
end
|
||||
|
||||
|
||||
@@ -600,6 +600,22 @@ def pbFadeOutInWithUpdate(z,sprites,nofadeout=false)
|
||||
end
|
||||
end
|
||||
|
||||
# Similar to pbFadeOutIn, but pauses the music as it fades out.
|
||||
# Requires scripts "Audio" (for bgm_pause) and "SpriteWindow" (for pbFadeOutIn).
|
||||
def pbFadeOutInWithMusic(zViewport=99999)
|
||||
playingBGS = $game_system.getPlayingBGS
|
||||
playingBGM = $game_system.getPlayingBGM
|
||||
$game_system.bgm_pause(1.0)
|
||||
$game_system.bgs_pause(1.0)
|
||||
pos = $game_system.bgm_position
|
||||
pbFadeOutIn(zViewport) {
|
||||
yield
|
||||
$game_system.bgm_position = pos
|
||||
$game_system.bgm_resume(playingBGM)
|
||||
$game_system.bgs_resume(playingBGS)
|
||||
}
|
||||
end
|
||||
|
||||
def pbFadeOutAndHide(sprites)
|
||||
visiblesprites = {}
|
||||
numFrames = (Graphics.frame_rate*0.4).floor
|
||||
|
||||
@@ -1081,25 +1081,6 @@ def drawFormattedTextEx(bitmap,x,y,width,text,baseColor=nil,shadowColor=nil,line
|
||||
drawFormattedChars(bitmap,chars)
|
||||
end
|
||||
|
||||
# Deprecated -- not to be used in new code
|
||||
def coloredToFormattedText(text,baseColor=nil,shadowColor=nil)
|
||||
base=!baseColor ? Color.new(12*8,12*8,12*8) : baseColor.clone
|
||||
shadow=!shadowColor ? Color.new(26*8,26*8,25*8) : shadowColor.clone
|
||||
text2=text.gsub(/&/,"&")
|
||||
text2.gsub!(/</,"<")
|
||||
text2.gsub!(/>/,">")
|
||||
text2.gsub!(/\\\[([A-Fa-f0-9]{8,8})\]/) { "<c2="+$1+">" }
|
||||
text2="<c2="+colorToRgb16(base)+colorToRgb16(shadow)+">"+text2
|
||||
text2.gsub!(/\\\\/,"\\")
|
||||
return text2
|
||||
end
|
||||
|
||||
# Deprecated -- not to be used in new code
|
||||
def drawColoredTextEx(bitmap,x,y,width,text,_baseColor=nil,_shadowColor=nil)
|
||||
chars=getFormattedText(bitmap,x,y,width,-1,coloredToFormattedText(text),32)
|
||||
drawFormattedChars(bitmap,chars)
|
||||
end
|
||||
|
||||
def pbDrawShadow(bitmap,x,y,width,height,string)
|
||||
return if !bitmap || !string
|
||||
pbDrawShadowText(bitmap,x,y,width,height,string,nil,bitmap.font.color)
|
||||
|
||||
@@ -732,9 +732,6 @@ def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
|
||||
Graphics.update
|
||||
Input.update
|
||||
facewindow.update if facewindow
|
||||
if $DEBUG && Input.trigger?(Input::F6)
|
||||
pbRecord(unformattedText)
|
||||
end
|
||||
if autoresume && msgwindow.waitcount==0
|
||||
msgwindow.resume if msgwindow.busy?
|
||||
break if !msgwindow.busy?
|
||||
|
||||
@@ -225,10 +225,6 @@ module GameData
|
||||
|
||||
def self.play_cry_from_pokemon(pkmn, volume = 90, pitch = nil)
|
||||
return if !pkmn || pkmn.egg?
|
||||
if pkmn.respond_to?("chatter") && pkmn.chatter
|
||||
pkmn.chatter.play
|
||||
return
|
||||
end
|
||||
filename = self.cry_filename_from_pokemon(pkmn)
|
||||
return if !filename
|
||||
pitch ||= 75 + (pkmn.hp * 25 / pkmn.totalhp)
|
||||
@@ -249,13 +245,8 @@ module GameData
|
||||
ret = 0.0
|
||||
if species.is_a?(Pokemon)
|
||||
if !species.egg?
|
||||
if species.respond_to?("chatter") && species.chatter
|
||||
ret = species.chatter.time
|
||||
pitch = 1.0
|
||||
else
|
||||
filename = pbResolveAudioSE(GameData::Species.cry_filename_from_pokemon(species))
|
||||
ret = getPlayTime(filename) if filename
|
||||
end
|
||||
filename = pbResolveAudioSE(GameData::Species.cry_filename_from_pokemon(species))
|
||||
ret = getPlayTime(filename) if filename
|
||||
end
|
||||
else
|
||||
filename = pbResolveAudioSE(GameData::Species.cry_filename(species, form))
|
||||
|
||||
@@ -292,22 +292,9 @@ end
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Confuses the target. Chance of causing confusion depends on the cry's volume.
|
||||
# Confusion chance is 0% if user doesn't have a recorded cry. (Chatter)
|
||||
# Confuses the target. (Chatter)
|
||||
#===============================================================================
|
||||
class PokeBattle_Move_014 < PokeBattle_ConfuseMove
|
||||
def pbOnStartUse(user,targets)
|
||||
@chatterChance = 0
|
||||
if user.pokemon && user.pokemon.chatter
|
||||
# Intensity can be 0-127, so return value is 0-10
|
||||
@chatterChance = 10*user.pokemon.chatter.intensity/127
|
||||
end
|
||||
end
|
||||
|
||||
def addlEffect
|
||||
return @chatterChance if MECHANICS_GENERATION <= 5
|
||||
return super
|
||||
end
|
||||
class PokeBattle_Move_014 < PokeBattle_Move_013
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ class PokeBattle_DebugSceneNoLogging
|
||||
def pbItemMenu(idxBattler,firstAction); return -1; end
|
||||
def pbResetMoveIndex(idxBattler); end
|
||||
|
||||
def pbChatter(user,target); end
|
||||
def pbHPChanged(battler,oldHP,showAnim=false); end
|
||||
def pbFaintBattler(battler); end
|
||||
def pbEXPBar(battler,startExp,endExp,tempExp1,tempExp2); end
|
||||
|
||||
@@ -672,74 +672,6 @@ end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Voice recorder
|
||||
#===============================================================================
|
||||
def pbRecord(text,maxtime=30.0)
|
||||
text = "" if !text
|
||||
textwindow = Window_UnformattedTextPokemon.newWithSize(text,0,0,Graphics.width,Graphics.height-96)
|
||||
textwindow.z=99999
|
||||
if text==""
|
||||
textwindow.visible = false
|
||||
end
|
||||
wave = nil
|
||||
msgwindow = pbCreateMessageWindow
|
||||
oldvolume = Audio_bgm_get_volume()
|
||||
Audio_bgm_set_volume(0)
|
||||
delay = 2
|
||||
delay.times do |i|
|
||||
pbMessageDisplay(msgwindow,_INTL("Recording in {1} second(s)...\nPress ESC to cancel.",delay-i),false)
|
||||
Graphics.frame_rate.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
if Input.trigger?(Input::B)
|
||||
Audio_bgm_set_volume(oldvolume)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
textwindow.dispose
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
pbMessageDisplay(msgwindow,_INTL("NOW RECORDING\nPress ESC to stop recording."),false)
|
||||
if beginRecordUI
|
||||
frames = (maxtime*Graphics.frame_rate).to_i
|
||||
frames.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
if Input.trigger?(Input::B)
|
||||
break
|
||||
end
|
||||
end
|
||||
tmpFile = ENV["TEMP"]+"\\record.wav"
|
||||
endRecord(tmpFile)
|
||||
wave = getWaveDataUI(tmpFile,true)
|
||||
if wave
|
||||
pbMessageDisplay(msgwindow,_INTL("PLAYING BACK..."),false)
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
Graphics.update
|
||||
Input.update
|
||||
wave.play
|
||||
(Graphics.frame_rate*wave.time).to_i.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
textwindow.update
|
||||
msgwindow.update
|
||||
end
|
||||
end
|
||||
end
|
||||
Audio_bgm_set_volume(oldvolume)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
textwindow.dispose
|
||||
return wave
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Event movement
|
||||
#===============================================================================
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
class Pokemon
|
||||
attr_accessor :chatter
|
||||
end
|
||||
|
||||
|
||||
|
||||
def pbChatter(pokemon)
|
||||
iconwindow=PictureWindow.new(GameData::Species.sprite_bitmap_from_pokemon(pokemon))
|
||||
iconwindow.x=(Graphics.width/2)-(iconwindow.width/2)
|
||||
iconwindow.y=((Graphics.height-96)/2)-(iconwindow.height/2)
|
||||
if pokemon.chatter
|
||||
pbMessage(_INTL("It will forget the song it knows.\1"))
|
||||
if !pbConfirmMessage(_INTL("Are you sure you want to change it?"))
|
||||
iconwindow.dispose
|
||||
return
|
||||
end
|
||||
end
|
||||
if pbConfirmMessage(_INTL("Do you want to change its song now?"))
|
||||
wave=pbRecord(nil,5)
|
||||
if wave
|
||||
pokemon.chatter=wave
|
||||
pbMessage(_INTL("{1} learned a new song!",pokemon.name))
|
||||
end
|
||||
end
|
||||
iconwindow.dispose
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
HiddenMoveHandlers::CanUseMove.add(:CHATTER,proc { |move,pkmn,showmsg|
|
||||
next true
|
||||
})
|
||||
|
||||
HiddenMoveHandlers::UseMove.add(:CHATTER,proc { |move,pokemon|
|
||||
pbChatter(pokemon)
|
||||
next true
|
||||
})
|
||||
|
||||
|
||||
class PokeBattle_Scene
|
||||
def pbChatter(user,_target)
|
||||
GameData::Species.play_cry_from_pokemon(user.pokemon, nil, 100) if user.pokemon
|
||||
Graphics.frame_rate.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -31,9 +31,6 @@ class PokemonTrainerCard_Scene
|
||||
@sprites["trainer"].y -= (@sprites["trainer"].bitmap.height-128)
|
||||
@sprites["trainer"].z = 2
|
||||
pbDrawTrainerCardFront
|
||||
if $PokemonGlobal.trainerRecording
|
||||
$PokemonGlobal.trainerRecording.play
|
||||
end
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
|
||||
@@ -128,78 +128,6 @@ end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# General-purpose utilities with dependencies
|
||||
#===============================================================================
|
||||
# Similar to pbFadeOutIn, but pauses the music as it fades out.
|
||||
# Requires scripts "Audio" (for bgm_pause) and "SpriteWindow" (for pbFadeOutIn).
|
||||
def pbFadeOutInWithMusic(zViewport=99999)
|
||||
playingBGS = $game_system.getPlayingBGS
|
||||
playingBGM = $game_system.getPlayingBGM
|
||||
$game_system.bgm_pause(1.0)
|
||||
$game_system.bgs_pause(1.0)
|
||||
pos = $game_system.bgm_position
|
||||
pbFadeOutIn(zViewport) {
|
||||
yield
|
||||
$game_system.bgm_position = pos
|
||||
$game_system.bgm_resume(playingBGM)
|
||||
$game_system.bgs_resume(playingBGS)
|
||||
}
|
||||
end
|
||||
|
||||
# Gets the wave data from a file and displays an message if an error occurs.
|
||||
# Can optionally delete the wave file (this is useful if the file was a
|
||||
# temporary file created by a recording).
|
||||
# Requires the script AudioUtilities
|
||||
# Requires the script "PokemonMessages"
|
||||
def getWaveDataUI(filename,deleteFile=false)
|
||||
error = getWaveData(filename)
|
||||
if deleteFile
|
||||
begin
|
||||
File.delete(filename)
|
||||
rescue Errno::EINVAL, Errno::EACCES, Errno::ENOENT
|
||||
end
|
||||
end
|
||||
case error
|
||||
when 1
|
||||
pbMessage(_INTL("The recorded data could not be found or saved."))
|
||||
when 2
|
||||
pbMessage(_INTL("The recorded data was in an invalid format."))
|
||||
when 3
|
||||
pbMessage(_INTL("The recorded data's format is not supported."))
|
||||
when 4
|
||||
pbMessage(_INTL("There was no sound in the recording. Please ensure that a microphone is attached to the computer and is ready."))
|
||||
else
|
||||
return error
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
# Starts recording, and displays a message if the recording failed to start.
|
||||
# Returns true if successful, false otherwise
|
||||
# Requires the script AudioUtilities
|
||||
# Requires the script "PokemonMessages"
|
||||
def beginRecordUI
|
||||
code = beginRecord
|
||||
case code
|
||||
when 0
|
||||
return true
|
||||
when 256+66
|
||||
pbMessage(_INTL("All recording devices are in use. Recording is not possible now."))
|
||||
return false
|
||||
when 256+72
|
||||
pbMessage(_INTL("No supported recording device was found. Recording is not possible."))
|
||||
return false
|
||||
else
|
||||
buffer = "\0"*256
|
||||
MciErrorString.call(code,buffer,256)
|
||||
pbMessage(_INTL("Recording failed: {1}",buffer.gsub(/\x00/,"")))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Constants utilities
|
||||
#===============================================================================
|
||||
@@ -1121,20 +1049,3 @@ def pbLoadRpgxpScene(scene)
|
||||
pbShowObjects(visibleObjects)
|
||||
Graphics.transition(20)
|
||||
end
|
||||
|
||||
|
||||
|
||||
class PokemonGlobalMetadata
|
||||
attr_accessor :trainerRecording
|
||||
end
|
||||
|
||||
|
||||
|
||||
def pbRecordTrainer
|
||||
wave = pbRecord(nil,10)
|
||||
if wave
|
||||
$PokemonGlobal.trainerRecording = wave
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user