summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-07-08 08:30:35 +0000
committerrubidium <rubidium@openttd.org>2009-07-08 08:30:35 +0000
commit8275a98e1f2e5adc770dc68492927416ddbb6fe6 (patch)
treecc2a2bbfd9544a2488bd50e8c798b1234ebb5c80
parent2d907d902ac830d3020fe21cea9299073577d7f3 (diff)
downloadopenttd-8275a98e1f2e5adc770dc68492927416ddbb6fe6.tar.xz
(svn r16764) -Codechange: unify the way viewport signs are marked dirty
-rw-r--r--src/functions.h6
-rw-r--r--src/lang/unfinished/vietnamese.txt4
-rw-r--r--src/signs.cpp20
-rw-r--r--src/signs_cmd.cpp10
-rw-r--r--src/signs_func.h1
-rw-r--r--src/station.cpp10
-rw-r--r--src/town_cmd.cpp22
-rw-r--r--src/viewport.cpp16
-rw-r--r--src/viewport_func.h7
-rw-r--r--src/viewport_type.h1
-rw-r--r--src/waypoint.cpp2
-rw-r--r--src/waypoint.h1
-rw-r--r--src/waypoint_cmd.cpp18
13 files changed, 38 insertions, 80 deletions
diff --git a/src/functions.h b/src/functions.h
index d92ea85ab..86f1545f1 100644
--- a/src/functions.h
+++ b/src/functions.h
@@ -32,12 +32,6 @@ void InitializeLandscapeVariables(bool only_constants);
*/
void MarkTileDirtyByTile(TileIndex tile);
-/**
- * Mark all viewports dirty for repaint.
- *
- * @ingroup dirty
- */
-void MarkAllViewportsDirty(int left, int top, int right, int bottom);
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost);
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost);
diff --git a/src/lang/unfinished/vietnamese.txt b/src/lang/unfinished/vietnamese.txt
index 23972f10e..2dee80d89 100644
--- a/src/lang/unfinished/vietnamese.txt
+++ b/src/lang/unfinished/vietnamese.txt
@@ -1,5 +1,5 @@
-##name Vietnamese (VI)
-##ownname Vietnamese (VI)
+##name Vietnamese
+##ownname Vietnamese
##isocode vi_VN
##winlangid 0x042a
##grflangid 0x54
diff --git a/src/signs.cpp b/src/signs.cpp
index 3102d7973..2744c31c4 100644
--- a/src/signs.cpp
+++ b/src/signs.cpp
@@ -54,26 +54,6 @@ void UpdateAllSignVirtCoords()
}
/**
- * Marks the region of a sign as dirty.
- *
- * This function marks the sign in all viewports as dirty for repaint.
- *
- * @param si Pointer to the Sign
- * @ingroup dirty
- */
-void MarkSignDirty(Sign *si)
-{
- /* We use ZOOM_LVL_MAX here, as every viewport can have an other zoom,
- * and there is no way for us to know which is the biggest. So make the
- * biggest area dirty, and we are safe for sure. */
- MarkAllViewportsDirty(
- si->sign.left - 6,
- si->sign.top - 3,
- si->sign.left + ScaleByZoom(si->sign.width_1 + 12, ZOOM_LVL_MAX),
- si->sign.top + ScaleByZoom(12, ZOOM_LVL_MAX));
-}
-
-/**
*
* Initialize the signs
*
diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp
index cb8add163..b07e4b204 100644
--- a/src/signs_cmd.cpp
+++ b/src/signs_cmd.cpp
@@ -47,7 +47,7 @@ CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
si->name = strdup(text);
}
UpdateSignVirtCoords(si);
- MarkSignDirty(si);
+ si->sign.MarkDirty();
InvalidateWindowData(WC_SIGN_LIST, 0, 0);
_new_sign_id = si->index;
}
@@ -80,15 +80,15 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
si->name = strdup(text);
si->owner = _current_company;
- /* Update; mark sign dirty twice, because it can either becom longer, or shorter */
- MarkSignDirty(si);
+ /* Update; mark sign dirty twice, because it can either become longer, or shorter */
+ si->sign.MarkDirty();
UpdateSignVirtCoords(si);
- MarkSignDirty(si);
+ si->sign.MarkDirty();
InvalidateWindowData(WC_SIGN_LIST, 0, 1);
}
} else { // Delete sign
if (flags & DC_EXEC) {
- MarkSignDirty(si);
+ si->sign.MarkDirty();
delete si;
InvalidateWindowData(WC_SIGN_LIST, 0, 0);
diff --git a/src/signs_func.h b/src/signs_func.h
index 06242eb2f..9dd81110a 100644
--- a/src/signs_func.h
+++ b/src/signs_func.h
@@ -11,7 +11,6 @@ extern SignID _new_sign_id;
void UpdateAllSignVirtCoords();
void PlaceProc_Sign(TileIndex tile);
-void MarkSignDirty(Sign *si);
void UpdateSignVirtCoords(Sign *si);
/* signs_gui.cpp */
diff --git a/src/station.cpp b/src/station.cpp
index efaab8565..3f594cefe 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -155,15 +155,7 @@ void Station::MarkDirty() const
{
if (this->sign.width_1 != 0) {
InvalidateWindowWidget(WC_STATION_VIEW, index, SVW_CAPTION);
-
- /* We use ZOOM_LVL_MAX here, as every viewport can have an other zoom,
- * and there is no way for us to know which is the biggest. So make the
- * biggest area dirty, and we are safe for sure. */
- MarkAllViewportsDirty(
- this->sign.left - 6,
- this->sign.top,
- this->sign.left + ScaleByZoom(this->sign.width_1 + 12, ZOOM_LVL_MAX),
- this->sign.top + ScaleByZoom(12, ZOOM_LVL_MAX));
+ this->sign.MarkDirty();
}
}
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 6a09c8a7e..529f7dbca 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -322,37 +322,19 @@ static bool IsCloseToTown(TileIndex tile, uint dist)
}
/**
- * Marks the town sign as needing a repaint.
- *
- * This function marks the area of the sign of a town as dirty for repaint.
- *
- * @param t Town requesting town sign for repaint
- * @ingroup dirty
- */
-static void MarkTownSignDirty(Town *t)
-{
- MarkAllViewportsDirty(
- t->sign.left - 6,
- t->sign.top - 3,
- t->sign.left + t->sign.width_1 * 4 + 12,
- t->sign.top + 45
- );
-}
-
-/**
* Resize the sign(label) of the town after changes in
* population (creation or growth or else)
* @param t Town to update
*/
void UpdateTownVirtCoord(Town *t)
{
- MarkTownSignDirty(t);
+ t->sign.MarkDirty();
Point pt = RemapCoords2(TileX(t->xy) * TILE_SIZE, TileY(t->xy) * TILE_SIZE);
SetDParam(0, t->index);
SetDParam(1, t->population);
t->sign.UpdatePosition(pt.x, pt.y - 24,
_settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL);
- MarkTownSignDirty(t);
+ t->sign.MarkDirty();
}
/** Update the virtual coords needed to draw the town sign for all towns. */
diff --git a/src/viewport.cpp b/src/viewport.cpp
index fa1f746a6..662c36850 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1301,6 +1301,22 @@ void ViewportSign::UpdatePosition(int center, int top, StringID str)
_cur_fontsize = FS_NORMAL;
}
+/**
+ * Mark the sign dirty in all viewports.
+ *
+ * @ingroup dirty
+ */
+void ViewportSign::MarkDirty() const
+{
+ /* We use ZOOM_LVL_MAX here, as every viewport can have an other zoom,
+ * and there is no way for us to know which is the biggest. So make the
+ * biggest area dirty, and we are safe for sure. */
+ MarkAllViewportsDirty(
+ this->left - 6,
+ this->top - 3,
+ this->left + ScaleByZoom(this->width_1 + 12, ZOOM_LVL_MAX),
+ this->top + ScaleByZoom(12, ZOOM_LVL_MAX));
+}
static void ViewportDrawTileSprites(const TileSpriteToDrawVector *tstdv)
{
diff --git a/src/viewport_func.h b/src/viewport_func.h
index bce5b002f..94adab7bf 100644
--- a/src/viewport_func.h
+++ b/src/viewport_func.h
@@ -19,6 +19,13 @@ ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
Point GetTileBelowCursor();
void UpdateViewportPosition(Window *w);
+/**
+ * Mark all viewports dirty for repaint.
+ *
+ * @ingroup dirty
+ */
+void MarkAllViewportsDirty(int left, int top, int right, int bottom);
+
bool DoZoomInOutWindow(int how, Window *w);
void ZoomInOrOutToCursorWindow(bool in, Window * w);
Point GetTileZoomCenterWindow(bool in, Window * w);
diff --git a/src/viewport_type.h b/src/viewport_type.h
index d00509eb5..39235ed19 100644
--- a/src/viewport_type.h
+++ b/src/viewport_type.h
@@ -31,6 +31,7 @@ struct ViewportSign {
uint16 width_1, width_2;
void UpdatePosition(int center, int top, StringID str);
+ void MarkDirty() const;
};
enum {
diff --git a/src/waypoint.cpp b/src/waypoint.cpp
index 96a9e5025..f1ba662a0 100644
--- a/src/waypoint.cpp
+++ b/src/waypoint.cpp
@@ -88,7 +88,7 @@ Waypoint::~Waypoint()
DeleteWindowById(WC_WAYPOINT_VIEW, this->index);
RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index);
- RedrawWaypointSign(this);
+ this->sign.MarkDirty();
}
void InitializeWaypoints()
diff --git a/src/waypoint.h b/src/waypoint.h
index 3f72ac4ca..6094c20c5 100644
--- a/src/waypoint.h
+++ b/src/waypoint.h
@@ -60,6 +60,5 @@ void ShowWaypointWindow(const Waypoint *wp);
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype);
void UpdateAllWaypointSigns();
void UpdateWaypointSign(Waypoint *wp);
-void RedrawWaypointSign(const Waypoint *wp);
#endif /* WAYPOINT_H */
diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp
index cb0129f43..986579c83 100644
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -36,18 +36,6 @@ void UpdateWaypointSign(Waypoint *wp)
}
/**
- * Redraw the sign of a waypoint
- * @param wp Waypoint to redraw sign */
-void RedrawWaypointSign(const Waypoint *wp)
-{
- MarkAllViewportsDirty(
- wp->sign.left - 6,
- wp->sign.top,
- wp->sign.left + (wp->sign.width_1 << 2) + 12,
- wp->sign.top + 48);
-}
-
-/**
* Set the default name for a waypoint
* @param wp Waypoint to work on
*/
@@ -192,7 +180,7 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1
}
}
- RedrawWaypointSign(wp);
+ wp->sign.MarkDirty();
wp->xy = tile;
InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index);
}
@@ -224,7 +212,7 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1
if (wp->town_index == INVALID_TOWN) MakeDefaultWaypointName(wp);
UpdateWaypointSign(wp);
- RedrawWaypointSign(wp);
+ wp->sign.MarkDirty();
YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis));
}
@@ -254,7 +242,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justre
wp = GetWaypointByTile(tile);
wp->deleted = 30; // let it live for this many days before we do the actual deletion.
- RedrawWaypointSign(wp);
+ wp->sign.MarkDirty();
Train *v = NULL;
if (justremove) {