Skip to content

Commit

Permalink
give lua the ability to grab a table of all goals and put the stupid …
Browse files Browse the repository at this point in the history
…spaces back because they actually make things easier to read
  • Loading branch information
MinaciousGrace committed Apr 28, 2017
1 parent cff3868 commit c62e0cb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
48 changes: 33 additions & 15 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@ void Profile::LoadEttScoresFromNode(const XNode* pSongScores) {
void Profile::CreateGoal(RString ck) {
ScoreGoal goal;
goal.timeassigned = DateTime::GetNowDateTime();
//goal.rate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
goal.rate = GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate;
goalmap[ck].emplace_back(goal);
LOG->Trace("New goal created %i goals", goalmap[ck].size());
}
Expand Down Expand Up @@ -3710,6 +3710,23 @@ class LunaProfile : public Luna<Profile>
return 1;
}

static int GetAllGoals(T* p, lua_State *L) {
lua_newtable(L);
int idx = 0;
FOREACHM(RString, vector<ScoreGoal>, p->goalmap, i) {
const RString &ck = i->first;
auto sgv = i->second;
FOREACH(ScoreGoal, sgv, sg) {
sg->PushSelf(L);
lua_rawseti(L, -2, idx + 1);
idx++;
}

}

return 1;
}

LunaProfile()
{
ADD_METHOD( AddScreenshot );
Expand Down Expand Up @@ -3791,20 +3808,21 @@ class LunaProfile : public Luna<Profile>
ADD_METHOD( RecalcTopSSR );
ADD_METHOD( GetPBHighScoreByKey );
ADD_METHOD( ValidateAllScores );
ADD_METHOD( GetGoalByKey);
ADD_METHOD( GetGoalByKey );
ADD_METHOD( GetAllGoals );
}
};

LUA_REGISTER_CLASS( Profile )
class LunaScoreGoal : public Luna<ScoreGoal>
{
public:
DEFINE_METHOD(GetRate, rate);
DEFINE_METHOD(GetPercent, percent);
DEFINE_METHOD(GetPriority, priority);
DEFINE_METHOD(IsAchieved, achieved);
DEFINE_METHOD(GetComment, comment);
DEFINE_METHOD(WhenAssigned, timeassigned.GetString());
DEFINE_METHOD( GetRate, rate );
DEFINE_METHOD( GetPercent, percent );
DEFINE_METHOD( GetPriority, priority );
DEFINE_METHOD( IsAchieved, achieved );
DEFINE_METHOD( GetComment, comment );
DEFINE_METHOD( WhenAssigned, timeassigned.GetString() );

static int WhenAchieved(T* p, lua_State *L) {
if (p->achieved)
Expand All @@ -3822,13 +3840,13 @@ class LunaScoreGoal : public Luna<ScoreGoal>

LunaScoreGoal()
{
ADD_METHOD(GetRate);
ADD_METHOD(GetPercent);
ADD_METHOD(GetPriority);
ADD_METHOD(IsAchieved);
ADD_METHOD(GetComment);
ADD_METHOD(WhenAssigned);
ADD_METHOD(WhenAchieved);
ADD_METHOD( GetRate );
ADD_METHOD( GetPercent );
ADD_METHOD( GetPriority );
ADD_METHOD( IsAchieved );
ADD_METHOD( GetComment );
ADD_METHOD( WhenAssigned );
ADD_METHOD( WhenAchieved );
}
};
LUA_REGISTER_CLASS(ScoreGoal)
Expand Down
1 change: 1 addition & 0 deletions src/Profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ScoreGoal
DateTime timeassigned;
DateTime timeachieved;
RString comment = "";
RString chartkey = "";

XNode* CreateNode() const;
void LoadFromNode(const XNode *pNode);
Expand Down

0 comments on commit c62e0cb

Please sign in to comment.