You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(25) |
Jul
(288) |
Aug
(119) |
Sep
(31) |
Oct
(59) |
Nov
(458) |
Dec
(359) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(268) |
Feb
(26) |
Mar
(36) |
Apr
(48) |
May
(119) |
Jun
(37) |
Jul
(173) |
Aug
(429) |
Sep
(137) |
Oct
(156) |
Nov
(59) |
Dec
(45) |
| 2011 |
Jan
(398) |
Feb
(257) |
Mar
(49) |
Apr
(5) |
May
(34) |
Jun
(11) |
Jul
(38) |
Aug
(12) |
Sep
(1) |
Oct
(49) |
Nov
(5) |
Dec
(10) |
| 2012 |
Jan
(21) |
Feb
(32) |
Mar
(20) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(173) |
Aug
|
Sep
(25) |
Oct
(6) |
Nov
(44) |
Dec
|
|
From: Tapio V. <aa...@us...> - 2009-12-11 07:35:11
|
Module: performous
Branch: dance
Commit: ed6d442826f150a06123a602438c4c352fd7e812
Author: Tapio Vierros <tap...@gm...>
Date: Fri Dec 11 08:22:55 2009 +0200
ScoreWindow not early also for dancers.
---
game/screen_sing.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index a347e69..135e2f9 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -329,7 +329,7 @@ void ScreenSing::draw() {
}
}
else if (!m_audio.isPlaying() || (status == Song::FINISHED
- && m_audio.getLength() - time <= (m_song->track_map.empty() ? 3.0 : 0.2) )) {
+ && m_audio.getLength() - time <= (m_song->track_map.empty() && m_song->danceTracks.empty() ? 3.0 : 0.2) )) {
// Time to create the score window
m_quitTimer.setValue(QUIT_TIMEOUT);
m_engine->kill(); // kill the engine thread (to avoid consuming memory)
|
|
From: Tapio V. <aa...@us...> - 2009-12-11 07:35:09
|
Module: performous
Branch: dance
Commit: 788707eb921c29b6e6a108254b0e5f9c145883a0
Author: Tapio Vierros <tap...@gm...>
Date: Tue Dec 1 15:31:07 2009 +0200
ScoreWindow no longer appears too early for instruments.
---
game/screen_sing.cc | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index a3b419c..a347e69 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -328,7 +328,8 @@ void ScreenSing::draw() {
m_score_window->draw();
}
}
- else if (!m_audio.isPlaying() || (status == Song::FINISHED && m_audio.getLength() - time < 3.0)) {
+ else if (!m_audio.isPlaying() || (status == Song::FINISHED
+ && m_audio.getLength() - time <= (m_song->track_map.empty() ? 3.0 : 0.2) )) {
// Time to create the score window
m_quitTimer.setValue(QUIT_TIMEOUT);
m_engine->kill(); // kill the engine thread (to avoid consuming memory)
|
|
From: Matti K. <mpk...@us...> - 2009-12-11 06:20:18
|
Module: performous
Branch: dance
Commit: 1fb9a950cc8f2dfae0e7af5b9db865b751a93b72
Author: Matti Kemppainen <mpk...@us...>
Date: Fri Dec 11 08:18:11 2009 +0200
Trying to commit dance point calculation once again. In addition, now we have mine calculation in it.
---
game/dancegraph.cc | 55 ++++++++++++++++++++++++++++++++-------------------
game/dancegraph.hh | 2 +-
2 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 8018e3a..ec663ea 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -103,9 +103,6 @@ void DanceGraph::difficulty(DanceDifficulty level) {
m_notes.push_back(DanceNote(*it));
std::sort(m_notes.begin(), m_notes.end(), lessEnd()); // for engine's iterators
m_notesIt = m_notes.begin();
-
- for (DanceNotes::iterator it = m_notes.begin(); it != m_notes.end(); it++)
- std::cout << "Begin: " << it->note.begin << "; End: " << it->note.end << "; Button: " << it->note.note << std::endl;
// std::cout << "Difficulty set to: " << level << std::endl;
m_level = level;
for(size_t i=0; i < 4; i++)
@@ -129,13 +126,25 @@ void DanceGraph::engine() {
m_streak = 0;
}
else {
- std::cout << "Note correctly played.." << std::endl;
+ if(it->note.type != Note::MINE)
+ std::cout << "Note correctly played.." << std::endl;
if(!it->releaseTime)
it->releaseTime = time;
m_score += it->score;
}
}
+ // mines
+ for (DanceNotes::iterator it = m_notesIt; it != m_notes.end() && time <= it->note.begin + maxTolerance; it++) {
+ if(!it->isHit && it->note.type == Note::MINE &&
+ m_pressed[it->note.note] &&
+ it->note.begin >= time - maxTolerance && it->note.end <= time + maxTolerance) {
+ std::cout << "Hit mine at " << time << "!" << std::endl;
+ it->isHit = true;
+ m_score = -points(0);
+ }
+ }
+
// Handle all events
for (input::Event ev; m_input.tryPoll(ev);) {
m_dead = false;
@@ -151,12 +160,12 @@ void DanceGraph::engine() {
if (ev.type == input::Event::RELEASE) {
m_pressed[ev.button] = false;
dance(time, ev);
+ m_pressed_anim[ev.button].setTarget(0.0);
}
else if (ev.type == input::Event::PRESS) {
m_pressed[ev.button] = true;
dance(time, ev);
m_pressed_anim[ev.button].setValue(1.0);
- m_pressed_anim[ev.button].setTarget(0.0);
}
}
@@ -171,7 +180,6 @@ void DanceGraph::engine() {
/// Handles scoring and such
void DanceGraph::dance(double time, input::Event const& ev) {
if(ev.type == input::Event::RELEASE) {
- std::cout << "Release called at " << time << ", button " << ev.button << std::endl;
DanceNotes::iterator it = m_activeNotes[ev.button];
if(it != m_notes.end()) {
if(!it->releaseTime && it->note.end > time + maxTolerance) {
@@ -179,6 +187,7 @@ void DanceGraph::dance(double time, input::Event const& ev) {
it->score = 0;
std::cout << "Failed to hold note " << it->note.note << "! Begin: "
<< it->note.begin << "; End: " << it->note.end << std::endl;
+ m_streak = 0;
}
}
return;
@@ -186,13 +195,10 @@ void DanceGraph::dance(double time, input::Event const& ev) {
std::cout << "Hit button " << ev.button << " at " << time << std::endl;
for (DanceNotes::iterator it = m_notesIt; it != m_notes.end() && time <= it->note.begin + maxTolerance; it++) {
- std::cout << "Iterating note beginning at " << it->note.begin << "..(button " << it->note.note << ")" << std::endl;
if(!it->isHit && time >= it->note.begin - maxTolerance && ev.button == it->note.note) {
it->isHit = true;
- std::cout << "hit note!" << std::endl;
it->score = points(it->note.begin - time);
it->accuracy = 1.0 - (std::abs(it->note.begin - time) / maxTolerance);
- std::cout << "Hit note " << ev.button << " at time " << time << std::endl;
m_streak++;
m_activeNotes[ev.button] = it;
break;
@@ -293,6 +299,9 @@ void DanceGraph::draw(double time) {
float y = time2y(0.0);
float l = m_pressed_anim[arrow_i].get();
float s = (5.0 - l) / 5.0;
+ glutil::Color c = color(arrow_i);
+ c.r += l; c.g += l; c.b +=l;
+ glColor4fv(c);
drawArrow(arrow_i, m_arrows_cursor, x, y, s);
}
@@ -340,24 +349,24 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
float ac = note.accuracy;
float yBeg = time2y(tBeg);
float yEnd = time2y(tEnd);
- glColor3f(1.0f, 1.0f, 1.0f);
+ glutil::Color c = color(arrow_i);
if (note.isHit && std::abs(tEnd) < maxTolerance) {
if (mine) note.hitAnim.setRate(1.0);
note.hitAnim.setTarget(1.0, false);
}
double glow = note.hitAnim.get();
-
- // Modify hold drawing coordinates
- if (note.isHit && note.releaseTime <= 0) {
- yBeg = std::max(time2y(0.0), yBeg);
- yEnd = std::max(time2y(0.0), yEnd);
- }
- if (note.releaseTime > 0) yBeg = time2y(note.releaseTime - time);
if (yEnd - yBeg > arrowSize) {
- // Draw hold
- {
+ // Draw holds
+ glColor4fv(c);
+ if (note.isHit && note.releaseTime <= 0) {
+ yBeg = std::max(time2y(0.0), yBeg);
+ yEnd = std::max(time2y(0.0), yEnd);
+ glColor3f(1.0f, 1.0f, 1.0f);
+ }
+ if (note.releaseTime > 0) yBeg = time2y(note.releaseTime - time);
+ if (yEnd - yBeg > 0) {
UseTexture tblock(m_arrows_hold);
glutil::Begin block(GL_TRIANGLE_STRIP);
// Draw end
@@ -368,18 +377,22 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
vertexPair(arrow_i, x, yBeg+arrowSize, 1.0f/3.0f);
}
// Draw begin
+ if (note.isHit && tEnd < 0.1) {
+ glColor4fv(colorGlow(c,glow));
+ s += glow;
+ }
drawArrow(arrow_i, m_arrows_hold, x, yBeg, s, 0.0f, 1.0f/3.0f);
} else {
// Draw short note
if (mine) {
- glColor4f(1.0f, 1.0f, 1.0f, 1.0 - glow);
+ c.a = 1.0 - glow; glColor4fv(c);
s = 0.6f + glow * 0.5f;
float rot = int(time*360 * (note.isHit ? 2.0 : 1.0) ) % 360;
if (note.isHit) yBeg = time2y(0.0);
drawMine(x, yBeg, rot, s);
} else {
s += glow;
- glColor4f(1.0f, 1.0f, 1.0f, 1.0 - glow);
+ glColor4fv(colorGlow(c, glow));
drawArrow(arrow_i, m_arrows, x, yBeg, s);
}
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index cfa1cbd..1281f1f 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -40,7 +40,7 @@ class DanceGraph {
double dead(double time) const { return time > -0.5 && m_dead > 50; }
unsigned stream() const { return m_stream; }
double correctness() const { return m_correctness.get(); }
- int getScore() const { return m_score * m_scoreFactor; }
+ int getScore() const { return (m_score > 0 ? m_score : 0) * m_scoreFactor; }
std::string getGameMode() const { return m_gamingMode; }
std::string getDifficultyString() const;
private:
|
|
From: Matti K. <mpk...@us...> - 2009-12-11 06:20:10
|
Module: performous Branch: dance Commit: fcb9869ab4e878e74f98d7c470f40e0956d309c0 Author: Matti Kemppainen <mpk...@us...> Date: Fri Dec 11 08:08:54 2009 +0200 Merge branch 'dance' of git://git.performous.org/gitroot/performous/performous into dance --- |
|
From: Matti K. <mpk...@us...> - 2009-12-11 06:20:02
|
Module: performous
Branch: dance
Commit: ed91dc95e9a11227fcecb2f948c28a99cfbd2802
Author: Matti Kemppainen <mpk...@us...>
Date: Fri Dec 11 06:57:34 2009 +0200
Point calculation..
---
game/dancegraph.cc | 95 +++++++++++++++++++++++++++++----------------------
game/dancegraph.hh | 8 +---
2 files changed, 56 insertions(+), 47 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 021cf26..115ed79 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -5,6 +5,7 @@
#include "surface.hh"
#include <boost/lexical_cast.hpp>
#include <stdexcept>
+#include <algorithm>
namespace {
const std::string diffv[] = { "Beginner", "Easy", "Medium", "Hard", "Challenge" };
@@ -32,7 +33,11 @@ namespace {
if (error < maxTolerance / 6) score += 5;
return score;
}
-
+ struct lessEnd {
+ bool operator()(const DanceNote& left, const DanceNote& right) {
+ return left.note.end < right.note.end;
+ }
+ };
}
@@ -41,7 +46,7 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_level(BEGINNER),
m_audio(audio),
m_song(song),
- m_input(input::DANCEPAD), // TODO: to be replaced by DANCEPAD
+ m_input(input::DANCEPAD),
m_arrows(getThemePath("arrows.svg")),
m_arrows_cursor(getThemePath("arrows_cursor.svg")),
m_arrows_hold(getThemePath("arrows_hold.svg")),
@@ -62,7 +67,8 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_bigStreak(),
m_gamingMode("dance-single")
{
-
+ for(size_t i=0; i < 4; i++)
+ m_activeNotes[i] = m_notes.end();
m_popupText.reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
for(size_t i = 0; i < 4; i++) m_pressed[i] = false;
@@ -72,7 +78,7 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
if(it == m_song.danceTracks.end())
throw std::runtime_error("Could not find any dance tracks.");
difficultyDelta(0); // hack to get initial level
-
+
}
std::string DanceGraph::getDifficultyString() const { return diffv[m_level]; }
@@ -95,9 +101,19 @@ void DanceGraph::difficulty(DanceDifficulty level) {
DanceTrack const& track = m_song.danceTracks.find(m_gamingMode)->second.find(level)->second;
for(Notes::const_iterator it = track.notes.begin(); it != track.notes.end(); it++)
m_notes.push_back(DanceNote(*it));
+ std::sort(m_notes.begin(), m_notes.end(), lessEnd()); // for engine's iterators
m_notesIt = m_notes.begin();
+
+ for (DanceNotes::iterator it = m_notes.begin(); it != m_notes.end(); it++)
+ std::cout << "Begin: " << it->note.begin << "; End: " << it->note.end << "; Button: " << it->note.note << std::endl;
// std::cout << "Difficulty set to: " << level << std::endl;
- m_level = level;
+ m_level = level;
+ for(size_t i=0; i < 4; i++)
+ m_activeNotes[i] = m_notes.end();
+ m_scoreFactor = 1;
+ if(m_notes.size() != 0)
+ m_scoreFactor = 10000.0 / (50 * m_notes.size()); // maxpoints / (notepoint * notes)
+ std::cout << "Scorefactor: " << m_scoreFactor << std::endl;
}
/// Handles input
@@ -105,6 +121,21 @@ void DanceGraph::engine() {
double time = m_audio.getPosition();
time -= config["audio/controller_delay"].f();
+ // missed notes
+ for (DanceNotes::iterator& it = m_notesIt; it != m_notes.end() && time > it->note.end + maxTolerance; it++) {
+ if(!it->isHit) {
+ std::cout << "(Engine) Missed note at time " << time
+ << "(note timing " << it->note.begin << ")" << std::endl;
+ m_streak = 0;
+ }
+ else {
+ std::cout << "Note correctly played.." << std::endl;
+ if(!it->releaseTime)
+ it->releaseTime = time;
+ m_score += it->score;
+ }
+ }
+
// Handle all events
for (input::Event ev; m_input.tryPoll(ev);) {
m_dead = false;
@@ -129,17 +160,6 @@ void DanceGraph::engine() {
}
}
- /**
- * Idea in the usage of the iterator:
- * Here it is used as reference to avoid needless iterations of the past notes during later calls of engine().
- * Compare to the usage in the dance() function!
- * Iterator is first initialized in the difficulty setting..
- **/
-/* for (DanceNotes::iterator& it = m_notesIt; it != m_notes.end() && it->note.begin < time - maxTolerance; it++) {
- if(!it->isHit)
- std::cout << "Missed note at time " << time
- << "(note timing " << it->note.begin << ")" << std::endl;
- }*/
// Check if a long streak goal has been reached
if (m_streak >= getNextBigStreak(m_bigStreak)) {
@@ -148,41 +168,34 @@ void DanceGraph::engine() {
}
}
-
/// Handles scoring and such
void DanceGraph::dance(double time, input::Event const& ev) {
if(ev.type == input::Event::RELEASE) {
- // (at least) initial hack for testing hold end..
- for (DanceNotes::iterator it = m_notesIt; it != m_notes.end() && it->note.begin <= time + maxTolerance; it++) {
- if(it->isHit && it->note.end - it->note.begin > 0.5) {
+ std::cout << "Release called at " << time << ", button " << ev.button << std::endl;
+ DanceNotes::iterator it = m_activeNotes[ev.button];
+ if(it != m_notes.end()) {
+ if(!it->releaseTime && it->note.end > time + maxTolerance) {
it->releaseTime = time;
- it->isHit = false;
+ it->score = 0;
+ std::cout << "Failed to hold note " << it->note.note << "! Begin: "
+ << it->note.begin << "; End: " << it->note.end << std::endl;
}
}
return;
}
- std::cout << "Pressed button " << ev.button << " at time " << time << std::endl;
- /**
- * Idea behind the usage of the iterator:
- * Here it is copied to a local variable, because jumping back to the first accepted time (within tolerance)
- * is necessary in order to recognize notes closely timed notes.
- **/
- for (DanceNotes::iterator it = m_notesIt; it != m_notes.end() && it->note.begin <= time + maxTolerance; it++) {
- if(!it->isHit && ev.button == it->note.note) {
- // following clause needless?
- if(!(it->note.begin >= time - maxTolerance))
- std::cout << "Missed note. Timing: " << it->note.begin << "; Time: " << time
- << "(difference " << (it->note.begin - time) << ")" << std::endl;
+ std::cout << "Hit button " << ev.button << " at " << time << std::endl;
+ for (DanceNotes::iterator it = m_notesIt; it != m_notes.end() && time <= it->note.begin + maxTolerance; it++) {
+ std::cout << "Iterating note beginning at " << it->note.begin << "..(button " << it->note.note << ")" << std::endl;
+ if(!it->isHit && time >= it->note.begin - maxTolerance && ev.button == it->note.note) {
it->isHit = true;
- double p = points(it->note.begin - time);
+ std::cout << "hit note!" << std::endl;
+ it->score = points(it->note.begin - time);
it->accuracy = 1.0 - (std::abs(it->note.begin - time) / maxTolerance);
- std::cout << "Hit note " << ev.button << " at time " << time
- << "; " << p << " points." << std::endl;
- it->score = p;
- m_score += p;
-
- m_streak++; // Hack to test streak popup
+ std::cout << "Hit note " << ev.button << " at time " << time << std::endl;
+ m_streak++;
+ m_activeNotes[ev.button] = it;
+ break;
}
}
}
@@ -289,7 +302,7 @@ void DanceGraph::draw(double time) {
// Draw the notes
for (DanceNotes::iterator it = m_notes.begin(); it != m_notes.end(); ++it) {
if (it->note.end - time < past) continue;
- if (it->note.begin - time > future) break;
+ if (it->note.begin - time > future) continue;
drawNote(*it, time);
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index a54d7a4..cfa1cbd 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -44,12 +44,7 @@ class DanceGraph {
std::string getGameMode() const { return m_gamingMode; }
std::string getDifficultyString() const;
private:
- enum DanceStep {
- STEP_LEFT = 0,
- STEP_DOWN = 1,
- STEP_UP = 2,
- STEP_RIGHT = 3
- };
+ enum DanceStep { STEP_LEFT, STEP_DOWN, STEP_UP, STEP_RIGHT };
void difficultyDelta(int delta);
void difficulty(DanceDifficulty level);
DanceDifficulty m_level;
@@ -63,6 +58,7 @@ class DanceGraph {
input::InputDev m_input;
DanceNotes m_notes;
DanceNotes::iterator m_notesIt;
+ DanceNotes::iterator m_activeNotes[4];
Texture m_arrows;
Texture m_arrows_cursor;
Texture m_arrows_hold;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-12-11 04:40:37
|
Module: performous
Branch: master
Commit: ad36da993792323b24029b65629a6e9657479bcc
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Dec 11 06:40:18 2009 +0200
Make i18n optional
---
game/CMakeLists.txt | 19 ++++++++++++++++---
game/i18n.hh | 5 +++++
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/game/CMakeLists.txt b/game/CMakeLists.txt
index c823ded..e7e8ef0 100644
--- a/game/CMakeLists.txt
+++ b/game/CMakeLists.txt
@@ -20,19 +20,32 @@ else()
endif()
# Find all the libs that don't require extra parameters
-foreach(lib ${OUR_LIBS} SDL PangoCairo LibRSVG LibXML++ Magick++ GLEW AVFormat SWScale OpenGL Gettext Z Jpeg Tiff Png)
+foreach(lib ${OUR_LIBS} SDL PangoCairo LibRSVG LibXML++ Magick++ GLEW AVFormat SWScale OpenGL Z Jpeg Tiff Png)
find_package(${lib} REQUIRED)
include_directories(${${lib}_INCLUDE_DIRS})
list(APPEND LIBS ${${lib}_LIBRARIES})
add_definitions(${${lib}_DEFINITIONS})
endforeach(lib)
+find_package(Gettext)
+if(Gettext_FOUND)
+ include_directories(${Gettext_INCLUDE_DIRS})
+ list(APPEND LIBS ${Gettext_LIBRARIES})
+ add_definitions("-DHAVE_GETTEXT")
+ message(STATUS "Internationalization: Enabled")
+else()
+ message(STATUS "Internationalization: Disabled (libintl not found)")
+endif()
+
find_package(PortMidi)
if(PortMidi_FOUND)
- include_directories(PortMidi_INCLUDE_DIRS)
+ include_directories(${PortMidi_INCLUDE_DIRS})
list(APPEND LIBS ${PortMidi_LIBRARIES})
add_definitions("-DHAVE_PORTMIDI")
-endif(PortMidi_FOUND)
+ message(STATUS "MIDI I/O: Enabled")
+else()
+ message(STATUS "MIDI I/O: Disabled (libportmidi not found)")
+endif()
# Set default compile flags for GCC
if(CMAKE_COMPILER_IS_GNUCXX)
diff --git a/game/i18n.hh b/game/i18n.hh
index ed353e1..83c74f1 100644
--- a/game/i18n.hh
+++ b/game/i18n.hh
@@ -1,6 +1,11 @@
#pragma once
+#ifdef HAVE_GETTEXT
/* Internationalization Dependances */
#include <libintl.h>
#include <locale.h>
#define _(x) gettext(x)
+#else
+#define _(x) (x)
+#endif
+
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-12-10 23:06:26
|
Module: performous
Branch: master
Commit: 6dde984a0e21ad1a61c756fc426dfa7dbaddc21d
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Dec 11 01:06:11 2009 +0200
Some updates and added development model to DeveloperReadme.txt
---
docs/DeveloperReadme.txt | 57 +++++++++++++++++++++++++++++++++++++++++----
1 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/docs/DeveloperReadme.txt b/docs/DeveloperReadme.txt
index 84d2a5a..f061f32 100644
--- a/docs/DeveloperReadme.txt
+++ b/docs/DeveloperReadme.txt
@@ -101,11 +101,11 @@ std::runtime_error (for errors in input data, etc) or std::logic_error
Indentation is one tab character per a pair of {}. Long lines that are
split over several use "small indent" of two spaces. Labels (public/private,
-case/default) are one level "higher" than they should (i.e. one less tab) but
-have a small indent of two spaces instead. Do not try to align anything with the
-next/previous line of code. Maintaining the alignment wastes time and it also
-easily breaks with Emacs (which cannot understand that it should not convert
-those spaces that you used for alignment into tab characters).
+case/default) are one level "higher" than they should (i.e. one less tab).
+Do not try to align anything with the next/previous line of code. Maintaining
+the alignment wastes time and it also easily breaks with Emacs (which cannot
+understand that it should not convert those spaces that you used for alignment
+into tab characters).
We prefer short and simple code. E-g- if (foo) bar(); is easiest to read when it
is all on one line, so don't make it three or four lines long by adding braces,
@@ -115,11 +115,58 @@ When you can, use "if" with return, break, continue and throw to handle
conditional situations instead of using if-elses. This makes the code much
easier to read.
+Do not use switch-case for anything but enum values (and never provide default
+label in that case). Just use ifs that break execution (return, continue,
+break or throw) or if-else structures.
+
+Rationale: The switch statement is very badly designed. There are no blocks
+around cases by default, so if you need to define variables, you need to add
+a block yourself (causing total two levels of indentation). It is also very easy
+to forget a break, causing incorrect and hard-to-debug errors that you will get
+no compile warnings for. Additionally, you won't be able to break out of a
+surrounding loop like you can with if-elses. The reason why enum values can and
+should still be handled with switch-case is that GCC gives a warning if you do
+not handle all possible values, therefore catching a class of hard-to-find bugs
+and outweighting the other disadvantages of switch statements.
+
Write more comments than we do! (to describe the intention, larger logical
blocks of code and the external behavior of functions, but do not duplicate your
C++ in English).
+Development model: (adding a new feature)
+
+1. Make things work (with minimal functionality)
+2. Clean up the code (trying to minimize the amount of code)
+3. Add functionality
+4. Repeat from step 2 until the feature is done
+
+Each step includes the necessary testing to make sure that the code works. At
+least one git commit should be done for each step. Atomic commits are preferred.
+
+If you are not sufficiently familiar with C++, ask other developers to help with
+the cleanup phase.
+
+Doing very rapid development also means that the git trunk may be broken at
+times. Bigger features that may cause breakage for more than a few hours
+(therefore disturbing other developers) or that may require postponing a release
+by several days should be done in separate branches and only merged to master
+once the problems have been sorted out. The separate branches should also merge
+master to them quite often to avoid becoming incompatible with the master
+branch.
+
+If you are working on master branch, avoid pushing your changes if they break
+compiling or any existing functionality. As long as the commits are in your
+local repository, they do not disturb other developers. On the other hand, you
+still should push often (a partially implemented feature doesn't usually cause
+problems). Frequent pushing allows other developers to follow what you are doing
+and comment on it.
+
+TDD hasn't been used, as it doesn't seem suitable for game developement where
+there are no specifications to follow (you only find out what you will be doing
+after implementing some of it). Writing useful tests for code dealing with
+graphics, threads etc. is also very difficult.
+
TODO: move the documentation in this file to the website developers page?
|
|
From: Jaakko N. <jni...@us...> - 2009-12-10 21:31:17
|
Module: performous Branch: dance Commit: 06086cda1b93f2c9ecffdc3a613b92f5d3ed21b2 Author: Jaakko Nikkola <jaa...@tk...> Date: Thu Dec 10 23:30:19 2009 +0200 Fixed the parser to parse the last measure. --- game/songparser-sm.cc | 193 ++++++++++++++++++++++++------------------------- 1 files changed, 93 insertions(+), 100 deletions(-) |
|
From: Stefano A. <xa...@us...> - 2009-12-10 21:26:16
|
Module: performous
Branch: master
Commit: dd01f1ef94a2ff7cbdef9c5fe122bb7b582a518f
Author: Xaldyz <xa...@us...>
Date: Thu Dec 10 22:25:56 2009 +0100
Find gettext detection
---
cmake/Modules/FindGettext.cmake | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/cmake/Modules/FindGettext.cmake b/cmake/Modules/FindGettext.cmake
index eb5b325..713b150 100644
--- a/cmake/Modules/FindGettext.cmake
+++ b/cmake/Modules/FindGettext.cmake
@@ -10,18 +10,18 @@
include(LibFindMacros)
-libfind_pkg_check_modules(gettext_PKGCONF gettext)
+libfind_pkg_check_modules(Gettext_PKGCONF Gettext)
-find_path(gettext_INCLUDE_DIR
+find_path(Gettext_INCLUDE_DIR
NAMES libintl.h
- PATHS ${gettext_PKGCONF_INCLUDE_DIRS}
+ PATHS ${Gettext_PKGCONF_INCLUDE_DIRS}
)
-find_library(gettext_LIBRARY
+find_library(Gettext_LIBRARY
NAMES libintl
- PATHS ${gettext_PKGCONF_LIBRARY_DIRS}
+ PATHS ${Gettext_PKGCONF_LIBRARY_DIRS}
)
-set(gettext_PROCESS_INCLUDES gettext_INCLUDE_DIR)
-set(gettext_PROCESS_LIBS gettext_LIBRARY)
+set(Gettext_PROCESS_INCLUDES Gettext_INCLUDE_DIR)
+set(Gettext_PROCESS_LIBS Gettext_LIBRARY)
libfind_process(Gettext)
|
|
From: Tapio V. <aa...@us...> - 2009-12-10 21:08:05
|
Module: performous
Branch: dance
Commit: f845b39ec1d27bcde802fd5ad7fb853bc1ea94b8
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 23:07:03 2009 +0200
Improvements into dance hold note drawing.
---
game/dancegraph.cc | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 482c470..b1eb290 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -334,15 +334,17 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
note.hitAnim.setTarget(1.0, false);
}
double glow = note.hitAnim.get();
+
+ // Modify hold drawing coordinates
+ if (note.isHit && note.releaseTime <= 0) {
+ yBeg = std::max(time2y(0.0), yBeg);
+ yEnd = std::max(time2y(0.0), yEnd);
+ }
+ if (note.releaseTime > 0) yBeg = time2y(note.releaseTime - time);
if (yEnd - yBeg > arrowSize) {
- // Draw holds
- if (note.isHit && note.releaseTime <= 0) {
- yBeg = std::max(time2y(0.0), yBeg);
- yEnd = std::max(time2y(0.0), yEnd);
- }
- if (note.releaseTime > 0) yBeg = time2y(note.releaseTime - time);
- if (yEnd - yBeg > 0) {
+ // Draw hold
+ {
UseTexture tblock(m_arrows_hold);
glutil::Begin block(GL_TRIANGLE_STRIP);
// Draw end
@@ -353,10 +355,6 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
vertexPair(arrow_i, x, yBeg+arrowSize, 1.0f/3.0f);
}
// Draw begin
- if (note.isHit && tEnd < 0.1) {
- glColor4f(1.0f, 1.0f, 1.0f, 1.0 - glow);
- s += glow;
- }
drawArrow(arrow_i, m_arrows_hold, x, yBeg, s, 0.0f, 1.0f/3.0f);
} else {
// Draw short note
|
|
From: Tapio V. <aa...@us...> - 2009-12-10 21:08:02
|
Module: performous Branch: dance Commit: 4b1dbe4b93d6080d447a9ab9410863ad964cb534 Author: Tapio Vierros <tap...@gm...> Date: Thu Dec 10 22:37:22 2009 +0200 Clean up some coloring left behind from change to separate arrow images. Also some tweks to arrow graphics. --- game/dancegraph.cc | 13 +- themes/default/arrows.svg | 146 +++++++++--- themes/default/arrows_cursor.svg | 425 ++++++++++++++++++++++++++++++-- themes/default/arrows_hold.svg | 498 ++++++++++++++++++++++++++++++++++++-- 4 files changed, 994 insertions(+), 88 deletions(-) |
|
From: Matti K. <mpk...@us...> - 2009-12-10 18:09:09
|
Module: performous
Branch: dance
Commit: 452ca0e577ab2a4bfb51f5429848283c8e6322f1
Author: Matti Kemppainen <mpk...@us...>
Date: Thu Dec 10 20:08:44 2009 +0200
USB dancepad
---
game/dancegraph.cc | 2 +-
game/joystick.cc | 16 +++++++++++++---
game/joystick.hh | 19 ++++++++++++++-----
3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index b0ab6cb..021cf26 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -41,7 +41,7 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_level(BEGINNER),
m_audio(audio),
m_song(song),
- m_input(input::GUITAR), // TODO: to be replaced by DANCEPAD
+ m_input(input::DANCEPAD), // TODO: to be replaced by DANCEPAD
m_arrows(getThemePath("arrows.svg")),
m_arrows_cursor(getThemePath("arrows_cursor.svg")),
m_arrows_hold(getThemePath("arrows_hold.svg")),
diff --git a/game/joystick.cc b/game/joystick.cc
index 3b0e42e..0430630 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -23,16 +23,18 @@ void input::MidiDrums::process() {
}
#endif
-static const unsigned SDL_BUTTONS = 6;
+static const unsigned SDL_BUTTONS = 10;
int buttonFromSDL(input::Private::Type _type, unsigned int _sdl_button) {
- static const int inputmap[4][SDL_BUTTONS] = {
+ static const int inputmap[5][SDL_BUTTONS] = {
//G R Y B O // for guitars
{ 2, 0, 1, 3, 4, -1 }, // Guitar Hero guitar
{ 3, 0, 1, 2, 4, -1 }, // Rock Band guitar
//K R Y B G O // for drums
{ 3, 4, 1, 2, 0, 4 }, // Guitar Hero drums
- { 3, 4, 1, 2, 0, -1 } // Rock Band drums
+ { 3, 4, 1, 2, 0, -1 }, // Rock Band drums
+ // Left Down Up Right DownL DownR UpL UpR Enter Select
+ { 0, 2, 1, 3 } /* 4, 5, 6, 7, 8, 9 } */ // generic dance pad
};
if( _sdl_button >= SDL_BUTTONS ) return -1;
switch(_type) {
@@ -44,6 +46,8 @@ int buttonFromSDL(input::Private::Type _type, unsigned int _sdl_button) {
return inputmap[2][_sdl_button];
case input::Private::DRUMS_RB:
return inputmap[3][_sdl_button];
+ case input::Private::DANCEPAD_GENERIC:
+ return inputmap[4][_sdl_button];
default:
return -1;
}
@@ -140,6 +144,9 @@ void input::SDL::init() {
case input::Private::DRUMS_MIDI:
std::cout << " Detected as: MIDI Drums (forced)" << std::endl;
break;
+ case input::Private::DANCEPAD_GENERIC:
+ std::cout << " Detected as: Generic dance pad" << std::endl;
+ break;
}
input::Private::devices[i] = input::Private::InputDevPrivate(forced_type[i]);
} else if( name.find("Guitar Hero3") != std::string::npos ) {
@@ -158,6 +165,9 @@ void input::SDL::init() {
} else if( name.find("Harmonix Drum kit") != std::string::npos ) {
std::cout << " Detected as: RockBand Drums" << std::endl;
input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::DRUMS_RB);
+ } else if( name.find("RedOctane USB Pad") != std::string::npos ) {
+ std::cout << " Detected as: Generic Dance Pad" << std::endl;
+ input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::DANCEPAD_GENERIC);
} else {
std::cout << " Detected as: Unknwown (please report the name, assuming Guitar Hero Drums)" << std::endl;
input::Private::devices[i] = input::Private::InputDevPrivate(input::Private::DRUMS_GH);
diff --git a/game/joystick.hh b/game/joystick.hh
index ea59fc8..538186d 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -18,7 +18,7 @@
namespace input {
enum DevType { GUITAR, DRUMS, DANCEPAD };
- static const std::size_t BUTTONS = 6;
+ static const std::size_t BUTTONS = 10;
struct Event {
enum Type { PRESS, RELEASE, PICK, WHAMMY };
@@ -30,7 +30,7 @@ namespace input {
};
namespace Private {
- enum Type {GUITAR_RB, DRUMS_RB, GUITAR_GH, DRUMS_GH, DRUMS_MIDI};
+ enum Type { GUITAR_RB, DRUMS_RB, GUITAR_GH, DRUMS_GH, DRUMS_MIDI, DANCEPAD_GENERIC };
static unsigned int KEYBOARD_ID = UINT_MAX;
class InputDevPrivate {
public:
@@ -76,10 +76,17 @@ namespace input {
if( _type == input::GUITAR &&
(m_type == input::Private::GUITAR_GH || m_type == input::Private::GUITAR_RB) ) {
return true;
- } else if( _type == input::DRUMS &&
+ }
+ else if( _type == input::DRUMS &&
(m_type == input::Private::DRUMS_GH || m_type == input::Private::DRUMS_RB || m_type == input::Private::DRUMS_MIDI) ) {
return true;
- } else {
+ }
+ else if( _type == input::DANCEPAD && (m_type == input::Private::DANCEPAD_GENERIC
+ || m_type == input::Private::GUITAR_GH // for keyboard controlling
+ )) {
+ return true;
+ }
+ else {
return false;
}
};
@@ -105,6 +112,8 @@ namespace input {
std::cout << "Request acquiring DRUM" << std::endl;
if( _type == input::GUITAR )
std::cout << "Request acquiring GUITAR" << std::endl;
+ if( _type == input::DANCEPAD )
+ std::cout << "Request acquiring DANCEPAD" << std::endl;
if( devices.size() == 0 ) throw std::runtime_error("No InputDev available");
for(InputDevs::iterator it = devices.begin() ; it != devices.end() ; ++it) {
if( it->first == input::Private::KEYBOARD_ID && !config["game/keyboard_guitar"].b()) continue;
@@ -115,7 +124,7 @@ namespace input {
return;
}
}
- std::cout << "Not Found" << std::endl;
+ std::cout << "No InputDev was found!" << std::endl;
throw std::runtime_error("No matching instrument available");
};
~InputDev() {
|
|
From: Tapio V. <aa...@us...> - 2009-12-10 09:13:11
|
Module: performous
Branch: master
Commit: fc5789ab5bda550b30d5a6fd45e76cf5d290ca43
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 11:11:45 2009 +0200
Make notes slighly faster in guitargraph.
---
game/guitargraph.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 8bd687f..d4d748a 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -20,7 +20,7 @@ namespace {
const float g_angle = 80.0f;
const float past = -0.2f;
- const float future = 1.8f;
+ const float future = 1.5f;
const float timescale = 25.0f;
const float texCoordStep = -0.5f; // Two beat lines per neck texture => 0.5 tex units per beat
// Note: t is difference from playback time so it must be in range [past, future]
|
|
From: Tapio V. <aa...@us...> - 2009-12-10 09:13:09
|
Module: performous
Branch: master
Commit: 5ffd3ea7599d8a03bdc992d6f67abeb51058c7bc
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 11:03:16 2009 +0200
Long streaks give bonus points to starmeter.
---
game/guitargraph.cc | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 5c251e1..8bd687f 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -41,6 +41,7 @@ namespace {
return score;
}
+ const int streakStarBonus = 500;
int getNextBigStreak(int prev) { return prev + 50; }
inline float blend(float a, float b, float f) { return a*f + b*(1.0f-f); }
@@ -213,6 +214,7 @@ void GuitarGraph::engine() {
if (m_streak >= getNextBigStreak(m_bigStreak)) {
m_streakPopup.setTarget(1.0);
m_bigStreak = getNextBigStreak(m_bigStreak);
+ m_starmeter += streakStarBonus;
}
if (m_starpower.get() > 0.01) m_correctness.setTarget(1.0, true);
}
|
|
From: Tapio V. <aa...@us...> - 2009-12-10 09:13:05
|
Module: performous
Branch: master
Commit: 0692d350a77765fa73f2b6c0c38412166fb0b295
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 10:59:33 2009 +0200
Fixed popups always being centered on the screen rather than on each neck.
---
game/guitargraph.cc | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index eeb09c3..5c251e1 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -645,7 +645,7 @@ void GuitarGraph::drawInfo(double time, double offsetX) {
double s = 0.2 * (1.0 + streakAnim);
glColor4f(1.0f, 0.0f, 0.0f, 1.0 - streakAnim);
m_popupText->render(boost::lexical_cast<std::string>(unsigned(m_bigStreak)) + "\nStreak!");
- m_popupText->dimensions().center(0.1).middle(0.0).stretch(s,s);
+ m_popupText->dimensions().center(0.1).middle(offsetX).stretch(s,s);
m_popupText->draw();
if (streakAnim > 0.999) m_streakPopup.setTarget(0.0, true);
}
@@ -656,12 +656,12 @@ void GuitarGraph::drawInfo(double time, double offsetX) {
float s = 0.2 * (1.0 + godAnim);
glColor4f(0.3f, 0.0f, 1.0f, a);
m_popupText->render("God Mode\nActivated!");
- m_popupText->dimensions().center(0.1).middle(0.0).stretch(s,s);
+ m_popupText->dimensions().center(0.1).middle(offsetX).stretch(s,s);
m_popupText->draw();
s = 0.12 * (1.0 + godAnim);
glColor4f(0.8f, 0.8f, 1.0f, a);
m_popupText->render("Mistakes ignored");
- m_popupText->dimensions().center(0.26).middle(0.0).stretch(s, s/5.0);
+ m_popupText->dimensions().center(0.26).middle(offsetX).stretch(s, s/5.0);
m_popupText->draw();
if (godAnim > 0.999) m_godmodePopup.setTarget(0.0, true);
}
|
|
From: Tapio V. <aa...@us...> - 2009-12-10 09:12:45
|
Module: performous
Branch: dance
Commit: 3f249909360da55d857d39a3e13569a5822a1f44
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 10:48:00 2009 +0200
Notes are only displayed if the player is joined.
Joining is possible also in the middle of a game.
---
game/dancegraph.cc | 122 +++++++++++++++++++++++++++-------------------------
game/dancegraph.hh | 1 +
2 files changed, 64 insertions(+), 59 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index edd505f..b0ab6cb 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -11,6 +11,7 @@ namespace {
const float past = -0.4f;
const float future = 2.0f;
const float timescale = 7.0f;
+ const float join_delay = 5.0f; // how long player has time to choose difficulty when joining in the middle
// Note: t is difference from playback time so it must be in range [past, future]
float time2y(float t) { return timescale * (t - past) / (future - past); }
float time2a(float t) {
@@ -49,6 +50,7 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_width(0.5, 0.4),
m_stream(),
m_dead(1000),
+ m_jointime(0),
m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()),
m_correctness(0.0, 5.0),
m_streakPopup(0.0, 1.0),
@@ -106,6 +108,7 @@ void DanceGraph::engine() {
// Handle all events
for (input::Event ev; m_input.tryPoll(ev);) {
m_dead = false;
+ if (m_jointime == 0) m_jointime = (time < 0.0 ? -join_delay : time);
if(ev.button < 0 || ev.button > 3)
continue;
if (time < -0.5) {
@@ -246,72 +249,73 @@ void DanceGraph::draw(double time) {
dimensions.screenTop().middle(m_cx.get()).stretch(m_width.get(), 1.0);
double offsetX = 0.5 * (dimensions.x1() + dimensions.x2());
double frac = 0.75; // Adjustable: 1.0 means fully separated, 0.0 means fully attached
- // Draw scores
- if (time >= -0.5) {
+ if (time < -0.5 || m_jointime == 0 || time - m_jointime < join_delay) {
+ if (m_jointime == 0) {
+ m_popupText->render("Choose difficulty/mode\nto enter the game!");
+ m_popupText->dimensions().center(0.0).middle(0.0 + offsetX).stretch(0.3, 0.15);
+ m_popupText->draw();
+ }
+ m_text.dimensions.screenBottom(-0.075).middle(-0.09 + offsetX);
+ m_text.draw("^ " + getDifficultyString() + " v");
+ m_text.dimensions.screenBottom(-0.050).middle(-0.09 + offsetX);
+ m_text.draw(getGameMode());
+ } else {
+ // Draw scores
m_text.dimensions.screenBottom(-0.35).middle(0.32 * dimensions.w() + offsetX);
m_text.draw(boost::lexical_cast<std::string>(unsigned(getScore())));
m_text.dimensions.screenBottom(-0.32).middle(0.32 * dimensions.w() + offsetX);
m_text.draw(boost::lexical_cast<std::string>(unsigned(m_streak)) + "/"
+ boost::lexical_cast<std::string>(unsigned(m_longestStreak)));
- } else {
- // TODO: only display if help if not pressed anything
- m_popupText->render("Choose difficulty/mode\nto enter the game!");
- m_popupText->dimensions().center(0.0).middle(0.0 + offsetX).stretch(0.3, 0.15);
- m_popupText->draw();
- m_text.dimensions.screenBottom(-0.075).middle(-0.09 + offsetX);
- m_text.draw("^ " + getDifficultyString() + " v");
- m_text.dimensions.screenBottom(-0.050).middle(-0.09 + offsetX);
- m_text.draw(getGameMode());
- }
- { glutil::PushMatrixMode pmm(GL_PROJECTION);
- { glutil::Translation tr1(frac * 2.0 * offsetX, 0.0f, 0.0f);
- { glutil::PushMatrixMode pmb(GL_MODELVIEW);
- { glutil::Translation tr2((1.0 - frac) * offsetX, dimensions.y1(), 0.0f);
- { float temp_s = dimensions.w() / 5.0f;
- glutil::Scale sc1(temp_s, temp_s, temp_s);
-
- // Arrows on cursor
- for (int arrow_i = 0; arrow_i < 4; ++arrow_i) {
- float x = -1.5f + arrow_i;
- float y = time2y(0.0);
- float l = m_pressed_anim[arrow_i].get();
- float s = (5.0 - l) / 5.0;
- glutil::Color c = color(arrow_i);
- c.r += l; c.g += l; c.b +=l;
- glColor4fv(c);
- drawArrow(arrow_i, m_arrows_cursor, x, y, s);
- }
-
- // Draw the notes
- for (DanceNotes::iterator it = m_notes.begin(); it != m_notes.end(); ++it) {
- if (it->note.end - time < past) continue;
- if (it->note.begin - time > future) break;
- drawNote(*it, time);
- }
+ // Some matrix magic to get the viewport right
+ { glutil::PushMatrixMode pmm(GL_PROJECTION);
+ { glutil::Translation tr1(frac * 2.0 * offsetX, 0.0f, 0.0f);
+ { glutil::PushMatrixMode pmb(GL_MODELVIEW);
+ { glutil::Translation tr2((1.0 - frac) * offsetX, dimensions.y1(), 0.0f);
+ { float temp_s = dimensions.w() / 5.0f;
+ glutil::Scale sc1(temp_s, temp_s, temp_s);
+
+ // Arrows on cursor
+ for (int arrow_i = 0; arrow_i < 4; ++arrow_i) {
+ float x = -1.5f + arrow_i;
+ float y = time2y(0.0);
+ float l = m_pressed_anim[arrow_i].get();
+ float s = (5.0 - l) / 5.0;
+ glutil::Color c = color(arrow_i);
+ c.r += l; c.g += l; c.b +=l;
+ glColor4fv(c);
+ drawArrow(arrow_i, m_arrows_cursor, x, y, s);
+ }
+
+ // Draw the notes
+ for (DanceNotes::iterator it = m_notes.begin(); it != m_notes.end(); ++it) {
+ if (it->note.end - time < past) continue;
+ if (it->note.begin - time > future) break;
+ drawNote(*it, time);
+ }
- // To test arrow coordinate positioning
- //for (float i = past; i <= future; i+=0.2) {
- //std::cout << i << ": " << time2y(i) << std::endl;
- //drawArrow(1, 0, time2y(i), 0.6);
- //}
-
- } //< reverse scale sc1
- } //< reverse trans tr2
- } //< reverse push pmb
- } //< reverse trans tr1
- } //< reverse push pmm
-
- // Draw streak pop-up for long streak intervals
- double streakAnim = m_streakPopup.get();
- if (streakAnim > 0.0) {
- double s = 0.15 * (1.0 + streakAnim);
- glColor4f(1.0f, 0.0f, 0.0f, 1.0 - streakAnim);
- m_popupText->render(boost::lexical_cast<std::string>(unsigned(m_bigStreak)) + "\nStreak!");
- m_popupText->dimensions().center(0.0).middle(offsetX).stretch(s,s);
- m_popupText->draw();
- if (streakAnim > 0.999) m_streakPopup.setTarget(0.0, true);
+ // To test arrow coordinate positioning
+ //for (float i = past; i <= future; i+=0.2) {
+ //std::cout << i << ": " << time2y(i) << std::endl;
+ //drawArrow(1, 0, time2y(i), 0.6);
+ //}
+
+ } //< reverse scale sc1
+ } //< reverse trans tr2
+ } //< reverse push pmb
+ } //< reverse trans tr1
+ } //< reverse push pmm
+
+ // Draw streak pop-up for long streak intervals
+ double streakAnim = m_streakPopup.get();
+ if (streakAnim > 0.0) {
+ double s = 0.15 * (1.0 + streakAnim);
+ glColor4f(1.0f, 0.0f, 0.0f, 1.0 - streakAnim);
+ m_popupText->render(boost::lexical_cast<std::string>(unsigned(m_bigStreak)) + "\nStreak!");
+ m_popupText->dimensions().center(0.0).middle(offsetX).stretch(s,s);
+ m_popupText->draw();
+ if (streakAnim > 0.999) m_streakPopup.setTarget(0.0, true);
+ }
}
-
glColor3f(1.0f, 1.0f, 1.0f);
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 150f51f..a54d7a4 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -83,6 +83,7 @@ class DanceGraph {
bool m_pressed[4];
AnimValue m_pressed_anim[4];
int m_dead;
+ double m_jointime;
SvgTxtTheme m_text;
boost::scoped_ptr<SvgTxtThemeSimple> m_popupText;
AnimValue m_correctness;
|
|
From: Tapio V. <aa...@us...> - 2009-12-10 08:00:00
|
Module: performous
Branch: dance
Commit: 525c6d55f7c0be1940488c362394fa2df962ff51
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 09:58:59 2009 +0200
Fixed combo popup always appearing in the center of the screen.
---
game/dancegraph.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 2f879c5..edd505f 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -307,7 +307,7 @@ void DanceGraph::draw(double time) {
double s = 0.15 * (1.0 + streakAnim);
glColor4f(1.0f, 0.0f, 0.0f, 1.0 - streakAnim);
m_popupText->render(boost::lexical_cast<std::string>(unsigned(m_bigStreak)) + "\nStreak!");
- m_popupText->dimensions().center(0.0).middle(0.0).stretch(s,s);
+ m_popupText->dimensions().center(0.0).middle(offsetX).stretch(s,s);
m_popupText->draw();
if (streakAnim > 0.999) m_streakPopup.setTarget(0.0, true);
}
|
|
From: Tapio V. <aa...@us...> - 2009-12-10 07:59:57
|
Module: performous
Branch: dance
Commit: 768c0c133612d2b1d6949c6e22fd1afdb3b552c3
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 09:56:54 2009 +0200
Tweaks to difficulty selection texts.
---
game/dancegraph.cc | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 413fbfe..2f879c5 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -248,15 +248,19 @@ void DanceGraph::draw(double time) {
double frac = 0.75; // Adjustable: 1.0 means fully separated, 0.0 means fully attached
// Draw scores
if (time >= -0.5) {
- m_text.dimensions.screenBottom(-0.30).middle(0.32 * dimensions.w() + offsetX);
+ m_text.dimensions.screenBottom(-0.35).middle(0.32 * dimensions.w() + offsetX);
m_text.draw(boost::lexical_cast<std::string>(unsigned(getScore())));
- m_text.dimensions.screenBottom(-0.27).middle(0.32 * dimensions.w() + offsetX);
+ m_text.dimensions.screenBottom(-0.32).middle(0.32 * dimensions.w() + offsetX);
m_text.draw(boost::lexical_cast<std::string>(unsigned(m_streak)) + "/"
+ boost::lexical_cast<std::string>(unsigned(m_longestStreak)));
} else {
- m_text.dimensions.screenBottom(-0.041).middle(-0.09 + offsetX);
- m_text.draw(getDifficultyString());
- m_text.dimensions.screenBottom(-0.015).middle(-0.09 + offsetX);
+ // TODO: only display if help if not pressed anything
+ m_popupText->render("Choose difficulty/mode\nto enter the game!");
+ m_popupText->dimensions().center(0.0).middle(0.0 + offsetX).stretch(0.3, 0.15);
+ m_popupText->draw();
+ m_text.dimensions.screenBottom(-0.075).middle(-0.09 + offsetX);
+ m_text.draw("^ " + getDifficultyString() + " v");
+ m_text.dimensions.screenBottom(-0.050).middle(-0.09 + offsetX);
m_text.draw(getGameMode());
}
{ glutil::PushMatrixMode pmm(GL_PROJECTION);
@@ -337,8 +341,6 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
yBeg = std::max(time2y(0.0), yBeg);
yEnd = std::max(time2y(0.0), yEnd);
glColor3f(1.0f, 1.0f, 1.0f);
- // Hack to test hold releasing
- //if (time > note.note.begin + 1) note.releaseTime = time;
}
if (note.releaseTime > 0) yBeg = time2y(note.releaseTime - time);
if (yEnd - yBeg > 0) {
|
|
From: Tapio V. <aa...@us...> - 2009-12-10 07:59:55
|
Module: performous Branch: dance Commit: bbf8af6180744ffd52289465dcfb4089d92273fc Author: Tapio Vierros <tap...@gm...> Date: Thu Dec 10 09:52:14 2009 +0200 Modifications to arrow images. --- themes/default/arrows.svg | 107 ++++++++++++++++++++++++++++++++++++--- themes/default/arrows_hold.svg | 54 ++++++++++---------- 2 files changed, 125 insertions(+), 36 deletions(-) |
|
From: Tapio V. <aa...@us...> - 2009-12-09 22:38:23
|
Module: performous
Branch: dance
Commit: 4dcc74b328b3104269298dde5950d39bc6c0f85f
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 00:36:06 2009 +0200
Hack to test streak popup.
---
game/dancegraph.cc | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index b6c9e9a..413fbfe 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -178,6 +178,8 @@ void DanceGraph::dance(double time, input::Event const& ev) {
<< "; " << p << " points." << std::endl;
it->score = p;
m_score += p;
+
+ m_streak++; // Hack to test streak popup
}
}
}
|
|
From: Tapio V. <aa...@us...> - 2009-12-09 22:38:21
|
Module: performous
Branch: dance
Commit: fa57d47a37db132d2a2fa210d8caae7502b17d85
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 00:34:15 2009 +0200
Popup for long streak intervals.
---
game/dancegraph.cc | 40 +++++++++++++++++++++++++++++++++-------
game/dancegraph.hh | 2 ++
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 028fc21..b6c9e9a 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -19,6 +19,7 @@ namespace {
}
float y2a(float y) { return time2a(past - y / timescale * (future - past)); }
const double maxTolerance = 0.15;
+ int getNextBigStreak(int prev) { return prev + 10; }
// TODO: Use this or something else?
double points(double error) {
@@ -50,11 +51,13 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_dead(1000),
m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()),
m_correctness(0.0, 5.0),
+ m_streakPopup(0.0, 1.0),
m_flow_direction(1),
m_score(),
m_scoreFactor(1),
m_streak(),
m_longestStreak(),
+ m_bigStreak(),
m_gamingMode("dance-single")
{
@@ -135,6 +138,11 @@ void DanceGraph::engine() {
<< "(note timing " << it->note.begin << ")" << std::endl;
}*/
+ // Check if a long streak goal has been reached
+ if (m_streak >= getNextBigStreak(m_bigStreak)) {
+ m_streakPopup.setTarget(1.0);
+ m_bigStreak = getNextBigStreak(m_bigStreak);
+ }
}
@@ -249,12 +257,13 @@ void DanceGraph::draw(double time) {
m_text.dimensions.screenBottom(-0.015).middle(-0.09 + offsetX);
m_text.draw(getGameMode());
}
- glutil::PushMatrixMode pmm(GL_PROJECTION);
- glTranslatef(frac * 2.0 * offsetX, 0.0f, 0.0f);
- glutil::PushMatrixMode pmb(GL_MODELVIEW);
- glTranslatef((1.0 - frac) * offsetX, dimensions.y1(), 0.0f);
- { float s = dimensions.w() / 5.0f; glScalef(s, s, s); }
-
+ { glutil::PushMatrixMode pmm(GL_PROJECTION);
+ { glutil::Translation tr1(frac * 2.0 * offsetX, 0.0f, 0.0f);
+ { glutil::PushMatrixMode pmb(GL_MODELVIEW);
+ { glutil::Translation tr2((1.0 - frac) * offsetX, dimensions.y1(), 0.0f);
+ { float temp_s = dimensions.w() / 5.0f;
+ glutil::Scale sc1(temp_s, temp_s, temp_s);
+
// Arrows on cursor
for (int arrow_i = 0; arrow_i < 4; ++arrow_i) {
float x = -1.5f + arrow_i;
@@ -279,7 +288,24 @@ void DanceGraph::draw(double time) {
//std::cout << i << ": " << time2y(i) << std::endl;
//drawArrow(1, 0, time2y(i), 0.6);
//}
-
+
+ } //< reverse scale sc1
+ } //< reverse trans tr2
+ } //< reverse push pmb
+ } //< reverse trans tr1
+ } //< reverse push pmm
+
+ // Draw streak pop-up for long streak intervals
+ double streakAnim = m_streakPopup.get();
+ if (streakAnim > 0.0) {
+ double s = 0.15 * (1.0 + streakAnim);
+ glColor4f(1.0f, 0.0f, 0.0f, 1.0 - streakAnim);
+ m_popupText->render(boost::lexical_cast<std::string>(unsigned(m_bigStreak)) + "\nStreak!");
+ m_popupText->dimensions().center(0.0).middle(0.0).stretch(s,s);
+ m_popupText->draw();
+ if (streakAnim > 0.999) m_streakPopup.setTarget(0.0, true);
+ }
+
glColor3f(1.0f, 1.0f, 1.0f);
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 1949e6b..150f51f 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -86,11 +86,13 @@ class DanceGraph {
SvgTxtTheme m_text;
boost::scoped_ptr<SvgTxtThemeSimple> m_popupText;
AnimValue m_correctness;
+ AnimValue m_streakPopup;
int m_flow_direction;
double m_score;
double m_scoreFactor;
int m_streak;
int m_longestStreak;
+ int m_bigStreak;
std::string m_gamingMode;
};
|
|
From: Tapio V. <aa...@us...> - 2009-12-09 22:38:19
|
Module: performous
Branch: dance
Commit: e9884d335a59398485b40d997b1fb0a5b6a74d71
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 00:33:24 2009 +0200
Some glutils from master.
---
game/glutil.hh | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/game/glutil.hh b/game/glutil.hh
index ad7f309..2d20d83 100644
--- a/game/glutil.hh
+++ b/game/glutil.hh
@@ -56,6 +56,33 @@ namespace glutil {
}
};
+ /// auto-reversing translation
+ struct Translation {
+ Translation(float _x, float _y, float _z = 0.0f): m_x(_x), m_y(_y), m_z(_z)
+ { glTranslatef(m_x, m_y, m_z); }
+ ~Translation() { glTranslatef(-m_x, -m_y, -m_z); }
+ private:
+ float m_x, m_y, m_z;
+ };
+
+ /// auto-reversing rotation
+ struct Rotation {
+ Rotation(float _a, float _x, float _y, float _z): m_a(_a), m_x(_x), m_y(_y), m_z(_z)
+ { glRotatef(m_a, m_x, m_y, m_z); }
+ ~Rotation() { glRotatef(-m_a, m_x, m_y, m_z); }
+ private:
+ float m_a, m_x, m_y, m_z;
+ };
+
+ /// auto-reversing scaling
+ struct Scale {
+ Scale(float _x, float _y, float _z): m_x(_x), m_y(_y), m_z(_z)
+ { glScalef(m_x, m_y, m_z); }
+ ~Scale() { glScalef(1.0/m_x, 1.0/m_y, 1.0/m_z); }
+ private:
+ float m_x, m_y, m_z;
+ };
+
/// struct to store color information
struct Color {
float r, ///< red component
|
|
From: Tapio V. <aa...@us...> - 2009-12-09 22:05:56
|
Module: performous
Branch: dance
Commit: 5f04e35c8f509b4b0cab842d2f9e42dc574cc9fa
Author: Tapio Vierros <tap...@gm...>
Date: Thu Dec 10 00:00:15 2009 +0200
Feedback on hitting accuracy.
---
game/dancegraph.cc | 22 +++++++++++++++++++++-
game/dancegraph.hh | 4 +++-
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 00608d3..028fc21 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -30,6 +30,7 @@ namespace {
if (error < maxTolerance / 6) score += 5;
return score;
}
+
}
@@ -57,6 +58,8 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_gamingMode("dance-single")
{
+ m_popupText.reset(new SvgTxtThemeSimple(getThemePath("sing_score_text.svg"), config["graphic/text_lod"].f()));
+
for(size_t i = 0; i < 4; i++) m_pressed[i] = false;
for(size_t i = 0; i < 4; i++) m_pressed_anim[i] = AnimValue(0.0, 4.0);
@@ -162,6 +165,7 @@ void DanceGraph::dance(double time, input::Event const& ev) {
<< "(difference " << (it->note.begin - time) << ")" << std::endl;
it->isHit = true;
double p = points(it->note.begin - time);
+ it->accuracy = 1.0 - (std::abs(it->note.begin - time) / maxTolerance);
std::cout << "Hit note " << ev.button << " at time " << time
<< "; " << p << " points." << std::endl;
it->score = p;
@@ -286,7 +290,8 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
int arrow_i = note.note.note;
bool mine = note.note.type == Note::MINE;
float x = -1.5f + arrow_i;
- float s = 1.0; //arrowScale;
+ float s = 1.0;
+ float ac = note.accuracy;
float yBeg = time2y(tBeg);
float yEnd = time2y(tEnd);
glutil::Color c = color(arrow_i);
@@ -338,4 +343,19 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
drawArrow(arrow_i, m_arrows, x, yBeg, s);
}
}
+ if (glow > 0 && ac > 0 && !mine) {
+ double s = 0.4 * (1.0 + glow);
+ glColor4fv(color(arrow_i));
+ std::string rank = "Horrible!";
+ if (ac > .90) rank = "Perfect!";
+ else if (ac > .80) rank = "Excellent!";
+ else if (ac > .70) rank = "Great!";
+ else if (ac > .60) rank = "Good!";
+ else if (ac > .50) rank = "OK!";
+ else if (ac > .40) rank = "Poor!";
+ else if (ac > .30) rank = "Bad!";
+ m_popupText->render(rank);
+ m_popupText->dimensions().middle(x).center(time2y(0.0)).stretch(s,s/2.0);
+ m_popupText->draw();
+ }
}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 8ae1999..1949e6b 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -14,10 +14,11 @@ class Song;
struct DanceNote {
DanceNote(Note note) :
- note(note), hitAnim(0.0, 5.0), releaseTime(0), score(0), isHit(false) {}
+ note(note), hitAnim(0.0, 5.0), releaseTime(0), accuracy(0), score(0), isHit(false) {}
Note note;
AnimValue hitAnim; /// for animating hits
double releaseTime; /// tells when a hold was ended
+ float accuracy; /// how accurate the hit was [0,1]
int score;
bool isHit;
};
@@ -83,6 +84,7 @@ class DanceGraph {
AnimValue m_pressed_anim[4];
int m_dead;
SvgTxtTheme m_text;
+ boost::scoped_ptr<SvgTxtThemeSimple> m_popupText;
AnimValue m_correctness;
int m_flow_direction;
double m_score;
|
|
From: Tapio V. <aa...@us...> - 2009-12-09 22:05:55
|
Module: performous
Branch: dance
Commit: 84853c4725686ce9f01e768b009180e35afdb5ab
Author: Tapio Vierros <tap...@gm...>
Date: Wed Dec 9 22:09:40 2009 +0200
Fix warnings about unhandled switch-cases.
---
game/notes.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/notes.cc b/game/notes.cc
index 1bfe3ae..16850e8 100644
--- a/game/notes.cc
+++ b/game/notes.cc
@@ -69,7 +69,7 @@ double Note::scoreMultiplier(double error) const {
case FREESTYLE: power += 1.0; return 1.0;
case NORMAL: case SLIDE: max = 1.0; break;
case GOLDEN: max = 2.0; break;
- case SLEEP: break;
+ case SLEEP: case TAP: case HOLDBEGIN: case HOLDEND: case MINE: break;
}
double accuracy = clamp(1.5 - error, 0.0, 1.0);
power += accuracy;
|
|
From: Jaakko N. <jni...@us...> - 2009-12-09 20:54:43
|
Module: performous
Branch: dance
Commit: 93a650f160b26c038190e8b3c2ad4b7d00a337a0
Author: Jaakko Nikkola <jaa...@tk...>
Date: Wed Dec 9 22:53:40 2009 +0200
Songparser modified to read more than one difficulty level. Also some other minor fixes were made.
---
game/songparser-sm.cc | 59 +++++++++++++++++++++++++++++++++---------------
game/songparser.hh | 4 ++-
2 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/game/songparser-sm.cc b/game/songparser-sm.cc
index 2054d92..f77f49d 100644
--- a/game/songparser-sm.cc
+++ b/game/songparser-sm.cc
@@ -32,6 +32,7 @@ namespace {
else throw std::runtime_error("Invalid boolean value: " + str);
}
int upper_case (int c) { return toupper (c); }
+ int lower_case (int c) { return tolower (c); }
}
@@ -50,7 +51,17 @@ void SongParser::smParse() {
if (m_song.danceTracks.empty() ) throw std::runtime_error("No note data in the file");
if (s.title.empty() || s.artist.empty()) throw std::runtime_error("Required header fields missing");
//if (m_bpm != 0.0) addBPM(0, m_bpm);
-}
+
+/*
+ if (m_song.danceTracks.find("EASY") != m_song.danceTracks.end() ) std::cout << "OK" << std::endl;
+ else std::cout << "WRONG TRACK" << std::endl;
+ if (m_song.danceTracks.find("MEDIUM") != m_song.danceTracks.end() ) std::cout << "OK" << std::endl;
+ else std::cout << "WRONG TRACK" << std::endl;
+ if (m_song.danceTracks.find("HARD") != m_song.danceTracks.end() ) std::cout << "OK" << std::endl;
+ else std::cout << "WRONG TRACK" << std::endl;
+*/
+}
+
bool SongParser::smParseField(std::string line) {
if (line.empty() || line == "\r") return true;
if (line[0] == '/' && line[1] == '/') return true; //jump over possible comments
@@ -61,20 +72,20 @@ bool SongParser::smParseField(std::string line) {
if (key == "NOTES") {
//Note values are analyzed here. Values are:
- bool endOfInput = false;
// TODO: NOTES header vars needs better way to strip trailing colon ':'
while (getline(line)) {
//<NotesType>:
//if(!getline(line)) { throw std::runtime_error("Required note data missing"); }
- std::string notestype = boost::trim_copy(line.substr(0, line.size() -2));
+ std::string notestype = boost::trim_copy(line.substr(0, line.find_first_of(':')));
+ transform(notestype.begin(), notestype.end(), notestype.begin(), lower_case );
//<Description>:
if(!getline(line)) { throw std::runtime_error("Required note data missing"); }
- std::string description = boost::trim_copy(line.substr(0, line.size() -2));
+ std::string description = boost::trim_copy(line.substr(0, line.find_first_of(':')));
+ //transform(description.begin(), description.end(), description.begin(), lower_case );
//<DifficultyClass>:
if(!getline(line)) { throw std::runtime_error("Required note data missing"); }
- std::string difficultyclass = boost::trim_copy(line.substr(0, line.size() -2));
- transform(difficultyclass.begin(), difficultyclass.end(),
- difficultyclass.begin(), upper_case );
+ std::string difficultyclass = boost::trim_copy(line.substr(0, line.find_first_of(':')));
+ transform(difficultyclass.begin(), difficultyclass.end(), difficultyclass.begin(), upper_case );
DanceDifficulty danceDifficulty = DIFFICULTYCOUNT;
if(difficultyclass == "BEGINNER") danceDifficulty = BEGINNER;
if(difficultyclass == "EASY") danceDifficulty = EASY;
@@ -91,20 +102,20 @@ bool SongParser::smParseField(std::string line) {
//std::string radarvalues = boost::trim_copy(line.substr(0, line.size() -2));
//<NoteData>:
- Notes notes = smParseNotes(line, endOfInput);
- if(endOfInput) throw std::runtime_error("end is here");
-
-
+ Notes notes = smParseNotes(line);
+
DanceTrack danceTrack(description, notes);
- DanceDifficultyMap danceDifficultyMap;
- danceDifficultyMap.insert(std::make_pair(danceDifficulty, danceTrack));
- m_song.danceTracks.insert(std::make_pair(notestype, danceDifficultyMap));
+ if (m_song.danceTracks.find(notestype) == m_song.danceTracks.end() ) {
+ DanceDifficultyMap danceDifficultyMap;
+ m_song.danceTracks.insert(std::make_pair(notestype, danceDifficultyMap));
+ }
+ m_song.danceTracks[notestype].insert(std::make_pair(danceDifficulty, danceTrack));
}
return false;
}
std::string value = boost::trim_copy(line.substr(pos + 1));
//values that continue to next line are handeled here
- while (value[value.size() -1] != ';') {
+ while (value[value.size() -1] != ';') {
std::string str;
getline (str);
value += boost::trim_copy(str);
@@ -127,7 +138,18 @@ bool SongParser::smParseField(std::string line) {
if (!(iss >> chr)) break;
}
}
- /*additionally .sm fileformat has following constants:
+ else if (key == "STOPS"){
+ std::istringstream iss(value);
+ double beat, sec;
+ char chr;
+ while (iss >> beat >> chr >> sec) {
+ m_stops.push_back(std::make_pair(beat, sec));
+ if (!(iss >> chr)) break;
+
+ }
+ }
+
+ /*.sm fileformat has also following constants that are ignored in this version of the parser:
#SUBTITLE
#TITLETRANSLIT
#SUBTITLETRANSLIT
@@ -137,13 +159,12 @@ bool SongParser::smParseField(std::string line) {
#SAMPLESTART
#SAMPLELENGTH
#SELECTABLE
- #STOPS
#BGCHANGE
*/
return true;
}
-Notes SongParser::smParseNotes(std::string line, bool endOfInput) {
+Notes SongParser::smParseNotes(std::string line) {
DanceChords chords; //temporary container for notes
Notes notes;
@@ -192,6 +213,7 @@ Notes SongParser::smParseNotes(std::string line, bool endOfInput) {
}
//reading notes into a temporary container chord
DanceChord chord;
+
std::istringstream iss(line);
for(int i =0; i<4; i++){
char notetype = iss.get();
@@ -226,6 +248,5 @@ Notes SongParser::smParseNotes(std::string line, bool endOfInput) {
chords.push_back(chord);
continue;
}
- endOfInput = true;
return notes;
}
diff --git a/game/songparser.hh b/game/songparser.hh
index 9fe2cc0..3a2fdb5 100644
--- a/game/songparser.hh
+++ b/game/songparser.hh
@@ -90,6 +90,7 @@ class SongParser {
bool m_relative;
double m_gap;
double m_bpm;
+
bool txtCheck(std::vector<char> const& data);
void txtParse();
bool txtParseField(std::string const& line);
@@ -99,11 +100,12 @@ class SongParser {
bool smCheck(std::vector<char> const& data);
void smParse();
bool smParseField(std::string line);
- Notes smParseNotes(std::string line, bool endOfInput);
+ Notes smParseNotes(std::string line);
double m_prevtime;
unsigned int m_prevts;
unsigned int m_relativeShift;
double m_maxScore;
+ std::vector<std::pair<double,double> > m_stops;
struct BPM {
BPM(double _begin, unsigned int _ts, double bpm): begin(_begin), step(0.25 * 60.0 / bpm), ts(_ts) {}
double begin; // Time in seconds
|