diff --git a/src/dropdown.cpp b/src/dropdown.cpp index b41cd15b89..b55b9ad65d 100644 --- a/src/dropdown.cpp +++ b/src/dropdown.cpp @@ -278,7 +278,7 @@ struct DropdownWindow : Window { bool selected = (this->selected_result == item->result) && item->Selectable(); if (selected) GfxFillRect(full, PC_BLACK); - item->Draw(full, full.Shrink(WidgetDimensions::scaled.dropdowntext, RectPadding::zero), selected, colour); + item->Draw(full, full.Shrink(WidgetDimensions::scaled.dropdowntext, RectPadding::zero), selected, selected ? this->selected_click_result : -1, colour); } y += item_height; } diff --git a/src/dropdown_common_type.h b/src/dropdown_common_type.h index 0c3bca6874..0771386c2c 100644 --- a/src/dropdown_common_type.h +++ b/src/dropdown_common_type.h @@ -34,7 +34,7 @@ public: bool Selectable() const override { return false; } uint Height() const override { return std::max(GetCharacterHeight(TFs), this->TBase::Height()); } - void Draw(const Rect &full, const Rect &, bool, Colours bg_colour) const override + void Draw(const Rect &full, const Rect &, bool, int, Colours bg_colour) const override { uint8_t c1 = GetColourGradient(bg_colour, SHADE_DARK); uint8_t c2 = GetColourGradient(bg_colour, SHADE_LIGHTEST); @@ -81,11 +81,11 @@ public: return this->TBase::OnClick(r.Indent(this->dim.width, rtl), pt); } - void Draw(const Rect &full, const Rect &r, bool sel, Colours bg_colour) const override + void Draw(const Rect &full, const Rect &r, bool sel, int click_result, Colours bg_colour) const override { bool rtl = TEnd ^ (_current_text_dir == TD_RTL); DrawStringMultiLine(r.WithWidth(this->dim.width, rtl), this->string, this->GetColour(sel), SA_CENTER, false, TFs); - this->TBase::Draw(full, r.Indent(this->dim.width, rtl), sel, bg_colour); + this->TBase::Draw(full, r.Indent(this->dim.width, rtl), sel, click_result, bg_colour); } /** @@ -137,12 +137,12 @@ public: return this->TBase::OnClick(r.Indent(this->dbounds.width + WidgetDimensions::scaled.hsep_normal, rtl), pt); } - void Draw(const Rect &full, const Rect &r, bool sel, Colours bg_colour) const override + void Draw(const Rect &full, const Rect &r, bool sel, int click_result, Colours bg_colour) const override { bool rtl = TEnd ^ (_current_text_dir == TD_RTL); Rect ir = r.WithWidth(this->dbounds.width, rtl); DrawSprite(this->sprite, this->palette, CentreBounds(ir.left, ir.right, this->dsprite.width), CentreBounds(r.top, r.bottom, this->dsprite.height)); - this->TBase::Draw(full, r.Indent(this->dbounds.width + WidgetDimensions::scaled.hsep_normal, rtl), sel, bg_colour); + this->TBase::Draw(full, r.Indent(this->dbounds.width + WidgetDimensions::scaled.hsep_normal, rtl), sel, click_result, bg_colour); } }; @@ -172,13 +172,13 @@ public: return this->TBase::OnClick(r.Indent(this->dim.width + WidgetDimensions::scaled.hsep_wide, rtl), pt); } - void Draw(const Rect &full, const Rect &r, bool sel, Colours bg_colour) const override + void Draw(const Rect &full, const Rect &r, bool sel, int click_result, Colours bg_colour) const override { bool rtl = TEnd ^ (_current_text_dir == TD_RTL); if (this->checked) { DrawStringMultiLine(r.WithWidth(this->dim.width, rtl), STR_JUST_CHECKMARK, this->GetColour(sel), SA_CENTER, false, TFs); } - this->TBase::Draw(full, r.Indent(this->dim.width + WidgetDimensions::scaled.hsep_wide, rtl), sel, bg_colour); + this->TBase::Draw(full, r.Indent(this->dim.width + WidgetDimensions::scaled.hsep_wide, rtl), sel, click_result, bg_colour); } }; @@ -202,10 +202,10 @@ public: return this->TBase::OnClick(r.Indent(this->indent * WidgetDimensions::scaled.hsep_indent, rtl), pt); } - void Draw(const Rect &full, const Rect &r, bool sel, Colours bg_colour) const override + void Draw(const Rect &full, const Rect &r, bool sel, int click_result, Colours bg_colour) const override { bool rtl = TEnd ^ (_current_text_dir == TD_RTL); - this->TBase::Draw(full, r.Indent(this->indent * WidgetDimensions::scaled.hsep_indent, rtl), sel, bg_colour); + this->TBase::Draw(full, r.Indent(this->indent * WidgetDimensions::scaled.hsep_indent, rtl), sel, click_result, bg_colour); } }; diff --git a/src/dropdown_type.h b/src/dropdown_type.h index 9469b1cbb0..ad77986459 100644 --- a/src/dropdown_type.h +++ b/src/dropdown_type.h @@ -37,7 +37,7 @@ public: return -1; } - virtual void Draw(const Rect &full, const Rect &, bool, Colours bg_colour) const + virtual void Draw(const Rect &full, const Rect &, bool, int, Colours bg_colour) const { if (this->masked) GfxFillRect(full, GetColourGradient(bg_colour, SHADE_LIGHT), FILLRECT_CHECKER); } diff --git a/src/newgrf_badge_gui.cpp b/src/newgrf_badge_gui.cpp index 43bb12df3a..6a9fba6459 100644 --- a/src/newgrf_badge_gui.cpp +++ b/src/newgrf_badge_gui.cpp @@ -215,13 +215,13 @@ public: return this->TBase::OnClick(r.Indent(this->dim.width + WidgetDimensions::scaled.hsep_wide, rtl), pt); } - void Draw(const Rect &full, const Rect &r, bool sel, Colours bg_colour) const override + void Draw(const Rect &full, const Rect &r, bool sel, int click_result, Colours bg_colour) const override { bool rtl = TEnd ^ (_current_text_dir == TD_RTL); DrawBadgeColumn(r.WithWidth(this->dim.width, rtl), 0, *this->gui_classes, this->badges, this->feature, this->introduction_date, PAL_NONE); - this->TBase::Draw(full, r.Indent(this->dim.width + WidgetDimensions::scaled.hsep_wide, rtl), sel, bg_colour); + this->TBase::Draw(full, r.Indent(this->dim.width + WidgetDimensions::scaled.hsep_wide, rtl), sel, click_result, bg_colour); } private: