diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -115,7 +115,7 @@ struct AIConfigWindow : public Window { this->Window::Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_AIC_NUMBER: @@ -128,7 +128,7 @@ struct AIConfigWindow : 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 { switch (widget) { case WID_AIC_DECREASE_NUMBER: @@ -165,7 +165,7 @@ struct AIConfigWindow : public Window { return slot < max_slot; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_AIC_LIST: { @@ -190,7 +190,7 @@ struct AIConfigWindow : 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 { if (widget >= WID_AIC_TEXTFILE && widget < WID_AIC_TEXTFILE + TFT_CONTENT_END) { if (this->selected_slot == INVALID_COMPANY || AIConfig::GetConfig(this->selected_slot) == nullptr) return; diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -118,7 +118,7 @@ struct BuildAirToolbarWindow : 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_AT_AIRPORT: @@ -291,7 +291,7 @@ public: this->PickerWindowBase::Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_AP_CLASS_DROPDOWN: @@ -316,7 +316,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 { switch (widget) { case WID_AP_CLASS_DROPDOWN: { @@ -377,7 +377,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_AP_AIRPORT_LIST: { @@ -487,7 +487,7 @@ public: } } - 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_AP_CLASS_DROPDOWN: @@ -562,7 +562,7 @@ public: this->SelectOtherAirport(-1); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget == WID_AP_CLASS_DROPDOWN) { _selected_airport_class = (AirportClassID)index; diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -315,7 +315,7 @@ public: this->sel_group = id_g; } - 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 { switch (widget) { case WID_RV_SORT_ASCENDING_DESCENDING: { @@ -402,7 +402,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_RV_CAPTION: @@ -457,7 +457,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_RV_SORT_ASCENDING_DESCENDING: @@ -541,7 +541,7 @@ public: } } - 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_RV_SORT_ASCENDING_DESCENDING: @@ -655,7 +655,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_RV_SORT_DROPDOWN: @@ -697,7 +697,7 @@ public: } } - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget != WID_RV_TRAIN_WAGONREMOVE_TOGGLE) return false; diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -57,7 +57,7 @@ public: ResizeWindow(this, _screen.width, _screen.height); } - void DrawWidget(const Rect &r, int) const override + void DrawWidget(const Rect &r, WidgetID) const override { GfxFillRect(r.left, r.top, r.right, r.bottom, 4, FILLRECT_OPAQUE); GfxFillRect(r.left, r.top, r.right, r.bottom, 0, FILLRECT_CHECKER); @@ -97,7 +97,7 @@ public: this->Window::Close(); } - 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_BEM_MESSAGE) { *size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR); @@ -106,14 +106,14 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_BEM_MESSAGE) { DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_MISSING_GRAPHICS_ERROR, 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 { if (widget == WID_BEM_QUIT) { _exit_game = true; @@ -211,7 +211,7 @@ public: this->Window::Close(); } - 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 { /* We cache the button size. This is safe as no reinit can happen here. */ if (this->button_size.width == 0) { @@ -234,14 +234,14 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_BAFD_QUESTION) return; DrawStringMultiLine(r.Shrink(WidgetDimensions::scaled.frametext), STR_MISSING_GRAPHICS_SET_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_BAFD_YES: diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -174,7 +174,7 @@ public: this->last_sorting = this->bridges.GetListing(); } - 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 { switch (widget) { case WID_BBS_DROPDOWN_ORDER: { @@ -221,7 +221,7 @@ public: return corner; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_BBS_DROPDOWN_ORDER: @@ -255,7 +255,7 @@ public: return ES_NOT_HANDLED; } - 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) { default: break; @@ -279,7 +279,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget == WID_BBS_DROPDOWN_CRITERIA && this->bridges.SortType() != index) { this->bridges.SetSortType(index); diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1586,7 +1586,7 @@ struct BuildVehicleWindow : Window { return list; } - 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_BV_SORT_ASCENDING_DESCENDING: @@ -1707,7 +1707,7 @@ struct BuildVehicleWindow : Window { this->eng_list.ForceRebuild(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_BV_CAPTION: @@ -1742,7 +1742,7 @@ struct BuildVehicleWindow : 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 { switch (widget) { case WID_BV_LIST: @@ -1783,7 +1783,7 @@ struct BuildVehicleWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_BV_LIST: @@ -1841,7 +1841,7 @@ struct BuildVehicleWindow : Window { Command::Post(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type, this->rename_engine, str); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_BV_SORT_DROPDOWN: @@ -1871,7 +1871,7 @@ struct BuildVehicleWindow : Window { this->vscroll->SetCapacityFromWidget(this, WID_BV_LIST); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_BV_FILTER) { this->string_filter.SetFilterTerm(this->vehicle_editbox.text.buf); diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -236,7 +236,7 @@ struct CheatWindow : Window { this->icon = GetSpriteSize(SPR_COMPANY_ICON); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_C_PANEL) return; @@ -298,7 +298,7 @@ struct CheatWindow : 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_C_PANEL) return; @@ -344,7 +344,7 @@ struct CheatWindow : Window { size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui); } - 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 { if (widget != WID_C_PANEL) return; diff --git a/src/company_gui.cpp b/src/company_gui.cpp --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -342,7 +342,7 @@ struct CompanyFinancesWindow : Window { this->owner = (Owner)this->window_number; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CF_CAPTION: @@ -383,7 +383,7 @@ struct CompanyFinancesWindow : 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 { switch (widget) { case WID_CF_EXPS_CATEGORY: @@ -410,7 +410,7 @@ struct CompanyFinancesWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_CF_EXPS_CATEGORY: @@ -479,7 +479,7 @@ struct CompanyFinancesWindow : Window { this->DrawWidgets(); } - 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_CF_TOGGLE_SIZE: // toggle size @@ -772,7 +772,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 { switch (widget) { case WID_SCL_SPACER_DROPDOWN: { @@ -838,7 +838,7 @@ public: this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SCL_CAPTION: @@ -878,7 +878,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_SCL_MATRIX) return; @@ -950,7 +950,7 @@ public: } } - 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) { /* Livery Class buttons */ @@ -1029,7 +1029,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_SCL_MATRIX); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { bool local = (CompanyID)this->window_number == _local_company; if (!local) return; @@ -1368,7 +1368,7 @@ class SelectCompanyManagerFaceWindow : p * @param val the value which will be displayed * @param is_bool_widget is it a bool button */ - void SetFaceStringParameters(byte widget_index, uint8_t val, bool is_bool_widget) const + void SetFaceStringParameters(WidgetID widget_index, uint8_t val, bool is_bool_widget) const { const NWidgetCore *nwi_widget = this->GetWidget(widget_index); if (nwi_widget->IsDisabled()) { @@ -1452,7 +1452,7 @@ public: this->number_dim = number_dim; } - 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 { switch (widget) { case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT: @@ -1555,7 +1555,7 @@ public: this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SCMF_HAS_MOUSTACHE_EARRING: @@ -1616,7 +1616,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SCMF_FACE: @@ -1625,7 +1625,7 @@ public: } } - 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) { /* Toggle size, advanced/simple face selection */ @@ -1878,7 +1878,7 @@ struct CompanyInfrastructureWindow : Win return total; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CI_CAPTION: @@ -1887,7 +1887,7 @@ struct CompanyInfrastructureWindow : Win } } - 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 { const Company *c = Company::Get((CompanyID)this->window_number); @@ -2012,7 +2012,7 @@ struct CompanyInfrastructureWindow : Win } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { const Company *c = Company::Get((CompanyID)this->window_number); @@ -2291,7 +2291,7 @@ struct CompanyWindow : Window this->DrawWidgets(); } - 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 { switch (widget) { case WID_C_FACE: @@ -2419,7 +2419,7 @@ struct CompanyWindow : Window } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { const Company *c = Company::Get((CompanyID)this->window_number); switch (widget) { @@ -2456,7 +2456,7 @@ struct CompanyWindow : Window } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_C_CAPTION: @@ -2474,7 +2474,7 @@ struct CompanyWindow : 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_C_NEW_FACE: DoSelectCompanyManagerFace(this); break; @@ -2648,7 +2648,7 @@ struct BuyCompanyWindow : Window { this->company_value = hostile_takeover ? CalculateHostileTakeoverValue(c) : c->bankrupt_value; } - 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 { switch (widget) { case WID_BC_FACE: @@ -2664,7 +2664,7 @@ struct BuyCompanyWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_BC_CAPTION: @@ -2674,7 +2674,7 @@ struct BuyCompanyWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_BC_FACE: { @@ -2693,7 +2693,7 @@ struct BuyCompanyWindow : 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_BC_NO: diff --git a/src/console_gui.cpp b/src/console_gui.cpp --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -271,7 +271,7 @@ struct IConsoleWindow : Window return ES_HANDLED; } - void InsertTextString(int, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) override + void InsertTextString(WidgetID, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) override { if (_iconsole_cmdline.InsertString(str, marked, caret, insert_location, replacement_end)) { IConsoleWindow::scroll = 0; diff --git a/src/date_gui.cpp b/src/date_gui.cpp --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -65,7 +65,7 @@ struct SetDateWindow : Window { * Helper function to construct the dropdown. * @param widget the dropdown widget to create the dropdown for */ - void ShowDateDropDown(int widget) + void ShowDateDropDown(WidgetID widget) { int selected; DropDownList list; @@ -99,7 +99,7 @@ struct SetDateWindow : Window { ShowDropDownList(this, std::move(list), selected, widget); } - 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 { Dimension d = {0, 0}; switch (widget) { @@ -128,7 +128,7 @@ struct SetDateWindow : Window { *size = d; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SD_DAY: SetDParam(0, this->date.day - 1 + STR_DAY_NUMBER_1ST); break; @@ -137,7 +137,7 @@ struct SetDateWindow : 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_SD_DAY: @@ -153,7 +153,7 @@ struct SetDateWindow : Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_SD_DAY: diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -258,7 +258,7 @@ struct DepotWindow : Window { VehicleID vehicle_over; ///< Rail vehicle over which another one is dragged, \c INVALID_VEHICLE if none. VehicleType type; bool generate_list; - int hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress. + WidgetID hovered_widget; ///< Index of the widget being hovered during drag/drop. -1 if no drag is in progress. VehicleList vehicle_list; VehicleList wagon_list; uint unitnumber_digits; @@ -363,7 +363,7 @@ struct DepotWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_D_MATRIX) return; @@ -421,7 +421,7 @@ struct DepotWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_D_CAPTION) return; @@ -653,7 +653,7 @@ struct DepotWindow : Window { this->flag_size = maxdim(GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED), GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING)); } - 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 { switch (widget) { case WID_D_MATRIX: { @@ -757,7 +757,7 @@ struct DepotWindow : Window { this->DrawWidgets(); } - 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_D_MATRIX: // List @@ -839,7 +839,7 @@ struct DepotWindow : Window { Command::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->GetDepotIndex(), str); } - bool OnRightClick([[maybe_unused]] Point pt, int widget) override + bool OnRightClick([[maybe_unused]] Point pt, WidgetID widget) override { if (widget != WID_D_MATRIX) return false; @@ -974,7 +974,7 @@ struct DepotWindow : Window { } } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { if (this->sel == INVALID_VEHICLE) return; if (widget != this->hovered_widget) { @@ -1025,7 +1025,7 @@ struct DepotWindow : Window { this->SetWidgetDirty(widget); } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { switch (widget) { case WID_D_MATRIX: { diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -148,7 +148,7 @@ struct BuildDocksToolbarWindow : 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_DT_CANAL: // Build canal button @@ -453,7 +453,7 @@ public: } } - 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 BDSW_LT_OFF: @@ -529,7 +529,7 @@ public: UpdateDocksDirection(); } - 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 { switch (widget) { case WID_BDD_X: @@ -540,7 +540,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { DrawPixelInfo tmp_dpi; @@ -564,7 +564,7 @@ public: } } - 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_BDD_X: diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -78,7 +78,7 @@ struct EnginePreviewWindow : Window { this->flags |= WF_STICKY; } - 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_EP_QUESTION) return; @@ -105,7 +105,7 @@ struct EnginePreviewWindow : Window { size->height += GetStringHeight(GetEngineInfoString(engine), size->width); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_EP_QUESTION) return; @@ -123,7 +123,7 @@ struct EnginePreviewWindow : Window { DrawStringMultiLine(r.left, r.right, y, r.bottom, GetEngineInfoString(engine), 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_EP_YES: diff --git a/src/error_gui.cpp b/src/error_gui.cpp --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -189,7 +189,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 { switch (widget) { case WID_EM_MESSAGE: { @@ -257,12 +257,12 @@ public: if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) this->Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_EM_CAPTION) CopyInDParam(this->params); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_EM_FACE: { diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -408,7 +408,7 @@ public: this->Window::Close(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SL_SORT_BYNAME: @@ -561,7 +561,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 { switch (widget) { case WID_SL_BACKGROUND: @@ -594,7 +594,7 @@ public: this->DrawWidgets(); } - 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_SL_SORT_BYNAME: // Sort save names by name @@ -716,7 +716,7 @@ public: } } - void OnMouseOver([[maybe_unused]] Point pt, int widget) override + void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override { if (widget == WID_SL_DRIVES_DIRECTORIES_LIST) { auto it = this->vscroll->GetScrolledItemFromWidget(this->display_list, pt.y, this, WID_SL_DRIVES_DIRECTORIES_LIST, WidgetDimensions::scaled.inset.top); @@ -873,7 +873,7 @@ public: } } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_SL_FILTER) { this->string_filter.SetFilterTerm(this->filter_editbox.text.buf); diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -512,7 +512,7 @@ struct FramerateWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_FRW_CAPTION: @@ -540,7 +540,7 @@ struct FramerateWindow : 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 { switch (widget) { case WID_FRW_RATE_GAMELOOP: @@ -651,7 +651,7 @@ struct FramerateWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_FRW_TIMES_NAMES: { @@ -693,7 +693,7 @@ struct FramerateWindow : 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_FRW_TIMES_NAMES: @@ -765,7 +765,7 @@ struct FrametimeGraphWindow : Window { this->UpdateScale(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_FGW_CAPTION: @@ -780,7 +780,7 @@ struct FrametimeGraphWindow : 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_FGW_GRAPH) { SetDParam(0, 100); @@ -897,7 +897,7 @@ struct FrametimeGraphWindow : Window { return (value - src_min) * dst_diff / src_diff + dst_min; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_FGW_GRAPH) { const TimingMeasurement *durations = _pf_data[this->element].durations; diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -135,7 +135,7 @@ struct GSConfigWindow : public Window { this->vscroll->SetCount(this->visible_settings.size()); } - 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 { switch (widget) { case WID_GSC_SETTINGS: @@ -161,7 +161,7 @@ struct GSConfigWindow : public Window { return _game_mode != GM_NORMAL || Game::GetInstance() != nullptr; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GSC_GSLIST: { @@ -243,7 +243,7 @@ struct GSConfigWindow : public Window { this->DrawWidgets(); } - 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 { if (widget >= WID_GSC_TEXTFILE && widget < WID_GSC_TEXTFILE + TFT_CONTENT_END) { if (GameConfig::GetConfig() == nullptr) return; @@ -373,14 +373,14 @@ struct GSConfigWindow : public Window { SetValue(value); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_GSC_SETTING_DROPDOWN) return; assert(this->clicked_dropdown); SetValue(index); } - void OnDropdownClose(Point, int widget, int, bool) override + void OnDropdownClose(Point, WidgetID widget, int, bool) override { if (widget != WID_GSC_SETTING_DROPDOWN) return; /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -384,7 +384,7 @@ static const StringID _variety[] = { static_assert(lengthof(_num_inds) == ID_END + 1); struct GenerateLandscapeWindow : public Window { - uint widget_id; + WidgetID widget_id; uint x; uint y; std::string name; @@ -415,7 +415,7 @@ struct GenerateLandscapeWindow : public } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_GL_START_DATE_TEXT: SetDParam(0, TimerGameCalendar::ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); break; @@ -570,7 +570,7 @@ struct GenerateLandscapeWindow : 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 { Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)}; const StringID *strs = nullptr; @@ -669,7 +669,7 @@ struct GenerateLandscapeWindow : public *size = maxdim(*size, d); } - 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_GL_TEMPERATE: @@ -879,7 +879,7 @@ struct GenerateLandscapeWindow : public } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_GL_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break; @@ -1076,7 +1076,7 @@ void StartNewGameWithoutGUI(uint32_t see struct CreateScenarioWindow : public Window { - uint widget_id; + WidgetID widget_id; CreateScenarioWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { @@ -1084,7 +1084,7 @@ struct CreateScenarioWindow : public Win this->LowerWidget(_settings_newgame.game_creation.landscape + WID_CS_TEMPERATE); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CS_START_DATE_TEXT: @@ -1120,7 +1120,7 @@ struct CreateScenarioWindow : public Win this->DrawWidgets(); } - 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 { StringID str = STR_JUST_INT; switch (widget) { @@ -1153,7 +1153,7 @@ struct CreateScenarioWindow : public Win *size = maxdim(*size, d); } - 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_CS_TEMPERATE: @@ -1223,7 +1223,7 @@ struct CreateScenarioWindow : public Win this->RaiseWidgetsWhenLowered(WID_CS_START_DATE_DOWN, WID_CS_START_DATE_UP, WID_CS_FLAT_LAND_HEIGHT_DOWN, WID_CS_FLAT_LAND_HEIGHT_UP); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_CS_MAPSIZE_X_PULLDOWN: _settings_newgame.game_creation.map_x = index; break; @@ -1389,7 +1389,7 @@ struct GenerateProgressWindow : public W this->InitNested(); } - 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_GP_ABORT: @@ -1404,7 +1404,7 @@ struct GenerateProgressWindow : public W } } - 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 { switch (widget) { case WID_GP_PROGRESS_BAR: { @@ -1425,7 +1425,7 @@ struct GenerateProgressWindow : public W } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GP_PROGRESS_BAR: { diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -51,7 +51,7 @@ struct GoalListWindow : public Window { this->OnInvalidateData(0); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_GOAL_CAPTION) return; @@ -63,7 +63,7 @@ struct GoalListWindow : 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_GOAL_GLOBAL_BUTTON: @@ -168,7 +168,7 @@ struct GoalListWindow : public Window { return num; } - 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_GOAL_LIST) return; Dimension d = GetStringBoundingBox(STR_GOALS_NONE); @@ -351,7 +351,7 @@ struct GoalQuestionWindow : public Windo } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_GQ_BUTTON_1: @@ -368,7 +368,7 @@ struct GoalQuestionWindow : public Windo } } - 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_GQ_BUTTON_1: @@ -388,7 +388,7 @@ struct GoalQuestionWindow : public Windo } } - 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_GQ_QUESTION) return; @@ -396,7 +396,7 @@ struct GoalQuestionWindow : public Windo size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_GQ_QUESTION) return; diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -56,7 +56,7 @@ struct GraphLegendWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return; @@ -76,7 +76,7 @@ struct GraphLegendWindow : Window { DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE); } - 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 { if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return; @@ -115,7 +115,7 @@ static NWidgetBase *MakeNWidgetCompanyLi vert->SetPadding(2, 2, 2, 2); uint sprite_height = GetSpriteSize(SPR_COMPANY_ICON, nullptr, ZOOM_LVL_OUT_4X).height; - for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) { + for (WidgetID widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) { NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum); panel->SetMinimalSize(246, sprite_height + WidgetDimensions::unscaled.framerect.Vertical()); panel->SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical(), FS_NORMAL); @@ -191,7 +191,7 @@ protected: uint16_t x_values_start; uint16_t x_values_increment; - int graph_widget; + WidgetID graph_widget; StringID format_str_y_axis; byte colours[GRAPH_MAX_DATASETS]; OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS]; ///< Stored costs for the last #GRAPH_NUM_MONTHS months @@ -471,7 +471,7 @@ protected: } - BaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis) : + BaseGraphWindow(WindowDesc *desc, WidgetID widget, StringID format_str_y_axis) : Window(desc), format_str_y_axis(format_str_y_axis) { @@ -489,7 +489,7 @@ protected: } 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 != this->graph_widget) return; @@ -525,7 +525,7 @@ public: size->height = std::max(size->height, size->width / 3); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != this->graph_widget) return; @@ -537,7 +537,7 @@ public: return INVALID_DATAPOINT; } - 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 { /* Clicked on legend? */ if (widget == WID_CV_KEY_BUTTON) ShowGraphLegend(); @@ -778,7 +778,7 @@ struct PerformanceHistoryGraphWindow : B return c->old_economy[j].performance_history; } - 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 { if (widget == WID_PHG_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail(); this->BaseGraphWindow::OnClick(pt, widget, click_count); @@ -912,7 +912,7 @@ struct PaymentRatesGraphWindow : BaseGra } } - 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_CPR_MATRIX) { BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize); @@ -936,7 +936,7 @@ struct PaymentRatesGraphWindow : BaseGra resize->height = this->line_height; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_CPR_MATRIX) { BaseGraphWindow::DrawWidget(r, widget); @@ -973,7 +973,7 @@ struct PaymentRatesGraphWindow : BaseGra } } - 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_CPR_ENABLE_CARGOES: @@ -1140,7 +1140,7 @@ struct PerformanceRatingDetailWindow : W uint score_detail_left; uint score_detail_right; - 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 { switch (widget) { case WID_PRD_SCORE_FIRST: @@ -1198,7 +1198,7 @@ struct PerformanceRatingDetailWindow : W } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { /* No need to draw when there's nothing to draw */ if (this->company == INVALID_COMPANY) return; @@ -1276,7 +1276,7 @@ struct PerformanceRatingDetailWindow : W } } - 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 { /* Check which button is clicked */ if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) { @@ -1355,7 +1355,7 @@ static NWidgetBase *MakePerformanceDetai static_assert(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN); NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE); - for (int widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) { + for (WidgetID widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) { NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum); panel->SetFill(1, 1); panel->SetDataTip(0x0, performance_tips[widnum - WID_PRD_SCORE_FIRST]); diff --git a/src/group_gui.cpp b/src/group_gui.cpp --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -384,7 +384,7 @@ public: *this->sorting = this->vehgroups.GetListing(); } - 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 { switch (widget) { case WID_GL_LIST_GROUP: @@ -466,7 +466,7 @@ public: this->SetDirty(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_GL_FILTER_BY_CARGO: @@ -552,7 +552,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GL_ALL_VEHICLES: @@ -648,7 +648,7 @@ public: } } - 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_GL_SORT_BY_ORDER: // Flip sorting method ascending/descending @@ -823,7 +823,7 @@ public: } } - void OnDragDrop_Group(Point pt, int widget) + void OnDragDrop_Group(Point pt, WidgetID widget) { const Group *g = Group::Get(this->group_sel); @@ -855,7 +855,7 @@ public: } } - void OnDragDrop_Vehicle(Point pt, int widget) + void OnDragDrop_Vehicle(Point pt, WidgetID widget) { switch (widget) { case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles @@ -921,7 +921,7 @@ public: } } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { if (this->vehicle_sel != INVALID_VEHICLE) OnDragDrop_Vehicle(pt, widget); if (this->group_sel != INVALID_GROUP) OnDragDrop_Group(pt, widget); @@ -941,7 +941,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_GL_LIST_VEHICLE); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_GL_GROUP_BY_DROPDOWN: @@ -1010,7 +1010,7 @@ public: this->SetWidgetDirty(WID_GL_LIST_VEHICLE); } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { if (this->vehicle_sel == INVALID_VEHICLE && this->group_sel == INVALID_GROUP) return; diff --git a/src/help_gui.cpp b/src/help_gui.cpp --- a/src/help_gui.cpp +++ b/src/help_gui.cpp @@ -73,7 +73,7 @@ struct GameManualTextfileWindow : public this->OnClick({ 0, 0 }, WID_TF_WRAPTEXT, 1); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParamStr(0, this->filename); @@ -129,7 +129,7 @@ struct HelpWindow : public Window { this->EnableTextfileButton(LICENSE_FILENAME, WID_HW_LICENSE); } - 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_HW_README: diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -65,7 +65,7 @@ struct EndGameHighScoreBaseWindow : Wind return pt; } - void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] int widget, [[maybe_unused]] int click_count) override + void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] int click_count) override { this->Close(); } diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -422,7 +422,7 @@ public: this->SetupArrays(); } - 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 { switch (widget) { case WID_DPI_MATRIX_WIDGET: { @@ -494,7 +494,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_DPI_FUND_WIDGET: @@ -515,7 +515,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_DPI_MATRIX_WIDGET: { @@ -626,7 +626,7 @@ public: MarkWholeScreenDirty(); } - 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_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET: { @@ -981,17 +981,17 @@ public: return ir.top - 1 + WidgetDimensions::scaled.framerect.bottom; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_IV_CAPTION) SetDParam(0, this->window_number); } - 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_IV_INFO) size->height = this->info_height; } - 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_IV_INFO: { @@ -1646,7 +1646,7 @@ public: this->SetCargoFilterArray(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_ID_DROPDOWN_CRITERIA: @@ -1663,7 +1663,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_ID_DROPDOWN_ORDER: @@ -1709,7 +1709,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 { switch (widget) { case WID_ID_DROPDOWN_ORDER: { @@ -1761,7 +1761,7 @@ public: return list; } - 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_ID_DROPDOWN_ORDER: @@ -1795,7 +1795,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_ID_DROPDOWN_CRITERIA: { @@ -1826,7 +1826,7 @@ public: this->hscroll->SetCapacityFromWidget(this, WID_ID_INDUSTRY_LIST); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_ID_FILTER) { this->string_filter.SetFilterTerm(this->industry_editbox.text.buf); @@ -2626,7 +2626,7 @@ struct IndustryCargoesWindow : public Wi CargoesField::cargo_field_width = CargoesField::cargo_border.width * 2 + CargoesField::cargo_line.width * CargoesField::max_cargoes + CargoesField::cargo_space.width * (CargoesField::max_cargoes - 1); } - 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 { switch (widget) { case WID_IC_PANEL: @@ -2647,7 +2647,7 @@ struct IndustryCargoesWindow : public Wi CargoesFieldType type; ///< Type of field. - void SetStringParameters (int widget) const override + void SetStringParameters (WidgetID widget) const override { if (widget != WID_IC_CAPTION) return; @@ -2976,7 +2976,7 @@ struct IndustryCargoesWindow : public Wi this->ComputeIndustryDisplay(data); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_IC_PANEL) return; @@ -3061,7 +3061,7 @@ struct IndustryCargoesWindow : public Wi return true; } - 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_IC_PANEL: { @@ -3134,7 +3134,7 @@ struct IndustryCargoesWindow : public Wi } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (index < 0) return; @@ -3149,7 +3149,7 @@ struct IndustryCargoesWindow : public Wi } } - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget != WID_IC_PANEL) return false; diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -282,7 +282,7 @@ struct SelectGameWindow : public Window this->GetWidget(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SGI_BASESET: @@ -297,7 +297,7 @@ struct SelectGameWindow : 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 { switch (widget) { case WID_SGI_TEMPERATE_LANDSCAPE: case WID_SGI_ARCTIC_LANDSCAPE: @@ -325,7 +325,7 @@ struct SelectGameWindow : public Window if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED); } - 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 { /* Do not create a network server when you (just) have closed one of the game * creation/load windows for the network server. */ diff --git a/src/league_gui.cpp b/src/league_gui.cpp --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -100,7 +100,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_PLT_BACKGROUND) return; @@ -127,7 +127,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_PLT_BACKGROUND) return; @@ -302,7 +302,7 @@ public: this->InitNested(table); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_SLT_CAPTION) return; SetDParamStr(0, this->title); @@ -313,7 +313,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_SLT_BACKGROUND) return; @@ -355,7 +355,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_SLT_BACKGROUND) return; @@ -395,7 +395,7 @@ public: } } - 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 { if (widget != WID_SLT_BACKGROUND) return; diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -582,7 +582,7 @@ void LinkGraphLegendWindow::SetOverlay(s } } -void LinkGraphLegendWindow::UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) +void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) { if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) { StringID str = STR_NULL; @@ -609,7 +609,7 @@ void LinkGraphLegendWindow::UpdateWidget } } -void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const +void LinkGraphLegendWindow::DrawWidget(const Rect &r, WidgetID widget) const { Rect br = r.Shrink(WidgetDimensions::scaled.bevel); if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) { @@ -640,7 +640,7 @@ void LinkGraphLegendWindow::DrawWidget(c } } -bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, int widget, TooltipCloseCondition close_cond) +bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, WidgetID widget, TooltipCloseCondition close_cond) { if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) { if (this->IsWidgetDisabled(widget)) { @@ -687,7 +687,7 @@ void LinkGraphLegendWindow::UpdateOverla this->overlay->SetCargoMask(mask); } -void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) +void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) { /* Check which button is clicked */ if (IsInsideMM(widget, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST + 1)) { diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -54,7 +54,7 @@ public: * @param company_mask Bitmask of companies to be shown. * @param scale Desired thickness of lines and size of station dots. */ - LinkGraphOverlay(Window *w, uint wid, CargoTypes cargo_mask, CompanyMask company_mask, uint scale) : + LinkGraphOverlay(Window *w, WidgetID wid, CargoTypes cargo_mask, CompanyMask company_mask, uint scale) : window(w), widget_id(wid), cargo_mask(cargo_mask), company_mask(company_mask), scale(scale) {} @@ -75,7 +75,7 @@ public: protected: Window *window; ///< Window to be drawn into. - const uint widget_id; ///< ID of Widget in Window to be drawn to. + const WidgetID widget_id; ///< ID of Widget in Window to be drawn to. CargoTypes cargo_mask; ///< Bitmask of cargos to be displayed. CompanyMask company_mask; ///< Bitmask of companies to be displayed. LinkMap cached_links; ///< Cache for links to reduce recalculation. @@ -108,10 +108,10 @@ public: LinkGraphLegendWindow(WindowDesc *desc, int window_number); void SetOverlay(std::shared_ptr overlay); - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; - void DrawWidget(const Rect &r, int widget) const override; - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override; - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override; + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; + void DrawWidget(const Rect &r, WidgetID widget) const override; + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override; + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override; void OnInvalidateData(int data = 0, bool gui_scope = true) override; private: diff --git a/src/main_gui.cpp b/src/main_gui.cpp --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -60,7 +60,7 @@ * @param mode Tile highlighting mode, e.g. drawing a rectangle or a dot on the ground * @return true if the button is clicked, false if it's unclicked */ -bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode) +bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode) { if (w->IsWidgetDisabled(widget)) return false; @@ -448,7 +448,7 @@ struct MainWindow : Window } } - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { if (widget != WID_M_VIEWPORT) return false; return this->viewport->overlay->ShowTooltip(pt, close_cond); 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: { diff --git a/src/music_gui.cpp b/src/music_gui.cpp --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -486,7 +486,7 @@ struct MusicTrackSelectionWindow : publi this->LowerWidget(WID_MTS_ALL + _settings_client.music.playlist); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_MTS_PLAYLIST: @@ -518,7 +518,7 @@ struct MusicTrackSelectionWindow : publi } } - 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 { switch (widget) { case WID_MTS_PLAYLIST: { @@ -553,7 +553,7 @@ struct MusicTrackSelectionWindow : publi } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_MTS_LIST_LEFT: { @@ -586,7 +586,7 @@ struct MusicTrackSelectionWindow : publi } } - 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_MTS_LIST_LEFT: { // add to playlist @@ -618,7 +618,7 @@ struct MusicTrackSelectionWindow : publi } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_MTS_MUSICSET: @@ -700,7 +700,7 @@ struct MusicWindow : 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 { switch (widget) { /* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size. @@ -742,7 +742,7 @@ struct MusicWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_M_TRACK_NR: { @@ -805,7 +805,7 @@ struct MusicWindow : 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_M_PREV: // skip to prev diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -440,7 +440,7 @@ struct NetworkChatWindow : public Window return pt; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_NC_DESTINATION) return; @@ -449,7 +449,7 @@ struct NetworkChatWindow : 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_NC_SENDBUTTON: /* Send */ @@ -472,7 +472,7 @@ struct NetworkChatWindow : public Window return state; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_NC_TEXTBOX) { _chat_tab_completion_active = false; diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -64,7 +64,7 @@ struct ContentTextfileWindow : public Te } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, this->GetTypeString()); @@ -114,7 +114,7 @@ void BaseNetworkContentDownloadStatusWin this->Window::Close(); } -void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) +void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) { switch (widget) { case WID_NCDS_PROGRESS_BAR: @@ -133,7 +133,7 @@ void BaseNetworkContentDownloadStatusWin } } -void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widget) const +void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, WidgetID widget) const { switch (widget) { case WID_NCDS_PROGRESS_BAR: { @@ -285,7 +285,7 @@ public: this->BaseNetworkContentDownloadStatusWindow::Close(); } - 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 { if (widget == WID_NCDS_CANCELOK) { if (this->downloaded_bytes != this->total_bytes) { @@ -581,7 +581,7 @@ public: this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT)); } - 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 { switch (widget) { case WID_NCL_CHECKBOX: @@ -605,7 +605,7 @@ public: } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NCL_DETAILS: @@ -788,7 +788,7 @@ public: } } - 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 { if (widget >= WID_NCL_TEXTFILE && widget < WID_NCL_TEXTFILE + TFT_CONTENT_END) { if (this->selected == nullptr || this->selected->state != ContentInfo::ALREADY_HERE) return; @@ -921,7 +921,7 @@ public: return ES_HANDLED; } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_NCL_FILTER) { this->filter_data.string_filter.SetFilterTerm(this->filter_editbox.text.buf); diff --git a/src/network/network_content_gui.h b/src/network/network_content_gui.h --- a/src/network/network_content_gui.h +++ b/src/network/network_content_gui.h @@ -33,8 +33,8 @@ public: BaseNetworkContentDownloadStatusWindow(WindowDesc *desc); void Close([[maybe_unused]] int data = 0) override; - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; - void DrawWidget(const Rect &r, int widget) const override; + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; + void DrawWidget(const Rect &r, WidgetID widget) const override; void OnDownloadProgress(const ContentInfo *ci, int bytes) override; }; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -462,7 +462,7 @@ public: this->flag_offset = this->blot_offset + ScaleGUITrad(2) + GetSpriteSize(SPR_BLOT).width; } - 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 { switch (widget) { case WID_NG_MATRIX: @@ -508,7 +508,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NG_MATRIX: { @@ -666,7 +666,7 @@ public: } } - 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_NG_CANCEL: // Cancel button @@ -800,7 +800,7 @@ public: return state; } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { switch (wid) { case WID_NG_FILTER: { @@ -963,7 +963,7 @@ void ShowNetworkGameWindow() } struct NetworkStartServerWindow : public Window { - byte widget_id; ///< The widget that has the pop-up input menu + WidgetID widget_id; ///< The widget that has the pop-up input menu QueryString name_editbox; ///< Server name editbox. NetworkStartServerWindow(WindowDesc *desc) : Window(desc), name_editbox(NETWORK_NAME_LENGTH) @@ -976,7 +976,7 @@ struct NetworkStartServerWindow : public this->SetFocusedWidget(WID_NSS_GAMENAME); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_NSS_CONNTYPE_BTN: @@ -993,7 +993,7 @@ struct NetworkStartServerWindow : 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 { switch (widget) { case WID_NSS_CONNTYPE_BTN: @@ -1004,7 +1004,7 @@ struct NetworkStartServerWindow : public } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NSS_SETPWD: @@ -1013,7 +1013,7 @@ struct NetworkStartServerWindow : public } } - 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_NSS_CANCEL: // Cancel button @@ -1091,7 +1091,7 @@ struct NetworkStartServerWindow : public } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_NSS_CONNTYPE_BTN: @@ -1656,7 +1656,7 @@ public: this->SetWidgetDisabledState(WID_CL_SERVER_NAME_EDIT, !_network_server); } - 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 { switch (widget) { case WID_CL_SERVER_VISIBILITY: @@ -1684,7 +1684,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_CL_MATRIX); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CL_SERVER_NAME: @@ -1719,7 +1719,7 @@ public: } } - 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_CL_SERVER_NAME_EDIT: @@ -1753,7 +1753,7 @@ public: } } - bool OnTooltip([[maybe_unused]] Point pt, int widget, TooltipCloseCondition close_cond) override + bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override { switch (widget) { case WID_CL_MATRIX: { @@ -1792,7 +1792,7 @@ public: return false; } - void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override + void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override { /* If you close the dropdown outside the list, don't take any action. */ if (widget == WID_CL_MATRIX) return; @@ -1800,7 +1800,7 @@ public: Window::OnDropdownClose(pt, widget, index, instant_close); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_CL_SERVER_VISIBILITY: @@ -2010,7 +2010,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_CL_MATRIX: { @@ -2046,7 +2046,7 @@ public: } } - void OnMouseOver([[maybe_unused]] Point pt, int widget) override + void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override { if (widget != WID_CL_MATRIX) { if (this->hover_index != -1) { @@ -2082,7 +2082,7 @@ struct NetworkJoinStatusWindow : Window this->InitNested(WN_NETWORK_STATUS_WINDOW_JOIN); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NJS_PROGRESS_BAR: { @@ -2133,7 +2133,7 @@ struct NetworkJoinStatusWindow : 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 { switch (widget) { case WID_NJS_PROGRESS_BAR: @@ -2159,7 +2159,7 @@ struct NetworkJoinStatusWindow : 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 { if (widget == WID_NJS_CANCELOK) { // Disconnect button NetworkDisconnect(); @@ -2248,14 +2248,14 @@ struct NetworkCompanyPasswordWindow : pu 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_NCP_WARNING) { *size = this->warning_size; } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_NCP_WARNING) return; @@ -2272,7 +2272,7 @@ struct NetworkCompanyPasswordWindow : pu NetworkChangeCompanyPassword(_local_company, this->password_editbox.text.buf); } - 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_NCP_OK: @@ -2354,14 +2354,14 @@ struct NetworkAskRelayWindow : public Wi this->Window::Close(); } - 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_NAR_TEXT) { *size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT); } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_NAR_TEXT) { DrawStringMultiLine(r, STR_NETWORK_ASK_RELAY_TEXT, TC_FROMSTRING, SA_CENTER); @@ -2376,7 +2376,7 @@ struct NetworkAskRelayWindow : public Wi this->SetDirty(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_NAR_TEXT: @@ -2386,7 +2386,7 @@ struct NetworkAskRelayWindow : public Wi } } - 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_NAR_NO: @@ -2457,14 +2457,14 @@ struct NetworkAskSurveyWindow : public W this->InitNested(0); } - 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_NAS_TEXT) { *size = GetStringBoundingBox(STR_NETWORK_ASK_SURVEY_TEXT); } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_NAS_TEXT) { DrawStringMultiLine(r, STR_NETWORK_ASK_SURVEY_TEXT, TC_BLACK, SA_CENTER); @@ -2479,7 +2479,7 @@ struct NetworkAskSurveyWindow : public W this->SetDirty(); } - 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_NAS_PREVIEW: diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -359,14 +359,14 @@ struct NewGRFInspectWindow : Window { this->OnInvalidateData(0, true); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_NGRFI_CAPTION) return; GetFeatureHelper(this->window_number)->SetStringParameters(this->GetFeatureIndex()); } - 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 { switch (widget) { case WID_NGRFI_VEH_CHAIN: { @@ -542,7 +542,7 @@ struct NewGRFInspectWindow : Window { const_cast(this)->vscroll->SetCount(i); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NGRFI_VEH_CHAIN: @@ -555,7 +555,7 @@ struct NewGRFInspectWindow : 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_NGRFI_PARENT: { @@ -843,7 +843,7 @@ struct SpriteAlignerWindow : Window { this->InvalidateData(0, true); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { const Sprite *spr = GetSprite(this->current_sprite, SpriteType::Normal); switch (widget) { @@ -877,7 +877,7 @@ struct SpriteAlignerWindow : 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 { switch (widget) { case WID_SA_SPRITE: @@ -895,7 +895,7 @@ struct SpriteAlignerWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SA_SPRITE: { @@ -947,7 +947,7 @@ struct SpriteAlignerWindow : 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_SA_PREVIOUS: diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -210,7 +210,7 @@ struct NewGRFParametersWindow : public W return this->HasParameterInfo(nr) ? this->grf_config->param_info[nr].value() : GetDummyParameterInfo(nr); } - 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 { switch (widget) { case WID_NP_NUMPAR_DEC: @@ -253,7 +253,7 @@ struct NewGRFParametersWindow : public W } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_NP_NUMPAR: @@ -262,7 +262,7 @@ struct NewGRFParametersWindow : public W } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget == WID_NP_DESCRIPTION) { if (!this->HasParameterInfo(this->clicked_row)) return; @@ -331,7 +331,7 @@ struct NewGRFParametersWindow : public W this->DrawWidgets(); } - 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_NP_NUMPAR_DEC: @@ -453,7 +453,7 @@ struct NewGRFParametersWindow : public W this->SetDirty(); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_NP_SETTING_DROPDOWN) return; assert(this->clicked_dropdown); @@ -462,7 +462,7 @@ struct NewGRFParametersWindow : public W this->SetDirty(); } - void OnDropdownClose(Point, int widget, int, bool) override + void OnDropdownClose(Point, WidgetID widget, int, bool) override { if (widget != WID_NP_SETTING_DROPDOWN) return; /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether @@ -564,7 +564,7 @@ struct NewGRFTextfileWindow : public Tex this->LoadTextfile(textfile.value(), NEWGRF_DIR); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, STR_CONTENT_TYPE_NEWGRF); @@ -741,7 +741,7 @@ struct NewGRFWindow : public Window, New } } - 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 { switch (widget) { case WID_NS_FILE_LIST: @@ -799,7 +799,7 @@ struct NewGRFWindow : public Window, New this->vscroll2->SetCapacityFromWidget(this, WID_NS_AVAIL_LIST); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_NS_PRESET_LIST: @@ -848,7 +848,7 @@ struct NewGRFWindow : public Window, New return pal; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_NS_FILE_LIST: { @@ -940,7 +940,7 @@ struct NewGRFWindow : public Window, New } } - 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 { if (widget >= WID_NS_NEWGRF_TEXTFILE && widget < WID_NS_NEWGRF_TEXTFILE + TFT_CONTENT_END) { if (this->active_sel == nullptr && this->avail_sel == nullptr) return; @@ -1175,7 +1175,7 @@ struct NewGRFWindow : public Window, New this->CloseChildWindows(WC_QUERY_STRING); // Remove the parameter query window } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_NS_PRESET_LIST) return; if (!this->editable) return; @@ -1361,7 +1361,7 @@ struct NewGRFWindow : public Window, New return ES_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (!this->editable) return; @@ -1373,7 +1373,7 @@ struct NewGRFWindow : public Window, New } } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { if (!this->editable) return; @@ -1421,7 +1421,7 @@ struct NewGRFWindow : public Window, New } } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { if (!this->editable) return; @@ -2096,7 +2096,7 @@ struct SavePresetWindow : 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 { switch (widget) { case WID_SVP_PRESET_LIST: { @@ -2113,7 +2113,7 @@ struct SavePresetWindow : public Window } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SVP_PRESET_LIST: { @@ -2137,7 +2137,7 @@ struct SavePresetWindow : 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_SVP_PRESET_LIST: { @@ -2211,7 +2211,7 @@ struct ScanProgressWindow : public Windo this->InitNested(1); } - 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 { switch (widget) { case WID_SP_PROGRESS_BAR: { @@ -2234,7 +2234,7 @@ struct ScanProgressWindow : public Windo } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SP_PROGRESS_BAR: { diff --git a/src/news_gui.cpp b/src/news_gui.cpp --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -342,7 +342,7 @@ struct NewsWindow : 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 { StringID str = STR_NULL; switch (widget) { @@ -416,12 +416,12 @@ struct NewsWindow : Window { *size = maxdim(*size, d); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_N_DATE) SetDParam(0, this->ni->date); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_N_CAPTION: @@ -478,7 +478,7 @@ struct NewsWindow : 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_N_CLOSEBOX: @@ -590,7 +590,7 @@ private: return this->ni->params[1].data; } - StringID GetNewVehicleMessageString(int widget) const + StringID GetNewVehicleMessageString(WidgetID widget) const { assert(this->ni->reftype1 == NR_ENGINE); EngineID engine = this->ni->ref1; @@ -1127,7 +1127,7 @@ struct MessageHistoryWindow : Window { this->OnInvalidateData(0); } - 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_MH_BACKGROUND) { this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; @@ -1149,7 +1149,7 @@ struct MessageHistoryWindow : Window { this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_MH_BACKGROUND || _total_news == 0) return; @@ -1188,7 +1188,7 @@ struct MessageHistoryWindow : Window { this->vscroll->SetCount(_total_news); } - 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 { if (widget == WID_MH_BACKGROUND) { NewsItem *ni = _latest_news; diff --git a/src/object_gui.cpp b/src/object_gui.cpp --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -184,7 +184,7 @@ public: assert(ObjectClass::Get(_selected_object_class)->GetUISpecCount() > 0); // object GUI should be disabled elsewise } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_BO_OBJECT_NAME: { @@ -212,7 +212,7 @@ public: this->object_margin = ScaleGUITrad(4); } - 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 { switch (widget) { case WID_BO_CLASS_LIST: { @@ -304,7 +304,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (GB(widget, 0, 16)) { case WID_BO_CLASS_LIST: { @@ -494,7 +494,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST); } - 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 (GB(widget, 0, 16)) { case WID_BO_CLASS_LIST: { @@ -575,7 +575,7 @@ public: return ES_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_BO_FILTER) { string_filter.SetFilterTerm(this->filter_editbox.text.buf); diff --git a/src/order_gui.cpp b/src/order_gui.cpp --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -801,7 +801,7 @@ public: this->OnInvalidateData(VIWD_MODIFY_ORDERS); } - 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 { switch (widget) { case WID_O_ORDER_LIST: @@ -1081,7 +1081,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_O_ORDER_LIST) return; @@ -1140,7 +1140,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_O_COND_VALUE: { @@ -1161,7 +1161,7 @@ public: } } - 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_O_ORDER_LIST: { @@ -1351,7 +1351,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_O_NON_STOP: @@ -1394,7 +1394,7 @@ public: } } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { switch (widget) { case WID_O_ORDER_LIST: { @@ -1525,7 +1525,7 @@ public: } } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { if (this->selected_order != -1 && widget == WID_O_ORDER_LIST) { /* An order is dragged.. */ diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -37,7 +37,7 @@ static byte _keystate = KEYS_NONE; struct OskWindow : public Window { StringID caption; ///< the caption for this window. QueryString *qs; ///< text-input - int text_btn; ///< widget number of parent's text field + WidgetID text_btn; ///< widget number of parent's text field Textbuf *text; ///< pointer to parent's textbuffer (to update caret position) std::string orig_str; ///< Original string. bool shift; ///< Is the shift effectively pressed? @@ -88,12 +88,12 @@ struct OskWindow : public Window { this->SetWidgetLoweredState(WID_OSK_CAPS, HasBit(_keystate, KEYS_CAPS)); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_OSK_CAPTION) SetDParam(0, this->caption); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget < WID_OSK_LETTERS) return; @@ -101,7 +101,7 @@ struct OskWindow : public Window { DrawCharCentered(_keyboard[this->shift][widget], r, TC_BLACK); } - 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 { /* clicked a letter */ if (widget >= WID_OSK_LETTERS) { @@ -183,7 +183,7 @@ struct OskWindow : public Window { } } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_OSK_TEXT) { this->SetWidgetDirty(WID_OSK_TEXT); @@ -222,7 +222,7 @@ static const int KEY_PADDING = 6; // * @param widdata Data value of the key widget. * @note Key width is measured in 1/2 keys to allow for 1/2 key shifting between rows. */ -static void AddKey(NWidgetHorizontal *hor, int pad_y, int num_half, WidgetType widtype, int widnum, uint16_t widdata) +static void AddKey(NWidgetHorizontal *hor, int pad_y, int num_half, WidgetType widtype, WidgetID widnum, uint16_t widdata) { int key_width = HALF_KEY_WIDTH + (INTER_KEY_SPACE + HALF_KEY_WIDTH) * (num_half - 1); @@ -260,7 +260,7 @@ static NWidgetBase *MakeNumberKeys() { NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); - for (int widnum = WID_OSK_NUMBERS_FIRST; widnum <= WID_OSK_NUMBERS_LAST; widnum++) { + for (WidgetID widnum = WID_OSK_NUMBERS_FIRST; widnum <= WID_OSK_NUMBERS_LAST; widnum++) { AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } return hor; @@ -272,7 +272,7 @@ static NWidgetBase *MakeQwertyKeys() NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); AddKey(hor, KEY_PADDING, 3, WWT_PUSHIMGBTN, WID_OSK_SPECIAL, SPR_OSK_SPECIAL); - for (int widnum = WID_OSK_QWERTY_FIRST; widnum <= WID_OSK_QWERTY_LAST; widnum++) { + for (WidgetID widnum = WID_OSK_QWERTY_FIRST; widnum <= WID_OSK_QWERTY_LAST; widnum++) { AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0); @@ -285,7 +285,7 @@ static NWidgetBase *MakeAsdfgKeys() NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); AddKey(hor, KEY_PADDING, 4, WWT_IMGBTN, WID_OSK_CAPS, SPR_OSK_CAPS); - for (int widnum = WID_OSK_ASDFG_FIRST; widnum <= WID_OSK_ASDFG_LAST; widnum++) { + for (WidgetID widnum = WID_OSK_ASDFG_FIRST; widnum <= WID_OSK_ASDFG_LAST; widnum++) { AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } return hor; @@ -297,7 +297,7 @@ static NWidgetBase *MakeZxcvbKeys() NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); AddKey(hor, KEY_PADDING, 3, WWT_IMGBTN, WID_OSK_SHIFT, SPR_OSK_SHIFT); - for (int widnum = WID_OSK_ZXCVB_FIRST; widnum <= WID_OSK_ZXCVB_LAST; widnum++) { + for (WidgetID widnum = WID_OSK_ZXCVB_FIRST; widnum <= WID_OSK_ZXCVB_LAST; widnum++) { AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0); @@ -390,7 +390,7 @@ void GetKeyboardLayout() * @param parent pointer to the Window where this keyboard originated from * @param button widget number of parent's textbox */ -void ShowOnScreenKeyboard(Window *parent, int button) +void ShowOnScreenKeyboard(Window *parent, WidgetID button) { CloseWindowById(WC_OSK, 0); @@ -405,7 +405,7 @@ void ShowOnScreenKeyboard(Window *parent * @param parent window that just updated its original text * @param button widget number of parent's textbox to update */ -void UpdateOSKOriginalText(const Window *parent, int button) +void UpdateOSKOriginalText(const Window *parent, WidgetID button) { OskWindow *osk = dynamic_cast(FindWindowById(WC_OSK, 0)); if (osk == nullptr || osk->parent != parent || osk->text_btn != button) return; @@ -421,7 +421,7 @@ void UpdateOSKOriginalText(const Window * @param button Editbox of \a w to check for * @return true if the OSK is opened for \a button. */ -bool IsOSKOpenedFor(const Window *w, int button) +bool IsOSKOpenedFor(const Window *w, WidgetID button) { OskWindow *osk = dynamic_cast(FindWindowById(WC_OSK, 0)); return osk != nullptr && osk->parent == w && osk->text_btn == button; diff --git a/src/querystring_gui.h b/src/querystring_gui.h --- a/src/querystring_gui.h +++ b/src/querystring_gui.h @@ -40,17 +40,17 @@ struct QueryString { } public: - void DrawEditBox(const Window *w, int wid) const; - void ClickEditBox(Window *w, Point pt, int wid, int click_count, bool focus_changed); - void HandleEditBox(Window *w, int wid); + void DrawEditBox(const Window *w, WidgetID wid) const; + void ClickEditBox(Window *w, Point pt, WidgetID wid, int click_count, bool focus_changed); + void HandleEditBox(Window *w, WidgetID wid); - Point GetCaretPosition(const Window *w, int wid) const; - Rect GetBoundingRect(const Window *w, int wid, const char *from, const char *to) const; - ptrdiff_t GetCharAtPosition(const Window *w, int wid, const Point &pt) const; + Point GetCaretPosition(const Window *w, WidgetID wid) const; + Rect GetBoundingRect(const Window *w, WidgetID wid, const char *from, const char *to) const; + ptrdiff_t GetCharAtPosition(const Window *w, WidgetID wid, const Point &pt) const; }; -void ShowOnScreenKeyboard(Window *parent, int button); -void UpdateOSKOriginalText(const Window *parent, int button); -bool IsOSKOpenedFor(const Window *w, int button); +void ShowOnScreenKeyboard(Window *parent, WidgetID button); +void UpdateOSKOriginalText(const Window *parent, WidgetID button); +bool IsOSKOpenedFor(const Window *w, WidgetID button); #endif /* QUERYSTRING_GUI_H */ diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -306,7 +306,7 @@ static bool RailToolbar_CtrlChanged(Wind if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return false; /* allow ctrl to switch remove mode only for these widgets */ - for (uint i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) { + for (WidgetID i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) { if ((i <= WID_RAT_AUTORAIL || i >= WID_RAT_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) { ToggleRailButton_Remove(w); return true; @@ -458,7 +458,7 @@ struct BuildRailToolbarWindow : Window { this->ReInit(); } - void UpdateRemoveWidgetStatus(int clicked_widget) + void UpdateRemoveWidgetStatus(WidgetID clicked_widget) { switch (clicked_widget) { case WID_RAT_REMOVE: @@ -488,7 +488,7 @@ struct BuildRailToolbarWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_RAT_CAPTION) { const RailTypeInfo *rti = GetRailTypeInfo(this->railtype); @@ -502,7 +502,7 @@ struct BuildRailToolbarWindow : 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 { if (widget < WID_RAT_BUILD_NS) return; @@ -1123,7 +1123,7 @@ public: return ES_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_BRAS_FILTER_EDITBOX) { string_filter.SetFilterTerm(this->filter_editbox.text.buf); @@ -1181,7 +1181,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 { switch (widget) { case WID_BRAS_NEWST_LIST: { @@ -1236,7 +1236,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { DrawPixelInfo tmp_dpi; @@ -1315,7 +1315,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_BRAS_SHOW_NEWST_TYPE) { const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type); @@ -1323,7 +1323,7 @@ public: } } - 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 (GB(widget, 0, 16)) { case WID_BRAS_PLATFORM_DIR_X: @@ -1644,7 +1644,7 @@ private: * @param widget_index index of this widget in the window * @param image the sprite to draw */ - void DrawSignalSprite(const Rect &r, int widget_index, SpriteID image) const + void DrawSignalSprite(const Rect &r, WidgetID widget_index, SpriteID image) const { Point offset; Dimension sprite_size = GetSpriteSize(image, &offset); @@ -1708,7 +1708,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_BS_DRAG_SIGNALS_DENSITY_LABEL) { /* Two digits for signals density. */ @@ -1721,7 +1721,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_BS_DRAG_SIGNALS_DENSITY_LABEL: @@ -1730,7 +1730,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) { /* Extract signal from widget number. */ @@ -1742,7 +1742,7 @@ public: } } - 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_BS_SEMAPHORE_NORM: @@ -1897,7 +1897,7 @@ struct BuildRailDepotWindow : public Pic this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); } - 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 (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return; @@ -1905,7 +1905,7 @@ struct BuildRailDepotWindow : public Pic size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return; @@ -1919,7 +1919,7 @@ struct BuildRailDepotWindow : public Pic } } - 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_BRAD_DEPOT_NE: @@ -2052,7 +2052,7 @@ struct BuildRailWaypointWindow : PickerW } } - 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 { switch (widget) { case WID_BRW_WAYPOINT_MATRIX: @@ -2071,7 +2071,7 @@ struct BuildRailWaypointWindow : PickerW } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_BRW_NAME) { if (!this->list.empty() && IsInsideBS(_cur_waypoint_type, 0, this->waypoints->GetSpecCount())) { @@ -2093,7 +2093,7 @@ struct BuildRailWaypointWindow : PickerW this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (GB(widget, 0, 16)) { case WID_BRW_WAYPOINT: { @@ -2116,7 +2116,7 @@ struct BuildRailWaypointWindow : PickerW } } - 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 (GB(widget, 0, 16)) { case WID_BRW_WAYPOINT: { @@ -2143,7 +2143,7 @@ struct BuildRailWaypointWindow : PickerW this->list.ForceRebuild(); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_BRW_FILTER) { this->string_filter.SetFilterTerm(this->editbox.text.buf); diff --git a/src/road_gui.cpp b/src/road_gui.cpp --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -294,7 +294,7 @@ static bool RoadToolbar_CtrlChanged(Wind if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false; /* allow ctrl to switch remove mode only for these widgets */ - for (uint i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) { + for (WidgetID i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) { if (w->IsWidgetLowered(i)) { ToggleRoadButton_Remove(w); return true; @@ -403,7 +403,7 @@ struct BuildRoadToolbarWindow : Window { this->ReInit(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_ROT_CAPTION) { if (this->rti->max_speed > 0) { @@ -470,7 +470,7 @@ struct BuildRoadToolbarWindow : 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 { _remove_button_clicked = false; _one_way_button_clicked = false; @@ -1010,13 +1010,15 @@ struct BuildRoadDepotWindow : public Pic this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE); if (RoadTypeIsTram(_cur_roadtype)) { this->GetWidget(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION; - for (int i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) this->GetWidget(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP; + for (WidgetID i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) { + this->GetWidget(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP; + } } this->FinishInitNested(TRANSPORT_ROAD); } - 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 (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return; @@ -1024,7 +1026,7 @@ struct BuildRoadDepotWindow : public Pic size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return; @@ -1038,7 +1040,7 @@ struct BuildRoadDepotWindow : public Pic } } - 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_BROD_DEPOT_NW: @@ -1178,7 +1180,7 @@ public: const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype); this->GetWidget(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs]; - for (uint i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) { + for (WidgetID i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) { this->GetWidget(i)->tool_tip = rti->strings.picker_tooltip[rs]; } @@ -1303,7 +1305,7 @@ public: return ES_NOT_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_BROS_FILTER_EDITBOX) { string_filter.SetFilterTerm(this->filter_editbox.text.buf); @@ -1341,7 +1343,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 { switch (widget) { case WID_BROS_NEWST_LIST: { @@ -1405,7 +1407,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (GB(widget, 0, 16)) { case WID_BROS_STATION_NE: @@ -1485,7 +1487,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_BROS_SHOW_NEWST_TYPE) { const RoadStopSpec *roadstopspec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type); @@ -1493,7 +1495,7 @@ public: } } - 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 (GB(widget, 0, 16)) { case WID_BROS_STATION_NE: diff --git a/src/screenshot_gui.cpp b/src/screenshot_gui.cpp --- a/src/screenshot_gui.cpp +++ b/src/screenshot_gui.cpp @@ -27,7 +27,7 @@ struct ScreenshotWindow : Window { this->DrawWidgets(); } - 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 { ScreenshotType st; switch (widget) { diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -924,7 +924,7 @@ public: * @param number The windownumber that was clicked. * @param widget The widget in the window that was clicked. */ - ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32_t number, uint8_t widget) : + ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32_t number, WidgetID widget) : ScriptEvent(ET_WINDOW_WIDGET_CLICK), window(window), number(number), @@ -955,12 +955,12 @@ public: * Get the number of the widget that was clicked. * @return The number of the clicked widget. */ - uint8_t GetWidgetNumber() { return this->widget; } + int GetWidgetNumber() { return this->widget; } private: ScriptWindow::WindowClass window; ///< Window of the click. - uint32_t number; ///< Number of the click. - uint8_t widget; ///< Widget of the click. + uint32_t number; ///< Number of the click. + WidgetID widget; ///< Widget of the click. }; /** diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -95,14 +95,14 @@ struct ScriptListWindow : public Window } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_SCRL_CAPTION) return; SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_LIST_CAPTION_GAMESCRIPT : STR_AI_LIST_CAPTION_AI); } - 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_SCRL_LIST) return; @@ -113,7 +113,7 @@ struct ScriptListWindow : public Window size->height = 5 * this->line_height; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SCRL_LIST: { @@ -184,7 +184,7 @@ struct ScriptListWindow : public Window InvalidateWindowClassesData(WC_TEXTFILE); } - 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_SCRL_LIST: { // Select one of the Scripts @@ -335,14 +335,14 @@ struct ScriptSettingsWindow : public Win this->vscroll->SetCount(this->visible_settings.size()); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_SCRS_CAPTION) return; SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_SETTINGS_CAPTION_GAMESCRIPT : STR_AI_SETTINGS_CAPTION_AI); } - 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_SCRS_BACKGROUND) return; @@ -353,7 +353,7 @@ struct ScriptSettingsWindow : public Win size->height = 5 * this->line_height; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_SCRS_BACKGROUND) return; @@ -421,7 +421,7 @@ struct ScriptSettingsWindow : public Win this->DrawWidgets(); } - 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_SCRS_BACKGROUND: { @@ -524,14 +524,14 @@ struct ScriptSettingsWindow : public Win SetValue(value); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_SCRS_SETTING_DROPDOWN) return; assert(this->clicked_dropdown); SetValue(index); } - void OnDropdownClose(Point, int widget, int, bool) override + void OnDropdownClose(Point, WidgetID widget, int, bool) override { if (widget != WID_SCRS_SETTING_DROPDOWN) return; /* We cannot raise the dropdown button just yet. OnClick needs some hint, whether @@ -634,7 +634,7 @@ struct ScriptTextfileWindow : public Tex this->OnInvalidateData(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, (slot == OWNER_DEITY) ? STR_CONTENT_TYPE_GAME_SCRIPT : STR_CONTENT_TYPE_AI); @@ -821,7 +821,7 @@ struct ScriptDebugWindow : public Window ScriptDebugWindow::initial_state = this->filter; } - 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_SCRD_LOG_PANEL) { resize->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; @@ -838,7 +838,7 @@ struct ScriptDebugWindow : public Window this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_SCRD_NAME_TEXT) return; @@ -859,7 +859,7 @@ struct ScriptDebugWindow : public Window } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SCRD_LOG_PANEL: @@ -880,7 +880,7 @@ struct ScriptDebugWindow : public Window * @param widget Widget index to start. * @param start Widget index of first company button. */ - void DrawWidgetCompanyButton(const Rect &r, int widget, int start) const + void DrawWidgetCompanyButton(const Rect &r, WidgetID widget, int start) const { if (this->IsWidgetDisabled(widget)) return; CompanyID cid = (CompanyID)(widget - start); @@ -1034,7 +1034,7 @@ struct ScriptDebugWindow : public Window this->last_vscroll_pos = this->vscroll->GetPosition(); } - 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 { /* Also called for hotkeys, so check for disabledness */ if (this->IsWidgetDisabled(widget)) return; @@ -1103,7 +1103,7 @@ struct ScriptDebugWindow : public Window } } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid != WID_SCRD_BREAK_STR_EDIT_BOX) return; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -96,7 +96,7 @@ struct BaseSetTextfileWindow : public Te this->LoadTextfile(textfile.value(), BASESET_DIR); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TF_CAPTION) { SetDParam(0, content_type); @@ -170,7 +170,7 @@ struct GameOptionsWindow : Window { GameSettings *opt; bool reload; int gui_scale; - static inline int active_tab = WID_GO_TAB_GENERAL; + static inline WidgetID active_tab = WID_GO_TAB_GENERAL; GameOptionsWindow(WindowDesc *desc) : Window(desc) { @@ -202,7 +202,7 @@ struct GameOptionsWindow : Window { * @param selected_index Currently selected item * @return the built dropdown list, or nullptr if the widget has no dropdown menu. */ - DropDownList BuildDropDownList(int widget, int *selected_index) const + DropDownList BuildDropDownList(WidgetID widget, int *selected_index) const { DropDownList list; switch (widget) { @@ -304,7 +304,7 @@ struct GameOptionsWindow : Window { return list; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_GO_CURRENCY_DROPDOWN: { @@ -347,7 +347,7 @@ struct GameOptionsWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GO_BASE_GRF_DESCRIPTION: @@ -384,7 +384,7 @@ struct GameOptionsWindow : Window { } } - void SetTab(int widget) + void SetTab(WidgetID widget) { this->SetWidgetsLoweredState(false, WID_GO_TAB_GENERAL, WID_GO_TAB_GRAPHICS, WID_GO_TAB_SOUND); this->LowerWidget(widget); @@ -433,7 +433,7 @@ struct GameOptionsWindow : Window { if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED); } - 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 { switch (widget) { case WID_GO_TEXT_SFX_VOLUME: @@ -453,7 +453,7 @@ struct GameOptionsWindow : 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 { if (widget >= WID_GO_BASE_GRF_TEXTFILE && widget < WID_GO_BASE_GRF_TEXTFILE + TFT_CONTENT_END) { if (BaseGraphics::GetUsedSet() == nullptr) return; @@ -644,7 +644,7 @@ struct GameOptionsWindow : Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_GO_CURRENCY_DROPDOWN: // Currency @@ -2110,7 +2110,7 @@ struct GameSettingsWindow : Window { _circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED)); } - 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 { switch (widget) { case WID_GS_OPTIONSPANEL: @@ -2178,7 +2178,7 @@ struct GameSettingsWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_GS_RESTRICT_DROPDOWN: @@ -2196,7 +2196,7 @@ struct GameSettingsWindow : Window { } } - DropDownList BuildDropDownList(int widget) const + DropDownList BuildDropDownList(WidgetID widget) const { DropDownList list; switch (widget) { @@ -2220,7 +2220,7 @@ struct GameSettingsWindow : Window { return list; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_GS_OPTIONSPANEL: { @@ -2270,7 +2270,7 @@ struct GameSettingsWindow : Window { this->last_clicked = pe; } - 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_GS_EXPAND_ALL: @@ -2488,7 +2488,7 @@ struct GameSettingsWindow : Window { this->SetDirty(); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_GS_RESTRICT_DROPDOWN: @@ -2525,7 +2525,7 @@ struct GameSettingsWindow : Window { } } - void OnDropdownClose(Point pt, int widget, int index, bool instant_close) override + void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) override { if (widget != WID_GS_SETTING_DROPDOWN) { /* Normally the default implementation of OnDropdownClose() takes care of @@ -2574,7 +2574,7 @@ struct GameSettingsWindow : Window { this->SetWidgetDisabledState(WID_GS_COLLAPSE_ALL, all_folded); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_GS_FILTER) { this->filter.string.SetFilterTerm(this->filter_editbox.text.buf); @@ -2737,7 +2737,7 @@ struct CustomCurrencyWindow : Window { this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == CalendarTime::MAX_YEAR); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_CC_RATE: SetDParam(0, 1); SetDParam(1, 1); break; @@ -2755,7 +2755,7 @@ struct CustomCurrencyWindow : 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 { switch (widget) { /* Set the appropriate width for the up/down buttons. */ @@ -2782,7 +2782,7 @@ struct CustomCurrencyWindow : 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 { int line = 0; int len = 0; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -192,7 +192,7 @@ struct SignListWindow : Window, SignList this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SIL_LIST: { @@ -226,12 +226,12 @@ struct SignListWindow : Window, SignList } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_SIL_CAPTION) SetDParam(0, this->vscroll->GetCount()); } - 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_SIL_LIST: { @@ -263,7 +263,7 @@ struct SignListWindow : Window, SignList this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.Vertical()); } - 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 { switch (widget) { case WID_SIL_LIST: { @@ -299,7 +299,7 @@ struct SignListWindow : Window, SignList return ES_HANDLED; } - void OnEditboxChanged(int widget) override + void OnEditboxChanged(WidgetID widget) override { if (widget == WID_SIL_FILTER_TEXT) this->SetFilterString(this->filter_editbox.text.buf); } @@ -474,7 +474,7 @@ struct SignWindow : Window, SignList { return next ? this->signs.front() : this->signs.back(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_QES_CAPTION: @@ -483,7 +483,7 @@ struct SignWindow : Window, SignList { } } - 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_QES_LOCATION: { diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1459,7 +1459,7 @@ public: this->Window::Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SM_CAPTION: @@ -1537,7 +1537,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_SM_MAP: { @@ -1634,7 +1634,7 @@ public: } } - 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_SM_MAP: { // Map window @@ -1779,7 +1779,7 @@ public: this->SetDirty(); } - bool OnRightClick(Point, int widget) override + bool OnRightClick(Point, WidgetID widget) override { if (widget != WID_SM_MAP || _scrolling_viewport) return false; @@ -1812,7 +1812,7 @@ public: this->SetDirty(); } - void OnMouseOver([[maybe_unused]] Point pt, int widget) override + void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override { IndustryType new_highlight = INVALID_INDUSTRYTYPE; if (widget == WID_SM_LEGEND && this->map_type == SMT_INDUSTRY) { diff --git a/src/station_gui.cpp b/src/station_gui.cpp --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -399,7 +399,7 @@ public: CompanyStationsWindow::initial_state = this->filter; } - 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 { switch (widget) { case WID_STL_SORTBY: { @@ -453,7 +453,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_STL_SORTBY: @@ -525,7 +525,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_STL_CAPTION) { SetDParam(0, this->window_number); @@ -533,7 +533,7 @@ public: } } - 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_STL_LIST: { @@ -572,7 +572,7 @@ public: break; case WID_STL_FACILALL: - for (uint i = WID_STL_TRAIN; i <= WID_STL_SHIP; i++) { + for (WidgetID i = WID_STL_TRAIN; i <= WID_STL_SHIP; i++) { this->LowerWidget(i); } @@ -648,7 +648,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget == WID_STL_SORTDROPBTN) { if (this->stations.SortType() != index) { @@ -1386,7 +1386,7 @@ struct StationViewWindow : public Window data->Update(count); } - 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 { switch (widget) { case WID_SV_WAITING: @@ -1470,7 +1470,7 @@ struct StationViewWindow : public Window } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_SV_CAPTION) { const Station *st = Station::Get(this->window_number); @@ -1914,7 +1914,7 @@ struct StationViewWindow : public Window this->SetWidgetDirty(WID_SV_WAITING); } - 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_SV_WAITING: @@ -2079,7 +2079,7 @@ struct StationViewWindow : public Window this->SetDirty(); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget == WID_SV_SORT_BY) { this->SelectSortBy(index); @@ -2299,7 +2299,7 @@ struct SelectStationWindow : Window { this->Window::Close(); } - 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_JS_PANEL) return; @@ -2320,7 +2320,7 @@ struct SelectStationWindow : Window { *size = d; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_JS_PANEL) return; @@ -2338,7 +2338,7 @@ struct SelectStationWindow : 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 { if (widget != WID_JS_PANEL) return; @@ -2378,7 +2378,7 @@ struct SelectStationWindow : Window { this->SetDirty(); } - void OnMouseOver([[maybe_unused]] Point pt, int widget) override + void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override { if (widget != WID_JS_PANEL) { SetViewportCatchmentSpecializedStation(nullptr, true); diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -83,7 +83,7 @@ struct StatusBarWindow : Window { Window::FindWindowPlacementAndResize(_toolbar_width, def_height); } - 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 { Dimension d; switch (widget) { @@ -109,7 +109,7 @@ struct StatusBarWindow : Window { *size = maxdim(d, *size); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { Rect tr = r.Shrink(WidgetDimensions::scaled.framerect, RectPadding::zero); tr.top = CenterBounds(r.top, r.bottom, GetCharacterHeight(FS_NORMAL)); @@ -190,7 +190,7 @@ struct StatusBarWindow : 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_S_MIDDLE: ShowLastNewsMessage(); break; diff --git a/src/story_gui.cpp b/src/story_gui.cpp --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -643,7 +643,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_SB_SEL_PAGE: { @@ -677,7 +677,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_SB_PAGE_PANEL) return; @@ -751,7 +751,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_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return; @@ -801,7 +801,7 @@ public: this->vscroll->SetCount(this->GetContentHeight()); } - 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_SB_SEL_PAGE: { @@ -842,7 +842,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_SB_SEL_PAGE) return; diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -36,7 +36,7 @@ struct SubsidyListWindow : Window { this->OnInvalidateData(0); } - 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 { if (widget != WID_SUL_PANEL) return; @@ -125,7 +125,7 @@ struct SubsidyListWindow : Window { return 3 + num_awarded + num_not_awarded; } - 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_SUL_PANEL) return; Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE)); @@ -138,7 +138,7 @@ struct SubsidyListWindow : 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_SUL_PANEL) return; diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -175,7 +175,7 @@ struct TerraformToolbarWindow : Window { show_object->SetDisplayedPlane(ObjectClass::GetUIClassCount() != 0 ? 0 : SZSP_NONE); } - 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 { if (widget < WID_TT_BUTTONS_START) return; @@ -553,7 +553,7 @@ struct ScenarioEditorLandscapeGeneration } } - 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_ETT_DOTS) return; @@ -561,7 +561,7 @@ struct ScenarioEditorLandscapeGeneration size->height = std::max(size->height, ScaleGUITrad(31)); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_ETT_DOTS) return; @@ -578,7 +578,7 @@ struct ScenarioEditorLandscapeGeneration } while (--n); } - 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 { if (widget < WID_ETT_BUTTONS_START) return; diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -126,7 +126,7 @@ uint TextfileWindow::GetContentHeight() return this->lines.back().bottom; } -/* virtual */ void TextfileWindow::UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) +/* virtual */ void TextfileWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) { switch (widget) { case WID_TF_BACKGROUND: @@ -516,7 +516,7 @@ void TextfileWindow::AfterLoadMarkdown() } } -/* virtual */ void TextfileWindow::OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) +/* virtual */ void TextfileWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) { switch (widget) { case WID_TF_WRAPTEXT: @@ -548,7 +548,7 @@ void TextfileWindow::AfterLoadMarkdown() } } -/* virtual */ void TextfileWindow::DrawWidget(const Rect &r, int widget) const +/* virtual */ void TextfileWindow::DrawWidget(const Rect &r, WidgetID widget) const { if (widget != WID_TF_BACKGROUND) return; @@ -592,7 +592,7 @@ void TextfileWindow::AfterLoadMarkdown() this->SetupScrollbars(true); } -void TextfileWindow::OnDropdownSelect(int widget, int index) +void TextfileWindow::OnDropdownSelect(WidgetID widget, int index) { if (widget != WID_TF_JUMPLIST) return; diff --git a/src/textfile_gui.h b/src/textfile_gui.h --- a/src/textfile_gui.h +++ b/src/textfile_gui.h @@ -25,12 +25,12 @@ struct TextfileWindow : public Window, M TextfileWindow(TextfileType file_type); - void UpdateWidgetSize(int widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; - void OnClick([[maybe_unused]] Point pt, int widget, [[maybe_unused]] int click_count) override; - void DrawWidget(const Rect &r, int widget) const override; + void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override; + void DrawWidget(const Rect &r, WidgetID widget) const override; void OnResize() override; void OnInvalidateData(int data = 0, bool gui_scope = true) override; - void OnDropdownSelect(int widget, int index) override; + void OnDropdownSelect(WidgetID widget, int index) override; void Reset() override; FontSize DefaultSize() override; diff --git a/src/tilehighlight_func.h b/src/tilehighlight_func.h --- a/src/tilehighlight_func.h +++ b/src/tilehighlight_func.h @@ -16,7 +16,7 @@ void PlaceProc_DemolishArea(TileIndex tile); bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile); -bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode); +bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode); void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w); void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num); void ResetObjectToPlace(); diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -242,7 +242,7 @@ struct TimetableWindow : Window { return (travelling && v->lateness_counter < 0); } - 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 { switch (widget) { case WID_VT_ARRIVAL_DEPARTURE_PANEL: @@ -396,7 +396,7 @@ struct TimetableWindow : Window { this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_VT_CAPTION: SetDParam(0, this->vehicle->index); break; @@ -590,7 +590,7 @@ struct TimetableWindow : Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_VT_TIMETABLE_PANEL: { @@ -620,7 +620,7 @@ struct TimetableWindow : Window { return { order_number, mtf }; } - 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 { const Vehicle *v = this->vehicle; diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -109,7 +109,7 @@ public: * @param list List of items * @param def Default item */ -static void PopupMainToolbarMenu(Window *w, int widget, DropDownList &&list, int def) +static void PopupMainToolbarMenu(Window *w, WidgetID widget, DropDownList &&list, int def) { ShowDropDownList(w, std::move(list), def, widget, 0, true); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); @@ -121,7 +121,7 @@ static void PopupMainToolbarMenu(Window * @param widget Toolbar button * @param strings List of strings for each item in the menu */ -static void PopupMainToolbarMenu(Window *w, int widget, const std::initializer_list &strings) +static void PopupMainToolbarMenu(Window *w, WidgetID widget, const std::initializer_list &strings) { DropDownList list; int i = 0; @@ -147,7 +147,7 @@ static const int CTMN_SPECTATOR = -3; * @param widget The button widget id. * @param grey A bitbask of which items to mark as disabled. */ -static void PopupMainCompanyToolbMenu(Window *w, int widget, int grey = 0) +static void PopupMainCompanyToolbMenu(Window *w, WidgetID widget, int grey = 0) { DropDownList list; @@ -820,7 +820,7 @@ static CallBackFunction MenuClickShowAir static CallBackFunction ToolbarZoomInClick(Window *w) { if (DoZoomInOutWindow(ZOOM_IN, GetMainWindow())) { - w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_IN : (byte)WID_TN_ZOOM_IN); + w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_IN : (WidgetID)WID_TN_ZOOM_IN); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } return CBF_NONE; @@ -831,7 +831,7 @@ static CallBackFunction ToolbarZoomInCli static CallBackFunction ToolbarZoomOutClick(Window *w) { if (DoZoomInOutWindow(ZOOM_OUT, GetMainWindow())) { - w->HandleButtonClick((_game_mode == GM_EDITOR) ? (byte)WID_TE_ZOOM_OUT : (byte)WID_TN_ZOOM_OUT); + w->HandleButtonClick((_game_mode == GM_EDITOR) ? (WidgetID)WID_TE_ZOOM_OUT : (WidgetID)WID_TN_ZOOM_OUT); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); } return CBF_NONE; @@ -980,7 +980,7 @@ static CallBackFunction MenuClickForest( static CallBackFunction ToolbarMusicClick(Window *w) { - PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_MUSIC_SOUND : (int)WID_TN_MUSIC_SOUND, {STR_TOOLBAR_SOUND_MUSIC}); + PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_MUSIC_SOUND : (WidgetID)WID_TN_MUSIC_SOUND, {STR_TOOLBAR_SOUND_MUSIC}); return CBF_NONE; } @@ -1035,13 +1035,13 @@ static CallBackFunction PlaceLandBlockIn static CallBackFunction ToolbarHelpClick(Window *w) { if (_settings_client.gui.newgrf_developer_tools) { - PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_HELP : (int)WID_TN_HELP, {STR_ABOUT_MENU_LAND_BLOCK_INFO, + PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_HELP : (WidgetID)WID_TN_HELP, {STR_ABOUT_MENU_LAND_BLOCK_INFO, STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG, STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD, STR_ABOUT_MENU_SPRITE_ALIGNER, STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES, STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS, STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES}); } else { - PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (int)WID_TE_HELP : (int)WID_TN_HELP, {STR_ABOUT_MENU_LAND_BLOCK_INFO, + PopupMainToolbarMenu(w, _game_mode == GM_EDITOR ? (WidgetID)WID_TE_HELP : (WidgetID)WID_TN_HELP, {STR_ABOUT_MENU_LAND_BLOCK_INFO, STR_ABOUT_MENU_HELP, STR_NULL, STR_ABOUT_MENU_TOGGLE_CONSOLE, STR_ABOUT_MENU_AI_DEBUG, STR_ABOUT_MENU_SCREENSHOT, STR_ABOUT_MENU_SHOW_FRAMERATE, STR_ABOUT_MENU_ABOUT_OPENTTD}); } @@ -1143,7 +1143,7 @@ static CallBackFunction ToolbarSwitchCli } w->ReInit(); - w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (uint)WID_TE_SWITCH_BAR : (uint)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER); + w->SetWidgetLoweredState(_game_mode == GM_EDITOR ? (WidgetID)WID_TE_SWITCH_BAR : (WidgetID)WID_TN_SWITCH_BAR, _toolbar_mode == TB_LOWER); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); return CBF_NONE; } @@ -1379,7 +1379,7 @@ public: /* Figure out what are the visible buttons */ uint arrangable_count, button_count, spacer_count; - const byte *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count); + const WidgetID *arrangement = GetButtonArrangement(given_width, arrangable_count, button_count, spacer_count); /* Create us ourselves a quick lookup table */ NWidgetBase *widgets[WID_TN_END]; @@ -1397,7 +1397,7 @@ public: uint button_i = 0; /* Index into the arrangement indices. The macro lastof cannot be used here! */ - const byte *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement; + const WidgetID *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement; for (uint i = 0; i < arrangable_count; i++) { NWidgetBase *child_wid = widgets[*cur_wid]; /* If we have to give space to the spacers, do that */ @@ -1448,12 +1448,12 @@ public: * @param spacer_count output of the number of spacers. * @return the button configuration. */ - virtual const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const = 0; + virtual const WidgetID *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const = 0; }; /** Container for the 'normal' main toolbar */ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer { - const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override + const WidgetID *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override { static const uint SMALLEST_ARRANGEMENT = 14; static const uint BIGGEST_ARRANGEMENT = 20; @@ -1464,7 +1464,7 @@ class NWidgetMainToolbarContainer : publ * pause button appearing on the right of the lower toolbar and weird resizing of the widgets even if there is * enough space. */ - static const byte arrange14[] = { + static const WidgetID arrange14[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_TRAINS, @@ -1495,7 +1495,7 @@ class NWidgetMainToolbarContainer : publ WID_TN_HELP, WID_TN_SWITCH_BAR, }; - static const byte arrange15[] = { + static const WidgetID arrange15[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SMALL_MAP, @@ -1528,7 +1528,7 @@ class NWidgetMainToolbarContainer : publ WID_TN_HELP, WID_TN_SWITCH_BAR, }; - static const byte arrange16[] = { + static const WidgetID arrange16[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1563,7 +1563,7 @@ class NWidgetMainToolbarContainer : publ WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange17[] = { + static const WidgetID arrange17[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1600,7 +1600,7 @@ class NWidgetMainToolbarContainer : publ WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange18[] = { + static const WidgetID arrange18[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1639,7 +1639,7 @@ class NWidgetMainToolbarContainer : publ WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange19[] = { + static const WidgetID arrange19[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1680,7 +1680,7 @@ class NWidgetMainToolbarContainer : publ WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange20[] = { + static const WidgetID arrange20[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1723,7 +1723,7 @@ class NWidgetMainToolbarContainer : publ WID_TN_ZOOM_OUT, WID_TN_SWITCH_BAR, }; - static const byte arrange_all[] = { + static const WidgetID arrange_all[] = { WID_TN_PAUSE, WID_TN_FAST_FORWARD, WID_TN_SETTINGS, @@ -1765,7 +1765,7 @@ class NWidgetMainToolbarContainer : publ } /* Introduce the split toolbar */ - static const byte * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 }; + static const WidgetID * const arrangements[] = { arrange14, arrange15, arrange16, arrange17, arrange18, arrange19, arrange20 }; button_count = arrangable_count = full_buttons; spacer_count = this->spacers; @@ -1792,9 +1792,9 @@ class NWidgetScenarioToolbarContainer : } } - const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override + const WidgetID *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const override { - static const byte arrange_all[] = { + static const WidgetID arrange_all[] = { WID_TE_PAUSE, WID_TE_FAST_FORWARD, WID_TE_SETTINGS, @@ -1815,7 +1815,7 @@ class NWidgetScenarioToolbarContainer : WID_TE_MUSIC_SOUND, WID_TE_HELP, }; - static const byte arrange_nopanel[] = { + static const WidgetID arrange_nopanel[] = { WID_TE_PAUSE, WID_TE_FAST_FORWARD, WID_TE_SETTINGS, @@ -1835,7 +1835,7 @@ class NWidgetScenarioToolbarContainer : WID_TE_MUSIC_SOUND, WID_TE_HELP, }; - static const byte arrange_switch[] = { + static const WidgetID arrange_switch[] = { WID_TE_DATE_PANEL, WID_TE_SMALL_MAP, WID_TE_LAND_GENERATE, @@ -1962,12 +1962,12 @@ struct MainToolbarWindow : Window { this->DrawWidgets(); } - 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 { if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this); } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { CallBackFunction cbf = _menu_clicked_procs[widget](index); if (cbf != CBF_NONE) _last_started_action = cbf; @@ -2060,7 +2060,7 @@ struct MainToolbarWindow : Window { { /* We do not want to automatically raise the pause, fast forward and * switchbar buttons; they have to stay down when pressed etc. */ - for (uint i = WID_TN_SETTINGS; i < WID_TN_SWITCH_BAR; i++) { + for (WidgetID i = WID_TN_SETTINGS; i < WID_TN_SWITCH_BAR; i++) { this->RaiseWidgetWhenLowered(i); } } @@ -2158,7 +2158,7 @@ static NWidgetBase *MakeMainToolbar() }; NWidgetMainToolbarContainer *hor = new NWidgetMainToolbarContainer(); - for (uint i = 0; i < WID_TN_END; i++) { + for (WidgetID i = 0; i < WID_TN_END; i++) { switch (i) { case WID_TN_SMALL_MAP: case WID_TN_FINANCES: @@ -2296,7 +2296,7 @@ struct ScenarioEditorToolbarWindow : Win this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_TE_DATE: @@ -2305,7 +2305,7 @@ struct ScenarioEditorToolbarWindow : Win } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TE_SPACER: { @@ -2321,7 +2321,7 @@ struct ScenarioEditorToolbarWindow : Win } } - 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 { switch (widget) { case WID_TE_SPACER: @@ -2335,14 +2335,14 @@ struct ScenarioEditorToolbarWindow : Win } } - 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 { if (_game_mode == GM_MENU) return; CallBackFunction cbf = _scen_toolbar_button_procs[widget](this); if (cbf != CBF_NONE) _last_started_action = cbf; } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { CallBackFunction cbf = _scen_toolbar_dropdown_procs[widget](index); if (cbf != CBF_NONE) _last_started_action = cbf; diff --git a/src/town_gui.cpp b/src/town_gui.cpp --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -222,12 +222,12 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TA_CAPTION) SetDParam(0, this->window_number); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TA_ACTION_INFO: @@ -244,7 +244,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 { switch (widget) { case WID_TA_ACTION_INFO: { @@ -276,7 +276,7 @@ public: } } - 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_TA_ZONE_BUTTON: { @@ -371,7 +371,7 @@ public: this->Window::Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_TV_CAPTION) SetDParam(0, this->town->index); } @@ -384,7 +384,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_TV_INFO) return; @@ -476,7 +476,7 @@ public: } } - 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_TV_CENTER_VIEW: // scroll to location @@ -511,7 +511,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 { switch (widget) { case WID_TV_INFO: @@ -796,7 +796,7 @@ public: this->townname_editbox.cancel_button = QueryString::ACTION_CLEAR; } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_TD_WORLD_POPULATION: @@ -819,7 +819,7 @@ public: return t->larger_town ? STR_TOWN_DIRECTORY_CITY : STR_TOWN_DIRECTORY_TOWN; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TD_SORT_ORDER: @@ -866,7 +866,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 { switch (widget) { case WID_TD_SORT_ORDER: { @@ -918,7 +918,7 @@ public: } } - 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_TD_SORT_ORDER: // Click on sort order button @@ -955,7 +955,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { if (widget != WID_TD_SORT_CRITERIA) return; @@ -983,7 +983,7 @@ public: this->vscroll->SetCapacityFromWidget(this, WID_TD_LIST); } - void OnEditboxChanged(int wid) override + void OnEditboxChanged(WidgetID wid) override { if (wid == WID_TD_FILTER) { this->string_filter.SetFilterTerm(this->townname_editbox.text.buf); @@ -1174,13 +1174,13 @@ public: if (_settings_game.economy.found_town != TF_CUSTOM_LAYOUT) town_layout = _settings_game.economy.town_layout; } - for (int i = WID_TF_SIZE_SMALL; i <= WID_TF_SIZE_RANDOM; i++) { + for (WidgetID i = WID_TF_SIZE_SMALL; i <= WID_TF_SIZE_RANDOM; i++) { this->SetWidgetLoweredState(i, i == WID_TF_SIZE_SMALL + this->town_size); } this->SetWidgetLoweredState(WID_TF_CITY, this->city); - for (int i = WID_TF_LAYOUT_ORIGINAL; i <= WID_TF_LAYOUT_RANDOM; i++) { + for (WidgetID i = WID_TF_LAYOUT_ORIGINAL; i <= WID_TF_LAYOUT_RANDOM; i++) { this->SetWidgetLoweredState(i, i == WID_TF_LAYOUT_ORIGINAL + this->town_layout); } @@ -1207,7 +1207,7 @@ public: if (success && !_shift_pressed) this->RandomTownName(); } - 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_TF_NEW_TOWN: diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -39,7 +39,7 @@ public: this->DrawWidgets(); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_TT_SIGNS: @@ -51,13 +51,13 @@ public: case WID_TT_STRUCTURES: case WID_TT_CATENARY: case WID_TT_TEXT: { - uint i = widget - WID_TT_BEGIN; + int i = widget - WID_TT_BEGIN; if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, r.left + WidgetDimensions::scaled.fullbevel.left, r.top + WidgetDimensions::scaled.fullbevel.top); break; } case WID_TT_BUTTONS: { const Rect fr = r.Shrink(WidgetDimensions::scaled.framerect); - for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) { + for (WidgetID i = WID_TT_BEGIN; i < WID_TT_END; i++) { if (i == WID_TT_TEXT) continue; // Loading and cost/income text has no invisibility button. const Rect wr = this->GetWidget(i)->GetCurrentRect().Shrink(WidgetDimensions::scaled.fullbevel); @@ -69,7 +69,7 @@ public: } } - 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 { if (widget >= WID_TT_BEGIN && widget < WID_TT_END) { if (_ctrl_pressed) { @@ -119,7 +119,7 @@ public: void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override { if (!gui_scope) return; - for (uint i = WID_TT_BEGIN; i < WID_TT_END; i++) { + for (WidgetID i = WID_TT_BEGIN; i < WID_TT_END; i++) { this->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - WID_TT_BEGIN))); } } diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -152,7 +152,7 @@ public: this->FinishInitNested(window_number); } - 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_BT_TYPE_BUTTON_FIRST) { /* Ensure tree type buttons are sized after the largest tree type */ @@ -162,7 +162,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget >= WID_BT_TYPE_BUTTON_FIRST) { const int index = widget - WID_BT_TYPE_BUTTON_FIRST; @@ -171,7 +171,7 @@ public: } } - 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_BT_TYPE_RANDOM: // tree of random type. diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -868,7 +868,7 @@ struct RefitWindow : public Window { this->DrawWidgets(); } - 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 { switch (widget) { case WID_VR_MATRIX: @@ -886,7 +886,7 @@ struct RefitWindow : public Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_VR_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index); } @@ -936,7 +936,7 @@ struct RefitWindow : public Window { } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { @@ -1131,7 +1131,7 @@ struct RefitWindow : 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_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image. @@ -1173,7 +1173,7 @@ struct RefitWindow : public Window { } } - void OnMouseDrag(Point pt, int widget) override + void OnMouseDrag(Point pt, WidgetID widget) override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image. @@ -1186,7 +1186,7 @@ struct RefitWindow : public Window { } } - void OnDragDrop(Point pt, int widget) override + void OnDragDrop(Point pt, WidgetID widget) override { switch (widget) { case WID_VR_VEHICLE_PANEL_DISPLAY: { // Vehicle image. @@ -1853,7 +1853,7 @@ public: *this->sorting = this->vehgroups.GetListing(); } - 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 { switch (widget) { case WID_VL_LIST: @@ -1904,7 +1904,7 @@ public: } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_VL_AVAILABLE_VEHICLES: @@ -1947,7 +1947,7 @@ public: } } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { switch (widget) { case WID_VL_SORT_ORDER: @@ -1997,7 +1997,7 @@ public: this->DrawWidgets(); } - 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_VL_ORDER_VIEW: // Open the shared orders window @@ -2081,7 +2081,7 @@ public: } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_VL_GROUP_BY_PULLDOWN: @@ -2367,7 +2367,7 @@ struct VehicleDetailsWindow : Window { return desired_height; } - 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 { switch (widget) { case WID_VD_TOP_DETAILS: { @@ -2474,12 +2474,12 @@ struct VehicleDetailsWindow : Window { } } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_VD_CAPTION) SetDParam(0, Vehicle::Get(this->window_number)->index); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { const Vehicle *v = Vehicle::Get(this->window_number); @@ -2604,7 +2604,7 @@ struct VehicleDetailsWindow : Window { this->DrawWidgets(); } - 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_VD_INCREASE_SERVICING_INTERVAL: // increase int @@ -2642,7 +2642,7 @@ struct VehicleDetailsWindow : Window { } } - void OnDropdownSelect(int widget, int index) override + void OnDropdownSelect(WidgetID widget, int index) override { switch (widget) { case WID_VD_SERVICE_INTERVAL_DROPDOWN: { @@ -2927,7 +2927,7 @@ public: this->Window::Close(); } - 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 { const Vehicle *v = Vehicle::Get(this->window_number); switch (widget) { @@ -2974,7 +2974,7 @@ public: this->DrawWidgets(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget != WID_VV_CAPTION) return; @@ -2982,7 +2982,7 @@ public: SetDParam(0, v->index); } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_VV_START_STOP) return; @@ -3087,7 +3087,7 @@ public: DrawString(tr.left, tr.right, CenterBounds(tr.top, tr.bottom, GetCharacterHeight(FS_NORMAL)), str, text_colour, SA_HOR_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 { const Vehicle *v = Vehicle::Get(this->window_number); @@ -3195,7 +3195,7 @@ public: Command::Post(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type, this->window_number, str); } - void OnMouseOver([[maybe_unused]] Point pt, int widget) override + void OnMouseOver([[maybe_unused]] Point pt, WidgetID widget) override { bool start_stop = widget == WID_VV_START_STOP; if (start_stop != mouse_over_start_stop) { diff --git a/src/viewport.cpp b/src/viewport.cpp --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -488,7 +488,7 @@ Point GetTileZoomCenterWindow(bool in, W * @param widget_zoom_in widget index for window with zoom-in button * @param widget_zoom_out widget index for window with zoom-out button */ -void HandleZoomMessage(Window *w, const Viewport *vp, byte widget_zoom_in, byte widget_zoom_out) +void HandleZoomMessage(Window *w, const Viewport *vp, WidgetID widget_zoom_in, WidgetID widget_zoom_out) { w->SetWidgetDisabledState(widget_zoom_in, vp->zoom <= _settings_client.gui.zoom_min); w->SetWidgetDirty(widget_zoom_in); diff --git a/src/viewport_func.h b/src/viewport_func.h --- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -35,7 +35,7 @@ void ZoomInOrOutToCursorWindow(bool in, void ConstrainAllViewportsZoom(); Point GetTileZoomCenterWindow(bool in, Window * w); void FixTitleGameZoom(int zoom_adjust = 0); -void HandleZoomMessage(Window *w, const Viewport *vp, byte widget_zoom_in, byte widget_zoom_out); +void HandleZoomMessage(Window *w, const Viewport *vp, WidgetID widget_zoom_in, WidgetID widget_zoom_out); /** * Zoom a viewport as far as possible in the given direction. diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -61,7 +61,7 @@ public: if (_settings_client.gui.zoom_min == viewport->zoom) this->DisableWidget(WID_EV_ZOOM_IN); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { switch (widget) { case WID_EV_CAPTION: @@ -71,7 +71,7 @@ public: } } - 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_EV_ZOOM_IN: DoZoomInOutWindow(ZOOM_IN, this); break; @@ -117,7 +117,7 @@ public: this->viewport->dest_scrollpos_y = this->viewport->scrollpos_y; } - bool OnRightClick([[maybe_unused]] Point pt, int widget) override + bool OnRightClick([[maybe_unused]] Point pt, WidgetID widget) override { return widget == WID_EV_VIEWPORT; } diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -83,7 +83,7 @@ public: this->Window::Close(); } - void SetStringParameters(int widget) const override + void SetStringParameters(WidgetID widget) const override { if (widget == WID_W_CAPTION) SetDParam(0, this->wp->index); } @@ -97,7 +97,7 @@ public: this->DrawWidgets(); } - 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_W_CENTER_VIEW: // scroll to location diff --git a/src/widget.cpp b/src/widget.cpp --- a/src/widget.cpp +++ b/src/widget.cpp @@ -402,7 +402,7 @@ void ScrollbarClickHandler(Window *w, NW * @param y The Window client y coordinate * @return A widget index, or -1 if no widget was found. */ -int GetWidgetFromPos(const Window *w, int x, int y) +WidgetID GetWidgetFromPos(const Window *w, int x, int y) { NWidgetCore *nw = w->nested_root->GetWidgetFromPos(x, y); return (nw != nullptr) ? nw->index : -1; @@ -899,7 +899,7 @@ void Window::DrawWidgets() const * @param widget Sort button widget * @param state State of sort button */ -void Window::DrawSortButtonState(int widget, SortButtonState state) const +void Window::DrawSortButtonState(WidgetID widget, SortButtonState state) const { if (state == SBS_OFF) return; @@ -1229,7 +1229,7 @@ NWidgetCore::NWidgetCore(WidgetType tp, * Set index of the nested widget in the widget array. * @param index Index to use. */ -void NWidgetCore::SetIndex(int index) +void NWidgetCore::SetIndex(WidgetID index) { assert(index >= 0); this->index = index; @@ -1379,7 +1379,7 @@ NWidgetStacked::NWidgetStacked() : NWidg this->index = -1; } -void NWidgetStacked::SetIndex(int index) +void NWidgetStacked::SetIndex(WidgetID index) { this->index = index; } @@ -1954,7 +1954,7 @@ NWidgetMatrix::NWidgetMatrix() : NWidget { } -void NWidgetMatrix::SetIndex(int index) +void NWidgetMatrix::SetIndex(WidgetID index) { this->index = index; } @@ -2189,7 +2189,7 @@ void NWidgetMatrix::GetScrollOffsets(int * vertical container will be inserted while adding the first * child widget. */ -NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL) +NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, NWidgetPIPContainer *child) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL) { assert(tp == WWT_PANEL || tp == WWT_INSET || tp == WWT_FRAME); if (index >= 0) this->SetIndex(index); @@ -2397,7 +2397,7 @@ NWidgetBase *NWidgetBackground::GetWidge return nwid; } -NWidgetViewport::NWidgetViewport(int index) : NWidgetCore(NWID_VIEWPORT, INVALID_COLOUR, 1, 1, 0x0, STR_NULL) +NWidgetViewport::NWidgetViewport(WidgetID index) : NWidgetCore(NWID_VIEWPORT, INVALID_COLOUR, 1, 1, 0x0, STR_NULL) { this->SetIndex(index); } @@ -2467,7 +2467,7 @@ void NWidgetViewport::UpdateViewportCoor * @param line_height Height of a single row. A negative value means using the vertical resize step of the widget. * @return Row number clicked at. If clicked at a wrong position, #INT_MAX is returned. */ -int Scrollbar::GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding, int line_height) const +int Scrollbar::GetScrolledRowFromWidget(int clickpos, const Window * const w, WidgetID widget, int padding, int line_height) const { uint pos = w->GetRowFromWidget(clickpos, widget, padding, line_height); if (pos != INT_MAX) pos += this->GetPosition(); @@ -2541,7 +2541,7 @@ EventState Scrollbar::UpdateListPosition * @param padding Padding to subtract from the size. * @note Updates the position if needed. */ -void Scrollbar::SetCapacityFromWidget(Window *w, int widget, int padding) +void Scrollbar::SetCapacityFromWidget(Window *w, WidgetID widget, int padding) { NWidgetBase *nwid = w->GetWidget(widget); if (this->IsVertical()) { @@ -2557,7 +2557,7 @@ void Scrollbar::SetCapacityFromWidget(Wi * @param colour Colour of the scrollbar. * @param index Index of the widget. */ -NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, int index) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL), Scrollbar(tp != NWID_HSCROLLBAR) +NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, WidgetID index) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL), Scrollbar(tp != NWID_HSCROLLBAR) { assert(tp == NWID_HSCROLLBAR || tp == NWID_VSCROLLBAR); this->SetIndex(index); @@ -2683,7 +2683,7 @@ Dimension NWidgetLeaf::dropdown_dimensio * @param data Data of the widget. * @param tip Tooltip of the widget. */ -NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32_t data, StringID tip) : NWidgetCore(tp, colour, 1, 1, data, tip) +NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, WidgetID index, uint32_t data, StringID tip) : NWidgetCore(tp, colour, 1, 1, data, tip) { assert(index >= 0 || tp == WWT_LABEL || tp == WWT_TEXT || tp == WWT_CAPTION || tp == WWT_RESIZEBOX || tp == WWT_SHADEBOX || tp == WWT_DEFSIZEBOX || tp == WWT_DEBUGBOX || tp == WWT_STICKYBOX || tp == WWT_CLOSEBOX); if (index >= 0) this->SetIndex(index); @@ -3416,7 +3416,7 @@ NWidgetContainer *MakeWindowNWidgetTree( * @param button_tooltip The tooltip-string of every button. * @return Panel with rows of company buttons. */ -NWidgetBase *MakeCompanyButtonRows(int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip) +NWidgetBase *MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip) { assert(max_length >= 1); NWidgetVertical *vert = nullptr; // Storage for all rows. @@ -3427,7 +3427,7 @@ NWidgetBase *MakeCompanyButtonRows(int w sprite_size.width += WidgetDimensions::unscaled.matrix.Horizontal(); sprite_size.height += WidgetDimensions::unscaled.matrix.Vertical() + 1; // 1 for the 'offset' of being pressed - for (int widnum = widget_first; widnum <= widget_last; widnum++) { + for (WidgetID widnum = widget_first; widnum <= widget_last; widnum++) { /* Ensure there is room in 'hor' for another button. */ if (hor_length == max_length) { if (vert == nullptr) vert = new NWidgetVertical(); diff --git a/src/widget_type.h b/src/widget_type.h --- a/src/widget_type.h +++ b/src/widget_type.h @@ -123,7 +123,7 @@ class NWidgetCore; class Scrollbar; /** Lookup between widget IDs and NWidget objects. */ -using WidgetLookup = std::map; +using WidgetLookup = std::map; /** * Baseclass for nested widgets. @@ -329,7 +329,7 @@ class NWidgetCore : public NWidgetResize public: NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32_t widget_data, StringID tool_tip); - void SetIndex(int index); + void SetIndex(WidgetID index); void SetDataTip(uint32_t widget_data, StringID tool_tip); void SetToolTip(StringID tool_tip); void SetTextStyle(TextColour colour, FontSize size); @@ -348,10 +348,10 @@ public: NWidgetDisplay disp_flags; ///< Flags that affect display and interaction with the widget. Colours colour; ///< Colour of this widget. - int index; ///< Index of the nested widget (\c -1 means 'not used'). + WidgetID index; ///< Index of the nested widget (\c -1 means 'not used'). uint32_t widget_data; ///< Data of the widget. @see Widget::data StringID tool_tip; ///< Tooltip of the widget. @see Widget::tootips - int scrollbar_index; ///< Index of an attached scrollbar. + WidgetID scrollbar_index; ///< Index of an attached scrollbar. TextColour highlight_colour; ///< Colour of highlight. TextColour text_colour; ///< Colour of text within widget. FontSize text_size; ///< Size of text within widget. @@ -460,7 +460,7 @@ class NWidgetStacked : public NWidgetCon public: NWidgetStacked(); - void SetIndex(int index); + void SetIndex(WidgetID index); void AdjustPaddingForZoom() override; void SetupSmallestSize(Window *w) override; @@ -473,7 +473,7 @@ public: bool SetDisplayedPlane(int plane); int shown_plane; ///< Plane being displayed (for #NWID_SELECTION only). - int index; ///< If non-negative, index in the #Window::widget_lookup. + WidgetID index; ///< If non-negative, index in the #Window::widget_lookup. }; /** Nested widget container flags, */ @@ -559,7 +559,7 @@ class NWidgetMatrix : public NWidgetPIPC public: NWidgetMatrix(); - void SetIndex(int index); + void SetIndex(WidgetID index); void SetColour(Colours colour); void SetClicked(int clicked); void SetCount(int count); @@ -572,7 +572,7 @@ public: NWidgetCore *GetWidgetFromPos(int x, int y) override; void Draw(const Window *w) override; protected: - int index; ///< If non-negative, index in the #Window::widget_lookup. + WidgetID index; ///< If non-negative, index in the #Window::widget_lookup. Colours colour; ///< Colour of this widget. int clicked; ///< The currently clicked widget. int count; ///< Amount of valid widgets. @@ -609,7 +609,7 @@ public: */ class NWidgetBackground : public NWidgetCore { public: - NWidgetBackground(WidgetType tp, Colours colour, int index, NWidgetPIPContainer *child = nullptr); + NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, NWidgetPIPContainer *child = nullptr); ~NWidgetBackground(); void Add(NWidgetBase *nwid); @@ -641,7 +641,7 @@ private: */ class NWidgetViewport : public NWidgetCore { public: - NWidgetViewport(int index); + NWidgetViewport(WidgetID index); void SetupSmallestSize(Window *w) override; void Draw(const Window *w) override; @@ -758,7 +758,7 @@ public: this->SetPosition(this->pos); } - void SetCapacityFromWidget(Window *w, int widget, int padding = 0); + void SetCapacityFromWidget(Window *w, WidgetID widget, int padding = 0); /** * Sets the position of the first visible element @@ -807,7 +807,7 @@ public: } } - int GetScrolledRowFromWidget(int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const; + int GetScrolledRowFromWidget(int clickpos, const Window * const w, WidgetID widget, int padding = 0, int line_height = -1) const; /** * Return an iterator pointing to the element of a scrolled widget that a user clicked in. @@ -820,7 +820,7 @@ public: * @return Iterator to the element clicked at. If clicked at a wrong position, returns as interator to the end of the container. */ template - typename Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window * const w, int widget, int padding = 0, int line_height = -1) const + typename Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window * const w, WidgetID widget, int padding = 0, int line_height = -1) const { assert(this->GetCount() == container.size()); // Scrollbar and container size must match. int row = this->GetScrolledRowFromWidget(clickpos, w, widget, padding, line_height); @@ -841,7 +841,7 @@ public: */ class NWidgetScrollbar : public NWidgetCore, public Scrollbar { public: - NWidgetScrollbar(WidgetType tp, Colours colour, int index); + NWidgetScrollbar(WidgetType tp, Colours colour, WidgetID index); void SetupSmallestSize(Window *w) override; void Draw(const Window *w) override; @@ -861,7 +861,7 @@ private: */ class NWidgetLeaf : public NWidgetCore { public: - NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32_t data, StringID tip); + NWidgetLeaf(WidgetType tp, Colours colour, WidgetID index, uint32_t data, StringID tip); void SetupSmallestSize(Window *w) override; void Draw(const Window *w) override; @@ -958,7 +958,7 @@ struct NWidgetPartDataTip { */ struct NWidgetPartWidget { Colours colour; ///< Widget colour. - int16_t index; ///< Index of the widget. + WidgetID index; ///< Index of the widget. }; /** @@ -1269,7 +1269,7 @@ static inline NWidgetPart SetPIPRatio(ui * @param index Widget index of the scrollbar. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetScrollbar(int index) +static inline NWidgetPart SetScrollbar(WidgetID index) { NWidgetPart part; @@ -1288,7 +1288,7 @@ static inline NWidgetPart SetScrollbar(i * Child widgets must have a index bigger than the parent index. * @ingroup NestedWidgetParts */ -static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16_t idx = -1) +static inline NWidgetPart NWidget(WidgetType tp, Colours col, int idx = -1) { NWidgetPart part; @@ -1334,7 +1334,7 @@ bool IsContainerWidgetType(WidgetType tp NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetContainer *container); NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetStacked **shade_select); -NWidgetBase *MakeCompanyButtonRows(int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip); +NWidgetBase *MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip); void SetupWidgetDimensions(); diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -40,7 +40,7 @@ static WindowDesc _dropdown_desc(__FILE_ /** Drop-down menu window */ struct DropdownWindow : Window { - int parent_button; ///< Parent widget number where the window is dropped from. + WidgetID parent_button; ///< Parent widget number where the window is dropped from. Rect wi_rect; ///< Rect of the button that opened the dropdown. const DropDownList list; ///< List with dropdown menu items. int selected_result; ///< Result value of the selected item in the list. @@ -63,7 +63,7 @@ struct DropdownWindow : Window { * @param instant_close Close the window when the mouse button is raised. * @param wi_colour Colour of the parent widget. */ - DropdownWindow(Window *parent, DropDownList &&list, int selected, int button, const Rect wi_rect, bool instant_close, Colours wi_colour) + DropdownWindow(Window *parent, DropDownList &&list, int selected, WidgetID button, const Rect wi_rect, bool instant_close, Colours wi_colour) : Window(&_dropdown_desc) , parent_button(button) , wi_rect(wi_rect) @@ -172,7 +172,7 @@ struct DropdownWindow : Window { if (this->position.y < button_rect.top && list_dim.height > widget_dim.height) this->vscroll->UpdatePosition(INT_MAX); } - 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_DM_ITEMS) *size = this->items_dim; } @@ -213,7 +213,7 @@ struct DropdownWindow : Window { return false; } - void DrawWidget(const Rect &r, int widget) const override + void DrawWidget(const Rect &r, WidgetID widget) const override { if (widget != WID_DM_ITEMS) return; @@ -240,7 +240,7 @@ struct DropdownWindow : 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 { if (widget != WID_DM_ITEMS) return; int item; @@ -329,7 +329,7 @@ Dimension GetDropDownListDimension(const * @param instant_close Set to true if releasing mouse button should close the * list regardless of where the cursor is. */ -void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool instant_close) +void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, bool instant_close) { CloseWindowByClass(WC_DROPDOWN_MENU); new DropdownWindow(w, std::move(list), selected, button, wi_rect, instant_close, wi_colour); @@ -346,7 +346,7 @@ void ShowDropDownListAt(Window *w, DropD * @param instant_close Set to true if releasing mouse button should close the * list regardless of where the cursor is. */ -void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool instant_close) +void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close) { /* Our parent's button widget is used to determine where to place the drop * down list window. */ @@ -383,7 +383,7 @@ void ShowDropDownList(Window *w, DropDow * @param hidden_mask Bitmask for hidden items (items with their bit set are not copied to the dropdown list). * @param width Minimum width of the dropdown menu. */ -void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32_t disabled_mask, uint32_t hidden_mask, uint width) +void ShowDropDownMenu(Window *w, const StringID *strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width) { DropDownList list; diff --git a/src/widgets/dropdown_func.h b/src/widgets/dropdown_func.h --- a/src/widgets/dropdown_func.h +++ b/src/widgets/dropdown_func.h @@ -13,6 +13,6 @@ #include "../window_gui.h" /* Show drop down menu containing a fixed list of strings */ -void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32_t disabled_mask, uint32_t hidden_mask, uint width = 0); +void ShowDropDownMenu(Window *w, const StringID *strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width = 0); #endif /* WIDGETS_DROPDOWN_FUNC_H */ diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h --- a/src/widgets/dropdown_type.h +++ b/src/widgets/dropdown_type.h @@ -209,9 +209,9 @@ using DropDownListCheckedItem = DropDown */ typedef std::vector> DropDownList; -void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button, Rect wi_rect, Colours wi_colour, bool instant_close = false); +void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, bool instant_close = false); -void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width = 0, bool instant_close = false); +void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width = 0, bool instant_close = false); Dimension GetDropDownListDimension(const DropDownList &list); diff --git a/src/window.cpp b/src/window.cpp --- a/src/window.cpp +++ b/src/window.cpp @@ -211,7 +211,7 @@ void Window::ApplyDefaults() * @return Row number clicked at. If clicked at a wrong position, #INT_MAX is returned. * @note The widget does not know where a list printed at the widget ends, so below a list is not a wrong position. */ -int Window::GetRowFromWidget(int clickpos, int widget, int padding, int line_height) const +int Window::GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height) const { const NWidgetBase *wid = this->GetWidget(widget); if (line_height < 0) line_height = wid->resize_y; @@ -240,7 +240,7 @@ void Window::DisableAllWidgetHighlight() * @param widget_index index of this widget in the window * @param highlighted_colour Colour of highlight, or TC_INVALID to disable. */ -void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour) +void Window::SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_colour) { NWidgetBase *nwid = this->GetWidget(widget_index); if (nwid == nullptr) return; @@ -270,7 +270,7 @@ void Window::SetWidgetHighlight(byte wid * @param widget_index index of this widget in the window * @return status of the widget ie: highlighted = true, not highlighted = false */ -bool Window::IsWidgetHighlighted(byte widget_index) const +bool Window::IsWidgetHighlighted(WidgetID widget_index) const { const NWidgetBase *nwid = this->GetWidget(widget_index); if (nwid == nullptr) return false; @@ -285,7 +285,7 @@ bool Window::IsWidgetHighlighted(byte wi * @param index the element in the dropdown that is selected. * @param instant_close whether the dropdown was configured to close on mouse up. */ -void Window::OnDropdownClose(Point pt, int widget, int index, bool instant_close) +void Window::OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close) { if (widget < 0) return; @@ -312,7 +312,7 @@ void Window::OnDropdownClose(Point pt, i * @param widnum Scrollbar widget index * @return Scrollbar to the widget */ -const Scrollbar *Window::GetScrollbar(uint widnum) const +const Scrollbar *Window::GetScrollbar(WidgetID widnum) const { return this->GetWidget(widnum); } @@ -322,7 +322,7 @@ const Scrollbar *Window::GetScrollbar(ui * @param widnum Scrollbar widget index * @return Scrollbar to the widget */ -Scrollbar *Window::GetScrollbar(uint widnum) +Scrollbar *Window::GetScrollbar(WidgetID widnum) { return this->GetWidget(widnum); } @@ -332,7 +332,7 @@ Scrollbar *Window::GetScrollbar(uint wid * @param widnum Editbox widget index * @return QueryString or nullptr. */ -const QueryString *Window::GetQueryString(uint widnum) const +const QueryString *Window::GetQueryString(WidgetID widnum) const { auto query = this->querystrings.find(widnum); return query != this->querystrings.end() ? query->second : nullptr; @@ -343,7 +343,7 @@ const QueryString *Window::GetQueryStrin * @param widnum Editbox widget index * @return QueryString or nullptr. */ -QueryString *Window::GetQueryString(uint widnum) +QueryString *Window::GetQueryString(WidgetID widnum) { auto query = this->querystrings.find(widnum); return query != this->querystrings.end() ? query->second : nullptr; @@ -484,7 +484,7 @@ void Window::UnfocusFocusedWidget() * @param widget_index Index of the widget in the window to set the focus to. * @return Focus has changed. */ -bool Window::SetFocusedWidget(int widget_index) +bool Window::SetFocusedWidget(WidgetID widget_index) { NWidgetCore *widget = this->GetWidget(widget_index); assert(widget != nullptr); /* Setting focus to a non-existing widget is a bad idea. */ @@ -549,7 +549,7 @@ void Window::RaiseButtons(bool autoraise * Invalidate a widget, i.e. mark it as being changed and in need of redraw. * @param widget_index the widget to redraw. */ -void Window::SetWidgetDirty(byte widget_index) const +void Window::SetWidgetDirty(WidgetID widget_index) const { /* Sometimes this function is called before the window is even fully initialized */ auto it = this->widget_lookup.find(widget_index); @@ -588,7 +588,7 @@ EventState Window::OnHotkey(int hotkey) * unclicked in a few ticks. * @param widget the widget to "click" */ -void Window::HandleButtonClick(byte widget) +void Window::HandleButtonClick(WidgetID widget) { this->LowerWidget(widget); this->SetTimeout(); @@ -627,7 +627,7 @@ static void DispatchLeftClickEvent(Windo /* don't allow any interaction if the button has been disabled */ if (nw->IsDisabled()) return; - int widget_index = nw->index; ///< Index of the widget + WidgetID widget_index = nw->index; ///< Index of the widget /* Clicked on a widget that is not disabled. * So unless the clicked widget is the caption bar, change focus to this widget. @@ -2472,7 +2472,7 @@ static bool MaybeBringWindowToFront(Wind * @return #ES_HANDLED if the key press has been handled and no other * window should receive the event. */ -EventState Window::HandleEditBoxKey(int wid, char32_t key, uint16_t keycode) +EventState Window::HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode) { QueryString *query = this->GetQueryString(wid); if (query == nullptr) return ES_NOT_HANDLED; @@ -2630,7 +2630,7 @@ void HandleCtrlChanged() * @param wid Edit box widget. * @param str Text string to insert. */ -/* virtual */ void Window::InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) +/* virtual */ void Window::InsertTextString(WidgetID wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) { QueryString *query = this->GetQueryString(wid); if (query == nullptr) return; @@ -3092,7 +3092,7 @@ void SetWindowDirty(WindowClass cls, Win * @param number Window number in that class * @param widget_index Index number of the widget that needs repainting */ -void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index) +void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index) { for (const Window *w : Window::Iterate()) { if (w->window_class == cls && w->window_number == number) { diff --git a/src/window_func.h b/src/window_func.h --- a/src/window_func.h +++ b/src/window_func.h @@ -63,7 +63,7 @@ void ShowVitalWindows(); */ void ReInitAllWindows(bool zoom_changed); -void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_index); +void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, WidgetID widget_index); void SetWindowDirty(WindowClass cls, WindowNumber number); void SetWindowClassesDirty(WindowClass cls); diff --git a/src/window_gui.h b/src/window_gui.h --- a/src/window_gui.h +++ b/src/window_gui.h @@ -264,21 +264,21 @@ public: NWidgetStacked *shade_select; ///< Selection widget (#NWID_SELECTION) to use for shading the window. If \c nullptr, window cannot shade. Dimension unshaded_size; ///< Last known unshaded size (only valid while shaded). - int mouse_capture_widget; ///< Widgetindex of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture. + WidgetID mouse_capture_widget; ///< ID of current mouse capture widget (e.g. dragged scrollbar). -1 if no widget has mouse capture. Window *parent; ///< Parent window. WindowList::iterator z_position; template - inline const NWID *GetWidget(uint widnum) const; + inline const NWID *GetWidget(WidgetID widnum) const; template - inline NWID *GetWidget(uint widnum); + inline NWID *GetWidget(WidgetID widnum); - const Scrollbar *GetScrollbar(uint widnum) const; - Scrollbar *GetScrollbar(uint widnum); + const Scrollbar *GetScrollbar(WidgetID widnum) const; + Scrollbar *GetScrollbar(WidgetID widnum); - const QueryString *GetQueryString(uint widnum) const; - QueryString *GetQueryString(uint widnum); + const QueryString *GetQueryString(WidgetID widnum) const; + QueryString *GetQueryString(WidgetID widnum); void UpdateQueryStringSize(); virtual const struct Textbuf *GetFocusedTextbuf() const; @@ -315,8 +315,8 @@ public: } void DisableAllWidgetHighlight(); - void SetWidgetHighlight(byte widget_index, TextColour highlighted_colour); - bool IsWidgetHighlighted(byte widget_index) const; + void SetWidgetHighlight(WidgetID widget_index, TextColour highlighted_colour); + bool IsWidgetHighlighted(WidgetID widget_index) const; /** * Sets the enabled/disabled status of a widget. @@ -325,7 +325,7 @@ public: * @param widget_index index of this widget in the window * @param disab_stat status to use ie: disabled = true, enabled = false */ - inline void SetWidgetDisabledState(byte widget_index, bool disab_stat) + inline void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat) { this->GetWidget(widget_index)->SetDisabled(disab_stat); } @@ -334,7 +334,7 @@ public: * Sets a widget to disabled. * @param widget_index index of this widget in the window */ - inline void DisableWidget(byte widget_index) + inline void DisableWidget(WidgetID widget_index) { SetWidgetDisabledState(widget_index, true); } @@ -343,7 +343,7 @@ public: * Sets a widget to Enabled. * @param widget_index index of this widget in the window */ - inline void EnableWidget(byte widget_index) + inline void EnableWidget(WidgetID widget_index) { SetWidgetDisabledState(widget_index, false); } @@ -353,7 +353,7 @@ public: * @param widget_index index of this widget in the window * @return status of the widget ie: disabled = true, enabled = false */ - inline bool IsWidgetDisabled(byte widget_index) const + inline bool IsWidgetDisabled(WidgetID widget_index) const { return this->GetWidget(widget_index)->IsDisabled(); } @@ -363,7 +363,7 @@ public: * @param widget_index : index of the widget in the window to check * @return true if given widget is the focused window in this window */ - inline bool IsWidgetFocused(byte widget_index) const + inline bool IsWidgetFocused(WidgetID widget_index) const { return this->nested_focus != nullptr && this->nested_focus->index == widget_index; } @@ -374,7 +374,7 @@ public: * @param widget_index : index of the widget in the window to check * @return true if given widget is the focused window in this window and this window has focus */ - inline bool IsWidgetGloballyFocused(byte widget_index) const + inline bool IsWidgetGloballyFocused(WidgetID widget_index) const { return _focused_window == this && IsWidgetFocused(widget_index); } @@ -384,7 +384,7 @@ public: * @param widget_index index of this widget in the window * @param lowered_stat status to use ie: lowered = true, raised = false */ - inline void SetWidgetLoweredState(byte widget_index, bool lowered_stat) + inline void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat) { this->GetWidget(widget_index)->SetLowered(lowered_stat); } @@ -393,7 +393,7 @@ public: * Invert the lowered/raised status of a widget. * @param widget_index index of this widget in the window */ - inline void ToggleWidgetLoweredState(byte widget_index) + inline void ToggleWidgetLoweredState(WidgetID widget_index) { bool lowered_state = this->GetWidget(widget_index)->IsLowered(); this->GetWidget(widget_index)->SetLowered(!lowered_state); @@ -403,7 +403,7 @@ public: * Marks a widget as lowered. * @param widget_index index of this widget in the window */ - inline void LowerWidget(byte widget_index) + inline void LowerWidget(WidgetID widget_index) { SetWidgetLoweredState(widget_index, true); } @@ -412,7 +412,7 @@ public: * Marks a widget as raised. * @param widget_index index of this widget in the window */ - inline void RaiseWidget(byte widget_index) + inline void RaiseWidget(WidgetID widget_index) { SetWidgetLoweredState(widget_index, false); } @@ -434,19 +434,19 @@ public: * @param widget_index index of this widget in the window * @return status of the widget ie: lowered = true, raised= false */ - inline bool IsWidgetLowered(byte widget_index) const + inline bool IsWidgetLowered(WidgetID widget_index) const { return this->GetWidget(widget_index)->IsLowered(); } void UnfocusFocusedWidget(); - bool SetFocusedWidget(int widget_index); + bool SetFocusedWidget(WidgetID widget_index); - EventState HandleEditBoxKey(int wid, char32_t key, uint16_t keycode); - virtual void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end); + EventState HandleEditBoxKey(WidgetID wid, char32_t key, uint16_t keycode); + virtual void InsertTextString(WidgetID wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end); - void HandleButtonClick(byte widget); - int GetRowFromWidget(int clickpos, int widget, int padding, int line_height = -1) const; + void HandleButtonClick(WidgetID widget); + int GetRowFromWidget(int clickpos, WidgetID widget, int padding, int line_height = -1) const; void RaiseButtons(bool autoraise = false); @@ -484,11 +484,11 @@ public: (this->RaiseWidgetWhenLowered(widgets), ...); } - void SetWidgetDirty(byte widget_index) const; + void SetWidgetDirty(WidgetID widget_index) const; void DrawWidgets() const; void DrawViewport() const; - void DrawSortButtonState(int widget, SortButtonState state) const; + void DrawSortButtonState(WidgetID widget, SortButtonState state) const; static int SortButtonWidth(); void CloseChildWindows(WindowClass wc = WC_INVALID) const; @@ -544,7 +544,7 @@ public: * @param widget Number of the widget to draw. * @note This method may not change any state, it may only use drawing functions. */ - virtual void DrawWidget([[maybe_unused]] const Rect &r, [[maybe_unused]] int widget) const {} + virtual void DrawWidget([[maybe_unused]] const Rect &r, [[maybe_unused]] WidgetID widget) const {} /** * Update size and resize step of a widget in the window. @@ -558,7 +558,7 @@ public: * @param fill Fill step of the widget. * @param resize Resize step of the widget. */ - virtual void UpdateWidgetSize([[maybe_unused]] int widget, [[maybe_unused]] Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) {} + virtual void UpdateWidgetSize([[maybe_unused]] WidgetID widget, [[maybe_unused]] Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) {} /** * Initialize string parameters for a widget. @@ -566,7 +566,7 @@ public: * and while re-initializing the window. Only for widgets that render text initializing is requested. * @param widget Widget number. */ - virtual void SetStringParameters([[maybe_unused]] int widget) const {} + virtual void SetStringParameters([[maybe_unused]] WidgetID widget) const {} /** * The window has gained focus. @@ -604,7 +604,7 @@ public: * @param widget the clicked widget. * @param click_count Number of fast consecutive clicks at same position */ - virtual void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] int widget, [[maybe_unused]] int click_count) {} + virtual void OnClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] int click_count) {} /** * A click with the right mouse button has been made on the window. @@ -613,14 +613,14 @@ public: * @return true if the click was actually handled, i.e. do not show a * tooltip if tooltip-on-right-click is enabled. */ - virtual bool OnRightClick([[maybe_unused]] Point pt, [[maybe_unused]] int widget) { return false; } + virtual bool OnRightClick([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) { return false; } /** * The mouse is hovering over a widget in the window, perform an action for it. * @param pt The point where the mouse is hovering. * @param widget The widget where the mouse is hovering. */ - virtual void OnHover([[maybe_unused]] Point pt, [[maybe_unused]] int widget) {} + virtual void OnHover([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {} /** * Event to display a custom tooltip. @@ -628,21 +628,21 @@ public: * @param widget The widget where the mouse is located. * @return True if the event is handled, false if it is ignored. */ - virtual bool OnTooltip([[maybe_unused]] Point pt, [[maybe_unused]] int widget, [[maybe_unused]] TooltipCloseCondition close_cond) { return false; } + virtual bool OnTooltip([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget, [[maybe_unused]] TooltipCloseCondition close_cond) { return false; } /** * An 'object' is being dragged at the provided position, highlight the target if possible. * @param pt The point inside the window that the mouse hovers over. * @param widget The widget the mouse hovers over. */ - virtual void OnMouseDrag([[maybe_unused]] Point pt, [[maybe_unused]] int widget) {} + virtual void OnMouseDrag([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {} /** * A dragged 'object' has been released. * @param pt the point inside the window where the release took place. * @param widget the widget where the release took place. */ - virtual void OnDragDrop([[maybe_unused]] Point pt, [[maybe_unused]] int widget) {} + virtual void OnDragDrop([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {} /** * Handle the request for (viewport) scrolling. @@ -656,7 +656,7 @@ public: * @param pt the point inside the window that the mouse hovers over. * @param widget the widget the mouse hovers over. */ - virtual void OnMouseOver([[maybe_unused]] Point pt, [[maybe_unused]] int widget) {} + virtual void OnMouseOver([[maybe_unused]] Point pt, [[maybe_unused]] WidgetID widget) {} /** * The mouse wheel has been turned. @@ -697,15 +697,15 @@ public: * @param widget the widget (button) that the dropdown is associated with. * @param index the element in the dropdown that is selected. */ - virtual void OnDropdownSelect([[maybe_unused]] int widget, [[maybe_unused]] int index) {} + virtual void OnDropdownSelect([[maybe_unused]] WidgetID widget, [[maybe_unused]] int index) {} - virtual void OnDropdownClose(Point pt, int widget, int index, bool instant_close); + virtual void OnDropdownClose(Point pt, WidgetID widget, int index, bool instant_close); /** * The text in an editbox has been edited. * @param widget The widget of the editbox. */ - virtual void OnEditboxChanged([[maybe_unused]] int widget) {} + virtual void OnEditboxChanged([[maybe_unused]] WidgetID widget) {} /** * The query window opened from this window has closed. @@ -886,7 +886,7 @@ inline bool AllEqual(It begin, It end, P * @return The requested widget if it is instantiated, \c nullptr otherwise. */ template -inline NWID *Window::GetWidget(uint widnum) +inline NWID *Window::GetWidget(WidgetID widnum) { auto it = this->widget_lookup.find(widnum); if (it == std::end(this->widget_lookup)) return nullptr; @@ -897,7 +897,7 @@ inline NWID *Window::GetWidget(uint widn /** Specialized case of #Window::GetWidget for the nested widget base class. */ template <> -inline const NWidgetBase *Window::GetWidget(uint widnum) const +inline const NWidgetBase *Window::GetWidget(WidgetID widnum) const { auto it = this->widget_lookup.find(widnum); if (it == std::end(this->widget_lookup)) return nullptr; @@ -911,7 +911,7 @@ inline const NWidgetBase *Window::GetWid * @return The requested widget if it is instantiated, \c nullptr otherwise. */ template -inline const NWID *Window::GetWidget(uint widnum) const +inline const NWID *Window::GetWidget(WidgetID widnum) const { return const_cast(this)->GetWidget(widnum); } @@ -961,7 +961,7 @@ void RelocateAllWindows(int neww, int ne void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount = 0); /* widget.cpp */ -int GetWidgetFromPos(const Window *w, int x, int y); +WidgetID GetWidgetFromPos(const Window *w, int x, int y); extern Point _cursorpos_drag_start; diff --git a/src/window_type.h b/src/window_type.h --- a/src/window_type.h +++ b/src/window_type.h @@ -10,6 +10,13 @@ #ifndef WINDOW_TYPE_H #define WINDOW_TYPE_H +/** + * Widget ID. + * Even though the ID is signed, actual IDs must be non-negative. + * Negative IDs are used for special cases, like denoting 'no widget'. + */ +using WidgetID = int; + /** %Window numbers. */ enum WindowNumberEnum { WN_GAME_OPTIONS_AI = 0, ///< AI settings.