|
From: rainbyte <rai...@us...> - 2012-07-17 10:48:40
|
Author: Tapio Vierros <tap...@gm...>
Date: Sun Feb 19 22:10:34 2012 +0200
Fixed (hopefully all) aspect ratio issues with the new threaded gfx loading.
---
game/instrumentgraph.cc | 10 +++++-----
game/progressbar.cc | 2 ++
game/screen_intro.cc | 1 +
game/screen_practice.cc | 4 +++-
game/screen_sing.cc | 7 +++----
game/theme.cc | 10 ++--------
6 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/game/instrumentgraph.cc b/game/instrumentgraph.cc
index 6d25d3b..454196a 100644
--- a/game/instrumentgraph.cc
+++ b/game/instrumentgraph.cc
@@ -36,10 +36,6 @@ InstrumentGraph::InstrumentGraph(Audio& audio, Song const& song, input::DevType
m_popupText.reset(new SvgTxtThemeSimple(getThemePath("sing_popup_text.svg"), config["graphic/text_lod"].f()));
m_menuTheme.reset(new ThemeInstrumentMenu());
for (size_t i = 0; i < max_panels; ++i) m_pressed[i] = false;
- m_arrow_up.dimensions.stretch(0.05, 0.05);
- m_arrow_down.dimensions.stretch(0.05, 0.05);
- m_arrow_left.dimensions.stretch(0.05, 0.05);
- m_arrow_right.dimensions.stretch(0.05, 0.05);
}
@@ -73,8 +69,12 @@ void InstrumentGraph::drawMenu() {
Dimensions dimensions(1.0); // FIXME: bogus aspect ratio (is this fixable?)
if (getGraphType() == input::DANCEPAD) dimensions.screenTop().middle().stretch(m_width.get(), 1.0);
else dimensions.screenBottom().middle().fixedWidth(std::min(m_width.get(), 0.5));
- // Some helper vars
ThemeInstrumentMenu& th = *m_menuTheme;
+ th.back_h.dimensions.fixedHeight(0.08f);
+ m_arrow_up.dimensions.stretch(0.05, 0.05);
+ m_arrow_down.dimensions.stretch(0.05, 0.05);
+ m_arrow_left.dimensions.stretch(0.05, 0.05);
+ m_arrow_right.dimensions.stretch(0.05, 0.05);
MenuOptions::const_iterator cur = static_cast<MenuOptions::const_iterator>(&m_menu.current());
double w = m_menu.dimensions.w();
const float s = std::min(m_width.get(), 0.5) / w;
diff --git a/game/progressbar.cc b/game/progressbar.cc
index a2a8c78..2c0a12c 100644
--- a/game/progressbar.cc
+++ b/game/progressbar.cc
@@ -40,4 +40,6 @@ void ProgressBar::draw(float value) {
break;
default: throw std::logic_error("ProgressBar::draw(): unknown m_mode value");
}
+ // Reset dimensions due to async image loading
+ dimensions = Dimensions(m_bg.ar());
}
diff --git a/game/screen_intro.cc b/game/screen_intro.cc
index 6109b06..906df55 100644
--- a/game/screen_intro.cc
+++ b/game/screen_intro.cc
@@ -78,6 +78,7 @@ void ScreenIntro::draw_menu_options() {
const float sel_margin = 0.05;
const MenuOptions opts = m_menu.getOptions();
double submenuanim = 1.0 - std::min(1.0, std::abs(m_submenuAnim.get()-m_menu.getSubmenuLevel()));
+ theme->back_h.dimensions.fixedHeight(0.08f);
theme->back_h.dimensions.stretch(m_menu.dimensions.w(), theme->back_h.dimensions.h());
// Determine from which item to start
int start_i = std::min((int)m_menu.curIndex() - 1, (int)opts.size() - (int)showopts
diff --git a/game/screen_practice.cc b/game/screen_practice.cc
index 3f6862f..28f8197 100644
--- a/game/screen_practice.cc
+++ b/game/screen_practice.cc
@@ -16,7 +16,6 @@ void ScreenPractice::enter() {
// draw vu meters
for (unsigned int i = 0, mics = m_audio.analyzers().size(); i < mics; ++i) {
m_vumeters.push_back(new ProgressBar(getThemePath("vumeter_bg.svg"), getThemePath("vumeter_fg.svg"), ProgressBar::VERTICAL, 0.136, 0.023));
- m_vumeters.back().dimensions.screenBottom().left(-0.4 + i * 0.2).fixedWidth(0.04);
}
m_samples.push_back("drum bass");
m_samples.push_back("drum snare");
@@ -56,6 +55,8 @@ void ScreenPractice::draw() {
}
void ScreenPractice::draw_analyzers() {
+ theme->note.dimensions.fixedHeight(0.03f);
+ theme->sharp.dimensions.fixedHeight(0.09f);
MusicalScale scale;
boost::ptr_vector<Analyzer>& analyzers = m_audio.analyzers();
if (analyzers.empty()) return;
@@ -73,6 +74,7 @@ void ScreenPractice::draw_analyzers() {
}
// getPeak returns 0.0 when clipping, negative values when not that loud.
// Normalizing to [0,1], where 0 is -43 dB or less (to match the vumeter graphic)
+ m_vumeters[i].dimensions.screenBottom().left(-0.4 + i * 0.2).fixedWidth(0.04);
m_vumeters[i].draw(analyzer.getPeak() / 43.0 + 1.0);
if (freq != 0.0) {
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index dfb7a9e..6b5ff3d 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -134,8 +134,6 @@ void ScreenSing::reloadGL() {
m_pause_icon.reset(new Surface(getThemePath("sing_pause.svg")));
m_help.reset(new Surface(getThemePath("instrumenthelp.svg")));
m_progress.reset(new ProgressBar(getThemePath("sing_progressbg.svg"), getThemePath("sing_progressfg.svg"), ProgressBar::HORIZONTAL, 0.01f, 0.01f, true));
- m_progress->dimensions.fixedWidth(0.4).left(-0.5).screenTop();
- theme->timer.dimensions.screenTop(0.5 * m_progress->dimensions.h());
// Load background
bool foundbg = false;
if (!m_song->background.empty()) { // Load bg image
@@ -490,6 +488,8 @@ void ScreenSing::draw() {
// Compute and draw the timer and the progressbar
{
unsigned t = clamp(time, 0.0, length);
+ m_progress->dimensions.fixedWidth(0.4).left(-0.5).screenTop();
+ theme->timer.dimensions.screenTop(0.5 * m_progress->dimensions.h());
m_progress->draw(songPercent);
Song::SongSection section("error", 0);
@@ -661,7 +661,6 @@ ScoreWindow::ScoreWindow(Instruments& instruments, Database& database, Dancers&
}
}
m_bg.dimensions.middle().center();
- m_scoreBar.dimensions.fixedWidth(0.09);
}
void ScoreWindow::draw() {
@@ -675,7 +674,7 @@ void ScoreWindow::draw() {
int score = p->score;
ColorTrans c(p->color);
double x = -0.12 + spacing * (0.5 + i - 0.5 * m_database.scores.size());
- m_scoreBar.dimensions.middle(x).bottom(0.20);
+ m_scoreBar.dimensions.fixedWidth(0.09).middle(x).bottom(0.20);
m_scoreBar.draw(score / 10000.0);
m_score_text.render(boost::lexical_cast<std::string>(score));
m_score_text.dimensions().middle(x).top(0.24).fixedHeight(0.05);
diff --git a/game/theme.cc b/game/theme.cc
index dbaab57..ffcc88d 100644
--- a/game/theme.cc
+++ b/game/theme.cc
@@ -21,10 +21,7 @@ ThemePractice::ThemePractice():
note(getThemePath("practice_note.svg")),
sharp(getThemePath("practice_sharp.svg")),
note_txt(getThemePath("practice_txt.svg"), config["graphic/text_lod"].f())
-{
- note.dimensions.fixedHeight(0.03f);
- sharp.dimensions.fixedHeight(0.09f);
-}
+{}
ThemeSing::ThemeSing():
bg_top(getThemePath("sing_bg_top.svg")),
@@ -53,9 +50,7 @@ ThemeIntro::ThemeIntro():
short_comment(getThemePath("mainmenu_short_comment.svg"), config["graphic/text_lod"].f()),
comment_bg(getThemePath("mainmenu_comment_bg.svg")),
short_comment_bg(getThemePath("mainmenu_scomment_bg.svg"))
-{
- back_h.dimensions.fixedHeight(0.08f);
-}
+{}
ThemeInstrumentMenu::ThemeInstrumentMenu():
Theme(getThemePath("instrumentmenu_bg.svg")),
@@ -65,7 +60,6 @@ ThemeInstrumentMenu::ThemeInstrumentMenu():
comment(getThemePath("instrumentmenu_comment.svg"), config["graphic/text_lod"].f())
//comment_bg(getThemePath("menu_comment_bg.svg"))
{
- back_h.dimensions.fixedHeight(0.08f);
comment.setAlign(SvgTxtTheme::CENTER);
}
|