Skip to content

Commit

Permalink
fix some silly goal sort logics
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jul 26, 2018
1 parent 108a036 commit 7c50eb9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class DownloadablePack {
class Packlist {
public:
int sortmode = 1; // 1=name 2=diff 3=size, init to name because that's the default- mina
int asc = true; // default sort
bool asc = true; // default sort

vector<DownloadablePack*> packs;
// Lua
Expand Down
13 changes: 7 additions & 6 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1600,18 +1600,19 @@ class LunaProfile : public Luna<Profile>
static int SetFromAll(T* p, lua_State *L) {
p->FillGoalTable();
p->filtermode = 1;
p->asc = true;
return 1;
}

static int SortByDate(T* p, lua_State* L) {
if (p->sortmode == 1)
if (p->asc) {
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->timeassigned > b->timeassigned; }; // custom operators?
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;
}
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->timeassigned < b->timeassigned; };
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;
Expand All @@ -1621,12 +1622,12 @@ class LunaProfile : public Luna<Profile>
static int SortByRate(T* p, lua_State* L) {
if (p->sortmode == 2)
if (p->asc) {
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->rate > b->rate; }; // custom operators?
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;
}
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return a->rate < b->rate; };
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;
Expand Down Expand Up @@ -1668,13 +1669,13 @@ class LunaProfile : public Luna<Profile>
static int SortByDiff(T* p, lua_State* L) {
if (p->sortmode == 5)
if (p->asc) {
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return SONGMAN->GetStepsByChartkey(a->chartkey)->GetMSD(a->rate, 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->asc = false;
return 3;
}
auto comp = [](ScoreGoal* a, ScoreGoal* b) { return SONGMAN->GetStepsByChartkey(a->chartkey)->GetMSD(a->rate, 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;
Expand Down
2 changes: 1 addition & 1 deletion src/Profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class Profile
vector<ScoreGoal*> goaltable;
int sortmode = 1; // 1=date 2=rate 3=name 4=priority 5=diff, init to name because that's the default- mina
int filtermode = 1; // 1=all, 2=completed, 3=uncompleted
int asc = false;
bool asc = false;

bool HasGoal(const string& ck) { return goalmap.count(ck) == 1; }
ScoreGoal& GetLowestGoalForRate(const string& ck, float rate);
Expand Down

0 comments on commit 7c50eb9

Please sign in to comment.