|
From: Tapio V. <aa...@us...> - 2010-08-21 18:03:48
|
Module: performous
Branch: master
Commit: 78d1f9ff3c756e4bef94b2fbd74f1297132f4743
Author: Tapio Vierros <tap...@gm...>
Date: Mon Aug 2 18:48:59 2010 +0300
Calculate instrument menu background size better.
---
game/instrumentgraph.cc | 13 +++++++------
game/opengl_text.cc | 18 +++++++++---------
game/opengl_text.hh | 6 ++++++
game/screen_sing.cc | 11 ++++++-----
4 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/game/instrumentgraph.cc b/game/instrumentgraph.cc
index 2177dde..76e5455 100644
--- a/game/instrumentgraph.cc
+++ b/game/instrumentgraph.cc
@@ -59,15 +59,16 @@ void InstrumentGraph::drawMenu() {
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;
- float h = m_menu.getOptions().size() * step + step;
// Some helper vars
ThemeInstrumentMenu& th = *m_menuTheme;
MenuOptions::const_iterator cur = static_cast<MenuOptions::const_iterator>(&m_menu.current());
+ const double offsetX = 0.5f * (dimensions.x1() + dimensions.x2());
+ const float txth = th.option.h();
+ const float step = txth * 0.7f;
+ const float h = m_menu.getOptions().size() * step + step;
+ float y = -h * .5f + step;
// Background
- th.bg.dimensions.middle(.05 + offsetX).center((y+step)*.5).stretch(.45, h);
+ th.bg.dimensions.middle(.05 + offsetX).center(0).stretch(.45, h);
th.bg.draw();
// Loop through menu items
for (MenuOptions::const_iterator it = m_menu.begin(); it != m_menu.end(); ++it) {
@@ -84,7 +85,7 @@ void InstrumentGraph::drawMenu() {
if (cur->getComment() != "") {
//th.comment_bg.dimensions.middle().screenBottom(-0.2);
//th.comment_bg.draw();
- th.comment.dimensions.middle(-0.1 + offsetX).screenBottom(-0.22);
+ th.comment.dimensions.middle(-0.1 + offsetX).screenBottom(-0.12);
th.comment.draw(cur->getComment());
}
}
diff --git a/game/opengl_text.cc b/game/opengl_text.cc
index 290d572..d46d3b3 100644
--- a/game/opengl_text.cc
+++ b/game/opengl_text.cc
@@ -219,27 +219,27 @@ void SvgTxtTheme::draw(std::vector<TZoomText> const& _text, float alpha) {
}
double text_x = 0.0;
double text_y = 0.0;
- // first compute maximum height and whole length
+ // First compute maximum height and whole length
for (unsigned int i = 0; i < _text.size(); i++ ) {
text_x += m_opengl_text[i].x();
text_y = std::max(text_y, m_opengl_text[i].y());
}
- double texture_ar = text_x/text_y;
- double texture_width = std::min(0.96, text_x/800.);
- double texture_height = texture_width / texture_ar;
+ double texture_ar = text_x / text_y;
+ m_texture_width = std::min(0.96, text_x/800.);
+ m_texture_height = m_texture_width / texture_ar;
double position_x = dimensions.x1();
- if (m_align == CENTER) position_x -= 0.5 * texture_width;
- if (m_align == RIGHT) position_x -= texture_width;
+ if (m_align == CENTER) position_x -= 0.5 * m_texture_width;
+ if (m_align == RIGHT) position_x -= m_texture_width;
for (unsigned int i = 0; i < _text.size(); i++ ) {
double syllable_x = m_opengl_text[i].x();
- double syllable_width = syllable_x * texture_width / text_x;
- double syllable_height = texture_height;
+ double syllable_width = syllable_x * m_texture_width / text_x;
+ double syllable_height = m_texture_height;
double syllable_ar = syllable_width / syllable_height;
Dimensions dim(syllable_ar);
- dim.fixedHeight(texture_height).center(dimensions.y1());
+ dim.fixedHeight(m_texture_height).center(dimensions.y1());
dim.middle(position_x + 0.5 * dim.w());
TexCoords tex;
double factor = _text[i].factor;
diff --git a/game/opengl_text.hh b/game/opengl_text.hh
index 4130fde..0a74b05 100644
--- a/game/opengl_text.hh
+++ b/game/opengl_text.hh
@@ -149,6 +149,10 @@ class SvgTxtTheme {
void draw(std::string _text, float alpha = 1.0f);
/// sets highlight
void setHighlight(std::string _theme_file);
+ /// width
+ double w() const { return m_texture_width; }
+ /// height
+ double h() const { return m_texture_height; }
private:
boost::ptr_vector<OpenGLText> m_opengl_text;
@@ -158,6 +162,8 @@ class SvgTxtTheme {
double m_width;
double m_height;
double m_factor;
+ double m_texture_width;
+ double m_texture_height;
std::string m_cache_text;
TThemeTxtOpenGL m_text;
TThemeTxtOpenGL m_text_highlight;
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 0fb6dd9..eedfdbb 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -483,14 +483,15 @@ void ScreenSing::draw() {
void ScreenSing::drawMenu() {
if (m_menu.empty()) return;
- float step = 0.075;
- float y = -0.6 * m_menu.getOptions().size() * step;
- float h = m_menu.getOptions().size() * step + step;
// Some helper vars
ThemeInstrumentMenu& th = *m_menuTheme;
MenuOptions::const_iterator cur = static_cast<MenuOptions::const_iterator>(&m_menu.current());
+ const float txth = th.option.h();
+ const float step = txth * 0.85f;
+ const float h = m_menu.getOptions().size() * step + step;
+ float y = -h * .5f + step;
// Background
- th.bg.dimensions.middle(.05).center((y+step)*.5).stretch(.45, h);
+ th.bg.dimensions.middle(.05).center(0).stretch(.45, h);
th.bg.draw();
// Loop through menu items
for (MenuOptions::const_iterator it = m_menu.begin(); it != m_menu.end(); ++it) {
@@ -503,7 +504,7 @@ void ScreenSing::drawMenu() {
y += step;
}
if (cur->getComment() != "") {
- th.comment.dimensions.middle(-0.1).screenBottom(-0.22);
+ th.comment.dimensions.middle(-0.1).screenBottom(-0.12);
th.comment.draw(cur->getComment());
}
}
|