Skip to content

Commit

Permalink
Add CCOn Filter to ChartLeaderboards
Browse files Browse the repository at this point in the history
To filter out invalid scores people don't like sometimes
It's on by default.
  • Loading branch information
poco0317 committed Jun 3, 2019
1 parent 12d1520 commit 592b158
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
33 changes: 32 additions & 1 deletion Themes/Til Death/BGAnimations/superscoreboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ end

local filts = {"All Rates", "Current Rate"}
local topornah = {"Top Scores", "All Scores"}
local ccornah = {"Show Invalid", "Hide Invalid"}

local scoretable = {}
local o =
Expand Down Expand Up @@ -301,7 +302,7 @@ local o =
if collapsed then
self:xy(c5x - 175, headeroff):zoom(tzoom):halign(1):valign(1)
else
self:xy(c5x - 115, headeroff):zoom(tzoom):halign(1):valign(1)
self:xy(c5x - 160, headeroff):zoom(tzoom):halign(1):valign(1)
end
end,
HighlightCommand = function(self)
Expand All @@ -321,6 +322,36 @@ local o =
self:GetParent():queuecommand("GetFilteredLeaderboard")
end
end
},
LoadFont("Common normal") ..
{
--ccon/off filter toggle
InitCommand = function(self)
if collapsed then
self:visible(false)
--self:xy(c5x - 110, headeroff):zoom(tzoom):halign(1):valign(1)
else
self:visible(true)
self:xy(c5x - 80, headeroff):zoom(tzoom):halign(1):valign(1)
end
end,
HighlightCommand = function(self)
highlightIfOver(self)
end,
UpdateCommand = function(self)
if DLMAN:GetCCFilter() then
self:settext(ccornah[1])
else
self:settext(ccornah[2])
end
end,
MouseLeftClickMessageCommand = function(self)
if isOver(self) then
DLMAN:ToggleCCFilter()
ind = 0
self:GetParent():queuecommand("GetFilteredLeaderboard")
end
end
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/Etterna/Singletons/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2731,6 +2731,8 @@ class LunaDownloadManager : public Luna<DownloadManager>

for (auto& score : leaderboardScores) {
auto& leaderboardHighScore = score.hs;
if (p->ccoffonly && !score.nocc)
continue;
if (p->currentrateonly &&
lround(leaderboardHighScore.GetMusicRate() * 10000.f) !=
lround(currentrate * 10000.f))
Expand Down Expand Up @@ -2778,6 +2780,16 @@ class LunaDownloadManager : public Luna<DownloadManager>
lua_pushboolean(L, p->topscoresonly);
return 1;
}
static int ToggleCCFilter(T* p, lua_State* L)
{
p->ccoffonly = !p->ccoffonly;
return 0;
}
static int GetCCFilter(T* p, lua_State* L)
{
lua_pushboolean(L, p->ccoffonly);
return 1;
}
static int SendReplayDataForOldScore(T* p, lua_State* L)
{
DLMAN->UploadScoreWithReplayDataFromDisk(SArg(1));
Expand Down Expand Up @@ -2815,6 +2827,8 @@ class LunaDownloadManager : public Luna<DownloadManager>
ADD_METHOD(GetCurrentRateFilter);
ADD_METHOD(ToggleTopScoresOnlyFilter);
ADD_METHOD(GetTopScoresOnlyFilter);
ADD_METHOD(ToggleCCFilter);
ADD_METHOD(GetCCFilter);
ADD_METHOD(SendReplayDataForOldScore);
ADD_METHOD(Logout);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Etterna/Singletons/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ class DownloadManager
done); // Sends login request if not already logging in
void OnLogin();
bool UploadScores(); // Uploads all scores not yet uploaded to current
bool UpdateOnlineScoreReplayData(); // attempts updates existing replaydata
// server (Async, 1 request per score)
bool UpdateOnlineScoreReplayData(); // attempts updates existing replaydata
// server (Async, 1 request per score)
void RefreshPackList(const string& url);

void init();
Expand Down Expand Up @@ -278,6 +278,7 @@ class DownloadManager
void RefreshRegisterPage();
bool currentrateonly = false;
bool topscoresonly = true;
bool ccoffonly = true;
void RefreshCountryCodes();
void RequestReplayData(const string& scorekey,
int userid,
Expand Down Expand Up @@ -314,4 +315,3 @@ class DownloadManager
extern shared_ptr<DownloadManager> DLMAN;

#endif

0 comments on commit 592b158

Please sign in to comment.