|
From: Tapio V. <aa...@us...> - 2009-11-15 13:10:36
|
Module: performous
Branch: dance
Commit: 33d7e98cb468189e974e7e01f379f9fed8cda72b
Author: Tapio Vierros <tap...@gm...>
Date: Sun Nov 15 15:08:11 2009 +0200
A couple of sm-parser hackish fixes and some test code to get a track to dancegraph.
---
game/dancegraph.cc | 64 ++++++++++++++++++++++++++++++------------------
game/dancegraph.hh | 2 +
game/songparser-sm.cc | 19 +++++++++-----
3 files changed, 54 insertions(+), 31 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index c93eabc..fd2ddc0 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -1,6 +1,7 @@
#include "dancegraph.hh"
#include "fs.hh"
+#include "notes.hh"
#include <boost/lexical_cast.hpp>
namespace {
@@ -46,9 +47,24 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_streak(),
m_longestStreak()
{
- //TODO
m_arrow.dimensions.middle().center();
+ //TODO: this is a hack
+ for (DanceTracks::const_iterator it = m_song.danceTracks.begin(); it != m_song.danceTracks.end(); ++it) {
+ std::cout << "DANCE GAME MODE FOUND: " << it->first << std::endl;
+ if (it->first == "dance-single") {
+ DanceDifficultyMap dtracks = it->second;
+ DanceDifficulty d = EASY;
+ for (DanceDifficultyMap::const_iterator it2 = dtracks.begin(); it2 != dtracks.end(); ++it2) {
+ std::cout << "DANCE DIFFICULTY FOUND: " << it2->first << std::endl;
+ if (it2->first == d) {
+ DanceTrack dt = it2->second;
+ m_chords = dt.chords;
+ std::cout << "DANCE-TRACK FOUND" << std::endl;
+ }
+ }
+ }
+ }
}
@@ -108,8 +124,8 @@ void DanceGraph::draw(double time) {
m_text.draw(boost::lexical_cast<std::string>(unsigned(m_streak)) + "/"
+ boost::lexical_cast<std::string>(unsigned(m_longestStreak)));
}
-std::cout << "m" << dimensions.x1() << " " << dimensions.x2() << std::endl;
-std::cout << dimensions.y1() << " " << dimensions.y2() << std::endl;
+//std::cout << "m" << dimensions.x1() << " " << dimensions.x2() << std::endl;
+//std::cout << dimensions.y1() << " " << dimensions.y2() << std::endl;
glutil::PushMatrixMode pmm(GL_PROJECTION);
glTranslatef(frac * 2.0 * offsetX, 0.0f, 0.0f);
glutil::PushMatrixMode pmb(GL_MODELVIEW);
@@ -118,27 +134,27 @@ std::cout << dimensions.y1() << " " << dimensions.y2() << std::endl;
{ float s = dimensions.w() / 5.0f; glScalef(s, s, s); }
// Draw the notes
// TODO: iteration needs rewrite to the dancenotes structure
- //for (Chords::const_iterator it = m_chords.begin(); it != m_chords.end(); ++it) {
- /*
- float tBeg = it->begin - time;
- float tEnd = it->end - time;
- if (tEnd < past) continue;
- if (tBeg > future) break;
- for (int arrow_i = 0; arrow_i < 5; ++arrow_i) {
- //if (!it->fret[arrow_i]) continue;
- if (tEnd > future) tEnd = future;
- unsigned event = m_notes[it->dur[fret]];
- float glow = 0.0f;
- if (event > 0) glow = m_events[event - 1].glow.get();
-
- glutil::Color c = color(arrow_i);
- c.r += glow;
- c.g += glow;
- c.b += glow;
- drawNote(fret, c, tBeg, tEnd);
+ float tBeg, tEnd = 0.0f;
+ for (DanceChords::const_iterator it = m_chords.begin(); it != m_chords.end(); ++it) {
+ // TODO: rewrite for guitargraph's Chord
+ DanceChord chord = *it;
+ for (int arrow_i = 0; arrow_i < 4; arrow_i++) {
+ if (chord.find(arrow_i) != chord.end()) {
+ tBeg = chord[arrow_i].begin; tEnd = chord[arrow_i].end;
+ if (tEnd < past) continue;
+ if (tBeg > future) break;
+ //unsigned event = m_notes[it->dur[fret]];
+ //float glow = 0.0f;
+ //if (event > 0) glow = m_events[event - 1].glow.get();
+
+ glutil::Color c = color(arrow_i);
+ //c.r += glow;
+ //c.g += glow;
+ //c.b += glow;
+ drawNote(arrow_i, c, tBeg, tEnd);
+ }
}
- */
- //}
+ }
// Arrows on cursor
// TODO: suitable effect for pressing the arrows?
// TODO: effect possibilities: zooming, whitening, external glow
@@ -157,5 +173,5 @@ void DanceGraph::drawNote(int arrow_i, glutil::Color c, float tBeg, float tEnd)
float yBeg = time2y(tBeg);
float yEnd = time2y(tEnd);
c.a = time2a(tBeg); glColor4fv(c);
- drawArrow(arrow_i, x, time2y(tBeg));
+ drawArrow(arrow_i, x, yBeg);
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 9ea6c20..6fe3eda 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -4,6 +4,7 @@
#include <boost/ptr_container/ptr_map.hpp>
#include "animvalue.hh"
+#include "song.hh"
#include "notes.hh"
#include "audio.hh"
#include "joystick.hh"
@@ -35,6 +36,7 @@ class DanceGraph {
Audio& m_audio;
//input::InputDev m_input;
Song const& m_song;
+ DanceChords m_chords;
Surface m_arrow;
AnimValue m_cx, m_width;
std::size_t m_stream;
diff --git a/game/songparser-sm.cc b/game/songparser-sm.cc
index 64a89af..7b7688a 100644
--- a/game/songparser-sm.cc
+++ b/game/songparser-sm.cc
@@ -35,6 +35,7 @@ namespace {
else if (str == "NO" || str == "no" || str == "0") var = false;
else throw std::runtime_error("Invalid boolean value: " + str);
}
+ int upper_case (int c) { return toupper (c); }
}
@@ -56,7 +57,7 @@ void SongParser::smParse() {
int dur; //note duration
std::string notestype;
std::string description;
- DanceDifficulty danceDifficulty;
+ DanceDifficulty danceDifficulty = DIFFICULTYCOUNT;
DanceDifficultyMap danceDifficultyMap;
DanceChords chords;
@@ -117,29 +118,33 @@ void SongParser::smParse() {
//Note values are analyzed here. Values are:
+ // TODO: NOTES header vars needs better way to strip trailing colon ':'
+
//<NotesType>:
if(!getline(line)) { throw std::runtime_error("Required note data missing"); }
- notestype = boost::trim_copy(line.substr(0, line.size() -1));
+ notestype = boost::trim_copy(line.substr(0, line.size() -2));
//<Description>:
if(!getline(line)) { throw std::runtime_error("Required note data missing"); }
- description = boost::trim_copy(line.substr(0, line.size() -1));
+ description = boost::trim_copy(line.substr(0, line.size() -2));
//<DifficultyClass>:
if(!getline(line)) { throw std::runtime_error("Required note data missing"); }
- std::string difficultyclass = boost::trim_copy(line.substr(0, line.size() -1));
+ std::string difficultyclass = boost::trim_copy(line.substr(0, line.size() -2));
//enum
+ transform(difficultyclass.begin(), difficultyclass.end(),
+ difficultyclass.begin(), upper_case );
if(difficultyclass == "BEGINNER") danceDifficulty = BEGINNER;
if(difficultyclass == "EASY") danceDifficulty = EASY;
if(difficultyclass == "MEDIUM") danceDifficulty = MEDIUM;
if(difficultyclass == "HARD") danceDifficulty = HARD;
if(difficultyclass == "CHALLENGE") danceDifficulty = CHALLENGE;
-
+
//ignoring difficultymeter and radarvalues
//<DifficultyMeter>:
if(!getline(line)) { throw std::runtime_error("Required note data missing"); }
- //std::string difficultymeter = boost::trim_copy(line.substr(0, line.size() -1));
+ //std::string difficultymeter = boost::trim_copy(line.substr(0, line.size() -2));
//<RadarValues>:
if(!getline(line)) { throw std::runtime_error("Required note data missing"); }
- //std::string radarvalues = boost::trim_copy(line.substr(0, line.size() -1));
+ //std::string radarvalues = boost::trim_copy(line.substr(0, line.size() -2));
//<NoteData>:
/*while (getline(line) && smParseNotes(line, chords)) {}
|