+ best diff to user panel

This commit is contained in:
FajsiEx 2021-10-28 18:28:49 +02:00
parent 0d0ba163ac
commit 54357e2d02
2 changed files with 39 additions and 2 deletions

View File

@ -34,7 +34,7 @@ function render(deltaTime)
Banner.render(deltaTime); Banner.render(deltaTime);
UserPanel.render(deltaTime); UserPanel.render(deltaTime, score, gameplay.scoreReplays[1]);
SongPanel.render(deltaTime, SongPanel.render(deltaTime,
gameplay.bpm, gameplay.bpm,
gameplay.hispeed, gameplay.hispeed,

View File

@ -13,11 +13,45 @@ local idolFrameImage = gfx.CreateSkinImage("crew/frame.png", 0);
local username = game.GetSkinSetting('username') or ''; local username = game.GetSkinSetting('username') or '';
local drawBestDiff = function (deltaTime, score, bestReplay)
if not bestReplay then return end
-- Calculate the difference between current and best play
local difference = score - bestReplay.currentScore
local prefix = "=" -- used to properly display negative values
gfx.BeginPath()
gfx.FontSize(26)
gfx.FillColor(255, 255, 255)
if difference < 0 then
-- If we're behind the best score, separate the minus sign and change the color
gfx.FillColor(255, 90, 70)
difference = math.abs(difference)
prefix = "-"
elseif difference > 0 then
gfx.FillColor(120, 146, 218)
difference = math.abs(difference)
prefix = "+"
end
gfx.LoadSkinFont("Digital-Serial-Bold.ttf")
gfx.FontSize(26)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.Text(prefix, 130, 827)
gfx.Text(string.format("%04d", math.floor(difference/10000)), 150, 827)
local lastFourDigits = ((difference / 10000) - math.floor(difference / 10000))*10000
gfx.FontSize(22)
gfx.Text(string.format("%04d", math.floor(lastFourDigits)), 209, 829)
end
local tickTransitions = function (deltaTime) local tickTransitions = function (deltaTime)
end end
local render = function (deltaTime) local render = function (deltaTime, score, bestReplay)
tickTransitions(deltaTime) tickTransitions(deltaTime)
gfx.BeginPath(); gfx.BeginPath();
@ -60,6 +94,9 @@ local render = function (deltaTime)
gfx.FontSize(26) gfx.FontSize(26)
gfx.Text(username, 150, 802); gfx.Text(username, 150, 802);
-- Draw best score diff
drawBestDiff(deltaTime, score, bestReplay);
-- Draw dan badge & volforce -- Draw dan badge & volforce
gfx.BeginPath(); gfx.BeginPath();
gfx.ImageRect( gfx.ImageRect(