|
From: Yoda-JM <yo...@us...> - 2010-04-10 08:15:51
|
Module: performous
Branch: master
Commit: 5e0ea6cefa869be04cba5f82e3ff43f9b0aa37dd
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Apr 10 10:14:45 2010 +0200
Fixed bug not displaying the notegraph anymore
---
game/notegraph.cc | 13 +++++----
game/notes.cc | 3 +-
game/song.hh | 2 +-
game/songparser-ini.cc | 29 ++++++++++---------
game/songparser-txt.cc | 19 +++++++------
game/songparser.hh | 2 +-
.../games-arcade/performous/performous-9999.ebuild | 2 -
7 files changed, 36 insertions(+), 34 deletions(-)
diff --git a/game/notegraph.cc b/game/notegraph.cc
index d220e8c..3569f6c 100644
--- a/game/notegraph.cc
+++ b/game/notegraph.cc
@@ -206,7 +206,8 @@ namespace {
}
void NoteGraph::drawWaves(Database const& database) {
- if (m_song.vocals.notes.empty()) return; // Cannot draw without notes
+ const VocalTrack &vocal = m_song.vocals;
+ if (vocal.notes.empty()) return; // Cannot draw without notes
UseTexture tblock(m_wave);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
for (std::list<Player>::const_iterator p = database.cur.begin(); p != database.cur.end(); ++p) {
@@ -223,7 +224,7 @@ void NoteGraph::drawWaves(Database const& database) {
double t = idx * Engine::TIMESTEP;
double oldval = getNaN();
Points points;
- Notes::const_iterator noteIt = m_song.vocals.notes.begin();
+ Notes::const_iterator noteIt = vocal.notes.begin();
for (; idx < endIdx; ++idx, t += Engine::TIMESTEP) {
double const freq = pitch[idx].first;
// If freq is NaN, we have nothing to process
@@ -232,17 +233,17 @@ void NoteGraph::drawWaves(Database const& database) {
if (idx < beginIdx) continue; // Skip graphics rendering if out of screen
double x = -0.2 + (t - m_time) * pixUnit;
// Find the currently active note(s)
- while (noteIt != m_song.vocals.notes.end() && (noteIt->type == Note::SLEEP || t > noteIt->end)) ++noteIt;
+ while (noteIt != vocal.notes.end() && (noteIt->type == Note::SLEEP || t > noteIt->end)) ++noteIt;
Notes::const_iterator notePrev = noteIt;
- while (notePrev != m_song.vocals.notes.begin() && (notePrev->type == Note::SLEEP || t < notePrev->begin)) --notePrev;
- bool hasNote = (noteIt != m_song.vocals.notes.end());
+ while (notePrev != vocal.notes.begin() && (notePrev->type == Note::SLEEP || t < notePrev->begin)) --notePrev;
+ bool hasNote = (noteIt != vocal.notes.end());
bool hasPrev = notePrev->type != Note::SLEEP && t >= notePrev->begin;
double val;
if (hasNote && hasPrev) val = 0.5 * (noteIt->note + notePrev->note);
else if (hasNote) val = noteIt->note;
else val = notePrev->note;
// Now val contains the active note value. The following calculates note value for current freq:
- val += Note::diff(val, m_song.vocals.scale.getNote(freq));
+ val += Note::diff(val, vocal.scale.getNote(freq));
// Graphics positioning & animation:
double y = m_baseY + val * m_noteUnit;
double thickness = clamp(1.0 + pitch[idx].second / 60.0) + 0.5;
diff --git a/game/notes.cc b/game/notes.cc
index e474643..ed7c6c0 100644
--- a/game/notes.cc
+++ b/game/notes.cc
@@ -80,6 +80,7 @@ VocalTrack::VocalTrack(std::string name) : name(name) {reload();}
void VocalTrack::reload() {
notes.clear();
m_scoreFactor = 0.0;
- noteMin = noteMax = std::numeric_limits<int>::max();
+ noteMin = std::numeric_limits<int>::max();
+ noteMax = std::numeric_limits<int>::min();
beginTime = endTime = getNaN();
}
diff --git a/game/song.hh b/game/song.hh
index 25d3c9d..f1062aa 100644
--- a/game/song.hh
+++ b/game/song.hh
@@ -32,7 +32,7 @@ class Song: boost::noncopyable {
friend class SongParser;
public:
/// constructor
- Song(std::string const& path_, std::string const& filename_): vocals(std::string("vocals")), path(path_), filename(filename_) { reload(false); }
+ Song(std::string const& path_, std::string const& filename_): vocals(std::string("VOCALS")), path(path_), filename(filename_) { reload(false); }
/// reload song
void reload(bool errorIgnore = true);
/// parse field
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index f6d676c..8542e32 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -133,7 +133,6 @@ void SongParser::iniParseHeader() {
/// Parse notes
void SongParser::iniParse() {
Song& s = m_song;
- s.vocals.notes.clear();
s.instrumentTracks.clear();
MidiFileParser midi(s.path + "/" + s.midifilename);
@@ -175,6 +174,8 @@ void SongParser::iniParse() {
continue;
}
// Process vocal tracks
+ VocalTrack &vocal = s.vocals;
+ vocal.notes.clear();
for (MidiFileParser::Lyrics::const_iterator it2 = it->lyrics.begin(); it2 != it->lyrics.end(); ++it2) {
Note n;
n.begin = midi.get_seconds(it2->begin)+s.start;
@@ -208,9 +209,9 @@ void SongParser::iniParse() {
}
// Special processing for slides (which depend on the previous note)
if (n.type == Note::SLIDE) {
- Notes::reverse_iterator prev = s.vocals.notes.rbegin();
- while (prev != s.vocals.notes.rend() && prev->type == Note::SLEEP) ++prev;
- if (prev == s.vocals.notes.rend()) throw std::runtime_error("The song begins with a slide note");
+ Notes::reverse_iterator prev = vocal.notes.rbegin();
+ while (prev != vocal.notes.rend() && prev->type == Note::SLEEP) ++prev;
+ if (prev == vocal.notes.rend()) throw std::runtime_error("The song begins with a slide note");
eraseLast(prev->syllable); // Erase the space if there is any
{
// insert new sliding note
@@ -222,9 +223,9 @@ void SongParser::iniParse() {
inter.type = Note::SLIDE;
inter.syllable = std::string("~");
m_maxScore += inter.maxScore();
- s.vocals.noteMin = std::min(s.vocals.noteMin, inter.note);
- s.vocals.noteMax = std::max(s.vocals.noteMax,inter.note);
- s.vocals.notes.push_back(inter);
+ vocal.noteMin = std::min(vocal.noteMin, inter.note);
+ vocal.noteMax = std::max(vocal.noteMax,inter.note);
+ vocal.notes.push_back(inter);
}
{
// modifying current note to be normal again
@@ -232,15 +233,15 @@ void SongParser::iniParse() {
}
}
m_maxScore += n.maxScore();
- s.vocals.noteMin = std::min(s.vocals.noteMin, n.note);
- s.vocals.noteMax = std::max(s.vocals.noteMax, n.note);
- s.vocals.notes.push_back(n);
- } else if (!s.vocals.notes.empty() && s.vocals.notes.back().type != Note::SLEEP) {
- eraseLast(s.vocals.notes.back().syllable);
- s.vocals.notes.push_back(n);
+ vocal.noteMin = std::min(vocal.noteMin, n.note);
+ vocal.noteMax = std::max(vocal.noteMax, n.note);
+ vocal.notes.push_back(n);
+ } else if (!vocal.notes.empty() && vocal.notes.back().type != Note::SLEEP) {
+ eraseLast(vocal.notes.back().syllable);
+ vocal.notes.push_back(n);
}
}
- if (!s.vocals.notes.empty()) break;
+ if (!vocal.notes.empty()) break;
}
// Figure out if we have BRE in the song
for (MidiFileParser::CommandEvents::const_iterator it = midi.cmdevents.begin(); it != midi.cmdevents.end(); ++it) {
diff --git a/game/songparser-txt.cc b/game/songparser-txt.cc
index 199c214..1b53d30 100644
--- a/game/songparser-txt.cc
+++ b/game/songparser-txt.cc
@@ -49,13 +49,14 @@ void SongParser::txtParseHeader() {
/// Parse notes
void SongParser::txtParse() {
std::string line;
- m_song.vocals.notes.clear();
+ VocalTrack &vocal = m_song.vocals;
+ vocal.notes.clear();
while (getline(line) && txtParseField(line)) {} // Parse the header again
if (m_bpm != 0.0) addBPM(0, m_bpm);
- while (txtParseNote(line) && getline(line)) {} // Parse notes
+ while (txtParseNote(line, vocal) && getline(line)) {} // Parse notes
// Workaround for the terminating : 1 0 0 line, written by some converters
- if (!m_song.vocals.notes.empty() && m_song.vocals.notes.back().type != Note::SLEEP
- && m_song.vocals.notes.back().begin == m_song.vocals.notes.back().end) m_song.vocals.notes.pop_back();
+ if (!vocal.notes.empty() && vocal.notes.back().type != Note::SLEEP
+ && vocal.notes.back().begin == vocal.notes.back().end) vocal.notes.pop_back();
}
bool SongParser::txtParseField(std::string const& line) {
@@ -86,7 +87,7 @@ bool SongParser::txtParseField(std::string const& line) {
return true;
}
-bool SongParser::txtParseNote(std::string line) {
+bool SongParser::txtParseNote(std::string line, VocalTrack &vocal) {
if (line.empty() || line == "\r") return true;
if (line[0] == '#') throw std::runtime_error("Key found in the middle of notes");
if (line[line.size() - 1] == '\r') line.erase(line.size() - 1);
@@ -132,8 +133,8 @@ bool SongParser::txtParseNote(std::string line) {
default: throw std::runtime_error("Unknown note type");
}
n.begin = tsTime(ts);
- Notes& notes = m_song.vocals.notes;
- if (m_relative && m_song.vocals.notes.empty()) m_relativeShift = ts;
+ Notes& notes = vocal.notes;
+ if (m_relative && notes.empty()) m_relativeShift = ts;
m_prevts = ts;
if (n.begin < m_prevtime) {
// Oh no, overlapping notes (b0rked file)
@@ -160,8 +161,8 @@ bool SongParser::txtParseNote(std::string line) {
double prevtime = m_prevtime;
m_prevtime = n.end;
if (n.type != Note::SLEEP && n.end > n.begin) {
- m_song.vocals.noteMin = std::min(m_song.vocals.noteMin, n.note);
- m_song.vocals.noteMax = std::max(m_song.vocals.noteMax, n.note);
+ vocal.noteMin = std::min(vocal.noteMin, n.note);
+ vocal.noteMax = std::max(vocal.noteMax, n.note);
m_maxScore += n.maxScore();
}
if (n.type == Note::SLEEP) {
diff --git a/game/songparser.hh b/game/songparser.hh
index d83ac3b..91d0025 100644
--- a/game/songparser.hh
+++ b/game/songparser.hh
@@ -123,7 +123,7 @@ class SongParser {
void txtParseHeader();
void txtParse();
bool txtParseField(std::string const& line);
- bool txtParseNote(std::string line);
+ bool txtParseNote(std::string line, VocalTrack &vocal);
bool iniCheck(std::vector<char> const& data);
void iniParseHeader();
void iniParse();
diff --git a/portage-overlay/games-arcade/performous/performous-9999.ebuild b/portage-overlay/games-arcade/performous/performous-9999.ebuild
index 8337767..6ac7944 100644
--- a/portage-overlay/games-arcade/performous/performous-9999.ebuild
+++ b/portage-overlay/games-arcade/performous/performous-9999.ebuild
@@ -103,8 +103,6 @@ src_compile() {
src_install() {
DOCS="docs/*.txt" cmake-utils_src_install
- mv "${D}/${GAMES_PREFIX}/share/locale" "${D}/usr/share/"
-
if use songs; then
insinto "/usr/share/games/ultrastar"
doins -r "${S}/songs" || die "doins songs failed"
|