chalwheel: optimization: removed sub function instantiations

This commit is contained in:
Hersi 2021-11-22 02:22:05 +01:00
parent 02578ce121
commit 67f6f70f7c
1 changed files with 132 additions and 134 deletions

View File

@ -215,12 +215,17 @@ draw_challenge = function(challenge, x, y, w, h, selected)
check_or_create_cache(challenge) check_or_create_cache(challenge)
local _draw_card_bg = function() ----------------------------------------------------------
-- draw card bg section
----------------------------------------------------------
if not selected then
gfx.BeginPath() gfx.BeginPath()
gfx.ImageRect(x, y, w, h, challengeCardBGImage, 1, 0) gfx.ImageRect(x, y, w, h, challengeCardBGImage, 1, 0)
end end
local _draw_info = function() ----------------------------------------------------------
-- draw info section
----------------------------------------------------------
local stateLabel = challengeCache[challenge.id]["pass_state"] local stateLabel = challengeCache[challenge.id]["pass_state"]
local stateLabelWidth, stateLabelHeight = gfx.ImageSize(stateLabel) local stateLabelWidth, stateLabelHeight = gfx.ImageSize(stateLabel)
local stateLabelAspect = stateLabelWidth / stateLabelHeight local stateLabelAspect = stateLabelWidth / stateLabelHeight
@ -255,9 +260,10 @@ draw_challenge = function(challenge, x, y, w, h, selected)
gfx.FontFace("divlit_custom.ttf") gfx.FontFace("divlit_custom.ttf")
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER | gfx.TEXT_ALIGN_BASELINE) gfx.TextAlign(gfx.TEXT_ALIGN_CENTER | gfx.TEXT_ALIGN_BASELINE)
gfx.DrawLabel(challengeCache[challenge.id]["title"], titleCenterX, titleBaselineY, titleMaxWidth) gfx.DrawLabel(challengeCache[challenge.id]["title"], titleCenterX, titleBaselineY, titleMaxWidth)
end
local _draw_jacket = function() ----------------------------------------------------------
-- draw jacket section
----------------------------------------------------------
local size = h * 0.68 local size = h * 0.68
local offsetX = x + w / 32 local offsetX = x + w / 32
local offsetY = y + h - size - h * 0.05 local offsetY = y + h - size - h * 0.05
@ -270,9 +276,10 @@ draw_challenge = function(challenge, x, y, w, h, selected)
gfx.BeginPath() gfx.BeginPath()
gfx.ImageRect(offsetX, offsetY, size, size, challengeCache[challenge.id]["jackets"][1], 1, 0) gfx.ImageRect(offsetX, offsetY, size, size, challengeCache[challenge.id]["jackets"][1], 1, 0)
end
local _draw_stats = function() ----------------------------------------------------------
-- draw stats section
----------------------------------------------------------
local textSizeCorrection = h / gfx.ImageSize(scoreNumber[1]) local textSizeCorrection = h / gfx.ImageSize(scoreNumber[1])
local percentOffsetX = x + 6 / 12 * w local percentOffsetX = x + 6 / 12 * w
@ -319,9 +326,10 @@ draw_challenge = function(challenge, x, y, w, h, selected)
-- TODO: Missing completion badge (COMP, HARD, UC, PUC) -- TODO: Missing completion badge (COMP, HARD, UC, PUC)
-- TODO: Missing completion grade (S+, S, AAA+, etc.) -- TODO: Missing completion grade (S+, S, AAA+, etc.)
end
local _draw_charts = function() ----------------------------------------------------------
-- draw charts section
----------------------------------------------------------
local diffIconHeight = 0.124 * h local diffIconHeight = 0.124 * h
local diffIconWidth = 140 / 31 * diffIconHeight -- only scaling, no stretching textures local diffIconWidth = 140 / 31 * diffIconHeight -- only scaling, no stretching textures
-- diffIconWidth = 0.8 * diffIconWidth -- okay, maybe a little squishing must be done -- diffIconWidth = 0.8 * diffIconWidth -- okay, maybe a little squishing must be done
@ -356,16 +364,6 @@ draw_challenge = function(challenge, x, y, w, h, selected)
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER | gfx.TEXT_ALIGN_MIDDLE) gfx.TextAlign(gfx.TEXT_ALIGN_CENTER | gfx.TEXT_ALIGN_MIDDLE)
gfx.DrawLabel(chart.title, titleCenterX, ypos + diffIconHeight / 2, titleMaxWidth) gfx.DrawLabel(chart.title, titleCenterX, ypos + diffIconHeight / 2, titleMaxWidth)
end end
end
if not selected then
_draw_card_bg()
end
_draw_info()
_draw_jacket()
_draw_stats()
_draw_charts()
gfx.ForceRender() gfx.ForceRender()