diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -791,17 +791,17 @@ public: this->RemapX(TileX(t->xy)), this->RemapY(TileY(t->xy)), 0); - x = pt.x - this->subscroll + 3 - (t->sign.width_2 >> 1); + x = pt.x - this->subscroll + 3 - (t->sign.width_small >> 1); y = pt.y; /* Check if the town sign is within bounds */ - if (x + t->sign.width_2 > dpi->left && + if (x + t->sign.width_small > dpi->left && x < dpi->left + dpi->width && y + 6 > dpi->top && y < dpi->top + dpi->height) { /* And draw it. */ SetDParam(0, t->index); - DrawString(x, x + t->sign.width_2, y, STR_SMALLMAP_TOWN); + DrawString(x, x + t->sign.width_small, y, STR_SMALLMAP_TOWN); } } } diff --git a/src/station.cpp b/src/station.cpp --- a/src/station.cpp +++ b/src/station.cpp @@ -153,7 +153,7 @@ void Station::AddFacility(StationFacilit void Station::MarkDirty() const { - if (this->sign.width_1 != 0) { + if (this->sign.width_normal != 0) { InvalidateWindowWidget(WC_STATION_VIEW, index, SVW_CAPTION); this->sign.MarkDirty(); } diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1438,7 +1438,6 @@ CommandCost CmdBuildRoadStop(TileIndex t if (Company::IsValidID(_current_company)) { SetBit(st->town->have_ratings, _current_company); } - st->sign.width_1 = 0; } } @@ -1795,7 +1794,6 @@ CommandCost CmdBuildAirport(TileIndex ti if (Company::IsValidID(_current_company)) { SetBit(st->town->have_ratings, _current_company); } - st->sign.width_1 = 0; } } @@ -1931,7 +1929,6 @@ CommandCost CmdBuildBuoy(TileIndex tile, if (Company::IsValidID(_current_company)) { SetBit(st->town->have_ratings, _current_company); } - st->sign.width_1 = 0; st->dock_tile = tile; st->facilities |= FACIL_DOCK; /* Buoys are marked in the Station struct by this flag. Yes, it is this @@ -2947,7 +2944,6 @@ void BuildOilRig(TileIndex tile) Station *st = new Station(tile); st->town = ClosestTownFromTile(tile, UINT_MAX); - st->sign.width_1 = 0; st->string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG); diff --git a/src/viewport.cpp b/src/viewport.cpp --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1043,7 +1043,7 @@ static void ViewportAddTownNames(DrawPix if (bottom > t->sign.top && top < t->sign.top + 12 && right > t->sign.left && - left < t->sign.left + t->sign.width_1) { + left < t->sign.left + t->sign.width_normal) { AddStringToDraw(t->sign.left + 1, t->sign.top + 1, _settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, t->index, t->population); @@ -1059,7 +1059,7 @@ static void ViewportAddTownNames(DrawPix if (bottom > t->sign.top && top < t->sign.top + 24 && right > t->sign.left && - left < t->sign.left + t->sign.width_1 * 2) { + left < t->sign.left + t->sign.width_normal * 2) { AddStringToDraw(t->sign.left + 1, t->sign.top + 1, _settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL, t->index, t->population); @@ -1076,7 +1076,7 @@ static void ViewportAddTownNames(DrawPix if (bottom > t->sign.top && top < t->sign.top + ScaleByZoom(12, dpi->zoom) && right > t->sign.left && - left < t->sign.left + ScaleByZoom(t->sign.width_2, dpi->zoom)) { + left < t->sign.left + ScaleByZoom(t->sign.width_small, dpi->zoom)) { AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0); AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0); } @@ -1113,8 +1113,8 @@ static void ViewportAddStationNames(Draw if (bottom > st->sign.top && top < st->sign.top + 12 && right > st->sign.left && - left < st->sign.left + st->sign.width_1) { - AddStation(st, STR_STATION_SIGN, st->sign.width_1); + left < st->sign.left + st->sign.width_normal) { + AddStation(st, STR_STATION_SIGN, st->sign.width_normal); } } break; @@ -1126,8 +1126,8 @@ static void ViewportAddStationNames(Draw if (bottom > st->sign.top && top < st->sign.top + 24 && right > st->sign.left && - left < st->sign.left + st->sign.width_1 * 2) { - AddStation(st, STR_STATION_SIGN, st->sign.width_1); + left < st->sign.left + st->sign.width_normal * 2) { + AddStation(st, STR_STATION_SIGN, st->sign.width_normal); } } break; @@ -1141,8 +1141,8 @@ static void ViewportAddStationNames(Draw if (bottom > st->sign.top && top < st->sign.top + ScaleByZoom(12, dpi->zoom) && right > st->sign.left && - left < st->sign.left + ScaleByZoom(st->sign.width_2, dpi->zoom)) { - AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000); + left < st->sign.left + ScaleByZoom(st->sign.width_small, dpi->zoom)) { + AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_small | 0x8000); } } break; @@ -1177,8 +1177,8 @@ static void ViewportAddSigns(DrawPixelIn if (bottom > si->sign.top && top < si->sign.top + 12 && right > si->sign.left && - left < si->sign.left + si->sign.width_1) { - AddSign(si, STR_SIGN_WHITE, si->sign.width_1); + left < si->sign.left + si->sign.width_normal) { + AddSign(si, STR_SIGN_WHITE, si->sign.width_normal); } } break; @@ -1190,8 +1190,8 @@ static void ViewportAddSigns(DrawPixelIn if (bottom > si->sign.top && top < si->sign.top + 24 && right > si->sign.left && - left < si->sign.left + si->sign.width_1 * 2) { - AddSign(si, STR_SIGN_WHITE, si->sign.width_1); + left < si->sign.left + si->sign.width_normal * 2) { + AddSign(si, STR_SIGN_WHITE, si->sign.width_normal); } } break; @@ -1205,8 +1205,8 @@ static void ViewportAddSigns(DrawPixelIn if (bottom > si->sign.top && top < si->sign.top + ScaleByZoom(12, dpi->zoom) && right > si->sign.left && - left < si->sign.left + ScaleByZoom(si->sign.width_2, dpi->zoom)) { - AddSign(si, IsTransparencySet(TO_SIGNS) ? STR_SIGN_SMALL_WHITE : STR_SIGN_SMALL_BLACK, si->sign.width_2 | 0x8000); + left < si->sign.left + ScaleByZoom(si->sign.width_small, dpi->zoom)) { + AddSign(si, IsTransparencySet(TO_SIGNS) ? STR_SIGN_SMALL_WHITE : STR_SIGN_SMALL_BLACK, si->sign.width_small | 0x8000); } } break; @@ -1241,8 +1241,8 @@ static void ViewportAddWaypoints(DrawPix if (bottom > wp->sign.top && top < wp->sign.top + 12 && right > wp->sign.left && - left < wp->sign.left + wp->sign.width_1) { - AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); + left < wp->sign.left + wp->sign.width_normal) { + AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_normal); } } break; @@ -1254,8 +1254,8 @@ static void ViewportAddWaypoints(DrawPix if (bottom > wp->sign.top && top < wp->sign.top + 24 && right > wp->sign.left && - left < wp->sign.left + wp->sign.width_1 * 2) { - AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1); + left < wp->sign.left + wp->sign.width_normal * 2) { + AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_normal); } } break; @@ -1269,8 +1269,8 @@ static void ViewportAddWaypoints(DrawPix if (bottom > wp->sign.top && top < wp->sign.top + ScaleByZoom(12, dpi->zoom) && right > wp->sign.left && - left < wp->sign.left + ScaleByZoom(wp->sign.width_2, dpi->zoom)) { - AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000); + left < wp->sign.left + ScaleByZoom(wp->sign.width_small, dpi->zoom)) { + AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_small | 0x8000); } } break; @@ -1292,12 +1292,12 @@ void ViewportSign::UpdatePosition(int ce char buffer[DRAW_STRING_BUFFER]; GetString(buffer, str, lastof(buffer)); - this->width_1 = GetStringBoundingBox(buffer).width + 3; - this->left = center - this->width_1 / 2; + this->width_normal = GetStringBoundingBox(buffer).width + 3; + this->left = center - this->width_normal / 2; /* zoomed out version */ _cur_fontsize = FS_SMALL; - this->width_2 = GetStringBoundingBox(buffer).width + 3; + this->width_small = GetStringBoundingBox(buffer).width + 3; _cur_fontsize = FS_NORMAL; } @@ -1314,7 +1314,7 @@ void ViewportSign::MarkDirty() const MarkAllViewportsDirty( this->left - 6, this->top - 3, - this->left + ScaleByZoom(this->width_1 + 12, ZOOM_LVL_MAX), + this->left + ScaleByZoom(this->width_normal + 12, ZOOM_LVL_MAX), this->top + ScaleByZoom(12, ZOOM_LVL_MAX)); } @@ -1845,7 +1845,7 @@ static bool CheckClickOnTown(const ViewP if (y >= t->sign.top && y < t->sign.top + 12 && x >= t->sign.left && - x < t->sign.left + t->sign.width_1) { + x < t->sign.left + t->sign.width_normal) { ShowTownViewWindow(t->index); return true; } @@ -1859,7 +1859,7 @@ static bool CheckClickOnTown(const ViewP if (y >= t->sign.top && y < t->sign.top + 24 && x >= t->sign.left && - x < t->sign.left + t->sign.width_1 * 2) { + x < t->sign.left + t->sign.width_normal * 2) { ShowTownViewWindow(t->index); return true; } @@ -1875,7 +1875,7 @@ static bool CheckClickOnTown(const ViewP if (y >= t->sign.top && y < t->sign.top + ScaleByZoom(12, vp->zoom) && x >= t->sign.left && - x < t->sign.left + ScaleByZoom(t->sign.width_2, vp->zoom)) { + x < t->sign.left + ScaleByZoom(t->sign.width_small, vp->zoom)) { ShowTownViewWindow(t->index); return true; } @@ -1903,7 +1903,7 @@ static bool CheckClickOnStation(const Vi if (y >= st->sign.top && y < st->sign.top + 12 && x >= st->sign.left && - x < st->sign.left + st->sign.width_1) { + x < st->sign.left + st->sign.width_normal) { ShowStationViewWindow(st->index); return true; } @@ -1917,7 +1917,7 @@ static bool CheckClickOnStation(const Vi if (y >= st->sign.top && y < st->sign.top + 24 && x >= st->sign.left && - x < st->sign.left + st->sign.width_1 * 2) { + x < st->sign.left + st->sign.width_normal * 2) { ShowStationViewWindow(st->index); return true; } @@ -1933,7 +1933,7 @@ static bool CheckClickOnStation(const Vi if (y >= st->sign.top && y < st->sign.top + ScaleByZoom(12, vp->zoom) && x >= st->sign.left && - x < st->sign.left + ScaleByZoom(st->sign.width_2, vp->zoom)) { + x < st->sign.left + ScaleByZoom(st->sign.width_small, vp->zoom)) { ShowStationViewWindow(st->index); return true; } @@ -1962,7 +1962,7 @@ static bool CheckClickOnSign(const ViewP if (y >= si->sign.top && y < si->sign.top + 12 && x >= si->sign.left && - x < si->sign.left + si->sign.width_1) { + x < si->sign.left + si->sign.width_normal) { HandleClickOnSign(si); return true; } @@ -1976,7 +1976,7 @@ static bool CheckClickOnSign(const ViewP if (y >= si->sign.top && y < si->sign.top + 24 && x >= si->sign.left && - x < si->sign.left + si->sign.width_1 * 2) { + x < si->sign.left + si->sign.width_normal * 2) { HandleClickOnSign(si); return true; } @@ -1992,7 +1992,7 @@ static bool CheckClickOnSign(const ViewP if (y >= si->sign.top && y < si->sign.top + ScaleByZoom(12, vp->zoom) && x >= si->sign.left && - x < si->sign.left + ScaleByZoom(si->sign.width_2, vp->zoom)) { + x < si->sign.left + ScaleByZoom(si->sign.width_small, vp->zoom)) { HandleClickOnSign(si); return true; } @@ -2020,7 +2020,7 @@ static bool CheckClickOnWaypoint(const V if (y >= wp->sign.top && y < wp->sign.top + 12 && x >= wp->sign.left && - x < wp->sign.left + wp->sign.width_1) { + x < wp->sign.left + wp->sign.width_normal) { ShowWaypointWindow(wp); return true; } @@ -2034,7 +2034,7 @@ static bool CheckClickOnWaypoint(const V if (y >= wp->sign.top && y < wp->sign.top + 24 && x >= wp->sign.left && - x < wp->sign.left + wp->sign.width_1 * 2) { + x < wp->sign.left + wp->sign.width_normal * 2) { ShowWaypointWindow(wp); return true; } @@ -2050,7 +2050,7 @@ static bool CheckClickOnWaypoint(const V if (y >= wp->sign.top && y < wp->sign.top + ScaleByZoom(12, vp->zoom) && x >= wp->sign.left && - x < wp->sign.left + ScaleByZoom(wp->sign.width_2, vp->zoom)) { + x < wp->sign.left + ScaleByZoom(wp->sign.width_small, vp->zoom)) { ShowWaypointWindow(wp); return true; } diff --git a/src/viewport_type.h b/src/viewport_type.h --- a/src/viewport_type.h +++ b/src/viewport_type.h @@ -25,10 +25,12 @@ struct ViewPort { ZoomLevel zoom; }; +/** Location information about a sign as seen on the viewport */ struct ViewportSign { - int32 left; - int32 top; - uint16 width_1, width_2; + int32 left; ///< The left most position of the sign + int32 top; ///< THe top of the sign + 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 MarkDirty() const;