|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-12 23:56:00
|
Module: performous
Branch: master
Commit: 2a94db73642cccf20353fb20078b3c6ac7024239
Author: Lasse Karkkainen <tro...@tr...>
Date: Mon Jul 13 02:55:01 2009 +0300
Guitar graph moved to separate class, now only used for guitar songs.
---
game/guitargraph.cc | 21 +++++++++++++++++++++
game/guitargraph.hh | 24 ++++++++++++++++++++++++
game/notegraph.hh | 5 +----
game/screen_sing.cc | 27 ++++++---------------------
game/screen_sing.hh | 6 +++---
5 files changed, 55 insertions(+), 28 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
new file mode 100644
index 0000000..45adcab
--- /dev/null
+++ b/game/guitargraph.cc
@@ -0,0 +1,21 @@
+#include "guitargraph.hh"
+
+GuitarGraph::GuitarGraph(Song const& song): m_song(song), m_neck("guitarneck.svg") {}
+
+void GuitarGraph::draw(double time) {
+ UseTexture tex(m_neck);
+ glPushMatrix();
+ glTranslatef(0.0f, 0.3f, 0.0f);
+ glRotatef(80.0f, 1.0f, 0.0f, 0.0f);
+ glScalef(0.1f, 0.1f, 0.1f);
+ glBegin(GL_QUADS);
+ float ts = 12.0f;
+ float future = 3.0f;
+ glTexCoord2f(0.0f, -(time + future)); glColor4f(1.0f, 1.0f, 1.0f, 0.0f); glVertex2f(-2.5f, -future * ts);
+ glTexCoord2f(1.0f, -(time + future)); glColor4f(1.0f, 1.0f, 1.0f, 0.0f); glVertex2f(2.5f, -future * ts);
+ glTexCoord2f(1.0f, -(time + 0.0f)); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glVertex2f(2.5f, 0.0f * ts);
+ glTexCoord2f(0.0f, -(time + 0.0f)); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glVertex2f(-2.5f, 0.0f * ts);
+ glEnd();
+ glColor3f(1.0f, 1.0f, 1.0f);
+ glPopMatrix();
+}
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
new file mode 100644
index 0000000..6f186a1
--- /dev/null
+++ b/game/guitargraph.hh
@@ -0,0 +1,24 @@
+#pragma once
+
+#include <boost/scoped_ptr.hpp>
+#include "animvalue.hh"
+#include "engine.hh"
+#include "surface.hh"
+
+class Song;
+
+/// handles drawing of notes and waves
+class GuitarGraph {
+ public:
+ /// constructor
+ GuitarGraph(Song const& song);
+
+ /** draws GuitarGraph
+ * @param time at which time to draw
+ */
+ void draw(double time);
+ private:
+ Song const& m_song;
+ Texture m_neck;
+};
+
diff --git a/game/notegraph.hh b/game/notegraph.hh
index 5144777..b9e166c 100644
--- a/game/notegraph.hh
+++ b/game/notegraph.hh
@@ -1,5 +1,4 @@
-#ifndef PERFORMOUS_NOTEGRAPH_HH
-#define PERFORMOUS_NOTEGRAPH_HH
+#pragma once
#include <boost/scoped_ptr.hpp>
#include "animvalue.hh"
@@ -42,5 +41,3 @@ class NoteGraph {
};
-#endif
-
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index a1c261e..919828a 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -37,11 +37,13 @@ void ScreenSing::enter() {
boost::ptr_vector<Analyzer>& analyzers = m_capture.analyzers();
m_engine.reset(new Engine(m_audio, m_songs.current(), analyzers.begin(), analyzers.end()));
m_noteGraph.reset(new NoteGraph(song));
+ if (song.music.size() > 1) m_guitarGraph.reset(new GuitarGraph(song));
}
void ScreenSing::exit() {
m_score_window.reset();
m_lyrics.clear();
+ m_guitarGraph.reset();
m_noteGraph.reset();
m_engine.reset();
m_pause_icon.reset();
@@ -116,7 +118,6 @@ namespace {
}
void ScreenSing::draw() {
- ScreenManager* sm = ScreenManager::getSingletonPtr();
Song& song = m_songs.current();
// Get the time in the song
double length = m_audio.getLength();
@@ -140,26 +141,8 @@ void ScreenSing::draw() {
theme->bg_top.draw();
}
- // Draw guitar stuff
- Texture tex(getThemePath("guitarneck.svg"));
- {
- UseTexture t(tex);
- glPushMatrix();
- glTranslatef(0.0f, 0.3f, 0.0f);
- glRotatef(80.0f, 1.0f, 0.0f, 0.0f);
- glScalef(0.1f, 0.1f, 0.1f);
- glBegin(GL_QUADS);
- float ts = 12.0f;
- float future = 3.0f;
- glTexCoord2f(0.0f, -(time + future)); glColor4f(1.0f, 1.0f, 1.0f, 0.0f); glVertex2f(-2.5f, -future * ts);
- glTexCoord2f(1.0f, -(time + future)); glColor4f(1.0f, 1.0f, 1.0f, 0.0f); glVertex2f(2.5f, -future * ts);
- glTexCoord2f(1.0f, -(time + 0.0f)); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glVertex2f(2.5f, 0.0f * ts);
- glTexCoord2f(0.0f, -(time + 0.0f)); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glVertex2f(-2.5f, 0.0f * ts);
- glEnd();
- glColor3f(1.0f, 1.0f, 1.0f);
- glPopMatrix();
- }
-
+ if (m_guitarGraph.get()) m_guitarGraph->draw(time);
+
if (!config["game/karaoke_mode"].b()) drawNonKaraoke(time);
// Compute and draw lyrics
@@ -201,6 +184,8 @@ void ScreenSing::draw() {
theme->timer.draw(statustxt);
}
+ ScreenManager* sm = ScreenManager::getSingletonPtr();
+
if (config["game/karaoke_mode"].b()) {
if (!m_audio.isPlaying()) sm->activateScreen("Songs");
} else {
diff --git a/game/screen_sing.hh b/game/screen_sing.hh
index 586908a..bcac4f0 100644
--- a/game/screen_sing.hh
+++ b/game/screen_sing.hh
@@ -1,11 +1,11 @@
-#ifndef PERFORMOUS_SCREEN_SING_HH
-#define PERFORMOUS_SCREEN_SING_HH
+#pragma once
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/scoped_ptr.hpp>
#include <deque>
#include "animvalue.hh"
#include "engine.hh"
+#include "guitargraph.hh"
#include "notegraph.hh"
#include "screen.hh"
#include "theme.hh"
@@ -96,6 +96,7 @@ class ScreenSing: public Screen {
boost::scoped_ptr<SvgTxtThemeSimple> m_score_text[2];
boost::scoped_ptr<Engine> m_engine;
boost::scoped_ptr<NoteGraph> m_noteGraph;
+ boost::scoped_ptr<GuitarGraph> m_guitarGraph;
double m_latencyAV; // Latency between audio and video output (do not confuse with latencyAR)
boost::scoped_ptr<ThemeSing> theme;
Notes::const_iterator m_lyricit;
@@ -103,4 +104,3 @@ class ScreenSing: public Screen {
AnimValue m_quitTimer;
};
-#endif
|