|
From: Markus R. <god...@us...> - 2009-07-29 15:34:54
|
Module: performous
Branch: hiscore
Commit: b2170b1d91971c000fd808ff87301d8a9b00150e
Author: Markus Raab <un...@ma...>
Date: Wed Jul 29 10:12:26 2009 +0200
Small changes
---
game/main.cc | 1 -
game/players.cc | 9 ++++++++-
game/players.hh | 2 ++
game/screen_players.cc | 9 +++++----
4 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/game/main.cc b/game/main.cc
index d8f5848..89669a6 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -135,7 +135,6 @@ void mainLoop() {
audioSetup(capture, audio);
Songs songs(songlist);
Players players(getSharePath("performous.xml"));
- try {players.load();} catch(...) {std::cerr << "Could not load players" << std::endl;}
ScreenManager sm;
Window window(config["graphic/window_width"].i(), config["graphic/window_height"].i(), config["graphic/fullscreen"].b(), config["graphic/fs_width"].i(), config["graphic/fs_height"].i());
sm.addScreen(new ScreenIntro("Intro", audio, capture));
diff --git a/game/players.cc b/game/players.cc
index fa00013..b13a4f9 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -17,11 +17,14 @@ Players::Players(std::string filename):
m_dirty(false),
cur()
{
+ try { load(); }
+ catch(...) { std::cerr << "Could not load " << file() << ", will create" << std::endl; }
m_filtered = m_players;
}
Players::~Players() {
- try { save(); } catch (...) { std::cerr << "Could not save players to " << m_filename << std::endl; }
+ try { save(); }
+ catch (...) { std::cerr << "Could not save players to " << file() << std::endl; }
}
void Players::load() {
@@ -67,6 +70,10 @@ void Players::update() {
if (m_dirty) filter_internal();
}
+std::string Players::file() {
+ return m_filename;
+}
+
void Players::addPlayer (std::string const& name, std::string const& picture) {
PlayerItem pi;
pi.name = name;
diff --git a/game/players.hh b/game/players.hh
index 924b13a..9f78b70 100644
--- a/game/players.hh
+++ b/game/players.hh
@@ -64,6 +64,8 @@ class Players: boost::noncopyable {
}
void save();
void update();
+ /**Returns the path to which file is used*/
+ std::string file();
void addPlayer (std::string const& name, std::string const& picture = "");
/// const array access
diff --git a/game/screen_players.cc b/game/screen_players.cc
index 0333213..f2b6542 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -18,7 +18,7 @@ void ScreenPlayers::enter() {
try {
m_highscore->load();
} catch (HiscoreException const& hi) {
- std::cerr << "high.sco:" << hi.line() << " " << hi.what() << std::endl;
+ std::cerr << "High.sco:" << hi.line() << " " << hi.what() << std::endl;
}
m_score_text[0].reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
@@ -51,7 +51,7 @@ void ScreenPlayers::exit() {
try {
m_highscore->save();
} catch (HiscoreException const& hi) {
- std::cerr << "high.sco:" << hi.line() << " " << hi.what() << std::endl;
+ std::cerr << "High.sco:" << hi.line() << " " << hi.what() << std::endl;
}
m_highscore.reset();
}
@@ -137,8 +137,9 @@ void ScreenPlayers::draw() {
// Format the song information text
if (m_search.text.empty()) {
oss_song << "No players found!";
- oss_order << "Check players.xml in current\n"; // TODO retrieve from configuration
- oss_order << "directory for players";
+ oss_order << "Check " << m_players.file() << "\n";
+ oss_order << "directory for players\n";
+ oss_order << "Enter a name to create a new player.";
} else {
oss_song << "Press enter to create player!";
oss_order << m_search.text << '\n';
|