summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-08 08:50:20 +0000
committerrubidium <rubidium@openttd.org>2009-07-08 08:50:20 +0000
commit3fb1506d6d71fcc124779f7f4a7ede68d9970636 (patch)
tree0136a9522a05a038181cc31ec9158339f34adec0
parent8275a98e1f2e5adc770dc68492927416ddbb6fe6 (diff)
downloadopenttd-3fb1506d6d71fcc124779f7f4a7ede68d9970636.tar.xz
(svn r16765) -Codechange: give ViewportSign's width_1 and width_2 more self explaining names
-rw-r--r--src/smallmap_gui.cpp6
-rw-r--r--src/station.cpp2
-rw-r--r--src/station_cmd.cpp4
-rw-r--r--src/viewport.cpp74
-rw-r--r--src/viewport_type.h8
5 files changed, 46 insertions, 48 deletions
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 3d0ab2ecb..6f4b1da80 100644
--- 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
index 3f594cefe..db2c50969 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -153,7 +153,7 @@ void Station::AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
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
index cde7a4ee6..8990c2e65 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1438,7 +1438,6 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (Company::IsValidID(_current_company)) {
SetBit(st->town->have_ratings, _current_company);
}
- st->sign.width_1 = 0;
}
}
@@ -1795,7 +1794,6 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
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, DoCommandFlag flags, uint32 p1, uint32
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
index 662c36850..0c510693e 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1043,7 +1043,7 @@ static void ViewportAddTownNames(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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(DrawPixelInfo *dpi)
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 center, int top, StringID str)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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 ViewPort *vp, int x, int y)
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
index 39235ed19..dd7cd8a7f 100644
--- 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;