+ chart leaderboard caching
This commit is contained in:
parent
d6dbee6316
commit
bd0a3c1005
|
@ -122,6 +122,7 @@ local top50diffs = {}
|
||||||
local irRequestStatus = 1; -- 0=unused, 1=not requested, 2=loading, others are status codes
|
local irRequestStatus = 1; -- 0=unused, 1=not requested, 2=loading, others are status codes
|
||||||
local irRequestTimeout = 2
|
local irRequestTimeout = 2
|
||||||
local irLeaderboard = {}
|
local irLeaderboard = {}
|
||||||
|
local irLeaderboardsCache = {}
|
||||||
|
|
||||||
local transitionScrollScale = 0;
|
local transitionScrollScale = 0;
|
||||||
local transitionScrollOffsetY = 0;
|
local transitionScrollOffsetY = 0;
|
||||||
|
@ -578,6 +579,7 @@ function drawIrLeaderboard()
|
||||||
end
|
end
|
||||||
|
|
||||||
if #irLeaderboard == 0 then
|
if #irLeaderboard == 0 then
|
||||||
|
gfx.Text("This chart has no scores", scoreBoardX + (sbBarWidth / 2), scoreBoardY + sbBarHeight/2);
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -667,7 +669,7 @@ function drawSearch()
|
||||||
gfx.Text(songwheel.searchText, desw-200, 30);
|
gfx.Text(songwheel.searchText, desw-200, 30);
|
||||||
end
|
end
|
||||||
|
|
||||||
function refreshIrLeaderboard()
|
function refreshIrLeaderboard(deltaTime)
|
||||||
if irRequestStatus ~= 1 then -- Only continue if the leaderboard is requesteded, but not loading or loaded.
|
if irRequestStatus ~= 1 then -- Only continue if the leaderboard is requesteded, but not loading or loaded.
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -680,6 +682,17 @@ function refreshIrLeaderboard()
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (irLeaderboardsCache[diff.hash]) then
|
||||||
|
irLeaderboard = irLeaderboardsCache[diff.hash];
|
||||||
|
irRequestStatus = 20;
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
if (irRequestTimeout > 0) then
|
||||||
|
irRequestTimeout = irRequestTimeout - deltaTime
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
irRequestStatus = 2; -- Loading
|
irRequestStatus = 2; -- Loading
|
||||||
-- onIrLeaderboardFetched({
|
-- onIrLeaderboardFetched({
|
||||||
-- statusCode = 20,
|
-- statusCode = 20,
|
||||||
|
@ -711,6 +724,10 @@ function onIrLeaderboardFetched(res)
|
||||||
irLeaderboard[tempScore.ranking] = tempScore
|
irLeaderboard[tempScore.ranking] = tempScore
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local song = songwheel.songs[selectedIndex];
|
||||||
|
local diff = song and song.difficulties[selectedDifficulty] or false;
|
||||||
|
irLeaderboardsCache[diff.hash] = irLeaderboard;
|
||||||
|
|
||||||
game.Log(dump(irLeaderboard), game.LOGGER_ERROR)
|
game.Log(dump(irLeaderboard), game.LOGGER_ERROR)
|
||||||
else
|
else
|
||||||
game.Log("IR error " .. res.statusCode, game.LOGGER_ERROR)
|
game.Log("IR error " .. res.statusCode, game.LOGGER_ERROR)
|
||||||
|
@ -921,11 +938,7 @@ render = function (deltaTime)
|
||||||
|
|
||||||
draw_songwheel((resX - fullX) / 2, 0, fullX, fullY, deltaTime);
|
draw_songwheel((resX - fullX) / 2, 0, fullX, fullY, deltaTime);
|
||||||
|
|
||||||
if (irRequestTimeout < 0) then
|
refreshIrLeaderboard(deltaTime);
|
||||||
refreshIrLeaderboard(); -- For explantion, check where isIrLeaderboardRequested is defined
|
|
||||||
else
|
|
||||||
irRequestTimeout = irRequestTimeout - deltaTime
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
songs_changed = function (withAll)
|
songs_changed = function (withAll)
|
||||||
|
|
Loading…
Reference in New Issue