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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:42
|
Module: performous
Branch: dance
Commit: be4b8ba5d506b2317bcb82a162dba8d67d96921f
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Nov 13 01:26:37 2009 +0200
Fix OSX libpath
---
libs/libda/src/CMakeLists.txt | 2 +-
libs/plugin++/CMakeLists.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/libda/src/CMakeLists.txt b/libs/libda/src/CMakeLists.txt
index ddfbf8a..13e18b3 100644
--- a/libs/libda/src/CMakeLists.txt
+++ b/libs/libda/src/CMakeLists.txt
@@ -7,5 +7,5 @@ find_package(Boost 1.34 REQUIRED COMPONENTS thread filesystem)
include_directories(${Boost_INCLUDE_DIRS})
add_library(da SHARED audio.cpp)
target_link_libraries(da plugin++ ${Boost_LIBRARIES})
-set_target_properties(da PROPERTIES INSTALL_NAME_DIR @rpath/lib)
+set_target_properties(da PROPERTIES INSTALL_NAME_DIR @rpath)
install(TARGETS da DESTINATION lib${LIB_SUFFIX})
diff --git a/libs/plugin++/CMakeLists.txt b/libs/plugin++/CMakeLists.txt
index 7b84fcd..b85f1a3 100644
--- a/libs/plugin++/CMakeLists.txt
+++ b/libs/plugin++/CMakeLists.txt
@@ -19,7 +19,7 @@ if(NOT WIN32)
target_link_libraries(plugin++ dl)
endif()
-set_target_properties(plugin++ PROPERTIES INSTALL_NAME_DIR @rpath/lib)
+set_target_properties(plugin++ PROPERTIES INSTALL_NAME_DIR @rpath)
install(TARGETS plugin++ DESTINATION lib${LIB_SUFFIX})
FILE(GLOB HEADER_FILES "include/plugin++/*")
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:40
|
Module: performous
Branch: dance
Commit: 9ca9f60972693603d9b196d511adc98c957f4968
Author: Tapio Vierros <tap...@gm...>
Date: Thu Nov 12 23:43:14 2009 +0200
Only warn about overlapping notes in TXT file.
---
game/songparser-txt.cc | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/game/songparser-txt.cc b/game/songparser-txt.cc
index 9ba1c67..e2d32fa 100644
--- a/game/songparser-txt.cc
+++ b/game/songparser-txt.cc
@@ -134,7 +134,12 @@ bool SongParser::txtParseNote(std::string line) {
}
// Can we just make the previous note shorter?
if (p.begin <= n.begin) p.end = n.begin;
- else throw std::runtime_error("Note overlaps with earlier notes");
+ else { // Nothing to do, warn and skip
+ std::ostringstream oss;
+ oss << "WARNING: Skipping overlapping note in " << m_song.path << m_song.filename << std::endl;
+ std::cerr << oss.str(); // More likely to be atomic when written as one string
+ return true;
+ }
} else throw std::runtime_error("The first note has negative timestamp");
}
double prevtime = m_prevtime;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:39
|
Module: performous
Branch: dance
Commit: 83a58d79dbad0294714ea8c03e292c78e900cf76
Author: Tapio Vierros <tap...@gm...>
Date: Thu Nov 12 23:17:22 2009 +0200
Reversed notes in midi file no longer produce error, only warning with count.
(A song could have perfectly fine tracks and a couple of missing notes shouldn't be fatal.)
---
game/songparser-ini.cc | 10 +++++++++-
game/songparser.hh | 2 +-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index 5184e83..1e79706 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -86,6 +86,7 @@ void SongParser::iniParse() {
}
MidiFileParser midi(s.path + "/" + midifilename);
+ int reversedNoteCount = 0;
for (uint32_t ts = 0, end = midi.ts_last + midi.division; ts < end; ts += midi.division) s.beats.push_back(midi.get_seconds(ts));
for (MidiFileParser::Tracks::const_iterator it = midi.tracks.begin(); it != midi.tracks.end(); ++it) {
// Figure out the track name
@@ -113,7 +114,7 @@ void SongParser::iniParse() {
double beg = midi.get_seconds(it3->begin);
double end = midi.get_seconds(it3->end);
if (end == 0) continue; // Note with no ending
- if (beg > end) throw std::runtime_error("Reversed notes");
+ if (beg > end) { reversedNoteCount++; continue; } // Reversed note
if (drums) end = beg;
dur.push_back(Duration(beg, end));
durCount++;
@@ -196,6 +197,13 @@ void SongParser::iniParse() {
}
if (!s.notes.empty()) break;
}
+ if (reversedNoteCount > 0) {
+ std::ostringstream oss;
+ oss << "WARNING: Skipping " << reversedNoteCount << " reversed note(s) in ";
+ oss << s.path << midifilename << std::endl;
+ std::cerr << oss.str(); // More likely to be atomic when written as one string
+ }
+
/*if (s.notes.empty()) {
Note n;
n.begin = 30.0;
diff --git a/game/songparser.hh b/game/songparser.hh
index d17b147..da15550 100644
--- a/game/songparser.hh
+++ b/game/songparser.hh
@@ -50,7 +50,7 @@ class SongParser {
if (m_song.cover.empty() || (m_song.background.empty() && m_song.video.empty())) {
boost::regex coverfile("((cover|album|label|\\[co\\])\\.(png|jpeg|jpg|svg|bmp|gif))$", boost::regex_constants::icase);
boost::regex backgroundfile("((background|bg||\\[bg\\])\\.(png|jpeg|jpg|svg|bmp|gif))$", boost::regex_constants::icase);
- boost::regex videofile("(.*\\.(avi|mpg|mpeg|flv|mov))$", boost::regex_constants::icase);
+ boost::regex videofile("(.*\\.(avi|mpg|mpeg|flv|mov|mp4))$", boost::regex_constants::icase);
boost::cmatch match;
for (boost::filesystem::directory_iterator dirIt(s.path), dirEnd; dirIt != dirEnd; ++dirIt) {
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:37
|
Module: performous
Branch: dance
Commit: 63610f031e9e9391961849fa2a265a9a872e29b3
Author: Tapio Vierros <tap...@gm...>
Date: Thu Nov 12 22:35:20 2009 +0200
Currently selected song is preserved after initial loading/randomizing is complete.
---
game/songs.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/songs.cc b/game/songs.cc
index 3b63876..4a9c5a5 100644
--- a/game/songs.cc
+++ b/game/songs.cc
@@ -116,8 +116,8 @@ void Songs::update() {
if (m_dirty) filter_internal();
// Shuffle the songlist if shuffle is finished and all songs are already filtered
if (m_needShuffle && !m_dirty) {
+ RestoreSel restore(*this);
randomize_internal();
- math_cover.setTarget(0, m_songs.size());
m_needShuffle = false;
}
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:35
|
Module: performous
Branch: dance
Commit: 40922f003360b145c10aac903b3117494895ecb6
Author: Tapio Vierros <tap...@gm...>
Date: Thu Nov 12 22:27:22 2009 +0200
Modified whammy effect.
---
game/guitargraph.cc | 14 ++++++++------
game/guitargraph.hh | 2 +-
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 3152ea3..e437130 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -127,7 +127,8 @@ void GuitarGraph::engine() {
if (!m_drums && ev.type == input::Event::RELEASE) {
endHold(ev.button);
}
- if (!m_drums && ev.type == input::Event::WHAMMY) whammy = (1.0 + ev.button) / 2.0;
+ if (!m_drums && ev.type == input::Event::WHAMMY)
+ whammy = (1.0 + ev.button + 2.0*(rand()/double(RAND_MAX))) / 4.0;
if (ev.type == input::Event::PRESS) m_hit[!m_drums + ev.button].setValue(1.0);
else if (ev.type == input::Event::PICK) m_hit[0].setValue(1.0);
if (time < -0.5) {
@@ -470,10 +471,10 @@ void GuitarGraph::draw(double time) {
namespace {
const float fretWid = 0.5f;
- void vertexPair(float x, float y, glutil::Color c, float ty) {
+ void vertexPair(float x, float y, glutil::Color c, float ty, float fretW = fretWid) {
c.a = y2a(y); glColor4fv(c);
- glNormal3f(0.0f,1.0f,0.0f); glTexCoord2f(0.0f, ty); glVertex2f(x - fretWid, y);
- glNormal3f(0.0f,1.0f,0.0f); glTexCoord2f(1.0f, ty); glVertex2f(x + fretWid, y);
+ glNormal3f(0.0f,1.0f,0.0f); glTexCoord2f(0.0f, ty); glVertex2f(x - fretW, y);
+ glNormal3f(0.0f,1.0f,0.0f); glTexCoord2f(1.0f, ty); glVertex2f(x + fretW, y);
}
}
@@ -512,8 +513,9 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
vertexPair(x, y, c, 0.5f);
if (whammy > 0.1) {
while ((y -= fretWid) > yEnd + fretWid) {
- // The sin formula is pure magic
- vertexPair(x+sin((whammy-0.75)*6.0 + (yBeg-tEnd)/y)/3.0, y, c, 0.5f);
+ float r = rand() / double(RAND_MAX);
+ float r2 = rand() / double(RAND_MAX);
+ vertexPair(x+cos(y*whammy)/4.0+(r-0.5)/4.0, y, c, r2*0.30 + 0.20);
}
} else {
while ((y -= 10.0) > yEnd + fretWid) vertexPair(x, y, c, 0.5f);
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index f706090..44d12fd 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -95,7 +95,7 @@ class GuitarGraph {
int fret;
Duration const* dur;
double holdTime;
- Event(double t, int ty, int f = -1, Duration const* d = NULL): time(t), glow(0.0, 5.0), whammy(0.0, 0.4), type(ty), fret(f), dur(d), holdTime(d ? d->begin : getNaN()) { if (type > 0) glow.setValue(1.0); }
+ Event(double t, int ty, int f = -1, Duration const* d = NULL): time(t), glow(0.0, 5.0), whammy(0.0, 1.2), type(ty), fret(f), dur(d), holdTime(d ? d->begin : getNaN()) { if (type > 0) glow.setValue(1.0); }
};
typedef std::vector<Event> Events;
Events m_events;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:33
|
Module: performous
Branch: dance
Commit: 3900316c5796ec5e742d4de8c12da5cd3c176236
Author: Lasse Karkkainen <tro...@tr...>
Date: Thu Nov 12 17:42:27 2009 +0200
Relocation support for Apple (needs testing)
---
game/CMakeLists.txt | 11 +++++------
libs/libda/src/CMakeLists.txt | 2 +-
libs/plugin++/CMakeLists.txt | 2 +-
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index 83168b6..1ea641a 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -39,12 +39,11 @@ add_executable(performous ${SOURCES} ${SDL_SOURCES})
target_link_libraries(performous da ${LIBS})
# Store library paths in executable
-set_target_properties(performous PROPERTIES
- INSTALL_RPATH_USE_LINK_PATH TRUE
- SKIP_BUILD_RPATH FALSE
- INSTALL_RPATH \$ORIGIN/../lib
- BUILD_WITH_INSTALL_RPATH FALSE
-)
+if(APPLE)
+ set_target_properties(performous PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH @loader_path/../lib)
+else()
+ set_target_properties(performous PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE INSTALL_RPATH \$ORIGIN/../lib)
+endif()
# Generate config.hh
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.hh" "${CMAKE_CURRENT_BINARY_DIR}/config.hh" @ONLY)
diff --git a/libs/libda/src/CMakeLists.txt b/libs/libda/src/CMakeLists.txt
index 60061a0..ddfbf8a 100644
--- a/libs/libda/src/CMakeLists.txt
+++ b/libs/libda/src/CMakeLists.txt
@@ -7,5 +7,5 @@ find_package(Boost 1.34 REQUIRED COMPONENTS thread filesystem)
include_directories(${Boost_INCLUDE_DIRS})
add_library(da SHARED audio.cpp)
target_link_libraries(da plugin++ ${Boost_LIBRARIES})
-set_target_properties(da PROPERTIES INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
+set_target_properties(da PROPERTIES INSTALL_NAME_DIR @rpath/lib)
install(TARGETS da DESTINATION lib${LIB_SUFFIX})
diff --git a/libs/plugin++/CMakeLists.txt b/libs/plugin++/CMakeLists.txt
index 1378e5a..7b84fcd 100644
--- a/libs/plugin++/CMakeLists.txt
+++ b/libs/plugin++/CMakeLists.txt
@@ -19,7 +19,7 @@ if(NOT WIN32)
target_link_libraries(plugin++ dl)
endif()
-set_target_properties(plugin++ PROPERTIES INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
+set_target_properties(plugin++ PROPERTIES INSTALL_NAME_DIR @rpath/lib)
install(TARGETS plugin++ DESTINATION lib${LIB_SUFFIX})
FILE(GLOB HEADER_FILES "include/plugin++/*")
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:31
|
Module: performous
Branch: dance
Commit: 92ab087792e53497396e80127a14b021e95721e3
Author: Markus Raab <un...@ma...>
Date: Thu Nov 12 13:42:38 2009 +0100
only add songs for which the sing screen was left
thanks Yoda for the idea
---
game/screen_sing.cc | 1 +
game/songs.cc | 1 -
2 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index ade25f7..f6c46ac 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -138,6 +138,7 @@ void ScreenSing::activateNextScreen()
{
ScreenManager* sm = ScreenManager::getSingletonPtr();
+ m_database.addSong(m_song);
if (m_database.scores.empty()
|| !m_database.reachedHiscore(m_song))
{
diff --git a/game/songs.cc b/game/songs.cc
index c4e13d7..3b63876 100644
--- a/game/songs.cc
+++ b/game/songs.cc
@@ -72,7 +72,6 @@ void Songs::reload_internal(fs::path const& parent) {
boost::shared_ptr<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);
- m_database.addSong(s);
m_songs.push_back(s);
m_dirty = true;
} catch (SongParserException& e) {
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:30
|
Module: performous Branch: dance Commit: 257fc9aa1c1b4b878a79d0bf333f15640f7bf7b0 Author: Markus Raab <un...@ma...> Date: Thu Nov 12 13:15:12 2009 +0100 Compiles again (with hiscores in performous) score and cur moved from players to database instead of making it public the friends are listed to indicate that this is not a good idea players.hh header removed where database is now used change constructors to accept database instead of players remove the m_highscore scoped_ptr, database has global scope use shared_ptr immediately when Song is allocated hiscore is used unconditionally: config item removed --- data/schema.xml | 6 ------ game/database.cc | 10 ++++------ game/database.hh | 25 +++++++++++++++++++++++-- game/engine.hh | 20 ++++++++++---------- game/layout_singer.cc | 13 ++++++------- game/layout_singer.hh | 6 ++++-- game/notegraph.cc | 8 ++++---- game/notegraph.hh | 6 +++--- game/players.cc | 3 +-- game/players.hh | 10 ---------- game/screen_hiscore.cc | 20 +++++--------------- game/screen_hiscore.hh | 9 +++++---- game/screen_players.cc | 30 ++++++++++-------------------- game/screen_players.hh | 10 +++++++--- game/screen_sing.cc | 42 +++++++++++++++++++++++++----------------- game/screen_sing.hh | 4 ++-- game/songs.cc | 8 ++++---- 17 files changed, 113 insertions(+), 117 deletions(-) |
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:28
|
Module: performous Branch: dance Commit: 0d183b3ce1783b96619e5f9e3d57169e91020102 Author: Markus Raab <un...@ma...> Date: Thu Nov 12 11:46:21 2009 +0100 Merge branch 'master' of git://git.performous.org/gitroot/performous/performous --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:26
|
Module: performous
Branch: dance
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();
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:25
|
Module: performous
Branch: dance
Commit: 20b425ffd6a6eaa119c125b675ea3164233b9acf
Author: Markus Raab <un...@ma...>
Date: Thu Nov 12 10:52:21 2009 +0100
Query Interface for Database
it is now possible to query the global hiscore
and hiscores per songs and player.
in test program you can now enter song too and query is used
more const correctness (queries are const)
assign_id_internal regression fixed
---
game/database.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++-----
game/database.hh | 9 ++++++-
game/hiscore.cc | 30 ++++++++++++++++++++++++--
game/hiscore.hh | 9 +++++++-
game/players.cc | 10 ++++++++-
game/players.hh | 9 ++++++-
game/songitems.cc | 14 ++++++++++-
game/songitems.hh | 5 ++++
8 files changed, 128 insertions(+), 17 deletions(-)
diff --git a/game/database.cc b/game/database.cc
index d9906dc..d0f2bba 100644
--- a/game/database.cc
+++ b/game/database.cc
@@ -76,17 +76,54 @@ void Database::addHiscore (boost::shared_ptr<Song> s) {
m_hiscores.addHiscore(score, playerid, songid);
}
-bool Database::reachedHiscore (boost::shared_ptr<Song> s) {
+bool Database::reachedHiscore (boost::shared_ptr<Song> s) const {
int score = m_players.scores.front();
int songid = m_songs.lookup(s);
+
return m_hiscores.reachedHiscore(score, songid);
}
-int test(std::string const& name, int score) {
+void Database::queryOverallHiscore (std::ostream & os, std::string const& track) const {
+ std::vector<HiscoreItem> hi = m_hiscores.queryHiscore (10, -1, -1, track);
+ for (size_t i=0; i<hi.size(); ++i)
+ {
+ os << i+1 << ".\t"
+ << m_players.lookup(hi[i].playerid) << "\t"
+ << m_songs.lookup(hi[i].songid) << "\t"
+ // << hi[i].track << "\t"
+ << hi[i].score << "\n";
+ }
+}
+
+void Database::queryPerSongHiscore (std::ostream & os, boost::shared_ptr<Song> s, std::string const& track) const {
+ int songid = m_songs.lookup(s);
+ std::vector<HiscoreItem> hi = m_hiscores.queryHiscore(10, -1, songid, track);
+ for (size_t i=0; i<hi.size(); ++i)
+ {
+ os << i+1 << ".\t"
+ << m_players.lookup(hi[i].playerid) << "\t"
+ // << hi[i].track << "\t"
+ << hi[i].score << "\n";
+ }
+}
+
+void Database::queryPerPlayerHiscore (std::ostream & os, std::string const& track) const {
+ int playerid = m_players.lookup(m_players.current().name);
+ std::vector<HiscoreItem> hi = m_hiscores.queryHiscore(10, playerid, -1, track);
+ for (size_t i=0; i<hi.size(); ++i)
+ {
+ os << i+1 << ".\t"
+ << m_songs.lookup(hi[i].songid) << "\t"
+ // << hi[i].track << "\t"
+ << hi[i].score << "\n";
+ }
+}
+
+int test(std::string const& name, std::string const& song, int score) {
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"));
+ boost::shared_ptr<Song> s(new Song("/usr/share/songs/ABBA/ABBA - " + song + "/", "ABBA - " + song + ".txt"));
d.addSong(s);
PlayerItem pi;
@@ -100,6 +137,15 @@ int test(std::string const& name, int score) {
d.addHiscore(s);
}
+ std::cout << " --- Overall Hiscore ---" << std::endl;
+ d.queryOverallHiscore(std::cout);
+
+ std::cout << " --- Player Hiscore ---" << std::endl;
+ d.queryPerPlayerHiscore(std::cout);
+
+ std::cout << " --- Song Hiscore ---" << std::endl;
+ d.queryPerSongHiscore(std::cout, s);
+
return 0;
}
@@ -107,10 +153,11 @@ int test(std::string const& name, int score) {
int main(int argc, char**argv) {
- if (argc < 3) return 3;
+ if (argc < 4) return 3;
std::string name = argv[1];
- int score = boost::lexical_cast<int>(argv[2]);
+ std::string song = argv[2];
+ int score = boost::lexical_cast<int>(argv[3]);
- return test(name, score);
+ return test(name, song, score);
}
diff --git a/game/database.hh b/game/database.hh
index 1adec0a..c884944 100644
--- a/game/database.hh
+++ b/game/database.hh
@@ -1,6 +1,7 @@
#pragma once
#include <string>
+#include <ostream>
#include "players.hh"
#include "hiscore.hh"
@@ -64,9 +65,13 @@ class Database
Queries if the current player with current score has reached a new hiscore
for the song s.
*/
- bool reachedHiscore (boost::shared_ptr<Song> s);
+ bool reachedHiscore (boost::shared_ptr<Song> s) const;
- friend int test(std::string const&, int);
+ void queryOverallHiscore (std::ostream & os, std::string const& track = "") const;
+ 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);
private:
fs::path m_filename;
diff --git a/game/hiscore.cc b/game/hiscore.cc
index a74ec5e..4c0bcae 100644
--- a/game/hiscore.cc
+++ b/game/hiscore.cc
@@ -10,7 +10,7 @@
Hiscore::Hiscore()
{}
-bool Hiscore::reachedHiscore(int score, int songid, std::string const& track) {
+bool Hiscore::reachedHiscore(int score, int songid, std::string const& track) const {
if (score < 0) throw HiscoreException("Score negativ overflow");
if (score > 10000) throw HiscoreException("Score positive overflow");
@@ -46,6 +46,31 @@ void Hiscore::addHiscore(int score, int playerid, int songid, std::string const&
m_hiscore.insert(hi);
}
+Hiscore::HiscoreVector Hiscore::queryHiscore(int max, int playerid, int songid, std::string const& track) const {
+ HiscoreVector hv;
+ for (hiscore_t::const_iterator it = m_hiscore.begin(); it != m_hiscore.end(); ++it) {
+ if (playerid != -1)
+ {
+ if (playerid != it->playerid) continue;
+ }
+ if (songid != -1)
+ {
+ if (songid != it->songid) continue;
+ }
+ if (!track.empty())
+ {
+ if (track != it->track) continue;
+ }
+ if (max != -1)
+ {
+ if (max == 0) break;
+ --max;
+ }
+ hv.push_back(*it);
+ }
+ return hv;
+}
+
void Hiscore::load(xmlpp::NodeSet const& n) {
for (xmlpp::NodeSet::const_iterator it = n.begin(); it != n.end(); ++it)
{
@@ -72,8 +97,7 @@ void Hiscore::load(xmlpp::NodeSet const& n) {
}
void Hiscore::save(xmlpp::Element *hiscores) {
- for (hiscore_t::const_iterator it = m_hiscore.begin(); it != m_hiscore.end(); ++it)
- {
+ for (hiscore_t::const_iterator it = m_hiscore.begin(); it != m_hiscore.end(); ++it) {
xmlpp::Element* hiscore = hiscores->add_child("hiscore");
hiscore->set_attribute("playerid", boost::lexical_cast<std::string>(it->playerid));
hiscore->set_attribute("songid", boost::lexical_cast<std::string>(it->songid));
diff --git a/game/hiscore.hh b/game/hiscore.hh
index 951fe16..704fe61 100644
--- a/game/hiscore.hh
+++ b/game/hiscore.hh
@@ -51,7 +51,7 @@ class Hiscore
@return true if the score make it into the top.
@return false if addNewHiscore does not make sense
for that score.*/
- bool reachedHiscore(int score, int songid, std::string const& track = "vocals");
+ bool reachedHiscore(int score, int songid, std::string const& track = "vocals") const;
/**Add a specific highscore into the list.
@@ -65,6 +65,13 @@ class Hiscore
HiscoreException will be raised.
*/
void addHiscore(int score, int playerid, int songid, std::string const& track = "vocals");
+
+ typedef std::vector<HiscoreItem> HiscoreVector;
+ /**This queries the database for a sorted vector of highscores.
+ The defaults mean to query everything.
+ @param max limits the number of elements returned.
+ */
+ HiscoreVector queryHiscore(int max = -1, int playerid = -1, int songid = -1, std::string const& track = "") const;
private:
typedef std::multiset<HiscoreItem>hiscore_t;
diff --git a/game/players.cc b/game/players.cc
index 1a0a764..9919ac4 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -62,7 +62,7 @@ void Players::update() {
if (m_dirty) filter_internal();
}
-int Players::lookup(std::string const& name) {
+int Players::lookup(std::string const& name) const {
for (players_t::const_iterator it = m_players.begin(); it != m_players.end(); ++it) {
if (it->name == name) return it->id;
}
@@ -70,6 +70,14 @@ int Players::lookup(std::string const& name) {
return -1;
}
+std::string Players::lookup(int id) const {
+ PlayerItem pi;
+ pi.id = id;
+ players_t::iterator it = m_players.find(pi);
+ if (it == m_players.end()) return "Unkown Player";
+ else return it->name;
+}
+
void Players::addPlayer (std::string const& name, std::string const& picture, int id) {
PlayerItem pi;
pi.id = id;
diff --git a/game/players.hh b/game/players.hh
index e739b0f..2e67199 100644
--- a/game/players.hh
+++ b/game/players.hh
@@ -54,7 +54,7 @@ class Players: boost::noncopyable {
bool m_dirty;
- friend int test(std::string const&, int);
+ friend int test(std::string const&, std::string const&, int);
public:
cur_players_t cur;
@@ -70,7 +70,12 @@ class Players: boost::noncopyable {
void update();
/// lookup a playerid using the players name
- int lookup(std::string const& name);
+ int lookup(std::string const& name) const;
+
+ /** lookup a players name using the playerid.
+ @return the players name or "Unkown Player"
+ */
+ std::string lookup(int id) const;
/// add a player with a displayed name and an optional picture; if no id is given one will be assigned
void addPlayer (std::string const& name, std::string const& picture = "", int id = -1);
diff --git a/game/songitems.cc b/game/songitems.cc
index d4d44a1..8e78ae0 100644
--- a/game/songitems.cc
+++ b/game/songitems.cc
@@ -83,8 +83,18 @@ int SongItems::lookup(boost::shared_ptr<Song> song) const {
return -1;
}
+std::string SongItems::lookup (int id) const {
+ SongItem si;
+ si.id = id;
+ songs_t::iterator it = m_songs.find(si);
+ if (it == m_songs.end()) return "Unkown Song";
+ else if (!it->song) return it->artist + " - " + it->title;
+ else return it->song->artist + " - " + it->song->title;
+}
+
int SongItems::assign_id_internal() const {
- songs_t::const_iterator it = m_songs.begin();
- if (it != m_songs.end()) return it->id+1;
+ // use the last one with highest id
+ songs_t::const_reverse_iterator it = m_songs.rbegin();
+ if (it != m_songs.rend()) return it->id+1;
else return 1; // empty set
}
diff --git a/game/songitems.hh b/game/songitems.hh
index a71f100..4575c45 100644
--- a/game/songitems.hh
+++ b/game/songitems.hh
@@ -83,6 +83,11 @@ struct SongItems
@return -1 if no song found.*/
int lookup(boost::shared_ptr<Song> song) const;
+ /**Lookup the artist + title for a specific song.
+ @return "Unknown Song" if nothing is found.
+ */
+ std::string lookup (int id) const;
+
private:
int assign_id_internal() const;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:23
|
Module: performous
Branch: dance
Commit: c17639f9cbadd3c1503dcbdbe0d9784f243d2544
Author: Markus Raab <un...@ma...>
Date: Thu Nov 12 09:29:49 2009 +0100
a pointer to song is stored
(for more complete information, e.g. artist)
---
game/songitems.cc | 34 ++++++++++++++++++++++++++--------
game/songitems.hh | 26 +++++++++++++++++++++-----
2 files changed, 47 insertions(+), 13 deletions(-)
diff --git a/game/songitems.cc b/game/songitems.cc
index 99b4eba..d4d44a1 100644
--- a/game/songitems.cc
+++ b/game/songitems.cc
@@ -38,7 +38,7 @@ void SongItems::save(xmlpp::Element *songs) {
}
}
-void SongItems::addSongItem(std::string const& artist, std::string const& title, int id) {
+int SongItems::addSongItem(std::string const& artist, std::string const& title, int id) {
SongItem si;
if (id==-1) id = assign_id_internal();
si.id = id;
@@ -51,22 +51,40 @@ void SongItems::addSongItem(std::string const& artist, std::string const& title,
si.id = assign_id_internal();
m_songs.insert(si); // now do the insert with the fresh id
}
+ return si.id;
}
void SongItems::addSong(boost::shared_ptr<Song> song) {
- if (lookup(song) == -1) addSongItem(song->artist, song->title);
+ int id = lookup(song);
+ if (id == -1)
+ {
+ id = addSongItem(song->artist, song->title);
+ }
+
+ SongItem si;
+ si.id = id;
+ songs_t::iterator it = m_songs.find(si);
+ if (it == m_songs.end()) throw SongItemsException("Cant find song which was added just before");
+ // it->song.reset(song); // does not work, it is a read only structure...
+
+ // fill up the rest of the information
+ si.artist = it->artist;
+ si.title = it->title;
+ si.song = song;
+
+ m_songs.erase(it);
+ m_songs.insert(si);
}
-int SongItems::lookup(boost::shared_ptr<Song> song) {
- for (songs_t::iterator it = m_songs.begin(); it != m_songs.end(); ++it)
- {
+int SongItems::lookup(boost::shared_ptr<Song> song) const {
+ for (songs_t::const_iterator it = m_songs.begin(); it != m_songs.end(); ++it) {
if (song->collateByArtistOnly == it->artist && song->collateByTitleOnly == it->title) return it->id;
}
return -1;
}
-int SongItems::assign_id_internal() {
- songs_t::const_reverse_iterator it = m_songs.rbegin();
- if (it != m_songs.rend()) return it->id+1;
+int SongItems::assign_id_internal() const {
+ songs_t::const_iterator it = m_songs.begin();
+ if (it != m_songs.end()) return it->id+1;
else return 1; // empty set
}
diff --git a/game/songitems.hh b/game/songitems.hh
index 9b1f2c5..a71f100 100644
--- a/game/songitems.hh
+++ b/game/songitems.hh
@@ -21,11 +21,22 @@ struct SongItemsException: public std::runtime_error {
struct SongItem
{
- int id; // TODO use a PUID instead (LibOFA)
+ int id; ///< The unique id for every song
+ /** This data is stored separate because it is read in before
+ the song is added.
+ A short, but relatively non-ambiguous collate form is used.
+ */
std::string artist;
std::string title;
+ /** This shared pointer is stored to access all song
+ information available.
+ E.g. the full artist information can be accessed using
+ this pointer.
+ */
+ boost::shared_ptr<Song> song;
+
bool operator< (SongItem const& other) const
{
return id < other.id;
@@ -54,10 +65,15 @@ struct SongItems
There will be no check if artist and title already exist - if you
need that you want addSong().
*/
- void addSongItem(std::string const& artist, std::string const& title, int id = -1);
+ int addSongItem(std::string const& artist, std::string const& title, int id = -1);
/**Adds or Links an already existing song with an songitem.
+
The id will be assigned and artist and title will be filled in.
- If there is already a song with the same artist and title nothing will be done.
+ If there is already a song with the same artist and title the existing
+ will be used.
+
+ Afterwards the pointer to the song will be stored for entire available
+ song information.
lookup is used internally to achieve that.
*/
@@ -65,10 +81,10 @@ struct SongItems
/**Lookup a songid for a specific song.
@return -1 if no song found.*/
- int lookup(boost::shared_ptr<Song> song);
+ int lookup(boost::shared_ptr<Song> song) const;
private:
- int assign_id_internal();
+ int assign_id_internal() const;
typedef std::set<SongItem> songs_t;
songs_t m_songs;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:21
|
Module: performous
Branch: dance
Commit: b1b9a58df683e2d4120f0fe9fbb5a4228ac82a53
Author: Markus Raab <un...@ma...>
Date: Thu Nov 12 09:00:06 2009 +0100
track names are lowercase
---
data/database.xml | 2 +-
game/hiscore.cc | 2 +-
game/hiscore.hh | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/data/database.xml b/data/database.xml
index 8116110..725b6e2 100644
--- a/data/database.xml
+++ b/data/database.xml
@@ -10,7 +10,7 @@
</player>
</players>
<hiscores> <!-- a list of highscores -->
- <hiscore songid="123" playerid="123" track="VOCALS">600</hiscore>
+ <hiscore songid="123" playerid="123" track="vocals">600</hiscore>
</hiscores>
</performous>
<!--
diff --git a/game/hiscore.cc b/game/hiscore.cc
index 67f2e3e..a74ec5e 100644
--- a/game/hiscore.cc
+++ b/game/hiscore.cc
@@ -64,7 +64,7 @@ void Hiscore::load(xmlpp::NodeSet const& n) {
int score = boost::lexical_cast<int>(tn->get_content());
std::string track;
- if (!a_track) track = "VOCALS";
+ if (!a_track) track = "vocals";
else track = a_track->get_value();
addHiscore(score, playerid, songid, track);
diff --git a/game/hiscore.hh b/game/hiscore.hh
index df673a9..951fe16 100644
--- a/game/hiscore.hh
+++ b/game/hiscore.hh
@@ -51,7 +51,7 @@ class Hiscore
@return true if the score make it into the top.
@return false if addNewHiscore does not make sense
for that score.*/
- bool reachedHiscore(int score, int songid, std::string const& track = "VOCALS");
+ bool reachedHiscore(int score, int songid, std::string const& track = "vocals");
/**Add a specific highscore into the list.
@@ -64,7 +64,7 @@ class Hiscore
in its valid interval. If one of this conditions is not net a
HiscoreException will be raised.
*/
- void addHiscore(int score, int playerid, int songid, std::string const& track = "VOCALS");
+ void addHiscore(int score, int playerid, int songid, std::string const& track = "vocals");
private:
typedef std::multiset<HiscoreItem>hiscore_t;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:19
|
Module: performous
Branch: dance
Commit: 935780efd7df860689b8eb5849844144bbad7726
Author: Markus Raab <un...@ma...>
Date: Thu Nov 12 08:25:39 2009 +0100
documentation
+ formatting
---
docs/DeveloperReadme.txt | 9 +++++++++
game/database.hh | 31 +++++++++++++++++++++++++++++--
game/hiscore.cc | 12 ++++--------
game/hiscore.hh | 16 ++++++++++++++--
game/players.cc | 9 +++------
5 files changed, 59 insertions(+), 18 deletions(-)
diff --git a/docs/DeveloperReadme.txt b/docs/DeveloperReadme.txt
index 3529a4d..84d2a5a 100644
--- a/docs/DeveloperReadme.txt
+++ b/docs/DeveloperReadme.txt
@@ -47,6 +47,15 @@ their value smoothly over time. This effect is most prominent it the song
browser, but it is used in various other parts of the UI and we also abuse it
as a simple timer in some places.
+The database is the access point to static information. There you can add
+players, songitems and - the reason why it was introduced - hiscores. It is also
+a facade for Players (players.cc/hh), hiscore (hiscore.cc/hh)
+and songitems (songitems.cc/hh). Don't confuse songs with songitems. In fact
+they both hold a shared_ptr to the same song (song.cc/hh), but only the songitems
+have a unique id which is used in the highscore. On the other hand the
+songs (songs.cc/hh) are used for the song browser. There is also the code
+for iterating above all files and call the song-parser.
+
The game logic runs as a separate thread so that slow OpenGL rendering or other
such factors don't disturb it (engine.cc/hh). This engine runs in an endless
loop, polling the audio analyzer code (pitch.cc/hh) for data that it then uses
diff --git a/game/database.hh b/game/database.hh
index eb014c3..1adec0a 100644
--- a/game/database.hh
+++ b/game/database.hh
@@ -9,14 +9,25 @@
#include "fs.hh"
/**Access to a database for performous which holds
- Player-, Hiscore-, Song- and Partydata.
+ Player-, Hiscore-, Song-, Track- and (in future)
+ Partydata.
+
+ This is a facade for Players, Hiscore and SongItems.
Will be initialized at the very beginning of
the program.*/
class Database
{
public:
+ /**Will try to load the database.
+ If it does not succeed the error will be ignored.
+ Only some information will be printed on stderr.
+ */
Database (fs::path filename);
+ /**Will try to save the database.
+ This will even be done if the loading failed.
+ It tries to create the directory above the file.
+ */
~Database ();
/**Loads the whole database from xml.
@@ -28,15 +39,31 @@ class Database
@post filled database
*/
void load();
+ /**Saves the whole database to xml.
+ Will write out everything to the file given in the constructor, @see file()
+ */
void save();
+ /**The filename given by the constructor.
+ @returns the filename used for the database.
+ */
std::string file();
- public: // methods for player management
+ public: // methods for database management
+ /**A facade for Players::addPlayer.*/
void addPlayer (std::string const& name, std::string const& picture = "", int id = -1);
+ /**A facade for SongItems::addSong.*/
void addSong (boost::shared_ptr<Song> s);
+ /**A facade for Hiscore::addHiscore.
+ The ids will be looked up first by using the songs and current players data.*/
void addHiscore (boost::shared_ptr<Song> s);
+
+ public: // methods for database queries
+ /**A facade for Hiscore::reachedHiscore.
+ Queries if the current player with current score has reached a new hiscore
+ for the song s.
+ */
bool reachedHiscore (boost::shared_ptr<Song> s);
friend int test(std::string const&, int);
diff --git a/game/hiscore.cc b/game/hiscore.cc
index 1c5fb13..67f2e3e 100644
--- a/game/hiscore.cc
+++ b/game/hiscore.cc
@@ -10,8 +10,7 @@
Hiscore::Hiscore()
{}
-bool Hiscore::reachedHiscore(int score, int songid, std::string const& track)
-{
+bool Hiscore::reachedHiscore(int score, int songid, std::string const& track) {
if (score < 0) throw HiscoreException("Score negativ overflow");
if (score > 10000) throw HiscoreException("Score positive overflow");
@@ -29,8 +28,7 @@ bool Hiscore::reachedHiscore(int score, int songid, std::string const& track)
return true; // nothing found for that song -> true
}
-void Hiscore::addHiscore(int score, int playerid, int songid, std::string const& track)
-{
+void Hiscore::addHiscore(int score, int playerid, int songid, std::string const& track) {
HiscoreItem hi;
if (score < 0) throw HiscoreException("Score negativ overflow");
if (score > 10000) throw HiscoreException("Score positive overflow");
@@ -48,8 +46,7 @@ void Hiscore::addHiscore(int score, int playerid, int songid, std::string const&
m_hiscore.insert(hi);
}
-void Hiscore::load(xmlpp::NodeSet const& n)
-{
+void Hiscore::load(xmlpp::NodeSet const& n) {
for (xmlpp::NodeSet::const_iterator it = n.begin(); it != n.end(); ++it)
{
xmlpp::Element& element = dynamic_cast<xmlpp::Element&>(**it);
@@ -74,8 +71,7 @@ void Hiscore::load(xmlpp::NodeSet const& n)
}
}
-void Hiscore::save(xmlpp::Element *hiscores)
-{
+void Hiscore::save(xmlpp::Element *hiscores) {
for (hiscore_t::const_iterator it = m_hiscore.begin(); it != m_hiscore.end(); ++it)
{
xmlpp::Element* hiscore = hiscores->add_child("hiscore");
diff --git a/game/hiscore.hh b/game/hiscore.hh
index 665854b..df673a9 100644
--- a/game/hiscore.hh
+++ b/game/hiscore.hh
@@ -34,7 +34,7 @@ struct HiscoreItem {
class Hiscore
{
-public:
+ public:
Hiscore ();
void load(xmlpp::NodeSet const& n);
@@ -52,8 +52,20 @@ public:
@return false if addNewHiscore does not make sense
for that score.*/
bool reachedHiscore(int score, int songid, std::string const& track = "VOCALS");
+
+ /**Add a specific highscore into the list.
+
+ @pre Hiscore is added.
+
+ There is no check regarding if it is useful to add this hiscore.
+ To check this, use reachedHiscore() first.
+
+ The method will check if all ids are non-negative and the score
+ in its valid interval. If one of this conditions is not net a
+ HiscoreException will be raised.
+ */
void addHiscore(int score, int playerid, int songid, std::string const& track = "VOCALS");
-private:
+ private:
typedef std::multiset<HiscoreItem>hiscore_t;
hiscore_t m_hiscore;
diff --git a/game/players.cc b/game/players.cc
index f840ded..1a0a764 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -25,8 +25,7 @@ Players::~Players()
{ }
void Players::load(xmlpp::NodeSet const& n) {
- for (xmlpp::NodeSet::const_iterator it = n.begin(); it != n.end(); ++it)
- {
+ for (xmlpp::NodeSet::const_iterator it = n.begin(); it != n.end(); ++it) {
xmlpp::Element& element = dynamic_cast<xmlpp::Element&>(**it);
xmlpp::Attribute* a_name = element.get_attribute("name");
if (!a_name) throw PlayersException("Attribute name not found");
@@ -47,8 +46,7 @@ void Players::load(xmlpp::NodeSet const& n) {
}
void Players::save(xmlpp::Element *players) {
- for (players_t::const_iterator it = m_players.begin(); it!=m_players.end(); ++it)
- {
+ for (players_t::const_iterator it = m_players.begin(); it!=m_players.end(); ++it) {
xmlpp::Element* player = players->add_child("player");
player->set_attribute("name", it->name);
player->set_attribute("id", boost::lexical_cast<std::string>(it->id));
@@ -65,8 +63,7 @@ void Players::update() {
}
int Players::lookup(std::string const& name) {
- for (players_t::const_iterator it = m_players.begin(); it != m_players.end(); ++it)
- {
+ for (players_t::const_iterator it = m_players.begin(); it != m_players.end(); ++it) {
if (it->name == name) return it->id;
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:18
|
Module: performous Branch: dance Commit: f3d8bc7ecfcfa381cd8a27b12eb9fe2b9c6c470c Author: Vincent Le Ligeour <yo...@us...> Date: Thu Nov 12 07:59:34 2009 +0100 Fixed missing include --- tools/cover_conv.cpp | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/tools/cover_conv.cpp b/tools/cover_conv.cpp index d0bacf2..a0ede50 100644 --- a/tools/cover_conv.cpp +++ b/tools/cover_conv.cpp @@ -1,5 +1,6 @@ #include <boost/lexical_cast.hpp> #include <iostream> +#include <cstdlib> #ifdef __WIN32__ # include <windows.h> #endif |
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:16
|
Module: performous
Branch: dance
Commit: b42ad83003f8d0b7cdc0ad8d74be04b8aa3a30f1
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Nov 11 23:49:57 2009 +0200
Testing OSX INSTALL_NAME_DIR to avoid startup script there as well.
---
libs/libda/src/CMakeLists.txt | 1 +
libs/plugin++/CMakeLists.txt | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/libs/libda/src/CMakeLists.txt b/libs/libda/src/CMakeLists.txt
index e2bb1b5..60061a0 100644
--- a/libs/libda/src/CMakeLists.txt
+++ b/libs/libda/src/CMakeLists.txt
@@ -7,4 +7,5 @@ find_package(Boost 1.34 REQUIRED COMPONENTS thread filesystem)
include_directories(${Boost_INCLUDE_DIRS})
add_library(da SHARED audio.cpp)
target_link_libraries(da plugin++ ${Boost_LIBRARIES})
+set_target_properties(da PROPERTIES INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
install(TARGETS da DESTINATION lib${LIB_SUFFIX})
diff --git a/libs/plugin++/CMakeLists.txt b/libs/plugin++/CMakeLists.txt
index 639e139..1378e5a 100644
--- a/libs/plugin++/CMakeLists.txt
+++ b/libs/plugin++/CMakeLists.txt
@@ -19,6 +19,7 @@ if(NOT WIN32)
target_link_libraries(plugin++ dl)
endif()
+set_target_properties(plugin++ PROPERTIES INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
install(TARGETS plugin++ DESTINATION lib${LIB_SUFFIX})
FILE(GLOB HEADER_FILES "include/plugin++/*")
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:14
|
Module: performous
Branch: dance
Commit: 6c6b7b1529d60ee362fde3141a709130a1298994
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Nov 11 22:14:47 2009 +0200
Update libda to Boost 1.36 (avoiding compile warnings).
Add CMake policy for version 2.6 (to avoid CMake warnings).
---
CMakeLists.txt | 1 +
libs/libda/CMakeLists.txt | 1 +
libs/libda/plugins/CMakeLists.txt | 2 +-
libs/libda/plugins/audio_dev_tone.cpp | 5 ++---
libs/plugin++/CMakeLists.txt | 1 +
5 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad4d399..e48ac49 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,6 @@
project(Performous CXX)
cmake_minimum_required(VERSION 2.6)
+cmake_policy(VERSION 2.6)
set(PROJECT_VERSION "0.4-pre5")
# Avoid source tree pollution
diff --git a/libs/libda/CMakeLists.txt b/libs/libda/CMakeLists.txt
index 3ecbe27..f10c47c 100644
--- a/libs/libda/CMakeLists.txt
+++ b/libs/libda/CMakeLists.txt
@@ -1,5 +1,6 @@
project(libda)
cmake_minimum_required(VERSION 2.6)
+cmake_policy(VERSION 2.6)
set(LIBDA_PLUGIN_DIR "lib${LIB_SUFFIX}/libda")
diff --git a/libs/libda/plugins/CMakeLists.txt b/libs/libda/plugins/CMakeLists.txt
index fb21655..1c32364 100644
--- a/libs/libda/plugins/CMakeLists.txt
+++ b/libs/libda/plugins/CMakeLists.txt
@@ -98,7 +98,7 @@ endif(LIBDA_PLUGIN_PULSE)
if(LIBDA_PLUGIN_TESTING)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREAD ON)
- find_package(Boost 1.34 REQUIRED COMPONENTS thread date_time)
+ find_package(Boost 1.36 REQUIRED COMPONENTS thread date_time)
if(Boost_FOUND)
set(PLUGIN_TESTING_DESC "enabled")
set(PLUGIN_TESTING true)
diff --git a/libs/libda/plugins/audio_dev_tone.cpp b/libs/libda/plugins/audio_dev_tone.cpp
index b126e8d..b715573 100644
--- a/libs/libda/plugins/audio_dev_tone.cpp
+++ b/libs/libda/plugins/audio_dev_tone.cpp
@@ -2,8 +2,7 @@
#include <boost/scoped_ptr.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
-// Needs at least Boost 1.36 and many systems don't have that: #include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/core.hpp>
+#include <boost/spirit/include/classic_core.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>
#include <algorithm>
@@ -60,7 +59,7 @@ namespace {
boost::xtime time;
void add(std::string const& tonestr) {
double freq = 440.0, amplitude = 0.1, phase = 0.0;
- using namespace boost::spirit; //::classic;
+ using namespace boost::spirit::classic;
using namespace boost::lambda;
placeholder1_type arg1;
if (!parse(tonestr.c_str(),
diff --git a/libs/plugin++/CMakeLists.txt b/libs/plugin++/CMakeLists.txt
index 76494e7..639e139 100644
--- a/libs/plugin++/CMakeLists.txt
+++ b/libs/plugin++/CMakeLists.txt
@@ -1,5 +1,6 @@
project(Plugin++)
cmake_minimum_required(VERSION 2.4)
+cmake_policy(VERSION 2.6)
include_directories(include)
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:12
|
Module: performous
Branch: dance
Commit: 4eacbaf655b911e71ca949f4ed5b908e9d81ce1d
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Nov 11 22:13:57 2009 +0200
Fix man page generation
---
docs/CMakeLists.txt | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index 24da6af..0a4269d 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -7,7 +7,7 @@ if(UNIX)
if(HELP2MAN AND GZIP)
set(MANFILE ${CMAKE_CURRENT_BINARY_DIR}/performous.6.gz)
set(H2MFILE ${CMAKE_CURRENT_SOURCE_DIR}/performous.h2m)
- set(PERFORMOUS_EXEC ${CMAKE_BINARY_DIR}/game/performous.bin)
+ set(PERFORMOUS_EXEC ${CMAKE_BINARY_DIR}/game/performous)
add_custom_command(
OUTPUT ${MANFILE}
COMMAND ${HELP2MAN} ${PERFORMOUS_EXEC} -s 6 -i ${H2MFILE} -N | ${GZIP} > ${MANFILE}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:11
|
Module: performous
Branch: dance
Commit: c3d60a4497c2cef29e2a969a31dc3ed8e096ef0b
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Nov 11 21:56:03 2009 +0200
Remove launcher script, install binary as bin/performous
---
CMakeLists.txt | 9 ---------
game/CMakeLists.txt | 9 +++++----
2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index efeac79..ad4d399 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,12 +49,3 @@ if (ENABLE_TOOLS)
add_subdirectory(tools)
endif (ENABLE_TOOLS)
-set(FULL_PREFIX ${CMAKE_INSTALL_PREFIX})
-if(UNIX AND NOT "${FULL_PREFIX}" MATCHES "^/")
- set(FULL_PREFIX "${CMAKE_BINARY_DIR}/${FULL_PREFIX}")
-endif(UNIX AND NOT "${FULL_PREFIX}" MATCHES "^/")
-set(PERFORMOUS_PLUGIN_PATH "${FULL_PREFIX}/lib${LIB_SUFFIX}/libda")
-set(PERFORMOUS_EXECUTABLE "${FULL_PREFIX}/bin/performous.bin")
-configure_file("${PROJECT_SOURCE_DIR}/cmake/performous.sh.cmake" "${PROJECT_BINARY_DIR}/performous" ESCAPE_QUOTES @ONLY)
-install(PROGRAMS "${PROJECT_BINARY_DIR}/performous" DESTINATION bin)
-install(SCRIPT "${PROJECT_SOURCE_DIR}/cmake/performous-launcher.cmake")
diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index d105f0d..83168b6 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -35,10 +35,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions("-D__STDC_CONSTANT_MACROS")
endif(CMAKE_COMPILER_IS_GNUCXX)
-add_executable(performous.bin ${SOURCES} ${SDL_SOURCES})
-target_link_libraries(performous.bin da ${LIBS})
+add_executable(performous ${SOURCES} ${SDL_SOURCES})
+target_link_libraries(performous da ${LIBS})
-set_target_properties(performous.bin PROPERTIES
+# Store library paths in executable
+set_target_properties(performous PROPERTIES
INSTALL_RPATH_USE_LINK_PATH TRUE
SKIP_BUILD_RPATH FALSE
INSTALL_RPATH \$ORIGIN/../lib
@@ -49,5 +50,5 @@ set_target_properties(performous.bin PROPERTIES
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.hh" "${CMAKE_CURRENT_BINARY_DIR}/config.hh" @ONLY)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
-install(TARGETS performous.bin DESTINATION bin)
+install(TARGETS performous DESTINATION bin)
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:09
|
Module: performous
Branch: dance
Commit: b998b79c9901faf4a7a108384495e86dc13e1999
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Nov 11 21:32:52 2009 +0200
CMakeLists.txt fixes, updated Boost version requirement
---
game/CMakeLists.txt | 2 +-
libs/plugin++/CMakeLists.txt | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index 3b191fa..d105f0d 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -7,7 +7,7 @@ set(SOURCES ${SOURCE_FILES} ${HEADER_FILES})
# Libraries
-find_package(Boost 1.34 REQUIRED COMPONENTS thread date_time program_options regex filesystem)
+find_package(Boost 1.36 REQUIRED COMPONENTS thread date_time program_options regex filesystem)
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
diff --git a/libs/plugin++/CMakeLists.txt b/libs/plugin++/CMakeLists.txt
index 79fc033..76494e7 100644
--- a/libs/plugin++/CMakeLists.txt
+++ b/libs/plugin++/CMakeLists.txt
@@ -10,6 +10,10 @@ endif(CMAKE_COMPILER_IS_GNUCXX)
add_library(plugin++ SHARED src/dll.cc src/execname.cc src/loader.cc)
+find_package(Boost 1.36 REQUIRED COMPONENTS filesystem)
+include_directories(${Boost_INCLUDE_DIRS})
+target_link_libraries(plugin++ ${Boost_LIBRARIES})
+
if(NOT WIN32)
target_link_libraries(plugin++ dl)
endif()
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:07
|
Module: performous Branch: dance Commit: 855f8aa11a13ebbd0a07f8cd3973048d232b0ff3 Author: Lasse Karkkainen <tro...@tr...> Date: Wed Nov 11 21:23:29 2009 +0200 Merge branch 'master' of ssh://tronic@git.performous.org/gitroot/performous/performous --- |
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:05
|
Module: performous
Branch: dance
Commit: 33cbfd782fa162eca8bbb723484524417d747fb7
Author: Lasse Karkkainen <tro...@tr...>
Date: Wed Nov 11 21:23:20 2009 +0200
Plugin++ loader using execname to find libs
---
libs/plugin++/CMakeLists.txt | 2 +-
libs/plugin++/include/plugin++/loader.hpp | 40 +----------------
libs/plugin++/src/loader.cc | 66 +++++++++++++++++++++++++++++
3 files changed, 70 insertions(+), 38 deletions(-)
diff --git a/libs/plugin++/CMakeLists.txt b/libs/plugin++/CMakeLists.txt
index 5ade017..79fc033 100644
--- a/libs/plugin++/CMakeLists.txt
+++ b/libs/plugin++/CMakeLists.txt
@@ -8,7 +8,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -Wall -Wextra")
endif(CMAKE_COMPILER_IS_GNUCXX)
-add_library(plugin++ SHARED src/dll.cc src/execname.cc)
+add_library(plugin++ SHARED src/dll.cc src/execname.cc src/loader.cc)
if(NOT WIN32)
target_link_libraries(plugin++ dl)
diff --git a/libs/plugin++/include/plugin++/loader.hpp b/libs/plugin++/include/plugin++/loader.hpp
index 89519e6..5c551a9 100644
--- a/libs/plugin++/include/plugin++/loader.hpp
+++ b/libs/plugin++/include/plugin++/loader.hpp
@@ -1,15 +1,10 @@
#ifndef LOADER_HPP_INCLUDED
#define LOADER_HPP_INCLUDED
-#pragma warning(disable: 4996) // Disable stupid Microsoft warnings about stdlib functions
-
#include "dll.hpp"
-#include <iostream>
#include <set>
-#include <sstream>
#include <boost/filesystem.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
-#include <stdexcept>
namespace plugin {
namespace fs = boost::filesystem;
@@ -17,39 +12,10 @@ namespace plugin {
/** @short A helper for loading all matching libraries in a folder. **/
class loader {
boost::ptr_vector<dll> dlls;
- void parse(std::set<fs::path>& paths, char const* var, fs::path const& folder = fs::path()) {
- if (!var) return;
- std::istringstream iss(var);
- std::string elem;
- while (std::getline(iss, elem, ':')) {
- fs::path p = elem;
- if (!folder.empty()) p /= folder;
- if (fs::is_directory(p)) paths.insert(p);
- }
- }
- /** Try to load all libraries in the given folder. **/
- void load(fs::path const& path) {
- for (fs::directory_iterator it(path), end; it != end; ++it) {
- try {
- dlls.push_back(new dll(it->string()));
- } catch (std::runtime_error const& e) {
- std::cerr << e.what() << std::endl;
- } catch (...) {
- std::cerr << "WTF?" << std::endl;
- }
- }
- }
+ void parse(std::set<fs::path>& paths, char const* var, fs::path const& folder = fs::path());
+ void load(fs::path const& path);
public:
- loader(fs::path const& folder) {
- std::set<fs::path> paths;
- parse(paths, std::getenv("PLUGIN_PATH"));
- if (!folder.empty()) {
- parse(paths, std::getenv("LD_LIBRARY_PATH"), folder);
- parse(paths, "/usr/lib:/usr/local/lib", folder);
- }
- for (std::set<fs::path>::const_iterator it = paths.begin(); it != paths.end(); ++it) load(*it);
- if (dlls.empty()) std::cerr << "No plugins found. Try setting PLUGIN_PATH or LD_LIBRARY_PATH." << std::endl;
- }
+ loader(fs::path const& folder);
};
}
diff --git a/libs/plugin++/src/loader.cc b/libs/plugin++/src/loader.cc
new file mode 100644
index 0000000..199698c
--- /dev/null
+++ b/libs/plugin++/src/loader.cc
@@ -0,0 +1,66 @@
+#include <plugin++/loader.hpp>
+#include <plugin++/execname.hpp>
+#include <iostream>
+#include <sstream>
+#include <stdexcept>
+
+#ifdef _MSC_VER
+#pragma warning(disable: 4996) // Disable stupid Microsoft warnings about stdlib functions
+#endif
+
+using namespace plugin;
+namespace fs = boost::filesystem;
+
+#ifdef _WIN32
+#define PATHSEP ';'
+#else
+#define PATHSEP ':'
+#endif
+
+/// Break var (a delimited path string) into paths (appends folder if supplied).
+void loader::parse(std::set<fs::path>& paths, char const* var, fs::path const& folder) {
+ if (!var) return;
+ std::istringstream iss(var);
+ std::string elem;
+ while (std::getline(iss, elem, PATHSEP)) {
+ fs::path p = elem;
+ if (!folder.empty()) p /= folder;
+ if (fs::is_directory(p)) paths.insert(p);
+ }
+}
+
+/// Try to load all libraries in the given folder.
+void loader::load(fs::path const& path) {
+ for (fs::directory_iterator it(path), end; it != end; ++it) {
+ try {
+ dlls.push_back(new dll(it->string()));
+ } catch (std::runtime_error const& e) {
+ std::cerr << e.what() << std::endl;
+ }
+ }
+}
+
+loader::loader(fs::path const& folder) {
+ std::set<fs::path> paths;
+ // Try PLUGIN_PATH environment setting
+ parse(paths, std::getenv("PLUGIN_PATH"));
+ // Try other options only if folder was given
+ if (!folder.empty()) {
+ // Try relative path from executable
+ fs::path p = execname();
+ p = p.parent_path().parent_path();
+ if (!p.empty()) {
+ p /= "lib" / folder;
+ if (fs::is_directory(p)) paths.insert(p);
+ }
+#ifndef _WIN32
+ // Try UNIX library paths
+ parse(paths, std::getenv("LD_LIBRARY_PATH"), folder);
+ parse(paths, "/usr/lib:/usr/local/lib", folder);
+#endif
+ }
+ // Load the contents of each folder
+ for (std::set<fs::path>::const_iterator it = paths.begin(); it != paths.end(); ++it) load(*it);
+ if (dlls.empty()) std::cerr << "No plugins found. Try setting PLUGIN_PATH to the folder with the plugins." << std::endl;
+}
+
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:02
|
Module: performous
Branch: dance
Commit: 0f84502c418bdd4eb5dbad3acc7e0edb87970995
Author: Tapio Vierros <tap...@gm...>
Date: Wed Nov 11 19:57:23 2009 +0200
Added possibility to texture 3d objects.
---
game/3dobject.cc | 1 -
game/3dobject.hh | 16 ++++++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/game/3dobject.cc b/game/3dobject.cc
index f4e5a2e..60e9e52 100644
--- a/game/3dobject.cc
+++ b/game/3dobject.cc
@@ -90,7 +90,6 @@ void Object3d::generateDisplayList() {
if (m_displist != 0) glDeleteLists(m_displist, 1);
m_displist = glGenLists(1);
glutil::DisplayList displist(m_displist, GL_COMPILE);
- //UseTexture tex(*m_texture);
std::vector<Face>::const_iterator it;
// Iterate through faces
for (it = m_faces.begin(); it != m_faces.end(); it++) {
diff --git a/game/3dobject.hh b/game/3dobject.hh
index 38ea1fc..585084b 100644
--- a/game/3dobject.hh
+++ b/game/3dobject.hh
@@ -6,6 +6,7 @@
#include <stdexcept>
#include <string>
+#include <boost/scoped_ptr.hpp>
#include <boost/noncopyable.hpp>
#include "surface.hh"
#include "glutil.hh"
@@ -40,7 +41,7 @@ class Object3d: boost::noncopyable {
std::vector<Vertex> m_normals;
std::vector<Face> m_faces;
GLuint m_displist;
- //boost::scoped_ptr<Texture> m_texture;
+ boost::scoped_ptr<Texture> m_texture;
/// load a Wavefront .obj 3d object file
void loadWavefrontObj(std::string filepath, float scale = 1.0);
/// generates a display list for the object
@@ -48,23 +49,26 @@ class Object3d: boost::noncopyable {
public:
/// constructors
Object3d(): m_displist(0) {};
- Object3d(std::string filepath, float scale = 1.0): m_displist(0) {
- load(filepath, scale);
+ Object3d(std::string filepath, std::string texturepath = "", float scale = 1.0): m_displist(0) {
+ load(filepath, texturepath, scale);
}
/// destructor
~Object3d() {
if (m_displist != 0) glDeleteLists(m_displist, 1);
}
/// load a new object file
- void load(std::string filepath, float scale = 1.0) {
- //m_texture.reset(new Texture(getThemePath("button.svg")));
+ void load(std::string filepath, std::string texturepath = "", float scale = 1.0) {
+ if (!texturepath.empty()) m_texture.reset(new Texture(texturepath));
loadWavefrontObj(filepath, scale);
generateDisplayList();
}
/// draws the object
void draw(float x = 0, float y = 0, float z = 0) const {
glTranslatef(x, y, z);
- glCallList(m_displist);
+ if (m_texture) {
+ UseTexture tex(*m_texture);
+ glCallList(m_displist);
+ } else glCallList(m_displist);
glTranslatef(-x, -y, -z);
}
};
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:44:00
|
Module: performous
Branch: dance
Commit: 7da4f8864081ce4b74128dced6f6657de9f44cf0
Author: Markus Raab <un...@ma...>
Date: Wed Nov 11 18:43:01 2009 +0100
Something like that for path
---
game/players.cc | 15 +--------------
1 files changed, 1 insertions(+), 14 deletions(-)
diff --git a/game/players.cc b/game/players.cc
index 683a1e6..f840ded 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -85,20 +85,7 @@ void Players::addPlayer (std::string const& name, std::string const& picture, in
if (pi.picture != "") // no picture, so don't search path
{
- /* TODO: add again check for pictures
- 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;
- */
+ // pi.picture = getXdgPath(fs::path("pictures") / pi.picture);
}
m_dirty = true;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:43:58
|
Module: performous Branch: dance Commit: dd49431362c70c19feb5bd58f35c35d17e7fb068 Author: Lasse Karkkainen <tro...@tr...> Date: Wed Nov 11 19:15:39 2009 +0200 Merge branch 'master' of ssh://tronic@git.performous.org/gitroot/performous/performous --- |