diff --git a/scripts/songselect/chalwheel.lua b/scripts/songselect/chalwheel.lua index 3144377..a80b6b7 100644 --- a/scripts/songselect/chalwheel.lua +++ b/scripts/songselect/chalwheel.lua @@ -1,35 +1,16 @@ local Numbers = require("common.numbers") local DiffRectangle = require("components.diff_rectangle") --- 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 - -local jacket = nil; -local selectedIndex = 1 -local selectedDiff = 1 -local challengeCache = {} -local doffset = 0 -local soffset = 0 -local diffColors = { { 0, 0, 255 }, { 0, 255, 0 }, { 255, 0, 0 }, { 255, 0, 255 } } -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 -local searchText = gfx.CreateLabel("", 5, 0) -local searchIndex = 1 - local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY) local challengeBGImage = gfx.CreateSkinImage("challenge_select/bg.png", 0) local challengeCardBGImage = gfx.CreateSkinImage("challenge_select/small_box.png", 0) - local jacketFallback = gfx.CreateSkinImage("song_select/loading.png", 0) + +--[[ will be reimplemented sometime later +local soffset = 0 +local searchText = gfx.CreateLabel("", 5, 0) +local searchIndex = 1 + local showGuide = game.GetSkinSetting("show_guide") local legendTable = { { @@ -63,6 +44,8 @@ local legendTable = { ["image"] = gfx.CreateSkinImage("legend/start.png", 0) } } +--]] + local grades = { ["D"] = gfx.CreateSkinImage("common/grades/D.png", 0), ["C"] = gfx.CreateSkinImage("common/grades/C.png", 0), @@ -90,33 +73,19 @@ local passStates = { gfx.CreateSkinImage("challenge_select/pass_states/cleared.png", 0) } -local scoreNumber = Numbers.load_number_image("score_num") +local scoreNumbers = Numbers.load_number_image("score_num") -local difficultyLabelImages = { - gfx.CreateSkinImage("diff/1 novice.png", 0), - gfx.CreateSkinImage("diff/2 advanced.png", 0), - gfx.CreateSkinImage("diff/3 exhaust.png", 0), - gfx.CreateSkinImage("diff/4 maximum.png", 0), - gfx.CreateSkinImage("diff/5 infinite.png", 0), - gfx.CreateSkinImage("diff/6 gravity.png", 0), - gfx.CreateSkinImage("diff/7 heavenly.png", 0), - gfx.CreateSkinImage("diff/8 vivid.png", 0) -} - -local difficultyLabelText = { "NOV", "ADV", "EXH", "MXM", "INF", "GRV", "HVN", "VVD" } - -gfx.LoadSkinFont("divlit_custom.ttf") gfx.LoadSkinFont("dfmarugoth.ttf"); game.LoadSkinSample("menu_click") -game.LoadSkinSample("click-02") game.LoadSkinSample("woosh") +-- Wheel variables local wheelSize = 5 -get_page_size = function() - return math.floor(wheelSize / 2) -end +local selectedIndex = 1 +local challengeCache = {} +local timer = 0 -- Window variables local resX, resY @@ -191,8 +160,10 @@ local check_or_create_cache = function(challenge) challengeCache[challenge.id]["total_score"] = challenge.bestScore end - if not challengeCache[challenge.id]["pass_state"] then - local passState = math.min(challenge.topBadge, 2) + 1 -- challenge.topBadge -> [1, 3] + local passState = math.min(challenge.topBadge, 2) + 1 -- challenge.topBadge -> [1, 3] + if (not challengeCache[challenge.id]["pass_state"] or not challengeCache[challenge.id]["pass_state_idx"] + or challengeCache[challenge.id]["pass_state_idx"] ~= passState) then + challengeCache[challenge.id]["pass_state_idx"] = passState challengeCache[challenge.id]["pass_state"] = passStates[passState] end @@ -280,7 +251,7 @@ draw_challenge = function(challenge, x, y, w, h, selected) ---------------------------------------------------------- -- draw stats section ---------------------------------------------------------- - local textSizeCorrection = h / gfx.ImageSize(scoreNumber[1]) + local textSizeCorrection = h / gfx.ImageSize(scoreNumbers[1]) local percentOffsetX = x + 6 / 12 * w local percentOffsetY = y + 0.87 * h @@ -328,16 +299,16 @@ draw_challenge = function(challenge, x, y, w, h, selected) gradeSize = 0.175 * h end - Numbers.draw_number(percentOffsetX, percentOffsetY, 1, percent, 3, scoreNumber, true, percentSize, 1) + Numbers.draw_number(percentOffsetX, percentOffsetY, 1, percent, 3, scoreNumbers, true, percentSize, 1) -- TODO: Missing percentage character if selected then Numbers.draw_number( - scoreUpperOffsetX, scoreUpperOffsetY, 1, scoreUpper, 4, scoreNumber, true, scoreUpperSize, 1 + scoreUpperOffsetX, scoreUpperOffsetY, 1, scoreUpper, 4, scoreNumbers, true, scoreUpperSize, 1 ) - Numbers.draw_number(scoreOffsetX, scoreOffsetY, 1, score, 4, scoreNumber, true, scoreSize, 1) + Numbers.draw_number(scoreOffsetX, scoreOffsetY, 1, score, 4, scoreNumbers, true, scoreSize, 1) else - Numbers.draw_number(scoreOffsetX, scoreOffsetY, 1, score, 8, scoreNumber, true, scoreSize, 1) + Numbers.draw_number(scoreOffsetX, scoreOffsetY, 1, score, 8, scoreNumbers, true, scoreSize, 1) end -- TODO: Missing completion bar @@ -442,6 +413,7 @@ draw_chalwheel = function(x, y, w, h) draw_selected(chalwheel.challenges[selectedIndex], xpos, ypos, selectedWidth, selectedHeight) end +--[[ will be reimplemented sometime later draw_legend_pane = function(x, y, w, h, obj) local xpos = x + 5 local ypos = y @@ -472,7 +444,9 @@ draw_legend = function(x, y, w, h) local xOffset = draw_legend_pane(xpos + (legendWidth * (i - 1)), y + 5, legendWidth, h - 10, legendTable[i]) end end +--]] +--[[ will be reimplemented sometime later 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 @@ -484,7 +458,7 @@ draw_search = function(x, y, w, h) 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.Rect(0, 0, resX, resY) gfx.Fill() gfx.ForceRender() local xpos = x + (searchIndex + soffset) * w @@ -504,6 +478,7 @@ draw_search = function(x, y, w, h) gfx.DrawLabel(searchText, xpos + 10, y + (h / 2), w - 20) end +--]] render = function(deltaTime) -- detect resolution change @@ -527,20 +502,16 @@ render = function(deltaTime) -- draw chalwheel gfx.BeginPath(); draw_chalwheel((resX - fullX) / 2, 0, fullX, fullY) - + -- Draw Legend Information - --[[ - if showGuide then - draw_legend(0, (fifthY / 3) * 14, fullX, (fifthY / 3) * 1) - end + --[[ will be reimplemented sometime later + draw_legend(0, fullX * 14 / 15, fullX, fullY / 15) --]] -- draw text search + --[[ will be reimplemented sometime later + draw_search(fullX * 2 / 5, 5, fullX * 3 / 5, fullY / 25) - --[[ - draw_search(fifthX * 2, 5, fifthX * 3, fifthY / 5) - - doffset = doffset * 0.9 soffset = soffset * 0.8 if chalwheel.searchStatus then gfx.BeginPath() @@ -549,45 +520,25 @@ render = function(deltaTime) gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP) gfx.Text(chalwheel.searchStatus, 3, 3) end - gfx.LoadSkinFont("dfmarugoth.ttf"); + --]] + + gfx.FontFace("dfmarugoth.ttf"); gfx.ResetTransform() gfx.ForceRender() - --]] end end +get_page_size = function() + return math.floor(wheelSize / 2) +end + set_index = function(newIndex, scrollamt) if newIndex ~= selectedIndex then game.PlaySample("menu_click") - scrollmulOffset = 0 end selectedIndex = newIndex - scrollmul = scrollamt + scrollmulOffset -end; - -local badgeRates = { - 0.5, -- Played - 1.0, -- Cleared - 1.02, -- Hard clear - 1.04, -- UC - 1.1 -- PUC -} - -local gradeRates = { - { ["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 -} +end challenges_changed = function(withAll) - if not withAll then - return - end + end