* 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. */
| 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 | |
| 1063 | static constexpr std::initializer_list<NWidgetPart> _nested_select_company_livery_widgets = { |
nothing calls this directly
no test coverage detected