1
0
Fork 0

(svn r16821) -Codechange: unify the naming of type::UpdateVirtCoord and UpdateAll[Type]VirtCoords.

release/1.0
rubidium 2009-07-13 22:33:25 +00:00
parent db63e1ad82
commit e067d4a4b8
15 changed files with 51 additions and 53 deletions

View File

@ -183,7 +183,7 @@ void ZoomInOrOutToCursorWindow(bool in, Window *w)
} }
} }
extern void UpdateAllStationVirtCoord(); extern void UpdateAllStationVirtCoords();
struct MainWindow : Window struct MainWindow : Window
{ {
@ -268,7 +268,7 @@ struct MainWindow : Window
break; break;
case '2' | WKC_ALT: // Update the coordinates of all station signs case '2' | WKC_ALT: // Update the coordinates of all station signs
UpdateAllStationVirtCoord(); UpdateAllStationVirtCoords();
break; break;
#endif #endif

View File

@ -213,10 +213,10 @@ static bool InitializeWindowsAndCaches()
ResetViewportAfterLoadGame(); ResetViewportAfterLoadGame();
/* Update coordinates of the signs. */ /* Update coordinates of the signs. */
UpdateAllStationVirtCoord(); UpdateAllStationVirtCoords();
UpdateAllSignVirtCoords(); UpdateAllSignVirtCoords();
UpdateAllTownVirtCoords(); UpdateAllTownVirtCoords();
UpdateAllWaypointSigns(); UpdateAllWaypointVirtCoords();
Company *c; Company *c;
FOR_ALL_COMPANIES(c) { FOR_ALL_COMPANIES(c) {

View File

@ -645,9 +645,7 @@ static bool v_PositionMainToolbar(int32 p1)
static bool PopulationInLabelActive(int32 p1) static bool PopulationInLabelActive(int32 p1)
{ {
Town *t; UpdateAllTownVirtCoords();
FOR_ALL_TOWNS(t) UpdateTownVirtCoord(t);
return true; return true;
} }

View File

@ -321,8 +321,8 @@ struct GameOptionsWindow : Window {
case GOW_LANG_DROPDOWN: // Change interface language case GOW_LANG_DROPDOWN: // Change interface language
ReadLanguagePack(index); ReadLanguagePack(index);
CheckForMissingGlyphsInLoadedLanguagePack(); CheckForMissingGlyphsInLoadedLanguagePack();
UpdateAllStationVirtCoord(); UpdateAllStationVirtCoords();
UpdateAllWaypointSigns(); UpdateAllWaypointVirtCoords();
ReInitAllWindows(); ReInitAllWindows();
MarkWholeScreenDirty(); MarkWholeScreenDirty();
break; break;

View File

@ -33,16 +33,13 @@ Sign::~Sign()
} }
/** /**
*
* Update the coordinate of one sign * Update the coordinate of one sign
* @param si Pointer to the Sign
*
*/ */
void UpdateSignVirtCoords(Sign *si) void Sign::UpdateVirtCoord()
{ {
Point pt = RemapCoords(si->x, si->y, si->z); Point pt = RemapCoords(this->x, this->y, this->z);
SetDParam(0, si->index); SetDParam(0, this->index);
si->sign.UpdatePosition(pt.x, pt.y - 6, STR_SIGN_WHITE); this->sign.UpdatePosition(pt.x, pt.y - 6, STR_SIGN_WHITE);
} }
/** Update the coordinates of all signs */ /** Update the coordinates of all signs */
@ -50,7 +47,9 @@ void UpdateAllSignVirtCoords()
{ {
Sign *si; Sign *si;
FOR_ALL_SIGNS(si) UpdateSignVirtCoords(si); FOR_ALL_SIGNS(si) {
si->UpdateVirtCoord();
}
} }
/** /**

View File

@ -28,6 +28,8 @@ struct Sign : SignPool::PoolItem<&_sign_pool> {
/** Destroy the sign */ /** Destroy the sign */
~Sign(); ~Sign();
void UpdateVirtCoord();
}; };
#define FOR_ALL_SIGNS_FROM(var, start) FOR_ALL_ITEMS_FROM(Sign, sign_index, var, start) #define FOR_ALL_SIGNS_FROM(var, start) FOR_ALL_ITEMS_FROM(Sign, sign_index, var, start)

View File

@ -46,7 +46,7 @@ CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (!StrEmpty(text)) { if (!StrEmpty(text)) {
si->name = strdup(text); si->name = strdup(text);
} }
UpdateSignVirtCoords(si); si->UpdateVirtCoord();
si->sign.MarkDirty(); si->sign.MarkDirty();
InvalidateWindowData(WC_SIGN_LIST, 0, 0); InvalidateWindowData(WC_SIGN_LIST, 0, 0);
_new_sign_id = si->index; _new_sign_id = si->index;
@ -82,7 +82,7 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
/* Update; mark sign dirty twice, because it can either become longer, or shorter */ /* Update; mark sign dirty twice, because it can either become longer, or shorter */
si->sign.MarkDirty(); si->sign.MarkDirty();
UpdateSignVirtCoords(si); si->UpdateVirtCoord();
si->sign.MarkDirty(); si->sign.MarkDirty();
InvalidateWindowData(WC_SIGN_LIST, 0, 1); InvalidateWindowData(WC_SIGN_LIST, 0, 1);
} }

View File

@ -11,7 +11,6 @@ extern SignID _new_sign_id;
void UpdateAllSignVirtCoords(); void UpdateAllSignVirtCoords();
void PlaceProc_Sign(TileIndex tile); void PlaceProc_Sign(TileIndex tile);
void UpdateSignVirtCoords(Sign *si);
/* signs_gui.cpp */ /* signs_gui.cpp */
void ShowRenameSignWindow(const Sign *si); void ShowRenameSignWindow(const Sign *si);

View File

@ -367,9 +367,7 @@ static Station *GetClosestDeletedStation(TileIndex tile)
} }
/** /**
* Update the virtual coords needed to draw the station sign and * Update the virtual coords needed to draw the station sign.
* mark the station sign dirty.
* @ingroup dirty
*/ */
void Station::UpdateVirtCoord() void Station::UpdateVirtCoord()
{ {
@ -384,7 +382,7 @@ void Station::UpdateVirtCoord()
} }
/** Update the virtual coords needed to draw the station sign for all stations. */ /** Update the virtual coords needed to draw the station sign for all stations. */
void UpdateAllStationVirtCoord() void UpdateAllStationVirtCoords()
{ {
Station *st; Station *st;

View File

@ -20,7 +20,7 @@ typedef SmallVector<Station*, 1> StationList;
void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList *stations); void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList *stations);
void ShowStationViewWindow(StationID station); void ShowStationViewWindow(StationID station);
void UpdateAllStationVirtCoord(); void UpdateAllStationVirtCoords();
CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad); CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad);
CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad); CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad);

View File

@ -48,7 +48,7 @@ struct Town : TownPool::PoolItem<&_town_pool> {
uint32 townnameparts; uint32 townnameparts;
char *name; char *name;
/* NOSAVE: Location of name sign, UpdateTownVirtCoord updates this. */ /* NOSAVE: Location of name sign, UpdateVirtCoord updates this. */
ViewportSign sign; ViewportSign sign;
/* Makes sure we don't build certain house types twice. /* Makes sure we don't build certain house types twice.
@ -136,6 +136,8 @@ struct Town : TownPool::PoolItem<&_town_pool> {
return ((this->population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3); return ((this->population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
} }
void UpdateVirtCoord();
static FORCEINLINE Town *GetByTile(TileIndex tile) static FORCEINLINE Town *GetByTile(TileIndex tile)
{ {
return Town::Get(GetTownIndex(tile)); return Town::Get(GetTownIndex(tile));
@ -147,7 +149,6 @@ struct Town : TownPool::PoolItem<&_town_pool> {
uint32 GetWorldPopulation(); uint32 GetWorldPopulation();
void UpdateTownVirtCoord(Town *t);
void UpdateAllTownVirtCoords(); void UpdateAllTownVirtCoords();
void InitializeTown(); void InitializeTown();
void ShowTownViewWindow(TownID town); void ShowTownViewWindow(TownID town);

View File

@ -324,25 +324,25 @@ static bool IsCloseToTown(TileIndex tile, uint dist)
/** /**
* Resize the sign(label) of the town after changes in * Resize the sign(label) of the town after changes in
* population (creation or growth or else) * population (creation or growth or else)
* @param t Town to update
*/ */
void UpdateTownVirtCoord(Town *t) void Town::UpdateVirtCoord()
{ {
t->sign.MarkDirty(); this->sign.MarkDirty();
Point pt = RemapCoords2(TileX(t->xy) * TILE_SIZE, TileY(t->xy) * TILE_SIZE); Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
SetDParam(0, t->index); SetDParam(0, this->index);
SetDParam(1, t->population); SetDParam(1, this->population);
t->sign.UpdatePosition(pt.x, pt.y - 24, this->sign.UpdatePosition(pt.x, pt.y - 24,
_settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL); _settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL);
t->sign.MarkDirty(); this->sign.MarkDirty();
} }
/** Update the virtual coords needed to draw the town sign for all towns. */ /** Update the virtual coords needed to draw the town sign for all towns. */
void UpdateAllTownVirtCoords() void UpdateAllTownVirtCoords()
{ {
Town *t; Town *t;
FOR_ALL_TOWNS(t) { FOR_ALL_TOWNS(t) {
UpdateTownVirtCoord(t); t->UpdateVirtCoord();
} }
} }
@ -355,7 +355,7 @@ static void ChangePopulation(Town *t, int mod)
{ {
t->population += mod; t->population += mod;
InvalidateWindow(WC_TOWN_VIEW, t->index); InvalidateWindow(WC_TOWN_VIEW, t->index);
UpdateTownVirtCoord(t); t->UpdateVirtCoord();
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1); InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
} }
@ -1505,7 +1505,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
} }
t->townnameparts = townnameparts; t->townnameparts = townnameparts;
UpdateTownVirtCoord(t); t->UpdateVirtCoord();
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 0); InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 0);
t->InitializeLayout(layout); t->InitializeLayout(layout);
@ -2285,10 +2285,10 @@ CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
free(t->name); free(t->name);
t->name = reset ? NULL : strdup(text); t->name = reset ? NULL : strdup(text);
UpdateTownVirtCoord(t); t->UpdateVirtCoord();
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1); InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
UpdateAllStationVirtCoord(); UpdateAllStationVirtCoords();
UpdateAllWaypointSigns(); UpdateAllWaypointVirtCoords();
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
return CommandCost(); return CommandCost();

View File

@ -20,12 +20,12 @@ INSTANTIATE_POOL_METHODS(Waypoint)
/** /**
* Update all signs * Update all signs
*/ */
void UpdateAllWaypointSigns() void UpdateAllWaypointVirtCoords()
{ {
Waypoint *wp; Waypoint *wp;
FOR_ALL_WAYPOINTS(wp) { FOR_ALL_WAYPOINTS(wp) {
UpdateWaypointSign(wp); wp->UpdateVirtCoord();
} }
} }

View File

@ -37,6 +37,8 @@ struct Waypoint : WaypointPool::PoolItem<&_waypoint_pool> {
Waypoint(TileIndex tile = INVALID_TILE) : xy(tile) { } Waypoint(TileIndex tile = INVALID_TILE) : xy(tile) { }
~Waypoint(); ~Waypoint();
void UpdateVirtCoord();
}; };
#define FOR_ALL_WAYPOINTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Waypoint, waypoint_index, var, start) #define FOR_ALL_WAYPOINTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Waypoint, waypoint_index, var, start)
@ -58,7 +60,6 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justre
Station *ComposeWaypointStation(TileIndex tile); Station *ComposeWaypointStation(TileIndex tile);
void ShowWaypointWindow(const Waypoint *wp); void ShowWaypointWindow(const Waypoint *wp);
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype); void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype);
void UpdateAllWaypointSigns(); void UpdateAllWaypointVirtCoords();
void UpdateWaypointSign(Waypoint *wp);
#endif /* WAYPOINT_H */ #endif /* WAYPOINT_H */

View File

@ -26,13 +26,13 @@
#include "table/strings.h" #include "table/strings.h"
/** /**
* Update the sign for the waypoint * Update the virtual coords needed to draw the waypoint sign.
* @param wp Waypoint to update sign */ */
void UpdateWaypointSign(Waypoint *wp) void Waypoint::UpdateVirtCoord()
{ {
Point pt = RemapCoords2(TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE); Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
SetDParam(0, wp->index); SetDParam(0, this->index);
wp->sign.UpdatePosition(pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT); this->sign.UpdatePosition(pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
} }
/** /**
@ -211,7 +211,7 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1
if (wp->town_index == INVALID_TOWN) MakeDefaultWaypointName(wp); if (wp->town_index == INVALID_TOWN) MakeDefaultWaypointName(wp);
UpdateWaypointSign(wp); wp->UpdateVirtCoord();
wp->sign.MarkDirty(); wp->sign.MarkDirty();
YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis)); YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis));
} }
@ -319,7 +319,7 @@ CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
wp->name = strdup(text); wp->name = strdup(text);
} }
UpdateWaypointSign(wp); wp->UpdateVirtCoord();
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
return CommandCost(); return CommandCost();