From ea9c39cead394d7f21fb583644e62ad27c3d0a64 Mon Sep 17 00:00:00 2001 From: Kyle Humphrey Date: Tue, 29 Mar 2022 21:33:52 -0500 Subject: [PATCH] add jacketPath to challengesCache --- scripts/common.lua | 4 ++++ scripts/songselect/chalwheel.lua | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/common.lua b/scripts/common.lua index 8e02166..8a2a924 100644 --- a/scripts/common.lua +++ b/scripts/common.lua @@ -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 diff --git a/scripts/songselect/chalwheel.lua b/scripts/songselect/chalwheel.lua index 54ecf4d..453d58c 100644 --- a/scripts/songselect/chalwheel.lua +++ b/scripts/songselect/chalwheel.lua @@ -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)