|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:43:35
|
Module: performous
Branch: dance
Commit: f65ed74215f3747e0f2c47e8a94a20f6ae8ebd05
Author: Markus Raab <un...@ma...>
Date: Wed Nov 11 15:15:15 2009 +0100
addSong now works
---
game/database.cc | 3 +++
game/database.hh | 3 +++
game/song.cc | 4 ++++
game/song.hh | 2 ++
game/songitems.cc | 2 +-
5 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/game/database.cc b/game/database.cc
index 6190ffb..c71c21f 100644
--- a/game/database.cc
+++ b/game/database.cc
@@ -66,4 +66,7 @@ int main()
{
Database d("database.xml");
d.addPlayer("Markus", "m.jpg");
+
+ boost::shared_ptr<Song> s(new Song("/usr/share/songs/ABBA/ABBA - Dancing Queen/", "ABBA - Dancing Queen.txt"));
+ d.addSong(s);
}
diff --git a/game/database.hh b/game/database.hh
index ba74745..fd0f553 100644
--- a/game/database.hh
+++ b/game/database.hh
@@ -37,6 +37,9 @@ public: // methods for player management
void addPlayer (std::string const& name, std::string const& picture = "", int id = -1)
{ m_players.addPlayer(name, picture, id); }
+ void addSong (boost::shared_ptr<Song>s)
+ { m_songs.addSong(s); }
+
private:
fs::path m_filename;
diff --git a/game/song.cc b/game/song.cc
index d75d92a..5135535 100644
--- a/game/song.cc
+++ b/game/song.cc
@@ -15,7 +15,9 @@ void Song::reload(bool errorIgnore) {
title.clear();
artist.clear();
collateByTitle.clear();
+ collateByTitleOnly.clear();
collateByArtist.clear();
+ collateByArtistOnly.clear();
text.clear();
creator.clear();
music.clear();
@@ -34,7 +36,9 @@ void Song::reload(bool errorIgnore) {
void Song::collateUpdate() {
collateByTitle = collate(title + artist) + '\0' + filename;
+ collateByTitleOnly = collate(title);
collateByArtist = collate(artist + title) + '\0' + filename;
+ collateByArtistOnly = collate(artist);
}
std::string Song::collate(std::string const& str) {
diff --git a/game/song.hh b/game/song.hh
index f02bf87..983dc3f 100644
--- a/game/song.hh
+++ b/game/song.hh
@@ -60,8 +60,10 @@ class Song: boost::noncopyable {
std::string video; ///< video
/// Variables used for comparisons (sorting)
std::string collateByTitle;
+ std::string collateByTitleOnly;
/// Variables used for comparisons (sorting)
std::string collateByArtist;
+ std::string collateByArtistOnly;
/** Rebuild collate variables from other strings **/
void collateUpdate();
/** Convert a string to its collate form **/
diff --git a/game/songitems.cc b/game/songitems.cc
index db61ff3..4b1c522 100644
--- a/game/songitems.cc
+++ b/game/songitems.cc
@@ -60,7 +60,7 @@ void SongItems::addSong(boost::shared_ptr<Song> song)
{
for (songs_t::iterator it = m_songs.begin(); it != m_songs.end(); ++it)
{
- if (song->artist == it->artist && song->title == it->title) return;
+ if (song->collateByArtistOnly == it->artist && song->collateByTitleOnly == it->title) return;
}
addSongItem(song->artist, song->title);
}
|