From 4b4a40a72ec6c39578ab65e2ca95106cdfe96993 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 13 Mar 2011 21:31:29 +0000 Subject: [PATCH] (svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData(). --- src/ai/ai_gui.cpp | 32 +++++++++++++++++++++--- src/autoreplace_gui.cpp | 8 +++++- src/build_vehicle_gui.cpp | 8 +++++- src/company_gui.cpp | 8 +++++- src/depot_gui.cpp | 8 +++++- src/dock_gui.cpp | 8 +++++- src/fios_gui.cpp | 8 +++++- src/genworld_gui.cpp | 8 +++++- src/graph_gui.cpp | 38 ++++++++++++++++++++++++----- src/group_gui.cpp | 8 +++++- src/industry_gui.cpp | 32 +++++++++++++++++++----- src/intro_gui.cpp | 8 +++++- src/main_gui.cpp | 8 +++++- src/misc_gui.cpp | 16 ++++++++++-- src/music_gui.cpp | 16 ++++++++++-- src/network/network_chat_gui.cpp | 8 +++++- src/network/network_content_gui.cpp | 8 +++++- src/network/network_gui.cpp | 8 +++++- src/newgrf_debug_gui.cpp | 8 +++++- src/newgrf_gui.cpp | 15 +++++++++--- src/news_gui.cpp | 24 +++++++++++++++--- src/order_gui.cpp | 8 +++++- src/osk_gui.cpp | 8 +++++- src/rail_gui.cpp | 8 +++++- src/road_gui.cpp | 8 +++++- src/settings_gui.cpp | 16 ++++++++++-- src/signs_gui.cpp | 8 +++++- src/smallmap_gui.cpp | 7 ++++-- src/station_gui.cpp | 16 ++++++++++-- src/statusbar_gui.cpp | 8 +++++- src/subsidy_gui.cpp | 8 +++++- src/timetable_gui.cpp | 8 +++++- src/toolbar_gui.cpp | 16 ++++++++++-- src/town_gui.cpp | 24 +++++++++++++++--- src/transparency_gui.cpp | 8 +++++- src/tree_gui.cpp | 8 +++++- src/vehicle_gui.cpp | 32 +++++++++++++++++++++--- src/viewport_gui.cpp | 8 +++++- src/waypoint_gui.cpp | 8 +++++- src/window_gui.h | 4 +-- 40 files changed, 427 insertions(+), 69 deletions(-) diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 1bc7ad9de9..e16644d4f1 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -182,8 +182,14 @@ struct AIListWindow : public Window { 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 (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) { delete this; return; @@ -437,8 +443,14 @@ struct AISettingsWindow : public Window { } } - 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 (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) delete this; } }; @@ -692,8 +704,14 @@ struct AIConfigWindow : public Window { } } - 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 (!IsEditable(this->selected_slot)) { this->selected_slot = INVALID_COMPANY; } @@ -1032,8 +1050,14 @@ struct AIDebugWindow : public QueryStringBaseWindow { return state; } - virtual void OnInvalidateData(int data = 0) + /** + * 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 || ai_debug_company == data) this->SetDirty(); if (data == -2) { diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 6182953d00..000df79632 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -491,8 +491,14 @@ public: this->GetWidget(RVW_WIDGET_RIGHT_MATRIX)->widget_data = (this->vscroll[0]->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 (data != 0) { this->engines[0].ForceRebuild(); } else { diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index dd3d8731d8..2caa42d9dd 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1218,8 +1218,14 @@ struct BuildVehicleWindow : Window { } } - 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; /* When switching to original acceleration model for road vehicles, clear the selected sort criteria if it is not available now. */ if (this->vehicle_type == VEH_ROAD && _settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL && diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 8471ccfe3d..7c45f3fed3 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -800,8 +800,14 @@ public: } } - virtual void OnInvalidateData(int data = 0) + /** + * 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->SetWidgetsDisabledState(true, SCLW_WIDGET_CLASS_RAIL, SCLW_WIDGET_CLASS_ROAD, SCLW_WIDGET_CLASS_SHIP, SCLW_WIDGET_CLASS_AIRCRAFT, WIDGET_LIST_END); bool current_class_valid = this->livery_class == LC_OTHER; diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index d3866af425..095d67b574 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -635,8 +635,14 @@ struct DepotWindow : Window { } } - 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; this->generate_list = true; } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 8e667ec3c0..f7c50fc6af 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -119,8 +119,14 @@ struct BuildDocksToolbarWindow : Window { if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false); } - void OnInvalidateData(int data = 0) + /** + * 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->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP), DTW_DEPOT, DTW_STATION, diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index c9bc284f54..c871678829 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -659,8 +659,14 @@ public: this->vscroll->SetCapacityFromWidget(this, SLWW_DRIVES_DIRECTORIES_LIST); } - 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; switch (data) { case 0: /* Rescan files */ diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 5104154d69..fffdb1587f 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -425,8 +425,14 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow { } } - virtual void OnInvalidateData(int data = 0) + /** + * 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; /* Update the climate buttons */ this->SetWidgetLoweredState(GLAND_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE); this->SetWidgetLoweredState(GLAND_ARCTIC, _settings_newgame.game_creation.landscape == LT_ARCTIC); diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 28ccf2bed7..6354366b0f 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -91,8 +91,14 @@ struct GraphLegendWindow : Window { InvalidateWindowData(WC_COMPANY_VALUE, 0); } - 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 (Company::IsValidID(data)) return; SetBit(_legend_excluded_companies, data); @@ -543,8 +549,14 @@ public: this->UpdateStatistics(false); } - 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; this->UpdateStatistics(true); } @@ -1013,8 +1025,14 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { /* Override default OnTick */ } - 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; this->OnHundredthTick(); } @@ -1247,8 +1265,14 @@ public: } } - 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 (data == 0) { this->companies.ForceRebuild(); } else { @@ -1488,11 +1512,13 @@ struct PerformanceRatingDetailWindow : Window { } /** - * Invalidate the data of this window. + * Some data on this window has become invalid. * @param data the company ID of the company that is going to be removed + * @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) + virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { + if (!gui_scope) return; /* Disable the companies who are not active */ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) { this->SetWidgetDisabledState(i + PRW_COMPANY_FIRST, !Company::IsValidID(i)); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 6f23af3fb9..906b099ec0 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -253,8 +253,14 @@ public: } } - 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; /* 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. */ diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 012d0a39d8..bc72f19650 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -597,8 +597,14 @@ public: this->RaiseButtons(); } - virtual void OnInvalidateData(int data = 0) + /** + * 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->SetupArrays(); const IndustrySpec *indsp = (this->selected_type == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(this->selected_type); @@ -947,8 +953,14 @@ public: this->SetDirty(); } - 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; const Industry *i = Industry::Get(this->window_number); if (IsProductionAlterable(i)) { const IndustrySpec *ind = GetIndustrySpec(i->type); @@ -1346,8 +1358,14 @@ public: this->BuildSortIndustriesList(); } - 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; /* 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. */ @@ -2394,13 +2412,15 @@ struct IndustryCargoesWindow : public Window { } /** - * Notify the window about external events. + * Some data on this window has become invalid. + * @param data Information about the changed data. * - data = 0 .. NUM_INDUSTRYTYPES - 1: Display the chain around the given industry. * - data = NUM_INDUSTRYTYPES: Stop sending updates to the smallmap window. - * @param data The event. + * @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) + virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { + if (!gui_scope) return; if (data == NUM_INDUSTRYTYPES) { if (this->IsWidgetLowered(ICW_NOTIFY)) { this->RaiseWidget(ICW_NOTIFY); diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 8f8458cbb5..1f5692d422 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -55,8 +55,14 @@ struct SelectGameWindow : public Window { this->OnInvalidateData(); } - virtual void OnInvalidateData(int data = 0) + /** + * 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->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE); this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_ARCTIC); this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TROPIC); diff --git a/src/main_gui.cpp b/src/main_gui.cpp index ed85860da5..45f2d7ebb5 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -432,8 +432,14 @@ struct MainWindow : Window } } - 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; /* Forward the message to the appropiate toolbar (ingame or scenario editor) */ InvalidateWindowData(WC_MAIN_TOOLBAR, 0, data, true); } diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index c86f6c6a36..4f97bcbf4d 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -332,8 +332,14 @@ public: ::ShowNewGRFInspectWindow(GetGrfSpecFeature(this->tile), this->tile); } - 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; switch (data) { case 1: /* ReInit, "debug" sprite might have changed */ @@ -639,8 +645,14 @@ public: return pt; } - 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 company gets shut down, while displaying an error about it, remove the error message. */ if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) delete this; } diff --git a/src/music_gui.cpp b/src/music_gui.cpp index a0cb8ac9b8..3a03fb152f 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -313,8 +313,14 @@ struct MusicTrackSelectionWindow : public Window { } } - virtual void OnInvalidateData(int data = 0) + /** + * 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; for (int i = 0; i < 6; i++) { this->SetWidgetLoweredState(MTSW_ALL + i, i == _settings_client.music.playlist); } @@ -638,8 +644,14 @@ struct MusicWindow : public Window { } } - virtual void OnInvalidateData(int data = 0) + /** + * 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; for (int i = 0; i < 6; i++) { this->SetWidgetLoweredState(MW_ALL + i, i == _settings_client.music.playlist); } diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index e610f9cbf4..ac7045d8c3 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -531,8 +531,14 @@ struct NetworkChatWindow : public QueryStringBaseWindow { ShowOnScreenKeyboard(this, wid, NWCW_CLOSE, NWCW_SENDBUTTON); } - 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 (data == this->dest) delete this; } }; diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index ee3a325d9f..13e0b5d59c 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -751,8 +751,14 @@ public: this->InvalidateData(); } - 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->content.NeedRebuild()) this->BuildContentList(); /* To sum all the bytes we intend to download */ diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index e62f2bcaee..5cb031d01c 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -794,8 +794,14 @@ public: if (this->field == NGWW_CLIENT) this->HandleEditBox(NGWW_CLIENT); } - 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 (data == 1) { this->server = NULL; this->list_pos = SLP_INVALID; diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index b96ecbd7f8..40581b9b2d 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -772,8 +772,14 @@ struct SpriteAlignerWindow : Window { this->SetDirty(); } - 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 (data == 1) { /* Sprite picker finished */ this->RaiseWidget(SAW_PICKER); diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 2034ae6abe..a1e45e3cc2 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -379,8 +379,14 @@ struct NewGRFParametersWindow : public Window { 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 @@ struct NewGRFWindow : public QueryStringBaseWindow { } /** - * 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: diff --git a/src/news_gui.cpp b/src/news_gui.cpp index a958e63926..4289285fc5 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -498,8 +498,14 @@ struct NewsWindow : Window { return ES_NOT_HANDLED; } - 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; /* The chatbar has notified us that is was either created or closed */ int newtop = this->top + this->chat_height - data; this->chat_height = data; @@ -1035,8 +1041,14 @@ struct MessageHistoryWindow : Window { } } - 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; this->vscroll->SetCount(_total_news); } @@ -1201,8 +1213,14 @@ struct MessageOptionsWindow : Window { } } - 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; /* Update the dropdown value for 'set all categories'. */ this->GetWidget(WIDGET_NEWSOPT_DROP_SUMMARY)->widget_data = this->message_opt[this->state]; diff --git a/src/order_gui.cpp b/src/order_gui.cpp index eefeddbfba..f12b104cc9 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -805,8 +805,14 @@ public: } } - 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; VehicleOrderID from = INVALID_VEH_ORDER_ID; VehicleOrderID to = INVALID_VEH_ORDER_ID; diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 0edb2eea3f..cd323b362c 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -247,8 +247,14 @@ struct OskWindow : public Window { this->parent->SetWidgetDirty(this->text_btn); } - virtual void OnInvalidateData(int) + /** + * 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->SetWidgetDirty(OSK_WIDGET_TEXT); } }; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 2b391218b6..36576a3ca2 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1617,8 +1617,14 @@ public: this->InvalidateData(); } - virtual void OnInvalidateData(int data = 0) + /** + * 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->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type); this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button); diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 0a99513143..9637240f33 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -341,8 +341,14 @@ struct BuildRoadToolbarWindow : Window { if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false); } - void OnInvalidateData(int data = 0) + /** + * 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->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD), RTW_DEPOT, RTW_BUS_STATION, diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 751075a201..0203b75746 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -460,8 +460,14 @@ struct GameOptionsWindow : Window { } } - 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; this->SetWidgetLoweredState(GOW_FULLSCREEN_BUTTON, _fullscreen); bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0; @@ -724,8 +730,14 @@ public: } } - virtual void OnInvalidateData(int data = 0) + /** + * 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; uint i; const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i); for (i = 0; i < GAME_DIFFICULTY_NUM; i++, sd++) { diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index f3101e99a1..d639e1dccb 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -367,8 +367,14 @@ struct SignListWindow : QueryStringBaseWindow, SignList { this->SetDirty(); } - 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; /* 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. diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index b7bcd9c20c..2fd86623dc 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1423,12 +1423,15 @@ public: } /** - * Notifications for the smallmap window. + * Some data on this window has become invalid. + * @param data Information about the changed data. * - data = 0: Displayed industries at the industry chain window have changed. * - data = 1: Companies have changed. + * @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) + virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { + if (!gui_scope) return; switch (data) { case 1: /* The owner legend has already been rebuilt. */ diff --git a/src/station_gui.cpp b/src/station_gui.cpp index fc27ae6153..cb40cb37de 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -687,8 +687,14 @@ public: this->vscroll->SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM); } - 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; /* 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. */ @@ -1451,8 +1457,14 @@ struct SelectStationWindow : Window { this->vscroll->SetCapacityFromWidget(this, JSW_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM); } - 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; FindStationsNearby(this->area, true); this->vscroll->SetCount(_stations_nearby_list.Length() + 1); this->SetDirty(); diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 4c11843367..82ffeb2393 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -183,8 +183,14 @@ struct StatusBarWindow : Window { } } - 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; switch (data) { default: NOT_REACHED(); case SBI_SAVELOAD_START: this->saving = true; break; diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 0b9182fdd2..9e31fb970d 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -215,8 +215,14 @@ struct SubsidyListWindow : Window { this->vscroll->SetCapacityFromWidget(this, SLW_PANEL); } - 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; this->vscroll->SetCount(this->CountLines()); } }; diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 4f991323bb..51cd82982f 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -243,8 +243,14 @@ struct TimetableWindow : Window { return (sel < v->GetNumOrders() * 2 && sel >= 0) ? sel : INVALID_ORDER; } - 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; switch (data) { case -666: /* Autoreplace replaced the vehicle */ diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index e57b2f101b..711b738467 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1482,8 +1482,14 @@ struct MainToolbarWindow : Window { } } - 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 (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBN_ZOOMIN, TBN_ZOOMOUT); } @@ -1792,8 +1798,14 @@ struct ScenarioEditorToolbarWindow : Window { } } - 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 (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBSE_ZOOMIN, TBSE_ZOOMOUT); } diff --git a/src/town_gui.cpp b/src/town_gui.cpp index cbcb43f203..016399e70e 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -523,8 +523,14 @@ public: } } - virtual void OnInvalidateData(int data = 0) + /** + * 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; /* Called when setting station noise or required cargos have changed, in order to resize the window */ this->SetDirty(); // refresh display for current size. This will allow to avoid glitches when downgrading this->ResizeWindowAsNeeded(); @@ -863,8 +869,14 @@ public: this->vscroll->SetCapacityFromWidget(this, TDW_CENTERTOWN); } - 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; /* 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. */ @@ -1165,8 +1177,14 @@ public: this->UpdateButtons(false); } - virtual void OnInvalidateData(int) + /** + * 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->UpdateButtons(true); } }; diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index cc8c399f6f..cf1979e387 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -125,8 +125,14 @@ public: return pt; } - 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; for (uint i = TTW_WIDGET_BEGIN; i < TTW_WIDGET_END; i++) { this->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_BEGIN))); } diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index ebbd2d1895..8623a3ff5b 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -144,8 +144,14 @@ public: } } - virtual void OnInvalidateData(int data = 0) + /** + * 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->base = _tree_base_by_landscape[_settings_game.game_creation.landscape]; this->count = _tree_count_by_landscape[_settings_game.game_creation.landscape]; } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index f8ff6d5c1a..26b8666a34 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -683,8 +683,14 @@ struct RefitWindow : public Window { } } - 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; switch (data) { case -666: /* Autoreplace replaced the vehicle. @@ -1600,8 +1606,14 @@ public: this->GetWidget(VLW_WIDGET_LIST)->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 (HasBit(data, 31) && this->vli.type == VL_SHARED_ORDERS) { this->vli.index = GB(data, 0, 20); this->window_number = this->vli.Pack(); @@ -1787,8 +1799,14 @@ struct VehicleDetailsWindow : Window { this->tab = TDW_TAB_CARGO; } - 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 (data == -666) { /* Autoreplace replaced the vehicle. * Nothing to do for this window though. @@ -2596,8 +2614,14 @@ public: } } - 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 (data == -666) { /* Autoreplace replaced the vehicle. * Nothing to do for this window though. diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 1a85311b6d..103b27cb28 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -148,8 +148,14 @@ public: } } - virtual void OnInvalidateData(int data = 0) + /** + * 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; /* Only handle zoom message if intended for us (msg ZOOM_IN/ZOOM_OUT) */ HandleZoomMessage(this, this->viewport, EVW_ZOOMIN, EVW_ZOOMOUT); } diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index 23c9781e33..af126f3ae5 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -114,8 +114,14 @@ public: } } - 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; /* You can only change your own waypoints */ this->SetWidgetDisabledState(WAYPVW_RENAME, !this->wp->IsInUse() || (this->wp->owner != _local_company && this->wp->owner != OWNER_NONE)); /* Disable the widget for waypoints with no use */ diff --git a/src/window_gui.h b/src/window_gui.h index 3254ee8c4c..fc5ebeedae 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -651,9 +651,9 @@ public: /** * 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) {} - + virtual void OnInvalidateData(int data = 0, bool gui_scope = true) {} /** * The user clicked some place on the map when a tile highlight mode