94 lines
2.5 KiB
Lua
94 lines
2.5 KiB
Lua
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 heightFractions = {
|
|
["UPPER+"] = 2,
|
|
["UPPER"] = 3,
|
|
["STANDARD"] = 3.5,
|
|
["LOWER"] = 5,
|
|
}
|
|
|
|
local earlyLateFor = compare[game.GetSkinSetting("gameplay_earlyLateFor")]
|
|
local msFor = compare[game.GetSkinSetting("gameplay_msFor")]
|
|
local heightFraction = heightFractions[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
|
|
|
|
if screenH > screenW then
|
|
desh = 1920
|
|
else
|
|
desh = 1080
|
|
end
|
|
|
|
local scale = screenH / desh
|
|
local y = screenH / 8 * heightFraction
|
|
|
|
gfx.BeginPath()
|
|
gfx.LoadSkinFont("Digital-Serial-Bold.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 |