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

Method OnInvalidateData

src/company_gui.cpp:1021–1060  ·  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

1019 * @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.
1020 */
1021 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
1022 {
1023 if (!gui_scope) return;
1024
1025 if (data != -1) {
1026 /* data contains a VehicleType, rebuild list if it displayed */
1027 if (this->livery_class == data + LC_GROUP_RAIL) {
1028 this->groups.ForceRebuild();
1029 this->BuildGroupList(this->window_number);
1030 this->SetRows();
1031
1032 if (!Group::IsValidID(this->sel)) {
1033 this->sel = GroupID::Invalid().base();
1034 if (!this->groups.empty()) this->sel = this->groups[0].group->index.base();
1035 }
1036
1037 this->SetDirty();
1038 }
1039 return;
1040 }
1041
1042 this->SetWidgetsDisabledState(true, WID_SCL_CLASS_RAIL, WID_SCL_CLASS_ROAD, WID_SCL_CLASS_SHIP, WID_SCL_CLASS_AIRCRAFT);
1043
1044 bool current_class_valid = this->livery_class == LC_OTHER || this->livery_class >= LC_GROUP_RAIL;
1045 if (_settings_client.gui.liveries == LIT_ALL || (_settings_client.gui.liveries == LIT_COMPANY && this->window_number == _local_company)) {
1046 for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
1047 if (HasBit(_loaded_newgrf_features.used_liveries, scheme)) {
1048 if (_livery_class[scheme] == this->livery_class) current_class_valid = true;
1049 this->EnableWidget(WID_SCL_CLASS_GENERAL + _livery_class[scheme]);
1050 } else if (this->livery_class < LC_GROUP_RAIL) {
1051 ClrBit(this->sel, scheme);
1052 }
1053 }
1054 }
1055
1056 if (!current_class_valid) {
1057 Point pt = {0, 0};
1058 this->OnClick(pt, WID_SCL_CLASS_GENERAL, 1);
1059 }
1060 }
1061};
1062
1063static constexpr std::initializer_list<NWidgetPart> _nested_select_company_livery_widgets = {

Callers

nothing calls this directly

Calls 12

BuildGroupListMethod · 0.95
SetRowsMethod · 0.95
OnClickMethod · 0.95
InvalidFunction · 0.85
HasBitFunction · 0.85
ClrBitFunction · 0.85
ForceRebuildMethod · 0.80
EnableWidgetMethod · 0.80
baseMethod · 0.45
emptyMethod · 0.45
SetDirtyMethod · 0.45

Tested by

no test coverage detected