Skip to content

Commit

Permalink
add toggle for including rate values in chart xml node creation to al…
Browse files Browse the repository at this point in the history
…low function to be used for scores as well without needless clutter
  • Loading branch information
MinaciousGrace committed May 29, 2017
1 parent 071c8f0 commit 277e3be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/SongManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ void SongManager::InitSongsFromDisk( LoadingWindow *ld )

void Chart::FromKey(const string& ck) {
Song* song = SONGMAN->GetSongByChartkey(ck);
key = ck;

if (song) {
Steps* steps = SONGMAN->GetStepsByChartkey(ck);
key = ck;

lastpack = song->m_sGroupName;
lastsong = song->GetDisplayMainTitle();
lastdiff = steps->GetDifficulty();
Expand All @@ -256,13 +256,15 @@ void Chart::FromKey(const string& ck) {
loaded = false;
}

XNode* Chart::CreateNode() const {
XNode* Chart::CreateNode(bool includerate) const {
XNode* ch = new XNode("Chart");
ch->AppendAttr("Key", key);
ch->AppendAttr("Pack", lastpack);
ch->AppendAttr("Song", lastsong);
ch->AppendAttr("Steps", DifficultyToString(lastdiff));
ch->AppendAttr("Rate", ssprintf("%.3f",rate));

if(includerate)
ch->AppendAttr("Rate", ssprintf("%.3f",rate));
return ch;
}

Expand Down Expand Up @@ -296,7 +298,7 @@ XNode* Playlist::CreateNode() const {

XNode* cl = new XNode("Chartlist");
FOREACH_CONST(Chart, chartlist, ch)
cl->AppendChild(ch->CreateNode());
cl->AppendChild(ch->CreateNode(true));

XNode* cr = new XNode("CourseRuns");
FOREACH_CONST(vector<string>, courseruns, run) {
Expand Down
2 changes: 1 addition & 1 deletion src/SongManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct Chart {

bool loaded = false;
void FromKey(const string& ck);
XNode * CreateNode() const;
XNode * CreateNode(bool includerate) const;
void LoadFromNode(const XNode * node);
void PushSelf(lua_State *L);
};
Expand Down

0 comments on commit 277e3be

Please sign in to comment.