Skip to content

Commit

Permalink
Once again, Nick12 is a genius. This probably fixes mac and linux and…
Browse files Browse the repository at this point in the history
… adds support for menu clickable items. Also fix accounts with no scores crashing on login.
  • Loading branch information
TheROPFather committed Aug 6, 2018
1 parent 275a83b commit d6671da
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
3 changes: 2 additions & 1 deletion Themes/Til Death/BGAnimations/ScreenTitleMenu underlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ for i=1,choiceCount do
transformF(self, 0, i, choiceCount)
self:addx(SCREEN_CENTER_X-20)
self:addy(SCREEN_CENTER_Y-20)
self:diffusealpha(0)
end,
MouseLeftClickMessageCommand = function(self)
if(isOver(self)) then
SCREENMAN:GetTopScreen():playcommand("MadeChoicePlayer_1")
SCREENMAN:GetTopScreen():playcommand("Choose")
if not choices[i] == "Multi" then -- for some reason multi gets stuck :/
if choices[i] ~= "Multi" then -- for some reason multi gets stuck :/
GAMESTATE:ApplyGameCommand(THEME:GetMetric("ScreenTitleMenu", "Choice"..choices[i]))
end
end
Expand Down
23 changes: 14 additions & 9 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,11 @@ void DownloadManager::RefreshTop25(Skillset ss)
catch (exception e) { }
auto scores = j.find("data");
vector<OnlineTopScore> & vec = DLMAN->topScores[ss];

if(scores == j.end()) {
return;
}

for (auto scoreJ : (*scores)) {
try {
auto score = *(scoreJ.find("attributes"));
Expand Down Expand Up @@ -1764,7 +1769,7 @@ class LunaPacklist: public Luna<Packlist>
p->packs.clear();
p->packs = DLMAN->GetCoreBundle(SArg(1));
MESSAGEMAN->Broadcast("RefreshPacklist");
return 1;
return 0;
}
static int FilterAndSearch(T* p, lua_State* L) {
if (lua_gettop(L) < 5) {
Expand All @@ -1787,7 +1792,7 @@ class LunaPacklist: public Luna<Packlist>
p->packs.push_back(&packs[i]);
}
MESSAGEMAN->Broadcast("RefreshPacklist");
return 1;
return 0;
}
static int GetTotalSize(T* p, lua_State* L) {
size_t totalsize = 0;
Expand All @@ -1812,14 +1817,14 @@ class LunaPacklist: public Luna<Packlist>
auto comp = [](DownloadablePack* a, DownloadablePack* b) { return Rage::make_lower(a->name) > Rage::make_lower(b->name); }; // custom operators?
sort(p->packs.begin(), p->packs.end(), comp);
p->asc = false;
return 1;
return 0;
}
auto comp = [](DownloadablePack* a, DownloadablePack* b) { return Rage::make_lower(a->name) < Rage::make_lower(b->name); };
sort(p->packs.begin(), p->packs.end(), comp);
p->sortmode = 1;
p->asc = true;
MESSAGEMAN->Broadcast("RefreshPacklist");
return 1;
return 0;
}
static int SortByDiff(T* p, lua_State* L) {
auto& packs = p->packs;
Expand All @@ -1828,14 +1833,14 @@ class LunaPacklist: public Luna<Packlist>
auto comp = [](DownloadablePack* a, DownloadablePack* b) { return (a->avgDifficulty < b->avgDifficulty); };
sort(packs.begin(), packs.end(), comp);
p->asc = false;
return 1;
return 0;
}
auto comp = [](DownloadablePack* a, DownloadablePack* b) { return (a->avgDifficulty > b->avgDifficulty); };
sort(packs.begin(), packs.end(), comp);
p->sortmode = 2;
p->asc = true;
MESSAGEMAN->Broadcast("RefreshPacklist");
return 1;
return 0;
}
static int SortBySize(T* p, lua_State* L) {
auto& packs = p->packs;
Expand All @@ -1844,22 +1849,22 @@ class LunaPacklist: public Luna<Packlist>
auto comp = [](DownloadablePack* a, DownloadablePack* b) { return (a->size < b->size); };
sort(packs.begin(), packs.end(), comp);
p->asc = false;
return 1;
return 0;
}
auto comp = [](DownloadablePack* a, DownloadablePack* b) { return (a->size > b->size); };
sort(packs.begin(), packs.end(), comp);
p->sortmode = 3;
p->asc = true;
MESSAGEMAN->Broadcast("RefreshPacklist");
return 1;
return 0;
}
static int SetFromAll(T* p, lua_State* L) {
auto& packs = DLMAN->downloadablePacks;
p->packs.clear();
for (auto& n : packs)
p->packs.emplace_back(&n);
MESSAGEMAN->Broadcast("RefreshPacklist");
return 1;
return 0;
}
LunaPacklist()
{
Expand Down
30 changes: 15 additions & 15 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ class LunaProfile : public Luna<Profile>
static int SetFromAll(T* p, lua_State *L) {
p->FillGoalTable();
p->filtermode = 1;
return 1;
return 0;
}

static int SortByDate(T* p, lua_State* L) {
Expand All @@ -1610,13 +1610,13 @@ class LunaProfile : public Luna<Profile>
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->timeassigned > b->timeassigned; }; // custom operators?
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->asc = false;
return 1;
return 0;
}
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->timeassigned < b->timeassigned; };
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->sortmode = 1;
p->asc = true;
return 1;
return 0;
}

