Changeset - r12334:57fa457522c9
[Not reviewed]
master
0 13 0
rubidium - 15 years ago 2009-07-08 08:30:35
rubidium@openttd.org
(svn r16764) -Codechange: unify the way viewport signs are marked dirty
13 files changed with 38 insertions and 80 deletions:
0 comments (0 inline, 0 general)
src/functions.h
Show inline comments
 
@@ -32,12 +32,6 @@ void InitializeLandscapeVariables(bool o
 
 */
 
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);
 

	
src/lang/unfinished/vietnamese.txt
Show inline comments
 
##name Vietnamese (VI)
 
##ownname Vietnamese (VI)
 
##name Vietnamese
 
##ownname Vietnamese
 
##isocode vi_VN
 
##winlangid 0x042a
 
##grflangid 0x54
src/signs.cpp
Show inline comments
 
@@ -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
 
 *
src/signs_cmd.cpp
Show inline comments
 
@@ -47,7 +47,7 @@ CommandCost CmdPlaceSign(TileIndex tile,
 
			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
 
			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);
src/signs_func.h
Show inline comments
 
@@ -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 */
src/station.cpp
Show inline comments
 
@@ -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();
 
	}
 
}
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -322,37 +322,19 @@ static bool IsCloseToTown(TileIndex tile
 
}
 

	
 
/**
 
 * 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. */
src/viewport.cpp
Show inline comments
 
@@ -1301,6 +1301,22 @@ void ViewportSign::UpdatePosition(int ce
 
	_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)
 
{
src/viewport_func.h
Show inline comments
 
@@ -19,6 +19,13 @@ ViewPort *IsPtInWindowViewport(const Win
 
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);
src/viewport_type.h
Show inline comments
 
@@ -31,6 +31,7 @@ struct ViewportSign {
 
	uint16 width_1, width_2;
 

	
 
	void UpdatePosition(int center, int top, StringID str);
 
	void MarkDirty() const;
 
};
 

	
 
enum {
src/waypoint.cpp
Show inline comments
 
@@ -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()
src/waypoint.h
Show inline comments
 
@@ -60,6 +60,5 @@ void ShowWaypointWindow(const Waypoint *
 
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 */
src/waypoint_cmd.cpp
Show inline comments
 
@@ -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(TileIn
 
				}
 
			}
 

	
 
			RedrawWaypointSign(wp);
 
			wp->sign.MarkDirty();
 
			wp->xy = tile;
 
			InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index);
 
		}
 
@@ -224,7 +212,7 @@ CommandCost CmdBuildTrainWaypoint(TileIn
 
		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(TileInde
 
		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) {
0 comments (0 inline, 0 general)