Merge pull request 'add jacketPath to challengesCache' (#14) from bugfix/TASK-55-fix-challenge-wheel into master

Reviewed-on: #14
This commit is contained in:
Kuenaimaku 2022-03-30 02:34:49 +00:00
commit 776fd6035b
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
function GetDisplayDifficulty(jacketPath, difficulty)
if jacketPath == nil then
return difficulty
end
local strippedPath = string.match(jacketPath:lower(), "[/\\][^\\/]+$")
if difficulty == 3 and strippedPath 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_raw"] = missing_text,
["level"] = 0,
["difficulty"] = 0
["difficulty"] = 0,
["jacketPath"] = "",
}
}
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_raw"] = chart.title,
["level"] = chart.level,
["difficulty"] = chart.difficulty
["difficulty"] = chart.difficulty,
["jacketPath"] = chart.jacketPath,
})
end
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
local ypos = offsetY + paddingY * (i - 1)
local adjustedDiff = GetDisplayDifficulty(chart.jacketPath, chart.diff)
local adjustedDiff = GetDisplayDifficulty(chart.jacketPath, chart.difficulty)
DiffRectangle.render(timer, offsetX, ypos, diffIconScale, adjustedDiff, chart.level)
local _, titleHeight = gfx.LabelSize(chart.title)