|
From: Yoda-JM <yo...@us...> - 2009-07-26 08:54:17
|
Module: performous
Branch: master
Commit: 79679fd2793a84e15f3e90c3df32478e61a69cb9
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Jul 26 10:53:04 2009 +0200
Moved score drawing to Singer Layout
Added text hack in guitar graph (Tronic will fix me)
Added API for InputDev (not implemented yet)
---
game/guitargraph.cc | 4 +++-
game/guitargraph.hh | 2 ++
game/joystick.cc | 1 +
game/joystick.hh | 20 ++++++++++++++++++--
game/layout_singer.cc | 25 ++++++++++++++++++++++++-
game/layout_singer.hh | 2 ++
game/screen_sing.cc | 30 ------------------------------
game/screen_sing.hh | 2 --
8 files changed, 50 insertions(+), 36 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 0ba4581..aa23746 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -81,7 +81,7 @@ namespace {
bool picked = false;
}
-GuitarGraph::GuitarGraph(Song const& song): m_song(song), m_button("button.svg"), m_pickValue(0.0, 5.0), m_instrument(), m_level() {
+GuitarGraph::GuitarGraph(Song const& song): m_song(song), m_button("button.svg"), m_pickValue(0.0, 5.0), m_instrument(), m_level(), m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()) {
if (m_song.tracks.empty()) throw std::runtime_error("No tracks");
m_necks.push_back(new Texture("guitarneck.svg"));
m_necks.push_back(new Texture("bassneck.svg"));
@@ -139,6 +139,8 @@ bool GuitarGraph::difficulty(Difficulty level) {
}
void GuitarGraph::draw(double time) {
+ m_text.dimensions.screenBottom(-0.1).middle(0.2);
+ m_text.draw(std::string("Tronic FIXME"));
engine(time);
Dimensions dimensions(1.0); // FIXME: bogus aspect ratio (is this fixable?)
dimensions.screenBottom().fixedWidth(0.5f);
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index feb2f4c..7fb30a3 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -5,6 +5,7 @@
#include "animvalue.hh"
#include "engine.hh"
#include "surface.hh"
+#include "opengl_text.hh"
class Song;
@@ -151,5 +152,6 @@ class GuitarGraph {
bool difficulty(Difficulty level);
typedef std::vector<Chord> Chords;
Chords m_chords;
+ SvgTxtTheme m_text;
};
diff --git a/game/joystick.cc b/game/joystick.cc
index 951a0c1..9ff4965 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -122,6 +122,7 @@ void Joystick::addEvent(SDL_JoyButtonEvent event) {
JoystickEvent joy_event((event.type == SDL_JOYBUTTONDOWN) ? JoystickEvent::BUTTON_DOWN : JoystickEvent::BUTTON_UP);
joy_event.button_id = event.button;
+ joy_event.button_state = event.state;
m_events.push_back(joy_event);
}
diff --git a/game/joystick.hh b/game/joystick.hh
index a0003bf..d5b4a16 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -16,11 +16,12 @@ void joysticks_init();
class JoystickEvent {
public:
enum Type {BUTTON_DOWN, BUTTON_UP, HAT_MOTION, AXIS_MOTION, BALL_MOTION};
- JoystickEvent(): button_id(), hat_id(), hat_direction(CENTERED), axis_id(), axis_value(), ball_id(), ball_dx(), ball_dy() {};
- JoystickEvent(Type _type): type(_type), button_id(), hat_id(), hat_direction(CENTERED), axis_id(), axis_value(), ball_id(), ball_dx(), ball_dy() {};
+ JoystickEvent(): button_id(), button_state(), hat_id(), hat_direction(CENTERED), axis_id(), axis_value(), ball_id(), ball_dx(), ball_dy() {};
+ JoystickEvent(Type _type): type(_type), button_id(), button_state(), hat_id(), hat_direction(CENTERED), axis_id(), axis_value(), ball_id(), ball_dx(), ball_dy() {};
Type type;
// for BUTTON_DOWN and BUTTON_UP
unsigned char button_id;
+ bool button_state;
// for HAT_MOTION
enum HatDirection {
LEFT_UP, UP, RIGHT_UP,
@@ -77,3 +78,18 @@ class Joystick {
typedef std::map<unsigned int,Joystick> Joysticks;
extern Joysticks joysticks;
+
+class InputDevEvent {
+ public:
+ InputDevEvent() {};
+};
+
+class InputDev {
+ public:
+ InputDev() {};
+ bool tryPoll(InputDevEvent& _event) {(void)_event;return true;};
+ bool fret(unsigned int _id) {(void)_id;return false;};
+ // reserved for feeding the device with event
+ void addEvent(SDL_JoyButtonEvent _event) {(void)_event;};
+ private:
+};
diff --git a/game/layout_singer.cc b/game/layout_singer.cc
index 0bbab52..72cdc33 100644
--- a/game/layout_singer.cc
+++ b/game/layout_singer.cc
@@ -1,7 +1,13 @@
#include "layout_singer.hh"
-LayoutSinger::LayoutSinger(Songs &_songs, Engine &_engine, ThemeSing& _theme): m_engine(_engine), m_songs(_songs), m_theme(_theme), m_noteGraph(_songs.current()),m_lyricit(_songs.current().notes.begin()), m_lyrics() {};
+LayoutSinger::LayoutSinger(Songs &_songs, Engine &_engine, ThemeSing& _theme): m_engine(_engine), m_songs(_songs), m_theme(_theme), m_noteGraph(_songs.current()),m_lyricit(_songs.current().notes.begin()), m_lyrics() {
+ 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")));
+}
LayoutSinger::~LayoutSinger() {};
@@ -57,6 +63,23 @@ void LayoutSinger::draw(double time, Position position) {
if (i == 0) m_lyrics[0].draw(m_theme.lyrics_now, time, pos);
else if (i == 1 && position == LayoutSinger::BOTTOM) m_lyrics[1].draw(m_theme.lyrics_next, time, pos);
}
+
+ // Score display
+ if (!config["game/karaoke_mode"].b() ) {// draw score if not in karaoke mode
+ std::list<Player> const& players = m_engine.getPlayers();
+ unsigned int i = 0;
+ for (std::list<Player>::const_iterator p = players.begin(); p != players.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).screenTop(0.055);
+ 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).screenTop(0.055);
+ m_score_text[i%4]->draw();
+ glColor4f(1.0, 1.0, 1.0, 1.0);
+ }
+ }
}
double LayoutSinger::lyrics_begin() {
diff --git a/game/layout_singer.hh b/game/layout_singer.hh
index d25d014..e70bcab 100644
--- a/game/layout_singer.hh
+++ b/game/layout_singer.hh
@@ -56,4 +56,6 @@ class LayoutSinger {
NoteGraph m_noteGraph;
Notes::const_iterator m_lyricit;
std::deque<LyricRow> m_lyrics;
+ boost::scoped_ptr<Surface> m_player_icon;
+ boost::scoped_ptr<SvgTxtThemeSimple> m_score_text[4];
};
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 4d9f069..2ae679c 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -26,11 +26,6 @@ void ScreenSing::enter() {
}
if (!song.video.empty() && config["graphic/video"].b()) m_video.reset(new Video(song.path + song.video, song.videoGap));
m_pause_icon.reset(new Surface(getThemePath("sing_pause.svg")));
- 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")));
m_progress.reset(new ProgressBar(getThemePath("sing_progressbg.svg"), getThemePath("sing_progressfg.svg"), ProgressBar::HORIZONTAL, 0.01f, 0.01f, true));
m_progress->dimensions.fixedWidth(0.4).left(-0.5).screenTop();
theme->timer.dimensions.screenTop(0.5 * m_progress->dimensions.h());
@@ -46,13 +41,8 @@ void ScreenSing::exit() {
m_layout_singer.reset();
m_engine.reset();
m_pause_icon.reset();
- m_player_icon.reset();
m_video.reset();
m_background.reset();
- m_score_text[0].reset();
- m_score_text[1].reset();
- m_score_text[2].reset();
- m_score_text[3].reset();
theme.reset();
}
@@ -149,7 +139,6 @@ void ScreenSing::draw() {
} else {
m_layout_singer->draw(time, LayoutSinger::MIDDLE);
}
- if (!config["game/karaoke_mode"].b()) drawScores(); // draw score if not in karaoke mode
Song::Status status = song.status(time);
@@ -186,25 +175,6 @@ void ScreenSing::draw() {
}
}
-void ScreenSing::drawScores() {
- std::list<Player> const& players = m_engine->getPlayers();
- // Score display
- {
- unsigned int i = 0;
- for (std::list<Player>::const_iterator p = players.begin(); p != players.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).screenTop(0.055);
- 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).screenTop(0.055);
- m_score_text[i%4]->draw();
- glColor4f(1.0, 1.0, 1.0, 1.0);
- }
- }
-}
-
ScoreWindow::ScoreWindow(Engine& e):
m_pos(0.8, 2.0),
m_bg(getThemePath("score_window.svg")),
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index 5a009f7..fbd1d96 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -55,8 +55,6 @@ class ScreenSing: public Screen {
boost::scoped_ptr<Surface> m_background;
boost::scoped_ptr<Video> m_video;
boost::scoped_ptr<Surface> m_pause_icon;
- boost::scoped_ptr<Surface> m_player_icon;
- boost::scoped_ptr<SvgTxtThemeSimple> m_score_text[4];
boost::scoped_ptr<Engine> m_engine;
boost::scoped_ptr<LayoutSinger> m_layout_singer;
boost::scoped_ptr<GuitarGraph> m_guitarGraph;
|