From 45effdd048eb17a6978e22ac7b7d28a25684f2a7 Mon Sep 17 00:00:00 2001 From: Not Date: Wed, 31 Aug 2022 00:41:05 +0200 Subject: [PATCH] draw flags --- browser.lua | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/browser.lua b/browser.lua index 8c9d8d2..237b95c 100644 --- a/browser.lua +++ b/browser.lua @@ -109,6 +109,7 @@ local F_SPBATK = 0x1 local F_SPBJUS = 0x2 local F_SPBBIG = 0x4 local F_SPBEXP = 0x8 +local F_ENCORE = 0x80 local function drawGamemode(v) local m = modes[mode] or 0 @@ -179,6 +180,53 @@ local function drawGamemode(v) end end +local function drawFlags(v, x, y, flags) + local nx = x * FRACUNIT + local ny = y * FRACUNIT + 3 * FRACUNIT + local margin = 4 * FRACUNIT + if flags & F_ENCORE then + local encp = v.cachePatch("RUBYICON") + v.drawScaled( + nx, ny, + FRACUNIT / 6, + encp + ) + nx = $ + margin + end + if flags & F_SPBATK then + local scale = FRACUNIT / 4 + local shift = 6 * FRACUNIT + nx = $ - shift + ny = $ - shift + if flags & F_SPBJUS then + local hyup = v.cachePatch("K_ISHYUD") + v.drawScaled(nx, ny, scale, hyup) + nx = $ + margin + end + if flags & F_SPBBIG then + local growp = v.cachePatch("K_ISGROW") + v.drawScaled(nx, ny, scale, growp) + nx = $ + margin + end + if flags & F_SPBEXP then + local invp = v.cachePatch("K_ISINV"..(leveltime / 6 % 6 + 1)) + v.drawScaled(nx, ny, scale, invp) + end + end +end + +local function drawStats(v, x, y, skin, stats) + local s = skins[skin] + if not (s + and s.kartspeed == stats["speed"] + and s.kartweight == stats["weight"] + ) + and stats then + v.drawString(x-2, y-2, stats["speed"], V_ALLOWLOWERCASE, "thin") + v.drawString(x + 13, y + 9, stats["weight"], V_ALLOWLOWERCASE, "thin") + end +end + -- draw in columns -- pos, facerank, name, time, flags -- ______________________________________________ @@ -189,7 +237,7 @@ local column = { [1] = 18, -- facerank [2] = 46, -- name [3] = 216, -- time - [4] = 250 -- flags + [4] = 270 -- flags } local function drawScore(v, i, score) local y = scoresY + i * 18 @@ -201,8 +249,10 @@ local function drawScore(v, i, score) local facerank = skin and v.cachePatch(skin.facerank) or v.cachePatch("M_NORANK") v.draw(column[1], y, facerank, 0, v.getColormap("sonic", score["color"])) + drawStats(v, column[1], y, score["skin"], score["stat"]) v.drawString(column[2], y, score["name"], V_ALLOWLOWERCASE) v.drawString(column[3], y, rawget(_G, "TicsToTime")(score["time"])) + drawFlags(v, column[4], y, score["flags"]) end local function drawBrowser(v, leaderboard)