diff --git a/scripts/gameplay.lua b/scripts/gameplay.lua index 76155bd..8921315 100644 --- a/scripts/gameplay.lua +++ b/scripts/gameplay.lua @@ -34,7 +34,7 @@ function render(deltaTime) Banner.render(deltaTime); - UserPanel.render(deltaTime); + UserPanel.render(deltaTime, score, gameplay.scoreReplays[1]); SongPanel.render(deltaTime, gameplay.bpm, gameplay.hispeed, diff --git a/scripts/gameplay/user_panel.lua b/scripts/gameplay/user_panel.lua index 31e97e1..444e2fa 100644 --- a/scripts/gameplay/user_panel.lua +++ b/scripts/gameplay/user_panel.lua @@ -13,11 +13,45 @@ local idolFrameImage = gfx.CreateSkinImage("crew/frame.png", 0); 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) end -local render = function (deltaTime) +local render = function (deltaTime, score, bestReplay) tickTransitions(deltaTime) gfx.BeginPath(); @@ -60,6 +94,9 @@ local render = function (deltaTime) gfx.FontSize(26) gfx.Text(username, 150, 802); + -- Draw best score diff + drawBestDiff(deltaTime, score, bestReplay); + -- Draw dan badge & volforce gfx.BeginPath(); gfx.ImageRect(