From 96f331e1e332c5a503a63558320174f1e838fb56 Mon Sep 17 00:00:00 2001 From: domdoc Date: Thu, 26 May 2022 12:21:11 +0200 Subject: [PATCH] Fixed Early/Late text or ms show when it shouldn't --- scripts/gameplay/earlylate.lua | 68 ++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/scripts/gameplay/earlylate.lua b/scripts/gameplay/earlylate.lua index b9aa464..78909bb 100644 --- a/scripts/gameplay/earlylate.lua +++ b/scripts/gameplay/earlylate.lua @@ -31,9 +31,9 @@ local earlyLatePosition = game.GetSkinSetting("gameplay_earlyLatePosition") local EarlyLate = { timer = 0, - lastMillisec = 0, - showEarlyLate = false, - showMillisec = false, + color = {}, + earlyLateText = "", + millisecText = "" } function EarlyLate.render(deltaTime) @@ -49,7 +49,7 @@ function EarlyLate.render(deltaTime) local desh, fractionTable if screenH > screenW then - desh = 1920 + desh = 1600 fractionTable = portraitHeightFractions else desh = 1080 @@ -63,41 +63,47 @@ function EarlyLate.render(deltaTime) gfx.LoadSkinFont("Digital-Serial-ExtraBold.ttf") gfx.FontSize(20 * scale) - if EarlyLate.showEarlyLate then - gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_BASELINE) + local color = EarlyLate.color + gfx.FillColor(color[1], color[2], color[3]) + + gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_BASELINE) - if EarlyLate.lastMillisec < 0 then - gfx.FillColor(206, 94, 135) - 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 + gfx.FastText(EarlyLate.earlyLateText, screenCenterX - 100 * scale, y) + gfx.FastText(EarlyLate.millisecText, screenCenterX + 100 * scale, y) end function EarlyLate.TriggerAnimation(rating, millisec) local showEarlyLate = rating <= earlyLateFor local showMillisec = rating <= msFor + local isEarly = millisec < 0 - if showEarlyLate or showMillisec then - EarlyLate.timer = 120 - EarlyLate.lastMillisec = millisec - EarlyLate.showEarlyLate = showEarlyLate - EarlyLate.showMillisec = showMillisec + if millisec == 0 then return end + if not showEarlyLate and not showMillisec then return end + + if showEarlyLate then + EarlyLate.earlyLateText = isEarly and "EARLY" or "LATE" + else + EarlyLate.earlyLateText = "" 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 return EarlyLate \ No newline at end of file