(svn r16764) -Codechange: unify the way viewport signs are marked dirty

pull/155/head
rubidium 15 years ago
parent b9e4c6653c
commit bb78e5bb14

@ -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);

@ -1,5 +1,5 @@
##name Vietnamese (VI)
##ownname Vietnamese (VI)
##name Vietnamese
##ownname Vietnamese
##isocode vi_VN
##winlangid 0x042a
##grflangid 0x54

@ -53,26 +53,6 @@ void UpdateAllSignVirtCoords()
FOR_ALL_SIGNS(si) UpdateSignVirtCoords(si);
}
/**
* 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

@ -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);

@ -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 */

@ -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();
}
}

@ -321,24 +321,6 @@ static bool IsCloseToTown(TileIndex tile, uint dist)
return false;
}
/**
* 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)
@ -346,13 +328,13 @@ static void MarkTownSignDirty(Town *t)
*/
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. */

@ -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)
{

@ -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);

@ -31,6 +31,7 @@ struct ViewportSign {
uint16 width_1, width_2;
void UpdatePosition(int center, int top, StringID str);
void MarkDirty() const;
};
enum {

@ -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()

@ -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 */

@ -35,18 +35,6 @@ void UpdateWaypointSign(Waypoint *wp)
wp->sign.UpdatePosition(pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
}
/**
* 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) {

Loading…
Cancel
Save