diff src/newgrf_gui.cpp @ 17486:e7672bafbe1c draft

(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
author frosch <frosch@openttd.org>
date Sun, 13 Mar 2011 21:31:29 +0000 (2011-03-13)
parents 5a60038ce980
children 105b4e4eb168
line wrap: on
line diff
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -379,8 +379,14 @@
 		nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
 	}
 
-	virtual void OnInvalidateData(int data)
+	/**
+	 * 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 (!this->action14present) {
 			this->SetWidgetDisabledState(GRFPAR_WIDGET_NUMPAR_DEC, this->grf_config->num_params == 0);
 			this->SetWidgetDisabledState(GRFPAR_WIDGET_NUMPAR_INC, this->grf_config->num_params >= this->grf_config->num_valid_params);
@@ -1025,15 +1031,18 @@
 	}
 
 	/**
-	 * Calback to update internal data.
+	 * Some data on this window has become invalid.
+	 * @param data Information about the changed data.
 	 *  - 0: (optionally) build availables, update button status.
 	 *  - 1: build availables, Add newly found grfs, update button status.
 	 *  - 2: (optionally) build availables, Reset preset, + 3
 	 *  - 3: (optionally) build availables, Update active scrollbar, update button status.
 	 *  - 4: Force a rebuild of the availables, + 2
+	 * @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)
+	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 	{
+		if (!gui_scope) return;
 		switch (data) {
 			default: NOT_REACHED();
 			case 0: