HitFX, Early/Late display with ms #35

Merged
hersi merged 16 commits from domdoc-develop into master 2022-05-27 11:17:12 +02:00
1 changed files with 37 additions and 31 deletions
Showing only changes of commit 96f331e1e3 - Show all commits

View File

@ -31,9 +31,9 @@ local earlyLatePosition = game.GetSkinSetting("gameplay_earlyLatePosition")
local EarlyLate = { local EarlyLate = {
timer = 0, timer = 0,
lastMillisec = 0, color = {},
showEarlyLate = false, earlyLateText = "",
showMillisec = false, millisecText = ""
} }
function EarlyLate.render(deltaTime) function EarlyLate.render(deltaTime)
@ -49,7 +49,7 @@ function EarlyLate.render(deltaTime)
local desh, fractionTable local desh, fractionTable
if screenH > screenW then if screenH > screenW then
desh = 1920 desh = 1600
fractionTable = portraitHeightFractions fractionTable = portraitHeightFractions
else else
desh = 1080 desh = 1080
@ -63,41 +63,47 @@ function EarlyLate.render(deltaTime)
gfx.LoadSkinFont("Digital-Serial-ExtraBold.ttf") gfx.LoadSkinFont("Digital-Serial-ExtraBold.ttf")
gfx.FontSize(20 * scale) gfx.FontSize(20 * scale)
if EarlyLate.showEarlyLate then local color = EarlyLate.color
gfx.FillColor(color[1], color[2], color[3])
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_BASELINE) gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_BASELINE)
if EarlyLate.lastMillisec < 0 then gfx.FastText(EarlyLate.earlyLateText, screenCenterX - 100 * scale, y)
gfx.FillColor(206, 94, 135) gfx.FastText(EarlyLate.millisecText, screenCenterX + 100 * scale, y)
gfx.FastText("EARLY", screenCenterX - 100 * scale, y)
else
gfx.FillColor(53, 102, 197)
gfx.FastText("LATE", screenCenterX - 100 * scale, y)
end
end
if EarlyLate.showMillisec then
local msString = string.format("%dms", EarlyLate.lastMillisec)
if EarlyLate.lastMillisec >= 0 then
msString = "+"..msString -- prepend + sign for lates
end
gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_BASELINE)
gfx.FastText(msString, screenCenterX + 100 * scale, y)
end
end end
function EarlyLate.TriggerAnimation(rating, millisec) function EarlyLate.TriggerAnimation(rating, millisec)
local showEarlyLate = rating <= earlyLateFor local showEarlyLate = rating <= earlyLateFor
local showMillisec = rating <= msFor local showMillisec = rating <= msFor
local isEarly = millisec < 0
if showEarlyLate or showMillisec then if millisec == 0 then return end
EarlyLate.timer = 120 if not showEarlyLate and not showMillisec then return end
EarlyLate.lastMillisec = millisec
EarlyLate.showEarlyLate = showEarlyLate if showEarlyLate then
EarlyLate.showMillisec = showMillisec EarlyLate.earlyLateText = isEarly and "EARLY" or "LATE"
else
EarlyLate.earlyLateText = ""
end end
if showMillisec then
local millisecText = string.format("%dms", millisec)
-- prepend + sign for lates
millisecText = isEarly and millisecText or "+"..millisecText
EarlyLate.millisecText = millisecText
else
EarlyLate.millisecText = ""
end
if isEarly then
EarlyLate.color = {206, 94, 135}
else
EarlyLate.color = {53, 102, 197}
end
EarlyLate.timer = 120
end end
return EarlyLate return EarlyLate