* rate limit the IR requests on songwheel further
This commit is contained in:
parent
899af3170e
commit
d9f8944e89
|
@ -119,7 +119,8 @@ local jacketCache = {}
|
||||||
|
|
||||||
local top50diffs = {}
|
local top50diffs = {}
|
||||||
|
|
||||||
local isIrLeaderboardRequested = false -- if false, we will request it after the scroll transition finishes to prevent spamming the API
|
local isIrLeaderboardRequested = false;
|
||||||
|
local irRequestTimeout = 2
|
||||||
local irLeaderboard = {}
|
local irLeaderboard = {}
|
||||||
|
|
||||||
local transitionScrollScale = 0;
|
local transitionScrollScale = 0;
|
||||||
|
@ -541,6 +542,10 @@ 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)
|
||||||
|
|
||||||
|
@ -653,6 +658,8 @@ function refreshIrLeaderboard()
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
irRequestTimeout = 2;
|
||||||
|
|
||||||
IR.Leaderboard(diff.hash, 'best', 4, onIrLeaderboardFetched)
|
IR.Leaderboard(diff.hash, 'best', 4, onIrLeaderboardFetched)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -856,7 +863,7 @@ draw_songwheel = function(x,y,w,h, deltaTime)
|
||||||
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
|
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
|
||||||
local debugScrollingUp= "FALSE"
|
local debugScrollingUp= "FALSE"
|
||||||
if scrollingUp then debugScrollingUp = "TRUE" end;
|
if scrollingUp then debugScrollingUp = "TRUE" end;
|
||||||
-- gfx.Text('S_I: ' .. selectedIndex .. ' // S_D: ' .. selectedDifficulty .. ' // S_UP: ' .. debugScrollingUp .. ' // AC_TS: ' .. transitionAfterscrollScale .. ' // L_TS: ' .. transitionLeaveScale, 8, 8);
|
gfx.Text('S_I: ' .. selectedIndex .. ' // S_D: ' .. selectedDifficulty .. ' // S_UP: ' .. debugScrollingUp .. ' // AC_TS: ' .. transitionAfterscrollScale .. ' // L_TS: ' .. transitionLeaveScale .. ' // IR_T: ' .. irRequestTimeout, 8, 8);
|
||||||
|
|
||||||
gfx.ResetTransform();
|
gfx.ResetTransform();
|
||||||
end
|
end
|
||||||
|
@ -882,8 +889,10 @@ render = function (deltaTime)
|
||||||
|
|
||||||
draw_songwheel((resX - fullX) / 2, 0, fullX, fullY, deltaTime);
|
draw_songwheel((resX - fullX) / 2, 0, fullX, fullY, deltaTime);
|
||||||
|
|
||||||
if (transitionScrollScale >= 1) then
|
if (irRequestTimeout < 0) then
|
||||||
refreshIrLeaderboard(); -- For explantion, check where isIrLeaderboardRequested is defined
|
refreshIrLeaderboard(); -- For explantion, check where isIrLeaderboardRequested is defined
|
||||||
|
else
|
||||||
|
irRequestTimeout = irRequestTimeout - deltaTime
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -944,4 +953,6 @@ set_diff = function(newDiff)
|
||||||
|
|
||||||
selectedDifficulty = newDiff;
|
selectedDifficulty = newDiff;
|
||||||
isIrLeaderboardRequested = false;
|
isIrLeaderboardRequested = false;
|
||||||
|
irLeaderboard = {}
|
||||||
|
irRequestTimeout = 2
|
||||||
end;
|
end;
|
Loading…
Reference in New Issue