local Dimensions = require "common.dimensions" -- Used for comparing button_hit()'s delta parameter with the -- gameplay_earlyLateFor/gameplay_msDisplay skin settings values. -- If the number is <= delta then the EarlyLate/ms should be shown local compare = { ["ALL"] = 2, ["CRITICAL (or worse)"] = 2, ["NEAR (or worse)"] = 1, ["NONE"] = -1, ["OFF"] = -1 } local portraitHeightFractions = { ["UPPER+"] = 2.4, ["UPPER"] = 3, ["STANDARD"] = 4, ["LOWER"] = 5.3, } local landscapeHeightFractions = { ["UPPER+"] = 1.5, ["UPPER"] = 2.7, ["STANDARD"] = 5.1, ["LOWER"] = 6.7, } local earlyLateFor = compare[game.GetSkinSetting("gameplay_earlyLateFor")] local msFor = compare[game.GetSkinSetting("gameplay_msFor")] local earlyLatePosition = game.GetSkinSetting("gameplay_earlyLatePosition") local EarlyLate = { timer = 0, lastMillisec = 0, showEarlyLate = false, showMillisec = false, } function EarlyLate.render(deltaTime) if EarlyLate.timer <= 0 then return end EarlyLate.timer = EarlyLate.timer - deltaTime * 100 local screenW, screenH = Dimensions.screen.width, Dimensions.screen.height local screenCenterX = screenW / 2 local desh, fractionTable if screenH > screenW then desh = 1920 fractionTable = portraitHeightFractions else desh = 1080 fractionTable = landscapeHeightFractions end local scale = screenH / desh local y = screenH / 8 * fractionTable[earlyLatePosition] gfx.BeginPath() gfx.LoadSkinFont("Digital-Serial-ExtraBold.ttf") gfx.FontSize(20 * scale) if EarlyLate.showEarlyLate then 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 end function EarlyLate.TriggerAnimation(rating, millisec) local showEarlyLate = rating <= earlyLateFor local showMillisec = rating <= msFor if showEarlyLate or showMillisec then EarlyLate.timer = 120 EarlyLate.lastMillisec = millisec EarlyLate.showEarlyLate = showEarlyLate EarlyLate.showMillisec = showMillisec end end return EarlyLate