Skip to content

Commit

Permalink
Make chart leaderboards only request if you care about them
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Oct 9, 2018
1 parent 7acd837 commit b405f04
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ local ret =
end
self:GetChild("ScoreDisplay"):xy(frameX, frameY)
MESSAGEMAN:Broadcast("TabChanged")
end,
PlayingSampleMusicMessageCommand = function(self)
local top = SCREENMAN:GetTopScreen()
if top:GetMusicWheel():IsSettled() == true and ((getTabIndex() == 2 and nestedTab == 2) or collapsed) then
DLMAN:RequestChartLeaderBoardFromOnline(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey())
end
end,
NestedTabChangedMessageCommand = function(self)
if getTabIndex() == 2 and nestedTab == 2 then
DLMAN:RequestChartLeaderBoardFromOnline(GAMESTATE:GetCurrentSteps(PLAYER_1):GetChartKey())
end
end
}

Expand Down
15 changes: 15 additions & 0 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,20 @@ class LunaDownloadManager : public Luna<DownloadManager>
return 1;
}

// This requests the leaderboard from online. This may cause lag.
// Use this sparingly.
// This will NOT request a leaderboard if it already exists for the
// chartkey. This needs to be updated in the future to do so. That means
// this will not update a leaderboard to a new state.
static int RequestChartLeaderBoardFromOnline(T* p, lua_State* L)
{
if (DLMAN->chartLeaderboards[SArg(1)].size() == 0)
DLMAN->RequestChartLeaderBoard(SArg(1));
return 1;
}

// This does not actually request the leaderboard from online.
// It gets the already retrieved data from DLMAN
static int RequestChartLeaderBoard(T* p, lua_State* L)
{
vector<HighScore*> filteredLeaderboardScores;
Expand Down Expand Up @@ -2274,6 +2288,7 @@ class LunaDownloadManager : public Luna<DownloadManager>
ADD_METHOD(GetTopChartScoreCount);
ADD_METHOD(GetLastVersion);
ADD_METHOD(GetRegisterPage);
ADD_METHOD(RequestChartLeaderBoardFromOnline);
ADD_METHOD(RequestChartLeaderBoard);
ADD_METHOD(ToggleRateFilter);
ADD_METHOD(GetCurrentRateFilter);
Expand Down
4 changes: 2 additions & 2 deletions src/ScreenSelectMusic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ ScreenSelectMusic::CheckBackgroundRequests(bool bForce)
FallbackMusic.bAlignBeat = ALIGN_MUSIC_BEATS;

SOUND->PlayMusic(PlayParams, FallbackMusic);
DLMAN->RequestChartLeaderBoard(
GAMESTATE->m_pCurSteps[PLAYER_1]->GetChartKey());
MESSAGEMAN->Broadcast("PlayingSampleMusic");
//DLMAN->RequestChartLeaderBoard(GAMESTATE->m_pCurSteps[PLAYER_1]->GetChartKey());
}
}

Expand Down

0 comments on commit b405f04

Please sign in to comment.