+ status messages to ir leaderboard

This commit is contained in:
FajsiEx 2021-12-16 16:52:03 +01:00
parent 3a5c1a010b
commit 6421323b14
2 changed files with 33 additions and 7 deletions

View File

@ -120,6 +120,8 @@ local jacketCache = {}
local top50diffs = {}
local isIrLeaderboardRequested = false;
local isIrLeaderboardFetching = false;
local irRequestStatus = 1; -- 0=unused, 1=not requested, 2=loading, others are status codes
local irRequestTimeout = 2
local irLeaderboard = {}
@ -497,6 +499,7 @@ function drawData() -- Draws the song data on the left panel
drawIrLeaderboard()
gfx.FontSize(22)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.GlobalAlpha(transitionAfterscrollDataOverlayAlpha);
gfx.Text(diff.effector, 270, 1180); -- effected by
gfx.Text(diff.illustrator, 270, 1210); -- illustrated by
@ -542,25 +545,43 @@ function drawLocalLeaderboard(diff)
end
function drawIrLeaderboard()
if #irLeaderboard == 0 then
return;
end
gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
gfx.FontSize(26)
local scoreBoardX = 75;
local scoreBoardY = 1500;
local sbBarWidth = 336*1.2;
local sbBarHeight = 33;
local sbBarContentLeftX = scoreBoardX + 80;
local sbBarContentRightX = scoreBoardX + sbBarWidth/2 + 30;
-- Draw the header
gfx.BeginPath();
gfx.ImageRect(scoreBoardX, scoreBoardY, sbBarWidth, sbBarHeight, scoreBoardBarBgImage, 1, 0);
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE)
gfx.BeginPath();
if isIrLeaderboardFetching or irRequestTimeout > 0 then
gfx.Text("Loading ranking...", scoreBoardX + (sbBarWidth / 2), scoreBoardY + sbBarHeight/2);
return;
end
if irRequestStatus == IRData.States.ChartRefused then
gfx.Text("This chart is blacklisted", scoreBoardX + (sbBarWidth / 2), scoreBoardY + sbBarHeight/2);
return;
end
if irRequestStatus == IRData.States.NotFound then
gfx.Text("This chart is not tracked", scoreBoardX + (sbBarWidth / 2), scoreBoardY + sbBarHeight/2);
return;
end
if #irLeaderboard == 0 then
return;
end
gfx.BeginPath();
gfx.ImageRect(205, 1252.5, 800*0.045, 600*0.045, crownImage, 1, 0);
@ -662,6 +683,7 @@ function refreshIrLeaderboard()
return;
end
isIrLeaderboardFetching = true;
IR.Leaderboard(diff.hash, 'best', 4, onIrLeaderboardFetched)
end
@ -679,6 +701,10 @@ function dump(o)
end
function onIrLeaderboardFetched(res)
isIrLeaderboardFetching = false;
irRequestStatus = res.statusCode;
if res.statusCode == IRData.States.Success then
local tempIrLeaderboard = res.body;

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB