2021-11-06 00:28:19 +01:00
|
|
|
local DiffRectangle = require("components.diff_rectangle")
|
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
-- Horizontal alignment
|
|
|
|
TEXT_ALIGN_LEFT = 1
|
|
|
|
TEXT_ALIGN_CENTER = 2
|
|
|
|
TEXT_ALIGN_RIGHT = 4
|
|
|
|
-- Vertical alignment
|
|
|
|
TEXT_ALIGN_TOP = 8
|
|
|
|
TEXT_ALIGN_MIDDLE = 16
|
|
|
|
TEXT_ALIGN_BOTTOM = 32
|
|
|
|
TEXT_ALIGN_BASELINE = 64
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
local jacket = nil;
|
|
|
|
local selectedIndex = 1
|
|
|
|
local selectedDiff = 1
|
2021-11-18 00:26:25 +01:00
|
|
|
local challengeCache = {}
|
2021-07-25 20:10:06 +02:00
|
|
|
local ioffset = 0
|
|
|
|
local doffset = 0
|
|
|
|
local soffset = 0
|
2021-11-17 22:28:26 +01:00
|
|
|
local diffColors = { { 0, 0, 255 }, { 0, 255, 0 }, { 255, 0, 0 }, { 255, 0, 255 } }
|
2021-07-25 20:10:06 +02:00
|
|
|
local timer = 0
|
|
|
|
local scrollmul = 0
|
|
|
|
local scrollmulOffset = 0 -- bc we have min/max the game doesn't know we have to account for extra
|
|
|
|
local effector = 0
|
2021-11-17 22:28:26 +01:00
|
|
|
local searchText = gfx.CreateLabel("", 5, 0)
|
2021-07-25 20:10:06 +02:00
|
|
|
local searchIndex = 1
|
2021-07-31 23:25:09 +02:00
|
|
|
|
|
|
|
local backgroundImage = gfx.CreateSkinImage("challenge_select/bg.png", 0)
|
|
|
|
|
2021-07-25 20:10:06 +02:00
|
|
|
local jacketFallback = gfx.CreateSkinImage("song_select/loading.png", 0)
|
|
|
|
local showGuide = game.GetSkinSetting("show_guide")
|
|
|
|
local legendTable = {
|
2021-11-17 22:28:26 +01:00
|
|
|
{
|
|
|
|
["labelSingleLine"] = gfx.CreateLabel("SCROLL INFO", 16, 0),
|
|
|
|
["labelMultiLine"] = gfx.CreateLabel("SCROLL\nINFO", 16, 0),
|
|
|
|
["image"] = gfx.CreateSkinImage("legend/knob-left.png", 0)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
["labelSingleLine"] = gfx.CreateLabel("CHALL SELECT", 16, 0),
|
|
|
|
["labelMultiLine"] = gfx.CreateLabel("CHALLENGE\nSELECT", 16, 0),
|
|
|
|
["image"] = gfx.CreateSkinImage("legend/knob-right.png", 0)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
["labelSingleLine"] = gfx.CreateLabel("FILTER CHALLS", 16, 0),
|
|
|
|
["labelMultiLine"] = gfx.CreateLabel("FILTER\nCHALLENGES", 16, 0),
|
|
|
|
["image"] = gfx.CreateSkinImage("legend/FX-L.png", 0)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
["labelSingleLine"] = gfx.CreateLabel("SORT CHALLS", 16, 0),
|
|
|
|
["labelMultiLine"] = gfx.CreateLabel("SORT\nCHALLENGES", 16, 0),
|
|
|
|
["image"] = gfx.CreateSkinImage("legend/FX-R.png", 0)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
["labelSingleLine"] = gfx.CreateLabel("GAME SETTINGS", 16, 0),
|
|
|
|
["labelMultiLine"] = gfx.CreateLabel("GAME\nSETTINGS", 16, 0),
|
|
|
|
["image"] = gfx.CreateSkinImage("legend/FX-LR.png", 0)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
["labelSingleLine"] = gfx.CreateLabel("PLAY", 16, 0),
|
|
|
|
["labelMultiLine"] = gfx.CreateLabel("PLAY", 16, 0),
|
|
|
|
["image"] = gfx.CreateSkinImage("legend/start.png", 0)
|
|
|
|
}
|
2021-07-25 20:10:06 +02:00
|
|
|
}
|
|
|
|
local grades = {
|
2021-11-17 22:28:26 +01:00
|
|
|
{ ["max"] = 6999999, ["image"] = gfx.CreateSkinImage("common/grades/D.png", 0) },
|
|
|
|
{ ["max"] = 7999999, ["image"] = gfx.CreateSkinImage("common/grades/C.png", 0) },
|
|
|
|
{ ["max"] = 8699999, ["image"] = gfx.CreateSkinImage("common/grades/B.png", 0) },
|
|
|
|
{ ["max"] = 8999999, ["image"] = gfx.CreateSkinImage("common/grades/A.png", 0) },
|
|
|
|
{ ["max"] = 9299999, ["image"] = gfx.CreateSkinImage("common/grades/A+.png", 0) },
|
|
|
|
{ ["max"] = 9499999, ["image"] = gfx.CreateSkinImage("common/grades/AA.png", 0) },
|
|
|
|
{ ["max"] = 9699999, ["image"] = gfx.CreateSkinImage("common/grades/AA+.png", 0) },
|
|
|
|
{ ["max"] = 9799999, ["image"] = gfx.CreateSkinImage("common/grades/AAA.png", 0) },
|
|
|
|
{ ["max"] = 9899999, ["image"] = gfx.CreateSkinImage("common/grades/AAA+.png", 0) },
|
|
|
|
{ ["max"] = 99999999, ["image"] = gfx.CreateSkinImage("common/grades/S.png", 0) }
|
2021-07-25 20:10:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local badges = {
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.CreateSkinImage("song_select/medal/played.png", 1),
|
|
|
|
gfx.CreateSkinImage("song_select/medal/clear.png", 1),
|
|
|
|
gfx.CreateSkinImage("song_select/medal/hard.png", 1),
|
|
|
|
gfx.CreateSkinImage("song_select/medal/uc.png", 1),
|
|
|
|
gfx.CreateSkinImage("song_select/medal/puc.png", 1)
|
2021-07-25 20:10:06 +02:00
|
|
|
}
|
|
|
|
|
2021-11-06 00:28:19 +01:00
|
|
|
gfx.LoadSkinFont("dfmarugoth.ttf");
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
game.LoadSkinSample("menu_click")
|
|
|
|
game.LoadSkinSample("click-02")
|
|
|
|
game.LoadSkinSample("woosh")
|
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
local wheelSize = 6
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
get_page_size = function()
|
2021-11-17 22:28:26 +01:00
|
|
|
return math.floor(wheelSize / 2)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Responsive UI variables
|
|
|
|
-- Aspect Ratios
|
|
|
|
local aspectFloat = 1.850
|
|
|
|
local aspectRatio = "widescreen"
|
|
|
|
local landscapeWidescreenRatio = 1.850
|
|
|
|
local landscapeStandardRatio = 1.500
|
|
|
|
local portraitWidescreenRatio = 0.5
|
|
|
|
|
|
|
|
-- Responsive sizes
|
|
|
|
local fifthX = 0
|
2021-11-17 22:28:26 +01:00
|
|
|
local fourthX = 0
|
2021-07-25 20:10:06 +02:00
|
|
|
local thirdX = 0
|
2021-11-17 22:28:26 +01:00
|
|
|
local halfX = 0
|
|
|
|
local fullX = 0
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
local fifthY = 0
|
2021-11-17 22:28:26 +01:00
|
|
|
local fourthY = 0
|
2021-07-25 20:10:06 +02:00
|
|
|
local thirdY = 0
|
2021-11-17 22:28:26 +01:00
|
|
|
local halfY = 0
|
|
|
|
local fullY = 0
|
|
|
|
|
|
|
|
adjustScreen = function(x, y)
|
|
|
|
local a = x / y;
|
|
|
|
fifthX = x / 5
|
|
|
|
fourthX = x / 4
|
|
|
|
thirdX = x / 3
|
|
|
|
halfX = x / 2
|
|
|
|
fullX = x
|
|
|
|
|
|
|
|
fifthY = y / 5
|
|
|
|
fourthY = y / 4
|
|
|
|
thirdY = y / 3
|
|
|
|
halfY = y / 2
|
|
|
|
fullY = y
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
check_or_create_cache = function(challenge, full)
|
|
|
|
if not challengeCache[challenge.id] then
|
|
|
|
challengeCache[challenge.id] = {}
|
2021-11-17 22:28:26 +01:00
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
if not challengeCache[challenge.id]["title"] then
|
|
|
|
challengeCache[challenge.id]["title"] = gfx.CreateLabel(challenge.title, 30, 0)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
if not challengeCache[challenge.id]["chart_names"] then
|
2021-07-25 20:10:06 +02:00
|
|
|
local names = "Charts:"
|
2021-11-18 00:26:25 +01:00
|
|
|
for _, chart in ipairs(challenge.charts) do
|
2021-11-17 22:28:26 +01:00
|
|
|
names = names .. " [" .. chart.title .. "]"
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
if challenge.missing_chart then
|
2021-11-17 22:28:26 +01:00
|
|
|
names = names .. " *COULD NOT FIND ALL CHARTS!*"
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
challengeCache[challenge.id]["chart_names"] = gfx.CreateLabel(names, 20, 0)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
if challenge.topBadge ~= 0
|
|
|
|
and (not challengeCache[challenge.id]["percent"] or not challengeCache[challenge.id]["percent_value"]
|
|
|
|
or challengeCache[challenge.id]["percent_value"] ~= challenge.bestScore) then
|
|
|
|
challengeCache[challenge.id]["percent"] = gfx.CreateLabel(
|
2021-11-17 22:28:26 +01:00
|
|
|
string.format(
|
2021-11-18 00:26:25 +01:00
|
|
|
"%u%%", math.max(0, (challenge.bestScore - 8000000) // 10000)
|
2021-11-17 22:28:26 +01:00
|
|
|
), 35, 0
|
|
|
|
)
|
2021-11-18 00:26:25 +01:00
|
|
|
challengeCache[challenge.id]["percent_value"] = challenge.bestScore
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
if full then
|
2021-11-18 00:26:25 +01:00
|
|
|
if not challengeCache[challenge.id]["jackets"] then
|
2021-11-17 22:28:26 +01:00
|
|
|
local jackets = {}
|
2021-11-18 00:26:25 +01:00
|
|
|
for i, chart in ipairs(challenge.charts) do
|
2021-11-17 22:28:26 +01:00
|
|
|
jackets[i] = gfx.LoadImageJob(chart.jacketPath, jacketFallback, 200, 200)
|
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
challengeCache[challenge.id]["jackets"] = jackets
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
if not challengeCache[challenge.id]["desc"] then
|
2021-11-17 22:28:26 +01:00
|
|
|
local desc = "\n"
|
2021-11-18 00:26:25 +01:00
|
|
|
for _, chart in ipairs(challenge.charts) do
|
2021-11-17 22:28:26 +01:00
|
|
|
desc = desc .. "" .. chart.title .. "\n\n"
|
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
if challenge.missing_chart then
|
2021-11-17 22:28:26 +01:00
|
|
|
desc = desc .. "*COULD NOT FIND ALL CHARTS!*\n\n"
|
|
|
|
end
|
|
|
|
desc = desc .. ""
|
2021-11-18 00:26:25 +01:00
|
|
|
challengeCache[challenge.id]["desc"] = gfx.CreateLabel(desc, 20, 0)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
draw_scores = function(difficulty, x, y, w, h)
|
2021-11-17 22:28:26 +01:00
|
|
|
-- 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)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
draw_challenge = function(challenge, x, y, w, h, selected)
|
|
|
|
if not challenge then return end
|
|
|
|
|
|
|
|
check_or_create_cache(challenge)
|
|
|
|
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.BeginPath()
|
2021-11-18 00:26:25 +01:00
|
|
|
gfx.RoundedRectVarying(x,y, w, h,0,0,0,40)
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FillColor(30, 30, 30)
|
|
|
|
gfx.StrokeColor(0, 128, 255)
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.StrokeWidth(1)
|
|
|
|
if selected then
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.StrokeColor(255, 128, 0)
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.StrokeWidth(2)
|
|
|
|
end
|
|
|
|
gfx.Fill()
|
|
|
|
gfx.Stroke()
|
2021-11-18 00:26:25 +01:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FillColor(255, 255, 255)
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_TOP + gfx.TEXT_ALIGN_LEFT)
|
2021-11-18 00:26:25 +01:00
|
|
|
gfx.DrawLabel(challengeCache[challenge.id]["title"], x+10, y + 5, w-10)
|
|
|
|
|
|
|
|
if (challenge.missing_chart) then
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FillColor(255, 20, 20)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
gfx.DrawLabel(challengeCache[challenge.id]["chart_names"], x+20, y + 50, w-10)
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
--gfx.DrawLabel(challengeCache[challenge.id]["artist"], x+20, y + 50, w-10)
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.ForceRender()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2021-11-06 00:28:19 +01:00
|
|
|
draw_diff_icon = function(diff, x, y, w, h, selected, deltaTime)
|
2021-11-17 22:28:26 +01:00
|
|
|
local shrinkX = w / 4
|
|
|
|
local shrinkY = h / 4
|
2021-07-25 20:10:06 +02:00
|
|
|
if selected then
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FontSize(h / 2)
|
|
|
|
shrinkX = w / 6
|
|
|
|
shrinkY = h / 6
|
2021-07-25 20:10:06 +02:00
|
|
|
else
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FontSize(math.floor(h / 3))
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
gfx.BeginPath()
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.RoundedRectVarying(x + shrinkX, y + shrinkY, w - shrinkX * 2, h - shrinkY * 2, 0, 0, 0, 0)
|
|
|
|
gfx.FillColor(15, 15, 15)
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.StrokeColor(table.unpack(diffColors[diff.difficulty + 1]))
|
|
|
|
gfx.StrokeWidth(2)
|
|
|
|
gfx.Fill()
|
|
|
|
gfx.Stroke()
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FillColor(255, 255, 255)
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_MIDDLE + gfx.TEXT_ALIGN_CENTER)
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FastText(tostring(diff.level), x + (w / 2), y + (h / 2))
|
|
|
|
-- gfx.BeginPath()
|
|
|
|
-- DiffRectangle.render(deltaTime, 183, 2.5, 10, songCache[song.id][selectedDiff],tostring(diff.level));
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
draw_diffs = function(diffs, x, y, w, h)
|
2021-11-17 22:28:26 +01:00
|
|
|
local diffWidth = w / 2.5
|
|
|
|
local diffHeight = w / 2.5
|
2021-07-25 20:10:06 +02:00
|
|
|
local diffCount = #diffs
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.Scissor(x, y, w, h)
|
|
|
|
for i = math.max(selectedDiff - 2, 1), math.max(selectedDiff - 1, 1) do
|
|
|
|
local diff = diffs[i]
|
|
|
|
local xpos = x + ((w / 2 - diffWidth / 2) + (selectedDiff - i + doffset) * (-0.8 * diffWidth))
|
|
|
|
if i ~= selectedDiff then
|
|
|
|
draw_diff_icon(diff, xpos, y, diffWidth, diffHeight, false)
|
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
-- after selected
|
|
|
|
for i = math.min(selectedDiff + 2, diffCount), selectedDiff + 1, -1 do
|
|
|
|
local diff = diffs[i]
|
|
|
|
local xpos = x + ((w / 2 - diffWidth / 2) + (selectedDiff - i + doffset) * (-0.8 * diffWidth))
|
|
|
|
if i ~= selectedDiff then
|
|
|
|
draw_diff_icon(diff, xpos, y, diffWidth, diffHeight, false)
|
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
local diff = diffs[selectedDiff]
|
2021-11-17 22:28:26 +01:00
|
|
|
local xpos = x + ((w / 2 - diffWidth / 2) + (doffset) * (-0.8 * diffWidth))
|
|
|
|
draw_diff_icon(diff, xpos, y, diffWidth, diffHeight, true)
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.FillColor(0, 128, 255)
|
|
|
|
gfx.Rect(x, y + 10, 2, diffHeight - h / 6)
|
|
|
|
gfx.Fill()
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.Rect(x + w - 2, y + 10, 2, diffHeight - h / 6)
|
|
|
|
gfx.Fill()
|
|
|
|
gfx.ResetScissor()
|
|
|
|
draw_cursor(x + w / 2, y + diffHeight / 2, timer * math.pi, diffHeight / 1.5)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
draw_selected = function(challenge, x, y, w, h)
|
|
|
|
if not challenge then return end
|
|
|
|
|
|
|
|
check_or_create_cache(challenge, true)
|
|
|
|
|
2021-07-25 20:10:06 +02:00
|
|
|
-- set up padding and margins
|
2021-11-17 22:28:26 +01:00
|
|
|
local xPadding = math.floor(w / 16)
|
|
|
|
local yPadding = math.floor(h / 32)
|
|
|
|
local xMargin = math.floor(w / 16)
|
|
|
|
local yMargin = math.floor(h / 32)
|
|
|
|
local width = (w - (xMargin * 2))
|
|
|
|
local height = (h - (yMargin * 2))
|
|
|
|
local xpos = x + xMargin
|
|
|
|
local ypos = y + yMargin
|
|
|
|
-- Border
|
|
|
|
-- local diff = song.difficulties[selectedDiff]
|
|
|
|
-- gfx.BeginPath()
|
|
|
|
-- gfx.RoundedRectVarying(xpos,ypos,width,height,yPadding,yPadding,yPadding,yPadding)
|
|
|
|
-- gfx.FillColor(30,30,30,100)
|
|
|
|
-- gfx.StrokeColor(0,128,255)
|
|
|
|
-- gfx.StrokeWidth(1)
|
|
|
|
-- gfx.Fill()
|
|
|
|
-- gfx.Stroke()
|
2021-07-25 20:10:06 +02:00
|
|
|
-- jacket should take up 1/3 of height, always be square, and be centered
|
2021-11-17 22:28:26 +01:00
|
|
|
local imageSize = math.floor((height / 2) * 2) - 10
|
|
|
|
local imageXPos = x + xMargin + xPadding
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
local square_size = math.ceil(math.sqrt(#challenge.charts))
|
2021-07-25 20:10:06 +02:00
|
|
|
local origImageSize = imageSize
|
|
|
|
imageSize = math.floor(imageSize / square_size)
|
2021-11-18 00:26:25 +01:00
|
|
|
local bottom_off = math.ceil((square_size - #challenge.charts))
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
local img_row = 0;
|
|
|
|
local img_col = 0;
|
2021-11-18 00:26:25 +01:00
|
|
|
for i, chart in ipairs(challenge.charts) do
|
|
|
|
if challengeCache[challenge.id]["jackets"][i] == jacketFallback then
|
|
|
|
challengeCache[challenge.id]["jackets"][i] = gfx.LoadImageJob(chart.jacketPath, jacketFallback, 200, 200)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
gfx.BeginPath()
|
|
|
|
local xoff = img_col * imageSize
|
|
|
|
if math.ceil(i / square_size) == square_size then
|
2021-11-06 00:28:19 +01:00
|
|
|
xoff = xoff
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.ImageRect(
|
|
|
|
62.52, 888.6 + (img_row / 200 * imageSize), imageSize * 1.19, imageSize * 1.19,
|
2021-11-18 00:26:25 +01:00
|
|
|
challengeCache[challenge.id]["jackets"][i], 1, 0
|
2021-11-17 22:28:26 +01:00
|
|
|
)
|
2021-07-25 20:10:06 +02:00
|
|
|
img_col = img_col + 1
|
|
|
|
if img_col >= square_size then
|
2021-11-17 22:28:26 +01:00
|
|
|
img_row = img_row + 1
|
|
|
|
img_col = 0
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local num_img_rows = img_row + 1
|
|
|
|
if img_col == 0 then
|
2021-11-17 22:28:26 +01:00
|
|
|
num_img_rows = img_row
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
if challengeCache[challenge.id][selectedDiff] then
|
2021-11-06 00:28:19 +01:00
|
|
|
gfx.BeginPath()
|
2021-11-17 22:28:26 +01:00
|
|
|
-- gfx.ImageRect(imageXPos, y+yMargin+yPadding, imageSize, imageSize, songCache[song.id][selectedDiff], 1, 0)
|
2021-11-06 00:28:19 +01:00
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
local gradeImg = nil
|
2021-11-17 22:28:26 +01:00
|
|
|
for i, v in ipairs(grades) do
|
2021-11-18 00:26:25 +01:00
|
|
|
if v.max > challenge.bestScore then
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.BeginPath()
|
|
|
|
gradeImg = v.image
|
|
|
|
break
|
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
if scrollmul < 0 then
|
2021-11-17 22:28:26 +01:00
|
|
|
scrollmulOffset = scrollmulOffset - scrollmul
|
|
|
|
scrollmul = 0
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
local descw, desch = gfx.LabelSize(challengeCache[challenge.id]["desc"])
|
|
|
|
local boxh, boxw = 0, 0
|
|
|
|
local starty, startx = 0, 0
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FontSize(40)
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_TOP + gfx.TEXT_ALIGN_MIDDLE)
|
|
|
|
starty = y + yMargin + yPadding
|
|
|
|
startx = xpos + xPadding + origImageSize + 10
|
2021-11-18 00:26:25 +01:00
|
|
|
gfx.DrawLabel(challengeCache[challenge.id]["title"], 295, 845, width - origImageSize - 30)
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FontSize(30)
|
|
|
|
|
|
|
|
-- Scroll box info
|
|
|
|
starty = starty + 50
|
|
|
|
boxh = height - starty
|
|
|
|
boxw = width - startx - 200
|
|
|
|
|
|
|
|
-- gfx.DrawLabel(songCache[song.id]["artist"], xpos+xPadding+imageSize+3, y+yMargin+yPadding + 45, width-imageSize-20)
|
|
|
|
-- gfx.DrawLabel(songCache[song.id]["artist"], xpos+xPadding+imageSize+3, y+yMargin+yPadding + 45, width-imageSize-20)
|
|
|
|
-- gfx.FontSize(20)
|
|
|
|
-- gfx.DrawLabel(songCache[song.id]["bpm"], xpos+xPadding+imageSize+3, y+yMargin+yPadding + 85, width-imageSize-20)
|
|
|
|
-- gfx.FastText(string.format("Effector: %s", diff.effector), xpos+xPadding+imageSize+3, y+yMargin+yPadding + 115)
|
2021-11-18 00:26:25 +01:00
|
|
|
if challenge.topBadge ~= 0 then
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.BeginPath()
|
2021-11-18 00:26:25 +01:00
|
|
|
gfx.ImageRect(978, 1026.5, 50, 50, badges[challenge.topBadge], 1, 0)
|
2021-07-25 20:10:06 +02:00
|
|
|
local iar = 0
|
|
|
|
if gradeImg ~= nil then
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.BeginPath()
|
|
|
|
local iw, ih = gfx.ImageSize(gradeImg)
|
|
|
|
iar = iw / ih
|
|
|
|
gfx.ImageRect(961 - iar * 50, 1026.5, iar * 50, 50, gradeImg, 1, 0)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE)
|
2021-11-18 00:26:25 +01:00
|
|
|
gfx.DrawLabel(challengeCache[challenge.id]["percent"], 595, 1045, 200)
|
2021-11-17 22:28:26 +01:00
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
-- Render desc scrolling box
|
|
|
|
do
|
2021-11-17 22:28:26 +01:00
|
|
|
-- gfx.BeginPath()
|
|
|
|
-- gfx.Rect(startx, starty, boxw, boxh)
|
|
|
|
-- gfx.FillColor(50,50,50)
|
|
|
|
-- gfx.Fill()
|
|
|
|
|
|
|
|
local overBottom = desch - 100 * scrollmul - boxh
|
|
|
|
if overBottom < 0 and scrollmul > 0 then
|
|
|
|
local scrollend = (desch - boxh) / 100
|
|
|
|
if scrollend < 0 then
|
|
|
|
scrollend = 0
|
|
|
|
end
|
|
|
|
scrollmulOffset = scrollmulOffset - (scrollmul - scrollend)
|
|
|
|
scrollmul = scrollend
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-06 00:28:19 +01:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
-- Draw scroll bar
|
|
|
|
if desch > boxh then
|
|
|
|
gfx.BeginPath()
|
|
|
|
local barStart = (100 * scrollmul) / desch -- Start percent of visible desc
|
|
|
|
local barh = (boxh / desch) * boxh
|
|
|
|
gfx.Rect(startx + boxw - 5, starty + (barStart * boxh) // 1, 5, barh // 1)
|
|
|
|
gfx.FillColor(20, 20, 20)
|
|
|
|
gfx.Fill()
|
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
|
2021-11-18 00:26:25 +01:00
|
|
|
gfx.DrawLabel(challengeCache[challenge.id]["desc"], 600, 942)
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
end
|
2021-11-17 22:28:26 +01:00
|
|
|
-- if aspectRatio == "PortraitWidescreen" then
|
2021-07-25 20:10:06 +02:00
|
|
|
-- draw_scores(diff, xpos+xPadding+imageSize+3, (height/3)*2, width-imageSize-20, (height/3)-yPadding)
|
2021-11-17 22:28:26 +01:00
|
|
|
-- else
|
2021-07-25 20:10:06 +02:00
|
|
|
-- draw_scores(diff, xpos, (height/6)*5, width, (height/6))
|
2021-11-17 22:28:26 +01:00
|
|
|
-- end
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.ForceRender()
|
|
|
|
end
|
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
draw_challengewheel = function(x, y, w, h)
|
2021-11-17 22:28:26 +01:00
|
|
|
local offsetX = fifthX / 2
|
|
|
|
local width = math.floor((w / 5) * 4)
|
|
|
|
local height = math.floor((h / wheelSize) * 1.5)
|
|
|
|
|
2021-11-18 00:26:25 +01:00
|
|
|
-- before selected
|
2021-11-17 22:28:26 +01:00
|
|
|
for i = math.max(selectedIndex - wheelSize / 2, 1), math.max(selectedIndex - 1, 0) do
|
2021-11-18 00:26:25 +01:00
|
|
|
local challenge = chalwheel.challenges[i]
|
2021-11-17 22:28:26 +01:00
|
|
|
local xpos = x + offsetX + ((selectedIndex - i + ioffset) ^ 2) * 3
|
|
|
|
local offsetY = (selectedIndex - i + ioffset)
|
|
|
|
* (height - (wheelSize / 2 * ((selectedIndex - i + ioffset) * aspectFloat)))
|
|
|
|
local ypos = y + ((h / 2 - height / 2) - offsetY)
|
2021-11-18 00:26:25 +01:00
|
|
|
draw_challenge(challenge, xpos, ypos, width, height)
|
2021-11-17 22:28:26 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
-- after selected
|
|
|
|
for i = math.min(selectedIndex + wheelSize / 2, #chalwheel.challenges), selectedIndex + 1, -1 do
|
2021-11-18 00:26:25 +01:00
|
|
|
local challenge = chalwheel.challenges[i]
|
2021-11-17 22:28:26 +01:00
|
|
|
local xpos = x + offsetX + ((i - selectedIndex - ioffset) ^ 2) * 2
|
|
|
|
local offsetY = (selectedIndex - i + ioffset)
|
|
|
|
* (height - (wheelSize / 2 * ((i - selectedIndex - ioffset) * aspectFloat)))
|
|
|
|
local ypos = y + ((h / 2 - height / 2) - (selectedIndex - i) - offsetY)
|
|
|
|
local alpha = 255 - (selectedIndex - i + ioffset) * 31
|
2021-11-18 00:26:25 +01:00
|
|
|
draw_challenge(challenge, xpos, ypos, width, height)
|
2021-11-17 22:28:26 +01:00
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
-- draw selected
|
|
|
|
local xpos = x + offsetX / 1.2 + ((-ioffset) ^ 2) * 2
|
|
|
|
local offsetY = (ioffset) * (height - (wheelSize / 2 * ((1) * aspectFloat)))
|
|
|
|
local ypos = y + ((h / 2 - height / 2) - (ioffset) - offsetY)
|
2021-11-18 00:26:25 +01:00
|
|
|
draw_challenge(chalwheel.challenges[selectedIndex], xpos, ypos, width, height, true)
|
2021-11-17 22:28:26 +01:00
|
|
|
return chalwheel.challenges[selectedIndex]
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-18 00:26:25 +01:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
draw_legend_pane = function(x, y, w, h, obj)
|
|
|
|
local xpos = x + 5
|
|
|
|
local ypos = y
|
|
|
|
local imageSize = h
|
2021-11-18 00:26:25 +01:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_MIDDLE + gfx.TEXT_ALIGN_LEFT)
|
|
|
|
gfx.ImageRect(x, y, imageSize, imageSize, obj.image, 1, 0)
|
|
|
|
xpos = xpos + imageSize + 5
|
|
|
|
gfx.FontSize(16);
|
|
|
|
if h < (w - (10 + imageSize)) / 2 then
|
|
|
|
gfx.DrawLabel(obj.labelSingleLine, xpos, y + (h / 2), w - (10 + imageSize))
|
|
|
|
else
|
|
|
|
gfx.DrawLabel(obj.labelMultiLine, xpos, y + (h / 2), w - (10 + imageSize))
|
|
|
|
end
|
|
|
|
gfx.ForceRender()
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
draw_legend = function(x, y, w, h)
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_MIDDLE + gfx.TEXT_ALIGN_LEFT);
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.FillColor(0, 0, 0, 170)
|
|
|
|
gfx.Rect(x, y, w, h)
|
|
|
|
gfx.Fill()
|
|
|
|
local xpos = 10;
|
|
|
|
local legendWidth = math.floor((w - 20) / #legendTable)
|
|
|
|
for i, v in ipairs(legendTable) do
|
|
|
|
local xOffset = draw_legend_pane(xpos + (legendWidth * (i - 1)), y + 5, legendWidth, h - 10, legendTable[i])
|
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
draw_search = function(x, y, w, h)
|
|
|
|
soffset = soffset + (searchIndex) - (chalwheel.searchInputActive and 0 or 1)
|
|
|
|
if searchIndex ~= (chalwheel.searchInputActive and 0 or 1) then
|
|
|
|
game.PlaySample("woosh")
|
|
|
|
end
|
|
|
|
searchIndex = chalwheel.searchInputActive and 0 or 1
|
|
|
|
|
|
|
|
gfx.BeginPath()
|
|
|
|
local bgfade = 1 - (searchIndex + soffset)
|
|
|
|
-- if not chalwheel.searchInputActive then bgfade = soffset end
|
|
|
|
gfx.FillColor(0, 0, 0, math.floor(200 * bgfade))
|
|
|
|
gfx.Rect(0, 0, resx, resy)
|
|
|
|
gfx.Fill()
|
|
|
|
gfx.ForceRender()
|
|
|
|
local xpos = x + (searchIndex + soffset) * w
|
2021-11-18 00:26:25 +01:00
|
|
|
gfx.UpdateLabel(searchText, string.format("Search: %s", chalwheel.searchText), 30)
|
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.RoundedRect(xpos, y, w, h, h / 2)
|
|
|
|
gfx.FillColor(30, 30, 30)
|
|
|
|
gfx.StrokeColor(0, 128, 255)
|
|
|
|
gfx.StrokeWidth(1)
|
|
|
|
gfx.Fill()
|
|
|
|
gfx.Stroke()
|
2021-11-18 00:26:25 +01:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.BeginPath();
|
|
|
|
gfx.LoadSkinFont("dfmarugoth.ttf");
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE);
|
|
|
|
gfx.DrawLabel(searchText, xpos + 10, y + (h / 2), w - 20)
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
render = function(deltaTime)
|
2021-11-17 22:28:26 +01:00
|
|
|
timer = (timer + deltaTime)
|
|
|
|
timer = timer % 2
|
|
|
|
resx, resy = game.GetResolution();
|
2021-11-18 00:26:25 +01:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.ImageRect(0, 0, resx, resy, backgroundImage, 1, 0)
|
|
|
|
adjustScreen(resx, resy);
|
2021-11-18 00:26:25 +01:00
|
|
|
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.BeginPath();
|
2021-11-06 00:28:19 +01:00
|
|
|
gfx.LoadSkinFont("dfmarugoth.ttf");
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.FontSize(40);
|
2021-11-17 22:28:26 +01:00
|
|
|
gfx.FillColor(255, 255, 255);
|
2021-11-18 00:26:25 +01:00
|
|
|
if chalwheel.challenges and chalwheel.challenges[1] then
|
2021-11-17 22:28:26 +01:00
|
|
|
-- draw chalwheel and get selected song
|
2021-11-18 00:26:25 +01:00
|
|
|
local song = draw_challengewheel(0, 0, fullX, fullY)
|
2021-11-17 22:28:26 +01:00
|
|
|
-- render selected song information
|
|
|
|
draw_selected(song, 0, 0, fullX, fifthY)
|
|
|
|
end
|
|
|
|
-- Draw Legend Information
|
|
|
|
if showGuide then
|
|
|
|
draw_legend(0, (fifthY / 3) * 14, fullX, (fifthY / 3) * 1)
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|
2021-11-06 00:28:19 +01:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
-- draw text search
|
2021-11-06 00:28:19 +01:00
|
|
|
|
2021-11-17 22:28:26 +01:00
|
|
|
draw_search(fifthX * 2, 5, fifthX * 3, fifthY / 5)
|
2021-07-25 20:10:06 +02:00
|
|
|
|
|
|
|
ioffset = ioffset * 0.9
|
|
|
|
doffset = doffset * 0.9
|
|
|
|
soffset = soffset * 0.8
|
2021-11-17 22:28:26 +01:00
|
|
|
if chalwheel.searchStatus then
|
|
|
|
gfx.BeginPath()
|
|
|
|
gfx.FillColor(255, 255, 255)
|
|
|
|
gfx.FontSize(20);
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
|
|
|
|
gfx.Text(chalwheel.searchStatus, 3, 3)
|
|
|
|
end
|
2021-11-06 00:28:19 +01:00
|
|
|
gfx.LoadSkinFont("dfmarugoth.ttf");
|
2021-07-25 20:10:06 +02:00
|
|
|
gfx.ResetTransform()
|
|
|
|
gfx.ForceRender()
|
|
|
|
end
|
|
|
|
|
|
|
|
set_index = function(newIndex, scrollamt)
|
|
|
|
if newIndex ~= selectedIndex then
|
|
|
|
game.PlaySample("menu_click")
|
|
|
|
scrollmulOffset = 0
|
|
|
|
end
|
|
|
|
ioffset = ioffset + selectedIndex - newIndex
|
|
|
|
selectedIndex = newIndex
|
|
|
|
scrollmul = scrollamt + scrollmulOffset
|
|
|
|
end;
|
|
|
|
|
|
|
|
local badgeRates = {
|
2021-11-17 22:28:26 +01:00
|
|
|
0.5, -- Played
|
|
|
|
1.0, -- Cleared
|
|
|
|
1.02, -- Hard clear
|
|
|
|
1.04, -- UC
|
|
|
|
1.1 -- PUC
|
2021-07-25 20:10:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
local gradeRates = {
|
2021-11-17 22:28:26 +01:00
|
|
|
{ ["min"] = 9900000, ["rate"] = 1.05 }, -- S
|
|
|
|
{ ["min"] = 9800000, ["rate"] = 1.02 }, -- AAA+
|
|
|
|
{ ["min"] = 9700000, ["rate"] = 1 }, -- AAA
|
|
|
|
{ ["min"] = 9500000, ["rate"] = 0.97 }, -- AA+
|
|
|
|
{ ["min"] = 9300000, ["rate"] = 0.94 }, -- AA
|
|
|
|
{ ["min"] = 9000000, ["rate"] = 0.91 }, -- A+
|
|
|
|
{ ["min"] = 8700000, ["rate"] = 0.88 }, -- A
|
|
|
|
{ ["min"] = 7500000, ["rate"] = 0.85 }, -- B
|
|
|
|
{ ["min"] = 6500000, ["rate"] = 0.82 }, -- C
|
|
|
|
{ ["min"] = 0, ["rate"] = 0.8 } -- D
|
2021-07-25 20:10:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
challenges_changed = function(withAll)
|
2021-11-17 22:28:26 +01:00
|
|
|
if not withAll then
|
|
|
|
return
|
|
|
|
end
|
2021-07-25 20:10:06 +02:00
|
|
|
end
|