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

Method OnInvalidateData

src/picker_gui.cpp:492–526  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492void PickerWindow::OnInvalidateData(int data, bool gui_scope)
493{
494 if (!gui_scope) return;
495
496 PickerInvalidations pi(data);
497
498 if (pi.Test(PickerInvalidation::Filter)) {
499 if (this->badge_filter_choices.empty()) {
500 this->type_string_filter.bdf.reset();
501 } else {
502 this->type_string_filter.bdf.emplace(this->badge_filter_choices);
503 }
504 this->types.SetFilterState(!type_string_filter.IsEmpty() || type_string_filter.bdf.has_value());
505 }
506
507 if (pi.Test(PickerInvalidation::Class)) this->classes.ForceRebuild();
508 if (pi.Test(PickerInvalidation::Type)) this->types.ForceRebuild();
509
510 this->BuildPickerClassList();
511 if (pi.Test(PickerInvalidation::Validate)) this->EnsureSelectedClassIsValid();
512 if (pi.Test(PickerInvalidation::Position)) this->EnsureSelectedClassIsVisible();
513
514 this->BuildPickerTypeList();
515 if (pi.Test(PickerInvalidation::Validate)) this->EnsureSelectedTypeIsValid();
516 if (pi.Test(PickerInvalidation::Position)) this->EnsureSelectedTypeIsVisible();
517
518 if (this->has_type_picker) {
519 SetWidgetLoweredState(WID_PW_MODE_ALL, HasBit(this->callbacks.mode, PFM_ALL));
520 SetWidgetLoweredState(WID_PW_MODE_USED, HasBit(this->callbacks.mode, PFM_USED));
521 SetWidgetLoweredState(WID_PW_MODE_SAVED, HasBit(this->callbacks.mode, PFM_SAVED));
522 }
523
524 SetWidgetDisabledState(WID_PW_SHRINK, this->preview_height == PREVIEW_HEIGHT);
525 SetWidgetDisabledState(WID_PW_EXPAND, this->preview_height == MAX_PREVIEW_HEIGHT);
526}
527
528EventState PickerWindow::OnHotkey(int hotkey)
529{

Callers 1

SelectGameWindowMethod · 0.45

Calls 13

BuildPickerClassListMethod · 0.95
BuildPickerTypeListMethod · 0.95
HasBitFunction · 0.85
TestMethod · 0.80
SetFilterStateMethod · 0.80
ForceRebuildMethod · 0.80
emptyMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected