mirror of https://github.com/OpenTTD/OpenTTD
(svn r22617) -Codechange: Add GameOptionsInvalidationData enum for data values for Window::OnInvalidateData() of windows with class WC_GAME_OPTIONS.
parent
56a41a8852
commit
1688470eb9
|
@ -1269,7 +1269,7 @@ DEF_CONSOLE_CMD(ConRescanNewGRF)
|
||||||
|
|
||||||
TarScanner::DoScan();
|
TarScanner::DoScan();
|
||||||
ScanNewGRFFiles();
|
ScanNewGRFFiles();
|
||||||
InvalidateWindowData(WC_GAME_OPTIONS, 0, 1);
|
InvalidateWindowData(WC_GAME_OPTIONS, 0, GOID_NEWGRF_RESCANNED);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ public:
|
||||||
ScanNewGRFFiles();
|
ScanNewGRFFiles();
|
||||||
/* Yes... these are the NewGRF windows */
|
/* Yes... these are the NewGRF windows */
|
||||||
InvalidateWindowClassesData(WC_SAVELOAD);
|
InvalidateWindowClassesData(WC_SAVELOAD);
|
||||||
InvalidateWindowData(WC_GAME_OPTIONS, 0, 1);
|
InvalidateWindowData(WC_GAME_OPTIONS, 0, GOID_NEWGRF_RESCANNED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CONTENT_TYPE_SCENARIO:
|
case CONTENT_TYPE_SCENARIO:
|
||||||
|
|
|
@ -569,7 +569,7 @@ struct NewGRFWindow : public QueryStringBaseWindow {
|
||||||
this->avails.SetFilterFuncs(this->filter_funcs);
|
this->avails.SetFilterFuncs(this->filter_funcs);
|
||||||
this->avails.ForceRebuild();
|
this->avails.ForceRebuild();
|
||||||
|
|
||||||
this->OnInvalidateData(2);
|
this->OnInvalidateData(GOID_NEWGRF_LIST_EDITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
~NewGRFWindow()
|
~NewGRFWindow()
|
||||||
|
@ -881,7 +881,7 @@ struct NewGRFWindow : public QueryStringBaseWindow {
|
||||||
this->avail_pos = -1;
|
this->avail_pos = -1;
|
||||||
this->avail_sel = NULL;
|
this->avail_sel = NULL;
|
||||||
this->avails.ForceRebuild();
|
this->avails.ForceRebuild();
|
||||||
this->InvalidateData(2);
|
this->InvalidateData(GOID_NEWGRF_LIST_EDITED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -921,7 +921,7 @@ struct NewGRFWindow : public QueryStringBaseWindow {
|
||||||
if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
|
if (new_pos >= 0) this->avail_sel = this->avails[new_pos];
|
||||||
|
|
||||||
this->avails.ForceRebuild();
|
this->avails.ForceRebuild();
|
||||||
this->InvalidateData(2);
|
this->InvalidateData(GOID_NEWGRF_LIST_EDITED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -989,7 +989,7 @@ struct NewGRFWindow : public QueryStringBaseWindow {
|
||||||
this->avail_sel = NULL;
|
this->avail_sel = NULL;
|
||||||
this->avail_pos = -1;
|
this->avail_pos = -1;
|
||||||
this->avails.ForceRebuild();
|
this->avails.ForceRebuild();
|
||||||
this->InvalidateData(1);
|
this->InvalidateData(GOID_NEWGRF_RESCANNED);
|
||||||
this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
|
this->DeleteChildWindows(WC_QUERY_STRING); // Remove the parameter query window
|
||||||
InvalidateWindowClassesData(WC_SAVELOAD);
|
InvalidateWindowClassesData(WC_SAVELOAD);
|
||||||
break;
|
break;
|
||||||
|
@ -1010,7 +1010,7 @@ struct NewGRFWindow : public QueryStringBaseWindow {
|
||||||
|
|
||||||
DeleteWindowByClass(WC_GRF_PARAMETERS);
|
DeleteWindowByClass(WC_GRF_PARAMETERS);
|
||||||
this->active_sel = NULL;
|
this->active_sel = NULL;
|
||||||
this->InvalidateData(3);
|
this->InvalidateData(GOID_NEWGRF_PRESET_LOADED);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnQueryTextFinished(char *str)
|
virtual void OnQueryTextFinished(char *str)
|
||||||
|
@ -1033,24 +1033,18 @@ struct NewGRFWindow : public QueryStringBaseWindow {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some data on this window has become invalid.
|
* Some data on this window has become invalid.
|
||||||
* @param data Information about the changed data.
|
* @param data Information about the changed data. @see GameOptionsInvalidationData
|
||||||
* - 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.
|
* @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)
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||||
{
|
{
|
||||||
if (!gui_scope) return;
|
if (!gui_scope) return;
|
||||||
switch (data) {
|
switch (data) {
|
||||||
default: NOT_REACHED();
|
default:
|
||||||
case 0:
|
|
||||||
/* Nothing important to do */
|
/* Nothing important to do */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case GOID_NEWGRF_RESCANNED:
|
||||||
/* Search the list for items that are now found and mark them as such. */
|
/* Search the list for items that are now found and mark them as such. */
|
||||||
for (GRFConfig **l = &this->actives; *l != NULL; l = &(*l)->next) {
|
for (GRFConfig **l = &this->actives; *l != NULL; l = &(*l)->next) {
|
||||||
GRFConfig *c = *l;
|
GRFConfig *c = *l;
|
||||||
|
@ -1067,14 +1061,14 @@ struct NewGRFWindow : public QueryStringBaseWindow {
|
||||||
|
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
/* FALL THROUGH */
|
|
||||||
case 4:
|
|
||||||
this->avails.ForceRebuild();
|
this->avails.ForceRebuild();
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
case 2:
|
case GOID_NEWGRF_LIST_EDITED:
|
||||||
this->preset = -1;
|
this->preset = -1;
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
case 3: {
|
case GOID_NEWGRF_PRESET_LOADED: {
|
||||||
|
/* Update scrollbars */
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const GRFConfig *c = this->actives; c != NULL; c = c->next, i++) {}
|
for (const GRFConfig *c = this->actives; c != NULL; c = c->next, i++) {}
|
||||||
|
|
||||||
|
|
|
@ -527,7 +527,7 @@ struct GameOptionsWindow : Window {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some data on this window has become invalid.
|
* Some data on this window has become invalid.
|
||||||
* @param data Information about the changed data.
|
* @param data Information about the changed data. @see GameOptionsInvalidationData
|
||||||
* @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.
|
* @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)
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||||
|
@ -797,7 +797,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some data on this window has become invalid.
|
* Some data on this window has become invalid.
|
||||||
* @param data Information about the changed data.
|
* @param data Information about the changed data. @see GameOptionsInvalidationData
|
||||||
* @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.
|
* @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)
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
||||||
|
|
|
@ -115,6 +115,16 @@ enum WindowClass {
|
||||||
WC_INVALID = 0xFFFF
|
WC_INVALID = 0xFFFF
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data value for #Window::OnInvalidateData() of windows with class #WC_GAME_OPTIONS.
|
||||||
|
*/
|
||||||
|
enum GameOptionsInvalidationData {
|
||||||
|
GOID_DEFAULT = 0,
|
||||||
|
GOID_NEWGRF_RESCANNED, ///< NewGRFs were just rescanned.
|
||||||
|
GOID_NEWGRF_LIST_EDITED, ///< List of active NewGRFs is being edited.
|
||||||
|
GOID_NEWGRF_PRESET_LOADED, ///< A NewGRF preset was picked.
|
||||||
|
};
|
||||||
|
|
||||||
struct Window;
|
struct Window;
|
||||||
|
|
||||||
/** Number to differentiate different windows of the same class */
|
/** Number to differentiate different windows of the same class */
|
||||||
|
|
Loading…
Reference in New Issue