fixed chalwheel stats at resolution change

This commit is contained in:
Hersi 2021-11-21 01:43:20 +01:00
parent c224aa928b
commit be96b53510
1 changed files with 17 additions and 92 deletions

View File

@ -199,98 +199,11 @@ check_or_create_cache = function(challenge)
end end
end end
draw_scores = function(difficulty, x, y, w, h)
-- draw the top score for this difficulty
local xOffset = 5
local height = h / 3 - 10
local ySpacing = h / 3
local yOffset = h / 3
gfx.FontSize(30);
gfx.TextAlign(gfx.TEXT_ALIGN_BOTTOM + gfx.TEXT_ALIGN_CENTER);
gfx.FastText("HIGH SCORE", x + (w / 2), y + (h / 2))
gfx.BeginPath()
gfx.Rect(x + xOffset, y + h / 2, w - (xOffset * 2), h / 2)
gfx.FillColor(30, 30, 30, 10)
gfx.StrokeColor(0, 128, 255)
gfx.StrokeWidth(1)
gfx.Fill()
gfx.Stroke()
if difficulty.scores[1] ~= nil then
local highScore = difficulty.scores[1]
scoreLabel = gfx.CreateLabel(string.format("%08d", highScore.score), 40, 0)
if difficulty.topBadge ~= 0 then
gfx.BeginPath()
gfx.ImageRect(
x + xOffset + w - h / 2, y + h / 2 + 5, (h / 2 - 10), h / 2 - 10, badges[difficulty.topBadge], 1, 0
)
end
gfx.FillColor(255, 255, 255)
gfx.FontSize(40);
gfx.TextAlign(gfx.TEXT_ALIGN_MIDDLE + gfx.TEXT_ALIGN_CENTER);
gfx.DrawLabel(scoreLabel, x + (w / 2), y + (h / 4) * 3, w)
end
end
draw_challenge = function(challenge, x, y, w, h, selected) draw_challenge = function(challenge, x, y, w, h, selected)
if not challenge then return end if not challenge then return end
check_or_create_cache(challenge) check_or_create_cache(challenge)
--[[
gfx.BeginPath()
gfx.RoundedRectVarying(x,y, w, h,0,0,0,40)
gfx.FillColor(30, 30, 30)
gfx.StrokeColor(0, 128, 255)
gfx.StrokeWidth(1)
if selected then
gfx.StrokeColor(255, 128, 0)
gfx.StrokeWidth(2)
end
gfx.Fill()
gfx.Stroke()
gfx.FillColor(255, 255, 255)
gfx.TextAlign(gfx.TEXT_ALIGN_TOP + gfx.TEXT_ALIGN_LEFT)
gfx.DrawLabel(challengeCache[challenge.id]["title"], x+10, y + 5, w-10)
if (challenge.missing_chart) then
gfx.FillColor(255, 20, 20)
end
gfx.DrawLabel(challengeCache[challenge.id]["chart_names"], x+20, y + 50, w-10)
--gfx.DrawLabel(challengeCache[challenge.id]["artist"], x+20, y + 50, w-10)
gfx.ForceRender()
--]]
--[[
gfx.Save()
gfx.BeginPath()
gfx.StrokeColor(255,0,0)
if selected then
gfx.StrokeColor(255,255,0)
end
gfx.Rect(x,y,w,h)
gfx.Stroke()
gfx.Restore()
--]]
local testBox = function (xpos, ypos, width, height, value)
local textSize = 24
gfx.BeginPath()
if value then
gfx.FontSize(textSize)
gfx.TextAlign(gfx.TEXT_ALIGN_MIDDLE | gfx.TEXT_ALIGN_CENTER)
gfx.Text(tostring(value), xpos + width / 2, ypos + height / 2)
end
gfx.StrokeColor(0,255,255)
gfx.Rect(xpos, ypos, width, height)
gfx.Stroke()
gfx.ForceRender()
end
local _draw_card_bg = function () local _draw_card_bg = function ()
gfx.BeginPath() gfx.BeginPath()
gfx.ImageRect(x, y, w, h, challengeCardBG, 1, 0) gfx.ImageRect(x, y, w, h, challengeCardBG, 1, 0)
@ -347,31 +260,43 @@ draw_challenge = function(challenge, x, y, w, h, selected)
end end
local _draw_stats = function () local _draw_stats = function ()
local textSizeCorrection = h / gfx.ImageSize(scoreNumber[1])
local percentOffsetX = x + 6/12 * w local percentOffsetX = x + 6/12 * w
local percentOffsetY = y + 14/16 * h local percentOffsetY = y + 0.87 * h
local percentSize = 0.17 * textSizeCorrection
local scoreUpperOffsetX = 0 local scoreUpperOffsetX = 0
local scoreUpperOffsetY = 0 local scoreUpperOffsetY = 0
local scoreOffsetX = x + w * 0.74 local scoreOffsetX = x + w * 0.74
local scoreOffsetY = y + h * 0.9 local scoreOffsetY = y + h * 0.9
local scoreUpperSize = 0.2 * textSizeCorrection
local scoreSize = 0.125 * textSizeCorrection
local percent = challengeCache[challenge.id]["percent"]
local scoreUpper = math.floor(challengeCache[challenge.id]["total_score"] / 10000)
local score = challengeCache[challenge.id]["total_score"]
if selected then if selected then
percentOffsetX = x + 11/24 * w percentOffsetX = x + 11/24 * w
percentOffsetY = y + 49/64 * h percentOffsetY = y + 49/64 * h
percentSize = 0.12 * textSizeCorrection
scoreUpperOffsetX = x + w * 0.63 scoreUpperOffsetX = x + w * 0.63
scoreUpperOffsetY = y + h * 0.82 scoreUpperOffsetY = y + h * 0.82
scoreOffsetX = x + w * 0.755 scoreOffsetX = x + w * 0.755
scoreOffsetY = y + h * 0.835 scoreOffsetY = y + h * 0.835
scoreUpperSize = 0.12 * textSizeCorrection
scoreSize = 0.09 * textSizeCorrection
end end
Numbers.draw_number(percentOffsetX, percentOffsetY, 1, challengeCache[challenge.id]["percent"], 3, scoreNumber, true, 0.2, 1) Numbers.draw_number(percentOffsetX, percentOffsetY, 1, percent, 3, scoreNumber, true, percentSize, 1)
if selected then if selected then
Numbers.draw_number(scoreUpperOffsetX, scoreUpperOffsetY, 1, math.floor(challengeCache[challenge.id]["total_score"] / 10000), 4, scoreNumber, true, 0.2, 1) Numbers.draw_number(scoreUpperOffsetX, scoreUpperOffsetY, 1, scoreUpper, 4, scoreNumber, true, scoreUpperSize, 1)
Numbers.draw_number(scoreOffsetX, scoreOffsetY, 1, challengeCache[challenge.id]["total_score"], 4, scoreNumber, true, 0.14, 1) Numbers.draw_number(scoreOffsetX, scoreOffsetY, 1, score, 4, scoreNumber, true, scoreSize, 1)
else else
Numbers.draw_number(scoreOffsetX, scoreOffsetY, 1, challengeCache[challenge.id]["total_score"], 8, scoreNumber, true, 0.14, 1) Numbers.draw_number(scoreOffsetX, scoreOffsetY, 1, score, 8, scoreNumber, true, scoreSize, 1)
end end
end end