Skip to content

Commit

Permalink
add online leaderboard toggle for current rate only
Browse files Browse the repository at this point in the history
i really didn't want to do it this way but you forced my hand nick!!!!
  • Loading branch information
MinaciousGrace committed Jul 16, 2018
1 parent a3bdcf3 commit aa5f169
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Song.h"
#include <nlohmann/json.hpp>
#include <unordered_set>
#include <FilterManager.h>
using json = nlohmann::json;
#ifdef _WIN32
#include <intrin.h>
Expand Down Expand Up @@ -788,6 +789,7 @@ void DownloadManager::RequestChartLeaderBoard(string chartkey)
vector<OnlineScore> & vec = DLMAN->chartLeaderboards[chartkey];
vec.clear();
unordered_set<string> userswithscores;
float currentrate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
try {
auto j = json::parse(req.result);
if (j.find("errors") != j.end())
Expand Down Expand Up @@ -822,7 +824,12 @@ void DownloadManager::RequestChartLeaderBoard(string chartkey)
tmp.letgo = judgements.value("letGoHold", 0);
}
tmp.datetime.FromString(score.value("datetime", "0"));

// filter scores not on the current rate out if enabled... dunno if we need this precision -mina
tmp.rate = score.value("rate", 0.0);
if (FILTERMAN->currentrateonlyforonlineleaderboardrankings)
if(lround(tmp.rate * 10000.f) != lround(currentrate * 10000.f))
continue;
tmp.nocc = score.value("noCC", 0);
tmp.valid = score.value("valid", 0);

Expand Down
10 changes: 10 additions & 0 deletions src/FilterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ class LunaFilterManager : public Luna<FilterManager>
lua_pushboolean(L, p->HighestSkillsetsOnly);
return 1;
}
static int ToggleCurrentRateOnlyForOnlineLeaderBoard(T* p, lua_State* L) {
p->currentrateonlyforonlineleaderboardrankings = !p->currentrateonlyforonlineleaderboardrankings;
return 1;
}
static int IsCurrentRateOnlyForOnlineLeaderBoard(T* p, lua_State* L) {
lua_pushnumber(L, static_cast<int>(p->currentrateonlyforonlineleaderboardrankings));
return 1;
}
LunaFilterManager() {
ADD_METHOD(SetSSFilter);
ADD_METHOD(GetSSFilter);
Expand All @@ -140,6 +148,8 @@ class LunaFilterManager : public Luna<FilterManager>
ADD_METHOD(GetFilterMode);
ADD_METHOD(ToggleHighestSkillsetsOnly);
ADD_METHOD(GetHighestSkillsetsOnly);
ADD_METHOD(ToggleCurrentRateOnlyForOnlineLeaderBoard);
ADD_METHOD(IsCurrentRateOnlyForOnlineLeaderBoard);
}
};

Expand Down
1 change: 1 addition & 0 deletions src/FilterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FilterManager {
void ResetSSFilters(); // reset button for filters
bool HighestSkillsetsOnly = false;
bool AnyActiveFilter();
bool currentrateonlyforonlineleaderboardrankings = false;

//Lua
void PushSelf(lua_State *L);
Expand Down

0 comments on commit aa5f169

Please sign in to comment.