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

Method OnDropdownSelect

src/picker_gui.cpp:460–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

458}
459
460void PickerWindow::OnDropdownSelect(WidgetID widget, int index, int click_result)
461{
462 switch (widget) {
463 case WID_PW_CONFIGURE_BADGES: {
464 bool reopen = HandleBadgeConfigurationDropDownClick(this->callbacks.GetFeature(), 1, index, click_result, this->badge_filter_choices);
465
466 this->ReInit();
467
468 if (reopen) {
469 ReplaceDropDownList(this, BuildBadgeClassConfigurationList(this->badge_classes, 1, {}, COLOUR_DARK_GREEN), -1);
470 } else {
471 this->CloseChildWindows(WC_DROPDOWN_MENU);
472 }
473
474 /* We need to refresh if a filter is removed. */
475 this->InvalidateData({PickerInvalidation::Type, PickerInvalidation::Filter, PickerInvalidation::Position});
476 break;
477 }
478
479 default:
480 if (IsInsideMM(widget, this->badge_filters.first, this->badge_filters.second)) {
481 if (index < 0) {
482 ResetBadgeFilter(this->badge_filter_choices, this->GetWidget<NWidgetBadgeFilter>(widget)->GetBadgeClassID());
483 } else {
484 SetBadgeFilter(this->badge_filter_choices, BadgeID(index));
485 }
486 this->InvalidateData({PickerInvalidation::Type, PickerInvalidation::Filter, PickerInvalidation::Position});
487 }
488 break;
489 }
490}
491
492void PickerWindow::OnInvalidateData(int data, bool gui_scope)
493{

Callers 1

OnMouseLoopMethod · 0.45

Calls 11

InvalidateDataMethod · 0.95
ReplaceDropDownListFunction · 0.85
IsInsideMMFunction · 0.85
ResetBadgeFilterFunction · 0.85
SetBadgeFilterFunction · 0.85
ReInitMethod · 0.80
CloseChildWindowsMethod · 0.80
GetBadgeClassIDMethod · 0.80
GetFeatureMethod · 0.45

Tested by

no test coverage detected