diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -72,7 +72,7 @@ class LandInfoWindow : public Window { public: TileIndex tile; - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_LI_BACKGROUND) return; @@ -88,7 +88,7 @@ public: } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_LI_BACKGROUND) return; @@ -340,7 +340,7 @@ public: ::ShowNewGRFInspectWindow(GetGrfSpecFeature(this->tile), this->tile.base()); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_LI_LOCATION: @@ -478,13 +478,13 @@ struct AboutWindow : public Window { this->text_position = this->GetWidget(WID_A_SCROLLING_TEXT)->pos_y + this->GetWidget(WID_A_SCROLLING_TEXT)->current_y; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_A_WEBSITE) SetDParamStr(0, "Website: https://www.openttd.org"); if (widget == WID_A_COPYRIGHT) SetDParamStr(0, _openttd_revision_year); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_A_SCROLLING_TEXT) return; @@ -500,7 +500,7 @@ struct AboutWindow : public Window { *size = maxdim(*size, d); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_A_SCROLLING_TEXT) return; @@ -697,7 +697,7 @@ struct TooltipsWindow : public Window return pt; } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_TT_BACKGROUND) return; CopyInDParam(this->params); @@ -710,7 +710,7 @@ struct TooltipsWindow : public Window size->height += WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.fullbevel.Vertical(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_TT_BACKGROUND) return; GfxFillRect(r, PC_BLACK); @@ -760,7 +760,7 @@ void GuiShowTooltips(Window *parent, Str new TooltipsWindow(parent, str, paramcount, close_tooltip); } -void QueryString::HandleEditBox(Window *w, int wid) +void QueryString::HandleEditBox(Window *w, WidgetID wid) { if (w->IsWidgetGloballyFocused(wid) && this->text.HandleCaret()) { w->SetWidgetDirty(wid); @@ -775,7 +775,7 @@ static int GetCaretWidth() return GetCharacterWidth(FS_NORMAL, '_'); } -void QueryString::DrawEditBox(const Window *w, int wid) const +void QueryString::DrawEditBox(const Window *w, WidgetID wid) const { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -827,7 +827,7 @@ void QueryString::DrawEditBox(const Wind * @param wid Widget index. * @return Top-left location of the caret, relative to the window. */ -Point QueryString::GetCaretPosition(const Window *w, int wid) const +Point QueryString::GetCaretPosition(const Window *w, WidgetID wid) const { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -856,7 +856,7 @@ Point QueryString::GetCaretPosition(cons * @param to End of the string range. * @return Rectangle encompassing the string range, relative to the window. */ -Rect QueryString::GetBoundingRect(const Window *w, int wid, const char *from, const char *to) const +Rect QueryString::GetBoundingRect(const Window *w, WidgetID wid, const char *from, const char *to) const { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -887,7 +887,7 @@ Rect QueryString::GetBoundingRect(const * @param pt Position to test. * @return Index of the character position or -1 if no character is at the position. */ -ptrdiff_t QueryString::GetCharAtPosition(const Window *w, int wid, const Point &pt) const +ptrdiff_t QueryString::GetCharAtPosition(const Window *w, WidgetID wid, const Point &pt) const { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -909,7 +909,7 @@ ptrdiff_t QueryString::GetCharAtPosition return ::GetCharAtPosition(tb->buf, pt.x - delta - r.left); } -void QueryString::ClickEditBox(Window *w, Point pt, int wid, int click_count, bool focus_changed) +void QueryString::ClickEditBox(Window *w, Point pt, WidgetID wid, int click_count, bool focus_changed) { const NWidgetLeaf *wi = w->GetWidget(wid); @@ -981,7 +981,7 @@ struct QueryStringWindow : public Window this->ReInit(); } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget == WID_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) { /* We don't want this widget to show! */ @@ -995,7 +995,7 @@ struct QueryStringWindow : public Window } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_QS_WARNING) return; @@ -1005,7 +1005,7 @@ struct QueryStringWindow : public Window } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_QS_CAPTION) SetDParam(0, this->editbox.caption); } @@ -1020,7 +1020,7 @@ struct QueryStringWindow : public Window } } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_QS_DEFAULT: @@ -1124,7 +1124,7 @@ struct QueryWindow : public Window { this->SetDirty(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_Q_CAPTION: @@ -1134,7 +1134,7 @@ struct QueryWindow : public Window { } } - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override { if (widget != WID_Q_TEXT) return; @@ -1144,7 +1144,7 @@ struct QueryWindow : public Window { *size = d; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_Q_TEXT) return; @@ -1152,7 +1152,7 @@ struct QueryWindow : public Window { this->message, TC_FROMSTRING, SA_CENTER); } - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { switch (widget) { case WID_Q_YES: {