static int SortByRate(T* p, lua_State* L) {
Expand All @@ -1625,13 +1625,13 @@ class LunaProfile : public Luna<Profile>
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->rate > b->rate; }; // custom operators?
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->asc = false;
return 1;
return 0;
}
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->rate < b->rate; };
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->sortmode = 2;
p->asc = true;
return 1;
return 0;
}

static int SortByName(T* p, lua_State* L) {
Expand All @@ -1641,14 +1641,14 @@ class LunaProfile : public Luna<Profile>
Rage::make_lower(SONGMAN->GetSongByChartkey(b->chartkey)->GetDisplayMainTitle()); }; // custom operators?
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->asc = false;
return 3;
return 0;
}
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return Rage::make_lower(SONGMAN->GetSongByChartkey(a->chartkey)->GetDisplayMainTitle()) <
Rage::make_lower(SONGMAN->GetSongByChartkey(b->chartkey)->GetDisplayMainTitle()); };
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->sortmode = 3;
p->asc = true;
return 1;
return 0;
}

static int SortByPriority(T* p, lua_State* L) {
Expand All @@ -1657,13 +1657,13 @@ class LunaProfile : public Luna<Profile>
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->priority > b->priority; }; // custom operators?
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->asc = false;
return 3;
return 0;
}
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->priority < b->priority; };
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->sortmode = 4;
p->asc = true;
return 1;
return 0;
}

static int SortByDiff(T* p, lua_State* L) {
Expand All @@ -1673,22 +1673,22 @@ class LunaProfile : public Luna<Profile>
SONGMAN->GetStepsByChartkey(b->chartkey)->GetMSD(b->rate, 0); };
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->asc = false;
return 3;
return 0;
}
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return SONGMAN->GetStepsByChartkey(a->chartkey)->GetMSD(a->rate, 0) <
SONGMAN->GetStepsByChartkey(b->chartkey)->GetMSD(b->rate, 0); };
sort(p->goaltable.begin(), p->goaltable.end(), comp);
p->sortmode = 5;
p->asc = true;
return 1;
return 0;
}

static int ToggleFilter(T* p, lua_State* L) {
p->FillGoalTable();

if (p->filtermode == 3) {
p->filtermode = 1;
return 1;
return 0;
}

vector<ScoreGoal*> doot;
Expand All @@ -1698,17 +1698,17 @@ class LunaProfile : public Luna<Profile>
doot.emplace_back(sg);
p->goaltable = doot;
p->filtermode = 2;
return 1;
return 0;
}
if (p->filtermode == 2) {
for (auto& sg : p->goaltable)
if (!sg->achieved)
doot.emplace_back(sg);
p->goaltable = doot;
p->filtermode = 3;
return 1;
return 0;
}
return 1;
return 0;
}
static int GetFilterMode(T* p, lua_State *L) {
lua_pushnumber(L, p->filtermode);
Expand Down

0 comments on commit d6671da

Please sign in to comment.