MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / OnInvalidateData

Method OnInvalidateData

src/fios_gui.cpp:892–947  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

890 * @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.
891 */
892 void OnInvalidateData(int data = 0, bool gui_scope = true) override
893 {
894 switch (data) {
895 case SLIWD_RESCAN_FILES:
896 /* Rescan files */
897 this->selected = nullptr;
898 _load_check_data.Clear();
899 if (!gui_scope) break;
900
901 _fios_path_changed = true;
902 this->fios_items.BuildFileList(this->abstract_filetype, this->fop, true);
903 this->selected = nullptr;
904 _load_check_data.Clear();
905
906 /* We reset the files filtered */
907 this->OnInvalidateData(SLIWD_FILTER_CHANGES);
908
909 [[fallthrough]];
910
911 case SLIWD_SELECTION_CHANGES:
912 /* Selection changes */
913 if (!gui_scope) break;
914
915 if (this->fop == SLO_SAVE) this->SetWidgetDisabledState(WID_SL_DELETE_SELECTION, this->selected == nullptr);
916
917 if (this->fop != SLO_LOAD) break;
918
919 switch (this->abstract_filetype) {
920 case FT_HEIGHTMAP:
921 case FT_TOWN_DATA:
922 this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, this->selected == nullptr || _load_check_data.HasErrors());
923 break;
924
925 case FT_SAVEGAME:
926 case FT_SCENARIO: {
927 bool disabled = this->selected == nullptr || _load_check_data.HasErrors();
928 if (!_settings_client.gui.UserIsAllowedToChangeNewGRFs()) {
929 disabled |= _load_check_data.HasNewGrfs() && _load_check_data.grf_compatibility == GLC_NOT_FOUND;
930 }
931 this->SetWidgetDisabledState(WID_SL_LOAD_BUTTON, disabled);
932 this->SetWidgetDisabledState(WID_SL_NEWGRF_INFO, !_load_check_data.HasNewGrfs());
933 this->SetWidgetDisabledState(WID_SL_MISSING_NEWGRFS,
934 !_load_check_data.HasNewGrfs() || _load_check_data.grf_compatibility == GLC_ALL_GOOD);
935 break;
936 }
937
938 default:
939 NOT_REACHED();
940 }
941 break;
942
943 case SLIWD_FILTER_CHANGES:
944 this->BuildDisplayList();
945 break;
946 }
947 }
948
949 void OnEditboxChanged(WidgetID wid) override

Callers 3

SaveLoadWindowMethod · 0.95
OnPaintMethod · 0.95
BuildDisplayListMethod · 0.95

Calls 8

BuildDisplayListMethod · 0.95
NOT_REACHEDFunction · 0.85
BuildFileListMethod · 0.80
HasErrorsMethod · 0.80
HasNewGrfsMethod · 0.80
ClearMethod · 0.45

Tested by

no test coverage detected