|
From: Yoda-JM <yo...@us...> - 2009-07-26 06:24:21
|
Module: performous
Branch: master
Commit: a98ba28316b5f909840fd4cc0c7f3a1839787d0c
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Jul 26 08:23:35 2009 +0200
Added both layout for sing-only mode and sing+instrument mode
---
game/layout_singer.cc | 34 +++++++++++++++++++++-------------
game/layout_singer.hh | 7 ++++---
game/notegraph.cc | 11 +++++++++--
game/notegraph.hh | 3 ++-
game/screen_sing.cc | 6 +++++-
5 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/game/layout_singer.cc b/game/layout_singer.cc
index a71526a..b4d9200 100644
--- a/game/layout_singer.cc
+++ b/game/layout_singer.cc
@@ -10,24 +10,33 @@ void LayoutSinger::reset() {
m_lyrics.clear();
}
-void LayoutSinger::draw(double time) {
+void LayoutSinger::draw(double time, Position position) {
Song &song = m_songs.current();
// Draw notes and pitch waves (only when not in karaoke mode)
if (!config["game/karaoke_mode"].b()) {
std::list<Player> const& players = m_engine.getPlayers();
- m_noteGraph.draw(time, players);
+ switch(position) {
+ case LayoutSinger::BOTTOM:
+ m_noteGraph.draw(time, players, NoteGraph::FULLSCREEN);
+ break;
+ case LayoutSinger::MIDDLE:
+ m_noteGraph.draw(time, players, NoteGraph::TOP);
+ break;
+ }
}
// Draw the lyrics
- double basepos;
double linespacing;
- if(1) {
- basepos = -0.35;
- linespacing = 0.04;
- } else {
- basepos = -0.1;
- linespacing = 0.06;
+ Dimensions pos;
+ switch(position) {
+ case LayoutSinger::BOTTOM:
+ pos.screenBottom(-0.1);
+ linespacing = 0.06;
+ break;
+ case LayoutSinger::MIDDLE:
+ linespacing = 0.04;
+ break;
}
bool dirty;
do {
@@ -43,11 +52,10 @@ void LayoutSinger::draw(double time) {
dirty = true;
}
} while (dirty);
- double pos = basepos;
- for (size_t i = 0; i < m_lyrics.size(); ++i, pos += linespacing) {
- pos += m_lyrics[i].extraspacing.get() * linespacing;
+ for (size_t i = 0; i < m_lyrics.size(); ++i, pos.move(0.0, linespacing)) {
+ pos.move(0.0, m_lyrics[i].extraspacing.get() * linespacing);
if (i == 0) m_lyrics[0].draw(m_theme.lyrics_now, time, pos);
- else if (i == 1) m_lyrics[1].draw(m_theme.lyrics_next, time, pos);
+ else if (i == 1 && position == LayoutSinger::BOTTOM) m_lyrics[1].draw(m_theme.lyrics_next, time, pos);
}
}
diff --git a/game/layout_singer.hh b/game/layout_singer.hh
index 673c333..d25d014 100644
--- a/game/layout_singer.hh
+++ b/game/layout_singer.hh
@@ -26,14 +26,14 @@ class LyricRow {
return time > lastTime;
}
/// draw/print lyrics
- void draw(SvgTxtTheme& txt, double time, double pos) const {
+ void draw(SvgTxtTheme& txt, double time, Dimensions &dim) const {
std::vector<TZoomText> sentence;
for (Iterator it = m_begin; it != m_end; ++it) {
sentence.push_back(TZoomText(it->syllable));
bool current = (time >= it->begin && time < it->end);
sentence.back().factor = current ? 1.2 - 0.2 * (time - it->begin) / (it->end - it->begin) : 1.0;
}
- txt.dimensions.screenBottom(pos);
+ txt.dimensions = dim;
txt.draw(sentence, fade.get());
}
@@ -43,10 +43,11 @@ class LyricRow {
class LayoutSinger {
public:
+ enum Position {BOTTOM, MIDDLE};
LayoutSinger(Songs &_songs, Engine &_engine, ThemeSing& _theme);
~LayoutSinger();
void reset();
- void draw(double time);
+ void draw(double time, Position position = LayoutSinger::BOTTOM);
double lyrics_begin();
private:
Engine& m_engine;
diff --git a/game/notegraph.cc b/game/notegraph.cc
index fab9ea0..0389280 100644
--- a/game/notegraph.cc
+++ b/game/notegraph.cc
@@ -51,7 +51,7 @@ namespace {
const double baseLine = -0.2;
const double pixUnit = 0.2;
-void NoteGraph::draw(double time, std::list<Player> const& players) {
+void NoteGraph::draw(double time, std::list<Player> const& players, Position position) {
if (time < m_time) reset();
m_time = time;
// Update m_songit (which note to start the rendering from)
@@ -76,7 +76,14 @@ void NoteGraph::draw(double time, std::list<Player> const& players) {
m_nlBottom.setRange(low, low2);
}
}
- dimensions.stretch(1.0, 0.25).bottom(0.0); // FIXME: Don't hardcode these testing dimensions
+ switch(position) {
+ case NoteGraph::FULLSCREEN:
+ dimensions.stretch(1.0, 0.50).center();
+ break;
+ case NoteGraph::TOP:
+ dimensions.stretch(1.0, 0.25).bottom(0.0);
+ break;
+ }
m_max = m_nlTop.get() + 7.0;
m_min = m_nlBottom.get() - 7.0;
m_noteUnit = -dimensions.h() / std::max(48.0 * dimensions.h(), m_max - m_min);
diff --git a/game/notegraph.hh b/game/notegraph.hh
index b9e166c..860f4ed 100644
--- a/game/notegraph.hh
+++ b/game/notegraph.hh
@@ -10,6 +10,7 @@ class Song;
/// handles drawing of notes and waves
class NoteGraph {
public:
+ enum Position {FULLSCREEN, TOP};
/// constructor
NoteGraph(Song const& song);
/// resets NoteGraph and Notes
@@ -18,7 +19,7 @@ class NoteGraph {
* @param time at which time to draw
* @param players reference to the list of singing Players
*/
- void draw(double time, std::list<Player> const& players);
+ void draw(double time, std::list<Player> const& players, Position position = NoteGraph::FULLSCREEN);
private:
/// draw notebars
void drawNotes();
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 9e9e09f..4d9f069 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -144,7 +144,11 @@ void ScreenSing::draw() {
if (m_guitarGraph.get()) m_guitarGraph->draw(time);
- m_layout_singer->draw(time);
+ if( song.tracks.empty() ) {
+ m_layout_singer->draw(time, LayoutSinger::BOTTOM);
+ } 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);
|