diff --git a/scripts/songselect/songwheel.lua b/scripts/songselect/songwheel.lua index 87d4da6..e3bba54 100644 --- a/scripts/songselect/songwheel.lua +++ b/scripts/songselect/songwheel.lua @@ -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; diff --git a/textures/song_select/ir_loading.png b/textures/song_select/ir_loading.png new file mode 100644 index 0000000..8576fde Binary files /dev/null and b/textures/song_select/ir_loading.png differ