Fix picker tool item selection in rail/road station and waypoint windows

This commit is contained in:
Jonathan G Rennison
2024-02-03 12:02:58 +00:00
parent 48c97d6cde
commit 7d92f185d3
3 changed files with 10 additions and 4 deletions

View File

@@ -1730,7 +1730,8 @@ public:
{ {
this->SelectClass(class_id); this->SelectClass(class_id);
this->EnsureSelectedStationClassIsVisible(); this->EnsureSelectedStationClassIsVisible();
this->OnClick({}, WID_BRAS_IMAGE | (spec_id << 16), 1); this->GetWidget<NWidgetBase>(WID_BRAS_IMAGE)->GetParentWidget<NWidgetMatrix>()->SetCurrentElement(spec_id);
this->OnClick({}, WID_BRAS_IMAGE, 1);
} }
static HotkeyList hotkeys; static HotkeyList hotkeys;
@@ -2620,7 +2621,8 @@ struct BuildRailWaypointWindow : PickerWindowBase {
{ {
for (uint i = 0; i < (uint)this->list.size(); i++) { for (uint i = 0; i < (uint)this->list.size(); i++) {
if (this->list[i] == spec_id) { if (this->list[i] == spec_id) {
this->OnClick({}, WID_BRW_WAYPOINT | (i << 16), 1); this->GetWidget<NWidgetBase>(WID_BRW_WAYPOINT)->GetParentWidget<NWidgetMatrix>()->SetCurrentElement(i);
this->OnClick({}, WID_BRW_WAYPOINT, 1);
break; break;
} }
} }

View File

@@ -1747,7 +1747,8 @@ public:
/* could not select class*/ /* could not select class*/
return; return;
} }
this->OnClick({}, WID_BROS_IMAGE | (spec_id << 16), 1); this->GetWidget<NWidgetBase>(WID_BROS_IMAGE)->GetParentWidget<NWidgetMatrix>()->SetCurrentElement(spec_id);
this->OnClick({}, WID_BROS_IMAGE, 1);
} }
static HotkeyList hotkeys; static HotkeyList hotkeys;
@@ -2118,7 +2119,8 @@ struct BuildRoadWaypointWindow : PickerWindowBase {
{ {
for (uint i = 0; i < (uint)this->list.size(); i++) { for (uint i = 0; i < (uint)this->list.size(); i++) {
if (this->list[i] == spec_id) { if (this->list[i] == spec_id) {
this->OnClick({}, WID_BROW_WAYPOINT | (i << 16), 1); this->GetWidget<NWidgetBase>(WID_BROW_WAYPOINT)->GetParentWidget<NWidgetMatrix>()->SetCurrentElement(i);
this->OnClick({}, WID_BROW_WAYPOINT, 1);
break; break;
} }
} }

View File

@@ -610,6 +610,8 @@ public:
void SetScrollbar(Scrollbar *sb); void SetScrollbar(Scrollbar *sb);
int GetCurrentElement() const; int GetCurrentElement() const;
void SetCurrentElement(int current_element) { this->current_element = current_element; }
void SetupSmallestSize(Window *w) override; void SetupSmallestSize(Window *w) override;
void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override;
void FillWidgetLookup(WidgetLookup &widget_lookup) override; void FillWidgetLookup(WidgetLookup &widget_lookup) override;