+ 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 top50diffs = {}
local isIrLeaderboardRequested = false; local isIrLeaderboardRequested = false;
local isIrLeaderboardFetching = false;
local irRequestStatus = 1; -- 0=unused, 1=not requested, 2=loading, others are status codes
local irRequestTimeout = 2 local irRequestTimeout = 2
local irLeaderboard = {} local irLeaderboard = {}
@ -497,6 +499,7 @@ function drawData() -- Draws the song data on the left panel
drawIrLeaderboard() drawIrLeaderboard()
gfx.FontSize(22) gfx.FontSize(22)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.GlobalAlpha(transitionAfterscrollDataOverlayAlpha); gfx.GlobalAlpha(transitionAfterscrollDataOverlayAlpha);
gfx.Text(diff.effector, 270, 1180); -- effected by gfx.Text(diff.effector, 270, 1180); -- effected by
gfx.Text(diff.illustrator, 270, 1210); -- illustrated by gfx.Text(diff.illustrator, 270, 1210); -- illustrated by
@ -542,10 +545,6 @@ function drawLocalLeaderboard(diff)
end end
function drawIrLeaderboard() function drawIrLeaderboard()
if #irLeaderboard == 0 then
return;
end
gfx.LoadSkinFont('Digital-Serial-Bold.ttf') gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
gfx.FontSize(26) gfx.FontSize(26)
@ -562,6 +561,28 @@ function drawIrLeaderboard()
gfx.BeginPath(); gfx.BeginPath();
gfx.ImageRect(scoreBoardX, scoreBoardY, sbBarWidth, sbBarHeight, scoreBoardBarBgImage, 1, 0); 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.BeginPath();
gfx.ImageRect(205, 1252.5, 800*0.045, 600*0.045, crownImage, 1, 0); gfx.ImageRect(205, 1252.5, 800*0.045, 600*0.045, crownImage, 1, 0);
@ -662,6 +683,7 @@ function refreshIrLeaderboard()
return; return;
end end
isIrLeaderboardFetching = true;
IR.Leaderboard(diff.hash, 'best', 4, onIrLeaderboardFetched) IR.Leaderboard(diff.hash, 'best', 4, onIrLeaderboardFetched)
end end
@ -679,6 +701,10 @@ function dump(o)
end end
function onIrLeaderboardFetched(res) function onIrLeaderboardFetched(res)
isIrLeaderboardFetching = false;
irRequestStatus = res.statusCode;
if res.statusCode == IRData.States.Success then if res.statusCode == IRData.States.Success then
local tempIrLeaderboard = res.body; local tempIrLeaderboard = res.body;

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB