Changeset - r17482:4dbb8b190ff9
[Not reviewed]
master
0 10 0
frosch - 13 years ago 2011-03-13 21:34:21
frosch@openttd.org
(svn r22247) -Codechange: Update comments wrt. ForceRebuild() in command-scope.
10 files changed with 11 insertions and 31 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -489,26 +489,26 @@ public:
 

	
 
		this->GetWidget<NWidgetCore>(RVW_WIDGET_LEFT_MATRIX)->widget_data =
 
				this->GetWidget<NWidgetCore>(RVW_WIDGET_RIGHT_MATRIX)->widget_data = (this->vscroll[0]->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		if (data != 0) {
 
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
			this->engines[0].ForceRebuild();
 
		} else {
 
			this->engines[1].ForceRebuild();
 
		}
 
	}
 
};
 

	
 
static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, RVW_WIDGET_CAPTION), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
src/depot_gui.cpp
Show inline comments
 
@@ -633,25 +633,24 @@ struct DepotWindow : Window {
 
				break;
 
			}
 
		}
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		this->generate_list = true;
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		if (this->generate_list) {
 
			/* Generate the vehicle list
 
			 * It's ok to use the wagon pointers for non-trains as they will be ignored */
 
			BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list);
 
			this->generate_list = false;
 
			DepotSortList(&this->vehicle_list);
 
		}
src/graph_gui.cpp
Show inline comments
 
@@ -1263,26 +1263,26 @@ public:
 
		if (this->companies.NeedResort()) {
 
			this->SetDirty();
 
		}
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		if (data == 0) {
 
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
			this->companies.ForceRebuild();
 
		} else {
 
			this->companies.ForceResort();
 
		}
 
	}
 
};
 

	
 
static const NWidgetPart _nested_company_league_widgets[] = {
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_COMPANY_LEAGUE_TABLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
 
		NWidget(WWT_SHADEBOX, COLOUR_GREY),
src/group_gui.cpp
Show inline comments
 
@@ -251,36 +251,34 @@ public:
 
				break;
 
			}
 
		}
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		/* We can only set the trigger for resorting/rebuilding.
 
		 * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
 
		 * and a rebuild needs to be done first though it is scheduled later. */
 
		if (data == 0) {
 
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
			this->vehicles.ForceRebuild();
 
			this->groups.ForceRebuild();
 
		} else {
 
			this->vehicles.ForceResort();
 
			this->groups.ForceResort();
 
		}
 

	
 
		/* Process ID-invalidation in command-scope as well */
 
		if (this->group_rename != INVALID_GROUP && !Group::IsValidID(this->group_rename)) {
 
			DeleteWindowByClass(WC_QUERY_STRING);
 
			this->group_rename = INVALID_GROUP;
 
		}
 

	
 
		if (!(IsAllGroupID(this->vli.index) || IsDefaultGroupID(this->vli.index) || Group::IsValidID(this->vli.index))) {
 
			this->vli.index = ALL_GROUP;
 
			HideDropDownMenu(this);
 
		}
 
		this->SetDirty();
 
	}
 

	
src/industry_gui.cpp
Show inline comments
 
@@ -1356,29 +1356,26 @@ public:
 
	{
 
		this->industries.ForceResort();
 
		this->BuildSortIndustriesList();
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		/* We can only set the trigger for resorting/rebuilding.
 
		 * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
 
		 * and a rebuild needs to be done first though it is scheduled later. */
 
		if (data == 0) {
 
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
			this->industries.ForceRebuild();
 
		} else {
 
			this->industries.ForceResort();
 
		}
 
	}
 
};
 

	
 
Listing IndustryDirectoryWindow::last_sorting = {false, 0};
 
const Industry *IndustryDirectoryWindow::last_industry = NULL;
 

	
 
/* Available station sorting functions. */
 
GUIIndustryList::SortFunction * const IndustryDirectoryWindow::sorter_funcs[] = {
src/network/network_gui.cpp
Show inline comments
 
@@ -792,25 +792,24 @@ public:
 
	virtual void OnMouseLoop()
 
	{
 
		if (this->field == NGWW_CLIENT) this->HandleEditBox(NGWW_CLIENT);
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		if (data == 1) {
 
			this->server = NULL;
 
			this->list_pos = SLP_INVALID;
 
		}
 
		this->servers.ForceRebuild();
 
		this->SetDirty();
 
	}
 

	
 
	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
 
	{
 
		EventState state = ES_NOT_HANDLED;
 

	
src/signs_gui.cpp
Show inline comments
 
@@ -365,33 +365,29 @@ struct SignListWindow : QueryStringBaseW
 
	{
 
		this->BuildSortSignList();
 
		this->SetDirty();
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		/* When there is a filter string, we always need to rebuild the list even if
 
		 * the amount of signs in total is unchanged, as the subset of signs that is
 
		 * accepted by the filter might has changed.
 
		 *
 
		 * We can only set the trigger for resorting/rebuilding.
 
		 * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
 
		 * and a rebuild needs to be done first though it is scheduled later. */
 
		 * accepted by the filter might has changed. */
 
		if (data == 0 || !StrEmpty(this->filter_string)) { // New or deleted sign, or there is a filter string
 
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
			this->signs.ForceRebuild();
 
		} else { // Change of sign contents while there is no filter string
 
			this->signs.ForceResort();
 
		}
 
	}
 

	
 
	static Hotkey<SignListWindow> signlist_hotkeys[];
 
};
 

	
 
Hotkey<SignListWindow> SignListWindow::signlist_hotkeys[] = {
 
	Hotkey<SignListWindow>('F', "focus_filter_box", SLHK_FOCUS_FILTER_BOX),
 
	HOTKEY_LIST_END(SignListWindow)
src/station_gui.cpp
Show inline comments
 
@@ -685,29 +685,26 @@ public:
 
	virtual void OnResize()
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		/* We can only set the trigger for resorting/rebuilding.
 
		 * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
 
		 * and a rebuild needs to be done first though it is scheduled later. */
 
		if (data == 0) {
 
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
			this->stations.ForceRebuild();
 
		} else {
 
			this->stations.ForceResort();
 
		}
 
	}
 
};
 

	
 
Listing CompanyStationsWindow::last_sorting = {false, 0};
 
byte CompanyStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
 
bool CompanyStationsWindow::include_empty = true;
 
const uint32 CompanyStationsWindow::cargo_filter_max = UINT32_MAX;
 
uint32 CompanyStationsWindow::cargo_filter = UINT32_MAX;
src/town_gui.cpp
Show inline comments
 
@@ -867,29 +867,26 @@ public:
 
	virtual void OnResize()
 
	{
 
		this->vscroll->SetCapacityFromWidget(this, TDW_CENTERTOWN);
 
	}
 

	
 
	/**
 
	 * Some data on this window has become invalid.
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope) return;
 
		/* We can only set the trigger for resorting/rebuilding.
 
		 * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
 
		 * and a rebuild needs to be done first though it is scheduled later. */
 
		if (data == 0) {
 
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
			this->towns.ForceRebuild();
 
		} else {
 
			this->towns.ForceResort();
 
		}
 
	}
 
};
 

	
 
Listing TownDirectoryWindow::last_sorting = {false, 0};
 
const Town *TownDirectoryWindow::last_town = NULL;
 

	
 
/* Available town directory sorting functions */
 
GUITownList::SortFunction * const TownDirectoryWindow::sorter_funcs[] = {
src/vehicle_gui.cpp
Show inline comments
 
@@ -1607,30 +1607,27 @@ public:
 
	 * @param data Information about the changed data.
 
	 * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (!gui_scope && HasBit(data, 31) && this->vli.type == VL_SHARED_ORDERS) {
 
			/* Needs to be done in command-scope, so everything stays valid */
 
			this->vli.index = GB(data, 0, 20);
 
			this->window_number = this->vli.Pack();
 
			this->vehicles.ForceRebuild();
 
			return;
 
		}
 
		if (!gui_scope) return;
 

	
 
		/* We can only set the trigger for resorting/rebuilding.
 
		 * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
 
		 * and a rebuild needs to be done first though it is scheduled later. */
 

	
 
		if (data == 0) {
 
			/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
 
			this->vehicles.ForceRebuild();
 
		} else {
 
			this->vehicles.ForceResort();
 
		}
 
	}
 
};
 

	
 
static WindowDesc _vehicle_list_desc(
 
	WDP_AUTO, 260, 246,
 
	WC_INVALID, WC_NONE,
 
	WDF_UNCLICK_BUTTONS,
 
	_nested_vehicle_list, lengthof(_nested_vehicle_list)
0 comments (0 inline, 0 general)