summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2014-09-21 09:12:04 +0000
committerpeter1138 <peter1138@openttd.org>2014-09-21 09:12:04 +0000
commitea8de14520f6d8e2581f4c3ccab35fc15c427fce (patch)
tree55b6ee430bea6b6fab57df325280033c01786b8a
parentc9d7e89138c7e8e2a65c455e50338ba99f195753 (diff)
downloadopenttd-ea8de14520f6d8e2581f4c3ccab35fc15c427fce.tar.xz
(svn r26871) -Codechange: Centre and draw arbitrary size highscore screen. Highscore text continues to be drawn with 640x480 dimensions.
-rw-r--r--src/highscore_gui.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp
index 35ada7266..c67aaa170 100644
--- a/src/highscore_gui.cpp
+++ b/src/highscore_gui.cpp
@@ -46,17 +46,20 @@ struct EndGameHighScoreBaseWindow : Window {
this->DrawWidgets();
- Point pt = this->GetTopLeft640x480();
+ /* Standard background slices are 50 pixels high, but it's designed
+ * for 480 pixels total. 96% of 500 is 480. */
+ Dimension dim = GetSpriteSize(this->background_img);
+ Point pt = this->GetTopLeft(dim.width, dim.height * 96 / 10);
/* Center Highscore/Endscreen background */
for (uint i = 0; i < 10; i++) { // the image is split into 10 50px high parts
- DrawSprite(this->background_img + i, PAL_NONE, pt.x, pt.y + (i * 50));
+ DrawSprite(this->background_img + i, PAL_NONE, pt.x, pt.y + (i * dim.height));
}
}
/** Return the coordinate of the screen such that a window of 640x480 is centered at the screen. */
- Point GetTopLeft640x480()
+ Point GetTopLeft(int x, int y)
{
- Point pt = {max(0, (_screen.width / 2) - (640 / 2)), max(0, (_screen.height / 2) - (480 / 2))};
+ Point pt = {max(0, (_screen.width / 2) - (x / 2)), max(0, (_screen.height / 2) - (y / 2))};
return pt;
}
@@ -129,7 +132,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
virtual void OnPaint()
{
this->SetupHighScoreEndWindow();
- Point pt = this->GetTopLeft640x480();
+ Point pt = this->GetTopLeft(640, 480);
const Company *c = Company::GetIfValid(_local_company);
if (c == NULL) return;
@@ -179,7 +182,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow {
const HighScore *hs = _highscore_table[this->window_number];
this->SetupHighScoreEndWindow();
- Point pt = this->GetTopLeft640x480();
+ Point pt = this->GetTopLeft(640, 480);
SetDParam(0, ORIGINAL_END_YEAR);
DrawStringMultiLine(pt.x + 70, pt.x + 570, pt.y, pt.y + 140, !_networking ? STR_HIGHSCORE_TOP_COMPANIES_WHO_REACHED : STR_HIGHSCORE_TOP_COMPANIES_NETWORK_GAME, TC_FROMSTRING, SA_CENTER);