summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-04-25 11:58:19 +0000
committerfrosch <frosch@openttd.org>2015-04-25 11:58:19 +0000
commit9fb56ca02e7e8122f57b73652c1b6734b3b45708 (patch)
tree0045b4d6cf342a109cf72ec4577824f43bcc862b /src
parent93d7db0b3608c7c081f8d291db6b8e93c942eb6e (diff)
downloadopenttd-9fb56ca02e7e8122f57b73652c1b6734b3b45708.tar.xz
(svn r27248) -Fix [FS#6257]: Town labels on smallmap and zoomed-out viewports were not centered. (_dp_)
Diffstat (limited to 'src')
-rw-r--r--src/texteff.cpp2
-rw-r--r--src/town_cmd.cpp3
-rw-r--r--src/viewport.cpp6
-rw-r--r--src/viewport_type.h3
4 files changed, 10 insertions, 4 deletions
diff --git a/src/texteff.cpp b/src/texteff.cpp
index 03b564599..cdb8b8ce6 100644
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -114,7 +114,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
if (te->string_id == INVALID_STRING_ID) continue;
if (te->mode == TE_RISING || (_settings_client.gui.loading_indicators && !IsTransparencySet(TO_LOADING))) {
- ViewportAddString(dpi, ZOOM_LVL_OUT_8X, te, te->string_id, te->string_id - 1, 0, te->params_1, te->params_2);
+ ViewportAddString(dpi, ZOOM_LVL_OUT_8X, te, te->string_id, te->string_id - 1, STR_NULL, te->params_1, te->params_2);
}
}
}
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 2d03f4f87..1444337ad 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -377,7 +377,8 @@ void Town::UpdateVirtCoord()
SetDParam(0, this->index);
SetDParam(1, this->cache.population);
this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE,
- _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN);
+ _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN,
+ STR_VIEWPORT_TOWN);
SetWindowDirty(WC_TOWN_VIEW, this->index);
}
diff --git a/src/viewport.cpp b/src/viewport.cpp
index ef23f1812..c1d4d61b4 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1309,8 +1309,9 @@ static void ViewportAddSigns(DrawPixelInfo *dpi)
* @param center the (preferred) center of the viewport sign
* @param top the new top of the sign
* @param str the string to show in the sign
+ * @param str_small the string to show when zoomed out. STR_NULL means same as \a str
*/
-void ViewportSign::UpdatePosition(int center, int top, StringID str)
+void ViewportSign::UpdatePosition(int center, int top, StringID str, StringID str_small)
{
if (this->width_normal != 0) this->MarkDirty();
@@ -1323,6 +1324,9 @@ void ViewportSign::UpdatePosition(int center, int top, StringID str)
this->center = center;
/* zoomed out version */
+ if (str_small != STR_NULL) {
+ GetString(buffer, str_small, lastof(buffer));
+ }
this->width_small = VPSM_LEFT + Align(GetStringBoundingBox(buffer, FS_SMALL).width, 2) + VPSM_RIGHT;
this->MarkDirty();
diff --git a/src/viewport_type.h b/src/viewport_type.h
index 800c8b495..07485c324 100644
--- a/src/viewport_type.h
+++ b/src/viewport_type.h
@@ -14,6 +14,7 @@
#include "zoom_type.h"
#include "strings_type.h"
+#include "table/strings.h"
class LinkGraphOverlay;
@@ -50,7 +51,7 @@ struct ViewportSign {
uint16 width_normal; ///< The width when not zoomed out (normal font)
uint16 width_small; ///< The width when zoomed out (small font)
- void UpdatePosition(int center, int top, StringID str);
+ void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL);
void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const;
};