|
From: Tapio V. <aa...@us...> - 2010-08-21 18:03:34
|
Module: performous
Branch: master
Commit: c815cde3dff0e33cea4c003f980957f2b43c5fe9
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jul 16 20:28:32 2010 +0300
Draw instrument menus on top of everything.
---
game/dancegraph.cc | 7 ++-----
game/guitargraph.cc | 6 ++----
game/instrumentgraph.cc | 6 +++++-
game/instrumentgraph.hh | 4 +++-
game/joystick.hh | 4 +++-
game/screen_sing.cc | 6 +++++-
6 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index e823614..62bb261 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -17,7 +17,7 @@ namespace {
static const int mapping10[max_panels]= {0, 3, 4, 7, 1, 6, 2, 5,-1,-1};
const std::string diffv[] = { "Beginner", "Easy", "Medium", "Hard", "Challenge" };
const int death_delay = 25; // Delay in notes after which the player is hidden
- const float join_delay = 7.0f; // Time to select track/difficulty when joining mid-game
+ const float join_delay = 3.0f; // Time after join menu before playing when joining mid-game
const float past = -0.3f; // Relative time from cursor that is considered past (out of screen)
const float future = 2.0f; // Relative time from cursor that is considered future (out of screen)
const float timescale = 12.0f; // Multiplier to get graphics units from time
@@ -534,10 +534,7 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
/// Draw popups and other info texts
void DanceGraph::drawInfo(double time, double offsetX, Dimensions dimensions) {
- if (menuOpen()) {
- // Draw join menu
- drawMenu(offsetX);
- } else {
+ if (!menuOpen()) {
// Draw scores
m_text.dimensions.screenBottom(-0.35).middle(0.32 * dimensions.w() + offsetX);
m_text.draw(boost::lexical_cast<std::string>(unsigned(getScore())));
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 0fe015f..9cbd7e3 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -20,7 +20,7 @@ namespace {
};
const size_t diffsz = sizeof(diffv) / sizeof(*diffv);
const int death_delay = 20; // Delay in notes after which the player is hidden
- const float join_delay = 6.0f; // Time to select track/difficulty when joining mid-game
+ const float join_delay = 3.0f; // Time after join menu before playing when joining mid-game
const float g_angle = 80.0f; // How much to rotate the fretboards
const float past = -0.2f; // Relative time from cursor that is considered past (out of screen)
const float future = 1.5f; // Relative time from cursor that is considered future (out of screen)
@@ -1055,9 +1055,7 @@ void GuitarGraph::drawDrumfill(float tBeg, float tEnd) {
/// Draw popups and other info texts
void GuitarGraph::drawInfo(double time, double offsetX, Dimensions dimensions) {
// Draw info
- if (menuOpen()) {
- drawMenu(offsetX);
- } else {
+ if (!menuOpen()) {
float xcor = 0.35 * dimensions.w();
float h = 0.075 * 2.0 * dimensions.w();
// Hack to show the scores better when there is more space (1 instrument)
diff --git a/game/instrumentgraph.cc b/game/instrumentgraph.cc
index cf40301..5d147a2 100644
--- a/game/instrumentgraph.cc
+++ b/game/instrumentgraph.cc
@@ -54,8 +54,12 @@ void InstrumentGraph::toggleMenu(int forcestate) {
}
-void InstrumentGraph::drawMenu(double offsetX) {
+void InstrumentGraph::drawMenu() {
if (m_menu.empty()) return;
+ Dimensions dimensions(1.0); // FIXME: bogus aspect ratio (is this fixable?)
+ if (getGraphType() == input::DANCEPAD) dimensions.screenTop().middle(m_cx.get()).stretch(m_width.get(), 1.0);
+ else dimensions.screenBottom().middle(m_cx.get()).fixedWidth(std::min(m_width.get(),0.5));
+ double offsetX = 0.5 * (dimensions.x1() + dimensions.x2());
float step = 0.05;
float y = -0.6 * m_menu.getOptions().size() * step;
// Some helper vars
diff --git a/game/instrumentgraph.hh b/game/instrumentgraph.hh
index c2f68dc..a0f85ea 100644
--- a/game/instrumentgraph.hh
+++ b/game/instrumentgraph.hh
@@ -74,7 +74,9 @@ class InstrumentGraph {
virtual void changeTrack(int dir = 1) = 0;
virtual void changeDifficulty(int dir = 1) = 0;
+ // General shared functions
void doUpdates();
+ void drawMenu();
void toggleMenu(int forcestate = -1); // 0 = close, 1 = open, -1 = auto/toggle
void togglePause(int) { m_audio.togglePause(); }
void restart(int) { /* TODO: Implement */ }
@@ -89,6 +91,7 @@ class InstrumentGraph {
unsigned stream() const { return m_stream; }
double correctness() const { return m_correctness.get(); }
int getScore() const { return (m_score > 0 ? m_score : 0) * m_scoreFactor; }
+ input::DevType getGraphType() const { return m_input.getDevType(); }
protected:
// Core stuff
@@ -115,7 +118,6 @@ class InstrumentGraph {
// Shared functions for derived classes
void setupPauseMenu();
- void drawMenu(double offsetX);
void drawPopups(double offsetX);
void handleCountdown(double time, double beginTime);
diff --git a/game/joystick.hh b/game/joystick.hh
index 09fccd1..294e16d 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -124,7 +124,7 @@ namespace input {
// First gives a correct instrument type
// Then gives an unknown instrument type
// Finally throw an exception if only wrong (or none) instrument are available
- InputDev(DevType _type) {
+ InputDev(DevType _type): m_dev_type(_type) {
for (detail::InputDevs::iterator it = detail::devices.begin() ; it != detail::devices.end() ; ++it) {
if (it->first == detail::KEYBOARD_ID && !config["game/keyboard_guitar"].b()) continue;
if (it->first == detail::KEYBOARD_ID2 && !config["game/keyboard_drumkit"].b()) continue;
@@ -144,8 +144,10 @@ namespace input {
void addEvent(Event _e) { detail::devices.find(m_device_id)->second.addEvent(_e); };
bool pressed(int _button) { return detail::devices.find(m_device_id)->second.pressed(_button); }; // Current state
bool isKeyboard() const { return (m_device_id == detail::KEYBOARD_ID || m_device_id == detail::KEYBOARD_ID2 || m_device_id == detail::KEYBOARD_ID3); };
+ DevType getDevType() const { return m_dev_type; }
private:
unsigned int m_device_id; // should be some kind of reference
+ DevType m_dev_type;
};
namespace SDL {
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index b96f840..3086eb8 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -472,7 +472,11 @@ void ScreenSing::draw() {
}
}
- // Draw menu
+ // Menus on top of everything
+ for (Instruments::iterator it = m_instruments.begin(); it != m_instruments.end(); ++it)
+ if (!it->dead() && it->menuOpen()) it->drawMenu();
+ for (Dancers::iterator it = m_dancers.begin(); it != m_dancers.end(); ++it)
+ if (!it->dead() && it->menuOpen()) it->drawMenu();
if (m_menu.isOpen()) drawMenu();
}
|