Skip to content

Commit

Permalink
Add Top Score/All Scores toggle like EO
Browse files Browse the repository at this point in the history
Original function now builds the whole list.
Lua filters out the stuff when it should.
  • Loading branch information
poco0317 committed Sep 3, 2018
1 parent dc79d47 commit da97cb6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
23 changes: 23 additions & 0 deletions Themes/Til Death/BGAnimations/superscoreboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ local function byAchieved(scoregoal)
end

local filts = {"All Rates", "Current Rate"}
local topornah = {"Top Scores", "All Scores"}

local scoretable
local o = Def.ActorFrame{
Expand Down Expand Up @@ -259,6 +260,28 @@ local o = Def.ActorFrame{
end
end,
},
LoadFont("Common normal") .. { --top score/all score toggle
InitCommand=function(self)
self:xy(c5x - 115, headeroff):zoom(tzoom):halign(1)
end,
HighlightCommand=function(self)
highlightIfOver(self)
end,
UpdateCommand=function(self)
if DLMAN:GetTopScoresOnlyFilter() then
self:settext(topornah[1])
else
self:settext(topornah[2])
end
end,
MouseLeftClickMessageCommand=function(self)
if isOver(self) then
DLMAN:ToggleTopScoresOnlyFilter()
ind = 0
self:GetParent():queuecommand("ChartLeaderboardUpdate")
end
end,
},
}

local function makeScoreDisplay(i)
Expand Down
19 changes: 17 additions & 2 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,9 @@ void DownloadManager::RequestChartLeaderBoard(string chartkey)
// it seems prudent to maintain the eo functionality in this way and screen out multiple scores from the same user
// even more prudent would be to put this last where it belongs, we don't want to screen out scores for players who wouldn't
// have had them registered in the first place -mina
if (userswithscores.count(tmp.username) == 1)
continue;
// Moved this filtering to the Lua call. -poco
//if (userswithscores.count(tmp.username) == 1)
// continue;

userswithscores.emplace(tmp.username);
vec.emplace_back(tmp);
Expand Down Expand Up @@ -1787,11 +1788,15 @@ class LunaDownloadManager : public Luna<DownloadManager>
//p->RequestChartLeaderBoard(SArg(1));
p->MakeAThing(SArg(1));
vector<HighScore*> wot;
unordered_set<string> userswithscores;
float currentrate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
for (auto& zoop : p->athing) {
if (lround(zoop.GetMusicRate() * 10000.f) != lround(currentrate * 10000.f) && p->currentrateonly)
continue;
if (userswithscores.count(zoop.GetName()) == 1 && p->topscoresonly)
continue;
wot.push_back(&zoop);
userswithscores.emplace(zoop.GetName());
}
LuaHelpers::CreateTableFromArray(wot, L);
return 1;
Expand All @@ -1805,6 +1810,14 @@ class LunaDownloadManager : public Luna<DownloadManager>
lua_pushboolean(L, p->currentrateonly);
return 1;
}
static int ToggleTopScoresOnlyFilter(T* p, lua_State* L) {
p->topscoresonly = !p->topscoresonly;
return 0;
}
static int GetTopScoresOnlyFilter(T* p, lua_State* L) {
lua_pushboolean(L, p->topscoresonly);
return 1;
}

LunaDownloadManager()
{
Expand All @@ -1828,6 +1841,8 @@ class LunaDownloadManager : public Luna<DownloadManager>
ADD_METHOD(RequestChartLeaderBoard);
ADD_METHOD(ToggleRateFilter);
ADD_METHOD(GetCurrentRateFilter);
ADD_METHOD(ToggleTopScoresOnlyFilter);
ADD_METHOD(GetTopScoresOnlyFilter);
ADD_METHOD(Logout);
}
};
Expand Down
1 change: 1 addition & 0 deletions src/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class DownloadManager
void MakeAThing(string chartkey);
vector<HighScore> athing;
bool currentrateonly = false;
bool topscoresonly = true;
void RequestChartLeaderBoard(string chartkey);
void RefreshUserData();
void RefreshUserRank();
Expand Down

0 comments on commit da97cb6

Please sign in to comment.