|
From: Markus R. <god...@us...> - 2009-11-12 12:50:03
|
Module: performous
Branch: master
Commit: a785edf51deeaa576cb7b2df263d29ec5d456f04
Author: Markus Raab <un...@ma...>
Date: Thu Nov 12 11:45:56 2009 +0100
in the middle of work
reason: to pull from master
---
game/CMakeLists.txt | 3 +--
game/database.cc | 5 +++++
game/database.hh | 2 +-
game/main.cc | 8 ++++----
game/players.hh | 2 --
game/screen_hiscore.hh | 2 +-
game/screen_players.hh | 2 +-
game/screen_sing.hh | 11 ++++++-----
game/songs.cc | 3 ++-
game/songs.hh | 4 +++-
10 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index 4f48dfa..3b191fa 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 2.6)
-# FILE(GLOB SOURCE_FILES "*.cc")
-SET(SOURCE_FILES hiscore.cc database.cc players.cc configuration.cc fs.cc unicode.cc songitems.cc song.cc notes.cc songparser-ini.cc songparser-txt.cc midifile.cc)
+FILE(GLOB SOURCE_FILES "*.cc")
FILE(GLOB HEADER_FILES "*.hh")
set(SOURCES ${SOURCE_FILES} ${HEADER_FILES})
diff --git a/game/database.cc b/game/database.cc
index d0f2bba..a7bb9ac 100644
--- a/game/database.cc
+++ b/game/database.cc
@@ -118,7 +118,11 @@ void Database::queryPerPlayerHiscore (std::ostream & os, std::string const& trac
<< hi[i].score << "\n";
}
}
+bool Database::noPlayers() const {
+ return m_players.cur.empty();
+}
+/*
int test(std::string const& name, std::string const& song, int score) {
Database d("database.xml");
// d.addPlayer("Markus", "m.jpg");
@@ -161,3 +165,4 @@ int main(int argc, char**argv) {
return test(name, song, score);
}
+*/
diff --git a/game/database.hh b/game/database.hh
index c884944..fb7d18f 100644
--- a/game/database.hh
+++ b/game/database.hh
@@ -71,7 +71,7 @@ class Database
void queryPerSongHiscore (std::ostream & os, boost::shared_ptr<Song> s, std::string const& track = "") const;
void queryPerPlayerHiscore (std::ostream & os, std::string const& track = "") const;
- friend int test(std::string const&, std::string const&, int);
+ bool noPlayers() const;
private:
fs::path m_filename;
diff --git a/game/main.cc b/game/main.cc
index c444e90..a863bfd 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -142,17 +142,17 @@ void mainLoop() {
Audio audio;
audioSetup(capture, audio);
Backgrounds backgrounds;
- Songs songs(songlist);
Database database(getHomeDir() / ".config" / "performous" / "database.xml");
+ Songs songs(database, songlist);
ScreenManager sm;
Window window(config["graphic/window_width"].i(), config["graphic/window_height"].i(), config["graphic/fullscreen"].b());
sm.addScreen(new ScreenIntro("Intro", audio, capture));
sm.addScreen(new ScreenSongs("Songs", audio, songs));
- sm.addScreen(new ScreenSing("Sing", audio, capture, database.m_players, backgrounds));
+ sm.addScreen(new ScreenSing("Sing", audio, capture, database, backgrounds));
sm.addScreen(new ScreenPractice("Practice", audio, capture));
sm.addScreen(new ScreenConfiguration("Configuration", audio));
- sm.addScreen(new ScreenPlayers("Players", audio, database.m_players));
- sm.addScreen(new ScreenHiscore("Hiscore", audio, database.m_players));
+ sm.addScreen(new ScreenPlayers("Players", audio, database));
+ sm.addScreen(new ScreenHiscore("Hiscore", audio, database));
sm.activateScreen("Intro");
// Main loop
boost::xtime time = now();
diff --git a/game/players.hh b/game/players.hh
index 2e67199..f3aa07b 100644
--- a/game/players.hh
+++ b/game/players.hh
@@ -54,8 +54,6 @@ class Players: boost::noncopyable {
bool m_dirty;
- friend int test(std::string const&, std::string const&, int);
-
public:
cur_players_t cur;
cur_scores_t scores;
diff --git a/game/screen_hiscore.hh b/game/screen_hiscore.hh
index 14e10a6..0e0ff5f 100644
--- a/game/screen_hiscore.hh
+++ b/game/screen_hiscore.hh
@@ -37,7 +37,7 @@ class ScreenHiscore : public Screen {
Audio& m_audio;
Players& m_players;
boost::shared_ptr<Song> m_song; /// Pointer to the current song
- boost::scoped_ptr<SongHiscore> m_highscore;
+ boost::scoped_ptr<Hiscore> m_highscore;
boost::scoped_ptr<Surface> m_songbg;
boost::scoped_ptr<Video> m_video;
boost::scoped_ptr<ThemeSongs> theme;
diff --git a/game/screen_players.hh b/game/screen_players.hh
index 5015c09..18cb58e 100644
--- a/game/screen_players.hh
+++ b/game/screen_players.hh
@@ -32,7 +32,7 @@ class ScreenPlayers : public Screen {
Audio& m_audio;
Players& m_players;
boost::shared_ptr<Song> m_song; /// Pointer to the current song
- boost::scoped_ptr<SongHiscore> m_highscore;
+ boost::scoped_ptr<Hiscore> m_highscore;
boost::scoped_ptr<Surface> m_songbg;
boost::scoped_ptr<Video> m_video;
boost::scoped_ptr<ThemeSongs> theme;
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index 98d3fb5..17d1d69 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -14,6 +14,7 @@
#include "surface.hh"
#include "opengl_text.hh"
#include "progressbar.hh"
+#include "database.hh"
#include "screen_players.hh"
@@ -25,12 +26,12 @@ class Capture;
class ScoreWindow {
public:
/// constructor
- ScoreWindow(Engine & e, Players & players);
+ ScoreWindow(Engine & e, Database & database);
/// draws ScoreWindow
void draw();
- bool empty() { return m_players.cur.empty(); }
+ bool empty() { return m_database.noPlayers(); }
private:
- Players & m_players;
+ Database & m_database;
AnimValue m_pos;
Surface m_bg;
ProgressBar m_scoreBar;
@@ -43,8 +44,8 @@ class ScoreWindow {
class ScreenSing: public Screen {
public:
/// constructor
- ScreenSing(std::string const& name, Audio& audio, Capture& capture, Players& players, Backgrounds& bgs):
- Screen(name), m_audio(audio), m_capture(capture), m_players(players), m_backgrounds(bgs), m_latencyAV()
+ ScreenSing(std::string const& name, Audio& audio, Capture& capture, Database& database, Backgrounds& bgs):
+ Screen(name), m_audio(audio), m_capture(capture), m_database(database), m_backgrounds(bgs), m_latencyAV()
{}
void enter();
void exit();
diff --git a/game/songs.cc b/game/songs.cc
index 65bce0c..51afd2f 100644
--- a/game/songs.cc
+++ b/game/songs.cc
@@ -14,7 +14,7 @@
#include <stdexcept>
#include <cstdlib>
-Songs::Songs(std::string const& songlist): m_songlist(songlist), math_cover(), m_order(), m_dirty(false), m_loading(false), m_needShuffle(false) {
+Songs::Songs(Database & database, std::string const& songlist): m_songlist(songlist), math_cover(), m_order(), m_dirty(false), m_loading(false), m_needShuffle(false), m_database(database) {
reload();
}
@@ -72,6 +72,7 @@ void Songs::reload_internal(fs::path const& parent) {
Song* s = new Song(path, name);
s->randomIdx = ++randomIdx; // Not so random during loading, they are shuffled after load is finished
boost::mutex::scoped_lock l(m_mutex);
+ database.addSong(s);
m_songs.push_back(boost::shared_ptr<Song>(s));
m_dirty = true;
} catch (SongParserException& e) {
diff --git a/game/songs.hh b/game/songs.hh
index a5c44ad..ee5028b 100644
--- a/game/songs.hh
+++ b/game/songs.hh
@@ -3,6 +3,7 @@
#include "animvalue.hh"
#include "fs.hh"
#include "song.hh"
+#include "database.hh"
#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/thread/mutex.hpp>
@@ -14,7 +15,7 @@
class Songs: boost::noncopyable {
public:
/// constructor
- Songs(std::string const& songlist = std::string());
+ Songs(Database & database, std::string const& songlist = std::string());
~Songs();
/// updates filtered songlist
void update();
@@ -70,6 +71,7 @@ class Songs: boost::noncopyable {
SongVector m_songs, m_filtered;
AnimAcceleration math_cover;
std::string m_filter;
+ Database & m_database;
int m_order;
void dumpSongs_internal() const;
void reload_internal();
|