|
From: Tapio V. <aa...@us...> - 2010-03-15 10:11:59
|
Module: performous
Branch: dumpxml
Commit: 4e01e92b21b7e303091750c41f8e65e7247c684d
Author: Tapio Vierros <tap...@gm...>
Date: Wed Dec 30 23:02:28 2009 +0200
Remove leading numbers from titles and add tracks attribute to song xml.
---
game/song.cc | 12 +++++++++++-
game/songs.cc | 18 +++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/game/song.cc b/game/song.cc
index 5135535..52a529e 100644
--- a/game/song.cc
+++ b/game/song.cc
@@ -42,7 +42,17 @@ void Song::collateUpdate() {
}
std::string Song::collate(std::string const& str) {
- return unicodeCollate(str);
+ std::string title = str;
+ if (title[1] == '.' || title[1] == '-') {
+ if (title[2] == ' ') title = title.substr(3);
+ else title = title.substr(2);
+ }
+ if (title[2] == '.' || title[2] == '-') {
+ if (title[3] == ' ') title = title.substr(4);
+ else title = title.substr(3);
+ }
+
+ return unicodeCollate(title);
}
namespace {
diff --git a/game/songs.cc b/game/songs.cc
index 78609b9..e57d6da 100644
--- a/game/songs.cc
+++ b/game/songs.cc
@@ -262,11 +262,27 @@ namespace {
Song const& s = *svec[i];
xmlpp::Element* song = songlist->add_child("song");
song->set_attribute("num", boost::lexical_cast<std::string>(i + 1));
+ std::string tracks = "";
+ if (s.notes.size()) tracks += "S";
+ if (s.track_map.find("guitar") != s.track_map.end()) tracks += "G";
+ if (s.track_map.find("bass") != s.track_map.end()) tracks += "B";
+ if (s.track_map.find("drums") != s.track_map.end()) tracks += "R";
+ if (!s.danceTracks.empty()) tracks += "N";
+ song->set_attribute("tracks", tracks);
xmlpp::Element* collate = song->add_child("collate");
collate->add_child("artist")->set_child_text(s.collateByArtist);
collate->add_child("title")->set_child_text(s.collateByTitle);
song->add_child("artist")->set_child_text(s.artist);
- song->add_child("title")->set_child_text(s.title);
+ std::string title = s.title;
+ if (title[1] == '.' || title[1] == '-') {
+ if (title[2] == ' ') title = title.substr(3);
+ else title = title.substr(2);
+ }
+ if (title[2] == '.' || title[2] == '-') {
+ if (title[3] == ' ') title = title.substr(4);
+ else title = title.substr(3);
+ }
+ song->add_child("title")->set_child_text(title);
if (!s.cover.empty()) dumpCover(song, s, i + 1);
}
doc.write_to_file_formatted(filename, "UTF-8");
|