From e164352e19234a88dc1824e4cba7f5bf67e3871d Mon Sep 17 00:00:00 2001 From: Pavel Stupnikov Date: Fri, 20 Mar 2015 20:50:33 +0300 Subject: [PATCH] center towns laels on minimap --- projects/openttd_vs90.vcproj.rej | 48 -------------------------------- src/town_cmd.cpp | 2 +- src/viewport.cpp | 5 +++- src/viewport_type.h | 4 ++- 4 files changed, 8 insertions(+), 51 deletions(-) delete mode 100644 projects/openttd_vs90.vcproj.rej diff --git a/projects/openttd_vs90.vcproj.rej b/projects/openttd_vs90.vcproj.rej deleted file mode 100644 index 459dad5d39..0000000000 --- a/projects/openttd_vs90.vcproj.rej +++ /dev/null @@ -1,48 +0,0 @@ ---- projects/openttd_vs90.vcproj (revision 26379) -+++ projects/openttd_vs90.vcproj (working copy) -@@ -255,38 +268,26 @@ - /> - - diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 0f315eecd1..3a30c7b4a9 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -409,7 +409,7 @@ void Town::UpdateVirtCoord() Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE); SetDParam(0, this->index); SetDParam(1, this->cache.population); - this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE, this->Label()); + this->cache.sign.UpdatePosition(pt.x, pt.y - 24 * ZOOM_LVL_BASE, this->Label(), this->SmallLabel()); SetWindowDirty(WC_TOWN_VIEW, this->index); SetWindowDirty(WC_CB_TOWN, this->index); } diff --git a/src/viewport.cpp b/src/viewport.cpp index f636808073..d2c54c7245 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1365,7 +1365,7 @@ static void ViewportAddSigns(DrawPixelInfo *dpi) * @param top the new top of the sign * @param str the string to show in the sign */ -void ViewportSign::UpdatePosition(int center, int top, StringID str) +void ViewportSign::UpdatePosition(int center, int top, StringID str, StringID small_str) { if (this->width_normal != 0) this->MarkDirty(); @@ -1378,6 +1378,9 @@ void ViewportSign::UpdatePosition(int center, int top, StringID str) this->center = center; /* zoomed out version */ + if (small_str != STR_NULL) { + GetString(buffer, small_str, 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 cb36ab262e..09a2cdbb4c 100644 --- a/src/viewport_type.h +++ b/src/viewport_type.h @@ -15,6 +15,8 @@ #include "zoom_type.h" #include "strings_type.h" #include "math.h" +#include "table/strings.h" + class LinkGraphOverlay; @@ -51,7 +53,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 small_str=STR_NULL); void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const; };