|
From: Tapio V. <aa...@us...> - 2010-08-21 18:04:01
|
Module: performous
Branch: master
Commit: 13325f573b4661a51c84af000e66d922ded29e4d
Author: Tapio Vierros <tap...@gm...>
Date: Tue Aug 3 00:28:01 2010 +0300
Fix instrument cursor rendering and don't crash with more than 5 menu items.
---
game/guitargraph.cc | 4 ++--
game/instrumentgraph.cc | 7 +++++--
game/menu.cc | 3 +--
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 5a47ce7..e98db01 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -293,8 +293,8 @@ void GuitarGraph::engine() {
// Menu keys
if (menuOpen()) {
// Check first regular keys
- if (ev.type == input::Event::PRESS && ev.button >= 0 && ev.button < 5) {
- int sel = m_drums ? ((ev.button + 5 - 1) % 5) : ev.button;
+ if (ev.type == input::Event::PRESS && ev.button >= 0 && ev.button < m_pads) {
+ int sel = m_drums ? ((ev.button + m_pads - 1) % m_pads) : ev.button;
m_menu.select(sel);
m_menu.action();
}
diff --git a/game/instrumentgraph.cc b/game/instrumentgraph.cc
index 6d25b26..a4f207a 100644
--- a/game/instrumentgraph.cc
+++ b/game/instrumentgraph.cc
@@ -80,8 +80,8 @@ void InstrumentGraph::drawMenu() {
for (MenuOptions::const_iterator it = m_menu.begin(); it != m_menu.end(); ++it, ++i) {
SvgTxtTheme* txt = &th.option;
// Draw the key hints
- if (getGraphType() != input::DANCEPAD) {
- int fret = (getGraphType() == input::DRUMS ? ((i + 1) % 5) : i);
+ if (getGraphType() != input::DANCEPAD && i < m_pads) {
+ int fret = (getGraphType() == input::DRUMS ? ((i + 1) % m_pads) : i);
glColor4fv(color(fret));
m_button.dimensions.middle(x - button_margin).center(y).stretch(0.05, 0.05);
m_button.draw();
@@ -97,12 +97,15 @@ void InstrumentGraph::drawMenu() {
w = std::max(w, txt->w() + 2 * step + button_margin * 2); // Calculate the widest entry
y += step;
}
+ // Draw comment text
if (cur->getComment() != "") {
//th.comment_bg.dimensions.middle().screenBottom(-0.2);
//th.comment_bg.draw();
th.comment.dimensions.middle(offsetX).screenBottom(-0.12);
th.comment.draw(cur->getComment());
}
+ m_button.dimensions.stretch(1.0, 1.0);
+ // Save the calculated menu dimensions
m_menu.dimensions.stretch(w, h);
}
diff --git a/game/menu.cc b/game/menu.cc
index 3081598..30ca24d 100644
--- a/game/menu.cc
+++ b/game/menu.cc
@@ -2,8 +2,7 @@
#include "screen.hh"
#include "surface.hh"
#include "fs.hh"
-#include "configuration.hh"
-#include "instrumentgraph.hh"
+
MenuOption::MenuOption(const std::string& nm, const std::string& comm):
type(CLOSE_SUBMENU),
|