mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Removed last possible usages of Graphics.frame_rate and Graphics.frame_count, improved screen scrolling code, player now animates walking into a wall
This commit is contained in:
@@ -315,7 +315,7 @@ class Window
|
||||
@cursoropacity = 128
|
||||
end
|
||||
if @pause
|
||||
@pauseframe = (Graphics.frame_count / 8) % 4
|
||||
@pauseframe = (System.uptime * 5).to_i % 4 # 4 frames, 5 frames per second
|
||||
@pauseopacity = [@pauseopacity + 64, 255].min
|
||||
mustchange = true
|
||||
end
|
||||
|
||||
@@ -312,7 +312,7 @@ class SpriteWindow < Window
|
||||
if @pause
|
||||
oldpauseframe = @pauseframe
|
||||
oldpauseopacity = @pauseopacity
|
||||
@pauseframe = (Graphics.frame_count / 8) % 4
|
||||
@pauseframe = (System.uptime * 5) % 4 # 4 frames, 5 frames per second
|
||||
@pauseopacity = [@pauseopacity + 64, 255].min
|
||||
mustchange = @pauseframe != oldpauseframe || @pauseopacity != oldpauseopacity
|
||||
end
|
||||
|
||||
@@ -164,6 +164,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
||||
|
||||
def waitcount=(value)
|
||||
@waitcount = (value <= 0) ? 0 : value
|
||||
@wait_timer_start = System.uptime if !@wait_timer_start && value > 0
|
||||
end
|
||||
|
||||
attr_reader :cursorMode
|
||||
@@ -282,24 +283,25 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
||||
end
|
||||
|
||||
def setText(value)
|
||||
@waitcount = 0
|
||||
@curchar = 0
|
||||
@drawncurchar = -1
|
||||
@waitcount = 0
|
||||
@wait_timer_start = nil
|
||||
@curchar = 0
|
||||
@drawncurchar = -1
|
||||
@lastDrawnChar = -1
|
||||
@text = value
|
||||
@textlength = unformattedTextLength(value)
|
||||
@scrollstate = 0
|
||||
@scrollY = 0
|
||||
@linesdrawn = 0
|
||||
@realframes = 0
|
||||
@textchars = []
|
||||
width = 1
|
||||
@text = value
|
||||
@textlength = unformattedTextLength(value)
|
||||
@scrollstate = 0
|
||||
@scrollY = 0
|
||||
@linesdrawn = 0
|
||||
@realframes = 0
|
||||
@textchars = []
|
||||
width = 1
|
||||
height = 1
|
||||
numlines = 0
|
||||
visiblelines = (self.height - self.borderY) / @lineHeight
|
||||
if value.length == 0
|
||||
@fmtchars = []
|
||||
@bitmapwidth = width
|
||||
@fmtchars = []
|
||||
@bitmapwidth = width
|
||||
@bitmapheight = height
|
||||
@numtextchars = 0
|
||||
else
|
||||
@@ -339,19 +341,19 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
||||
@fmtchars.each do |ch|
|
||||
chx = ch[1] + ch[3]
|
||||
chy = ch[2] + ch[4]
|
||||
width = chx if width < chx
|
||||
width = chx if width < chx
|
||||
height = chy if height < chy
|
||||
@textchars.push(ch[5] ? "" : ch[0])
|
||||
end
|
||||
end
|
||||
@bitmapwidth = width
|
||||
@bitmapwidth = width
|
||||
@bitmapheight = height
|
||||
@numtextchars = @textchars.length
|
||||
end
|
||||
stopPause
|
||||
@displaying = @letterbyletter
|
||||
@needclear = true
|
||||
@nodraw = @letterbyletter
|
||||
@needclear = true
|
||||
@nodraw = @letterbyletter
|
||||
refresh
|
||||
end
|
||||
|
||||
@@ -573,9 +575,12 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
||||
def update
|
||||
super
|
||||
@pausesprite.update if @pausesprite&.visible
|
||||
if @waitcount > 0
|
||||
@waitcount -= 1
|
||||
return
|
||||
if @wait_timer_start
|
||||
if System.uptime - @wait_timer_start >= @waitcount
|
||||
@wait_timer_start = nil
|
||||
@waitcount = 0
|
||||
end
|
||||
return if @wait_timer_start
|
||||
end
|
||||
if busy?
|
||||
refresh if !@frameskipChanged
|
||||
|
||||
@@ -421,7 +421,6 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
msgwindow.waitcount = 0
|
||||
autoresume = false
|
||||
text = message.clone
|
||||
msgback = nil
|
||||
linecount = (Graphics.height > 400) ? 3 : 2
|
||||
### Text replacement
|
||||
text.gsub!(/\\sign\[([^\]]*)\]/i) do # \sign[something] gets turned into
|
||||
@@ -508,8 +507,8 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
controls[i][2] = textlen
|
||||
end
|
||||
text = textchunks.join
|
||||
signWaitCount = 0
|
||||
signWaitTime = Graphics.frame_rate / 2
|
||||
appear_timer_start = nil
|
||||
appear_duration = 0.5 # In seconds
|
||||
haveSpecialClose = false
|
||||
specialCloseSE = ""
|
||||
startSE = nil
|
||||
@@ -518,7 +517,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
param = controls[i][1]
|
||||
case control
|
||||
when "op"
|
||||
signWaitCount = signWaitTime + 1
|
||||
appear_timer_start = System.uptime
|
||||
when "cl"
|
||||
text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well
|
||||
haveSpecialClose = true
|
||||
@@ -548,7 +547,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
end
|
||||
if startSE
|
||||
pbSEPlay(pbStringToAudioFile(startSE))
|
||||
elsif signWaitCount == 0 && letterbyletter
|
||||
elsif !appear_timer_start && letterbyletter
|
||||
pbPlayDecisionSE
|
||||
end
|
||||
# Position message window
|
||||
@@ -561,15 +560,12 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
atTop = (msgwindow.y == 0)
|
||||
# Show text
|
||||
msgwindow.text = text
|
||||
Graphics.frame_reset if Graphics.frame_rate > 40
|
||||
loop do
|
||||
if signWaitCount > 0
|
||||
signWaitCount -= 1
|
||||
if atTop
|
||||
msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime
|
||||
else
|
||||
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime)
|
||||
end
|
||||
if appear_timer_start
|
||||
y_start = (atTop) ? -msgwindow.height : Graphics.height
|
||||
y_end = (atTop) ? 0 : Graphics.height - msgwindow.height
|
||||
msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime)
|
||||
appear_timer_start = nil if msgwindow.y == y_end
|
||||
end
|
||||
controls.length.times do |i|
|
||||
next if !controls[i]
|
||||
@@ -599,34 +595,35 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
battlepointswindow&.dispose
|
||||
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
|
||||
when "wu"
|
||||
msgwindow.y = 0
|
||||
atTop = true
|
||||
msgback.y = msgwindow.y if msgback
|
||||
msgwindow.y = 0
|
||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||
msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime
|
||||
if appear_timer_start
|
||||
msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime)
|
||||
end
|
||||
when "wm"
|
||||
atTop = false
|
||||
msgwindow.y = (Graphics.height - msgwindow.height) / 2
|
||||
msgback.y = msgwindow.y if msgback
|
||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||
when "wd"
|
||||
atTop = false
|
||||
msgwindow.y = Graphics.height - msgwindow.height
|
||||
msgback.y = msgwindow.y if msgback
|
||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime)
|
||||
if appear_timer_start
|
||||
msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime)
|
||||
end
|
||||
when "ts" # Change text speed
|
||||
msgwindow.textspeed = (param == "") ? -999 : param.to_i
|
||||
when "." # Wait 0.25 seconds
|
||||
msgwindow.waitcount += Graphics.frame_rate / 4
|
||||
msgwindow.waitcount += 0.25
|
||||
when "|" # Wait 1 second
|
||||
msgwindow.waitcount += Graphics.frame_rate
|
||||
msgwindow.waitcount += 1.0
|
||||
when "wt" # Wait X/20 seconds
|
||||
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
|
||||
msgwindow.waitcount += param.to_i * Graphics.frame_rate / 20
|
||||
msgwindow.waitcount += param.to_i / 20.0
|
||||
when "wtnp" # Wait X/20 seconds, no pause
|
||||
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
|
||||
msgwindow.waitcount = param.to_i * Graphics.frame_rate / 20
|
||||
msgwindow.waitcount = param.to_i / 20.0
|
||||
autoresume = true
|
||||
when "^" # Wait, no pause
|
||||
autoresume = true
|
||||
@@ -649,7 +646,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
if msgwindow.busy?
|
||||
pbPlayDecisionSE if msgwindow.pausing?
|
||||
msgwindow.resume
|
||||
elsif signWaitCount == 0
|
||||
elsif !appear_timer_start
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -665,7 +662,6 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
$game_map.need_refresh = true if $game_map
|
||||
end
|
||||
ret = commandProc.call(msgwindow) if commandProc
|
||||
msgback&.dispose
|
||||
goldwindow&.dispose
|
||||
coinwindow&.dispose
|
||||
battlepointswindow&.dispose
|
||||
@@ -673,16 +669,17 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
if haveSpecialClose
|
||||
pbSEPlay(pbStringToAudioFile(specialCloseSE))
|
||||
atTop = (msgwindow.y == 0)
|
||||
(0..signWaitTime).each do |i|
|
||||
if atTop
|
||||
msgwindow.y = -msgwindow.height * i / signWaitTime
|
||||
else
|
||||
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - i) / signWaitTime)
|
||||
end
|
||||
y_start = (atTop) ? 0 : Graphics.height - msgwindow.height
|
||||
y_end = (atTop) ? -msgwindow.height : Graphics.height
|
||||
disappear_duration = 0.5 # In seconds
|
||||
disappear_timer_start = System.uptime
|
||||
loop do
|
||||
msgwindow.y = lerp(y_start, y_end, disappear_duration, disappear_timer_start, System.uptime)
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
msgwindow.update
|
||||
break if msgwindow.y == y_end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user