You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(25) |
Jul
(288) |
Aug
(119) |
Sep
(31) |
Oct
(59) |
Nov
(458) |
Dec
(359) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(268) |
Feb
(26) |
Mar
(36) |
Apr
(48) |
May
(119) |
Jun
(37) |
Jul
(173) |
Aug
(429) |
Sep
(137) |
Oct
(156) |
Nov
(59) |
Dec
(45) |
| 2011 |
Jan
(398) |
Feb
(257) |
Mar
(49) |
Apr
(5) |
May
(34) |
Jun
(11) |
Jul
(38) |
Aug
(12) |
Sep
(1) |
Oct
(49) |
Nov
(5) |
Dec
(10) |
| 2012 |
Jan
(21) |
Feb
(32) |
Mar
(20) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(173) |
Aug
|
Sep
(25) |
Oct
(6) |
Nov
(44) |
Dec
|
|
From: knittl <kn...@us...> - 2009-08-03 08:39:34
|
Module: performous Branch: master Commit: fc07860cd127193852054449c26a0cf0a52a3743 Author: Lasse Karkkainen <tro...@tr...> Date: Thu Jul 30 23:49:05 2009 +0300 Proper gameplay for drums, improved gameplay for guitar. Mistakes reduce the score now. --- game/guitargraph.cc | 90 +++++++++++++++++++++++++++++++---------- themes/default/band_cover.svg | 4 +- 2 files changed, 70 insertions(+), 24 deletions(-) |
|
From: knittl <kn...@us...> - 2009-08-03 08:39:32
|
Module: performous Branch: master Commit: b3e89650089d9f6b3a8ea0a4268fdc898c90ca09 Author: Lasse Karkkainen <tro...@tr...> Date: Thu Jul 30 22:33:41 2009 +0300 Drum graphics and partial handling. --- game/guitargraph.cc | 88 +++++++++++++++------- game/guitargraph.hh | 3 + themes/default/drumneck.svg | 175 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+), 29 deletions(-) |
|
From: Markus R. <god...@us...> - 2009-07-31 13:58:37
|
Module: performous
Branch: master
Commit: 9e4d772c0d91ad2a6f5b7f1b26241bed6d943dcc
Author: Markus Raab <un...@ma...>
Date: Fri Jul 31 15:57:47 2009 +0200
hiscore bugs
CRLF is now handeled correctly (thanks to boost::trim)
isWriteable should not truncate the file anymore
thanks to Andreas Fachathaler for High.sco example
---
game/highscore.cc | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/game/highscore.cc b/game/highscore.cc
index a1420f8..e67bb20 100644
--- a/game/highscore.cc
+++ b/game/highscore.cc
@@ -1,5 +1,6 @@
#include "highscore.hh"
#include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string.hpp>
#include "unicode.hh"
@@ -42,10 +43,13 @@ void SongHiscore::load()
unsigned int playernum = 0;
while (std::getline(ss, str))
{
- if (str == "E") break;
linenum++;
- if (playernum > 9) throw HiscoreException("Not more than 10 highscores expected in file", linenum);
+
+ boost::trim(str);
if (str.empty()) continue; // ignore empty player lines
+
+ if (str == "E") break;
+ if (playernum > 9) throw HiscoreException("Not more than 10 highscores expected in file", linenum);
if (str.length() <= 9) throw HiscoreException("Line not long enough for player information", linenum);
if (str[0] != '#') throw HiscoreException("No # found at begin of line", linenum);
@@ -61,7 +65,10 @@ void SongHiscore::load()
std::getline(ss, str);
linenum++;
+
+ boost::trim(str);
if (str.empty()) throw HiscoreException("Expected Score, but found empty line", linenum);
+
if (str.length() <= 8) throw HiscoreException("Line not long enough for score information", linenum);
if (str[0] != '#') throw HiscoreException("No # found at begin of line", linenum);
@@ -76,6 +83,7 @@ void SongHiscore::load()
int score = 0;
try {
+ boost::trim(sscore);
score = boost::lexical_cast<int>(sscore);
} catch (boost::bad_lexical_cast const& blc)
{
@@ -115,7 +123,7 @@ void SongHiscore::save()
bool SongHiscore::isWritable()
{
- std::ofstream out ((m_path + m_filename).c_str());
+ std::ofstream out ((m_path + m_filename).c_str(), std::ios::app);
return out.is_open();
}
@@ -162,12 +170,13 @@ int main()
else std::cout << "Is not writeable" << std::endl;
hi.load();
- int new_score = 9000;
+ int new_score = 5000;
if (hi.reachedNewHiscore(new_score))
{
std::cout << "Reached new highscore" << std::endl;
- hi.addNewHiscore("new player", new_score);
+ hi.addNewHiscore("nplayer", new_score);
}
+ hi.getInfo(std::cout);
hi.save();
} catch (HiscoreException const& hie)
{
|
|
From: Markus R. <god...@us...> - 2009-07-30 08:34:18
|
Module: performous
Branch: master
Commit: 138ab3f1ab2804311936eaf02ee79b2d962f3f7d
Author: Markus Raab <un...@ma...>
Date: Thu Jul 30 10:26:43 2009 +0200
activate next screen in ScreenPlayers
some docu
better name
---
game/screen_sing.cc | 6 +++---
game/screen_sing.hh | 8 +++++++-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 6fbc735..d1e4fa0 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -46,7 +46,7 @@ void ScreenSing::exit() {
theme.reset();
}
-void ScreenSing::activatePlayerScreen()
+void ScreenSing::activateNextScreen()
{
ScreenManager* sm = ScreenManager::getSingletonPtr();
@@ -97,7 +97,7 @@ void ScreenSing::manageEvent(SDL_Event event) {
return;
}
else if (key == SDLK_RETURN) {
- if (m_score_window.get()) { activatePlayerScreen(); return; } // Score window visible -> Enter quits
+ if (m_score_window.get()) { activateNextScreen(); return; } // Score window visible -> Enter quits
else if (status == Song::FINISHED) m_score_window.reset(new ScoreWindow(*m_engine, m_players)); // Song finished, but no score window -> show it
}
else if (key == SDLK_SPACE || key == SDLK_PAUSE) m_audio.togglePause();
@@ -201,7 +201,7 @@ void ScreenSing::draw() {
}
} else {
if (m_score_window.get()) {
- if (m_quitTimer.get() == 0.0 && !m_audio.isPaused()) { activatePlayerScreen(); return; }
+ if (m_quitTimer.get() == 0.0 && !m_audio.isPaused()) { activateNextScreen(); return; }
m_score_window->draw();
}
else if (!m_audio.isPlaying() || (status == Song::FINISHED && m_audio.getLength() - time < 3.0)) {
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index 927ee1c..07e3668 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -53,7 +53,13 @@ class ScreenSing: public Screen {
}
private:
- void activatePlayerScreen();
+ /**Activates Songs Screen or Players Screen.
+ This depends on
+ - the configuration (is Hiscore enabled)
+ - did a player reach a new hiscore
+ - is the hiscore file writable
+ */
+ void activateNextScreen();
Audio& m_audio;
Capture& m_capture;
Players& m_players;
|
|
From: Markus R. <god...@us...> - 2009-07-30 08:34:17
|
Module: performous
Branch: master
Commit: 366b96e080defc98559ab11cf4621ca3db80da73
Author: Markus Raab <un...@ma...>
Date: Thu Jul 30 10:21:56 2009 +0200
move PlayerItem to player.hh
---
game/player.hh | 20 ++++++++++++++++++++
game/players.hh | 20 --------------------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/game/player.hh b/game/player.hh
index 6335ec9..a32aa2d 100644
--- a/game/player.hh
+++ b/game/player.hh
@@ -46,3 +46,23 @@ struct Player {
return other.m_score < m_score;
}
};
+
+/** Static Information of a player, not
+ dependent from current song.
+
+ Used for Players Management.
+ */
+struct PlayerItem {
+ std::string name; /// unique name, link to highscore
+ std::string path; /// a path to a picture shown
+ std::string picture; /// + the filename for it
+/* Future ideas
+ std::string displayedName; /// artist name, short name, nick (can be changed)
+ std::map<std::string, int> scores; /// map between a Song and the highest score the Player achieved
+*/
+
+ bool operator== (PlayerItem const& pi) const
+ {
+ return name == pi.name;
+ }
+};
diff --git a/game/players.hh b/game/players.hh
index 9f78b70..11dcdb4 100644
--- a/game/players.hh
+++ b/game/players.hh
@@ -8,26 +8,6 @@
#include "animvalue.hh"
-/** Static Information of a player, not
- dependent from current song.
-
- Used for Players Management.
- */
-struct PlayerItem {
- std::string name; /// unique name, link to highscore
- std::string path; /// a path to a picture shown
- std::string picture; /// + the filename for it
-/* Future ideas
- std::string displayedName; /// artist name, short name, nick (can be changed)
- std::map<std::string, int> scores; /// map between a Song and the highest score the Player achieved
-*/
-
- bool operator== (PlayerItem const& pi) const
- {
- return name == pi.name;
- }
-};
-
/**A collection of all Players.
The current players plugged in a song can
|
|
From: Markus R. <god...@us...> - 2009-07-30 08:34:16
|
Module: performous Branch: master Commit: 3056549f9bf4070606cf8f7ae2f464d63933504f Author: Markus Raab <un...@ma...> Date: Thu Jul 30 10:15:41 2009 +0200 ScreenPlayer use drawScores from LayoutSinger theme is now optional using shared_ptr drawScore as own method drawing lyrics only if theme is present Removed not used Engine and Song in LayoutSinger --- game/layout_singer.cc | 73 +++++++++++++++++++++++++----------------------- game/layout_singer.hh | 11 ++++--- game/screen_players.cc | 36 ++--------------------- game/screen_players.hh | 7 +--- game/screen_sing.cc | 2 +- game/screen_sing.hh | 2 +- 6 files changed, 52 insertions(+), 79 deletions(-) |
|
From: Markus R. <god...@us...> - 2009-07-29 15:47:32
|
Module: performous Branch: hiscore Commit: 2d3dd5b4c46c86edb579d3155f00b6cc0c55845c Author: Markus Raab <un...@ma...> Date: Wed Jul 29 17:46:37 2009 +0200 use cmake . later on --- docs/Compiling.txt | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/docs/Compiling.txt b/docs/Compiling.txt index 8f1128d..cab8fea 100644 --- a/docs/Compiling.txt +++ b/docs/Compiling.txt @@ -14,7 +14,7 @@ To install from git: performous # Should you need to change building settings (e.g. installation prefix) - ccmake .. + ccmake . Dependencies: |
|
From: Markus R. <god...@us...> - 2009-07-29 15:36:11
|
Module: performous
Branch: master
Commit: 75c176eb6cf015d46d220777115e43f73743b51e
Author: Markus Raab <un...@ma...>
Date: Wed Jul 29 11:34:15 2009 +0200
bug fix
check path, because there might be a picture given in
xml but not as file
---
game/screen_players.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/screen_players.cc b/game/screen_players.cc
index f2b6542..81e819c 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -162,7 +162,7 @@ void ScreenPlayers::draw() {
PlayerItem player_display = m_players[baseidx + i];
if (baseidx + i < 0 || baseidx + i >= int(ss)) continue;
Surface* cover = 0;
- if (player_display.picture != "")
+ if (player_display.path != "")
{
try { cover = &m_covers[player_display.path + "/" + player_display.picture]; }
catch (std::exception const&) {}
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:36:09
|
Module: performous
Branch: master
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';
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:36:09
|
Module: performous Branch: master Commit: 4e72409fcb6b2412df88692cef7988448ba1fd86 Author: Markus Raab <un...@ma...> Date: Wed Jul 29 13:52:48 2009 +0200 Merge branch 'highscore' Conflicts: game/layout_singer.cc game/layout_singer.hh game/notegraph.cc game/notegraph.hh game/screen_sing.cc game/screen_songs.cc --- |
|
From: Markus R. <god...@us...> - 2009-07-29 15:36:07
|
Module: performous
Branch: master
Commit: 82595126294551b772ac38d3842f9733163c5ca1
Author: Markus Raab <un...@ma...>
Date: Wed Jul 29 12:24:41 2009 +0200
optimize deactivation
---
game/screen_sing.cc | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 09161f8..5ec8717 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -63,6 +63,13 @@ void ScreenSing::activatePlayerScreen()
{
ScreenManager* sm = ScreenManager::getSingletonPtr();
+ if (!config["game/song_hiscore"].b())
+ {
+ // user does not want a per song highscore
+ sm->activateScreen("Songs");
+ return;
+ }
+
// TODO: multiple loading...
// TODO: make it possible to switch of highscore through configuration
SongHiscore hi(m_song->path, "High.sco");
@@ -74,8 +81,7 @@ void ScreenSing::activatePlayerScreen()
if (m_players.scores.empty()
|| !hi.reachedNewHiscore(m_players.scores.front())
- || !hi.isWritable()
- || !config["game/song_hiscore"].b())
+ || !hi.isWritable())
{
// if no highscore reached..
sm->activateScreen("Songs");
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:36:02
|
Module: performous
Branch: master
Commit: 26f0fadddd5c8dbeb4851cfa966a8e16164efbb9
Author: Markus Raab <un...@ma...>
Date: Wed Jul 29 09:31:37 2009 +0200
Hiscore now disabled per default
---
data/performous.xml | 6 ++++++
game/screen_sing.cc | 3 ++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/data/performous.xml b/data/performous.xml
index 8e894da..3760fa7 100644
--- a/data/performous.xml
+++ b/data/performous.xml
@@ -38,6 +38,12 @@
<long>Hide pitch wave, notes and scoring</long>
</locale>
</entry>
+ <entry name="game/song_hiscore" type="bool" value="false">
+ <locale name="C">
+ <short>Song Hiscore</short>
+ <long>Show and save a per song hiscore.</long>
+ </locale>
+ </entry>
<entry name="game/pitch" type="bool" value="true">
<locale name="C">
<short>Pitch waves</short>
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 7accaea..09161f8 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -74,7 +74,8 @@ void ScreenSing::activatePlayerScreen()
if (m_players.scores.empty()
|| !hi.reachedNewHiscore(m_players.scores.front())
- || !hi.isWritable())
+ || !hi.isWritable()
+ || !config["game/song_hiscore"].b())
{
// if no highscore reached..
sm->activateScreen("Songs");
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:36:01
|
Module: performous
Branch: master
Commit: 5206710e9ecbe137118ca071fc1c25e908c21bca
Author: Markus Raab <un...@ma...>
Date: Wed Jul 29 10:03:12 2009 +0200
use share path
---
data/performous.xml | 9 +++++++++
game/fs.cc | 13 +++++++++++++
game/fs.hh | 3 +++
game/main.cc | 3 ++-
game/players.cc | 3 +--
5 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/data/performous.xml b/data/performous.xml
index 3760fa7..0183814 100644
--- a/data/performous.xml
+++ b/data/performous.xml
@@ -198,6 +198,15 @@
<long>Where to recursively look for songs.</long>
</locale>
</entry>
+ <entry name="system/path_share" type="string_list">
+ <stringvalue>~/.local/share</stringvalue>
+ <stringvalue>../share</stringvalue><!-- For Windows where the program is started in bin/ -->
+ <stringvalue>~/.performous/share</stringvalue>
+ <locale name="C">
+ <short>Data folders</short>
+ <long>Where Performous data are stored.</long>
+ </locale>
+ </entry>
<entry name="system/path_pictures" type="string_list">
<stringvalue>/usr/local/share/games/performous/pictures</stringvalue>
<stringvalue>/usr/share/games/performous/pictures</stringvalue>
diff --git a/game/fs.cc b/game/fs.cc
index f504fc1..82a5f93 100644
--- a/game/fs.cc
+++ b/game/fs.cc
@@ -49,6 +49,19 @@ std::string getDataPath(std::string const& filename) {
ConfigItem::StringList sd = config["system/path_data"].sl();
for (std::vector<std::string>::const_iterator it = sd.begin(); it != sd.end(); ++it) {
fs::path p = *it;
+ p = pathMangle(p);
+ if (fs::is_directory(p)) { data_dir = p.string(); break; }
+ }
+ return data_dir + "/" + filename;
+}
+
+std::string getSharePath(std::string const& filename) {
+ // Figure out theme folder (if theme name rather than path was given)
+ std::string data_dir;
+ ConfigItem::StringList sd = config["system/path_share"].sl();
+ for (std::vector<std::string>::const_iterator it = sd.begin(); it != sd.end(); ++it) {
+ fs::path p = *it;
+ p = pathMangle(p);
if (fs::is_directory(p)) { data_dir = p.string(); break; }
}
return data_dir + "/" + filename;
diff --git a/game/fs.hh b/game/fs.hh
index ea02bbe..6500baa 100644
--- a/game/fs.hh
+++ b/game/fs.hh
@@ -16,3 +16,6 @@ std::string getThemePath(std::string const& filename);
/** Get full path to a data file **/
std::string getDataPath(std::string const& filename);
+
+/** Get full path to a share file **/
+std::string getSharePath(std::string const& filename);
diff --git a/game/main.cc b/game/main.cc
index 4d80e8c..d8f5848 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -134,7 +134,8 @@ void mainLoop() {
Audio audio;
audioSetup(capture, audio);
Songs songs(songlist);
- Players players("players.xml"); // TODO: retrieve from configuration
+ 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 9eeb442..fa00013 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -17,12 +17,11 @@ Players::Players(std::string filename):
m_dirty(false),
cur()
{
- load();
m_filtered = m_players;
}
Players::~Players() {
- save();
+ try { save(); } catch (...) { std::cerr << "Could not save players to " << m_filename << std::endl; }
}
void Players::load() {
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:58
|
Module: performous
Branch: master
Commit: 3a3638414d016f922731b61d0d05ed9a77f69729
Author: Markus Raab <un...@ma...>
Date: Wed Jul 29 09:28:06 2009 +0200
Search for pictures in path_pictures
---
data/performous.xml | 10 ++++++++++
game/players.cc | 23 ++++++++++++++++++++++-
game/screen_players.cc | 8 ++++++--
3 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/data/performous.xml b/data/performous.xml
index 29dc585..8e894da 100644
--- a/data/performous.xml
+++ b/data/performous.xml
@@ -192,4 +192,14 @@
<long>Where to recursively look for songs.</long>
</locale>
</entry>
+ <entry name="system/path_pictures" type="string_list">
+ <stringvalue>/usr/local/share/games/performous/pictures</stringvalue>
+ <stringvalue>/usr/share/games/performous/pictures</stringvalue>
+ <stringvalue>../pictures/</stringvalue><!-- For Windows where the program is started in bin/ -->
+ <stringvalue>~/.performous/pictures/</stringvalue>
+ <locale name="C">
+ <short>Picture folders</short>
+ <long>Where to look for pictures of players.</long>
+ </locale>
+ </entry>
</performous>
diff --git a/game/players.cc b/game/players.cc
index 93512d4..9eeb442 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -1,6 +1,10 @@
#include "players.hh"
+#include "fs.hh"
+#include "configuration.hh"
+
#include <fstream>
+#include <iostream>
#include <boost/regex.hpp>
#include <libxml++/libxml++.h>
@@ -67,8 +71,25 @@ void Players::update() {
void Players::addPlayer (std::string const& name, std::string const& picture) {
PlayerItem pi;
pi.name = name;
- pi.path = "";
pi.picture = picture;
+ pi.path = "";
+
+ if (pi.picture != "") // no picture, so don't search path
+ {
+ ConfigItem::StringList const& sl = config["system/path_pictures"].sl();
+ typedef std::set<fs::path> dirs;
+ dirs d;
+ std::transform(sl.begin(), sl.end(), std::inserter(d, d.end()), pathMangle);
+
+ for (dirs::const_iterator it = d.begin(); it != d.end(); ++it) {
+ if (!fs::exists(*it)) continue; // as long as it does not exists
+ pi.path = it->file_string();
+ }
+
+ if (pi.path != "") std::cout << "Found " << pi.picture << " in " << pi.path << std::endl;
+ else std::cout << "Not found " << pi.picture << std::endl;
+ }
+
players_t::const_iterator it = std::find(m_players.begin(), m_players.end(), pi);
if (it != m_players.end()) return; // dont do anything, player exists
diff --git a/game/screen_players.cc b/game/screen_players.cc
index 7435d5f..0333213 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -160,8 +160,12 @@ void ScreenPlayers::draw() {
for (int i = -2; i < 5; ++i) {
PlayerItem player_display = m_players[baseidx + i];
if (baseidx + i < 0 || baseidx + i >= int(ss)) continue;
- Surface* cover = NULL;
- try { cover = &m_covers[player_display.path + player_display.picture]; } catch (std::exception const&) {}
+ Surface* cover = 0;
+ if (player_display.picture != "")
+ {
+ try { cover = &m_covers[player_display.path + "/" + player_display.picture]; }
+ catch (std::exception const&) {}
+ }
Surface& s = (cover ? *cover : *m_emptyCover);
double diff = (i == 0 ? (0.5 - fabs(shift)) * 0.07 : 0.0);
double y = 0.27 + 0.5 * diff;
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:57
|
Module: performous
Branch: master
Commit: c12838d7aa61dc4c5e1de5dbdd00f59e6e3f1b44
Author: Markus Raab <un...@ma...>
Date: Tue Jul 28 10:34:46 2009 +0200
Loading pictures works
---
game/players.cc | 21 ++++++++++++++++++---
game/players.hh | 10 +++++++---
game/screen_players.cc | 7 ++-----
3 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/game/players.cc b/game/players.cc
index 2ae321d..93512d4 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -29,7 +29,15 @@ void Players::load() {
{
xmlpp::Element& element = dynamic_cast<xmlpp::Element&>(**it);
xmlpp::Attribute* a = element.get_attribute("name");
- addPlayer(a->get_value());
+ xmlpp::NodeSet n2 = element.find("picture");
+ std::string picture;
+ if (!n2.empty()) // optional picture element
+ {
+ xmlpp::Element& element2 =dynamic_cast<xmlpp::Element&>(**n2.begin());
+ xmlpp::TextNode* tn = element2.get_child_text();
+ picture = tn->get_content();
+ }
+ addPlayer(a->get_value(), picture);
}
}
@@ -42,6 +50,11 @@ void Players::save() {
{
xmlpp::Element* player = players->add_child("player");
player->set_attribute("name", it->name);
+ if (it->picture != "")
+ {
+ xmlpp::Element* picture = player->add_child("picture");
+ picture->add_child_text(it->picture);
+ }
}
doc.write_to_file_formatted(m_filename, "UTF-8");
@@ -51,9 +64,11 @@ void Players::update() {
if (m_dirty) filter_internal();
}
-void Players::addPlayer (std::string const& name) {
+void Players::addPlayer (std::string const& name, std::string const& picture) {
PlayerItem pi;
pi.name = name;
+ pi.path = "";
+ pi.picture = picture;
players_t::const_iterator it = std::find(m_players.begin(), m_players.end(), pi);
if (it != m_players.end()) return; // dont do anything, player exists
@@ -104,7 +119,7 @@ int main(int argc, char** argv)
for (size_t i=0; i<p.size(); i++)
{
- std::cout << p[i].name << std::endl;
+ std::cout << p[i].name << " picture: " << p[i].picture << std::endl;
}
return 0;
diff --git a/game/players.hh b/game/players.hh
index e956828..924b13a 100644
--- a/game/players.hh
+++ b/game/players.hh
@@ -15,9 +15,10 @@
*/
struct PlayerItem {
std::string name; /// unique name, link to highscore
+ std::string path; /// a path to a picture shown
+ std::string picture; /// + the filename for it
/* Future ideas
std::string displayedName; /// artist name, short name, nick (can be changed)
- std::string picture; /// a path to a picture shown
std::map<std::string, int> scores; /// map between a Song and the highest score the Player achieved
*/
@@ -63,10 +64,13 @@ class Players: boost::noncopyable {
}
void save();
void update();
- void addPlayer (std::string const& name);
+ void addPlayer (std::string const& name, std::string const& picture = "");
/// const array access
- PlayerItem operator[](std::size_t pos) const { return m_filtered[pos]; }
+ PlayerItem operator[](std::size_t pos) const {
+ if (pos < m_filtered.size()) return m_filtered[pos];
+ else return PlayerItem();
+ }
/// number of songs
size_t size() const { return m_filtered.size(); };
/// true if empty
diff --git a/game/screen_players.cc b/game/screen_players.cc
index 872c0bf..7435d5f 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -158,13 +158,10 @@ void ScreenPlayers::draw() {
int baseidx = spos + 1.5; --baseidx; // Round correctly
double shift = spos - baseidx;
for (int i = -2; i < 5; ++i) {
+ PlayerItem player_display = m_players[baseidx + i];
if (baseidx + i < 0 || baseidx + i >= int(ss)) continue;
Surface* cover = NULL;
- /*
- Song& song_display = m_players[baseidx + i];
- // Fetch cover image from cache or try loading it
- if (!song_display.cover.empty()) try { cover = &m_covers[song_display.path + song_display.cover]; } catch (std::exception const&) {}
- */
+ try { cover = &m_covers[player_display.path + player_display.picture]; } catch (std::exception const&) {}
Surface& s = (cover ? *cover : *m_emptyCover);
double diff = (i == 0 ? (0.5 - fabs(shift)) * 0.07 : 0.0);
double y = 0.27 + 0.5 * diff;
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:56
|
Module: performous
Branch: master
Commit: a088841982b759be5b3cce3908759d35f7b0f2cc
Author: Markus Raab <un...@ma...>
Date: Wed Jul 29 08:44:44 2009 +0200
input of Player only if location (was) writeable
---
game/highscore.cc | 11 +++++++++++
game/highscore.hh | 6 ++++++
game/screen_sing.cc | 4 +++-
3 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/game/highscore.cc b/game/highscore.cc
index ebfdb84..a1420f8 100644
--- a/game/highscore.cc
+++ b/game/highscore.cc
@@ -113,6 +113,13 @@ void SongHiscore::save()
out << "E" << std::endl;
}
+bool SongHiscore::isWritable()
+{
+ std::ofstream out ((m_path + m_filename).c_str());
+
+ return out.is_open();
+}
+
void SongHiscore::getInfo (std::ostream & out)
{
for (size_t i=0; i<m_scores.size();i++)
@@ -150,6 +157,10 @@ int main()
{
try {
SongHiscore hi ("", "highscore.txt");
+
+ if (hi.isWritable()) std::cout << "Is writeable" << std::endl;
+ else std::cout << "Is not writeable" << std::endl;
+
hi.load();
int new_score = 9000;
if (hi.reachedNewHiscore(new_score))
diff --git a/game/highscore.hh b/game/highscore.hh
index 7e3642e..61a5183 100644
--- a/game/highscore.hh
+++ b/game/highscore.hh
@@ -52,6 +52,12 @@ class SongHiscore {
void load();
void save();
+ /**Check if file location is writable.
+ @return true if it is.
+ @return false if you can't write at the location where path points to.
+ */
+ bool isWritable();
+
void getInfo (std::ostream & os);
/**Check if you reached a new highscore.
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 920ea63..7accaea 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -72,7 +72,9 @@ void ScreenSing::activatePlayerScreen()
std::cerr << "high.sco:" << hi.line() << " " << hi.what() << std::endl;
}
- if (m_players.scores.empty() || !hi.reachedNewHiscore(m_players.scores.front()))
+ if (m_players.scores.empty()
+ || !hi.reachedNewHiscore(m_players.scores.front())
+ || !hi.isWritable())
{
// if no highscore reached..
sm->activateScreen("Songs");
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:55
|
Module: performous
Branch: master
Commit: e33e68d97aa189fc1ce77955a5454c82bf679ab8
Author: Markus Raab <un...@ma...>
Date: Mon Jul 27 16:58:35 2009 +0200
Player Database now in xml
---
game/.gitignore | 2 +-
game/main.cc | 2 +-
game/players.cc | 28 +++++++++++++++++-----------
game/screen_players.cc | 2 +-
4 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/game/.gitignore b/game/.gitignore
index 13ba250..deb27f7 100644
--- a/game/.gitignore
+++ b/game/.gitignore
@@ -3,4 +3,4 @@ Makefile
highscore
highscore.txt
players
-players.txt
+players.xml
diff --git a/game/main.cc b/game/main.cc
index 70944de..4d80e8c 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -134,7 +134,7 @@ void mainLoop() {
Audio audio;
audioSetup(capture, audio);
Songs songs(songlist);
- Players players("players.txt"); // TODO: retrieve from configuration
+ Players players("players.xml"); // TODO: retrieve from configuration
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 572d8f7..2ae321d 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -2,6 +2,7 @@
#include <fstream>
#include <boost/regex.hpp>
+#include <libxml++/libxml++.h>
Players::Players(std::string filename):
m_players(),
@@ -21,22 +22,29 @@ Players::~Players() {
}
void Players::load() {
- std::ifstream in (m_filename.c_str());
+ xmlpp::DomParser domParser(m_filename);
+ xmlpp::NodeSet n = domParser.get_document()->get_root_node()->find("/performous/players/player");
- std::string str;
- while (getline(in, str))
+ for (xmlpp::NodeSet::const_iterator it = n.begin(); it != n.end(); ++it)
{
- addPlayer(str);
+ xmlpp::Element& element = dynamic_cast<xmlpp::Element&>(**it);
+ xmlpp::Attribute* a = element.get_attribute("name");
+ addPlayer(a->get_value());
}
}
void Players::save() {
- std::ofstream out (m_filename.c_str());
+ xmlpp::Document doc;
+ xmlpp::Node* nodeRoot = doc.create_root_node("performous");
+ xmlpp::Element *players = nodeRoot->add_child("players");
for (players_t::const_iterator it = m_players.begin(); it!=m_players.end(); ++it)
{
- out << it->name << std::endl;
+ xmlpp::Element* player = players->add_child("player");
+ player->set_attribute("name", it->name);
}
+
+ doc.write_to_file_formatted(m_filename, "UTF-8");
}
void Players::update() {
@@ -91,16 +99,14 @@ void Players::filter_internal() {
int main(int argc, char** argv)
{
- if (argc != 2) return 1;
-
- std::string filter = argv[1];
- Players p("players.txt");
+ Players p("players.xml");
p.addPlayer("hubert");
- p.setFilter(filter);
for (size_t i=0; i<p.size(); i++)
{
std::cout << p[i].name << std::endl;
}
+
+ return 0;
}
*/
diff --git a/game/screen_players.cc b/game/screen_players.cc
index 4b58452..872c0bf 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -137,7 +137,7 @@ void ScreenPlayers::draw() {
// Format the song information text
if (m_search.text.empty()) {
oss_song << "No players found!";
- oss_order << "Check players.txt in current\n";
+ oss_order << "Check players.xml in current\n"; // TODO retrieve from configuration
oss_order << "directory for players";
} else {
oss_song << "Press enter to create player!";
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:53
|
Module: performous
Branch: master
Commit: aa80c8f0c28e636335883214f15a072efe58cd51
Author: Markus Raab <un...@ma...>
Date: Tue Jul 28 08:32:29 2009 +0200
activate PlayersScreen also on Timeout
---
game/screen_sing.cc | 66 +++++++++++++++++++++++++++++---------------------
game/screen_sing.hh | 1 +
2 files changed, 39 insertions(+), 28 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 96f5093..920ea63 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -59,40 +59,49 @@ void ScreenSing::exit() {
theme.reset();
}
+void ScreenSing::activatePlayerScreen()
+{
+ ScreenManager* sm = ScreenManager::getSingletonPtr();
+
+ // TODO: multiple loading...
+ // TODO: make it possible to switch of highscore through configuration
+ SongHiscore hi(m_song->path, "High.sco");
+ try {
+ hi.load();
+ } catch (HiscoreException const& hi) {
+ std::cerr << "high.sco:" << hi.line() << " " << hi.what() << std::endl;
+ }
+
+ if (m_players.scores.empty() || !hi.reachedNewHiscore(m_players.scores.front()))
+ {
+ // if no highscore reached..
+ sm->activateScreen("Songs");
+ return;
+ }
+
+ // Score window visible -> Enter quits to Players Screen
+ Screen* s = sm->getScreen("Players");
+ ScreenPlayers* ss = dynamic_cast<ScreenPlayers*> (s);
+ assert(ss);
+ ss->setSong(m_song);
+ sm->activateScreen("Players");
+}
+
void ScreenSing::manageEvent(SDL_Event event) {
if (event.type == SDL_KEYDOWN) {
double time = m_audio.getPosition();
Song::Status status = m_song->status(time);
m_quitTimer.setValue(QUIT_TIMEOUT);
bool seekback = false;
- ScreenManager* sm = ScreenManager::getSingletonPtr();
int key = event.key.keysym.sym;
- if (key == SDLK_ESCAPE || key == SDLK_q) sm->activateScreen("Songs");
+ if (key == SDLK_ESCAPE || key == SDLK_q) {
+ ScreenManager* sm = ScreenManager::getSingletonPtr();
+ sm->activateScreen("Songs");
+ }
else if (key == SDLK_RETURN) {
if (m_score_window.get())
{
- // TODO: multiple loading...
- // TODO: make it possible to switch of highscore through configuration
- SongHiscore hi(m_song->path, "High.sco");
- try {
- hi.load();
- } catch (HiscoreException const& hi) {
- std::cerr << "high.sco:" << hi.line() << " " << hi.what() << std::endl;
- }
-
- if (m_players.scores.empty() || !hi.reachedNewHiscore(m_players.scores.front()))
- {
- // if no highscore reached..
- sm->activateScreen("Songs");
- return;
- }
-
- // Score window visible -> Enter quits to Players Screen
- Screen* s = sm->getScreen("Players");
- ScreenPlayers* ss = dynamic_cast<ScreenPlayers*> (s);
- assert(ss);
- ss->setSong(m_song);
- sm->activateScreen("Players");
+ activatePlayerScreen();
return;
}
else if (status == Song::FINISHED) m_score_window.reset(new ScoreWindow(*m_engine, m_players)); // Song finished, but no score window -> show it
@@ -193,13 +202,14 @@ void ScreenSing::draw() {
theme->timer.draw(statustxt);
}
- ScreenManager* sm = ScreenManager::getSingletonPtr();
-
if (config["game/karaoke_mode"].b()) {
- if (!m_audio.isPlaying()) sm->activateScreen("Songs");
+ if (!m_audio.isPlaying()) {
+ ScreenManager* sm = ScreenManager::getSingletonPtr();
+ sm->activateScreen("Songs");
+ }
} else {
if (m_score_window.get()) {
- if (m_quitTimer.get() == 0.0 && !m_audio.isPaused()) { sm->activateScreen("Songs"); return; }
+ if (m_quitTimer.get() == 0.0 && !m_audio.isPaused()) { activatePlayerScreen(); return; }
m_score_window->draw();
}
else if (!m_audio.isPlaying() || (status == Song::FINISHED && m_audio.getLength() - time < 3.0)) {
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index a096e63..bf8317d 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -54,6 +54,7 @@ class ScreenSing: public Screen {
private:
void drawScores();
+ void activatePlayerScreen();
Audio& m_audio;
Capture& m_capture;
Players& m_players;
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:51
|
Module: performous
Branch: master
Commit: 4b11fda42f55715aae0624391aa6a41da16e2712
Author: Markus Raab <un...@ma...>
Date: Mon Jul 27 17:21:10 2009 +0200
Segfault when creating player
---
game/players.hh | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/game/players.hh b/game/players.hh
index 5937926..e956828 100644
--- a/game/players.hh
+++ b/game/players.hh
@@ -88,7 +88,10 @@ class Players: boost::noncopyable {
/// sets margins for animation
void setAnimMargins(double left, double right) { math_cover.setMargins(left, right); }
/// @return current PlayerItem (the copy is very cheap at the moment)
- PlayerItem current() const { return m_filtered[math_cover.getTarget()]; }
+ PlayerItem current() const {
+ if (math_cover.getTarget() < m_filtered.size()) return m_filtered[math_cover.getTarget()];
+ else return PlayerItem();
+ }
/// filters playerlist by regular expression
void setFilter(std::string const& regex);
private:
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:51
|
Module: performous Branch: master Commit: 98aba3e0c032cc52a56d9affbf736be4a2891df9 Author: Markus Raab <un...@ma...> Date: Mon Jul 27 15:37:50 2009 +0200 Highscore renamed to Hiscore --- game/highscore.cc | 68 +++++++++++++++++++++++----------------------- game/highscore.hh | 26 +++++++++--------- game/main.cc | 2 +- game/screen_highscore.cc | 20 +++++++------- game/screen_highscore.hh | 6 ++-- game/screen_players.cc | 10 +++--- game/screen_players.hh | 2 +- game/screen_sing.cc | 6 ++-- game/screen_songs.cc | 6 ++-- 9 files changed, 73 insertions(+), 73 deletions(-) |
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:50
|
Module: performous
Branch: master
Commit: 1d9cf906230165eaf353c25aeadcd7ccf5ed6753
Author: Markus Raab <un...@ma...>
Date: Mon Jul 27 15:30:21 2009 +0200
more doc
---
game/highscore.hh | 18 +++++++++++++++++-
game/screen_players.cc | 3 ++-
game/screen_sing.cc | 1 +
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/game/highscore.hh b/game/highscore.hh
index 7f186da..6d1c2ad 100644
--- a/game/highscore.hh
+++ b/game/highscore.hh
@@ -32,7 +32,18 @@ struct HighScoreItem {
}
};
-/**HighScore loads and saves a list of HighScoreItems.*/
+/**HighScore loads and saves a list of HighScoreItems.
+
+ Format of highscore is compatible with Ultrastar.
+
+ Name of File: High.sco
+ @code
+#PLAYER0:name
+#SCORE0:1234
+ @endcode
+ Then the same thing for PLAYER/SCORE with other numbers up to 9.
+ Finally, you need to have a line that says only "E".
+ */
class HighScore {
public:
HighScore (std::string const& path_, std::string const& filename_);
@@ -44,6 +55,11 @@ class HighScore {
void getInfo (std::ostream & os);
/**Check if you reached a new highscore.
+
+ You must be in TOP 3 to enter the highscore list.
+ This is because it will take forever to fill all 9.
+ And people refuse to enter their names if they are not close to the top.
+
@param score is a value between 0 and 10000
values below 500 will lead to returning false
@return true if the score make it into the top.
diff --git a/game/screen_players.cc b/game/screen_players.cc
index fb424a9..6281c0c 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -88,7 +88,8 @@ void ScreenPlayers::manageEvent(SDL_Event event) {
} else {
m_search.text.clear();
m_players.setFilter("");
- // enter the next highscore
+ // add all players which reach highscore because if score is very near or same it might be
+ // frustrating for second one that he cannot enter, so better go for next one...
}
}
// The rest are only available when there are songs available
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 5614597..765ef96 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -72,6 +72,7 @@ void ScreenSing::manageEvent(SDL_Event event) {
if (m_score_window.get())
{
// TODO: multiple loading...
+ // TODO: make it possible to switch of highscore through configuration
HighScore hi(m_song->path, "High.sco");
try {
hi.load();
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:48
|
Module: performous
Branch: master
Commit: e000615e428522783161eb52566b7fbb47505d24
Author: Markus Raab <un...@ma...>
Date: Mon Jul 27 15:49:37 2009 +0200
Restore Selection for Players
---
game/players.cc | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/game/players.cc b/game/players.cc
index 88adacf..572d8f7 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -62,6 +62,7 @@ void Players::setFilter(std::string const& val) {
void Players::filter_internal() {
m_dirty = false;
+ PlayerItem selection = current();
try {
players_t filtered;
@@ -73,7 +74,15 @@ void Players::filter_internal() {
players_t(m_players.begin(), m_players.end()).swap(m_filtered); // Invalid regex => copy everything
}
math_cover.reset();
- // TODO restore selection
+
+ // Restore old selection
+ int pos = 0;
+ if (selection.name != "") {
+ players_t::iterator it = std::find(m_filtered.begin(), m_filtered.end(), selection);
+ math_cover.setTarget(0, 0);
+ if (it != m_filtered.end()) pos = it - m_filtered.begin();
+ }
+ math_cover.setTarget(pos, size());
}
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:43
|
Module: performous
Branch: master
Commit: 0f6d7e9750340306eb95de790884a7de1b7b47ad
Author: Markus Raab <un...@ma...>
Date: Sat Jul 25 12:28:50 2009 +0200
draw scores in Players screen
---
game/screen_players.cc | 35 ++++++++++++++++++++++++++++++++++-
game/screen_players.hh | 3 +++
2 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/game/screen_players.cc b/game/screen_players.cc
index 4b8a59e..55d05da 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -21,6 +21,11 @@ void ScreenPlayers::enter() {
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()));
+ m_score_text[1].reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
+ m_score_text[2].reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
+ m_score_text[3].reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
+ m_player_icon.reset(new Surface(getThemePath("sing_pbox.svg")));
theme.reset(new ThemeSongs());
m_emptyCover.reset(new Surface(getThemePath("no_cover.svg"))); // TODO use persons head
m_search.text.clear();
@@ -29,6 +34,12 @@ void ScreenPlayers::enter() {
}
void ScreenPlayers::exit() {
+ m_player_icon.reset();
+ m_score_text[0].reset();
+ m_score_text[1].reset();
+ m_score_text[2].reset();
+ m_score_text[3].reset();
+
m_covers.clear();
m_emptyCover.reset();
theme.reset();
@@ -91,6 +102,27 @@ else if (key == SDLK_ESCAPE) {
else if (key == SDLK_PAGEDOWN) m_players.advance(10);
}
+/**Draw the scores in the bottom*/
+void ScreenPlayers::drawScores() {
+ // Score display
+ {
+ unsigned int i = 0;
+ for (std::list<Player>::const_iterator p = m_players.cur.begin(); p != m_players.cur.end(); ++p, ++i) {
+ float act = p->activity();
+ if (act == 0.0f) continue;
+ glColor4f(p->m_color.r, p->m_color.g, p->m_color.b,act);
+ m_player_icon->dimensions.left(-0.5 + 0.01 + 0.25 * i).fixedWidth(0.075)
+ .screenBottom(-0.025);
+ m_player_icon->draw();
+ m_score_text[i%4]->render((boost::format("%04d") % p->getScore()).str());
+ m_score_text[i%4]->dimensions().middle(-0.350 + 0.01 + 0.25 * i).fixedHeight(0.075)
+ .screenBottom(-0.025);
+ m_score_text[i%4]->draw();
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+ }
+ }
+}
+
void ScreenPlayers::draw() {
m_players.update(); // Poll for new players
double length = m_audio.getLength();
@@ -117,7 +149,7 @@ void ScreenPlayers::draw() {
oss_song << "You reached " << m_players.scores.front() << " points!\n";
oss_order << "Name: " << m_players.current().name << '\n'
<< "Search Text: "
- << (m_search.text.empty() ? std::string("new player") : m_search.text)
+ << (m_search.text.empty() ? std::string("please enter") : m_search.text)
<< '\n';
oss_order << "(" << m_players.currentId() + 1 << "/" << m_players.size() << ")";
double spos = m_players.currentPosition(); // This needs to be polled to run the animation
@@ -166,5 +198,6 @@ void ScreenPlayers::draw() {
} else if (!m_audio.isPaused() && m_playTimer.get() > IDLE_TIMEOUT) { // Switch if song hasn't changed for IDLE_TIMEOUT seconds
if (!m_search.text.empty()) { m_search.text.clear(); m_players.setFilter(m_search.text); }
}
+ drawScores();
}
diff --git a/game/screen_players.hh b/game/screen_players.hh
index 86e68b5..51ad72d 100644
--- a/game/screen_players.hh
+++ b/game/screen_players.hh
@@ -23,6 +23,7 @@ class ScreenPlayers : public Screen {
void exit();
void manageEvent(SDL_Event event);
void draw();
+ void drawScores();
void setSong (boost::shared_ptr<Song> song_)
{
@@ -43,4 +44,6 @@ class ScreenPlayers : public Screen {
TextInput m_search;
boost::scoped_ptr<Surface> m_emptyCover;
Cachemap<std::string, Surface> m_covers;
+ boost::scoped_ptr<Surface> m_player_icon;
+ boost::scoped_ptr<SvgTxtThemeSimple> m_score_text[4];
};
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:43
|
Module: performous
Branch: master
Commit: 01b0b5df91a4bd4b472b402a618970f12ada515a
Author: Markus Raab <un...@ma...>
Date: Mon Jul 27 09:01:09 2009 +0200
Adding new Player works
resetting Input correctly
---
game/players.cc | 10 ----------
game/screen_players.cc | 36 +++++++++++++++++-------------------
2 files changed, 17 insertions(+), 29 deletions(-)
diff --git a/game/players.cc b/game/players.cc
index ab2360e..88adacf 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -60,19 +60,9 @@ void Players::setFilter(std::string const& val) {
filter_internal();
}
-#include <iostream> //TODO remove
-
void Players::filter_internal() {
m_dirty = false;
- if (m_filter == "")
- {
- std::cout << "empty filter" << std::endl; //TODO remove
- // without filter get all names
- m_filtered = m_players;
- return;
- }
-
try {
players_t filtered;
for (players_t::const_iterator it = m_players.begin(); it != m_players.end(); ++it) {
diff --git a/game/screen_players.cc b/game/screen_players.cc
index 55d05da..fb424a9 100644
--- a/game/screen_players.cc
+++ b/game/screen_players.cc
@@ -57,32 +57,27 @@ void ScreenPlayers::exit() {
}
void ScreenPlayers::manageEvent(SDL_Event event) {
-ScreenManager* sm = ScreenManager::getSingletonPtr();
-if (event.type != SDL_KEYDOWN) return;
-SDL_keysym keysym = event.key.keysym;
-int key = keysym.sym;
-SDLMod mod = event.key.keysym.mod;
-
-if (key == SDLK_r && mod & KMOD_CTRL) { m_players.reload(); m_players.setFilter(m_search.text); }
-if (m_search.process(keysym)) m_players.setFilter(m_search.text);
-else if (key == SDLK_ESCAPE) {
- if (m_search.text.empty()) sm->activateScreen("Songs");
- else { m_search.text.clear(); m_players.setFilter(m_search.text); }
+ ScreenManager* sm = ScreenManager::getSingletonPtr();
+ if (event.type != SDL_KEYDOWN) return;
+ SDL_keysym keysym = event.key.keysym;
+ int key = keysym.sym;
+ SDLMod mod = event.key.keysym.mod;
+
+ if (key == SDLK_r && mod & KMOD_CTRL) { m_players.reload(); m_players.setFilter(m_search.text); }
+ if (m_search.process(keysym)) m_players.setFilter(m_search.text);
+ else if (key == SDLK_ESCAPE) {
+ if (m_search.text.empty()) sm->activateScreen("Songs");
+ else { m_search.text.clear(); m_players.setFilter(m_search.text); }
}
- // The rest are only available when there are songs available
- else if (m_players.empty()) return;
- else if (key == SDLK_SPACE || (key == SDLK_PAUSE || (key == SDLK_p && mod & KMOD_CTRL))) m_audio.togglePause();
else if (key == SDLK_RETURN)
{
if (m_players.empty())
{
m_players.addPlayer(m_search.text);
m_players.setFilter(m_search.text);
+ m_players.update();
// the current player is the new created one
}
- std::cout << "add new highscore " << m_players.scores.front()
- << " name: " << m_players.current().name
- << std::endl;
m_highscore->addNewHighscore(m_players.current().name, m_players.scores.front());
m_players.scores.pop_front();
@@ -91,11 +86,14 @@ else if (key == SDLK_ESCAPE) {
// no more highscore, we are now finished
sm->activateScreen("Songs");
} else {
- std::cout << "enter the next highscore" << std::endl;
m_search.text.clear();
+ m_players.setFilter("");
// enter the next highscore
}
}
+ // The rest are only available when there are songs available
+ else if (m_players.empty()) return;
+ else if (key == SDLK_SPACE || (key == SDLK_PAUSE || (key == SDLK_p && mod & KMOD_CTRL))) m_audio.togglePause();
else if (key == SDLK_LEFT) m_players.advance(-1);
else if (key == SDLK_RIGHT) m_players.advance(1);
else if (key == SDLK_PAGEUP) m_players.advance(-10);
@@ -147,11 +145,11 @@ void ScreenPlayers::draw() {
} else {
// Format the player information text
oss_song << "You reached " << m_players.scores.front() << " points!\n";
- oss_order << "Name: " << m_players.current().name << '\n'
+ oss_order << "Please enter your Name!\n"
+ << "Name: " << m_players.current().name << '\n'
<< "Search Text: "
<< (m_search.text.empty() ? std::string("please enter") : m_search.text)
<< '\n';
- oss_order << "(" << m_players.currentId() + 1 << "/" << m_players.size() << ")";
double spos = m_players.currentPosition(); // This needs to be polled to run the animation
// Draw the covers
|
|
From: Markus R. <god...@us...> - 2009-07-29 15:35:42
|
Module: performous
Branch: master
Commit: 6b162bf37606b759910a7be814a470c611005e3f
Author: Markus Raab <un...@ma...>
Date: Sat Jul 25 15:53:57 2009 +0200
Try for Party...
END shows highscore...
---
game/highscore.cc | 15 +++++
game/highscore.hh | 4 +
game/main.cc | 2 +
game/screen_highscore.cc | 139 ++++++++++++++++++++++++++++++++++++++++++++++
game/screen_highscore.hh | 49 ++++++++++++++++
game/screen_songs.cc | 10 +++
6 files changed, 219 insertions(+), 0 deletions(-)
diff --git a/game/highscore.cc b/game/highscore.cc
index 17768f0..e799fd7 100644
--- a/game/highscore.cc
+++ b/game/highscore.cc
@@ -113,6 +113,21 @@ void HighScore::save()
out << "E" << std::endl;
}
+void HighScore::getInfo (std::ostream & out)
+{
+ for (size_t i=0; i<m_scores.size();i++)
+ {
+ if (m_scores[i].score <= 0) break; // maybe change to 500?
+
+ try {
+ out << i+1 << ".\t" << m_scores[i].name
+ << "\t" << m_scores[i].score << std::endl;
+ } catch (std::ofstream::failure const&) {
+ throw HighScoreException("Unexpected I/O error", i);
+ }
+ }
+}
+
void HighScore::addNewHighscore(std::string name, int score)
{
// do not allow invalid name
diff --git a/game/highscore.hh b/game/highscore.hh
index bed7ab8..7f186da 100644
--- a/game/highscore.hh
+++ b/game/highscore.hh
@@ -4,6 +4,8 @@
#include <vector>
#include <stdexcept>
+#include <ostream>
+
/**Exception which will be thrown when loading or
saving a HighScore fails.*/
struct HighScoreException: public std::runtime_error {
@@ -39,6 +41,8 @@ class HighScore {
void load();
void save();
+ void getInfo (std::ostream & os);
+
/**Check if you reached a new highscore.
@param score is a value between 0 and 10000
values below 500 will lead to returning false
diff --git a/game/main.cc b/game/main.cc
index dd7f5be..3a04405 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -7,6 +7,7 @@
#include "screen_practice.hh"
#include "screen_configuration.hh"
#include "screen_players.hh"
+#include "screen_highscore.hh"
#include "video_driver.hh"
#include "xtime.hh"
#include <boost/format.hpp>
@@ -142,6 +143,7 @@ void mainLoop() {
sm.addScreen(new ScreenPractice("Practice", audio, capture));
sm.addScreen(new ScreenConfiguration("Configuration", audio));
sm.addScreen(new ScreenPlayers("Players", audio, players));
+ sm.addScreen(new ScreenHighscore("Highscore", audio, players));
sm.activateScreen("Intro");
// Main loop
boost::xtime time = now();
diff --git a/game/screen_highscore.cc b/game/screen_highscore.cc
new file mode 100644
index 0000000..bc51118
--- /dev/null
+++ b/game/screen_highscore.cc
@@ -0,0 +1,139 @@
+#include "screen_highscore.hh"
+#include "util.hh"
+#include "xtime.hh"
+#include <iostream>
+#include <sstream>
+
+static const double IDLE_TIMEOUT = 45.0; // seconds
+
+ScreenHighscore::ScreenHighscore(std::string const& name, Audio& audio, Players& players):
+ Screen(name), m_audio(audio), m_players(players), m_covers(20)
+{
+ m_players.setAnimMargins(5.0, 5.0);
+ m_playTimer.setTarget(getInf()); // Using this as a simple timer counting seconds
+}
+
+void ScreenHighscore::enter() {
+ m_highscore.reset(new HighScore(m_song->path, "High.sco"));
+ try {
+ m_highscore->load();
+ } catch (HighScoreException const& hi) {
+ 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()));
+ m_score_text[1].reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
+ m_score_text[2].reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
+ m_score_text[3].reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
+ m_player_icon.reset(new Surface(getThemePath("sing_pbox.svg")));
+ theme.reset(new ThemeSongs());
+ m_emptyCover.reset(new Surface(getThemePath("no_cover.svg"))); // TODO use persons head
+ m_search.text.clear();
+ m_players.setFilter(m_search.text);
+ m_audio.fadeout();
+}
+
+void ScreenHighscore::exit() {
+ m_player_icon.reset();
+ m_score_text[0].reset();
+ m_score_text[1].reset();
+ m_score_text[2].reset();
+ m_score_text[3].reset();
+
+ m_covers.clear();
+ m_emptyCover.reset();
+ theme.reset();
+ m_video.reset();
+ m_songbg.reset();
+ m_playing.clear();
+ m_playReq.clear();
+
+ try {
+ m_highscore->save();
+ } catch (HighScoreException const& hi) {
+ std::cerr << "high.sco:" << hi.line() << " " << hi.what() << std::endl;
+ }
+ m_highscore.reset();
+}
+
+void ScreenHighscore::manageEvent(SDL_Event event) {
+ ScreenManager* sm = ScreenManager::getSingletonPtr();
+ if (event.type != SDL_KEYDOWN) return;
+ SDL_keysym keysym = event.key.keysym;
+ int key = keysym.sym;
+ SDLMod mod = event.key.keysym.mod;
+
+ if (key == SDLK_r && mod & KMOD_CTRL) { m_players.reload(); m_players.setFilter(m_search.text); }
+ if (m_search.process(keysym)) m_players.setFilter(m_search.text);
+ else if (key == SDLK_ESCAPE) {
+ if (m_search.text.empty()) sm->activateScreen("Songs");
+ else { m_search.text.clear(); m_players.setFilter(m_search.text); }
+ }
+ // The rest are only available when there are songs available
+ else if (m_players.empty()) return;
+ else if (key == SDLK_SPACE || (key == SDLK_PAUSE || (key == SDLK_p && mod & KMOD_CTRL))) m_audio.togglePause();
+ else if (key == SDLK_RETURN)
+ {
+ sm->activateScreen("Songs");
+ }
+ else if (key == SDLK_LEFT) m_players.advance(-1);
+ else if (key == SDLK_RIGHT) m_players.advance(1);
+ else if (key == SDLK_PAGEUP) m_players.advance(-10);
+ else if (key == SDLK_PAGEDOWN) m_players.advance(10);
+}
+
+/**Draw the scores in the bottom*/
+void ScreenHighscore::drawScores() {
+ // Score display
+ {
+ unsigned int i = 0;
+ for (std::list<Player>::const_iterator p = m_players.cur.begin(); p != m_players.cur.end(); ++p, ++i) {
+ float act = p->activity();
+ if (act == 0.0f) continue;
+ glColor4f(p->m_color.r, p->m_color.g, p->m_color.b,act);
+ m_player_icon->dimensions.left(-0.5 + 0.01 + 0.25 * i).fixedWidth(0.075)
+ .screenBottom(-0.025);
+ m_player_icon->draw();
+ m_score_text[i%4]->render((boost::format("%04d") % p->getScore()).str());
+ m_score_text[i%4]->dimensions().middle(-0.350 + 0.01 + 0.25 * i).fixedHeight(0.075)
+ .screenBottom(-0.025);
+ m_score_text[i%4]->draw();
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+ }
+ }
+}
+
+void ScreenHighscore::draw() {
+ m_players.update(); // Poll for new players
+ double length = m_audio.getLength();
+ double time = clamp(m_audio.getPosition() - config["audio/video_delay"].f(), 0.0, length);
+ if (m_songbg.get()) m_songbg->draw();
+ if (m_video.get()) m_video->render(time);
+ theme->bg.draw();
+ std::string music, songbg, video;
+ double videoGap = 0.0;
+ std::ostringstream oss_song, oss_order;
+
+ // Format the player information text
+ oss_song << "Highscore for " << m_song->title << "!\n";
+
+ m_highscore->getInfo (oss_order);
+
+ // Draw song and order texts
+ theme->song.draw(oss_song.str());
+ theme->order.draw(oss_order.str());
+
+ // Schedule playback change if the chosen song has changed
+ if (music != m_playReq) { m_playReq = music; m_playTimer.setValue(0.0); }
+ // Play/stop preview playback (if it is the time)
+ if (music != m_playing && m_playTimer.get() > 0.4) {
+ m_songbg.reset(); m_video.reset();
+ if (music.empty()) m_audio.fadeout(); else m_audio.playPreview(music, 30.0);
+ if (!songbg.empty()) try { m_songbg.reset(new Surface(songbg)); } catch (std::exception const&) {}
+ if (!video.empty() && config["graphic/video"].b()) m_video.reset(new Video(video, videoGap));
+ m_playing = music;
+ } else if (!m_audio.isPaused() && m_playTimer.get() > IDLE_TIMEOUT) { // Switch if song hasn't changed for IDLE_TIMEOUT seconds
+ if (!m_search.text.empty()) { m_search.text.clear(); m_players.setFilter(m_search.text); }
+ }
+}
+
diff --git a/game/screen_highscore.hh b/game/screen_highscore.hh
new file mode 100644
index 0000000..60f29ca
--- /dev/null
+++ b/game/screen_highscore.hh
@@ -0,0 +1,49 @@
+#pragma once
+
+#include <boost/scoped_ptr.hpp>
+#include "animvalue.hh"
+#include "cachemap.hh"
+#include "opengl_text.hh"
+#include "screen.hh"
+#include "surface.hh"
+#include "textinput.hh"
+#include "theme.hh"
+#include "video.hh"
+#include "players.hh"
+#include "highscore.hh"
+
+class CAudio;
+
+/// song chooser screen
+class ScreenHighscore : public Screen {
+ public:
+ /// constructor
+ ScreenHighscore(std::string const& name, Audio& audio, Players& players);
+ void enter();
+ void exit();
+ void manageEvent(SDL_Event event);
+ void draw();
+ void drawScores();
+
+ void setSong (boost::shared_ptr<Song> song_)
+ {
+ m_song = song_;
+ }
+
+ private:
+ Audio& m_audio;
+ Players& m_players;
+ boost::shared_ptr<Song> m_song; /// Pointer to the current song
+ boost::scoped_ptr<HighScore> m_highscore;
+ boost::scoped_ptr<Surface> m_songbg;
+ boost::scoped_ptr<Video> m_video;
+ boost::scoped_ptr<ThemeSongs> theme;
+ std::string m_playing;
+ std::string m_playReq;
+ AnimValue m_playTimer;
+ TextInput m_search;
+ boost::scoped_ptr<Surface> m_emptyCover;
+ Cachemap<std::string, Surface> m_covers;
+ boost::scoped_ptr<Surface> m_player_icon;
+ boost::scoped_ptr<SvgTxtThemeSimple> m_score_text[4];
+};
diff --git a/game/screen_songs.cc b/game/screen_songs.cc
index 63917bc..c60b357 100644
--- a/game/screen_songs.cc
+++ b/game/screen_songs.cc
@@ -1,5 +1,6 @@
#include "screen_songs.hh"
#include "screen_sing.hh"
+#include "screen_highscore.hh"
#include "configuration.hh"
#include "util.hh"
#include "xtime.hh"
@@ -50,6 +51,15 @@ void ScreenSongs::manageSharedKey(int key, SDLMod mod)
}
else if (key == SDLK_LEFT) m_songs.advance(-1);
else if (key == SDLK_RIGHT) m_songs.advance(1);
+ else if (key == SDLK_END)
+ {
+ ScreenManager* sm = ScreenManager::getSingletonPtr();
+ Screen* s = sm->getScreen("Highscore");
+ ScreenHighscore* ss = dynamic_cast<ScreenHighscore*> (s);
+ assert(ss);
+ ss->setSong(m_songs.currentPtr());
+ sm->activateScreen("Highscore");
+ }
}
void ScreenSongs::manageEvent(SDL_Event event) {
|