add jacketPath to challengesCache

This commit is contained in:
Kyle Humphrey 2022-03-29 21:33:52 -05:00
parent 44c2a10783
commit ea9c39cead
2 changed files with 9 additions and 4 deletions

View File

@ -131,6 +131,10 @@ ImageFont.draw = function(this, text, x, y, alpha, hFlag, vFlag)
end end
function GetDisplayDifficulty(jacketPath, difficulty) function GetDisplayDifficulty(jacketPath, difficulty)
if jacketPath == nil then
return difficulty
end
local strippedPath = string.match(jacketPath:lower(), "[/\\][^\\/]+$") local strippedPath = string.match(jacketPath:lower(), "[/\\][^\\/]+$")
if difficulty == 3 and strippedPath then if difficulty == 3 and strippedPath then
if string.find(strippedPath, "inf") ~= nil then if string.find(strippedPath, "inf") ~= nil then

View File

@ -143,7 +143,8 @@ local check_or_create_cache = function(challenge)
["title"] = gfx.CreateLabel(missing_text, defaultLabelSize, 0), ["title"] = gfx.CreateLabel(missing_text, defaultLabelSize, 0),
["title_raw"] = missing_text, ["title_raw"] = missing_text,
["level"] = 0, ["level"] = 0,
["difficulty"] = 0 ["difficulty"] = 0,
["jacketPath"] = "",
} }
} }
else -- if not challenge.missing_chart then else -- if not challenge.missing_chart then
@ -153,7 +154,8 @@ local check_or_create_cache = function(challenge)
["title"] = gfx.CreateLabel(chart.title, defaultLabelSize, 0), ["title"] = gfx.CreateLabel(chart.title, defaultLabelSize, 0),
["title_raw"] = chart.title, ["title_raw"] = chart.title,
["level"] = chart.level, ["level"] = chart.level,
["difficulty"] = chart.difficulty ["difficulty"] = chart.difficulty,
["jacketPath"] = chart.jacketPath,
}) })
end end
challengeCache[challenge.id]["charts"] = charts challengeCache[challenge.id]["charts"] = charts
@ -403,8 +405,7 @@ draw_challenge = function(challenge, x, y, w, h, selected)
for i, chart in ipairs(challengeCache[challenge.id]["charts"]) do for i, chart in ipairs(challengeCache[challenge.id]["charts"]) do
local ypos = offsetY + paddingY * (i - 1) local ypos = offsetY + paddingY * (i - 1)
local adjustedDiff = GetDisplayDifficulty(chart.jacketPath, chart.difficulty)
local adjustedDiff = GetDisplayDifficulty(chart.jacketPath, chart.diff)
DiffRectangle.render(timer, offsetX, ypos, diffIconScale, adjustedDiff, chart.level) DiffRectangle.render(timer, offsetX, ypos, diffIconScale, adjustedDiff, chart.level)
local _, titleHeight = gfx.LabelSize(chart.title) local _, titleHeight = gfx.LabelSize(chart.title)