From a8e587632a454c7e48fcf5ae13a4f6f82ac9f0f3 Mon Sep 17 00:00:00 2001 From: translators Date: Fri, 29 Dec 2023 18:38:59 +0000 Subject: [PATCH 01/29] Update: Translations from eints danish: 3 changes by bscargo dutch: 10 changes by Afoklala --- src/lang/danish.txt | 3 +++ src/lang/dutch.txt | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lang/danish.txt b/src/lang/danish.txt index af5f1af464..0cfccb6724 100644 --- a/src/lang/danish.txt +++ b/src/lang/danish.txt @@ -257,6 +257,7 @@ STR_UNITS_HEIGHT_SI :{DECIMAL} m STR_UNITS_DAYS :{COMMA}{NBSP}dag{P "" s} STR_UNITS_SECONDS :{COMMA}{NBSP}sekund{P "" er} +STR_UNITS_TICKS :{COMMA}{NBSP}tick{P "" s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filtrer udtryk: @@ -1664,6 +1665,7 @@ STR_CONFIG_SETTING_TIMETABLE_MODE_HELPTEXT :Vælg de tidsen ###length 3 STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Dage STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Sekunder +STR_CONFIG_SETTING_TIMETABLE_MODE_TICKS :Ticks STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Vis ankomst og afgang i tidsplaner: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Vis forventede ankomst-og afgangstider i tidsplaner @@ -2201,6 +2203,7 @@ STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Vis farv STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Vælg den primære farve for det valgte farveskema. Ctrl+Click vil sætte denne farve for alle farveskemaer STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Vælg den sekundære farve for det valgte farveskema. Ctrl+Click vil sætte denne farve for alle farveskemaer STR_LIVERY_PANEL_TOOLTIP :{BLACK}Vælg et farveskema, som skal ændres, eller flere farveskemaer vha. CTRL+klik. Klik på boksen for at slå brug af farveskemaet til/fra +STR_LIVERY_TRAIN_GROUP_EMPTY :Der er ikke oprettet toggrupper STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Der er ikke oprettet grupper af vejkøretøjer STR_LIVERY_SHIP_GROUP_EMPTY :Der er ikke oprettet skibsgrupper STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Der er ikke oprettet flygrupper diff --git a/src/lang/dutch.txt b/src/lang/dutch.txt index 60fead6ee5..7a485a9b37 100644 --- a/src/lang/dutch.txt +++ b/src/lang/dutch.txt @@ -2196,9 +2196,17 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Kleurens STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Kleurenschema's voor wegvoertuigen weergeven STR_LIVERY_SHIP_TOOLTIP :{BLACK}Kleurenschema's voor schepen weergeven STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Kleurenschema's voor vliegtuigen weergeven +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Kleuren van treingroepen weergeven +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Kleuren van wegvoertuiggroepen weergeven +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Kleuren van scheepsgroepen weergeven +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Kleuren van vliegtuiggroepen weergeven STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Selecteer de hoofdkleur voor het geselecteerde schema. Ctrl+klik zal deze kleur instellen voor elk schema STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Selecteer de secundaire kleur voor het geselecteerde schema. Met Ctrl+klik stel je deze kleur in voor alle schema's STR_LIVERY_PANEL_TOOLTIP :{BLACK}Selecteer een kleurenschema om te wijzigen of meerdere schema's met Ctrl+klik. Vink de keuzevakjes aan-uit om het schema aan-uit te zetten +STR_LIVERY_TRAIN_GROUP_EMPTY :Geen treingroepen ingesteld +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Geen wegvoertuiggroepen ingesteld +STR_LIVERY_SHIP_GROUP_EMPTY :Geen scheepsgroepen ingesteld +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Geen vliegtuiggroepen ingesteld ###length 23 STR_LIVERY_DEFAULT :Standaard kleurenschema @@ -4653,9 +4661,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Hoofdlet STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Hoofdlettergevoeligheid aan-uitzetten bij het vergelijken van AI-logberichten t.o.v. de afbreektekst STR_AI_DEBUG_CONTINUE :{BLACK}Doorgaan STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Het spel vervolgen en de AI voortzetten -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Probleemgegevens van deze AI weergeven +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Probleemgegevens van deze AI weergeven. Ctrl+klik opent in een nieuw venster STR_AI_GAME_SCRIPT :{BLACK}Spelscript -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Controleer het logboek van het spelscript +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Controleer het logboek van het spelscript. Ctrl+klik opent in een nieuw venster STR_ERROR_AI_NO_AI_FOUND :Geen geschikte AI gevonden.{} Deze AI is een 'dummy' en voert niets uit.{}Verschillende AI's kunnen worden gedownload via het 'Online Content' systeem STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Eén van de actieve scripts is vastgelopen. Meld dit a.u.b. bij de auteur van dit script met een schermafdruk van het AI-/spelscript-probleemvenster. From a12f426d69ff98bd22d6287a7b98b4cae81689bc Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 29 Dec 2023 14:52:42 +0000 Subject: [PATCH 02/29] Codechange: Rename nested array to widget lookup. This changes from naming storage-type to naming functionality. * `FillNestedArray` is renamed to `FillWidgetLookup`. * `Window::nested_array` is renamed to `Window::widget_lookup`. * `array` parameter renamed as well. --- src/widget.cpp | 34 +++++++++++++++++----------------- src/widget_type.h | 18 +++++++++--------- src/window.cpp | 24 ++++++++++++------------ src/window_gui.h | 12 ++++++------ 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/widget.cpp b/src/widget.cpp index 71f367181a..08646c8eea 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -903,7 +903,7 @@ void Window::DrawSortButtonState(int widget, SortButtonState state) const { if (state == SBS_OFF) return; - assert(this->nested_array != nullptr); + assert(this->widget_lookup != nullptr); Rect r = this->GetWidget(widget)->GetCurrentRect(); /* Sort button uses the same sprites as vertical scrollbar */ @@ -1023,8 +1023,8 @@ NWidgetBase::NWidgetBase(WidgetType tp) : ZeroedMemoryAllocator() */ /** - * @fn void NWidgetBase::FillNestedArray(NWidgetBase **array, uint length) - * Fill the Window::nested_array array with pointers to nested widgets in the tree. + * @fn void NWidgetBase::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) + * Fill the Window::widget_lookup array with pointers to nested widgets in the tree. * @param array Base pointer of the array. * @param length Length of the array. */ @@ -1276,9 +1276,9 @@ void NWidgetCore::SetAlignment(StringAlignment align) this->align = align; } -void NWidgetCore::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetCore::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) { - if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; + if (this->index >= 0 && (uint)(this->index) < length) widget_lookup[this->index] = this; } NWidgetCore *NWidgetCore::GetWidgetFromPos(int x, int y) @@ -1345,10 +1345,10 @@ void NWidgetContainer::Add(NWidgetBase *wid) } } -void NWidgetContainer::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetContainer::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) { for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { - child_wid->FillNestedArray(array, length); + child_wid->FillWidgetLookup(widget_lookup, length); } } @@ -1452,10 +1452,10 @@ void NWidgetStacked::AssignSizePosition(SizingType sizing, int x, int y, uint gi } } -void NWidgetStacked::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetStacked::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) { - if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; - NWidgetContainer::FillNestedArray(array, length); + if (this->index >= 0 && (uint)(this->index) < length) widget_lookup[this->index] = this; + NWidgetContainer::FillWidgetLookup(widget_lookup, length); } void NWidgetStacked::Draw(const Window *w) @@ -1925,7 +1925,7 @@ void NWidgetSpacer::SetupSmallestSize(Window *) this->smallest_y = this->min_y; } -void NWidgetSpacer::FillNestedArray(NWidgetBase **, uint) +void NWidgetSpacer::FillWidgetLookup(NWidgetBase **, uint) { } @@ -2065,10 +2065,10 @@ void NWidgetMatrix::AssignSizePosition(SizingType, int x, int y, uint given_widt this->SetCount(this->count); } -void NWidgetMatrix::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetMatrix::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) { - if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; - NWidgetContainer::FillNestedArray(array, length); + if (this->index >= 0 && (uint)(this->index) < length) widget_lookup[this->index] = this; + NWidgetContainer::FillWidgetLookup(widget_lookup, length); } NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) @@ -2335,10 +2335,10 @@ void NWidgetBackground::AssignSizePosition(SizingType sizing, int x, int y, uint } } -void NWidgetBackground::FillNestedArray(NWidgetBase **array, uint length) +void NWidgetBackground::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) { - if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this; - if (this->child != nullptr) this->child->FillNestedArray(array, length); + if (this->index >= 0 && (uint)(this->index) < length) widget_lookup[this->index] = this; + if (this->child != nullptr) this->child->FillWidgetLookup(widget_lookup, length); } void NWidgetBackground::Draw(const Window *w) diff --git a/src/widget_type.h b/src/widget_type.h index b4bf6da505..ae9da95634 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -136,7 +136,7 @@ public: virtual void SetupSmallestSize(Window *w) = 0; virtual void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) = 0; - virtual void FillNestedArray(NWidgetBase **array, uint length) = 0; + virtual void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) = 0; virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0; virtual NWidgetBase *GetWidgetOfType(WidgetType tp); @@ -337,7 +337,7 @@ public: inline void SetDisabled(bool disabled); inline bool IsDisabled() const; - void FillNestedArray(NWidgetBase **array, uint length) override; + void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; bool IsHighlighted() const override; TextColour GetHighlightColour() const override; @@ -419,7 +419,7 @@ public: void AdjustPaddingForZoom() override; void Add(NWidgetBase *wid); - void FillNestedArray(NWidgetBase **array, uint length) override; + void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; @@ -462,7 +462,7 @@ public: void AdjustPaddingForZoom() override; void SetupSmallestSize(Window *w) override; void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; - void FillNestedArray(NWidgetBase **array, uint length) override; + void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; @@ -470,7 +470,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::nested_array. + int index; ///< If non-negative, index in the #Window::widget_lookup. }; /** Nested widget container flags, */ @@ -564,12 +564,12 @@ public: void SetupSmallestSize(Window *w) override; void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; - void FillNestedArray(NWidgetBase **array, uint length) override; + void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; void Draw(const Window *w) override; protected: - int index; ///< If non-negative, index in the #Window::nested_array. + int 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. @@ -593,7 +593,7 @@ public: NWidgetSpacer(int width, int height); void SetupSmallestSize(Window *w) override; - void FillNestedArray(NWidgetBase **array, uint length) override; + void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; void Draw(const Window *w) override; void SetDirty(const Window *w) const override; @@ -617,7 +617,7 @@ public: void SetupSmallestSize(Window *w) override; void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; - void FillNestedArray(NWidgetBase **array, uint length) override; + void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; diff --git a/src/window.cpp b/src/window.cpp index 41a55d41f3..40edb5d77c 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -496,7 +496,7 @@ bool Window::SetFocusedWidget(int widget_index) /* Do nothing if widget_index is already focused, or if it wasn't a valid widget. */ if ((uint)widget_index >= this->nested_array_size) return false; - assert(this->nested_array[widget_index] != nullptr); // Setting focus to a non-existing widget is a bad idea. + assert(this->widget_lookup[widget_index] != nullptr); // Setting focus to a non-existing widget is a bad idea. if (this->nested_focus != nullptr) { if (this->GetWidget(widget_index) == this->nested_focus) return false; @@ -532,8 +532,8 @@ void Window::OnFocusLost(bool) void Window::RaiseButtons(bool autoraise) { for (uint i = 0; i < this->nested_array_size; i++) { - if (this->nested_array[i] == nullptr) continue; - WidgetType type = this->nested_array[i]->type; + if (this->widget_lookup[i] == nullptr) continue; + WidgetType type = this->widget_lookup[i]->type; if (((type & ~WWB_PUSHBUTTON) < WWT_LAST || type == NWID_PUSHBUTTON_DROPDOWN) && (!autoraise || (type & WWB_PUSHBUTTON) || type == WWT_EDITBOX) && this->IsWidgetLowered(i)) { this->RaiseWidget(i); @@ -556,9 +556,9 @@ void Window::RaiseButtons(bool autoraise) void Window::SetWidgetDirty(byte widget_index) const { /* Sometimes this function is called before the window is even fully initialized */ - if (this->nested_array == nullptr) return; + if (this->widget_lookup == nullptr) return; - this->nested_array[widget_index]->SetDirty(this); + this->widget_lookup[widget_index]->SetDirty(this); } /** @@ -1092,7 +1092,7 @@ Window::~Window() if (this->viewport != nullptr) DeleteWindowViewport(this); - free(this->nested_array); // Contents is released through deletion of #nested_root. + free(this->widget_lookup); // Contents is released through deletion of #nested_root. delete this->nested_root; } @@ -1366,7 +1366,7 @@ static void BringWindowToFront(Window *w, bool dirty) * @param window_number Number being assigned to the new window * @return Window pointer of the newly created window * @pre If nested widgets are used (\a widget is \c nullptr), #nested_root and #nested_array_size must be initialized. - * In addition, #nested_array is either \c nullptr, or already initialized. + * In addition, #widget_lookup is either \c nullptr, or already initialized. */ void Window::InitializeData(WindowNumber window_number) { @@ -1722,9 +1722,9 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16_t sm_width, i /** * Perform the first part of the initialization of a nested widget tree. - * Construct a nested widget tree in #nested_root, and optionally fill the #nested_array array to provide quick access to the uninitialized widgets. + * Construct a nested widget tree in #nested_root, and optionally fill the #widget_lookup array to provide quick access to the uninitialized widgets. * This is mainly useful for setting very basic properties. - * @param fill_nested Fill the #nested_array (enabling is expensive!). + * @param fill_nested Fill the #widget_lookup (enabling is expensive!). * @note Filling the nested array requires an additional traversal through the nested widget tree, and is best performed by #FinishInitNested rather than here. */ void Window::CreateNestedTree() @@ -1733,8 +1733,8 @@ void Window::CreateNestedTree() this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_begin, this->window_desc->nwid_end, &biggest_index, &this->shade_select); this->nested_array_size = (uint)(biggest_index + 1); - this->nested_array = CallocT(this->nested_array_size); - this->nested_root->FillNestedArray(this->nested_array, this->nested_array_size); + this->widget_lookup = CallocT(this->nested_array_size); + this->nested_root->FillWidgetLookup(this->widget_lookup, this->nested_array_size); } /** @@ -1841,7 +1841,7 @@ static void DecreaseWindowCounters() if (_scroller_click_timeout == 0) { /* Unclick scrollbar buttons if they are pressed. */ for (uint i = 0; i < w->nested_array_size; i++) { - NWidgetBase *nwid = w->nested_array[i]; + NWidgetBase *nwid = w->widget_lookup[i]; if (nwid != nullptr && (nwid->type == NWID_HSCROLLBAR || nwid->type == NWID_VSCROLLBAR)) { NWidgetScrollbar *sb = static_cast(nwid); if (sb->disp_flags & (ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN)) { diff --git a/src/window_gui.h b/src/window_gui.h index df6b47f027..93414a3402 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -260,7 +260,7 @@ public: const NWidgetCore *nested_focus; ///< Currently focused nested widget, or \c nullptr if no nested widget has focus. std::map querystrings; ///< QueryString associated to WWT_EDITBOX widgets. NWidgetBase *nested_root; ///< Root of the nested tree. - NWidgetBase **nested_array; ///< Array of pointers into the tree. Do not access directly, use #Window::GetWidget() instead. + NWidgetBase **widget_lookup; ///< Array of pointers into the tree. Do not access directly, use #Window::GetWidget() instead. uint nested_array_size; ///< Size of the nested array. 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). @@ -329,7 +329,7 @@ public: inline void SetWidgetDisabledState(byte widget_index, bool disab_stat) { assert(widget_index < this->nested_array_size); - if (this->nested_array[widget_index] != nullptr) this->GetWidget(widget_index)->SetDisabled(disab_stat); + if (this->widget_lookup[widget_index] != nullptr) this->GetWidget(widget_index)->SetDisabled(disab_stat); } /** @@ -520,7 +520,7 @@ public: /** * Notification that the nested widget tree gets initialized. The event can be used to perform general computations. - * @note #nested_root and/or #nested_array (normally accessed via #GetWidget()) may not exist during this call. + * @note #nested_root and/or #widget_lookup (normally accessed via #GetWidget()) may not exist during this call. */ virtual void OnInit() { } @@ -894,8 +894,8 @@ inline bool AllEqual(It begin, It end, Pred pred) template inline NWID *Window::GetWidget(uint widnum) { - if (widnum >= this->nested_array_size || this->nested_array[widnum] == nullptr) return nullptr; - NWID *nwid = dynamic_cast(this->nested_array[widnum]); + if (widnum >= this->nested_array_size || this->widget_lookup[widnum] == nullptr) return nullptr; + NWID *nwid = dynamic_cast(this->widget_lookup[widnum]); assert(nwid != nullptr); return nwid; } @@ -905,7 +905,7 @@ template <> inline const NWidgetBase *Window::GetWidget(uint widnum) const { if (widnum >= this->nested_array_size) return nullptr; - return this->nested_array[widnum]; + return this->widget_lookup[widnum]; } /** From b86182ab848462cc4ef7bfc4d2c4d79fc39d0fb3 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 16 Oct 2023 11:13:36 +0100 Subject: [PATCH 03/29] Codechange: Use std::map to provide indexed widget access. This removes the need to determine the biggest widget index and replaces C-style memory handling. --- src/graph_gui.cpp | 14 ++--- src/linkgraph/linkgraph_gui.cpp | 10 ++-- src/network/network_gui.cpp | 3 +- src/newgrf_gui.cpp | 13 ++-- src/osk_gui.cpp | 51 ++++++++-------- src/script/script_gui.cpp | 4 +- src/smallmap_gui.cpp | 6 +- src/station_gui.cpp | 4 +- src/terraform_gui.cpp | 6 +- src/tests/test_window_desc.cpp | 3 +- src/toolbar_gui.cpp | 7 +-- src/tree_gui.cpp | 3 +- src/widget.cpp | 102 ++++++++++++-------------------- src/widget_type.h | 35 +++++------ src/window.cpp | 75 +++++++++++------------ src/window_gui.h | 20 +++---- 16 files changed, 147 insertions(+), 209 deletions(-) diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 25eee1d791..ec311a8cc7 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -107,11 +107,9 @@ struct GraphLegendWindow : Window { /** * Construct a vertical list of buttons, one for each company. - * @param biggest_index Storage for collecting the biggest index used in the returned tree. * @return Panel with company buttons. - * @post \c *biggest_index contains the largest used index in the tree. */ -static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index) +static NWidgetBase *MakeNWidgetCompanyLines() { NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE); vert->SetPadding(2, 2, 2, 2); @@ -125,7 +123,6 @@ static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index) panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP); vert->Add(panel); } - *biggest_index = WID_GL_LAST_COMPANY; return vert; } @@ -1338,11 +1335,9 @@ CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY; /** * Make a vertical list of panels for outputting score details. - * @param biggest_index Storage for collecting the biggest index used in the returned tree. * @return Panel with performance details. - * @post \c *biggest_index contains the largest used index in the tree. */ -static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index) +static NWidgetBase *MakePerformanceDetailPanels() { const StringID performance_tips[] = { STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP, @@ -1366,14 +1361,13 @@ static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index) panel->SetDataTip(0x0, performance_tips[widnum - WID_PRD_SCORE_FIRST]); vert->Add(panel); } - *biggest_index = WID_PRD_SCORE_LAST; return vert; } /** Make a number of rows with buttons for each company for the performance rating detail window. */ -NWidgetBase *MakeCompanyButtonRowsGraphGUI(int *biggest_index) +NWidgetBase *MakeCompanyButtonRowsGraphGUI() { - return MakeCompanyButtonRows(biggest_index, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST, COLOUR_BROWN, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP); + return MakeCompanyButtonRows(WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST, COLOUR_BROWN, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP); } static const NWidgetPart _nested_performance_rating_detail_widgets[] = { diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index deaba0d844..0c37ec59b8 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -454,12 +454,12 @@ void LinkGraphOverlay::SetCompanyMask(CompanyMask company_mask) } /** Make a number of rows with buttons for each company for the linkgraph legend window. */ -NWidgetBase *MakeCompanyButtonRowsLinkGraphGUI(int *biggest_index) +NWidgetBase *MakeCompanyButtonRowsLinkGraphGUI() { - return MakeCompanyButtonRows(biggest_index, WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, COLOUR_GREY, 3, STR_NULL); + return MakeCompanyButtonRows(WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, COLOUR_GREY, 3, STR_NULL); } -NWidgetBase *MakeSaturationLegendLinkGraphGUI(int *biggest_index) +NWidgetBase *MakeSaturationLegendLinkGraphGUI() { NWidgetVertical *panel = new NWidgetVertical(NC_EQUALSIZE); for (uint i = 0; i < lengthof(LinkGraphOverlay::LINK_COLOURS[0]); ++i) { @@ -470,11 +470,10 @@ NWidgetBase *MakeSaturationLegendLinkGraphGUI(int *biggest_index) wid->SetResize(0, 0); panel->Add(wid); } - *biggest_index = WID_LGL_SATURATION_LAST; return panel; } -NWidgetBase *MakeCargoesLegendLinkGraphGUI(int *biggest_index) +NWidgetBase *MakeCargoesLegendLinkGraphGUI() { uint num_cargo = static_cast(_sorted_cargo_specs.size()); static const uint ENTRIES_PER_COL = 5; @@ -503,7 +502,6 @@ NWidgetBase *MakeCargoesLegendLinkGraphGUI(int *biggest_index) } /* If there are no cargo specs defined, then col won't have been created so don't add it. */ if (col != nullptr) panel->Add(col); - *biggest_index = WID_LGL_CARGO_LAST; return panel; } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 4f0890f6ad..123626764d 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -855,9 +855,8 @@ GUIGameServerList::FilterFunction * const NetworkGameWindow::filter_funcs[] = { &NGameSearchFilter }; -static NWidgetBase *MakeResizableHeader(int *biggest_index) +static NWidgetBase *MakeResizableHeader() { - *biggest_index = std::max(*biggest_index, WID_NG_INFO); return new NWidgetServerListHeader(); } diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 472dfca745..583f4206a5 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1937,16 +1937,11 @@ static const NWidgetPart _nested_newgrf_infopanel_widgets[] = { }; /** Construct nested container widget for managing the lists and the info panel of the NewGRF GUI. */ -NWidgetBase* NewGRFDisplay(int *biggest_index) +NWidgetBase* NewGRFDisplay() { - NWidgetBase *avs = MakeNWidgets(std::begin(_nested_newgrf_availables_widgets), std::end(_nested_newgrf_availables_widgets), biggest_index, nullptr); - - int biggest2; - NWidgetBase *acs = MakeNWidgets(std::begin(_nested_newgrf_actives_widgets), std::end(_nested_newgrf_actives_widgets), &biggest2, nullptr); - *biggest_index = std::max(*biggest_index, biggest2); - - NWidgetBase *inf = MakeNWidgets(std::begin(_nested_newgrf_infopanel_widgets), std::end(_nested_newgrf_infopanel_widgets), &biggest2, nullptr); - *biggest_index = std::max(*biggest_index, biggest2); + NWidgetBase *avs = MakeNWidgets(std::begin(_nested_newgrf_availables_widgets), std::end(_nested_newgrf_availables_widgets), nullptr); + NWidgetBase *acs = MakeNWidgets(std::begin(_nested_newgrf_actives_widgets), std::end(_nested_newgrf_actives_widgets), nullptr); + NWidgetBase *inf = MakeNWidgets(std::begin(_nested_newgrf_infopanel_widgets), std::end(_nested_newgrf_infopanel_widgets), nullptr); return new NWidgetNewGRFDisplay(avs, acs, inf); } diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 1beb896ffa..9051484454 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -220,10 +220,9 @@ static const int KEY_PADDING = 6; // Vertical padding for remaining key rows * @param widtype Widget type of the key. Must be either \c NWID_SPACER for an invisible key, or a \c WWT_* widget. * @param widnum Widget number of the key. * @param widdata Data value of the key widget. - * @param biggest_index Collected biggest widget index so far. * @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, int *biggest_index) +static void AddKey(NWidgetHorizontal *hor, int pad_y, int num_half, WidgetType widtype, int widnum, uint16_t widdata) { int key_width = HALF_KEY_WIDTH + (INTER_KEY_SPACE + HALF_KEY_WIDTH) * (num_half - 1); @@ -243,80 +242,78 @@ static void AddKey(NWidgetHorizontal *hor, int pad_y, int num_half, WidgetType w leaf->SetMinimalTextLines(1, pad_y, FS_NORMAL); hor->Add(leaf); } - - *biggest_index = std::max(*biggest_index, widnum); } /** Construct the top row keys (cancel, ok, backspace). */ -static NWidgetBase *MakeTopKeys(int *biggest_index) +static NWidgetBase *MakeTopKeys() { NWidgetHorizontal *hor = new NWidgetHorizontal(); - AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_CANCEL, STR_BUTTON_CANCEL, biggest_index); - AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_OK, STR_BUTTON_OK, biggest_index); - AddKey(hor, TOP_KEY_PADDING, 2 * 2, WWT_PUSHIMGBTN, WID_OSK_BACKSPACE, SPR_OSK_BACKSPACE, biggest_index); + AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_CANCEL, STR_BUTTON_CANCEL); + AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_OK, STR_BUTTON_OK ); + AddKey(hor, TOP_KEY_PADDING, 2 * 2, WWT_PUSHIMGBTN, WID_OSK_BACKSPACE, SPR_OSK_BACKSPACE); return hor; } /** Construct the row containing the digit keys. */ -static NWidgetBase *MakeNumberKeys(int *biggest_index) +static NWidgetBase *MakeNumberKeys() { NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); for (int widnum = WID_OSK_NUMBERS_FIRST; widnum <= WID_OSK_NUMBERS_LAST; widnum++) { - AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index); + AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } return hor; } /** Construct the qwerty row keys. */ -static NWidgetBase *MakeQwertyKeys(int *biggest_index) +static NWidgetBase *MakeQwertyKeys() { NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); - AddKey(hor, KEY_PADDING, 3, WWT_PUSHIMGBTN, WID_OSK_SPECIAL, SPR_OSK_SPECIAL, biggest_index); + 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++) { - AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index); + AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } - AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0, biggest_index); + AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0); return hor; } /** Construct the asdfg row keys. */ -static NWidgetBase *MakeAsdfgKeys(int *biggest_index) +static NWidgetBase *MakeAsdfgKeys() { NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); - AddKey(hor, KEY_PADDING, 4, WWT_IMGBTN, WID_OSK_CAPS, SPR_OSK_CAPS, biggest_index); + 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++) { - AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index); + AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } return hor; } /** Construct the zxcvb row keys. */ -static NWidgetBase *MakeZxcvbKeys(int *biggest_index) +static NWidgetBase *MakeZxcvbKeys() { NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); - AddKey(hor, KEY_PADDING, 3, WWT_IMGBTN, WID_OSK_SHIFT, SPR_OSK_SHIFT, biggest_index); + 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++) { - AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0, biggest_index); + AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); } - AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0, biggest_index); + AddKey(hor, KEY_PADDING, 1, NWID_SPACER, 0, 0); return hor; } /** Construct the spacebar row keys. */ -static NWidgetBase *MakeSpacebarKeys(int *biggest_index) +static NWidgetBase *MakeSpacebarKeys() { NWidgetHorizontal *hor = new NWidgetHorizontal(); - AddKey(hor, KEY_PADDING, 8, NWID_SPACER, 0, 0, biggest_index); - AddKey(hor, KEY_PADDING, 13, WWT_PUSHTXTBTN, WID_OSK_SPACE, STR_EMPTY, biggest_index); - AddKey(hor, KEY_PADDING, 3, NWID_SPACER, 0, 0, biggest_index); - AddKey(hor, KEY_PADDING, 2, WWT_PUSHIMGBTN, WID_OSK_LEFT, SPR_OSK_LEFT, biggest_index); - AddKey(hor, KEY_PADDING, 2, WWT_PUSHIMGBTN, WID_OSK_RIGHT, SPR_OSK_RIGHT, biggest_index); + AddKey(hor, KEY_PADDING, 8, NWID_SPACER, 0, 0); + AddKey(hor, KEY_PADDING, 13, WWT_PUSHTXTBTN, WID_OSK_SPACE, STR_EMPTY); + AddKey(hor, KEY_PADDING, 3, NWID_SPACER, 0, 0); + AddKey(hor, KEY_PADDING, 2, WWT_PUSHIMGBTN, WID_OSK_LEFT, SPR_OSK_LEFT); + AddKey(hor, KEY_PADDING, 2, WWT_PUSHIMGBTN, WID_OSK_RIGHT, SPR_OSK_RIGHT); return hor; } diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 1450de8d7a..195fab5a24 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -1229,9 +1229,9 @@ struct ScriptDebugWindow : public Window { }; /** Make a number of rows with buttons for each company for the Script debug window. */ -NWidgetBase *MakeCompanyButtonRowsScriptDebug(int *biggest_index) +NWidgetBase *MakeCompanyButtonRowsScriptDebug() { - return MakeCompanyButtonRows(biggest_index, WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END, COLOUR_GREY, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP); + return MakeCompanyButtonRows(WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END, COLOUR_GREY, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP); } /** Widgets for the Script debug window. */ diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index e1a1ffb2d5..b6befbbe7d 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1942,12 +1942,12 @@ static const NWidgetPart _nested_smallmap_bar[] = { EndContainer(), }; -static NWidgetBase *SmallMapDisplay(int *biggest_index) +static NWidgetBase *SmallMapDisplay() { NWidgetContainer *map_display = new NWidgetSmallmapDisplay; - MakeNWidgets(std::begin(_nested_smallmap_display), std::end(_nested_smallmap_display), biggest_index, map_display); - MakeNWidgets(std::begin(_nested_smallmap_bar), std::end(_nested_smallmap_bar), biggest_index, map_display); + MakeNWidgets(std::begin(_nested_smallmap_display), std::end(_nested_smallmap_display), map_display); + MakeNWidgets(std::begin(_nested_smallmap_bar), std::end(_nested_smallmap_bar), map_display); return map_display; } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 51f3cc1fdf..c48ca4b4b5 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -714,10 +714,9 @@ const StringID CompanyStationsWindow::sorter_names[] = { /** * Make a horizontal row of cargo buttons, starting at widget #WID_STL_CARGOSTART. - * @param biggest_index Pointer to store biggest used widget number of the buttons. * @return Horizontal row. */ -static NWidgetBase *CargoWidgets(int *biggest_index) +static NWidgetBase *CargoWidgets() { NWidgetHorizontal *container = new NWidgetHorizontal(); @@ -730,7 +729,6 @@ static NWidgetBase *CargoWidgets(int *biggest_index) panel->SetDataTip(0, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE); container->Add(panel); } - *biggest_index = WID_STL_CARGOSTART + static_cast(_sorted_standard_cargo_specs.size()); return container; } diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index f3e3f4e690..3eff82f29d 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -646,9 +646,9 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { void OnTimeout() override { - for (uint i = WID_ETT_START; i < this->nested_array_size; i++) { - if (i == WID_ETT_BUTTONS_START) i = WID_ETT_BUTTONS_END; // skip the buttons - this->RaiseWidgetWhenLowered(i); + for (const auto &pair : this->widget_lookup) { + if (pair.first < WID_ETT_START || (pair.first >= WID_ETT_BUTTONS_START && pair.first < WID_ETT_BUTTONS_END)) continue; // skip the buttons + this->RaiseWidgetWhenLowered(pair.first); } } diff --git a/src/tests/test_window_desc.cpp b/src/tests/test_window_desc.cpp index ab89c12ccc..419c6994ca 100644 --- a/src/tests/test_window_desc.cpp +++ b/src/tests/test_window_desc.cpp @@ -89,11 +89,10 @@ TEST_CASE_METHOD(WindowDescTestsFixture, "WindowDesc - NWidgetPart validity") INFO(fmt::format("{}:{}", window_desc->file, window_desc->line)); - int biggest_index = -1; NWidgetStacked *shade_select = nullptr; NWidgetBase *root = nullptr; - REQUIRE_NOTHROW(root = MakeWindowNWidgetTree(window_desc->nwid_begin, window_desc->nwid_end, &biggest_index, &shade_select)); + REQUIRE_NOTHROW(root = MakeWindowNWidgetTree(window_desc->nwid_begin, window_desc->nwid_end, &shade_select)); CHECK((root != nullptr)); delete root; } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 4a9081e22a..a880362a3b 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -2120,7 +2120,7 @@ struct MainToolbarWindow : Window { }}; }; -static NWidgetBase *MakeMainToolbar(int *biggest_index) +static NWidgetBase *MakeMainToolbar() { /** Sprites to use for the different toolbar buttons */ static const SpriteID toolbar_button_sprites[] = { @@ -2174,7 +2174,6 @@ static NWidgetBase *MakeMainToolbar(int *biggest_index) hor->Add(leaf); } - *biggest_index = std::max(*biggest_index, WID_TN_SWITCH_BAR); return hor; } @@ -2513,9 +2512,9 @@ static const NWidgetPart _nested_toolb_scen_inner_widgets[] = { NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SWITCH_BAR), SetDataTip(SPR_IMG_SWITCH_TOOLBAR, STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR), }; -static NWidgetBase *MakeScenarioToolbar(int *biggest_index) +static NWidgetBase *MakeScenarioToolbar() { - return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), biggest_index, new NWidgetScenarioToolbarContainer()); + return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), new NWidgetScenarioToolbarContainer()); } static const NWidgetPart _nested_toolb_scen_widgets[] = { diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 9f8e045945..91770b73c4 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -256,7 +256,7 @@ public: * get producing the correct result than dynamically building the widgets is. * @see NWidgetFunctionType */ -static NWidgetBase *MakeTreeTypeButtons(int *biggest_index) +static NWidgetBase *MakeTreeTypeButtons() { const byte type_base = _tree_base_by_landscape[_settings_game.game_creation.landscape]; const byte type_count = _tree_count_by_landscape[_settings_game.game_creation.landscape]; @@ -278,7 +278,6 @@ static NWidgetBase *MakeTreeTypeButtons(int *biggest_index) NWidgetBackground *button = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_BT_TYPE_BUTTON_FIRST + cur_type); button->SetDataTip(0x0, STR_PLANT_TREE_TOOLTIP); hstack->Add(button); - *biggest_index = WID_BT_TYPE_BUTTON_FIRST + cur_type; cur_type++; } } diff --git a/src/widget.cpp b/src/widget.cpp index 08646c8eea..72ed790edf 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -877,9 +877,9 @@ void Window::DrawWidgets() const if (this->flags & WF_HIGHLIGHTED) { extern bool _window_highlight_colour; - for (uint i = 0; i < this->nested_array_size; i++) { - const NWidgetBase *widget = this->GetWidget(i); - if (widget == nullptr || !widget->IsHighlighted()) continue; + for (const auto &pair : this->widget_lookup) { + const NWidgetBase *widget = pair.second; + if (!widget->IsHighlighted()) continue; Rect outer = widget->GetCurrentRect(); Rect inner = outer.Shrink(WidgetDimensions::scaled.bevel).Expand(1); @@ -903,7 +903,7 @@ void Window::DrawSortButtonState(int widget, SortButtonState state) const { if (state == SBS_OFF) return; - assert(this->widget_lookup != nullptr); + assert(!this->widget_lookup.empty()); Rect r = this->GetWidget(widget)->GetCurrentRect(); /* Sort button uses the same sprites as vertical scrollbar */ @@ -1023,10 +1023,9 @@ NWidgetBase::NWidgetBase(WidgetType tp) : ZeroedMemoryAllocator() */ /** - * @fn void NWidgetBase::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) - * Fill the Window::widget_lookup array with pointers to nested widgets in the tree. - * @param array Base pointer of the array. - * @param length Length of the array. + * @fn void NWidgetBase::FillWidgetLookup(WidgetLookup &widget_lookup) + * Fill the Window::widget_lookup with pointers to nested widgets in the tree. + * @param widget_lookup The WidgetLookup. */ /** @@ -1276,9 +1275,9 @@ void NWidgetCore::SetAlignment(StringAlignment align) this->align = align; } -void NWidgetCore::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) +void NWidgetCore::FillWidgetLookup(WidgetLookup &widget_lookup) { - if (this->index >= 0 && (uint)(this->index) < length) widget_lookup[this->index] = this; + if (this->index >= 0) widget_lookup[this->index] = this; } NWidgetCore *NWidgetCore::GetWidgetFromPos(int x, int y) @@ -1345,10 +1344,10 @@ void NWidgetContainer::Add(NWidgetBase *wid) } } -void NWidgetContainer::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) +void NWidgetContainer::FillWidgetLookup(WidgetLookup &widget_lookup) { for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { - child_wid->FillWidgetLookup(widget_lookup, length); + child_wid->FillWidgetLookup(widget_lookup); } } @@ -1452,10 +1451,10 @@ void NWidgetStacked::AssignSizePosition(SizingType sizing, int x, int y, uint gi } } -void NWidgetStacked::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) +void NWidgetStacked::FillWidgetLookup(WidgetLookup &widget_lookup) { - if (this->index >= 0 && (uint)(this->index) < length) widget_lookup[this->index] = this; - NWidgetContainer::FillWidgetLookup(widget_lookup, length); + if (this->index >= 0) widget_lookup[this->index] = this; + NWidgetContainer::FillWidgetLookup(widget_lookup); } void NWidgetStacked::Draw(const Window *w) @@ -1564,7 +1563,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w) this->resize_y = 1; // smallest common child resize step. this->gaps = 0; - /* 1a. Forward call, collect biggest nested array index, and longest/widest child length. */ + /* 1a. Forward call, collect longest/widest child length. */ uint longest = 0; // Longest child found. uint max_vert_fill = 0; // Biggest vertical fill step. for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { @@ -1756,7 +1755,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w) this->resize_y = 0; // smallest non-zero child widget resize step. this->gaps = 0; - /* 1a. Forward call, collect biggest nested array index, and longest/widest child length. */ + /* 1a. Forward call, collect longest/widest child length. */ uint highest = 0; // Highest child found. uint max_hor_fill = 0; // Biggest horizontal fill step. for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { @@ -1925,7 +1924,7 @@ void NWidgetSpacer::SetupSmallestSize(Window *) this->smallest_y = this->min_y; } -void NWidgetSpacer::FillWidgetLookup(NWidgetBase **, uint) +void NWidgetSpacer::FillWidgetLookup(WidgetLookup &) { } @@ -2065,10 +2064,10 @@ void NWidgetMatrix::AssignSizePosition(SizingType, int x, int y, uint given_widt this->SetCount(this->count); } -void NWidgetMatrix::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) +void NWidgetMatrix::FillWidgetLookup(WidgetLookup &widget_lookup) { - if (this->index >= 0 && (uint)(this->index) < length) widget_lookup[this->index] = this; - NWidgetContainer::FillWidgetLookup(widget_lookup, length); + if (this->index >= 0) widget_lookup[this->index] = this; + NWidgetContainer::FillWidgetLookup(widget_lookup); } NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) @@ -2185,7 +2184,7 @@ void NWidgetMatrix::GetScrollOffsets(int &start_x, int &start_y, int &base_offs_ * Constructor parent nested widgets. * @param tp Type of parent widget. * @param colour Colour of the parent widget. - * @param index Index in the widget array used by the window system. + * @param index Index of the widget. * @param child Child container widget (if supplied). If not supplied, a * vertical container will be inserted while adding the first * child widget. @@ -2335,10 +2334,10 @@ void NWidgetBackground::AssignSizePosition(SizingType sizing, int x, int y, uint } } -void NWidgetBackground::FillWidgetLookup(NWidgetBase **widget_lookup, uint length) +void NWidgetBackground::FillWidgetLookup(WidgetLookup &widget_lookup) { - if (this->index >= 0 && (uint)(this->index) < length) widget_lookup[this->index] = this; - if (this->child != nullptr) this->child->FillWidgetLookup(widget_lookup, length); + if (this->index >= 0) widget_lookup[this->index] = this; + if (this->child != nullptr) this->child->FillWidgetLookup(widget_lookup); } void NWidgetBackground::Draw(const Window *w) @@ -2556,7 +2555,7 @@ void Scrollbar::SetCapacityFromWidget(Window *w, int widget, int padding) * Scrollbar widget. * @param tp Scrollbar type. (horizontal/vertical) * @param colour Colour of the scrollbar. - * @param index Index in the widget array used by the window system. + * @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) { @@ -2680,7 +2679,7 @@ Dimension NWidgetLeaf::dropdown_dimension = {0, 0}; * Nested leaf widget. * @param tp Type of leaf widget. * @param colour Colour of the leaf widget. - * @param index Index in the widget array used by the window system. + * @param index Index of the widget. * @param data Data of the widget. * @param tip Tooltip of the widget. */ @@ -3110,11 +3109,9 @@ bool NWidgetLeaf::ButtonHit(const Point &pt) * @param nwid_end Pointer to ending of nested widget parts. * @param dest Address of pointer to use for returning the composed widget. * @param fill_dest Fill the composed widget with child widgets. - * @param biggest_index Pointer to biggest nested widget index in the tree encountered so far. * @return Pointer to remaining nested widget parts. - * @pre \c biggest_index != nullptr. */ -static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **dest, bool *fill_dest, int *biggest_index) +static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **dest, bool *fill_dest) { *dest = nullptr; *fill_dest = false; @@ -3143,7 +3140,6 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg case WWT_FRAME: if (*dest != nullptr) return nwid_begin; *dest = new NWidgetBackground(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); *fill_dest = true; break; @@ -3160,16 +3156,12 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg *fill_dest = true; nwm->SetIndex(nwid_begin->u.widget.index); nwm->SetColour(nwid_begin->u.widget.colour); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); break; } case WPT_FUNCTION: { if (*dest != nullptr) return nwid_begin; - /* Ensure proper functioning even when the called code simply writes its largest index. */ - int biggest = -1; - *dest = nwid_begin->u.func_ptr(&biggest); - *biggest_index = std::max(*biggest_index, biggest); + *dest = nwid_begin->u.func_ptr(); *fill_dest = false; break; } @@ -3267,14 +3259,12 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg case NWID_VIEWPORT: if (*dest != nullptr) return nwid_begin; *dest = new NWidgetViewport(nwid_begin->u.widget.index); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); break; case NWID_HSCROLLBAR: case NWID_VSCROLLBAR: if (*dest != nullptr) return nwid_begin; *dest = new NWidgetScrollbar(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); break; case NWID_SELECTION: { @@ -3283,7 +3273,6 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg *dest = nws; *fill_dest = true; nws->SetIndex(nwid_begin->u.widget.index); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); break; } @@ -3291,7 +3280,6 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg if (*dest != nullptr) return nwid_begin; assert((nwid_begin->type & WWT_MASK) < WWT_LAST || (nwid_begin->type & WWT_MASK) == NWID_BUTTON_DROPDOWN); *dest = new NWidgetLeaf(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index, 0x0, STR_NULL); - *biggest_index = std::max(*biggest_index, (int)nwid_begin->u.widget.index); break; } nwid_begin++; @@ -3316,11 +3304,9 @@ bool IsContainerWidgetType(WidgetType tp) * @param nwid_begin Pointer to beginning of nested widget parts. * @param nwid_end Pointer to ending of nested widget parts. * @param parent Pointer or container to use for storing the child widgets (*parent == nullptr or *parent == container or background widget). - * @param biggest_index Pointer to biggest nested widget index in the tree. * @return Pointer to remaining nested widget parts. - * @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used. */ -static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **parent, int *biggest_index) +static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **parent) { /* If *parent == nullptr, only the first widget is read and returned. Otherwise, *parent must point to either * a #NWidgetContainer or a #NWidgetBackground object, and parts are added as much as possible. */ @@ -3331,7 +3317,7 @@ static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NW for (;;) { NWidgetBase *sub_widget = nullptr; bool fill_sub = false; - nwid_begin = MakeNWidget(nwid_begin, nwid_end, &sub_widget, &fill_sub, biggest_index); + nwid_begin = MakeNWidget(nwid_begin, nwid_end, &sub_widget, &fill_sub); /* Break out of loop when end reached */ if (sub_widget == nullptr) break; @@ -3339,7 +3325,7 @@ static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NW /* If sub-widget is a container, recursively fill that container. */ if (fill_sub && IsContainerWidgetType(sub_widget->type)) { NWidgetBase *sub_ptr = sub_widget; - nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, &sub_ptr, biggest_index); + nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, &sub_ptr); } /* Add sub_widget to parent container if available, otherwise return the widget to the caller. */ @@ -3362,19 +3348,15 @@ static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NW * Construct a nested widget tree from an array of parts. * @param nwid_begin Pointer to beginning of nested widget parts. * @param nwid_end Pointer to ending of nested widget parts. - * @param biggest_index Pointer to biggest nested widget index collected in the tree. * @param container Container to add the nested widgets to. In case it is nullptr a vertical container is used. * @return Root of the nested widget tree, a vertical container containing the entire GUI. * @ingroup NestedWidgetParts - * @pre \c biggest_index != nullptr - * @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used. */ -NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetContainer *container) +NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetContainer *container) { - *biggest_index = -1; if (container == nullptr) container = new NWidgetVertical(); NWidgetBase *cont_ptr = container; - [[maybe_unused]] const NWidgetPart *nwid_part = MakeWidgetTree(nwid_begin, nwid_end, &cont_ptr, biggest_index); + [[maybe_unused]] const NWidgetPart *nwid_part = MakeWidgetTree(nwid_begin, nwid_end, &cont_ptr); #ifdef WITH_ASSERT if (unlikely(nwid_part != nwid_end)) throw std::runtime_error("Did not consume all NWidgetParts"); #endif @@ -3387,20 +3369,15 @@ NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart * container with a caption widget) and has a shade box widget. * @param nwid_begin Pointer to beginning of nested widget parts. * @param nwid_end Pointer to ending of nested widget parts. - * @param biggest_index Pointer to biggest nested widget index collected in the tree. * @param[out] shade_select Pointer to the inserted shade selection widget (\c nullptr if not unserted). * @return Root of the nested widget tree, a vertical container containing the entire GUI. * @ingroup NestedWidgetParts - * @pre \c biggest_index != nullptr - * @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used. */ -NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetStacked **shade_select) +NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetStacked **shade_select) { - *biggest_index = -1; - /* Read the first widget recursively from the array. */ NWidgetBase *nwid = nullptr; - nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, &nwid, biggest_index); + nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, &nwid); assert(nwid != nullptr); NWidgetContainer *root = new NWidgetVertical; @@ -3425,25 +3402,21 @@ NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWi } /* Load the remaining parts into 'body'. */ - int biggest2 = -1; - MakeNWidgets(nwid_begin, nwid_end, &biggest2, body); + MakeNWidgets(nwid_begin, nwid_end, body); - *biggest_index = std::max(*biggest_index, biggest2); return root; } /** * Make a number of rows with button-like graphics, for enabling/disabling each company. - * @param biggest_index Storage for collecting the biggest index used in the returned tree. * @param widget_first The first widget index to use. * @param widget_last The last widget index to use. * @param colour The colour in which to draw the button. * @param max_length Maximal number of company buttons in one row. * @param button_tooltip The tooltip-string of every button. * @return Panel with rows of company buttons. - * @post \c *biggest_index contains the largest used index in the tree. */ -NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip) +NWidgetBase *MakeCompanyButtonRows(int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip) { assert(max_length >= 1); NWidgetVertical *vert = nullptr; // Storage for all rows. @@ -3475,7 +3448,6 @@ NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int wid hor->Add(panel); hor_length++; } - *biggest_index = widget_last; if (vert == nullptr) return hor; // All buttons fit in a single row. if (hor_length > 0 && hor_length < max_length) { diff --git a/src/widget_type.h b/src/widget_type.h index ae9da95634..3082d6be42 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -47,7 +47,7 @@ enum ResizeWidgetValues { */ enum WidgetType { /* Window widget types. */ - WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget array + WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget tree. WWT_PANEL, ///< Simple depressed panel WWT_INSET, ///< Pressed (inset) panel, most commonly used as combo box _text_ area @@ -122,6 +122,9 @@ enum SizingType { class NWidgetCore; class Scrollbar; +/** Lookup between widget IDs and NWidget objects. */ +using WidgetLookup = std::map; + /** * Baseclass for nested widgets. * @invariant After initialization, \f$current\_x = smallest\_x + n * resize\_x, for n \geq 0\f$. @@ -136,7 +139,7 @@ public: virtual void SetupSmallestSize(Window *w) = 0; virtual void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) = 0; - virtual void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) = 0; + virtual void FillWidgetLookup(WidgetLookup &widget_lookup) = 0; virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0; virtual NWidgetBase *GetWidgetOfType(WidgetType tp); @@ -337,7 +340,7 @@ public: inline void SetDisabled(bool disabled); inline bool IsDisabled() const; - void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; + void FillWidgetLookup(WidgetLookup &widget_lookup) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; bool IsHighlighted() const override; TextColour GetHighlightColour() const override; @@ -345,7 +348,7 @@ 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 in the widget array of the window (\c -1 means 'not used'). + int 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. @@ -419,7 +422,7 @@ public: void AdjustPaddingForZoom() override; void Add(NWidgetBase *wid); - void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; + void FillWidgetLookup(WidgetLookup &widget_lookup) override; void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; @@ -462,7 +465,7 @@ public: void AdjustPaddingForZoom() override; void SetupSmallestSize(Window *w) override; void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; - void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; + void FillWidgetLookup(WidgetLookup &widget_lookup) override; void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; @@ -564,7 +567,7 @@ public: void SetupSmallestSize(Window *w) override; void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; - void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; + void FillWidgetLookup(WidgetLookup &widget_lookup) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; void Draw(const Window *w) override; @@ -593,7 +596,7 @@ public: NWidgetSpacer(int width, int height); void SetupSmallestSize(Window *w) override; - void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; + void FillWidgetLookup(WidgetLookup &widget_lookup) override; void Draw(const Window *w) override; void SetDirty(const Window *w) const override; @@ -617,7 +620,7 @@ public: void SetupSmallestSize(Window *w) override; void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; - void FillWidgetLookup(NWidgetBase **widget_lookup, uint length) override; + void FillWidgetLookup(WidgetLookup &widget_lookup) override; void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; @@ -955,7 +958,7 @@ struct NWidgetPartDataTip { */ struct NWidgetPartWidget { Colours colour; ///< Widget colour. - int16_t index; ///< Widget index in the widget array. + int16_t index; ///< Index of the widget. }; /** @@ -1002,11 +1005,9 @@ struct NWidgetPartAlignment { /** * Pointer to function returning a nested widget. - * @param biggest_index Pointer to storage for collecting the biggest index used in the nested widget. * @return Nested widget (tree). - * @post \c *biggest_index must contain the value of the biggest index in the returned tree. */ -typedef NWidgetBase *NWidgetFunctionType(int *biggest_index); +typedef NWidgetBase *NWidgetFunctionType(); /** * Partial widget specification to allow NWidgets to be written nested. @@ -1282,7 +1283,7 @@ static inline NWidgetPart SetScrollbar(int index) * Widget part function for starting a new 'real' widget. * @param tp Type of the new nested widget. * @param col Colour of the new widget. - * @param idx Index of the widget in the widget array. + * @param idx Index of the widget. * @note with #WWT_PANEL, #WWT_FRAME, #WWT_INSET, a new container is started. * Child widgets must have a index bigger than the parent index. * @ingroup NestedWidgetParts @@ -1330,10 +1331,10 @@ static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr) } bool IsContainerWidgetType(WidgetType tp); -NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetContainer *container); -NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, int *biggest_index, NWidgetStacked **shade_select); +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 *biggest_index, int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip); +NWidgetBase *MakeCompanyButtonRows(int widget_first, int widget_last, Colours button_colour, int max_length, StringID button_tooltip); void SetupWidgetDimensions(); diff --git a/src/window.cpp b/src/window.cpp index 40edb5d77c..075b29c767 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -224,10 +224,8 @@ int Window::GetRowFromWidget(int clickpos, int widget, int padding, int line_hei */ void Window::DisableAllWidgetHighlight() { - for (uint i = 0; i < this->nested_array_size; i++) { - NWidgetBase *nwid = this->GetWidget(i); - if (nwid == nullptr) continue; - + for (auto &pair : this->widget_lookup) { + NWidgetBase *nwid = pair.second; if (nwid->IsHighlighted()) { nwid->SetHighlighted(TC_INVALID); nwid->SetDirty(this); @@ -244,8 +242,6 @@ void Window::DisableAllWidgetHighlight() */ void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour) { - assert(widget_index < this->nested_array_size); - NWidgetBase *nwid = this->GetWidget(widget_index); if (nwid == nullptr) return; @@ -258,9 +254,8 @@ void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour } else { /* If we disable a highlight, check all widgets if anyone still has a highlight */ bool valid = false; - for (uint i = 0; i < this->nested_array_size; i++) { - nwid = this->GetWidget(i); - if (nwid == nullptr) continue; + for (const auto &pair : this->widget_lookup) { + nwid = pair.second; if (!nwid->IsHighlighted()) continue; valid = true; @@ -277,8 +272,6 @@ void Window::SetWidgetHighlight(byte widget_index, TextColour highlighted_colour */ bool Window::IsWidgetHighlighted(byte widget_index) const { - assert(widget_index < this->nested_array_size); - const NWidgetBase *nwid = this->GetWidget(widget_index); if (nwid == nullptr) return false; @@ -493,18 +486,19 @@ void Window::UnfocusFocusedWidget() */ bool Window::SetFocusedWidget(int widget_index) { - /* Do nothing if widget_index is already focused, or if it wasn't a valid widget. */ - if ((uint)widget_index >= this->nested_array_size) return false; + NWidgetCore *widget = this->GetWidget(widget_index); + assert(widget != nullptr); /* Setting focus to a non-existing widget is a bad idea. */ - assert(this->widget_lookup[widget_index] != nullptr); // Setting focus to a non-existing widget is a bad idea. if (this->nested_focus != nullptr) { - if (this->GetWidget(widget_index) == this->nested_focus) return false; + /* Do nothing if widget_index is already focused. */ + if (widget == this->nested_focus) return false; /* Repaint the widget that lost focus. A focused edit box may else leave the caret on the screen. */ this->nested_focus->SetDirty(this); if (this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxLostFocus(); } - this->nested_focus = this->GetWidget(widget_index); + + this->nested_focus = widget; if (this->nested_focus->type == WWT_EDITBOX) VideoDriver::GetInstance()->EditBoxGainedFocus(); return true; } @@ -531,21 +525,23 @@ void Window::OnFocusLost(bool) */ void Window::RaiseButtons(bool autoraise) { - for (uint i = 0; i < this->nested_array_size; i++) { - if (this->widget_lookup[i] == nullptr) continue; - WidgetType type = this->widget_lookup[i]->type; + for (auto &pair : this->widget_lookup) { + WidgetType type = pair.second->type; + NWidgetCore *wid = dynamic_cast(pair.second); if (((type & ~WWB_PUSHBUTTON) < WWT_LAST || type == NWID_PUSHBUTTON_DROPDOWN) && - (!autoraise || (type & WWB_PUSHBUTTON) || type == WWT_EDITBOX) && this->IsWidgetLowered(i)) { - this->RaiseWidget(i); - this->SetWidgetDirty(i); + (!autoraise || (type & WWB_PUSHBUTTON) || type == WWT_EDITBOX) && wid->IsLowered()) { + wid->SetLowered(false); + wid->SetDirty(this); } } /* Special widgets without widget index */ - NWidgetCore *wid = this->nested_root != nullptr ? (NWidgetCore*)this->nested_root->GetWidgetOfType(WWT_DEFSIZEBOX) : nullptr; - if (wid != nullptr) { - wid->SetLowered(false); - wid->SetDirty(this); + { + NWidgetCore *wid = this->nested_root != nullptr ? dynamic_cast(this->nested_root->GetWidgetOfType(WWT_DEFSIZEBOX)) : nullptr; + if (wid != nullptr) { + wid->SetLowered(false); + wid->SetDirty(this); + } } } @@ -556,9 +552,10 @@ void Window::RaiseButtons(bool autoraise) void Window::SetWidgetDirty(byte widget_index) const { /* Sometimes this function is called before the window is even fully initialized */ - if (this->widget_lookup == nullptr) return; + auto it = this->widget_lookup.find(widget_index); + if (it == std::end(this->widget_lookup)) return; - this->widget_lookup[widget_index]->SetDirty(this); + it->second->SetDirty(this); } /** @@ -635,7 +632,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) /* Clicked on a widget that is not disabled. * So unless the clicked widget is the caption bar, change focus to this widget. * Exception: In the OSK we always want the editbox to stay focused. */ - if (widget_type != WWT_CAPTION && w->window_class != WC_OSK) { + if (widget_index >= 0 && widget_type != WWT_CAPTION && w->window_class != WC_OSK) { /* focused_widget_changed is 'now' only true if the window this widget * is in gained focus. In that case it must remain true, also if the * local widget focus did not change. As such it's the logical-or of @@ -1091,8 +1088,6 @@ Window::~Window() assert(*this->z_position == nullptr); if (this->viewport != nullptr) DeleteWindowViewport(this); - - free(this->widget_lookup); // Contents is released through deletion of #nested_root. delete this->nested_root; } @@ -1729,12 +1724,8 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16_t sm_width, i */ void Window::CreateNestedTree() { - int biggest_index = -1; - this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_begin, this->window_desc->nwid_end, &biggest_index, &this->shade_select); - this->nested_array_size = (uint)(biggest_index + 1); - - this->widget_lookup = CallocT(this->nested_array_size); - this->nested_root->FillWidgetLookup(this->widget_lookup, this->nested_array_size); + this->nested_root = MakeWindowNWidgetTree(this->window_desc->nwid_begin, this->window_desc->nwid_end, &this->shade_select); + this->nested_root->FillWidgetLookup(this->widget_lookup); } /** @@ -1840,9 +1831,9 @@ static void DecreaseWindowCounters() for (Window *w : Window::Iterate()) { if (_scroller_click_timeout == 0) { /* Unclick scrollbar buttons if they are pressed. */ - for (uint i = 0; i < w->nested_array_size; i++) { - NWidgetBase *nwid = w->widget_lookup[i]; - if (nwid != nullptr && (nwid->type == NWID_HSCROLLBAR || nwid->type == NWID_VSCROLLBAR)) { + for (auto &pair : w->widget_lookup) { + NWidgetBase *nwid = pair.second; + if (nwid->type == NWID_HSCROLLBAR || nwid->type == NWID_VSCROLLBAR) { NWidgetScrollbar *sb = static_cast(nwid); if (sb->disp_flags & (ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN)) { sb->disp_flags &= ~(ND_SCROLLBAR_UP | ND_SCROLLBAR_DOWN); @@ -3155,8 +3146,8 @@ void Window::ProcessHighlightedInvalidations() { if ((this->flags & WF_HIGHLIGHTED) == 0) return; - for (uint i = 0; i < this->nested_array_size; i++) { - if (this->IsWidgetHighlighted(i)) this->SetWidgetDirty(i); + for (const auto &pair : this->widget_lookup) { + if (pair.second->IsHighlighted()) pair.second->SetDirty(this); } } diff --git a/src/window_gui.h b/src/window_gui.h index 93414a3402..9ac8e81de9 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -260,8 +260,7 @@ public: const NWidgetCore *nested_focus; ///< Currently focused nested widget, or \c nullptr if no nested widget has focus. std::map querystrings; ///< QueryString associated to WWT_EDITBOX widgets. NWidgetBase *nested_root; ///< Root of the nested tree. - NWidgetBase **widget_lookup; ///< Array of pointers into the tree. Do not access directly, use #Window::GetWidget() instead. - uint nested_array_size; ///< Size of the nested array. + WidgetLookup widget_lookup; ///< Indexed access to the nested widget tree. Do not access directly, use #Window::GetWidget() instead. 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). @@ -328,8 +327,7 @@ public: */ inline void SetWidgetDisabledState(byte widget_index, bool disab_stat) { - assert(widget_index < this->nested_array_size); - if (this->widget_lookup[widget_index] != nullptr) this->GetWidget(widget_index)->SetDisabled(disab_stat); + this->GetWidget(widget_index)->SetDisabled(disab_stat); } /** @@ -357,7 +355,6 @@ public: */ inline bool IsWidgetDisabled(byte widget_index) const { - assert(widget_index < this->nested_array_size); return this->GetWidget(widget_index)->IsDisabled(); } @@ -389,7 +386,6 @@ public: */ inline void SetWidgetLoweredState(byte widget_index, bool lowered_stat) { - assert(widget_index < this->nested_array_size); this->GetWidget(widget_index)->SetLowered(lowered_stat); } @@ -399,7 +395,6 @@ public: */ inline void ToggleWidgetLoweredState(byte widget_index) { - assert(widget_index < this->nested_array_size); bool lowered_state = this->GetWidget(widget_index)->IsLowered(); this->GetWidget(widget_index)->SetLowered(!lowered_state); } @@ -441,7 +436,6 @@ public: */ inline bool IsWidgetLowered(byte widget_index) const { - assert(widget_index < this->nested_array_size); return this->GetWidget(widget_index)->IsLowered(); } @@ -894,8 +888,9 @@ inline bool AllEqual(It begin, It end, Pred pred) template inline NWID *Window::GetWidget(uint widnum) { - if (widnum >= this->nested_array_size || this->widget_lookup[widnum] == nullptr) return nullptr; - NWID *nwid = dynamic_cast(this->widget_lookup[widnum]); + auto it = this->widget_lookup.find(widnum); + if (it == std::end(this->widget_lookup)) return nullptr; + NWID *nwid = dynamic_cast(it->second); assert(nwid != nullptr); return nwid; } @@ -904,8 +899,9 @@ inline NWID *Window::GetWidget(uint widnum) template <> inline const NWidgetBase *Window::GetWidget(uint widnum) const { - if (widnum >= this->nested_array_size) return nullptr; - return this->widget_lookup[widnum]; + auto it = this->widget_lookup.find(widnum); + if (it == std::end(this->widget_lookup)) return nullptr; + return it->second; } /** From fd84f733236e6288d7b4b007eb976753c0ae19e2 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 00:19:27 +0000 Subject: [PATCH 04/29] Fix #11643: Empty area at top of survey preview. (#11647) Empty area at the top of some textfile windows due to calling SetDisplayedPlane() after calling FinishInitNested(), and/or changing the displayed plane and not calling ReInit() after. This was previously hidden by CheckForMissingGlyphs() reinitialising all windows anyway. --- src/help_gui.cpp | 2 +- src/textfile_gui.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/help_gui.cpp b/src/help_gui.cpp index ea318dbda7..2664d79458 100644 --- a/src/help_gui.cpp +++ b/src/help_gui.cpp @@ -85,7 +85,7 @@ struct GameManualTextfileWindow : public TextfileWindow { if (this->filename == CHANGELOG_FILENAME) { this->link_anchors.clear(); this->AfterLoadChangelog(); - this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0); + if (this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0)) this->ReInit(); } else { this->TextfileWindow::AfterLoadText(); } diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 578ac7924a..cebfc38eac 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -86,9 +86,9 @@ TextfileWindow::TextfileWindow(TextfileType file_type) : Window(&_textfile_desc) this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_TF_VSCROLLBAR); this->hscroll = this->GetScrollbar(WID_TF_HSCROLLBAR); - this->FinishInitNested(file_type); this->GetWidget(WID_TF_CAPTION)->SetDataTip(STR_TEXTFILE_README_CAPTION + file_type, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS); this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL); + this->FinishInitNested(file_type); this->DisableWidget(WID_TF_NAVBACK); this->DisableWidget(WID_TF_NAVFORWARD); @@ -493,7 +493,7 @@ void TextfileWindow::NavigateToFile(std::string newfile, size_t line) if (StrEndsWithIgnoreCase(this->filename, ".md")) this->AfterLoadMarkdown(); - this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0); + if (this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(this->jumplist.empty() ? SZSP_HORIZONTAL : 0)) this->ReInit(); } /** @@ -761,8 +761,7 @@ static void Xunzip(byte **bufp, size_t *sizep) this->lines.clear(); this->jumplist.clear(); - this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL); - this->ReInit(); + if (this->GetWidget(WID_TF_SEL_JUMPLIST)->SetDisplayedPlane(SZSP_HORIZONTAL)) this->ReInit(); if (textfile.empty()) return; From a0dfb76e34785d619ea2282aaf6212a52328d664 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 29 Dec 2023 19:11:59 +0000 Subject: [PATCH 05/29] Codechange: Replace mishmash of types for widget index with WidgetID. Indices were stored as int, but often passed around as uint/uint8_t and casts. Now they should all use WidgetID. --- src/ai/ai_gui.cpp | 8 +-- src/airport_gui.cpp | 12 ++-- src/autoreplace_gui.cpp | 12 ++-- src/bootstrap_gui.cpp | 14 ++--- src/bridge_gui.cpp | 8 +-- src/build_vehicle_gui.cpp | 12 ++-- src/cheat_gui.cpp | 6 +- src/company_gui.cpp | 50 +++++++-------- src/console_gui.cpp | 2 +- src/date_gui.cpp | 10 +-- src/depot_gui.cpp | 16 ++--- src/dock_gui.cpp | 10 +-- src/engine_gui.cpp | 6 +- src/error_gui.cpp | 6 +- src/fios_gui.cpp | 10 +-- src/framerate_gui.cpp | 14 ++--- src/game/game_gui.cpp | 10 +-- src/genworld_gui.cpp | 26 ++++---- src/goal_gui.cpp | 14 ++--- src/graph_gui.cpp | 32 +++++----- src/group_gui.cpp | 18 +++--- src/help_gui.cpp | 4 +- src/highscore_gui.cpp | 2 +- src/industry_gui.cpp | 38 ++++++------ src/intro_gui.cpp | 6 +- src/league_gui.cpp | 12 ++-- src/linkgraph/linkgraph_gui.cpp | 8 +-- src/linkgraph/linkgraph_gui.h | 12 ++-- src/main_gui.cpp | 4 +- src/misc_gui.cpp | 44 +++++++------- src/music_gui.cpp | 16 ++--- src/network/network_chat_gui.cpp | 6 +- src/network/network_content_gui.cpp | 16 ++--- src/network/network_content_gui.h | 4 +- src/network/network_gui.cpp | 62 +++++++++---------- src/newgrf_debug_gui.cpp | 16 ++--- src/newgrf_gui.cpp | 40 ++++++------ src/news_gui.cpp | 16 ++--- src/object_gui.cpp | 10 +-- src/order_gui.cpp | 14 ++--- src/osk_gui.cpp | 26 ++++---- src/querystring_gui.h | 18 +++--- src/rail_gui.cpp | 44 +++++++------- src/road_gui.cpp | 28 +++++---- src/screenshot_gui.cpp | 2 +- src/script/api/script_event_types.hpp | 8 +-- src/script/script_gui.cpp | 34 +++++------ src/settings_gui.cpp | 40 ++++++------ src/signs_gui.cpp | 14 ++--- src/smallmap_gui.cpp | 10 +-- src/station_gui.cpp | 28 ++++----- src/statusbar_gui.cpp | 6 +- src/story_gui.cpp | 10 +-- src/subsidy_gui.cpp | 6 +- src/terraform_gui.cpp | 8 +-- src/textfile_gui.cpp | 8 +-- src/textfile_gui.h | 8 +-- src/tilehighlight_func.h | 2 +- src/timetable_gui.cpp | 8 +-- src/toolbar_gui.cpp | 70 ++++++++++----------- src/town_gui.cpp | 34 +++++------ src/transparency_gui.cpp | 10 +-- src/tree_gui.cpp | 6 +- src/vehicle_gui.cpp | 42 ++++++------- src/viewport.cpp | 2 +- src/viewport_func.h | 2 +- src/viewport_gui.cpp | 6 +- src/waypoint_gui.cpp | 4 +- src/widget.cpp | 26 ++++---- src/widget_type.h | 38 ++++++------ src/widgets/dropdown.cpp | 16 ++--- src/widgets/dropdown_func.h | 2 +- src/widgets/dropdown_type.h | 4 +- src/window.cpp | 30 ++++----- src/window_func.h | 2 +- src/window_gui.h | 88 +++++++++++++-------------- src/window_type.h | 7 +++ 77 files changed, 666 insertions(+), 657 deletions(-) diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 31dd2d1b4f..2a78ce04bb 100644 --- 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 index a19cfc03db..aa6b0f5e1e 100644 --- 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 index b6ff9f6674..1c097fd9a9 100644 --- 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 index 03f64de705..b3eac7456a 100644 --- 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 index ded870fa12..f671a8f4db 100644 --- 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 index 1398b6c280..10f27330d0 100644 --- 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 index 93e6b61623..cd6be9d21d 100644 --- 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 index a19430b3b6..17f6fdac97 100644 --- 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 : public Window * @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 : Window 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 : 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 { const Company *c = Company::Get((CompanyID)this->window_number); @@ -2012,7 +2012,7 @@ struct CompanyInfrastructureWindow : 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); @@ -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 index 6ac256100c..412efe0d3e 100644 --- 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 index f928345a43..6a43a73fbb 100644 --- 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 index 43bd17f4a3..999cdd41bf 100644 --- 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 index 3997fd74c6..518481c510 100644 --- 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 index f5a969788d..97b3bd4be4 100644 --- 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 index 007094ca75..b47d8f056e 100644 --- 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 index fb140bb138..e2fb4d3491 100644 --- 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 index 4406b97879..c82e90f5a8 100644 --- 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 index 8dfd319407..08afc3a795 100644 --- 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 index 1d99ed1c93..44c295784d 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -384,7 +384,7 @@ static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, 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 Window { } - 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 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 { Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)}; const StringID *strs = nullptr; @@ -669,7 +669,7 @@ struct GenerateLandscapeWindow : public Window { *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 Window { } } - 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 seed) 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 Window 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 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 { StringID str = STR_JUST_INT; switch (widget) { @@ -1153,7 +1153,7 @@ struct CreateScenarioWindow : public Window *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 Window 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 Window { 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 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_GP_PROGRESS_BAR: { @@ -1425,7 +1425,7 @@ struct GenerateProgressWindow : public Window { } } - 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 index 487ba146e9..db39c84f25 100644 --- 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 Window { } - 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 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_GQ_BUTTON_1: @@ -388,7 +388,7 @@ struct GoalQuestionWindow : 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_GQ_QUESTION) return; @@ -396,7 +396,7 @@ struct GoalQuestionWindow : public Window { 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 index ec311a8cc7..20186a6080 100644 --- 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 *MakeNWidgetCompanyLines() 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 : BaseGraphWindow { 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 : BaseGraphWindow { } } - 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 : BaseGraphWindow { 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 : BaseGraphWindow { } } - 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 : Window { 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 : Window { } } - 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 : 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 { /* Check which button is clicked */ if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) { @@ -1355,7 +1355,7 @@ static NWidgetBase *MakePerformanceDetailPanels() 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 index 56c46adf11..f4ad3a032e 100644 --- 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 index 2664d79458..60fde1db92 100644 --- a/src/help_gui.cpp +++ b/src/help_gui.cpp @@ -73,7 +73,7 @@ struct GameManualTextfileWindow : public TextfileWindow { 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 index 3fedda84ca..c93e073f44 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -65,7 +65,7 @@ struct EndGameHighScoreBaseWindow : Window { 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 index 73f4aeee6b..51a271da56 100644 --- 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 Window { 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 Window { 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 Window { 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 Window { 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 Window { } } - 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 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_IC_PANEL) return false; diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 954615570b..472f241453 100644 --- 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 index e113c29613..500ccce085 100644 --- 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 index 0c37ec59b8..ad3661b44e 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -582,7 +582,7 @@ void LinkGraphLegendWindow::SetOverlay(std::shared_ptr overlay } } -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::UpdateWidgetSize(int widget, Dimension *size, [[mayb } } -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(const Rect &r, int widget) const } } -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::UpdateOverlayCargoes() 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 index db2300e8f7..9e2d064285 100644 --- 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 index 9f35dfeade..7be47653b3 100644 --- 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 index d2367c67b0..1b4794abb4 100644 --- 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, StringID str, TooltipCloseCondition close_t 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 Window *w, int wid) const * @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(const Window *w, int wid) const * @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 Window *w, int wid, const char *from, co * @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(const Window *w, int wid, const Point & 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 index ebbc4ddf7b..ffe15319a6 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -486,7 +486,7 @@ struct MusicTrackSelectionWindow : public Window { 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 : 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_MTS_PLAYLIST: { @@ -553,7 +553,7 @@ struct MusicTrackSelectionWindow : public Window { } } - 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 : 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_MTS_LIST_LEFT: { // add to playlist @@ -618,7 +618,7 @@ struct MusicTrackSelectionWindow : public Window { } } - 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 index bab250f482..8b4bfd7b04 100644 --- 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 index cfbd160222..e90d0daeb7 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -64,7 +64,7 @@ struct ContentTextfileWindow : public TextfileWindow { } } - 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 BaseNetworkContentDownloadStatusWindow::Close([[maybe_unused]] int data) 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 BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(int widget, Dimens } } -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 index 75d9b21d4f..5af46a59aa 100644 --- 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 index 123626764d..bef7637ef4 100644 --- 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 Window { 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 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_NSS_CONNTYPE_BTN: @@ -1004,7 +1004,7 @@ struct NetworkStartServerWindow : public Window { } } - 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 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_NSS_CANCEL: // Cancel button @@ -1091,7 +1091,7 @@ struct NetworkStartServerWindow : public Window { } } - 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 : 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_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 : public Window { 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 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_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 Window { 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 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_NAR_NO: @@ -2457,14 +2457,14 @@ struct NetworkAskSurveyWindow : public Window { 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 Window { 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 index 4edac598f0..c64f58549a 100644 --- 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 index 583f4206a5..fd9dd69f87 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -210,7 +210,7 @@ struct NewGRFParametersWindow : public Window { 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 Window { } } - 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 Window { } } - 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 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_NP_NUMPAR_DEC: @@ -453,7 +453,7 @@ struct NewGRFParametersWindow : public Window { 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 Window { 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 TextfileWindow { 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, NewGRFScanCallback { } } - 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, NewGRFScanCallback { 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, NewGRFScanCallback { 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, NewGRFScanCallback { } } - 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, NewGRFScanCallback { 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, NewGRFScanCallback { 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, NewGRFScanCallback { } } - 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, NewGRFScanCallback { } } - 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 Window { 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 Window { } } - 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 index 2773e6ea53..0bc8caf012 100644 --- 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 index 084cd0caed..0976af70af 100644 --- 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 index aca85ecd4d..dc0ddb1ff0 100644 --- 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 index 9051484454..627e264138 100644 --- 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; // Vertical padding for remaining key rows * @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, int button) * @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 *parent, int button) * @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 index fd440a3449..39cabb7fbd 100644 --- 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 index c655852820..31644321a5 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -306,7 +306,7 @@ static bool RailToolbar_CtrlChanged(Window *w) 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 PickerWindowBase { 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 PickerWindowBase { 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 PickerWindowBase { } } - 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 : PickerWindowBase { } } - 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 : PickerWindowBase { } } - 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 : PickerWindowBase { 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 : PickerWindowBase { } } - 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 : PickerWindowBase { 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 index 1364a0c94a..c83307c141 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -294,7 +294,7 @@ static bool RoadToolbar_CtrlChanged(Window *w) 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 PickerWindowBase { 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 PickerWindowBase { 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 PickerWindowBase { } } - 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 index bcc74baa75..2d92c6ca4d 100644 --- 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 index 4496b3a310..da9cdf3a6d 100644 --- 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 index 195fab5a24..f89e7f3f59 100644 --- 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 Window { 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 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 { if (widget != WID_SCRS_BACKGROUND) return; @@ -421,7 +421,7 @@ struct ScriptSettingsWindow : 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 { switch (widget) { case WID_SCRS_BACKGROUND: { @@ -524,14 +524,14 @@ struct ScriptSettingsWindow : public Window { 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 TextfileWindow { 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 index b6d9a9118d..8bd0f82fb3 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -96,7 +96,7 @@ struct BaseSetTextfileWindow : public TextfileWindow { 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 index f5ebdb9e8f..a22da119c7 100644 --- 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 index b6befbbe7d..85012d66c1 100644 --- 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 index c48ca4b4b5..036bb665e1 100644 --- 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 index 9d8bc32e4d..f892080454 100644 --- 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 index 81c8517f36..a3232194ca 100644 --- 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 index 68837bb6b2..8cf07ef253 100644 --- 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 index 3eff82f29d..ed395d0491 100644 --- 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 ScenarioEditorLandscapeGenerationWindow : 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_ETT_DOTS) return; @@ -561,7 +561,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { 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 ScenarioEditorLandscapeGenerationWindow : Window { } 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 index cebfc38eac..710ab3b526 100644 --- 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 index 119b0b6081..f5445025c1 100644 --- a/src/textfile_gui.h +++ b/src/textfile_gui.h @@ -25,12 +25,12 @@ struct TextfileWindow : public Window, MissingGlyphSearcher { 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 index c980931d7d..572c5bd43e 100644 --- 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 index be8941187e..c01689e242 100644 --- 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 index a880362a3b..2b3f12417a 100644 --- 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 *w, int widget, DropDownList &&list, int * @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; ///< Show a company window as spectator * @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(int index) 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 ToolbarZoomInClick(Window *w) 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(int index) 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 PlaceLandBlockInfo() 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 ToolbarSwitchClick(Window *w) } 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 : public NWidgetToolbarContainer { * 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 : public NWidgetToolbarContainer { 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 : public NWidgetToolbarContainer { 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 : public NWidgetToolbarContainer { 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 : public NWidgetToolbarContainer { 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 : public NWidgetToolbarContainer { 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 : public NWidgetToolbarContainer { 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 : public NWidgetToolbarContainer { 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 : public NWidgetToolbarContainer { } /* 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 : 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 byte arrange_all[] = { + static const WidgetID arrange_all[] = { WID_TE_PAUSE, WID_TE_FAST_FORWARD, WID_TE_SETTINGS, @@ -1815,7 +1815,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer { 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 : public NWidgetToolbarContainer { 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 : Window { 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 : Window { } } - 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 : 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_TE_SPACER: @@ -2335,14 +2335,14 @@ struct ScenarioEditorToolbarWindow : 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 (_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 index dddfc6d81f..1455d95e21 100644 --- 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 index 5f1bbabbdf..4029125d38 100644 --- 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 index 91770b73c4..448df9a797 100644 --- 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 index de7bdb479a..a135557cc2 100644 --- 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 index 797f16aaae..7179846b44 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -488,7 +488,7 @@ Point GetTileZoomCenterWindow(bool in, Window * 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 index a9111c4375..0367c44ffb 100644 --- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -35,7 +35,7 @@ void ZoomInOrOutToCursorWindow(bool in, Window * w); 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 index ccf02c31fc..19a4e34888 100644 --- 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 index 071d8bb37c..ba930c2606 100644 --- 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 index 72ed790edf..1517fb8a2f 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -402,7 +402,7 @@ void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y) * @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, Colours colour, uint fill_x, uint fill_y * 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() : NWidgetContainer(NWID_SELECTION) this->index = -1; } -void NWidgetStacked::SetIndex(int index) +void NWidgetStacked::SetIndex(WidgetID index) { this->index = index; } @@ -1954,7 +1954,7 @@ NWidgetMatrix::NWidgetMatrix() : NWidgetPIPContainer(NWID_MATRIX, NC_EQUALSIZE), { } -void NWidgetMatrix::SetIndex(int index) +void NWidgetMatrix::SetIndex(WidgetID index) { this->index = index; } @@ -2189,7 +2189,7 @@ void NWidgetMatrix::GetScrollOffsets(int &start_x, int &start_y, int &base_offs_ * 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::GetWidgetOfType(WidgetType tp) 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::UpdateViewportCoordinates(Window *w) * @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::UpdateListPositionOnKeyPress(int &list_position, uint16_t * @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(Window *w, int widget, int padding) * @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_dimension = {0, 0}; * @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(const NWidgetPart *nwid_begin, const NWi * @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 widget_first, int widget_last, Colours bu 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 index 3082d6be42..10b2360bd4 100644 --- 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 NWidgetResizeBase { 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 NWidgetContainer { 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 NWidgetPIPContainer { 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(uint8_t ratio_pre, uint8_t ratio_inter, 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(int index) * 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 index b60117fa7d..93266c40b8 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -40,7 +40,7 @@ static WindowDesc _dropdown_desc(__FILE__, __LINE__, /** 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 DropDownList &list) * @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, DropDownList &&list, int selected, int button * @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, DropDownList &&list, int selected, int button, * @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 index 88b0053c9d..7cc10f56f2 100644 --- 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 index 8ca6472c2d..2a079b5e73 100644 --- a/src/widgets/dropdown_type.h +++ b/src/widgets/dropdown_type.h @@ -209,9 +209,9 @@ using DropDownListCheckedItem = DropDownCheck>; */ 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 index 075b29c767..ebe91b007b 100644 --- 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 widget_index, TextColour highlighted_colour * @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 widget_index) const * @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, int widget, int index, bool instant_close * @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(uint widnum) const * @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 widnum) * @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::GetQueryString(uint widnum) const * @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(Window *w, int x, int y, int click_count) /* 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(Window *w) * @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, WindowNumber number) * @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 index 8cc02153ee..da798aa4e9 100644 --- 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 index 9ac8e81de9..69ecaf068a 100644 --- 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, Pred pred) * @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 widnum) /** 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::GetWidget(uint widnum) const * @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 newh); 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 index e546c405ad..9e4d96acbd 100644 --- 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. From 268e512fb8d3275c09ed53a817feab09551169c7 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 29 Dec 2023 21:15:25 +0000 Subject: [PATCH 06/29] Codechange: Set storage type of widget enums to WidgetID. --- src/widgets/ai_widget.h | 2 +- src/widgets/airport_widget.h | 4 ++-- src/widgets/autoreplace_widget.h | 2 +- src/widgets/bootstrap_widget.h | 6 +++--- src/widgets/bridge_widget.h | 2 +- src/widgets/build_vehicle_widget.h | 2 +- src/widgets/cheat_widget.h | 2 +- src/widgets/company_widget.h | 12 ++++++------ src/widgets/console_widget.h | 2 +- src/widgets/date_widget.h | 2 +- src/widgets/depot_widget.h | 2 +- src/widgets/dock_widget.h | 4 ++-- src/widgets/dropdown_widget.h | 2 +- src/widgets/engine_widget.h | 2 +- src/widgets/error_widget.h | 2 +- src/widgets/fios_widget.h | 2 +- src/widgets/framerate_widget.h | 4 ++-- src/widgets/game_widget.h | 2 +- src/widgets/genworld_widget.h | 6 +++--- src/widgets/goal_widget.h | 4 ++-- src/widgets/graph_widget.h | 10 +++++----- src/widgets/group_widget.h | 2 +- src/widgets/help_widget.h | 2 +- src/widgets/highscore_widget.h | 2 +- src/widgets/industry_widget.h | 8 ++++---- src/widgets/intro_widget.h | 2 +- src/widgets/league_widget.h | 4 ++-- src/widgets/link_graph_legend_widget.h | 2 +- src/widgets/main_widget.h | 2 +- src/widgets/misc_widget.h | 12 ++++++------ src/widgets/music_widget.h | 4 ++-- src/widgets/network_chat_widget.h | 2 +- src/widgets/network_content_widget.h | 4 ++-- src/widgets/network_widget.h | 14 +++++++------- src/widgets/newgrf_debug_widget.h | 4 ++-- src/widgets/newgrf_widget.h | 8 ++++---- src/widgets/news_widget.h | 4 ++-- src/widgets/object_widget.h | 2 +- src/widgets/order_widget.h | 2 +- src/widgets/osk_widget.h | 2 +- src/widgets/rail_widget.h | 10 +++++----- src/widgets/road_widget.h | 6 +++--- src/widgets/screenshot_widget.h | 2 +- src/widgets/script_widget.h | 6 +++--- src/widgets/settings_widget.h | 6 +++--- src/widgets/sign_widget.h | 4 ++-- src/widgets/smallmap_widget.h | 2 +- src/widgets/station_widget.h | 6 +++--- src/widgets/statusbar_widget.h | 2 +- src/widgets/story_widget.h | 2 +- src/widgets/subsidy_widget.h | 2 +- src/widgets/terraform_widget.h | 4 ++-- src/widgets/timetable_widget.h | 2 +- src/widgets/toolbar_widget.h | 4 ++-- src/widgets/town_widget.h | 8 ++++---- src/widgets/transparency_widget.h | 2 +- src/widgets/tree_widget.h | 2 +- src/widgets/vehicle_widget.h | 8 ++++---- src/widgets/viewport_widget.h | 2 +- src/widgets/waypoint_widget.h | 2 +- 60 files changed, 120 insertions(+), 120 deletions(-) diff --git a/src/widgets/ai_widget.h b/src/widgets/ai_widget.h index 964026ff79..23144e0103 100644 --- a/src/widgets/ai_widget.h +++ b/src/widgets/ai_widget.h @@ -13,7 +13,7 @@ #include "../textfile_type.h" /** Widgets of the #AIConfigWindow class. */ -enum AIConfigWidgets { +enum AIConfigWidgets : WidgetID { WID_AIC_BACKGROUND, ///< Window background. WID_AIC_DECREASE_NUMBER, ///< Decrease the number of AIs. WID_AIC_INCREASE_NUMBER, ///< Increase the number of AIs. diff --git a/src/widgets/airport_widget.h b/src/widgets/airport_widget.h index 514a44e88a..4e16f4596e 100644 --- a/src/widgets/airport_widget.h +++ b/src/widgets/airport_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_AIRPORT_WIDGET_H /** Widgets of the #BuildAirToolbarWindow class. */ -enum AirportToolbarWidgets { +enum AirportToolbarWidgets : WidgetID { WID_AT_AIRPORT, ///< Build airport button. WID_AT_DEMOLISH, ///< Demolish button. @@ -19,7 +19,7 @@ enum AirportToolbarWidgets { }; /** Widgets of the #BuildAirportWindow class. */ -enum AirportPickerWidgets { +enum AirportPickerWidgets : WidgetID { WID_AP_CLASS_DROPDOWN, ///< Dropdown of airport classes. WID_AP_AIRPORT_LIST, ///< List of airports. WID_AP_SCROLLBAR, ///< Scrollbar of the list. diff --git a/src/widgets/autoreplace_widget.h b/src/widgets/autoreplace_widget.h index ab0b14aad2..c5d8c158aa 100644 --- a/src/widgets/autoreplace_widget.h +++ b/src/widgets/autoreplace_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_AUTOREPLACE_WIDGET_H /** Widgets of the #ReplaceVehicleWindow class. */ -enum ReplaceVehicleWidgets { +enum ReplaceVehicleWidgets : WidgetID { WID_RV_CAPTION, ///< Caption of the window. /* Sort dropdown at the right. */ diff --git a/src/widgets/bootstrap_widget.h b/src/widgets/bootstrap_widget.h index 16a36cc5b4..073e382907 100644 --- a/src/widgets/bootstrap_widget.h +++ b/src/widgets/bootstrap_widget.h @@ -11,19 +11,19 @@ #define WIDGETS_BOOTSTRAP_WIDGET_H /** Widgets of the #BootstrapBackground class. */ -enum BootstrapBackgroundWidgets { +enum BootstrapBackgroundWidgets : WidgetID { WID_BB_BACKGROUND, ///< Background of the window. }; /** Widgets of the #BootstrapErrmsgWindow class. */ -enum BootstrapErrorMessageWidgets { +enum BootstrapErrorMessageWidgets : WidgetID { WID_BEM_CAPTION, ///< Caption of the window. WID_BEM_MESSAGE, ///< Error message. WID_BEM_QUIT, ///< Quit button. }; /** Widgets of the #BootstrapContentDownloadStatusWindow class. */ -enum BootstrapAskForDownloadWidgets { +enum BootstrapAskForDownloadWidgets : WidgetID { WID_BAFD_QUESTION, ///< The question whether to download. WID_BAFD_YES, ///< An affirmative answer to the question. WID_BAFD_NO, ///< An negative answer to the question. diff --git a/src/widgets/bridge_widget.h b/src/widgets/bridge_widget.h index d9b6adedda..0d8f46362f 100644 --- a/src/widgets/bridge_widget.h +++ b/src/widgets/bridge_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_BRIDGE_WIDGET_H /** Widgets of the #BuildBridgeWindow class. */ -enum BuildBridgeSelectionWidgets { +enum BuildBridgeSelectionWidgets : WidgetID { WID_BBS_CAPTION, ///< Caption of the window. WID_BBS_DROPDOWN_ORDER, ///< Direction of sort dropdown. WID_BBS_DROPDOWN_CRITERIA, ///< Criteria of sort dropdown. diff --git a/src/widgets/build_vehicle_widget.h b/src/widgets/build_vehicle_widget.h index d0374a83d3..df541b8c0f 100644 --- a/src/widgets/build_vehicle_widget.h +++ b/src/widgets/build_vehicle_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_BUILD_VEHICLE_WIDGET_H /** Widgets of the #BuildVehicleWindow class. */ -enum BuildVehicleWidgets { +enum BuildVehicleWidgets : WidgetID { WID_BV_CAPTION, ///< Caption of window. WID_BV_SORT_ASCENDING_DESCENDING, ///< Sort direction. WID_BV_SORT_DROPDOWN, ///< Criteria of sorting dropdown. diff --git a/src/widgets/cheat_widget.h b/src/widgets/cheat_widget.h index b8ee75f52b..204358e6a5 100644 --- a/src/widgets/cheat_widget.h +++ b/src/widgets/cheat_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_CHEAT_WIDGET_H /** Widgets of the #CheatWindow class. */ -enum CheatWidgets { +enum CheatWidgets : WidgetID { WID_C_NOTE, ///< Note on top of panel for use of cheat. WID_C_PANEL, ///< Panel where all cheats are shown in. }; diff --git a/src/widgets/company_widget.h b/src/widgets/company_widget.h index a2e3cb685f..f53f83a494 100644 --- a/src/widgets/company_widget.h +++ b/src/widgets/company_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_COMPANY_WIDGET_H /** Widgets of the #CompanyWindow class. */ -enum CompanyWidgets { +enum CompanyWidgets : WidgetID { WID_C_CAPTION, ///< Caption of the window. WID_C_FACE, ///< View of the face. @@ -54,7 +54,7 @@ enum CompanyWidgets { }; /** Widgets of the #CompanyFinancesWindow class. */ -enum CompanyFinancesWidgets { +enum CompanyFinancesWidgets : WidgetID { WID_CF_CAPTION, ///< Caption of the window. WID_CF_TOGGLE_SIZE, ///< Toggle windows size. WID_CF_SEL_PANEL, ///< Select panel or nothing. @@ -78,7 +78,7 @@ enum CompanyFinancesWidgets { /** Widgets of the #SelectCompanyLiveryWindow class. */ -enum SelectCompanyLiveryWidgets { +enum SelectCompanyLiveryWidgets : WidgetID { WID_SCL_CAPTION, ///< Caption of window. WID_SCL_CLASS_GENERAL, ///< Class general. WID_SCL_CLASS_RAIL, ///< Class rail. @@ -102,7 +102,7 @@ enum SelectCompanyLiveryWidgets { * Do not change the order of the widgets from WID_SCMF_HAS_MOUSTACHE_EARRING to WID_SCMF_GLASSES_R, * this order is needed for the WE_CLICK event of DrawFaceStringLabel(). */ -enum SelectCompanyManagerFaceWidgets { +enum SelectCompanyManagerFaceWidgets : WidgetID { WID_SCMF_CAPTION, ///< Caption of window. WID_SCMF_TOGGLE_LARGE_SMALL, ///< Toggle for large or small. WID_SCMF_SELECT_FACE, ///< Select face. @@ -170,7 +170,7 @@ enum SelectCompanyManagerFaceWidgets { }; /** Widgets of the #CompanyInfrastructureWindow class. */ -enum CompanyInfrastructureWidgets { +enum CompanyInfrastructureWidgets : WidgetID { WID_CI_CAPTION, ///< Caption of window. WID_CI_RAIL_DESC, ///< Description of rail. WID_CI_RAIL_COUNT, ///< Count of rail. @@ -187,7 +187,7 @@ enum CompanyInfrastructureWidgets { }; /** Widgets of the #BuyCompanyWindow class. */ -enum BuyCompanyWidgets { +enum BuyCompanyWidgets : WidgetID { WID_BC_CAPTION, ///< Caption of window. WID_BC_FACE, ///< Face button. WID_BC_QUESTION, ///< Question text. diff --git a/src/widgets/console_widget.h b/src/widgets/console_widget.h index 1bc1be1f67..8f90631824 100644 --- a/src/widgets/console_widget.h +++ b/src/widgets/console_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_CONSOLE_WIDGET_H /** Widgets of the #IConsoleWindow class. */ -enum ConsoleWidgets { +enum ConsoleWidgets : WidgetID { WID_C_BACKGROUND, ///< Background of the console. }; diff --git a/src/widgets/date_widget.h b/src/widgets/date_widget.h index 3b397dae47..45bc4e9966 100644 --- a/src/widgets/date_widget.h +++ b/src/widgets/date_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_DATE_WIDGET_H /** Widgets of the #SetDateWindow class. */ -enum SetDateWidgets { +enum SetDateWidgets : WidgetID { WID_SD_DAY, ///< Dropdown for the day. WID_SD_MONTH, ///< Dropdown for the month. WID_SD_YEAR, ///< Dropdown for the year. diff --git a/src/widgets/depot_widget.h b/src/widgets/depot_widget.h index c162cb8b7d..f94f1263d2 100644 --- a/src/widgets/depot_widget.h +++ b/src/widgets/depot_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_DEPOT_WIDGET_H /** Widgets of the #DepotWindow class. */ -enum DepotWidgets { +enum DepotWidgets : WidgetID { WID_D_CAPTION, ///< Caption of window. WID_D_SELL, ///< Sell button. WID_D_SHOW_SELL_CHAIN, ///< Show sell chain panel. diff --git a/src/widgets/dock_widget.h b/src/widgets/dock_widget.h index 139fcd55bc..0a1f480eb6 100644 --- a/src/widgets/dock_widget.h +++ b/src/widgets/dock_widget.h @@ -11,14 +11,14 @@ #define WIDGETS_DOCK_WIDGET_H /** Widgets of the #BuildDocksDepotWindow class. */ -enum BuildDockDepotWidgets { +enum BuildDockDepotWidgets : WidgetID { WID_BDD_BACKGROUND, ///< Background of the window. WID_BDD_X, ///< X-direction button. WID_BDD_Y, ///< Y-direction button. }; /** Widgets of the #BuildDocksToolbarWindow class. */ -enum DockToolbarWidgets { +enum DockToolbarWidgets : WidgetID { WID_DT_CANAL, ///< Build canal button. WID_DT_LOCK, ///< Build lock button. WID_DT_DEMOLISH, ///< Demolish aka dynamite button. diff --git a/src/widgets/dropdown_widget.h b/src/widgets/dropdown_widget.h index 21223179e9..b9a5f3e17a 100644 --- a/src/widgets/dropdown_widget.h +++ b/src/widgets/dropdown_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_DROPDOWN_WIDGET_H /** Widgets of the #DropdownWindow class. */ -enum DropdownMenuWidgets { +enum DropdownMenuWidgets : WidgetID { WID_DM_ITEMS, ///< Panel showing the dropdown items. WID_DM_SHOW_SCROLL, ///< Hide scrollbar if too few items. WID_DM_SCROLL, ///< Scrollbar. diff --git a/src/widgets/engine_widget.h b/src/widgets/engine_widget.h index 5d3468efc6..e66319ba05 100644 --- a/src/widgets/engine_widget.h +++ b/src/widgets/engine_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_ENGINE_WIDGET_H /** Widgets of the #EnginePreviewWindow class. */ -enum EnginePreviewWidgets { +enum EnginePreviewWidgets : WidgetID { WID_EP_QUESTION, ///< The container for the question. WID_EP_NO, ///< No button. WID_EP_YES, ///< Yes button. diff --git a/src/widgets/error_widget.h b/src/widgets/error_widget.h index 7a7fa4af38..40519644e7 100644 --- a/src/widgets/error_widget.h +++ b/src/widgets/error_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_ERROR_WIDGET_H /** Widgets of the #ErrmsgWindow class. */ -enum ErrorMessageWidgets { +enum ErrorMessageWidgets : WidgetID { WID_EM_CAPTION, ///< Caption of the window. WID_EM_FACE, ///< Error title. WID_EM_MESSAGE, ///< Error message. diff --git a/src/widgets/fios_widget.h b/src/widgets/fios_widget.h index 86995588ed..0d8e723848 100644 --- a/src/widgets/fios_widget.h +++ b/src/widgets/fios_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_FIOS_WIDGET_H /** Widgets of the #SaveLoadWindow class. */ -enum SaveLoadWidgets { +enum SaveLoadWidgets : WidgetID { WID_SL_CAPTION, ///< Caption of the window. WID_SL_SORT_BYNAME, ///< Sort by name button. WID_SL_SORT_BYDATE, ///< Sort by date button. diff --git a/src/widgets/framerate_widget.h b/src/widgets/framerate_widget.h index 49ee2f9528..0192b540c6 100644 --- a/src/widgets/framerate_widget.h +++ b/src/widgets/framerate_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_FRAMERATE_WIDGET_H /** Widgets of the #FramerateWindow class. */ -enum FramerateWindowWidgets { +enum FramerateWindowWidgets : WidgetID { WID_FRW_CAPTION, WID_FRW_RATE_GAMELOOP, WID_FRW_RATE_DRAWING, @@ -26,7 +26,7 @@ enum FramerateWindowWidgets { }; /** Widgets of the #FrametimeGraphWindow class. */ -enum FrametimeGraphWindowWidgets { +enum FrametimeGraphWindowWidgets : WidgetID { WID_FGW_CAPTION, WID_FGW_GRAPH, }; diff --git a/src/widgets/game_widget.h b/src/widgets/game_widget.h index 3a2d2d7082..5b105d9934 100644 --- a/src/widgets/game_widget.h +++ b/src/widgets/game_widget.h @@ -13,7 +13,7 @@ #include "../textfile_type.h" /** Widgets of the #GSConfigWindow class. */ -enum GSConfigWidgets { +enum GSConfigWidgets : WidgetID { WID_GSC_BACKGROUND, ///< Window background. WID_GSC_GSLIST, ///< List with current selected Game Script. WID_GSC_SETTINGS, ///< Panel to draw the Game Script settings on diff --git a/src/widgets/genworld_widget.h b/src/widgets/genworld_widget.h index 34d2f149d8..8d852a117b 100644 --- a/src/widgets/genworld_widget.h +++ b/src/widgets/genworld_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_GENWORLD_WIDGET_H /** Widgets of the #GenerateLandscapeWindow class. */ -enum GenerateLandscapeWidgets { +enum GenerateLandscapeWidgets : WidgetID { WID_GL_TEMPERATE, ///< Button with icon "Temperate". WID_GL_ARCTIC, ///< Button with icon "Arctic". WID_GL_TROPICAL, ///< Button with icon "Tropical". @@ -69,7 +69,7 @@ enum GenerateLandscapeWidgets { }; /** Widgets of the #CreateScenarioWindow class. */ -enum CreateScenarioWidgets { +enum CreateScenarioWidgets : WidgetID { WID_CS_TEMPERATE, ///< Select temperate landscape style. WID_CS_ARCTIC, ///< Select arctic landscape style. WID_CS_TROPICAL, ///< Select tropical landscape style. @@ -87,7 +87,7 @@ enum CreateScenarioWidgets { }; /** Widgets of the #GenerateProgressWindow class. */ -enum GenerationProgressWidgets { +enum GenerationProgressWidgets : WidgetID { WID_GP_PROGRESS_BAR, ///< Progress bar. WID_GP_PROGRESS_TEXT, ///< Text with the progress bar. WID_GP_ABORT, ///< Abort button. diff --git a/src/widgets/goal_widget.h b/src/widgets/goal_widget.h index 303eaa69e9..c34749022a 100644 --- a/src/widgets/goal_widget.h +++ b/src/widgets/goal_widget.h @@ -12,7 +12,7 @@ #define WIDGETS_GOAL_WIDGET_H /** Widgets of the #GoalListWindow class. */ -enum GoalListWidgets { +enum GoalListWidgets : WidgetID { WID_GOAL_CAPTION, ///< Caption of the window. WID_GOAL_SELECT_BUTTONS, ///< Selection widget for the title bar button. WID_GOAL_GLOBAL_BUTTON, ///< Button to show global goals. @@ -22,7 +22,7 @@ enum GoalListWidgets { }; /** Widgets of the #GoalQuestionWindow class. */ -enum GoalQuestionWidgets { +enum GoalQuestionWidgets : WidgetID { WID_GQ_CAPTION, ///< Caption of the window. WID_GQ_QUESTION, ///< Question text. WID_GQ_BUTTONS, ///< Buttons selection (between 1, 2 or 3). diff --git a/src/widgets/graph_widget.h b/src/widgets/graph_widget.h index 2548c990cd..3d155ec565 100644 --- a/src/widgets/graph_widget.h +++ b/src/widgets/graph_widget.h @@ -14,7 +14,7 @@ #include "../company_type.h" /** Widgets of the #GraphLegendWindow class. */ -enum GraphLegendWidgets { +enum GraphLegendWidgets : WidgetID { WID_GL_BACKGROUND, ///< Background of the window. WID_GL_FIRST_COMPANY, ///< First company in the legend. @@ -22,7 +22,7 @@ enum GraphLegendWidgets { }; /** Widgets of the #OperatingProfitGraphWindow class, #IncomeGraphWindow class, #DeliveredCargoGraphWindow class, and #CompanyValueGraphWindow class. */ -enum CompanyValueWidgets { +enum CompanyValueWidgets : WidgetID { WID_CV_KEY_BUTTON, ///< Key button. WID_CV_BACKGROUND, ///< Background of the window. WID_CV_GRAPH, ///< Graph itself. @@ -30,7 +30,7 @@ enum CompanyValueWidgets { }; /** Widget of the #PerformanceHistoryGraphWindow class. */ -enum PerformanceHistoryGraphWidgets { +enum PerformanceHistoryGraphWidgets : WidgetID { WID_PHG_KEY, ///< Key button. WID_PHG_DETAILED_PERFORMANCE, ///< Detailed performance. WID_PHG_BACKGROUND, ///< Background of the window. @@ -39,7 +39,7 @@ enum PerformanceHistoryGraphWidgets { }; /** Widget of the #PaymentRatesGraphWindow class. */ -enum CargoPaymentRatesWidgets { +enum CargoPaymentRatesWidgets : WidgetID { WID_CPR_BACKGROUND, ///< Background of the window. WID_CPR_HEADER, ///< Header. WID_CPR_GRAPH, ///< Graph itself. @@ -52,7 +52,7 @@ enum CargoPaymentRatesWidgets { }; /** Widget of the #PerformanceRatingDetailWindow class. */ -enum PerformanceRatingDetailsWidgets { +enum PerformanceRatingDetailsWidgets : WidgetID { WID_PRD_SCORE_FIRST, ///< First entry in the score list. WID_PRD_SCORE_LAST = WID_PRD_SCORE_FIRST + (SCORE_END - SCORE_BEGIN) - 1, ///< Last entry in the score list. diff --git a/src/widgets/group_widget.h b/src/widgets/group_widget.h index e097b5314e..c140917899 100644 --- a/src/widgets/group_widget.h +++ b/src/widgets/group_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_GROUP_WIDGET_H /** Widgets of the #VehicleGroupWindow class. */ -enum GroupListWidgets { +enum GroupListWidgets : WidgetID { WID_GL_CAPTION, ///< Caption of the window. WID_GL_GROUP_BY_ORDER, ///< Group order. WID_GL_GROUP_BY_DROPDOWN, ///< Group by dropdown list. diff --git a/src/widgets/help_widget.h b/src/widgets/help_widget.h index 5b898fc01c..d6715d9632 100644 --- a/src/widgets/help_widget.h +++ b/src/widgets/help_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_HELP_WIDGET_H /** Widgets of the #HelpWindow class. */ -enum HelpWindowWidgets { +enum HelpWindowWidgets : WidgetID { WID_HW_README, WID_HW_CHANGELOG, WID_HW_KNOWN_BUGS, diff --git a/src/widgets/highscore_widget.h b/src/widgets/highscore_widget.h index 394b8c9bf7..3cf6fef968 100644 --- a/src/widgets/highscore_widget.h +++ b/src/widgets/highscore_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_HIGHSCORE_WIDGET_H /** Widgets of the #EndGameHighScoreBaseWindow class and #HighScoreWindow class. */ -enum HighscoreWidgets { +enum HighscoreWidgets : WidgetID { WID_H_BACKGROUND, ///< Background of the window. }; diff --git a/src/widgets/industry_widget.h b/src/widgets/industry_widget.h index ee74d90d54..da8de1c58f 100644 --- a/src/widgets/industry_widget.h +++ b/src/widgets/industry_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_INDUSTRY_WIDGET_H /** Widgets of the #BuildIndustryWindow class. */ -enum DynamicPlaceIndustriesWidgets { +enum DynamicPlaceIndustriesWidgets : WidgetID { WID_DPI_SCENARIO_EDITOR_PANE, ///< Pane containing SE-only widgets. WID_DPI_REMOVE_ALL_INDUSTRIES_WIDGET, ///< Remove all industries button. WID_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET, ///< Create random industries button. @@ -23,7 +23,7 @@ enum DynamicPlaceIndustriesWidgets { }; /** Widgets of the #IndustryViewWindow class. */ -enum IndustryViewWidgets { +enum IndustryViewWidgets : WidgetID { WID_IV_CAPTION, ///< Caption of the window. WID_IV_VIEWPORT, ///< Viewport of the industry. WID_IV_INFO, ///< Info of the industry. @@ -32,7 +32,7 @@ enum IndustryViewWidgets { }; /** Widgets of the #IndustryDirectoryWindow class. */ -enum IndustryDirectoryWidgets { +enum IndustryDirectoryWidgets : WidgetID { WID_ID_DROPDOWN_ORDER, ///< Dropdown for the order of the sort. WID_ID_DROPDOWN_CRITERIA, ///< Dropdown for the criteria of the sort. WID_ID_FILTER_BY_ACC_CARGO, ///< Accepted cargo filter dropdown list. @@ -44,7 +44,7 @@ enum IndustryDirectoryWidgets { }; /** Widgets of the #IndustryCargoesWindow class */ -enum IndustryCargoesWidgets { +enum IndustryCargoesWidgets : WidgetID { WID_IC_CAPTION, ///< Caption of the window. WID_IC_NOTIFY, ///< Row of buttons at the bottom. WID_IC_PANEL, ///< Panel that shows the chain. diff --git a/src/widgets/intro_widget.h b/src/widgets/intro_widget.h index 6e5e70eea9..dcefc172be 100644 --- a/src/widgets/intro_widget.h +++ b/src/widgets/intro_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_INTRO_WIDGET_H /** Widgets of the #SelectGameWindow class. */ -enum SelectGameIntroWidgets { +enum SelectGameIntroWidgets : WidgetID { WID_SGI_GENERATE_GAME, ///< Generate game button. WID_SGI_LOAD_GAME, ///< Load game button. WID_SGI_PLAY_SCENARIO, ///< Play scenario button. diff --git a/src/widgets/league_widget.h b/src/widgets/league_widget.h index 381d379a7e..d6f7c13717 100644 --- a/src/widgets/league_widget.h +++ b/src/widgets/league_widget.h @@ -11,12 +11,12 @@ #define WIDGETS_LEAGUE_WIDGET_H /** Widget of the #PerformanceLeagueWindow class. */ -enum PerformanceLeagueWidgets { +enum PerformanceLeagueWidgets : WidgetID { WID_PLT_BACKGROUND, ///< Background of the window. }; /** Widget of the #ScriptLeagueWindow class. */ -enum ScriptLeagueWidgets { +enum ScriptLeagueWidgets : WidgetID { WID_SLT_CAPTION, ///< Caption of the window. WID_SLT_BACKGROUND, ///< Background of the window. }; diff --git a/src/widgets/link_graph_legend_widget.h b/src/widgets/link_graph_legend_widget.h index a0ff68ab07..a8b2357d72 100644 --- a/src/widgets/link_graph_legend_widget.h +++ b/src/widgets/link_graph_legend_widget.h @@ -14,7 +14,7 @@ /** Widgets of the WC_LINKGRAPH_LEGEND. */ -enum LinkGraphLegendWidgets { +enum LinkGraphLegendWidgets : WidgetID { WID_LGL_CAPTION, ///< Caption widget. WID_LGL_SATURATION, ///< Saturation legend. WID_LGL_SATURATION_FIRST, diff --git a/src/widgets/main_widget.h b/src/widgets/main_widget.h index 51627da5c0..8c12f42620 100644 --- a/src/widgets/main_widget.h +++ b/src/widgets/main_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_MAIN_WIDGET_H /** Widgets of the #MainWindow class. */ -enum MainWidgets { +enum MainWidgets : WidgetID { WID_M_VIEWPORT, ///< Main window viewport. }; diff --git a/src/widgets/misc_widget.h b/src/widgets/misc_widget.h index 61e916d1da..a3ec814f1b 100644 --- a/src/widgets/misc_widget.h +++ b/src/widgets/misc_widget.h @@ -11,25 +11,25 @@ #define WIDGETS_MISC_WIDGET_H /** Widgets of the #LandInfoWindow class. */ -enum LandInfoWidgets { +enum LandInfoWidgets : WidgetID { WID_LI_LOCATION, ///< Scroll to location. WID_LI_BACKGROUND, ///< Background of the window. }; /** Widgets of the #TooltipsWindow class. */ -enum ToolTipsWidgets { +enum ToolTipsWidgets : WidgetID { WID_TT_BACKGROUND, ///< Background of the window. }; /** Widgets of the #AboutWindow class. */ -enum AboutWidgets { +enum AboutWidgets : WidgetID { WID_A_SCROLLING_TEXT, ///< The actually scrolling text. WID_A_WEBSITE, ///< URL of OpenTTD website. WID_A_COPYRIGHT, ///< Copyright string }; /** Widgets of the #QueryStringWindow class. */ -enum QueryStringWidgets { +enum QueryStringWidgets : WidgetID { WID_QS_CAPTION, ///< Caption of the window. WID_QS_TEXT, ///< Text of the query. WID_QS_WARNING, ///< Warning label about password security @@ -39,7 +39,7 @@ enum QueryStringWidgets { }; /** Widgets of the #QueryWindow class. */ -enum QueryWidgets { +enum QueryWidgets : WidgetID { WID_Q_CAPTION, ///< Caption of the window. WID_Q_TEXT, ///< Text of the query. WID_Q_NO, ///< Yes button. @@ -47,7 +47,7 @@ enum QueryWidgets { }; /** Widgets of the #TextfileWindow class. */ -enum TextfileWidgets { +enum TextfileWidgets : WidgetID { WID_TF_CAPTION, ///< The caption of the window. WID_TF_NAVBACK, ///< Navigate back button. WID_TF_NAVFORWARD, ///< Navigate forward button. diff --git a/src/widgets/music_widget.h b/src/widgets/music_widget.h index dc2e685325..bbb0a3e4d0 100644 --- a/src/widgets/music_widget.h +++ b/src/widgets/music_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_MUSIC_WIDGET_H /** Widgets of the #MusicTrackSelectionWindow class. */ -enum MusicTrackSelectionWidgets { +enum MusicTrackSelectionWidgets : WidgetID { WID_MTS_CAPTION, ///< Window caption. WID_MTS_LIST_LEFT, ///< Left button. WID_MTS_PLAYLIST, ///< Playlist. @@ -27,7 +27,7 @@ enum MusicTrackSelectionWidgets { }; /** Widgets of the #MusicWindow class. */ -enum MusicWidgets { +enum MusicWidgets : WidgetID { WID_M_PREV, ///< Previous button. WID_M_NEXT, ///< Next button. WID_M_STOP, ///< Stop button. diff --git a/src/widgets/network_chat_widget.h b/src/widgets/network_chat_widget.h index ccfb467f71..26a3a1e436 100644 --- a/src/widgets/network_chat_widget.h +++ b/src/widgets/network_chat_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_NETWORK_CHAT_WIDGET_H /** Widgets of the #NetworkChatWindow class. */ -enum NetWorkChatWidgets { +enum NetWorkChatWidgets : WidgetID { WID_NC_CLOSE, ///< Close button. WID_NC_BACKGROUND, ///< Background of the window. WID_NC_DESTINATION, ///< Destination. diff --git a/src/widgets/network_content_widget.h b/src/widgets/network_content_widget.h index c8092aefa8..38158272ba 100644 --- a/src/widgets/network_content_widget.h +++ b/src/widgets/network_content_widget.h @@ -13,14 +13,14 @@ #include "../textfile_type.h" /** Widgets of the #NetworkContentDownloadStatusWindow class. */ -enum NetworkContentDownloadStatusWidgets { +enum NetworkContentDownloadStatusWidgets : WidgetID { WID_NCDS_PROGRESS_BAR, ///< Simple progress bar. WID_NCDS_PROGRESS_TEXT, ///< Text explaining what is happening. WID_NCDS_CANCELOK, ///< (Optional) Cancel/OK button. }; /** Widgets of the #NetworkContentListWindow class. */ -enum NetworkContentListWidgets { +enum NetworkContentListWidgets : WidgetID { WID_NCL_BACKGROUND, ///< Resize button. WID_NCL_FILTER_CAPT, ///< Caption for the filter editbox. diff --git a/src/widgets/network_widget.h b/src/widgets/network_widget.h index 087436a516..276874f92e 100644 --- a/src/widgets/network_widget.h +++ b/src/widgets/network_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_NETWORK_WIDGET_H /** Widgets of the #NetworkGameWindow class. */ -enum NetworkGameWidgets { +enum NetworkGameWidgets : WidgetID { WID_NG_MAIN, ///< Main panel. WID_NG_CLIENT_LABEL, ///< Label in front of client name edit box. @@ -49,7 +49,7 @@ enum NetworkGameWidgets { }; /** Widgets of the #NetworkStartServerWindow class. */ -enum NetworkStartServerWidgets { +enum NetworkStartServerWidgets : WidgetID { WID_NSS_BACKGROUND, ///< Background of the window. WID_NSS_GAMENAME_LABEL, ///< Label for the game name. WID_NSS_GAMENAME, ///< Background for editbox to set game name. @@ -74,7 +74,7 @@ enum NetworkStartServerWidgets { }; /** Widgets of the #NetworkClientListWindow class. */ -enum ClientListWidgets { +enum ClientListWidgets : WidgetID { WID_CL_PANEL, ///< Panel of the window. WID_CL_SERVER_SELECTOR, ///< Selector to hide the server frame. WID_CL_SERVER_NAME, ///< Server name. @@ -91,14 +91,14 @@ enum ClientListWidgets { }; /** Widgets of the #NetworkJoinStatusWindow class. */ -enum NetworkJoinStatusWidgets { +enum NetworkJoinStatusWidgets : WidgetID { WID_NJS_PROGRESS_BAR, ///< Simple progress bar. WID_NJS_PROGRESS_TEXT, ///< Text explaining what is happening. WID_NJS_CANCELOK, ///< Cancel / OK button. }; /** Widgets of the #NetworkCompanyPasswordWindow class. */ -enum NetworkCompanyPasswordWidgets { +enum NetworkCompanyPasswordWidgets : WidgetID { WID_NCP_BACKGROUND, ///< Background of the window. WID_NCP_LABEL, ///< Label in front of the password field. WID_NCP_PASSWORD, ///< Input field for the password. @@ -109,7 +109,7 @@ enum NetworkCompanyPasswordWidgets { }; /** Widgets of the #NetworkAskRelayWindow class. */ -enum NetworkAskRelayWidgets { +enum NetworkAskRelayWidgets : WidgetID { WID_NAR_CAPTION, ///< Caption of the window. WID_NAR_TEXT, ///< Text in the window. WID_NAR_NO, ///< "No" button. @@ -118,7 +118,7 @@ enum NetworkAskRelayWidgets { }; /** Widgets of the #NetworkAskSurveyWindow class. */ -enum NetworkAskSurveyWidgets { +enum NetworkAskSurveyWidgets : WidgetID { WID_NAS_CAPTION, ///< Caption of the window. WID_NAS_TEXT, ///< Text in the window. WID_NAS_PREVIEW, ///< "Preview" button. diff --git a/src/widgets/newgrf_debug_widget.h b/src/widgets/newgrf_debug_widget.h index 910d212199..b4dffcaad2 100644 --- a/src/widgets/newgrf_debug_widget.h +++ b/src/widgets/newgrf_debug_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_NEWGRF_DEBUG_WIDGET_H /** Widgets of the #NewGRFInspectWindow class. */ -enum NewGRFInspectWidgets { +enum NewGRFInspectWidgets : WidgetID { WID_NGRFI_CAPTION, ///< The caption bar of course. WID_NGRFI_PARENT, ///< Inspect the parent. WID_NGRFI_VEH_PREV, ///< Go to previous vehicle in chain. @@ -22,7 +22,7 @@ enum NewGRFInspectWidgets { }; /** Widgets of the #SpriteAlignerWindow class. */ -enum SpriteAlignerWidgets { +enum SpriteAlignerWidgets : WidgetID { WID_SA_CAPTION, ///< Caption of the window. WID_SA_PREVIOUS, ///< Skip to the previous sprite. WID_SA_GOTO, ///< Go to a given sprite. diff --git a/src/widgets/newgrf_widget.h b/src/widgets/newgrf_widget.h index da4e4d584d..d4bab8e200 100644 --- a/src/widgets/newgrf_widget.h +++ b/src/widgets/newgrf_widget.h @@ -14,7 +14,7 @@ #include "../textfile_type.h" /** Widgets of the #NewGRFParametersWindow class. */ -enum NewGRFParametersWidgets { +enum NewGRFParametersWidgets : WidgetID { WID_NP_CAPTION, ///< Caption of the window. WID_NP_SHOW_NUMPAR, ///< #NWID_SELECTION to optionally display #WID_NP_NUMPAR. WID_NP_NUMPAR_DEC, ///< Button to decrease number of parameters. @@ -32,7 +32,7 @@ enum NewGRFParametersWidgets { }; /** Widgets of the #NewGRFWindow class. */ -enum NewGRFStateWidgets { +enum NewGRFStateWidgets : WidgetID { WID_NS_PRESET_LIST, ///< Active NewGRF preset. WID_NS_PRESET_SAVE, ///< Save list of active NewGRFs as presets. WID_NS_PRESET_DELETE, ///< Delete active preset. @@ -63,7 +63,7 @@ enum NewGRFStateWidgets { }; /** Widgets of the #SavePresetWindow class. */ -enum SavePresetWidgets { +enum SavePresetWidgets : WidgetID { WID_SVP_PRESET_LIST, ///< List with available preset names. WID_SVP_SCROLLBAR, ///< Scrollbar for the list available preset names. WID_SVP_EDITBOX, ///< Edit box for changing the preset name. @@ -72,7 +72,7 @@ enum SavePresetWidgets { }; /** Widgets of the #ScanProgressWindow class. */ -enum ScanProgressWidgets { +enum ScanProgressWidgets : WidgetID { WID_SP_PROGRESS_BAR, ///< Simple progress bar. WID_SP_PROGRESS_TEXT, ///< Text explaining what is happening. }; diff --git a/src/widgets/news_widget.h b/src/widgets/news_widget.h index e5b8934439..68d59fa133 100644 --- a/src/widgets/news_widget.h +++ b/src/widgets/news_widget.h @@ -13,7 +13,7 @@ #include "../news_type.h" /** Widgets of the #NewsWindow class. */ -enum NewsWidgets { +enum NewsWidgets : WidgetID { WID_N_PANEL, ///< Panel of the window. WID_N_TITLE, ///< Title of the company news. WID_N_HEADLINE, ///< The news headline. @@ -35,7 +35,7 @@ enum NewsWidgets { }; /** Widgets of the #MessageHistoryWindow class. */ -enum MessageHistoryWidgets { +enum MessageHistoryWidgets : WidgetID { WID_MH_STICKYBOX, ///< Stickybox. WID_MH_BACKGROUND, ///< Background of the window. WID_MH_SCROLLBAR, ///< Scrollbar for the list. diff --git a/src/widgets/object_widget.h b/src/widgets/object_widget.h index 9afb783c56..9adf13dde7 100644 --- a/src/widgets/object_widget.h +++ b/src/widgets/object_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_OBJECT_WIDGET_H /** Widgets of the #BuildObjectWindow class. */ -enum BuildObjectWidgets { +enum BuildObjectWidgets : WidgetID { WID_BO_FILTER, ///< The filter text box for the object list. WID_BO_CLASS_LIST, ///< The list with classes. WID_BO_SCROLLBAR, ///< The scrollbar associated with the list. diff --git a/src/widgets/order_widget.h b/src/widgets/order_widget.h index 82ca472e20..3177359de9 100644 --- a/src/widgets/order_widget.h +++ b/src/widgets/order_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_ORDER_WIDGET_H /** Widgets of the #OrdersWindow class. */ -enum OrderWidgets { +enum OrderWidgets : WidgetID { WID_O_CAPTION, ///< Caption of the window. WID_O_TIMETABLE_VIEW, ///< Toggle timetable view. WID_O_ORDER_LIST, ///< Order list panel. diff --git a/src/widgets/osk_widget.h b/src/widgets/osk_widget.h index ccda502fff..ae84037b53 100644 --- a/src/widgets/osk_widget.h +++ b/src/widgets/osk_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_OSK_WIDGET_H /** Widgets of the #OskWindow class. */ -enum OnScreenKeyboardWidgets { +enum OnScreenKeyboardWidgets : WidgetID { WID_OSK_CAPTION, ///< Caption of window. WID_OSK_TEXT, ///< Edit box. WID_OSK_CANCEL, ///< Cancel key. diff --git a/src/widgets/rail_widget.h b/src/widgets/rail_widget.h index 479915cc01..b418e45bd1 100644 --- a/src/widgets/rail_widget.h +++ b/src/widgets/rail_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_RAIL_WIDGET_H /** Widgets of the #BuildRailToolbarWindow class. */ -enum RailToolbarWidgets { +enum RailToolbarWidgets : WidgetID { /* Name starts with RA instead of R, because of collision with RoadToolbarWidgets */ WID_RAT_CAPTION, ///< Caption of the window. WID_RAT_BUILD_NS, ///< Build rail along the game view Y axis. @@ -33,7 +33,7 @@ enum RailToolbarWidgets { }; /** Widgets of the #BuildRailStationWindow class. */ -enum BuildRailStationWidgets { +enum BuildRailStationWidgets : WidgetID { /* Name starts with BRA instead of BR, because of collision with BuildRoadStationWidgets */ WID_BRAS_PLATFORM_DIR_X, ///< Button to select '/' view. WID_BRAS_PLATFORM_DIR_Y, ///< Button to select '\' view. @@ -79,7 +79,7 @@ enum BuildRailStationWidgets { }; /** Widgets of the #BuildSignalWindow class. */ -enum BuildSignalWidgets { +enum BuildSignalWidgets : WidgetID { WID_BS_CAPTION, ///< Caption for the Signal Selection window. WID_BS_TOGGLE_SIZE, ///< Toggle showing advanced signal types. WID_BS_SEMAPHORE_NORM, ///< Build a semaphore normal block signal. @@ -109,7 +109,7 @@ enum BuildSignalWidgets { }; /** Widgets of the #BuildRailDepotWindow class. */ -enum BuildRailDepotWidgets { +enum BuildRailDepotWidgets : WidgetID { /* Name starts with BRA instead of BR, because of collision with BuildRoadDepotWidgets */ WID_BRAD_DEPOT_NE, ///< Build a depot with the entrance in the north east. WID_BRAD_DEPOT_SE, ///< Build a depot with the entrance in the south east. @@ -118,7 +118,7 @@ enum BuildRailDepotWidgets { }; /** Widgets of the #BuildRailWaypointWindow class. */ -enum BuildRailWaypointWidgets { +enum BuildRailWaypointWidgets : WidgetID { WID_BRW_FILTER, ///< Text filter. WID_BRW_WAYPOINT_MATRIX, ///< Matrix with waypoints. WID_BRW_WAYPOINT, ///< A single waypoint. diff --git a/src/widgets/road_widget.h b/src/widgets/road_widget.h index 9050480bfb..416e1868c7 100644 --- a/src/widgets/road_widget.h +++ b/src/widgets/road_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_ROAD_WIDGET_H /** Widgets of the #BuildRoadToolbarWindow class. */ -enum RoadToolbarWidgets { +enum RoadToolbarWidgets : WidgetID { /* Name starts with RO instead of R, because of collision with RailToolbarWidgets */ WID_ROT_CAPTION, ///< Caption of the window WID_ROT_ROAD_X, ///< Build road in x-direction. @@ -31,7 +31,7 @@ enum RoadToolbarWidgets { }; /** Widgets of the #BuildRoadDepotWindow class. */ -enum BuildRoadDepotWidgets { +enum BuildRoadDepotWidgets : WidgetID { /* Name starts with BRO instead of BR, because of collision with BuildRailDepotWidgets */ WID_BROD_CAPTION, ///< Caption of the window. WID_BROD_DEPOT_NE, ///< Depot with NE entry. @@ -41,7 +41,7 @@ enum BuildRoadDepotWidgets { }; /** Widgets of the #BuildRoadStationWindow class. */ -enum BuildRoadStationWidgets { +enum BuildRoadStationWidgets : WidgetID { /* Name starts with BRO instead of BR, because of collision with BuildRailStationWidgets */ WID_BROS_CAPTION, ///< Caption of the window. WID_BROS_STATION_NE, ///< Terminal station with NE entry. diff --git a/src/widgets/screenshot_widget.h b/src/widgets/screenshot_widget.h index 6f42b784d6..7fc3a0779f 100644 --- a/src/widgets/screenshot_widget.h +++ b/src/widgets/screenshot_widget.h @@ -12,7 +12,7 @@ /** Widgets of the #ScreenshotWindow class. */ -enum ScreenshotWindowWidgets { +enum ScreenshotWindowWidgets : WidgetID { WID_SC_TAKE, ///< Button for taking a normal screenshot WID_SC_TAKE_ZOOMIN, ///< Button for taking a zoomed in screenshot WID_SC_TAKE_DEFAULTZOOM, ///< Button for taking a screenshot at normal zoom diff --git a/src/widgets/script_widget.h b/src/widgets/script_widget.h index d4ba17e452..253e1673ed 100644 --- a/src/widgets/script_widget.h +++ b/src/widgets/script_widget.h @@ -13,7 +13,7 @@ #include "../company_type.h" /** Widgets of the #ScriptListWindow class. */ -enum ScriptListWidgets { +enum ScriptListWidgets : WidgetID { WID_SCRL_CAPTION, ///< Caption of the window. WID_SCRL_LIST, ///< The matrix with all available Scripts. WID_SCRL_SCROLLBAR, ///< Scrollbar next to the Script list. @@ -23,7 +23,7 @@ enum ScriptListWidgets { }; /** Widgets of the #ScriptSettingsWindow class. */ -enum ScriptSettingsWidgets { +enum ScriptSettingsWidgets : WidgetID { WID_SCRS_CAPTION, ///< Caption of the window. WID_SCRS_BACKGROUND, ///< Panel to draw the settings on. WID_SCRS_SCROLLBAR, ///< Scrollbar to scroll through all settings. @@ -34,7 +34,7 @@ enum ScriptSettingsWidgets { }; /** Widgets of the #ScriptDebugWindow class. */ -enum ScriptDebugWidgets { +enum ScriptDebugWidgets : WidgetID { WID_SCRD_VIEW, ///< The row of company buttons. WID_SCRD_NAME_TEXT, ///< Name of the current selected. WID_SCRD_SETTINGS, ///< Settings button. diff --git a/src/widgets/settings_widget.h b/src/widgets/settings_widget.h index 33b02f3d88..b59778a14d 100644 --- a/src/widgets/settings_widget.h +++ b/src/widgets/settings_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_SETTINGS_WIDGET_H /** Widgets of the #GameOptionsWindow class. */ -enum GameOptionsWidgets { +enum GameOptionsWidgets : WidgetID { WID_GO_TAB_GENERAL, ///< General tab. WID_GO_TAB_GRAPHICS, ///< Graphics tab. WID_GO_TAB_SOUND, ///< Sound tab. @@ -54,7 +54,7 @@ enum GameOptionsWidgets { }; /** Widgets of the #GameSettingsWindow class. */ -enum GameSettingsWidgets { +enum GameSettingsWidgets : WidgetID { WID_GS_FILTER, ///< Text filter. WID_GS_OPTIONSPANEL, ///< Panel widget containing the option lists. WID_GS_SCROLLBAR, ///< Scrollbar. @@ -71,7 +71,7 @@ enum GameSettingsWidgets { }; /** Widgets of the #CustomCurrencyWindow class. */ -enum CustomCurrencyWidgets { +enum CustomCurrencyWidgets : WidgetID { WID_CC_RATE_DOWN, ///< Down button. WID_CC_RATE_UP, ///< Up button. WID_CC_RATE, ///< Rate of currency. diff --git a/src/widgets/sign_widget.h b/src/widgets/sign_widget.h index 1a05dd349b..0ab5fe060d 100644 --- a/src/widgets/sign_widget.h +++ b/src/widgets/sign_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_SIGN_WIDGET_H /** Widgets of the #SignListWindow class. */ -enum SignListWidgets { +enum SignListWidgets : WidgetID { /* Name starts with SI instead of S, because of collision with SaveLoadWidgets */ WID_SIL_CAPTION, ///< Caption of the window. WID_SIL_LIST, ///< List of signs. @@ -22,7 +22,7 @@ enum SignListWidgets { }; /** Widgets of the #SignWindow class. */ -enum QueryEditSignWidgets { +enum QueryEditSignWidgets : WidgetID { WID_QES_CAPTION, ///< Caption of the window. WID_QES_LOCATION, ///< Scroll to sign location. WID_QES_TEXT, ///< Text of the query. diff --git a/src/widgets/smallmap_widget.h b/src/widgets/smallmap_widget.h index 79769a21cc..73c89df3d6 100644 --- a/src/widgets/smallmap_widget.h +++ b/src/widgets/smallmap_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_SMALLMAP_WIDGET_H /** Widgets of the #SmallMapWindow class. */ -enum SmallMapWidgets { +enum SmallMapWidgets : WidgetID { WID_SM_CAPTION, ///< Caption of the window. WID_SM_MAP_BORDER, ///< Border around the smallmap. WID_SM_MAP, ///< Panel containing the smallmap. diff --git a/src/widgets/station_widget.h b/src/widgets/station_widget.h index 491505e430..4ed97af79c 100644 --- a/src/widgets/station_widget.h +++ b/src/widgets/station_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_STATION_WIDGET_H /** Widgets of the #StationViewWindow class. */ -enum StationViewWidgets { +enum StationViewWidgets : WidgetID { WID_SV_CAPTION, ///< Caption of the window. WID_SV_GROUP, ///< label for "group by" WID_SV_GROUP_BY, ///< 'Group by' button @@ -32,7 +32,7 @@ enum StationViewWidgets { }; /** Widgets of the #CompanyStationsWindow class. */ -enum StationListWidgets { +enum StationListWidgets : WidgetID { /* Name starts with ST instead of S, because of collision with SaveLoadWidgets */ WID_STL_CAPTION, ///< Caption of the window. WID_STL_LIST, ///< The main panel, list of stations. @@ -56,7 +56,7 @@ enum StationListWidgets { }; /** Widgets of the #SelectStationWindow class. */ -enum JoinStationWidgets { +enum JoinStationWidgets : WidgetID { WID_JS_CAPTION, // Caption of the window. WID_JS_PANEL, // Main panel. WID_JS_SCROLLBAR, // Scrollbar of the panel. diff --git a/src/widgets/statusbar_widget.h b/src/widgets/statusbar_widget.h index bb8149e461..dae3efb5b9 100644 --- a/src/widgets/statusbar_widget.h +++ b/src/widgets/statusbar_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_STATUSBAR_WIDGET_H /** Widgets of the #StatusBarWindow class. */ -enum StatusbarWidgets { +enum StatusbarWidgets : WidgetID { WID_S_LEFT, ///< Left part of the statusbar; date is shown there. WID_S_MIDDLE, ///< Middle part; current news or company name or *** SAVING *** or *** PAUSED ***. WID_S_RIGHT, ///< Right part; bank balance. diff --git a/src/widgets/story_widget.h b/src/widgets/story_widget.h index 3492aed419..ce3ffd5dff 100644 --- a/src/widgets/story_widget.h +++ b/src/widgets/story_widget.h @@ -12,7 +12,7 @@ #define WIDGETS_STORY_WIDGET_H /** Widgets of the #GoalListWindow class. */ -enum StoryBookWidgets { +enum StoryBookWidgets : WidgetID { WID_SB_CAPTION, ///< Caption of the window. WID_SB_SEL_PAGE, ///< Page selector. WID_SB_PAGE_PANEL,///< Page body. diff --git a/src/widgets/subsidy_widget.h b/src/widgets/subsidy_widget.h index b3edd897c5..a2dfe8d1e8 100644 --- a/src/widgets/subsidy_widget.h +++ b/src/widgets/subsidy_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_SUBSIDY_WIDGET_H /** Widgets of the #SubsidyListWindow class. */ -enum SubsidyListWidgets { +enum SubsidyListWidgets : WidgetID { /* Name starts with SU instead of S, because of collision with SaveLoadWidgets. */ WID_SUL_PANEL, ///< Main panel of window. WID_SUL_SCROLLBAR, ///< Scrollbar of panel. diff --git a/src/widgets/terraform_widget.h b/src/widgets/terraform_widget.h index 777a2beb64..6b5796f9b5 100644 --- a/src/widgets/terraform_widget.h +++ b/src/widgets/terraform_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TERRAFORM_WIDGET_H /** Widgets of the #TerraformToolbarWindow class. */ -enum TerraformToolbarWidgets { +enum TerraformToolbarWidgets : WidgetID { WID_TT_SHOW_PLACE_OBJECT, ///< Should the place object button be shown? WID_TT_BUTTONS_START, ///< Start of pushable buttons. WID_TT_LOWER_LAND = WID_TT_BUTTONS_START, ///< Lower land button. @@ -27,7 +27,7 @@ enum TerraformToolbarWidgets { }; /** Widgets of the #ScenarioEditorLandscapeGenerationWindow class. */ -enum EditorTerraformToolbarWidgets { +enum EditorTerraformToolbarWidgets : WidgetID { WID_ETT_SHOW_PLACE_DESERT, ///< Should the place desert button be shown? WID_ETT_START, ///< Used for iterations. WID_ETT_DOTS = WID_ETT_START, ///< Invisible widget for rendering the terraform size on. diff --git a/src/widgets/timetable_widget.h b/src/widgets/timetable_widget.h index 15c44f33c5..2136b1ba2f 100644 --- a/src/widgets/timetable_widget.h +++ b/src/widgets/timetable_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TIMETABLE_WIDGET_H /** Widgets of the #TimetableWindow class. */ -enum VehicleTimetableWidgets { +enum VehicleTimetableWidgets : WidgetID { WID_VT_CAPTION, ///< Caption of the window. WID_VT_ORDER_VIEW, ///< Order view. WID_VT_TIMETABLE_PANEL, ///< Timetable panel. diff --git a/src/widgets/toolbar_widget.h b/src/widgets/toolbar_widget.h index d68de49700..36b53516af 100644 --- a/src/widgets/toolbar_widget.h +++ b/src/widgets/toolbar_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TOOLBAR_WIDGET_H /** Widgets of the #MainToolbarWindow class. */ -enum ToolbarNormalWidgets { +enum ToolbarNormalWidgets : WidgetID { WID_TN_PAUSE, ///< Pause the game. WID_TN_FAST_FORWARD, ///< Fast forward the game. WID_TN_SETTINGS, ///< Settings menu. @@ -49,7 +49,7 @@ enum ToolbarNormalWidgets { }; /** Widgets of the #ScenarioEditorToolbarWindow class. */ -enum ToolbarEditorWidgets { +enum ToolbarEditorWidgets : WidgetID { WID_TE_PAUSE, ///< Pause the game. WID_TE_FAST_FORWARD, ///< Fast forward the game. WID_TE_SETTINGS, ///< Settings menu. diff --git a/src/widgets/town_widget.h b/src/widgets/town_widget.h index f16a8a585e..f8d6c84ba0 100644 --- a/src/widgets/town_widget.h +++ b/src/widgets/town_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TOWN_WIDGET_H /** Widgets of the #TownDirectoryWindow class. */ -enum TownDirectoryWidgets { +enum TownDirectoryWidgets : WidgetID { WID_TD_SORT_ORDER, ///< Direction of sort dropdown. WID_TD_SORT_CRITERIA, ///< Criteria of sort dropdown. WID_TD_FILTER, ///< Filter of name. @@ -21,7 +21,7 @@ enum TownDirectoryWidgets { }; /** Widgets of the #TownAuthorityWindow class. */ -enum TownAuthorityWidgets { +enum TownAuthorityWidgets : WidgetID { WID_TA_CAPTION, ///< Caption of window. WID_TA_ZONE_BUTTON, ///< Turn on/off showing local authority zone. WID_TA_RATING_INFO, ///< Overview with ratings for each company. @@ -32,7 +32,7 @@ enum TownAuthorityWidgets { }; /** Widgets of the #TownViewWindow class. */ -enum TownViewWidgets { +enum TownViewWidgets : WidgetID { WID_TV_CAPTION, ///< Caption of window. WID_TV_VIEWPORT, ///< View of the center of the town. WID_TV_INFO, ///< General information about the town. @@ -45,7 +45,7 @@ enum TownViewWidgets { }; /** Widgets of the #FoundTownWindow class. */ -enum TownFoundingWidgets { +enum TownFoundingWidgets : WidgetID { WID_TF_NEW_TOWN, ///< Create a new town. WID_TF_RANDOM_TOWN, ///< Randomly place a town. WID_TF_MANY_RANDOM_TOWNS, ///< Randomly place many towns. diff --git a/src/widgets/transparency_widget.h b/src/widgets/transparency_widget.h index a187eeaa47..15cf7b731d 100644 --- a/src/widgets/transparency_widget.h +++ b/src/widgets/transparency_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TRANSPARENCY_WIDGET_H /** Widgets of the #TransparenciesWindow class. */ -enum TransparencyToolbarWidgets { +enum TransparencyToolbarWidgets : WidgetID { /* Button row. */ WID_TT_BEGIN, ///< First toggle button. WID_TT_SIGNS = WID_TT_BEGIN, ///< Signs background transparency toggle button. diff --git a/src/widgets/tree_widget.h b/src/widgets/tree_widget.h index 2cfc38ad40..ba22199d65 100644 --- a/src/widgets/tree_widget.h +++ b/src/widgets/tree_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_TREE_WIDGET_H /** Widgets of the #BuildTreesWindow class. */ -enum BuildTreesWidgets { +enum BuildTreesWidgets : WidgetID { WID_BT_TYPE_RANDOM, ///< Button to build random type of tree. WID_BT_SE_PANE, ///< Selection pane to show/hide scenario editor tools. WID_BT_MODE_NORMAL, ///< Select normal/rectangle planting mode. diff --git a/src/widgets/vehicle_widget.h b/src/widgets/vehicle_widget.h index 8e960bcb79..e74011b9cb 100644 --- a/src/widgets/vehicle_widget.h +++ b/src/widgets/vehicle_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_VEHICLE_WIDGET_H /** Widgets of the #VehicleViewWindow class. */ -enum VehicleViewWidgets { +enum VehicleViewWidgets : WidgetID { WID_VV_CAPTION, ///< Caption of window. WID_VV_VIEWPORT, ///< Viewport widget. WID_VV_START_STOP, ///< Start or stop this vehicle, and show information about the current state. @@ -31,7 +31,7 @@ enum VehicleViewWidgets { }; /** Widgets of the #RefitWindow class. */ -enum VehicleRefitWidgets { +enum VehicleRefitWidgets : WidgetID { WID_VR_CAPTION, ///< Caption of window. WID_VR_VEHICLE_PANEL_DISPLAY, ///< Display with a representation of the vehicle to refit. WID_VR_SHOW_HSCROLLBAR, ///< Selection widget for the horizontal scrollbar. @@ -44,7 +44,7 @@ enum VehicleRefitWidgets { }; /** Widgets of the #VehicleDetailsWindow class. */ -enum VehicleDetailsWidgets { +enum VehicleDetailsWidgets : WidgetID { WID_VD_CAPTION, ///< Caption of window. WID_VD_TOP_DETAILS, ///< Panel with generic details. WID_VD_INCREASE_SERVICING_INTERVAL, ///< Increase the servicing interval. @@ -61,7 +61,7 @@ enum VehicleDetailsWidgets { }; /** Widgets of the #VehicleListWindow class. */ -enum VehicleListWidgets { +enum VehicleListWidgets : WidgetID { WID_VL_CAPTION, ///< Caption of window (for non shared orders windows). WID_VL_CAPTION_SHARED_ORDERS, ///< Caption of window (for shared orders windows). WID_VL_CAPTION_SELECTION, ///< Selection for caption. diff --git a/src/widgets/viewport_widget.h b/src/widgets/viewport_widget.h index 81a6983e89..b83d3c55e3 100644 --- a/src/widgets/viewport_widget.h +++ b/src/widgets/viewport_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_VIEWPORT_WIDGET_H /** Widgets of the #ExtraViewportWindow class. */ -enum ExtraViewportWidgets { +enum ExtraViewportWidgets : WidgetID { WID_EV_CAPTION, ///< Caption of window. WID_EV_VIEWPORT, ///< The viewport. WID_EV_ZOOM_IN, ///< Zoom in. diff --git a/src/widgets/waypoint_widget.h b/src/widgets/waypoint_widget.h index bca6082bd1..f942b51bc5 100644 --- a/src/widgets/waypoint_widget.h +++ b/src/widgets/waypoint_widget.h @@ -11,7 +11,7 @@ #define WIDGETS_WAYPOINT_WIDGET_H /** Widgets of the #WaypointWindow class. */ -enum WaypointWidgets { +enum WaypointWidgets : WidgetID { WID_W_CAPTION, ///< Caption of window. WID_W_VIEWPORT, ///< The viewport on this waypoint. WID_W_CENTER_VIEW, ///< Center the main view on this waypoint. From f3b4d2a384e9c8ef6bbaa877bb83514566d3ad79 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 13:29:31 +0000 Subject: [PATCH 07/29] Fix #11649: Ignore disabling a widget that does not exist. (#11652) Orders window has different widget layouts depending on vehicle type which don't all have the same widgets, and therefore it tries to disable widgets that might not exist. Restore the old behaviour of ignoring such requests, instead of crashing. --- src/window_gui.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/window_gui.h b/src/window_gui.h index 69ecaf068a..49426c5000 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -327,7 +327,8 @@ public: */ inline void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat) { - this->GetWidget(widget_index)->SetDisabled(disab_stat); + NWidgetCore *nwid = this->GetWidget(widget_index); + if (nwid != nullptr) nwid->SetDisabled(disab_stat); } /** From d6e8e83052ab75e8ed0fe8124ae72b689c04d051 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 30 Dec 2023 14:40:09 +0100 Subject: [PATCH 08/29] Fix: [CI] patch in SHF_COMPRESSED symbol for our Linux Generic binaries (#11651) --- .github/workflows/release-linux.yml | 8 ++++++++ os/linux/shf-compressed.patch | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 os/linux/shf-compressed.patch diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index e267a4afa6..5d1fc85d8a 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -97,6 +97,14 @@ jobs: cmake --build . -j $(nproc) cmake --install . ) + + # The container we use is old enough, that it doesn't know SHF_COMPRESSED. + # But, breakpad needs this symbol to exist. So we patch it in our system + # libraries. + ( + cd / + patch -p1 < ${GITHUB_WORKSPACE}/os/linux/shf-compressed.patch + ) echo "::endgroup::" echo "::group::Install audio drivers" diff --git a/os/linux/shf-compressed.patch b/os/linux/shf-compressed.patch new file mode 100644 index 0000000000..6ec7865b31 --- /dev/null +++ b/os/linux/shf-compressed.patch @@ -0,0 +1,10 @@ +--- a/usr/include/elf.h 2023-12-30 13:46:27.038645199 +0100 ++++ b/usr/include/elf.h 2023-12-30 13:46:42.278641893 +0100 +@@ -365,6 +365,7 @@ + required */ + #define SHF_GROUP (1 << 9) /* Section is member of a group. */ + #define SHF_TLS (1 << 10) /* Section hold thread-local data. */ ++#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */ + #define SHF_MASKOS 0x0ff00000 /* OS-specific. */ + #define SHF_MASKPROC 0xf0000000 /* Processor-specific */ + #define SHF_ORDERED (1 << 30) /* Special ordering requirement From 3fec8ece5a2e0e535712316f0676cd6f290ee07a Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 30 Dec 2023 17:55:31 +0100 Subject: [PATCH 09/29] Change: [CI] always use "latest" image for our runners --- .github/workflows/ci-build.yml | 2 +- .github/workflows/release-linux.yml | 2 +- .github/workflows/release-macos.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 2da7d1870d..90b37433be 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -99,7 +99,7 @@ jobs: name: Linux (${{ matrix.name }}) - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: CC: ${{ matrix.compiler }} CXX: ${{ matrix.cxxcompiler }} diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 5d1fc85d8a..6fe8b281fe 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -12,7 +12,7 @@ jobs: linux: name: Linux (Generic) - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest container: # manylinux2014 is based on CentOS 7, but already has a lot of things # installed and preconfigured. It makes it easier to build OpenTTD. diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 26e3395642..04c2baa167 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -12,7 +12,7 @@ jobs: macos: name: MacOS - runs-on: macos-12 + runs-on: macos-latest env: MACOSX_DEPLOYMENT_TARGET: 10.13 From 086bd00f5da7c146508027186924b0bce96b7eab Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 30 Dec 2023 17:59:46 +0100 Subject: [PATCH 10/29] Fix: [CI] upgrade curl to a modern version to avoid patching other tools --- .github/workflows/release-linux.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 6fe8b281fe..bc65f12079 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -33,12 +33,23 @@ jobs: run: | tar -xf source.tar.gz --strip-components=1 - # dtolnay/rust-toolchain uses a curl argument (--retry-connrefused) that the curl shipped with our container doesn't support. - # So we need to do one part ourselves; the action takes over the rest and prepares the setup further. - - name: Prepare Rust toolchain + # curl is too old for most of the tools to work properly. For example, + # rust-toolchain doesn't work properly, neither vcpkg caching. + # The easier solution here is to upgrade curl. + - name: Update curl run: | - curl --proto '=https' --tlsv1.2 --retry 10 --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y - echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH + yum install -y \ + openssl-devel \ + # EOF + + mkdir /curl + cd /curl + curl -o curl-7.81.0.zip https://curl.se/download/curl-7.81.0.zip + unzip curl-7.81.0.zip + cd curl-7.81.0 + ./configure --with-ssl --with-zlib --prefix=/usr --libdir=/usr/lib64 + make -j $(nproc) + make install - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable From 5d86588a45ed65f2360ce5e577c096a7d6cadc3f Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 30 Dec 2023 18:00:38 +0100 Subject: [PATCH 11/29] Change: [CI] pkg-config is installed by default on latest runner --- .github/workflows/ci-build.yml | 9 --------- .github/workflows/release-macos.yml | 1 - 2 files changed, 10 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 90b37433be..4da94d2073 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -192,15 +192,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Install dependencies - env: - HOMEBREW_NO_AUTO_UPDATE: 1 - HOMEBREW_NO_INSTALL_CLEANUP: 1 - run: | - brew install \ - pkg-config \ - # EOF - - name: Prepare cache key id: key run: | diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 04c2baa167..53f326c419 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -40,7 +40,6 @@ jobs: echo "::group::Install brew dependencies" brew install \ pandoc \ - pkg-config \ # EOF echo "::endgroup::" From 0c064b5119f945aab1e8299dd2a285e5d18ea861 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 30 Dec 2023 17:58:18 +0100 Subject: [PATCH 12/29] Change: [CI] use vcpkg built-in caching mechanism --- .github/workflows/ci-build.yml | 46 ++++++++++++--------------- .github/workflows/release-linux.yml | 33 ++++++++++--------- .github/workflows/release-macos.yml | 22 +++++-------- .github/workflows/release-windows.yml | 25 +++++---------- 4 files changed, 52 insertions(+), 74 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 4da94d2073..d646a3a7bf 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -108,6 +108,14 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') + - name: Install dependencies run: | echo "::group::Update apt" @@ -192,18 +200,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare cache key - id: key - run: | - echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: /usr/local/share/vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - name: Prepare vcpkg run: | @@ -272,22 +275,13 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Prepare cache key - id: key - shell: powershell - run: | - # Work around caching failure with GNU tar - New-Item -Type Junction -Path vcpkg -Target c:\vcpkg - - Write-Output "image=$env:ImageOS-$env:ImageVersion" >> $env:GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - name: Prepare vcpkg shell: bash diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index bc65f12079..8a3fec19b5 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -17,11 +17,6 @@ jobs: # manylinux2014 is based on CentOS 7, but already has a lot of things # installed and preconfigured. It makes it easier to build OpenTTD. image: quay.io/pypa/manylinux2014_x86_64 - volumes: - - /usr/local/share/vcpkg:/vcpkg - env: - ImageOS: ${{ env.ImageOS }} - ImageVersion: ${{ env.ImageVersion }} steps: - name: Download source @@ -57,18 +52,13 @@ jobs: - name: Enable Rust cache uses: Swatinem/rust-cache@v2 - - name: Prepare cache key - id: key - run: | - echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 + - name: Setup vcpkg caching + uses: actions/github-script@v6 with: - path: /vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-release-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-release + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - name: Install dependencies run: | @@ -132,7 +122,16 @@ jobs: # We use vcpkg for our dependencies, to get more up-to-date version. echo "::group::Install vcpkg and dependencies" - # Make Python3 available for other packages. + git clone https://github.com/microsoft/vcpkg /vcpkg + + ( + cd /vcpkg + ./bootstrap-vcpkg.sh -disableMetrics + ) + + # Make Python3 available for other packages. This needs to be done + # first, as otherwise dependencies fail to build because Python3 is + # not available. /vcpkg/vcpkg install python3 ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3 diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 53f326c419..631584bc98 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -32,6 +32,14 @@ jobs: - name: Enable Rust cache uses: Swatinem/rust-cache@v2 + - name: Setup vcpkg caching + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') + - name: Install dependencies env: HOMEBREW_NO_AUTO_UPDATE: 1 @@ -47,20 +55,6 @@ jobs: cargo install dump_syms echo "::endgroup::" - - name: Prepare cache key - id: key - run: | - echo "image=$ImageOS-$ImageVersion" >> $GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 - with: - path: /usr/local/share/vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-release-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-release - ${{ steps.key.outputs.image }}-vcpkg-x64 - - name: Prepare vcpkg run: | vcpkg install \ diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 4b883675bd..3f7658083d 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -45,6 +45,14 @@ jobs: - name: Enable Rust cache uses: Swatinem/rust-cache@v2 + - name: Setup vcpkg caching + uses: actions/github-script@v6 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') + - name: Install dependencies shell: bash run: | @@ -56,23 +64,6 @@ jobs: cargo install dump_syms echo "::endgroup::" - - name: Prepare cache key - id: key - shell: powershell - run: | - # Work around caching failure with GNU tar - New-Item -Type Junction -Path vcpkg -Target c:\vcpkg - - Write-Output "image=$env:ImageOS-$env:ImageVersion" >> $env:GITHUB_OUTPUT - - - name: Enable vcpkg cache - uses: actions/cache@v3 - with: - path: vcpkg/installed - key: ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }}-1 # Increase the number whenever dependencies are modified - restore-keys: | - ${{ steps.key.outputs.image }}-vcpkg-${{ matrix.arch }} - - name: Prepare vcpkg shell: bash run: | From 49db7bbe081f9f103df04fd0d30b8ffd31508a2b Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 30 Dec 2023 18:00:24 +0100 Subject: [PATCH 13/29] Change: add vcpkg.json to instruct vcpkg what dependencies we require This works on all OSes, making it far simpler for any developer to jump in. Just install vcpkg, run "vcpkg install" in our root, and you have all the dependencies. --- .github/workflows/ci-build.yml | 45 +++++++++------------- .github/workflows/release-linux.yml | 28 +++----------- .github/workflows/release-macos.yml | 17 --------- .github/workflows/release-windows.yml | 17 --------- .gitignore | 1 + COMPILING.md | 4 +- vcpkg.json | 54 +++++++++++++++++++++++++++ 7 files changed, 80 insertions(+), 86 deletions(-) create mode 100644 vcpkg.json diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index d646a3a7bf..e5e6e6e5a4 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -135,9 +135,15 @@ jobs: zlib1g-dev \ # EOF - sudo vcpkg install \ - breakpad \ - # EOF + echo "::group::Install vcpkg dependencies" + + # Disable vcpkg integration, as we mostly use system libraries. + mv vcpkg.json vcpkg-disabled.json + + # We only use breakpad from vcpkg, as its CMake files + # are a bit special. So the Ubuntu's variant doesn't work. + vcpkg install breakpad + echo "::endgroup::" env: DEBIAN_FRONTEND: noninteractive @@ -176,10 +182,15 @@ jobs: - name: Test run: | - cd build - ctest -j $(nproc) --timeout 120 + ( + cd build + ctest -j $(nproc) --timeout 120 + ) + + # Re-enable vcpkg. + mv vcpkg-disabled.json vcpkg.json - # Check no tracked files have been modified + # Check no tracked files have been modified. git diff --exit-code macos: @@ -208,17 +219,6 @@ jobs: core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - - name: Prepare vcpkg - run: | - vcpkg install --triplet=${{ matrix.arch }}-osx \ - breakpad \ - curl \ - liblzma \ - libpng \ - lzo \ - zlib \ - # EOF - - name: Install OpenGFX run: | mkdir -p ~/Documents/OpenTTD/baseset @@ -283,17 +283,6 @@ jobs: core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite') - - name: Prepare vcpkg - shell: bash - run: | - vcpkg install --triplet=${{ matrix.arch }}-windows-static \ - breakpad \ - liblzma \ - libpng \ - lzo \ - zlib \ - # EOF - - name: Install OpenGFX shell: bash run: | diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 8a3fec19b5..e7151347dc 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -132,28 +132,12 @@ jobs: # Make Python3 available for other packages. This needs to be done # first, as otherwise dependencies fail to build because Python3 is # not available. - /vcpkg/vcpkg install python3 - ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3 - - # SDL2 needs dbus, but dbus default install comes with libsystemd - # and some of libsystemd deps fail to build on our quite old linux. - # So just install basic dbus without any extra deps. - /vcpkg/vcpkg install dbus[core] - - # Now we can install OpenTTD dependencies - /vcpkg/vcpkg install \ - breakpad \ - curl[http2] \ - fontconfig \ - freetype \ - harfbuzz \ - icu \ - liblzma \ - libpng \ - lzo \ - sdl2 \ - zlib \ - # EOF + ( + cd / + + /vcpkg/vcpkg install python3 + ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3 + ) echo "::endgroup::" echo "::group::Install breakpad dependencies" diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 631584bc98..ca4d1ac412 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -55,23 +55,6 @@ jobs: cargo install dump_syms echo "::endgroup::" - - name: Prepare vcpkg - run: | - vcpkg install \ - breakpad:x64-osx \ - breakpad:arm64-osx \ - curl:x64-osx \ - curl:arm64-osx \ - liblzma:x64-osx \ - liblzma:arm64-osx \ - libpng:x64-osx \ - libpng:arm64-osx \ - lzo:x64-osx \ - lzo:arm64-osx \ - zlib:x64-osx \ - zlib:arm64-osx \ - # EOF - - name: Install GCC problem matcher uses: ammaraskar/gcc-problem-matcher@master diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 3f7658083d..602c6050a0 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -64,23 +64,6 @@ jobs: cargo install dump_syms echo "::endgroup::" - - name: Prepare vcpkg - shell: bash - run: | - vcpkg install --triplet=${{ matrix.arch }}-windows-static \ - liblzma \ - libpng \ - lzo \ - zlib \ - # EOF - - # arm64-windows-static is not (yet) supported for breakpad. - if [ "${{ matrix.arch }}" != "arm64" ]; then - vcpkg install --triplet=${{ matrix.arch }}-windows-static \ - breakpad \ - # EOF - fi - - name: Install MSVC problem matcher uses: ammaraskar/msvc-problem-matcher@master diff --git a/.gitignore b/.gitignore index 4eed0f0e47..3d0376aa94 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ docs/aidocs/* docs/gamedocs/* docs/source/* /out +/vcpkg_installed diff --git a/COMPILING.md b/COMPILING.md index 5ed519553e..578b5e4568 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -59,8 +59,8 @@ the `static` versions, and OpenTTD currently needs the following dependencies: To install both the x64 (64bit) and x86 (32bit) variants (though only one is necessary), you can use: ```ps -.\vcpkg install breakpad:x64-windows-static liblzma:x64-windows-static libpng:x64-windows-static lzo:x64-windows-static zlib:x64-windows-static -.\vcpkg install breakpad:x86-windows-static liblzma:x86-windows-static libpng:x86-windows-static lzo:x86-windows-static zlib:x86-windows-static +.\vcpkg install --triplet=x64-windows-static +.\vcpkg install --triplet=x86-windows-static ``` You can open the folder (as a CMake project). CMake will be detected, and you can compile from there. diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000000..15079f7a31 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,54 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", + "dependencies": [ + { + "name": "breakpad", + "platform": "!(windows & arm)" + }, + { + "name": "curl", + "platform": "linux", + "features": [ + "http2" + ] + }, + { + "name": "dbus", + "platform": "linux", + "default-features": false + }, + { + "name": "fontconfig", + "platform": "linux" + }, + { + "name": "freetype", + "platform": "linux" + }, + { + "name": "harfbuzz", + "platform": "linux" + }, + { + "name": "icu", + "platform": "linux" + }, + { + "name": "liblzma" + }, + { + "name": "libpng" + }, + { + "name": "lzo" + }, + { + "name": "sdl2", + "platform": "linux" + }, + { + "name": "zlib" + } + ], + "builtin-baseline": "94cf042e6b7713913a3b3150f3ca3d0f4550f7c4" +} From 1e60734660fccfb12189c6d6f3c971d8c0995daa Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Sat, 30 Dec 2023 17:46:32 +0000 Subject: [PATCH 14/29] Fix: Compilation with DEBUG_DUMP_COMMANDS enabled (#11607) --- src/command.cpp | 4 ++-- src/command_func.h | 6 +++--- src/network/network.cpp | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/command.cpp b/src/command.cpp index c2f16a55f6..48fa93ffcb 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -272,9 +272,9 @@ void CommandHelperBase::InternalPostResult(const CommandCost &res, TileIndex til } /** Helper to make a desync log for a command. */ -void CommandHelperBase::LogCommandExecution(Commands cmd, StringID err_message, TileIndex tile, const CommandDataBuffer &args, bool failed) +void CommandHelperBase::LogCommandExecution(Commands cmd, StringID err_message, const CommandDataBuffer &args, bool failed) { - Debug(desync, 1, "{}: {:08x}; {:02x}; {:02x}; {:08x}; {:08x}; {:06x}; {} ({})", failed ? "cmdf" : "cmd", TimerGameCalendar::date, TimerGameCalendar::date_fract, (int)_current_company, cmd, err_message, tile, FormatArrayAsHex(args), GetCommandName(cmd)); + Debug(desync, 1, "{}: {:08x}; {:02x}; {:02x}; {:08x}; {:08x}; {} ({})", failed ? "cmdf" : "cmd", (uint32_t)TimerGameCalendar::date.base(), TimerGameCalendar::date_fract, (int)_current_company, cmd, err_message, FormatArrayAsHex(args), GetCommandName(cmd)); } /** diff --git a/src/command_func.h b/src/command_func.h index 35aadb7591..47ce1ffe24 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -102,7 +102,7 @@ protected: static bool InternalExecutePrepTest(CommandFlags cmd_flags, TileIndex tile, Backup &cur_company); static std::tuple InternalExecuteValidateTestAndPrepExec(CommandCost &res, CommandFlags cmd_flags, bool estimate_only, bool network_command, Backup &cur_company); static CommandCost InternalExecuteProcessResult(Commands cmd, CommandFlags cmd_flags, const CommandCost &res_test, const CommandCost &res_exec, Money extra_cash, TileIndex tile, Backup &cur_company); - static void LogCommandExecution(Commands cmd, StringID err_message, TileIndex tile, const CommandDataBuffer &args, bool failed); + static void LogCommandExecution(Commands cmd, StringID err_message, const CommandDataBuffer &args, bool failed); }; /** @@ -385,7 +385,7 @@ protected: auto [exit_test, desync_log, send_net] = InternalExecuteValidateTestAndPrepExec(ExtractCommandCost(res), cmd_flags, estimate_only, network_command, cur_company); if (exit_test) { - if (desync_log) LogCommandExecution(Tcmd, err_message, tile, EndianBufferWriter::FromValue(args), true); + if (desync_log) LogCommandExecution(Tcmd, err_message, EndianBufferWriter::FromValue(args), true); cur_company.Restore(); return res; } @@ -403,7 +403,7 @@ protected: return {}; } - if (desync_log) LogCommandExecution(Tcmd, err_message, tile, EndianBufferWriter::FromValue(args), false); + if (desync_log) LogCommandExecution(Tcmd, err_message, EndianBufferWriter::FromValue(args), false); /* Actually try and execute the command. */ Tret res2 = std::apply(CommandTraits::proc, std::tuple_cat(std::make_tuple(flags | DC_EXEC), args)); diff --git a/src/network/network.cpp b/src/network/network.cpp index e4fe00f5ad..0914d476f2 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -1055,21 +1055,21 @@ void NetworkGameLoop() #ifdef DEBUG_DUMP_COMMANDS /* Loading of the debug commands from -ddesync>=1 */ static FILE *f = FioFOpenFile("commands.log", "rb", SAVE_DIR); - static Date next_date = 0; + static TimerGameCalendar::Date next_date(0); static uint32_t next_date_fract; static CommandPacket *cp = nullptr; static bool check_sync_state = false; static uint32_t sync_state[2]; if (f == nullptr && next_date == 0) { Debug(desync, 0, "Cannot open commands.log"); - next_date = 1; + next_date = TimerGameCalendar::Date(1); } while (f != nullptr && !feof(f)) { if (TimerGameCalendar::date == next_date && TimerGameCalendar::date_fract == next_date_fract) { if (cp != nullptr) { NetworkSendCommand(cp->cmd, cp->err_msg, nullptr, cp->company, cp->data); - Debug(desync, 0, "Injecting: {:08x}; {:02x}; {:02x}; {:08x}; {:06x}; {} ({})", TimerGameCalendar::date, TimerGameCalendar::date_fract, (int)_current_company, cp->cmd, cp->tile, FormatArrayAsHex(cp->data), GetCommandName(cp->cmd)); + Debug(desync, 0, "Injecting: {:08x}; {:02x}; {:02x}; {:08x}; {} ({})", TimerGameCalendar::date, TimerGameCalendar::date_fract, (int)_current_company, cp->cmd, FormatArrayAsHex(cp->data), GetCommandName(cp->cmd)); delete cp; cp = nullptr; } @@ -1109,8 +1109,10 @@ void NetworkGameLoop() int company; uint cmd; char buffer[256]; - int ret = sscanf(p, "%x; %x; %x; %x; %x; %x; %255s", &next_date, &next_date_fract, &company, &cmd, &cp->err_msg, &cp->tile, buffer); + uint32_t next_date_raw; + int ret = sscanf(p, "%x; %x; %x; %x; %x; %255s", &next_date_raw, &next_date_fract, &company, &cmd, &cp->err_msg, buffer); assert(ret == 6); + next_date = TimerGameCalendar::Date((int32_t)next_date_raw); cp->company = (CompanyID)company; cp->cmd = (Commands)cmd; @@ -1119,13 +1121,15 @@ void NetworkGameLoop() size_t arg_len = strlen(buffer); for (size_t i = 0; i + 1 < arg_len; i += 2) { byte e = 0; - std::from_chars(buffer + i, buffer + i + 1, e, 16); + std::from_chars(buffer + i, buffer + i + 2, e, 16); args.emplace_back(e); } cp->data = args; } else if (strncmp(p, "join: ", 6) == 0) { /* Manually insert a pause when joining; this way the client can join at the exact right time. */ - int ret = sscanf(p + 6, "%x; %x", &next_date, &next_date_fract); + uint32_t next_date_raw; + int ret = sscanf(p + 6, "%x; %x", &next_date_raw, &next_date_fract); + next_date = TimerGameCalendar::Date((int32_t)next_date_raw); assert(ret == 2); Debug(desync, 0, "Injecting pause for join at {:08x}:{:02x}; please join when paused", next_date, next_date_fract); cp = new CommandPacket(); @@ -1134,7 +1138,9 @@ void NetworkGameLoop() cp->data = EndianBufferWriter<>::FromValue(CommandTraits::Args{ PM_PAUSED_NORMAL, true }); _ddc_fastforward = false; } else if (strncmp(p, "sync: ", 6) == 0) { - int ret = sscanf(p + 6, "%x; %x; %x; %x", &next_date, &next_date_fract, &sync_state[0], &sync_state[1]); + uint32_t next_date_raw; + int ret = sscanf(p + 6, "%x; %x; %x; %x", &next_date_raw, &next_date_fract, &sync_state[0], &sync_state[1]); + next_date = TimerGameCalendar::Date((int32_t)next_date_raw); assert(ret == 4); check_sync_state = true; } else if (strncmp(p, "msg: ", 5) == 0 || strncmp(p, "client: ", 8) == 0 || From 6215e9bf7713ddfdecb0be30da873038bf28c42e Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 18:24:26 +0000 Subject: [PATCH 15/29] Fix #11655: Crash due to NWidgetMatrix modifying widget->index. (#11657) NWidgetMatrix modifies its child widget's index to indicate which element is to be drawn, which now causes issues with code that does not know about stuffing extra data into the index. Instead, let NWidgetMatrix store the currently processing element, and retrieve this information from the matrix widget while child widgets are being drawn. This means only widgets that are children of NWidgetMatrix need to know anything about their extra data. --- src/object_gui.cpp | 15 ++++++++------- src/rail_gui.cpp | 16 ++++++++-------- src/road_gui.cpp | 8 ++++---- src/widget.cpp | 30 ++++++++++++++++-------------- src/widget_type.h | 6 ++++-- 5 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 0976af70af..046a55c9f9 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -306,7 +306,7 @@ public: void DrawWidget(const Rect &r, WidgetID widget) const override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BO_CLASS_LIST: { Rect mr = r.Shrink(WidgetDimensions::scaled.matrix); uint pos = 0; @@ -333,7 +333,8 @@ public: * look nice in all layouts, we use the 4x4 layout (smallest previews) as starting point. For the bigger * previews in the layouts with less views we add space homogeneously on all sides, so the 4x4 preview-rectangle * is centered in the 2x1, 1x2 resp. 1x1 buttons. */ - uint matrix_height = this->GetWidget(WID_BO_OBJECT_MATRIX)->current_y; + const NWidgetMatrix *matrix = this->GetWidget(WID_BO_OBJECT_MATRIX); + uint matrix_height = matrix->current_y; DrawPixelInfo tmp_dpi; /* Set up a clipping area for the preview. */ @@ -345,7 +346,7 @@ public: const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id]; DrawOrigTileSeqInGUI(ir.Width() / 2 - 1, (ir.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE); } else { - DrawNewObjectTileInGUI(ir.Width() / 2 - 1, (ir.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec, GB(widget, 16, 16)); + DrawNewObjectTileInGUI(ir.Width() / 2 - 1, (ir.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec, matrix->GetCurrentElement()); } } break; @@ -353,7 +354,7 @@ public: case WID_BO_SELECT_IMAGE: { ObjectClass *objclass = ObjectClass::Get(_selected_object_class); - int obj_index = objclass->GetIndexFromUI(GB(widget, 16, 16)); + int obj_index = objclass->GetIndexFromUI(this->GetWidget(WID_BO_SELECT_MATRIX)->GetCurrentElement()); if (obj_index < 0) break; const ObjectSpec *spec = objclass->GetSpec(obj_index); if (spec == nullptr) break; @@ -496,7 +497,7 @@ public: void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BO_CLASS_LIST: { auto it = this->vscroll->GetScrolledItemFromWidget(this->object_classes, pt.y, this, widget); if (it == this->object_classes.end()) break; @@ -508,14 +509,14 @@ public: case WID_BO_SELECT_IMAGE: { ObjectClass *objclass = ObjectClass::Get(_selected_object_class); - int num_clicked = objclass->GetIndexFromUI(GB(widget, 16, 16)); + int num_clicked = objclass->GetIndexFromUI(this->GetWidget(WID_BO_SELECT_MATRIX)->GetCurrentElement()); if (num_clicked >= 0 && objclass->GetSpec(num_clicked)->IsAvailable()) this->SelectOtherObject(num_clicked); break; } case WID_BO_OBJECT_SPRITE: if (_selected_object_index != -1) { - _selected_object_view = GB(widget, 16, 16); + _selected_object_view = this->GetWidget(WID_BO_OBJECT_MATRIX)->GetCurrentElement(); this->SelectOtherObject(_selected_object_index); // Re-select the object for a different view. } break; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 31644321a5..494ba7d0e2 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1240,7 +1240,7 @@ public: { DrawPixelInfo tmp_dpi; - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BRAS_PLATFORM_DIR_X: { /* Set up a clipping area for the '/' station preview */ Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); @@ -1285,7 +1285,7 @@ public: } case WID_BRAS_IMAGE: { - uint16_t type = GB(widget, 16, 16); + uint16_t type = this->GetWidget(WID_BRAS_MATRIX)->GetCurrentElement(); assert(type < _railstation.station_count); /* Check station availability callback */ const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type); @@ -1325,7 +1325,7 @@ public: void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BRAS_PLATFORM_DIR_X: case WID_BRAS_PLATFORM_DIR_Y: this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); @@ -1470,7 +1470,7 @@ public: } case WID_BRAS_IMAGE: { - uint16_t y = GB(widget, 16, 16); + uint16_t y = this->GetWidget(WID_BRAS_MATRIX)->GetCurrentElement(); if (y >= _railstation.station_count) return; /* Check station availability callback */ @@ -2095,9 +2095,9 @@ struct BuildRailWaypointWindow : PickerWindowBase { void DrawWidget(const Rect &r, WidgetID widget) const override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BRW_WAYPOINT: { - uint16_t type = this->list.at(GB(widget, 16, 16)); + uint16_t type = this->list.at(this->GetWidget(WID_BRW_WAYPOINT_MATRIX)->GetCurrentElement()); const StationSpec *statspec = this->waypoints->GetSpec(type); DrawPixelInfo tmp_dpi; @@ -2118,9 +2118,9 @@ struct BuildRailWaypointWindow : PickerWindowBase { void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BRW_WAYPOINT: { - uint16_t sel = GB(widget, 16, 16); + uint16_t sel = this->GetWidget(WID_BRW_WAYPOINT_MATRIX)->GetCurrentElement(); assert(sel < this->list.size()); uint16_t type = this->list.at(sel); diff --git a/src/road_gui.cpp b/src/road_gui.cpp index c83307c141..55cbc60e28 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1409,7 +1409,7 @@ public: void DrawWidget(const Rect &r, WidgetID widget) const override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BROS_STATION_NE: case WID_BROS_STATION_SE: case WID_BROS_STATION_SW: @@ -1451,7 +1451,7 @@ public: } case WID_BROS_IMAGE: { - uint16_t type = GB(widget, 16, 16); + uint16_t type = this->GetWidget(WID_BROS_MATRIX)->GetCurrentElement(); assert(type < _roadstop_gui_settings.roadstop_count); const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(type); @@ -1497,7 +1497,7 @@ public: void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - switch (GB(widget, 0, 16)) { + switch (widget) { case WID_BROS_STATION_NE: case WID_BROS_STATION_SE: case WID_BROS_STATION_SW: @@ -1549,7 +1549,7 @@ public: } case WID_BROS_IMAGE: { - uint16_t y = GB(widget, 16, 16); + uint16_t y = this->GetWidget(WID_BROS_MATRIX)->GetCurrentElement(); if (y >= _roadstop_gui_settings.roadstop_count) return; const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(y); diff --git a/src/widget.cpp b/src/widget.cpp index 1517fb8a2f..323e7157d2 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1965,8 +1965,8 @@ void NWidgetMatrix::SetColour(Colours colour) } /** - * Sets the clicked widget in the matrix. - * @param clicked The clicked widget. + * Sets the clicked element in the matrix. + * @param clicked The clicked element. */ void NWidgetMatrix::SetClicked(int clicked) { @@ -2014,15 +2014,20 @@ void NWidgetMatrix::SetScrollbar(Scrollbar *sb) this->sb = sb; } +/** + * Get current element. + * @returns index of current element. + */ +int NWidgetMatrix::GetCurrentElement() const +{ + return this->current_element; +} + void NWidgetMatrix::SetupSmallestSize(Window *w) { assert(this->head != nullptr); assert(this->head->next == nullptr); - /* Reset the widget number. */ - NWidgetCore *nw = dynamic_cast(this->head); - assert(nw != nullptr); - SB(nw->index, 16, 16, 0); this->head->SetupSmallestSize(w); Dimension padding = { (uint)this->pip_pre + this->pip_post, (uint)this->pip_pre + this->pip_post}; @@ -2087,8 +2092,8 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) int widget_row = (y - base_offs_y - (int)this->pip_pre - this->pos_y) / this->widget_h; - int sub_wid = (widget_row + start_y) * this->widgets_x + start_x + widget_col; - if (sub_wid >= this->count) return nullptr; + this->current_element = (widget_row + start_y) * this->widgets_x + start_x + widget_col; + if (this->current_element >= this->count) return nullptr; NWidgetCore *child = dynamic_cast(this->head); assert(child != nullptr); @@ -2097,8 +2102,6 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) this->pos_y + this->pip_pre + widget_row * this->widget_h + base_offs_y, child->smallest_x, child->smallest_y, rtl); - SB(child->index, 16, 16, sub_wid); - return child->GetWidgetFromPos(x, y); } @@ -2137,12 +2140,11 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) if (offs_x >= (int)this->current_x) continue; /* Do we have this many widgets? */ - int sub_wid = y * this->widgets_x + x; - if (sub_wid >= this->count) break; + this->current_element = y * this->widgets_x + x; + if (this->current_element >= this->count) break; child->AssignSizePosition(ST_RESIZE, offs_x, offs_y, child->smallest_x, child->smallest_y, rtl); - child->SetLowered(this->clicked == sub_wid); - SB(child->index, 16, 16, sub_wid); + child->SetLowered(this->clicked == this->current_element); child->Draw(w); } } diff --git a/src/widget_type.h b/src/widget_type.h index 10b2360bd4..5a7c686a27 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -564,6 +564,7 @@ public: void SetClicked(int clicked); void SetCount(int count); void SetScrollbar(Scrollbar *sb); + int GetCurrentElement() const; void SetupSmallestSize(Window *w) override; void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override; @@ -574,8 +575,9 @@ public: protected: 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. + int clicked; ///< The currently clicked element. + int count; ///< Amount of valid elements. + int current_element; ///< The element currently being processed. Scrollbar *sb; ///< The scrollbar we're associated with. private: int widget_w; ///< The width of the child widget including inter spacing. From fd782ada050529fe1ac5e56e7b06bf76d4e2393a Mon Sep 17 00:00:00 2001 From: translators Date: Sat, 30 Dec 2023 18:38:27 +0000 Subject: [PATCH 16/29] Update: Translations from eints russian: 11 changes by lexuslatvia finnish: 12 changes by hpiirai latvian: 217 changes by lexuslatvia --- src/lang/finnish.txt | 16 ++- src/lang/latvian.txt | 266 +++++++++++++++++++++++++++++++++++-------- src/lang/russian.txt | 14 ++- 3 files changed, 240 insertions(+), 56 deletions(-) diff --git a/src/lang/finnish.txt b/src/lang/finnish.txt index d161ecb8c3..72aff10a6b 100644 --- a/src/lang/finnish.txt +++ b/src/lang/finnish.txt @@ -2196,12 +2196,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Näytä STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Näytä tieajoneuvojen väriteemat STR_LIVERY_SHIP_TOOLTIP :{BLACK}Näytä laivojen väriteemat STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Näytä ilma-alusten väriteemat +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Näytä junaryhmien värit +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Näytä ajoneuvoryhmien värit +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Näytä laivaryhmien värit +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Näytä ilma-alusryhmien värit STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Valitse valitun kaavan ensisijainen väri. Ctrl+napsautus asettaa tämän värin kaikille kaavoille. STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Valitse valitun kaavan toissijainen väri. Ctrl+napsautus asettaa tämän värin kaikille kaavoille. STR_LIVERY_PANEL_TOOLTIP :{BLACK}Valitse muutettava väriteema, tai valitse useita Ctrl pohjassa. Paina valintalaatikkoa valitaksesi teeman +STR_LIVERY_TRAIN_GROUP_EMPTY :Junaryhmiä ei ole muodostettu +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Ajoneuvoryhmiä ei ole muodostettu +STR_LIVERY_SHIP_GROUP_EMPTY :Laivaryhmiä ei ole muodostettu +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Ilma-alusryhmiä ei ole muodostettu ###length 23 -STR_LIVERY_DEFAULT :Normaalit tunnusvärit +STR_LIVERY_DEFAULT :Oletusväritys STR_LIVERY_STEAM :Höyryveturi STR_LIVERY_DIESEL :Dieselveturi STR_LIVERY_ELECTRIC :Sähköveturi @@ -2711,7 +2719,7 @@ STR_RAIL_TOOLBAR_TOOLTIP_BUILD_AUTORAIL :{BLACK}Rakenna STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING :{BLACK}Rakenna veturitalli (junien ostamista ja huoltoa varten). Shift vaihtaa rakennustilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT :{BLACK}Muunna raide reittipisteeksi. Ctrl liittää reittipisteet. Shift vaihtaa muuntotilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_STATION :{BLACK}Rakenna rautatieasema. Ctrl liittää asemat. Shift vaihtaa rakennustilan ja kustannusarvion välillä -STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS :{BLACK}Rakenna opastimia. Ctrl vaihtaa joko siipiopastimet tai valo-opastimet{}Vetäminen rakentaa opastimia suoralle rautatielle. Ctrl rakentaa opastimia seuraavaan risteykseen saakka{}Ctrl+Click avaa opastimenvalintaikkunan. Shift vaihtaa rakennustilan ja kustannusarvion välillä +STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS :{BLACK}Rakenna opastimia. Ctrl vaihtaa siipi- ja valo-opastimien välillä{}Vetäminen rakentaa opastimia suoralle rataosuudelle. Ctrl rakentaa opastimia seuraavaan risteykseen tai opastimeen saakka{}Ctrl+napsautus avaa opastimenvalintaikkunan. Shift vaihtaa rakennustilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_BRIDGE :{BLACK}Rakenna rautatiesilta. Shift vaihtaa rakennustilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TUNNEL :{BLACK}Rakenna rautatietunneli. Shift vaihtaa rakennustilan ja kustannusarvion välillä STR_RAIL_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR :{BLACK}Rautatien, opastimien, reittipisteiden ja asemien rakentaminen/poisto päälle/pois. Pidä pohjassa Ctrl-näppäintä poistaaksesi myös aseman tai reittipisteen alla olevat raiteet @@ -4653,9 +4661,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Kirjaink STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Kytke kirjainkoon täsmäys, kun verrataan tekoälyn viestejä pysäytysmerkkijonoon STR_AI_DEBUG_CONTINUE :{BLACK}Jatka STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Jatka tekoälyn suorittamista -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Näytä tämän tekoälyn virheenkorjaustiedot +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Näytä tämän tekoälyn virheenkorjaustiedot. Ctrl+napsautus avaa uuteen ikkunaan STR_AI_GAME_SCRIPT :{BLACK}Peliskripti -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Tarkista peliskriptin loki +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Tarkista peliskriptin loki. Ctrl+napsautus avaa uuteen ikkunaan STR_ERROR_AI_NO_AI_FOUND :Sopivaa tekoälyä ei löydetty.{}Tämä tekoäly ei tee mitään.{}Voit ladata useita tekoälyjä ”online-sisältö” -järjestelmän kautta STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Yksi käynnissä olevista skripteistä kaatui. Ilmoita tästä skriptin kehittäjälle liittäen mukaan kuvankaappaus Tekoälyn/peliskriptin virheenjäljitys -ikkunasta diff --git a/src/lang/latvian.txt b/src/lang/latvian.txt index e616355e56..4d4c04f8bc 100644 --- a/src/lang/latvian.txt +++ b/src/lang/latvian.txt @@ -176,7 +176,7 @@ STR_COLOUR_DEFAULT :Noklusējuma ###length 17 STR_COLOUR_DARK_BLUE :Tumši zila STR_COLOUR_PALE_GREEN :Gaiši zaļa -STR_COLOUR_PINK :Sārta +STR_COLOUR_PINK :Rozā STR_COLOUR_YELLOW :Dzeltena STR_COLOUR_RED :Sarkana STR_COLOUR_LIGHT_BLUE :Gaiši zila @@ -185,7 +185,7 @@ STR_COLOUR_DARK_GREEN :Tumši zaļa STR_COLOUR_BLUE :Zila STR_COLOUR_CREAM :Krēmkrāsa STR_COLOUR_MAUVE :Gaišsārti violeta -STR_COLOUR_PURPLE :Purpura +STR_COLOUR_PURPLE :Violets STR_COLOUR_ORANGE :Oranža STR_COLOUR_BROWN :Brūna STR_COLOUR_GREY :Pelēka @@ -193,6 +193,23 @@ STR_COLOUR_WHITE :Balta STR_COLOUR_RANDOM :Nejaušs ###length 17 +STR_COLOUR_SECONDARY_DARK_BLUE :Tumši Zila +STR_COLOUR_SECONDARY_PALE_GREEN :Gaiši Zaļa +STR_COLOUR_SECONDARY_SECONDARY_PINK :Rozā +STR_COLOUR_SECONDARY_YELLOW :Dzeltena +STR_COLOUR_SECONDARY_RED :Sarkana +STR_COLOUR_SECONDARY_LIGHT_BLUE :Gaiši Zila +STR_COLOUR_SECONDARY_GREEN :Zaļa +STR_COLOUR_SECONDARY_DARK_GREEN :Tumši zaļa +STR_COLOUR_SECONDARY_BLUE :Zila +STR_COLOUR_SECONDARY_CREAM :Krēmkrāsa +STR_COLOUR_SECONDARY_MAUVE :Purpursarkana +STR_COLOUR_SECONDARY_PURPLE :Violets +STR_COLOUR_SECONDARY_ORANGE :Oranžs +STR_COLOUR_SECONDARY_BROWN :Brūna +STR_COLOUR_SECONDARY_GREY :Pelēka +STR_COLOUR_SECONDARY_WHITE :Balta +STR_COLOUR_SECONDARY_SAME_AS_PRIMARY :Tāds, ka primārais # Units used in OpenTTD @@ -200,6 +217,7 @@ STR_UNITS_VELOCITY_IMPERIAL :{DECIMAL}{NBSP} STR_UNITS_VELOCITY_METRIC :{DECIMAL}{NBSP}km/h STR_UNITS_VELOCITY_SI :{DECIMAL}{NBSP}m/s STR_UNITS_VELOCITY_GAMEUNITS :{DECIMAL}{NBSP}lauciņi/diena +STR_UNITS_VELOCITY_KNOTS :{DECIMAL}{NBSP}mezgli STR_UNITS_POWER_IMPERIAL :{DECIMAL}{NBSP}ZS STR_UNITS_POWER_METRIC :{DECIMAL}{NBSP}ZS @@ -239,6 +257,9 @@ STR_UNITS_HEIGHT_IMPERIAL :{DECIMAL}{NBSP} STR_UNITS_HEIGHT_METRIC :{DECIMAL}{NBSP}m STR_UNITS_HEIGHT_SI :{DECIMAL}{NBSP}m +STR_UNITS_DAYS :{COMMA}{NBSP}dien{P a as ""} +STR_UNITS_SECONDS :{COMMA}{NBSP}sekund{P e s ''''} +STR_UNITS_TICKS :{COMMA}{NBSP}tick{P šķi šķi s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filters: @@ -279,7 +300,7 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_SHIP_TOOLTIP :{BLACK}Ieslēdz STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP :{BLACK}Ieslēdzot šo iestatījumu tiks parādīti arī paslēptie lidaparāti # Query window -STR_BUTTON_DEFAULT :{BLACK}Noklusējums +STR_BUTTON_DEFAULT :{BLACK}Noklusējuma STR_BUTTON_CANCEL :{BLACK}Atcelt STR_BUTTON_OK :{BLACK}Labi STR_WARNING_PASSWORD_SECURITY :{YELLOW}Brīdinājums: servera administrators var izlasīt jebkuru tekstu, kas šeit tiek ievadīts. @@ -349,9 +370,9 @@ STR_GOTO_ORDER_VIEW_TOOLTIP :{BLACK}Atvērt ###length 31 STR_TOOLBAR_TOOLTIP_PAUSE_GAME :{BLACK}Pauzēt spēli STR_TOOLBAR_TOOLTIP_FORWARD :{BLACK}Paātrināta spēle -STR_TOOLBAR_TOOLTIP_OPTIONS :{BLACK}Opcijas -STR_TOOLBAR_TOOLTIP_SAVE_GAME_ABANDON_GAME :{BLACK}Saglabāt spēli, pamest spēli, iziet -STR_TOOLBAR_TOOLTIP_DISPLAY_MAP :{BLACK}Rādīt karti, papildu skatvietu vai zīmju sarakstu +STR_TOOLBAR_TOOLTIP_OPTIONS :{BLACK}Opcijas un iestatījumi +STR_TOOLBAR_TOOLTIP_SAVE_GAME_ABANDON_GAME :{BLACK}Saglabājiet, ielādējiet vai pametiet spēli, iziet no programmas +STR_TOOLBAR_TOOLTIP_DISPLAY_MAP :{BLACK}Rādīt karti, papildu skata logu, kravas plūsmu vai zīmju sarakstu STR_TOOLBAR_TOOLTIP_DISPLAY_TOWN_DIRECTORY :{BLACK}Rādīt pilsētu sarakstu STR_TOOLBAR_TOOLTIP_DISPLAY_SUBSIDIES :{BLACK}Rādīt subsīdijas STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_STATIONS :{BLACK}Rādīt uzņēmuma staciju sarakstu @@ -359,9 +380,9 @@ STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_FINANCES :{BLACK}Rādīt STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_GENERAL :{BLACK}Rādīt uzņēmuma vispārējo informāciju STR_TOOLBAR_TOOLTIP_DISPLAY_STORY_BOOK :{BLACK}Rādīt stāstu grāmatu STR_TOOLBAR_TOOLTIP_DISPLAY_GOALS_LIST :{BLACK}Rādīt mērķu sarakstu -STR_TOOLBAR_TOOLTIP_DISPLAY_GRAPHS :{BLACK}Rādīt diagrammas +STR_TOOLBAR_TOOLTIP_DISPLAY_GRAPHS :{BLACK}Rādīt uzņēmumu grafikus un kravas maksājumu likmes STR_TOOLBAR_TOOLTIP_DISPLAY_COMPANY_LEAGUE :{BLACK}Rādīt uzņēmumu rangu sarakstu -STR_TOOLBAR_TOOLTIP_FUND_CONSTRUCTION_OF_NEW :{BLACK}Finansēt jaunas ražotnes būvniecību vai uzskaitīt visas ražotnes +STR_TOOLBAR_TOOLTIP_FUND_CONSTRUCTION_OF_NEW :{BLACK}Izpētiet nozares vai finansējiet jaunas nozares celtniecību STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_TRAINS :{BLACK}Rādīt uzņēmuma vilcienu sarakstu. Ctrl+klikšķis pārslēdz grupu/transportlīdzekļu saraksta atvēršanu STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_ROAD_VEHICLES :{BLACK}Rādīt uzņēmuma autotransporta sarakstu. Ctrl+klikšķis pārslēdz grupu/transportlīdzekļu saraksta atvēršanu STR_TOOLBAR_TOOLTIP_DISPLAY_LIST_OF_COMPANY_SHIPS :{BLACK}Rādīt uzņēmuma kuģu sarakstu. Ctrl+klikšķis pārslēdz grupu/transportlīdzekļu saraksta atvēršanu @@ -375,8 +396,8 @@ STR_TOOLBAR_TOOLTIP_BUILD_SHIP_DOCKS :{BLACK}Būvēt STR_TOOLBAR_TOOLTIP_BUILD_AIRPORTS :{BLACK}Būvēt lidostas STR_TOOLBAR_TOOLTIP_LANDSCAPING :{BLACK}Atvērt ainavas rīkjoslu, lai paceltu/nolaistu zemes līmeni, stādītu kokus utt. STR_TOOLBAR_TOOLTIP_SHOW_SOUND_MUSIC_WINDOW :{BLACK}Rādīt skaņas/mūzikas logu -STR_TOOLBAR_TOOLTIP_SHOW_LAST_MESSAGE_NEWS :{BLACK}Rādīt pēdējos ziņojumus/avīžu ziņas, ziņojumu rādīšanas opcijas -STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION :{BLACK}Informācija par zemes platību, konsole, skriptu atkļūdošana, ekrānuzņēmumi, par OpenTTD +STR_TOOLBAR_TOOLTIP_SHOW_LAST_MESSAGE_NEWS :{BLACK}Rādīt pēdējo ziņojumu/ziņu pārskatu, ziņojumu vēsturi vai dzēst visus ziņojumus +STR_TOOLBAR_TOOLTIP_LAND_BLOCK_INFORMATION :{BLACK}Informācija par zemi, ekrānuzņēmums par OpenTTD un izstrādātāju rīkiem STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR :{BLACK}Pārslēgt rīkjoslas # Extra tooltips for the scenario editor toolbar @@ -392,7 +413,7 @@ STR_SCENEDIT_TOOLBAR_TOWN_GENERATION :{BLACK}Pilsētu STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION :{BLACK}Ražotņu radīšana STR_SCENEDIT_TOOLBAR_ROAD_CONSTRUCTION :{BLACK}Ceļu būvēšana STR_SCENEDIT_TOOLBAR_TRAM_CONSTRUCTION :{BLACK}Tramvaju sliežu ceļu būvniecība -STR_SCENEDIT_TOOLBAR_PLANT_TREES :{BLACK}Stādīt kokus. Shift pārslēdz būvēšanu/izmaksu tāmes rādīšanu +STR_SCENEDIT_TOOLBAR_PLANT_TREES :{BLACK}Iestādiet kokus. Ctrl atlasa apgabalu pa diagonāli. Shift pārslēdz celt/parādīt izmaksas STR_SCENEDIT_TOOLBAR_PLACE_SIGN :{BLACK}Novietot zīmi STR_SCENEDIT_TOOLBAR_PLACE_OBJECT :{BLACK}Novietojiet objektu. Ctrl atlasa apgabalu pa diagonāli. Shift pārslēdz ēku/rāda izmaksu tāmi @@ -433,7 +454,7 @@ STR_FILE_MENU_EXIT :Iziet # Map menu STR_MAP_MENU_MAP_OF_WORLD :Pasaules karte STR_MAP_MENU_EXTRA_VIEWPORT :Papildu skatvieta -STR_MAP_MENU_LINGRAPH_LEGEND :Kravu plūsmas apzīmējumi +STR_MAP_MENU_LINGRAPH_LEGEND :Kravas plūsmas apzīmējums STR_MAP_MENU_SIGN_LIST :Zīmju saraksts # Town menu @@ -492,6 +513,7 @@ STR_NEWS_MENU_DELETE_ALL_MESSAGES :Dzēst visus zi # About menu STR_ABOUT_MENU_LAND_BLOCK_INFO :Zemes platības informācija +STR_ABOUT_MENU_HELP :Palīdzība un rokasgrāmatas STR_ABOUT_MENU_TOGGLE_CONSOLE :Atvērt/aizvērt konsoli STR_ABOUT_MENU_AI_DEBUG :MI/spēles skriptu atkļūdošana STR_ABOUT_MENU_SCREENSHOT :Ekrānuzņēmums @@ -500,6 +522,7 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :Par 'OpenTTD' STR_ABOUT_MENU_SPRITE_ALIGNER :Gariņu līdzinātājs STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Pārslēgt saistītās kastes STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Pārslēgt netīru bloku krāsojumu +STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES :Pārslēgt logrīku kontūras # Place in highscore window ###length 15 @@ -592,7 +615,7 @@ STR_GRAPH_OPERATING_PROFIT_CAPTION :{WHITE}Darbība STR_GRAPH_INCOME_CAPTION :{WHITE}Ienākumu diagramma STR_GRAPH_CARGO_DELIVERED_CAPTION :{WHITE}Pārvadātās kravas vienības STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION :{WHITE}Uzņēmuma darbības vērtējumi (maksimālais ir 1000) -STR_GRAPH_COMPANY_VALUES_CAPTION :{WHITE}Uzņēmuma vērtības +STR_GRAPH_COMPANY_VALUES_CAPTION :{WHITE}Uzņēmuma vērtības diagramma STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION :{WHITE}Kravas apmaksas cenas STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL :{TINY_FONT}{BLACK}Dienas pārvadājumos @@ -701,6 +724,7 @@ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Klikšķ STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Klikšķināt uz mūzikas celiņa, lai to izdzēstu no pašreizējās programmas (tikai Pielāgotā1 un Pielāgotā2) # Highscore window +STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}Lielākie uzņēmumi STR_HIGHSCORE_POSITION :{BIG_FONT}{BLACK}{COMMA}. STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN :Darījumu cilvēks STR_HIGHSCORE_PERFORMANCE_TITLE_ENTREPRENEUR :Uzņēmējs @@ -832,7 +856,7 @@ STR_NEWS_COMPANY_BANKRUPT_TITLE :{BIG_FONT}{BLAC STR_NEWS_COMPANY_BANKRUPT_DESCRIPTION :{BIG_FONT}{BLACK}{STRING} kreditori slēdza un visi īpašumi tika izpārdoti! STR_NEWS_COMPANY_LAUNCH_TITLE :{BIG_FONT}{BLACK}Darbu sāk jauns transporta uzņēmums! STR_NEWS_COMPANY_LAUNCH_DESCRIPTION :{BIG_FONT}{BLACK}{STRING} sāk būvdarbus netālu no {TOWN}! -STR_NEWS_MERGER_TAKEOVER_TITLE :{BIG_FONT}{BLACK}{STRING} tiek pārņemts {STRING} izpildījumā! +STR_NEWS_MERGER_TAKEOVER_TITLE :{BIG_FONT}{BLACK}{STRING} ir pārņēmis {STRING} par neizpaužamu summu! STR_PRESIDENT_NAME_MANAGER :{BLACK}{PRESIDENT_NAME}{}(vadītājs) STR_NEWS_NEW_TOWN :{BLACK}{BIG_FONT}{STRING} pabalstīja jaunas pilsētas - {TOWN} dibināšanu! @@ -889,6 +913,8 @@ STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE :{BLACK}Tagad ir STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP :{BLACK}Atvērt grupas logu, fokusēts uz transportlīdzekļu grupu +STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST :{WHITE}{STATION} vairs nepieņem: {CARGO_LIST} +STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST :{WHITE}{STATION} tagad pieņem: {CARGO_LIST} STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED :{BIG_FONT}{BLACK}Subsīdijas piedāvājums beidzies:{}{}{STRING} no {STRING} uz {STRING} subsidēšana ir atcelta STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE :{BIG_FONT}{BLACK}Subsidēšana atcelta:{}{}{STRING} pārvadājumi no {STRING} uz {STRING} turpmāk vairs netiek subsidēti @@ -913,12 +939,27 @@ STR_EXTRA_VIEW_MOVE_MAIN_TO_VIEW_TT :{BLACK}Kopēt # Game options window STR_GAME_OPTIONS_CAPTION :{WHITE}Spēles opcijas +STR_GAME_OPTIONS_TAB_GENERAL :Vispārīgi +STR_GAME_OPTIONS_TAB_GENERAL_TT :{BLACK}Izvēlieties vispārīgos iestatījumus +STR_GAME_OPTIONS_TAB_GRAPHICS :Grafika +STR_GAME_OPTIONS_TAB_GRAPHICS_TT :{BLACK}Izvēlieties grafikas iestatījumus +STR_GAME_OPTIONS_TAB_SOUND :Skaņa +STR_GAME_OPTIONS_TAB_SOUND_TT :{BLACK}Izvēlieties skaņas un mūzikas iestatījumus +STR_GAME_OPTIONS_VOLUME :Skaļums +STR_GAME_OPTIONS_SFX_VOLUME :Skaņas efekti +STR_GAME_OPTIONS_MUSIC_VOLUME :Mūzika +STR_GAME_OPTIONS_VOLUME_0 :0% +STR_GAME_OPTIONS_VOLUME_25 :25% +STR_GAME_OPTIONS_VOLUME_50 :50% +STR_GAME_OPTIONS_VOLUME_75 :75% +STR_GAME_OPTIONS_VOLUME_100 :100% STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME :{BLACK}Naudas vienības STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP :{BLACK}Naudas vienību izvēle +STR_GAME_OPTIONS_CURRENCY_CODE :{STRING} ({STRING}) ###length 42 STR_GAME_OPTIONS_CURRENCY_GBP :Lielbritānijas sterliņu mārciņas @@ -940,7 +981,7 @@ STR_GAME_OPTIONS_CURRENCY_ISK :Īslandes krona STR_GAME_OPTIONS_CURRENCY_ITL :Itālijas liras STR_GAME_OPTIONS_CURRENCY_NLG :Nīderlandes guldeņi STR_GAME_OPTIONS_CURRENCY_NOK :Norvēģijas kronas -STR_GAME_OPTIONS_CURRENCY_PLN :Polijas zloti +STR_GAME_OPTIONS_CURRENCY_PLN :Polijas Zlots STR_GAME_OPTIONS_CURRENCY_RON :Rumānijas lejas STR_GAME_OPTIONS_CURRENCY_RUR :Krievijas rubļi STR_GAME_OPTIONS_CURRENCY_SIT :Slovēnijas tolāri @@ -970,6 +1011,10 @@ STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP :{BLACK}Izvēlē # Autosave dropdown ###length 5 STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF :Izslēgta +STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_10_MINUTES :Ik pēc 10 minūtēm +STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_30_MINUTES :Ik pēc 30 minūtēm +STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_60_MINUTES :Ik pēc 60 minūtēm +STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_120_MINUTES :Ik pēc 120 minūtēm STR_GAME_OPTIONS_LANGUAGE :{BLACK}Valoda STR_GAME_OPTIONS_LANGUAGE_TOOLTIP :{BLACK}Saskarnes valodas izvēle @@ -1006,6 +1051,13 @@ STR_GAME_OPTIONS_GUI_SCALE_3X :3x STR_GAME_OPTIONS_GUI_SCALE_4X :4x STR_GAME_OPTIONS_GUI_SCALE_5X :5x +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_FRAME :{BLACK}Automatizēta aptauja +STR_GAME_OPTIONS_PARTICIPATE_SURVEY :{BLACK}Piedalieties automatizētā aptaujā +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_TOOLTIP :{BLACK}Ja ieslēgts, OpenTTD pārsūtīs aptauju, izejot no spēles +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_LINK :{BLACK}Par aptauju un privātumu +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_LINK_TOOLTIP :{BLACK}Tiek atvērts pārlūks ar plašāku informāciju par automatizēto aptauju +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_PREVIEW :{BLACK}Priekšskatīt aptaujas rezultātus +STR_GAME_OPTIONS_PARTICIPATE_SURVEY_PREVIEW_TOOLTIP :{BLACK}Rādīt pašreizējās spēles aptaujas rezultātus STR_GAME_OPTIONS_GRAPHICS :{BLACK}Grafika @@ -1015,7 +1067,7 @@ STR_GAME_OPTIONS_REFRESH_RATE_ITEM :{NUM}Hz STR_GAME_OPTIONS_REFRESH_RATE_WARNING :{WHITE}Atsvaidzes intensitāte, kas lielāka par 60 Hz, var ietekmēt veiktspēju. STR_GAME_OPTIONS_BASE_GRF :{BLACK}Pamata grafikas kopa -STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Atlasīt lietošanai pamata grafikas kopu +STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Atlasiet izmantojamo pamata grafiku (to nevar mainīt spēlē, tikai no galvenās izvēlnes) STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP :{BLACK}Papildinformācija par pamata grafikas kopu STR_GAME_OPTIONS_BASE_SFX :{BLACK}Pamata skaņas kopa @@ -1026,6 +1078,7 @@ STR_GAME_OPTIONS_BASE_MUSIC :{BLACK}Pamata m STR_GAME_OPTIONS_BASE_MUSIC_TOOLTIP :{BLACK}Atlasīt lietošanai pamata mūzikas kopu STR_GAME_OPTIONS_BASE_MUSIC_DESCRIPTION_TOOLTIP :{BLACK}Papildinformācija par pamata mūzikas kopu +STR_BASESET_STATUS :{STRING} {RED}({NUM} trūkst/bojāts fail{P s i ""}) STR_ERROR_RESOLUTION_LIST_FAILED :{WHITE}Neizdevās saņemt sarakstu ar atbalstītajām izšķirtspējām STR_ERROR_FULLSCREEN_FAILED :{WHITE}Pilnekrāna spēles iestatīšana neizdevās @@ -1135,6 +1188,7 @@ STR_CONFIG_SETTING_EXPAND_ALL :{BLACK}Izvērst STR_CONFIG_SETTING_COLLAPSE_ALL :{BLACK}Sakļaut visu STR_CONFIG_SETTING_RESET_ALL :{BLACK}Atiestatīt visas vērtības STR_CONFIG_SETTING_NO_EXPLANATION_AVAILABLE_HELPTEXT :(skaidrojums nav pieejams) +STR_CONFIG_SETTING_VALUE :{PUSH_COLOUR}{ORANGE}{STRING}{POP_COLOUR} STR_CONFIG_SETTING_DEFAULT_VALUE :{LTBLUE}Noklusējuma vērtība: {ORANGE}{STRING} STR_CONFIG_SETTING_TYPE :{LTBLUE}Iestatījuma veids: {ORANGE}{STRING} STR_CONFIG_SETTING_TYPE_CLIENT :lietotāja iestatījums (netiek iekļauts saglabājumos, ietekmē visas spēles) @@ -1188,6 +1242,7 @@ STR_CONFIG_SETTING_HORIZONTAL_POS_LEFT :pa kreisi STR_CONFIG_SETTING_HORIZONTAL_POS_CENTER :centrā STR_CONFIG_SETTING_HORIZONTAL_POS_RIGHT :pa labi +STR_CONFIG_SETTING_SECONDS_VALUE :{COMMA}{NBSP}sekund{P 0 i es ""} STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN :Maksimālais sākotnējais aizdevums: {STRING} STR_CONFIG_SETTING_MAXIMUM_INITIAL_LOAN_HELPTEXT :Maksimālais aizdevuma daudzums, ko uzņēmums var izsniegt (neskaitot inflāciju) @@ -1316,7 +1371,7 @@ STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT :Jaunie rīkojum STR_CONFIG_SETTING_NONSTOP_BY_DEFAULT_HELPTEXT :Transportlīdzeklis parasti pietur pie katras caurbraucamās stacijas. Ieslēdzot šo iestatījumu, tas dosies cauri visām ceļa stacijām uz savu galamērķi bez pieturām. Ņemiet vērā, ka šis iestatījums nosaka noklusējuma vērtību tikai jaunajiem rīkojumiem. Tomēr ir iespējams katru rīkojumu iestatīt arī atsevišķi STR_CONFIG_SETTING_STOP_LOCATION :Jaunie vilcienu rīkojumi noklusējumā liek apstāties perona {STRING} -STR_CONFIG_SETTING_STOP_LOCATION_HELPTEXT :Vieta, kur vilciens apstāsies pie perona noklusējumā. 'Sākumā' ir pie ieejas stacijā, 'vidū' nozīmē perona vidū, un 'beigās' ir tālu prom no ieejas. Ņemiet vērā, ka šis iestatījums nosaka noklusējuma vērtību tikai jaunajiem rīkojumiem. Taču individuālos rīkojumos var noteikt atšķirīgu rīcību +STR_CONFIG_SETTING_STOP_LOCATION_HELPTEXT :Vieta, kur vilciens pēc noklusējuma apstāsies pie perona. “Tuvākais gals” nozīmē tuvu ieejas punktam, “vidējais” nozīmē platformas vidu un “tālais gals” nozīmē tālu no ieejas punkta. Ņemiet vērā, ka šis iestatījums nosaka tikai noklusējuma vērtību jauniem pasūtījumiem. Atsevišķu pasūtījumu pieturas vietu var iestatīt, noklikšķinot uz pasūtījuma teksta ###length 3 STR_CONFIG_SETTING_STOP_LOCATION_NEAR_END :sākumā STR_CONFIG_SETTING_STOP_LOCATION_MIDDLE :vidū @@ -1359,9 +1414,11 @@ STR_CONFIG_SETTING_PLANE_CRASHES_NONE :Nav* STR_CONFIG_SETTING_PLANE_CRASHES_REDUCED :samazināts STR_CONFIG_SETTING_PLANE_CRASHES_NORMAL :parasts +STR_CONFIG_SETTING_CROSSING_WITH_COMPETITOR :Atļaut dzelzceļa pārbrauktuves ar ceļiem vai sliedēm, kas pieder sāncenšiem: {STRING} +STR_CONFIG_SETTING_CROSSING_WITH_COMPETITOR_HELPTEXT :Atļaut būvēt dzelzceļa pārbrauktuves uz sāncenšu piederošiem ceļiem vai sliedēm -STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD :Atļaut caurbraucamas pieturvietas uz pilsētai piederošiem ceļiem: {STRING} -STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD_HELPTEXT :Ļauj būvēt caurbraucamas pieturvietas uz pilsētai piederošiem ceļiem +STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD :Atļaut caurbraucamo ceļu pieturas uz ceļiem, kas pieder pilsētām: {STRING} +STR_CONFIG_SETTING_STOP_ON_TOWN_ROAD_HELPTEXT :Atļaut būvēt caurbraucamo ceļu pieturas uz ceļiem, kas pieder pilsētām STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD :Atļaut caurbraucamas pieturvietas uz sāncenšu ceļiem: {STRING} STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD_HELPTEXT :Ļauj būvēt caurbraucamas pieturvietas uz citiem uzņēmumiem piederošiem ceļiem STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES :{WHITE}Šo iestatījumu nav iespējams mainīt, kad tur ir transportlīdzekļi @@ -1372,6 +1429,8 @@ STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT :Kad ieslēgts, STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR :Sākotnējā uzņēmuma krāsa: {STRING} STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_HELPTEXT :Izvēlieties uzņēmuma sākotnējo krāsu +STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_SECONDARY :Uzņēmuma sākuma sekundārā krāsa: {STRING} +STR_CONFIG_SETTING_COMPANY_STARTING_COLOUR_SECONDARY_HELPTEXT :Izvēlieties uzņēmuma sākuma sekundāro krāsu, ja izmantojat NewGRF, kas to ļauj. STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS :Lidostas darbosies mūžīgi: {STRING} STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT :Ieslēdzot šo iestatījumu, katrs lidostas veids pēc tā ieviešanas vienmēr ir pieejams @@ -1434,7 +1493,7 @@ STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL :Sākotnējais STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS :TerraGenesis STR_CONFIG_SETTING_TERRAIN_TYPE :Reljefa veids: {STRING} -STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :(Tikai TerraGenesis) Ainavas kalnainība +STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :Izvēlieties ainavas pauguru un kalnu augstumu STR_CONFIG_SETTING_INDUSTRY_DENSITY :Industriju blīvums: {STRING} STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :Iestatiet, cik industrijas jāģenerē un kāds līmenis jāuztur spēles laikā @@ -1443,18 +1502,18 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Naftas industri STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Limits, cik tālu no kartes malām drīkst taisīt naftas pārstrādes rūpnīcas un un naftas ieguves platformas. Uz salu kartēm tas nodrošina, ka šīs konstrukcijas tiek būvētas piekrastēs. Uz kartēm, kas ir lielākas par 256 lauciņiem šī vērtība tiek palielināta. STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Sniega līnijas augstums: {STRING} -STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Kontrolē, kādā augstumā sākas sniegs subarktiskajā ainavā. Sniegs ietekmē arī nozares ražošanas un pilsētu izaugsmes prasības. Var mainīt tikai, izmantojot scenāriju redaktoru, vai citādi aprēķināts, izmantojot “sniega segumu” +STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Izvēlieties, kādā augstumā sākas sniegs subarktiskajā ainavā. Sniegs ietekmē arī nozares ražošanas un pilsētu izaugsmi. Var mainīt tikai, izmantojot scenāriju redaktoru, vai citādi aprēķināt, izmantojot "sniega segumu" STR_CONFIG_SETTING_SNOW_COVERAGE :Sniega pārklājums: {STRING} -STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Kontrolē aptuveno sniega daudzumu subarktiskajā ainavā. Sniegs ietekmē arī nozares ražošanas un pilsētu izaugsmes prasības. Izmanto tikai karšu ģenerēšanas laikā. Zeme tieši virs jūras līmeņa vienmēr ir bez sniega +STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Izvēlieties aptuveno sniega daudzumu subarktiskajā ainavā. Sniegs ietekmē arī nozares ražošanas un pilsētu izaugsmei. Izmanto tikai kartes ģenerēšanas laikā. Uz jūras līmeņa un piekrastes abpagaliem nekad nav sniega. STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_DESERT_COVERAGE :Tuksneša pārklājums: {STRING} -STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Kontrolējiet aptuveno tuksneša daudzumu tropiskajā ainavā. Tuksnesis ietekmē arī nozaru veidošanos. Izmanto tikai karšu ģenerēšanas laikā +STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Izvēlieties aptuveno tuksneša daudzumu tropiskajā ainavā. Tuksnesis ietekmē arī nozares ražošanas un pilsētu izaugsmi. Izmanto tikai kartes ģenerēšanas laikā STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Apvidus nelīdzenums: {STRING} -STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(Tikai TerraGenesis) Izvēlieties pauguru biežumu — gludās ainavās ir mazāk pauguru, bet tie ir plaši izvērsti. Nelīdzenā ainavā ir daudz pauguru, kas var izskatīties vienveidīgi. +STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :Izvēlieties pauguru formu un skaitu. Gludās ainavās ir mazāk, bet platāku pauguru, savukārt nelīdzenās ainavās ir vairāk, mazāku kalnu. ###length 4 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :Ļoti gluda STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH :Gluda @@ -1462,7 +1521,7 @@ STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH :Nelīdzena STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH :Ļoti nelīdzena STR_CONFIG_SETTING_VARIETY :Dažādības sadalījums: {STRING} -STR_CONFIG_SETTING_VARIETY_HELPTEXT :(Tikai TerraGenesis) Nosaka, vai karte satur gan kalnus, gan līdzenumus. Tā kā šis padara karti tikai plakanāku, citus iestatījumus vajadzētu pārslēgt uz kalnainumu +STR_CONFIG_SETTING_VARIETY_HELPTEXT :Izvēlieties, vai kartē ir gan kalni, gan līdzenas vietas. Jo augstāka atšķirība, jo lielākas atšķirības kalnu un līdzenu apgabalu augstumā. STR_CONFIG_SETTING_RIVER_AMOUNT :Upju daudzums: {STRING} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Izvēlieties, cik daudz upju ģenerēt @@ -1482,6 +1541,7 @@ STR_CONFIG_SETTING_ROAD_SIDE_LEFT :Brauc pa kreiso STR_CONFIG_SETTING_ROAD_SIDE_RIGHT :Brauc pa labo pusi STR_CONFIG_SETTING_HEIGHTMAP_ROTATION :Augstumu kartes pagriešana: {STRING} +STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP :Izvēlieties, kādā veidā augstuma kartes attēls tiek pagriezts, lai tas iekļautos spēles pasaulē ###length 2 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE :Pret pulksteņa rādītāja virzienu STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE :Pulksteņa rādītāja virzienā @@ -1574,6 +1634,9 @@ STR_CONFIG_SETTING_RIGHT_MOUSE_BTN_EMU_OFF :Izslēgta STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE :Aizvērt logu ar labo klikšķi: {STRING} STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_HELPTEXT :Labais klikšķis logā aizver logu. Izslēdz paskaidres parādīšanu ar labo klikšķi! ###length 3 +STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_NO :Nē +STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_YES :Jā +STR_CONFIG_SETTING_RIGHT_MOUSE_WND_CLOSE_YES_EXCEPT_STICKY :Jā, izņemot lipīgo STR_CONFIG_SETTING_DATE_FORMAT_IN_SAVE_NAMES :Lietot {STRING} datuma formātu saglabāto spēļu nosaukumos STR_CONFIG_SETTING_DATE_FORMAT_IN_SAVE_NAMES_HELPTEXT :Datuma formāts spēļu saglabājuma failu nosaukumos @@ -1599,7 +1662,12 @@ STR_CONFIG_SETTING_ADVANCED_VEHICLE_LISTS_HELPTEXT :Ieslēgt papild STR_CONFIG_SETTING_LOADING_INDICATORS :Lietot piekraušanas rādītājus: {STRING} STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Izvēlēties piekraušanas rādītāju attēlošanu virs iekraujamiem un izkraujamiem transportlīdzekļiem +STR_CONFIG_SETTING_TIMETABLE_MODE :Laika vienības laika grafikiem: {STRING} +STR_CONFIG_SETTING_TIMETABLE_MODE_HELPTEXT :Izvēlieties transportlīdzekļu kustības sarakstos izmantotās laika vienības ###length 3 +STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Dienas +STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Sekundes +STR_CONFIG_SETTING_TIMETABLE_MODE_TICKS :Tiki STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Kustības sarakstos rādīt pienākšanu un atiešanu: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Kustības sarakstos rādīt paredzamos pienākšanas un atiešanas laikus @@ -1694,7 +1762,7 @@ STR_CONFIG_SETTING_SCRIPT_MAX_MEMORY_HELPTEXT :Cik daudz atmi STR_CONFIG_SETTING_SCRIPT_MAX_MEMORY_VALUE :{COMMA} MiB STR_CONFIG_SETTING_SERVINT_ISPERCENT :Apkopju starplaiki procentos: {STRING} -STR_CONFIG_SETTING_SERVINT_ISPERCENT_HELPTEXT :Izvēlieties, vai transportlīdzekļu apkopi veikt pēc fiksēta laika kopš iepriekšējās apkopes vai, kad uzticamība nokrīt zem kāda noteiktas daļas no maksimālās uzticamības +STR_CONFIG_SETTING_SERVINT_ISPERCENT_HELPTEXT :Ja tas ir ieslēgts, transportlīdzekļi mēģina veikt apkopi, kad to uzticamība samazinās par noteiktu procentuālo daļu no maksimālās uzticamības.{}{}Piemēram, ja transportlīdzekļa maksimālā uzticamība ir 90% un apkopes intervāls ir 20%, transportlīdzeklis mēģinās veikt apkopi, kad tas sasniedz 72% ticamību. STR_CONFIG_SETTING_SERVINT_TRAINS :Vilcienu apkopju noklusējuma starplaiks: {STRING} STR_CONFIG_SETTING_SERVINT_TRAINS_HELPTEXT :Izvēlēties jaunajiem sliežu transportlīdzekļiem apkopju noklusējuma starplaiku, ja tiem tas nav noteikts @@ -1824,7 +1892,7 @@ STR_CONFIG_SETTING_ALLOW_TOWN_ROADS_HELPTEXT :Ļauj pilsētā STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS :Pilsētam ir atļauts būvēt vienlīmeņa krustojumus: {STRING} STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS_HELPTEXT :Šā iestatījuma ieslēgšana pilsētām atļauj būvēt vienlīmeņa krustojumus -STR_CONFIG_SETTING_NOISE_LEVEL :Atļaut pilsētām kontrolēt trokšņu līmeni lidostās: {STRING} +STR_CONFIG_SETTING_NOISE_LEVEL :Lidostas izvietojuma ierobežojums, pamatojoties uz trokšņa līmeni: {STRING} STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :Ja šis iestatījums ir izslēgts, tad katrā pilsētā var būt divas lidostas. Ja šis iestatījums ir ieslēgts, tad lidostu daudzums pilsētā ir ierobežots ar pilsētas piekrišanu troksnim, kas ir atkarīga no iedzīvotāju skaita, lidostas lieluma un attāluma STR_CONFIG_SETTING_TOWN_FOUNDING :Pilsētu dibināšana: {STRING} @@ -1899,13 +1967,17 @@ STR_CONFIG_SETTING_LARGER_TOWNS_DISABLED :neviena STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER :Pilsētu sākuma lieluma reizinātājs: {STRING} STR_CONFIG_SETTING_CITY_SIZE_MULTIPLIER_HELPTEXT :Pilsētu vidējais lielums attiecībā pret parastām apdzīvotām vietām spēles sākumā +STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL :Atjaunināt sadalījuma grafu ik pēc {STRING} +STR_CONFIG_SETTING_LINKGRAPH_RECALC_INTERVAL_HELPTEXT :Laiks starp turpmākajiem saišu grafa pārrēķiniem. Katrs pārrēķins aprēķina viena grafa komponentes plānus. Tas nozīmē, ka vērtība X šim iestatījumam nenozīmē, ka visa diagramma tiks atjaunināta ik pēc X sekundēm. Būs tikai daži komponenti. Jo īsāku to iestatīsit, jo vairāk CPU laika būs nepieciešams tā aprēķināšanai. Jo ilgāk to iestatīsit, jo ilgāks laiks paies, līdz sāksies kravu sadale jaunos maršrutos. +STR_CONFIG_SETTING_LINKGRAPH_RECALC_TIME :Izplatības grafa pārrēķināšanai izmantojiet {STRING} +STR_CONFIG_SETTING_LINKGRAPH_RECALC_TIME_HELPTEXT :Laiks, kas nepieciešams katram saišu grafa komponenta pārrēķinam. Kad tiek sākts pārrēķins, tiek izveidots pavediens, kuram ir atļauts darboties šo sekunžu skaitu. Jo īsāku iestatījumu iestatāt, jo lielāka iespēja, ka pavediens nebūs pabeigts paredzētajā laikā. Tad spēle apstājas, līdz pāriet ielāde. Jo ilgāk jūs to iestatāt, jo ilgāks laiks nepieciešams, līdz izplatīšana tiek atjaunināta, mainoties maršrutiem. STR_CONFIG_SETTING_DISTRIBUTION_PAX :Pasažieru izplatīšanas režīms: {STRING} -STR_CONFIG_SETTING_DISTRIBUTION_PAX_HELPTEXT :"simetriska" nozīmē, ka apmēram vienāds daudzums pasažieri vēlēsies doties virzienā no stacijas A uz B, cik no B uz A. "asimetriska" nozīmē, ka patvaļīgs pasažieru daudzums var vēlēties nokļūt katrā no virzieniem. "manuāli" nozīmē, ka pasažieriem netiks veikta automātiska izplatīšana. +STR_CONFIG_SETTING_DISTRIBUTION_PAX_HELPTEXT :"Simetrisks" nozīmē, ka aptuveni tikpat daudz pasažieru dosies no stacijas A uz staciju B kā no B uz A. "Asimetrisks" nozīmē, ka abos virzienos var doties patvaļīgs pasažieru skaits. "Manuāli" nozīmē, ka pasažieriem nenotiks automātiska sadale. STR_CONFIG_SETTING_DISTRIBUTION_MAIL :Pasta izplatīšanas režīms: {STRING} -STR_CONFIG_SETTING_DISTRIBUTION_MAIL_HELPTEXT :"simetriska" nozīmē, ka apmēram vienāds daudzums pasta tiks nosūtīts virzienā no stacijas A uz B, cik no B uz A. "asimetriska" nozīmē, ka patvaļīgs pasta daudzums var tikt nosūtīts katrā no virzieniem. "manuāli" nozīmē, ka pastam netiks veikta automātiska izplatīšana. +STR_CONFIG_SETTING_DISTRIBUTION_MAIL_HELPTEXT :"Simetrisks" nozīmē, ka no stacijas A uz staciju B tiks nosūtīts aptuveni tāds pats pasta daudzums kā no B uz A. "Asimetrisks" nozīmē, ka jebkurā virzienā var nosūtīt patvaļīgu pasta daudzumu. "Manuāli" nozīmē, ka pasta automātiska izplatīšana netiks veikta. STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED :Izplatīšanas režīms APSARGĀJAMAI preču klasei: {STRING} -STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED_HELPTEXT :APSARGĀJAMĀ kravas klase satur vērtslietas mērenajā joslā, dimantus subtropu joslā un zeltu subarktiskajā joslā. NewGRF paplašinājumi var to mainīt. "simetriska" nozīmē, ka apmēram vienāds daudzums kravas tiks nosūtīts virzienā no stacijas A uz B, cik no B uz A. "asimetriska" nozīmē, ka patvaļīgs kravas daudzums var tikt nosūtīts katrā no virzieniem. "manuāli" nozīmē, ka pastam netiks veikta automātiska izplatīšana. Šo vērtību vēlams iestatīt kā asimetrisku vai manuālu, kad spēlē subarktiskajā joslā, jo bankas nesūta zeltu atpakaļ uz zelta raktuvēm. Mērenajā un subtropu joslā var izvēlēties simetrisku, jo bankas sūtīs vērtslietas atpakaļ uz izcelsmes banku, kad saņems vērtslietu pievedumu. +STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED_HELPTEXT :APSARGĀJAMĀ kravu klasē ir vērtslietas mērenā klimatā, dimanti subtropu klimatā vai zelts subarktiskajā klimatā. NewGRF to var mainīt. "Simetrisks" nozīmē, ka no stacijas A uz staciju B tiks nosūtīts aptuveni tāds pats šīs kravas daudzums kā no B uz A. "Asimetrisks" nozīmē, ka šīs kravas var nosūtīt jebkurā virzienā patvaļīgi. "Manuāli" nozīmē, ka šai kravai automātiskā sadale nenotiks. Spēlējot subarktisko vai subtropu, ieteicams to iestatīt uz asimetrisku vai manuālu, jo bankas saņem kravas tikai šādos klimatiskajos apstākļos. Mērenam klimatam varat izvēlēties arī simetrisko, jo bankas nosūtīs vērtslietas atpakaļ uz izcelsmes banku. STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT :Izplatīšanas modelis citām kravu klasēm: {STRING} STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT_HELPTEXT :"Asimetrisks" nozīmē, ka jebkurā virzienā var nosūtīt patvaļīgu daudzumu kravas. "Manuāli" nozīmē, ka šīm kravām automātiska sadale nenotiks ###length 3 @@ -1924,13 +1996,15 @@ STR_CONFIG_SETTING_DEMAND_SIZE_HELPTEXT :Uzstādod šo m STR_CONFIG_SETTING_SHORT_PATH_SATURATION :Īso ceļu piesātinājums pirms sākt izmantot augstas ietilpības ceļus: {STRING} STR_CONFIG_SETTING_SHORT_PATH_SATURATION_HELPTEXT :Nereti starp divām stacijām ir vairāki ceļi. Kravu sadale vispirms piesātinās īsāko maršrutu, pēc tam izmantos nākamo īsāko maršrutu līdz tas būs piesātināts, un tā tālāk. Piesātinājumu nosaka novērtējot ietilpību un plānoto izmantojumu. Kad visi ceļi ir piesātināti un vēl ir palicis pieprasījumus, tas pārslogos visus ceļus, dodot priekšroku ceļiem ar lielāko ietilpību. Algoritms visbiežāk nepareizi novērtēs ietilpību. Šis iestatījums jums atļaus norādīt, līdz cik procentiem īsākais ceļš ir jāpiesātina pirmajā piegājienā pirms izvēlēties garāku ceļu. Iestatiet to uz mazāk kā 100%, lai izvairītos no pārpildītām stacijām, ja kapacitāte ir pārvērtēta. -STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY :Ātruma mērvienības: {STRING} +STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY :Ātruma vienības (sauszemes): {STRING} +STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_NAUTICAL :Ātruma vienības (jūras): {STRING} STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_HELPTEXT :Vai lietotāja saskarnē rāda ātrumu, rādīt norādītajās mērvienībās ###length 5 STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_IMPERIAL :impērijas, britu (jūdzes stundā) STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_METRIC :metriskās (km/h) STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_SI :SI, starptautiskās (m/s) STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_GAMEUNITS :Spēles vienības (lauciņi/dienas) +STR_CONFIG_SETTING_LOCALISATION_UNITS_VELOCITY_KNOTS :Mezgli STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER :Transportlīdzekļu jaudas mērvienības: {STRING} STR_CONFIG_SETTING_LOCALISATION_UNITS_POWER_HELPTEXT :Vai lietotāja saskarnē rāda transporta līdzekļa jaudu, rādīt norādītajās mērvienībās @@ -2031,6 +2105,7 @@ STR_CONFIG_ERROR_SPRITECACHE_TOO_BIG :{WHITE}Neizdev # Video initalization errors STR_VIDEO_DRIVER_ERROR :{WHITE}Kļūda ar video iestatījumiem STR_VIDEO_DRIVER_ERROR_NO_HARDWARE_ACCELERATION :{WHITE}... nav atrasts saderīgs GPU. Aparatūras paātrinājums ir atspējots +STR_VIDEO_DRIVER_ERROR_HARDWARE_ACCELERATION_CRASH :{WHITE}... GPU dzinulis apturēja spēli. Aparatūras paātrinājums ir izslēgts # Intro window STR_INTRO_CAPTION :{WHITE}OpenTTD {REV} @@ -2044,6 +2119,7 @@ STR_INTRO_MULTIPLAYER :{BLACK}Vairāks STR_INTRO_GAME_OPTIONS :{BLACK}Spēles opcijas STR_INTRO_HIGHSCORE :{BLACK}Sasniegumu tabula +STR_INTRO_HELP :{BLACK}Palīdzība un rokasgrāmatas STR_INTRO_CONFIG_SETTINGS_TREE :{BLACK}Iestatījumi STR_INTRO_NEWGRF_SETTINGS :{BLACK}NewGRF iestatījumi STR_INTRO_ONLINE_CONTENT :{BLACK}Pārbaudīt tiešsaistes saturu @@ -2065,6 +2141,7 @@ STR_INTRO_TOOLTIP_TOYLAND_LANDSCAPE :{BLACK}Izvēlē STR_INTRO_TOOLTIP_GAME_OPTIONS :{BLACK}Rādīt spēles opcijas STR_INTRO_TOOLTIP_HIGHSCORE :{BLACK}Rādīt sasniegumu tabulu +STR_INTRO_TOOLTIP_HELP :{BLACK}Piekļūstiet dokumentācijai un tiešsaistes resursiem STR_INTRO_TOOLTIP_CONFIG_SETTINGS_TREE :{BLACK}Displeja iestatījumi STR_INTRO_TOOLTIP_NEWGRF_SETTINGS :{BLACK}Rādīt NewGRF iestatījumus STR_INTRO_TOOLTIP_ONLINE_CONTENT :{BLACK}Pārbaudīt vai lejupielādei nav pieejams jauns un atjaunināts saturs @@ -2087,6 +2164,17 @@ STR_ABANDON_GAME_QUERY :{YELLOW}Vai tie STR_ABANDON_SCENARIO_QUERY :{YELLOW}Vai tiešām vēlaties pamest šo scenāriju? # Help window +STR_HELP_WINDOW_CAPTION :{WHITE}Palīdzība un rokasgrāmatas +STR_HELP_WINDOW_WEBSITES :{BLACK}Vietnes +STR_HELP_WINDOW_DOCUMENTS :{BLACK}Dokumenti +STR_HELP_WINDOW_README :{BLACK}Lasi_Mani +STR_HELP_WINDOW_CHANGELOG :{BLACK}Izmaiņu žurnāls +STR_HELP_WINDOW_KNOWN_BUGS :{BLACK}Zināmās kļūdas +STR_HELP_WINDOW_LICENSE :{BLACK}Licence +STR_HELP_WINDOW_MAIN_WEBSITE :{BLACK}OpenTTD +STR_HELP_WINDOW_MANUAL_WIKI :{BLACK}Rokasgrāmata / Wiki +STR_HELP_WINDOW_BUGTRACKER :{BLACK}Ziņot par kļūdu +STR_HELP_WINDOW_COMMUNITY :{BLACK}Kopiena # Cheat window STR_CHEATS :{WHITE}Blēdības @@ -2102,6 +2190,7 @@ STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT :{WHITE}Izmainī STR_CHEAT_CHANGE_DATE :{LTBLUE}Nomainīt datumu: {ORANGE} {DATE_SHORT} STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}Mainīt pašreizējo gadu STR_CHEAT_SETUP_PROD :{LTBLUE}Ieslēgt ražojumu vērtības maiņu: {ORANGE}{STRING} +STR_CHEAT_STATION_RATING :{LTBLUE}Labot stacijas vērtējumus uz 100%: {ORANGE}{STRING} # Livery window STR_LIVERY_CAPTION :{WHITE}{COMPANY} - krāsu shēma @@ -2111,12 +2200,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Rādīt STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Rādīt autotransporta identitātes krāsu shēmas STR_LIVERY_SHIP_TOOLTIP :{BLACK}Rādīt kuģu identitātes krāsu shēmas STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Rādīt lidaparātu identitātes krāsu shēmas +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Rādīt vilcienu grupu krāsas +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Rādīt autotransporta grupu krāsas +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Rādīt kuģu grupu krāsas +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Rādīt lidaparātu grupu krāsas STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Izvēlēties galveno identitātes krāsu atlasītajai shēmai. Ctrl+klikšķis iestatīs šo krāsu katrai shēmai STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Izvēlēties papildu identitātes krāsu atlasītajai shēmai. Ctrl+klikšķis iestatīs šo krāsu katrai shēmai STR_LIVERY_PANEL_TOOLTIP :{BLACK}Izvēlēties kuru identitātes krāsu shēmu mainīt, vai vairākas ar Ctrl+klikšķi. Klikšķināt uz rūtiņas, lai pārslēgtu shēmas izmantošanu +STR_LIVERY_TRAIN_GROUP_EMPTY :Vilcienu grupas nav izveidotas +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Autotransporta līdzekļu grupas nav izveidotas +STR_LIVERY_SHIP_GROUP_EMPTY :Nav izveidotas kuģu grupas +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Nav izveidota neviena gaisa kuģu grupa ###length 23 -STR_LIVERY_DEFAULT :Vispārpieņemtā identitātes krāsa +STR_LIVERY_DEFAULT :Noklusējuma Nokrāsa STR_LIVERY_STEAM :Tvaika lokomotīve STR_LIVERY_DIESEL :Dīzeļlokomotīve STR_LIVERY_ELECTRIC :Elektrolokomotīve @@ -2269,7 +2366,7 @@ STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP :{BLACK}Spēles STR_NETWORK_START_SERVER_SET_PASSWORD :{BLACK}Uzstādīt paroli STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP :{BLACK}Aizsargā jūsu spēli ar paroli, ja nevēlaties lai tā būtu publiski pieejama -STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Redzamība +STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Redzamība: STR_NETWORK_START_SERVER_VISIBILITY_TOOLTIP :{BLACK} Vai citi lietotāji var redzēt jūsu serveri publiskajā sarakstā STR_NETWORK_START_SERVER_CLIENTS_SELECT :{BLACK}{NUM} spēlētāj{P s i u} STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS :{BLACK}Maksimālais spēlētāju skaits: @@ -2335,6 +2432,7 @@ STR_NETWORK_CLIENT_LIST_NEW_COMPANY :(Jauna kompāni STR_NETWORK_CLIENT_LIST_NEW_COMPANY_TOOLTIP :{BLACK}Izveidot jaunu kompāniju un pievienoties tai STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP :{BLACK}Tas esat jūs STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP :{BLACK}Šis ir spēles īpašnieks +STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT_TOOLTIP :{BLACK}Pašlaik savienoto klientu skaits, uzņēmumu skaits un maksimālais servera administratora atļautais uzņēmumu skaits # Matches ConnectionType ###length 5 @@ -2361,6 +2459,12 @@ STR_NETWORK_ASK_RELAY_NO :{BLACK}Nē STR_NETWORK_ASK_RELAY_YES_ONCE :{BLACK}Jā, vienreiz STR_NETWORK_ASK_RELAY_YES_ALWAYS :{BLACK}Jā, vairs nejautāt +STR_NETWORK_ASK_SURVEY_CAPTION :Vai piedalīties automatizētā aptaujā? +STR_NETWORK_ASK_SURVEY_TEXT :Vai vēlaties piedalīties automatizētajā aptaujā?{}OpenTTD pārsūtīs aptauju, izejot no spēles.{}To jebkurā laikā varat mainīt sadaļā "Spēles opcijas". +STR_NETWORK_ASK_SURVEY_PREVIEW :Priekšskatīt aptaujas rezultātus +STR_NETWORK_ASK_SURVEY_LINK :Par aptauju un privātumu +STR_NETWORK_ASK_SURVEY_NO :Nē +STR_NETWORK_ASK_SURVEY_YES :Jā STR_NETWORK_SPECTATORS :Novērotāji @@ -2496,7 +2600,7 @@ STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP :{BLACK}Meklēt STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER_CAPTION :{WHITE}Jūs aizejat no OpenTTD! STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER :{WHITE}Lietošanas noteikumi no ārpuses lejupielādētam saturam var būt dažāi.{}Jums būs jāskatās ārējās saites ārējā satura instalēšanai uz OpenTTD.{}Vai vēlaties turpināt? STR_CONTENT_FILTER_TITLE :{BLACK}Atzīmju/nosaukumu filtrs: -STR_CONTENT_OPEN_URL :{BLACK}Apmeklēt tīmekļa vietni +STR_CONTENT_OPEN_URL :{BLACK}Vietne STR_CONTENT_OPEN_URL_TOOLTIP :{BLACK}Apmeklēt tīmekļa vietni, lai tiktu pie šī satura STR_CONTENT_DOWNLOAD_CAPTION :{BLACK}Lejupielādēt STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP :{BLACK}Sākt atlasītā lejupielādi @@ -2567,6 +2671,7 @@ STR_TRANSPARENT_BUILDINGS_TOOLTIP :{BLACK}Pārslē STR_TRANSPARENT_BRIDGES_TOOLTIP :{BLACK}Pārslēgt tiltu caurspīdību. Ctrl+klikšķis, lai slēgtu STR_TRANSPARENT_STRUCTURES_TOOLTIP :{BLACK}Pārslēgt caurspīdību tādām celtnēm kā bākas un antenas. Ctrl+klikšķis, lai slēgtu STR_TRANSPARENT_CATENARY_TOOLTIP :{BLACK}Pārslēgt piekartroses caurspīdību. Ctrl+klikšķis, lai slēgtu +STR_TRANSPARENT_TEXT_TOOLTIP :{BLACK}Pārslēgt caurspīdīgumu ielādei un izmaksu/ienākumu tekstam. Ctrl+klikšķis, lai bloķētu STR_TRANSPARENT_INVISIBLE_TOOLTIP :{BLACK}Caurspīdības vietā objektus padarīt neredzamus # Linkgraph legend window @@ -2650,8 +2755,11 @@ STR_STATION_BUILD_DRAG_DROP_TOOLTIP :{BLACK}Būvēt STR_STATION_BUILD_STATION_CLASS_TOOLTIP :{BLACK}Izvēlēties kuru stacijas klasi rādīt STR_STATION_BUILD_STATION_TYPE_TOOLTIP :{BLACK}Izvēlēties kuru stacijas veidu būvēt -STR_STATION_CLASS_DFLT :Noklusējuma stacija +STR_STATION_CLASS_DFLT :Noklusējuma +STR_STATION_CLASS_DFLT_STATION :Noklusējuma stacija +STR_STATION_CLASS_DFLT_ROADSTOP :Noklusējuma pietura STR_STATION_CLASS_WAYP :Pieturas punkti +STR_STATION_CLASS_WAYP_WAYPOINT :Noklusējuma pieturas punkts # Signal window STR_BUILD_SIGNAL_CAPTION :{WHITE}Signāla izvēle @@ -2679,6 +2787,7 @@ STR_SELECT_ROAD_BRIDGE_CAPTION :{WHITE}Izvēlē STR_SELECT_BRIDGE_SELECTION_TOOLTIP :{BLACK}Tiltu izvēle - klikšķināt uz vēlamo tiltu, lai to uzbūvētu STR_SELECT_BRIDGE_INFO_NAME :{GOLD}{STRING} STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED :{GOLD}{STRING},{} {VELOCITY} +STR_SELECT_BRIDGE_INFO_NAME_COST :{GOLD}{0:STRING},{} {WHITE}{2:CURRENCY_LONG} STR_SELECT_BRIDGE_INFO_NAME_MAX_SPEED_COST :{GOLD}{STRING},{} {VELOCITY} {WHITE}{CURRENCY_LONG} STR_BRIDGE_NAME_SUSPENSION_STEEL :Vanšu, tērauda STR_BRIDGE_NAME_GIRDER_STEEL :Siju, tērauda @@ -2858,7 +2967,7 @@ STR_FOUND_TOWN_SELECT_LAYOUT_3X3_GRID :{BLACK}3x3 rež STR_FOUND_TOWN_SELECT_LAYOUT_RANDOM :{BLACK}Nejaušs # Fund new industry window -STR_FUND_INDUSTRY_CAPTION :{WHITE}Finansēt jaunu ražotni +STR_FUND_INDUSTRY_CAPTION :{WHITE}Industrijas Finansējums STR_FUND_INDUSTRY_SELECTION_TOOLTIP :{BLACK}Izvēlēties no saraksta atbilstošu ražotni STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES :{BLACK}Izveidot nejaušas nozares STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_TOOLTIP :{BLACK}Pārklāt karti ar nejauši izvietotām ražotnēm @@ -2881,7 +2990,7 @@ STR_INDUSTRY_CARGOES_CUSTOMERS :{WHITE}Patērē STR_INDUSTRY_CARGOES_HOUSES :{WHITE}Mājas STR_INDUSTRY_CARGOES_INDUSTRY_TOOLTIP :{BLACK}Klikšķināt uz ražotnes, lai redzētu tās piegādātājus un patērētājus STR_INDUSTRY_CARGOES_CARGO_TOOLTIP :{BLACK}{STRING}{}Klikšķināt uz kravas, lai redzētu tās piegādātājus un patērētājus -STR_INDUSTRY_DISPLAY_CHAIN :{BLACK}Rādīt ķēdi +STR_INDUSTRY_DISPLAY_CHAIN :{BLACK}Nozares ķēde STR_INDUSTRY_DISPLAY_CHAIN_TOOLTIP :{BLACK}Rādīt kravas ražojošās un patērējošās ražotnes STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP :{BLACK}Piesaistīt minikartei STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP_TOOLTIP :{BLACK}Izvēlēties arī minikartē attēlotās rūpnīcas @@ -3019,7 +3128,7 @@ STR_ABOUT_VERSION :{BLACK}OpenTTD STR_ABOUT_COPYRIGHT_OPENTTD :{BLACK}OpenTTD {COPYRIGHT} 2002-{STRING} OpenTTD darba grupa # Framerate display window -STR_FRAMERATE_CAPTION :{WHITE}Kadru biežums +STR_FRAMERATE_CAPTION :{WHITE}Kadru nomaiņas ātrums STR_FRAMERATE_CAPTION_SMALL :{STRING}{WHITE} ({DECIMAL}x) STR_FRAMERATE_RATE_GAMELOOP :{BLACK}Simulācijas ātrums: {STRING} STR_FRAMERATE_RATE_GAMELOOP_TOOLTIP :{BLACK}Spēles tikšķu skaits, ko simulēt vienā sekundē. @@ -3112,11 +3221,15 @@ STR_MAPGEN_MAPSIZE :{BLACK}Kartes i STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}Izvēlieties kartes izmēru, izteikts lauciņos. Pieejamo lauciņu skaits var būt nedaudz mazāks STR_MAPGEN_BY :{BLACK}* STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Pilsētu daudzums: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :{BLACK}Atlasiet pilsētu blīvumu vai pielāgojiet daudzumu STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}Pilsētu nosaukumi: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}Pilsētu nosaukumu stila izvēle STR_MAPGEN_DATE :{BLACK}Datums: +STR_MAPGEN_DATE_TOOLTIP :{BLACK}Izvēlieties sākuma datumu STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}Ražotņu daudzums: +STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP :{BLACK}Atlasiet nozaru blīvumu vai pielāgojiet daudzumu STR_MAPGEN_HEIGHTMAP_HEIGHT :{BLACK}Augstākā virsotne: +STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}Izvēlieties augstāko virsotni, ko spēle mēģinās izveidot, mērot augstumu virs jūras līmeņa STR_MAPGEN_HEIGHTMAP_HEIGHT_UP :{BLACK}Palielināt augstāko punktu virsotnes pa vienai STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN :{BLACK}Pa vienai samazināt kartes augstākās virsotnes maksimālo augstumu STR_MAPGEN_SNOW_COVERAGE :{BLACK}Sniega pārklājums: @@ -3129,10 +3242,12 @@ STR_MAPGEN_DESERT_COVERAGE_DOWN :{BLACK}Samazin STR_MAPGEN_DESERT_COVERAGE_TEXT :{BLACK}{NUM}% STR_MAPGEN_TERRAIN_TYPE :{BLACK}Apvidus reljefs: STR_MAPGEN_SEA_LEVEL :{BLACK}Jūras līmenis: +STR_MAPGEN_SEA_LEVEL_TOOLTIP :{BLACK}Izvēlieties jūras līmeni STR_MAPGEN_QUANTITY_OF_RIVERS :{BLACK}Upes: STR_MAPGEN_SMOOTHNESS :{BLACK}Gludums: STR_MAPGEN_VARIETY :{BLACK}Dažādības sadalījums: STR_MAPGEN_GENERATE :{WHITE}Radīt +STR_MAPGEN_GENERATE_TOOLTIP :{BLACK}Izveidojiet pasauli un spēlējiet OpenTTD! STR_MAPGEN_NEWGRF_SETTINGS :{BLACK}NewGRF Iestatījumi STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP :{BLACK}Rādīt NewGRF iestatījumus STR_MAPGEN_AI_SETTINGS :{BLACK}AI iestatījumi @@ -3165,6 +3280,7 @@ STR_MAPGEN_TOWN_NAME_CATALAN :Katalāņu # Strings for map borders at game generation STR_MAPGEN_BORDER_TYPE :{BLACK}Kartes malas: +STR_MAPGEN_BORDER_TYPE_TOOLTIP :{BLACK}Izvēlieties spēļu pasaules robežas STR_MAPGEN_NORTHWEST :{BLACK}Ziemeļrietumi STR_MAPGEN_NORTHEAST :{BLACK}Ziemeļaustrumi STR_MAPGEN_SOUTHEAST :{BLACK}Dienvidaustrumi @@ -3177,7 +3293,9 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}Manuāli STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}Augstumu kartes pagriešana: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Augstumu kartes nosaukums: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :{BLACK}Augstuma kartes attēla faila nosaukums STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Lielums: +STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP :{BLACK}Avota augstuma kartes attēla izmērs. Lai iegūtu labākos rezultātus, katrai malai ir jāatbilst OpenTTD pieejamajam kartes malas garumam, piemēram, 256, 512, 1024 utt. STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}Vēlamā augtākā virsotne @@ -3192,6 +3310,7 @@ STR_SE_MAPGEN_FLAT_WORLD :{WHITE}Līdzena STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP :{BLACK}Radīt līdzenu zemi STR_SE_MAPGEN_RANDOM_LAND :{WHITE}Nejauša zeme STR_SE_MAPGEN_FLAT_WORLD_HEIGHT :{BLACK}Līdzenas zemes augstums: +STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP :{BLACK}Izvēlieties zemes augstumu virs jūras līmeņa STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN :{BLACK}Par vienu līmeni samazināt līdzenas zemes augstumu STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP :{BLACK}Par vienu līmeni palielināt līdzenas zemes augstumu @@ -3278,6 +3397,7 @@ STR_SAVE_PRESET_SAVE :{BLACK}Saglabā STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}pašreizējos iestatījumus saglābāt kā sākontnējos iestatījumus # NewGRF parameters window +STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Mainiet pamata grafikas parametrus STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Mainīt NewGRF parametrus STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Aizvērt STR_NEWGRF_PARAMETERS_RESET :{BLACK}Atjaunot @@ -3294,6 +3414,7 @@ STR_NEWGRF_INSPECT_PARENT_TOOLTIP :{BLACK}Pārbaud STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT :{STRING} adresē {HEX} STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT :Objekts STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE :Sliežu veids +STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE :Ceļa tips STR_NEWGRF_INSPECT_QUERY_CAPTION :{WHITE}NewGRF mainīgā 60+x parametrs (heksadecimāls) @@ -3328,6 +3449,7 @@ STR_NEWGRF_ERROR_MSG_INFO :{SILVER}{STRING STR_NEWGRF_ERROR_MSG_WARNING :{RED}Brīdinājums: {SILVER}{STRING} STR_NEWGRF_ERROR_MSG_ERROR :{RED}Kļūda: {SILVER}{STRING} STR_NEWGRF_ERROR_MSG_FATAL :{RED}Fatāls: {SILVER}{STRING} +STR_NEWGRF_ERROR_FATAL_POPUP :{WHITE}NewGRF "{STRING}" apstrādājas dēl neatgrieziniskās kļūdas:{}{STRING} STR_NEWGRF_ERROR_VERSION_NUMBER :{1:STRING} nedarbosies kopā ar TTDPatch versiju (par ko ziņoja OpenTTD). STR_NEWGRF_ERROR_DOS_OR_WINDOWS :{1:STRING} ir paredzēts TTD versijai {2:STRING} STR_NEWGRF_ERROR_UNSET_SWITCH :{1:STRING} ir paredzēts lietošanai ar {2:STRING} @@ -3478,8 +3600,8 @@ STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_LARGE_ADVERTISING :{PUSH_COLOUR}{Y STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_ROAD_RECONSTRUCTION :{PUSH_COLOUR}{YELLOW}Finansējiet pilsētas ceļu tīkla rekonstrukciju.{}Līdz 6 mēnešiem rada ievērojamus ceļu satiksmes traucējumus.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_STATUE_OF_COMPANY :{PUSH_COLOUR}{YELLOW}Uzceliet statuju par godu savam uzņēmumam.{}Nodrošina pastāvīgu staciju vērtējuma palielinājumu šajā pilsētā.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_NEW_BUILDINGS :{PUSH_COLOUR}{YELLOW}Finansējiet jaunu ēku celtniecību pilsētā.{}Nodrošina īslaicīgu stimulu pilsētas izaugsmei šajā pilsētā.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} -STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_EXCLUSIVE_TRANSPORT :{PUSH_COLOUR}{YELLOW}Iegādājieties 1 gada ekskluzīvas transporta tiesības pilsētā.{}Pašvaldība neļaus pasažieriem un kravai izmantot jūsu konkurentu stacijas.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} -STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE :{PUSH_COLOUR}{YELLOW}Piekukuļojiet vietējo pašvaldību, lai paaugstinātu savu vērtējumu, riskējot saņemt bargu sodu.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} +STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_EXCLUSIVE_TRANSPORT :{PUSH_COLOUR}{YELLOW}Iegādājieties 1 gada ekskluzīvas transporta tiesības pilsētā.{}Pilsētas pašvaldība neļaus pasažieriem un kravai izmantot jūsu konkurentu stacijas. Veiksmīgs kukulis no konkurenta atcels šo līgumu.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} +STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_BRIBE :{PUSH_COLOUR}{YELLOW}Piekukuļot vietējo pašvaldību, lai paaugstinātu savu vērtējumu un atceltu konkurenta ekskluzīvās transporta tiesības, riskējot ar bargu sodu, ja tiksiet pieķerts.{}{POP_COLOUR}Izmaksas: {CURRENCY_LONG} # Goal window STR_GOALS_CAPTION :{WHITE}{COMPANY} mērķi @@ -3703,6 +3825,8 @@ STR_COMPANY_VIEW_INFRASTRUCTURE_BUTTON :{BLACK}Sīkāk STR_COMPANY_VIEW_INFRASTRUCTURE_TOOLTIP :{BLACK}Skatīt detalizētāku infrastruktūras uzskaiti STR_COMPANY_VIEW_GIVE_MONEY_BUTTON :{BLACK}Iedot naudu STR_COMPANY_VIEW_GIVE_MONEY_TOOLTIP :{BLACK}Iedot naudu šai kompānijai +STR_COMPANY_VIEW_HOSTILE_TAKEOVER_BUTTON :{BLACK}Naidīga pārņemšana +STR_COMPANY_VIEW_HOSTILE_TAKEOVER_TOOLTIP :{BLACK}Veiciet naidīgu šī uzņēmuma pārņemšanu STR_COMPANY_VIEW_NEW_FACE_BUTTON :{BLACK}Jauna seja STR_COMPANY_VIEW_NEW_FACE_TOOLTIP :{BLACK}Izvēlēties jaunu seju vadītājam @@ -3718,6 +3842,7 @@ STR_COMPANY_VIEW_PRESIDENT_S_NAME_QUERY_CAPTION :Vadītāja vār STR_COMPANY_VIEW_GIVE_MONEY_QUERY_CAPTION :Ievadiet naudas daudzumu, kuru vēlaties atdot STR_BUY_COMPANY_MESSAGE :{WHITE}Mēs meklējam transporta uzņēmumu, kurš vēlētos pārņemt mūsējo.{}{}Vai Jūs vēlaties pirkt {COMPANY} par {CURRENCY_LONG}? +STR_BUY_COMPANY_HOSTILE_TAKEOVER :{WHITE}Naidīgā uzņēmuma {COMPANY} pārņemšanas gadījumā jūs iegādāsities visus aktīvus, atmaksāsit visus aizdevumus un maksāsiet divu gadu peļņu.{}{}Tiek lēsts, ka kopējā summa ir {CURRENCY_LONG}.{}{}Vai jūs vēlaties turpināt šo naidīgo pārņemšanu? # Company infrastructure window STR_COMPANY_INFRASTRUCTURE_VIEW_CAPTION :{WHITE}{COMPANY} infrastruktūra @@ -3790,11 +3915,14 @@ STR_VEHICLE_LIST_MANAGE_LIST :{BLACK}Pārvald STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP :{BLACK}Sūtīt norādījumus visiem transportlīdzekļiem, kas ir šajā sarakstā STR_VEHICLE_LIST_REPLACE_VEHICLES :Nomainīt transportlīdzekļus STR_VEHICLE_LIST_SEND_FOR_SERVICING :Sūtīt uz apkopi +STR_VEHICLE_LIST_CREATE_GROUP :Izveidot grupu STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR :{TINY_FONT}{BLACK}Peļņa šogad: {CURRENCY_LONG} (pērn: {CURRENCY_LONG}) +STR_VEHICLE_LIST_CARGO :[{CARGO_LIST}] +STR_VEHICLE_LIST_NAME_AND_CARGO :{STRING} {STRING} -STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT :Sūtīt uz depo -STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT :Sūtīt uz depo -STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT :Sūtīt uz depo +STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT :Nosūtīt uz depo +STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT :Nosūtīt uz depo +STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT :Nosūtīt uz depo STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR :Sūtīt uz angāru STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP :{BLACK}Klikšķināt, lai apstādinātu visas mašīnas, kas ir sarakstā @@ -4481,8 +4609,13 @@ STR_TIMETABLE_STATUS_ON_TIME :{BLACK}Šis tra STR_TIMETABLE_STATUS_LATE :{BLACK}Šis transportlīdzeklis pašlaik {STRING} kavē STR_TIMETABLE_STATUS_EARLY :{BLACK}Šis transportlīdzeklis pašlaik {STRING} par agru STR_TIMETABLE_STATUS_NOT_STARTED :{BLACK}Šis saraksts vēl nav sācies +STR_TIMETABLE_STATUS_START_AT_DATE :{BLACK}Šis grafiks sāksies plkst. {STRING} +STR_TIMETABLE_STATUS_START_IN_SECONDS :{BLACK}Šis grafiks sāksies pēc {COMMA} sekundēm +STR_TIMETABLE_START :{BLACK}Sākt Grafiku +STR_TIMETABLE_START_TOOLTIP :{BLACK}Atlasiet, kad sākas šis saraksts. Ctrl+klikšķis vienmērīgi sadala visu transportlīdzekļu sākumu, kas koplieto šo pasūtījumu, pamatojoties uz to relatīvo pasūtījumu, ja pasūtījumam ir pilnībā noteikts saraksts +STR_TIMETABLE_START_SECONDS_QUERY :Sekundes līdz grafika sākumam STR_TIMETABLE_CHANGE_TIME :{BLACK}Mainīt laiku STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Mainiet laiku, kas nepieciešams iezīmētajam pasūtījumam. Ctrl+Click iestata laiku visiem pasūtījumiem @@ -4506,6 +4639,10 @@ STR_TIMETABLE_EXPECTED :{BLACK}Paredzē STR_TIMETABLE_SCHEDULED :{BLACK}Ieplānots STR_TIMETABLE_EXPECTED_TOOLTIP :{BLACK}Pārslēgties starp sagaidāmo un ieplānoto +STR_TIMETABLE_ARRIVAL_DATE :A: {COLOUR}{DATE_TINY} +STR_TIMETABLE_DEPARTURE_DATE :D: {COLOUR}{DATE_TINY} +STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE :iekš: {COLOUR}{COMMA} sek +STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE :D: {COLOUR}{COMMA} sek # Date window (for timetable) @@ -4535,21 +4672,23 @@ STR_AI_DEBUG_CONTINUE :{BLACK}Turpinā STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Atsākt un turpināt šo MI STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Attēlot šī MI atkļūdošanas izvadu STR_AI_GAME_SCRIPT :{BLACK}Spēles skripts -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Pārbaudīt spēles skriptu žurnālu +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Pārbaudiet spēles skripta žurnālu. Ctrl-klikšķis, lai atvērtu jaunā logā STR_ERROR_AI_NO_AI_FOUND :Nav atrasts ielādei piemērots MI.{}Šis ir MI makets un spēlē tas neko nedarīs.{}Jūs varat lejupielādēt dažus MI no 'Tiešsaistes satura' sistēmas STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Viens no strādājošiem skriptiem nobruka. Lūdzu, paziņojiet par šo gadījumu skripta autoram, pievienojot ekrānuzņēmumu ar MI/spēles skriptu atkļūdošanas logu STR_ERROR_AI_DEBUG_SERVER_ONLY :{YELLOW}MI/spēles skriptu atkļūdošanas logs ir pieejams tikai serverim # AI configuration window -STR_AI_CONFIG_CAPTION_AI :{WHITE}AI Konfigurācija -STR_AI_CONFIG_CAPTION_GAMESCRIPT :{WHITE}Spēles skripta konfigurācija +STR_AI_CONFIG_CAPTION_AI :{WHITE}AI iestatījumi +STR_AI_CONFIG_CAPTION_GAMESCRIPT :{WHITE}Spēles Skripta Iestatījumi STR_AI_CONFIG_GAMELIST_TOOLTIP :{BLACK}Spēles skripts, kas tiks ielādēts nākamajā spēlē STR_AI_CONFIG_AILIST_TOOLTIP :{BLACK}MI, kas tiks ielādēts nākamajā spēlē STR_AI_CONFIG_HUMAN_PLAYER :Spēlētājs (cilvēks) STR_AI_CONFIG_RANDOM_AI :Nejaušs MI STR_AI_CONFIG_NONE :(nav) +STR_AI_CONFIG_NAME_VERSION :{STRING} {YELLOW}v{NUM} STR_AI_CONFIG_MAX_COMPETITORS :{LTBLUE}Maksimālais sāncenšu daudzums: {ORANGE}{COMMA} +STR_AI_CONFIG_COMPETITORS_INTERVAL :{LTBLUE}Intervāls starp konkurentu startiem: {ORANGE}{COMMA} minut{P e es ""} STR_AI_CONFIG_MOVE_UP :{BLACK}Pacelt uz augšu STR_AI_CONFIG_MOVE_UP_TOOLTIP :{BLACK}Pacelt izvēlētos MI sarakstā uz augšu @@ -4562,7 +4701,7 @@ STR_AI_CONFIG_AI :{SILVER}MI STR_AI_CONFIG_CHANGE_AI :{BLACK}Izvēlēties MI STR_AI_CONFIG_CHANGE_GAMESCRIPT :{BLACK}Atlasiet spēles skriptu -STR_AI_CONFIG_CHANGE_TOOLTIP :{BLACK}Ielādēt citu skriptu +STR_AI_CONFIG_CHANGE_TOOLTIP :{BLACK}Ielādēt citu skriptu. Ctrl+klikšķis, lai parādītu visas pieejamās versijas STR_AI_CONFIG_CONFIGURE :{BLACK}Konfigurēt STR_AI_CONFIG_CONFIGURE_TOOLTIP :{BLACK}Konfigurēt skripta parametrus @@ -4592,21 +4731,32 @@ STR_SCREENSHOT_MINIMAP_SCREENSHOT :{BLACK}Minikart # Script Parameters STR_AI_SETTINGS_CAPTION :{WHITE}{STRING} Iestatījumi STR_AI_SETTINGS_CAPTION_AI :{WHITE}MI Parametri +STR_AI_SETTINGS_CAPTION_GAMESCRIPT :Spēles skripts STR_AI_SETTINGS_CLOSE :{BLACK}Aizvērt STR_AI_SETTINGS_RESET :{BLACK}Atiestatīt STR_AI_SETTINGS_SETTING :{STRING}: {ORANGE}{STRING} # Textfile window +STR_TEXTFILE_JUMPLIST :{WHITE}Satura rādītājs +STR_TEXTFILE_JUMPLIST_TOOLTIP :{BLACK}Izmantojot šo sarakstu, ātri pārejiet uz parādītā faila sadaļu +STR_TEXTFILE_JUMPLIST_ITEM :{WHITE}{STRING} +STR_TEXTFILE_NAVBACK_TOOLTIP :{BLACK}Atgriezties navigācijas vēsturē +STR_TEXTFILE_NAVFORWARD_TOOLTIP :{BLACK}Atgriezties uz priekšu navigācijas vēsturē STR_TEXTFILE_WRAP_TEXT :{WHITE}Aplauzt tekstu STR_TEXTFILE_WRAP_TEXT_TOOLTIP :{BLACK}Aplauzt tekstu logā, lai tas viss iekļautos un nevajadzētu ritināt -STR_TEXTFILE_VIEW_README :{BLACK}Skatīt failu Lasi_mani +STR_TEXTFILE_VIEW_README :{BLACK}Lasi_Mani +STR_TEXTFILE_VIEW_README_TOOLTIP :Skatīt šī satura readme STR_TEXTFILE_VIEW_CHANGELOG :{BLACK}Izmaiņu žurnāls +STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP :Skatīt šī satura izmaiņu žurnālu STR_TEXTFILE_VIEW_LICENCE :{BLACK}Licence +STR_TEXTFILE_VIEW_LICENCE_TOOLTIP :Skatīt šī satura licenci ###length 5 STR_TEXTFILE_README_CAPTION :{WHITE}{STRING} kopas {STRING} fails Lasi_mani STR_TEXTFILE_CHANGELOG_CAPTION :{WHITE}{STRING} kopas {STRING} izmaiņu žurnāls STR_TEXTFILE_LICENCE_CAPTION :{WHITE}{STRING} kopas {STRING} licence +STR_TEXTFILE_SURVEY_RESULT_CAPTION :{WHITE}Priekšskatīt aptaujas rezultātus +STR_TEXTFILE_GAME_MANUAL_CAPTION :{WHITE}OpenTTD dokuments'{STRING}' # Vehicle loading indicators @@ -4788,7 +4938,7 @@ STR_ERROR_TOO_MANY_TRUCK_STOPS :{WHITE}Pārāk STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK :{WHITE}Pārāk tuvu citai piestātnei STR_ERROR_TOO_CLOSE_TO_ANOTHER_AIRPORT :{WHITE}Pārāk tuvu citai lidostai STR_ERROR_CAN_T_RENAME_STATION :{WHITE}Nevar pārdēvēt staciju... -STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD :{WHITE}... šis ceļš pieder pilsētai +STR_ERROR_DRIVE_THROUGH_ON_TOWN_ROAD :{WHITE}... ceļš pieder pilsētai STR_ERROR_DRIVE_THROUGH_DIRECTION :{WHITE}... ceļš novietots nepareizā virzienā STR_ERROR_DRIVE_THROUGH_CORNER :{WHITE}... caurbraucamās stacijās nevar būt stūru STR_ERROR_DRIVE_THROUGH_JUNCTION :{WHITE}... caurbraucamās stacijās nevar būt sazarojumu @@ -5045,11 +5195,25 @@ STR_ERROR_TOO_FAR_FROM_PREVIOUS_DESTINATION :{WHITE}... pār STR_ERROR_AIRCRAFT_NOT_ENOUGH_RANGE :{WHITE}... lidaparātam ir nepietiekams apgabals # Extra messages which go on the third line of errors, explaining why orders failed +STR_ERROR_NO_RAIL_STATION :{WHITE}Dzelzceļa stacijas nav +STR_ERROR_NO_BUS_STATION :{WHITE}Nav autoostas +STR_ERROR_NO_TRUCK_STATION :{WHITE}Nav kravas automašīnu stacijas +STR_ERROR_NO_DOCK :{WHITE}Nav piestātnes +STR_ERROR_NO_AIRPORT :{WHITE}Nav lidostas/heliportu +STR_ERROR_NO_STOP_COMPATIBLE_ROAD_TYPE :{WHITE}Nav pieturu ar saderīgu ceļa veidu +STR_ERROR_NO_STOP_COMPATIBLE_TRAM_TYPE :{WHITE}Saderīgam tramvaja veidam pieturu nav +STR_ERROR_NO_STOP_ARTICULATED_VEHICLE :{WHITE}Nav pieturu, kas būtu piemērotas posmainiem transportlīdzekļiem.{}Posmainiem transportlīdzekļiem ir nepieciešama caurbraucama pietura. +STR_ERROR_AIRPORT_NO_PLANES :{WHITE}Šī lidmašīna nevar nolaisties šajā helikopteru lidlaukā +STR_ERROR_AIRPORT_NO_HELICOPTERS :{WHITE}Šis helikopters nevar nolaisties šajā lidostā +STR_ERROR_NO_RAIL_WAYPOINT :{WHITE}Nav dzelzceļa pieturas punkta +STR_ERROR_NO_BUOY :{WHITE}Bojas nav # Timetable related errors STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Nevar panākt transportalīdzekļa iekļaušanos sarakstā STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Transportlīdzekļus var gaidīt tikai stacijās STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Šis transportlīdzeklis šajā stacijā nepieturēs +STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... saraksts ir nepilnīgs +STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... grafiks vēl nav sācies # Sign related errors STR_ERROR_TOO_MANY_SIGNS :{WHITE}... pārāk daudz zīmju @@ -5529,17 +5693,21 @@ STR_VEHICLE_NAME :{VEHICLE} STR_WAYPOINT_NAME :{WAYPOINT} STR_JUST_CARGO :{CARGO_LONG} +STR_JUST_RIGHT_ARROW :{RIGHT_ARROW} STR_JUST_CHECKMARK :{CHECKMARK} STR_JUST_COMMA :{COMMA} STR_JUST_CURRENCY_SHORT :{CURRENCY_SHORT} STR_JUST_CURRENCY_LONG :{CURRENCY_LONG} STR_JUST_CARGO_LIST :{CARGO_LIST} +STR_JUST_DECIMAL :{DECIMAL} STR_JUST_INT :{NUM} STR_JUST_DATE_TINY :{DATE_TINY} STR_JUST_DATE_SHORT :{DATE_SHORT} STR_JUST_DATE_LONG :{DATE_LONG} STR_JUST_DATE_ISO :{DATE_ISO} STR_JUST_STRING :{STRING} +STR_JUST_STRING1 :{STRING} +STR_JUST_STRING2 :{STRING} STR_JUST_STRING_STRING :{STRING}{STRING} STR_JUST_RAW_STRING :{STRING} STR_JUST_BIG_RAW_STRING :{BIG_FONT}{STRING} diff --git a/src/lang/russian.txt b/src/lang/russian.txt index 05305c66c0..1b9cf46733 100644 --- a/src/lang/russian.txt +++ b/src/lang/russian.txt @@ -2347,12 +2347,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Наст STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Настройка цветовой схемы автотранспорта STR_LIVERY_SHIP_TOOLTIP :{BLACK}Настройка цветовой схемы судов STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Настройка цветовой схемы авиатранспорта +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}{BLACK}Показать цвета поездных групп +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Показать цвета автомобильных групп +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Показать цвета корабельных групп +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Показать цвета самолетных групп STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Настройка основного цвета выбранного вида транспорта. Ctrl+щелчок установит выбранный цвет для всех видов транспорта. STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Настройка дополнительного цвета выбранного вида транспорта. Ctrl+щелчок установит выбранный цвет для всех видов транспорта. STR_LIVERY_PANEL_TOOLTIP :{BLACK}Выберите цветовую схему для изменения, либо несколько схем с Ctrl. Щёлкните по флажку для использования выбранной схемы. +STR_LIVERY_TRAIN_GROUP_EMPTY :Группы поездов не настроены +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Группы автомобильных транспортных средств не настроены +STR_LIVERY_SHIP_GROUP_EMPTY :Группы кораблей не настроены +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Группы самолетов не созданы ###length 23 -STR_LIVERY_DEFAULT :Стандарт. окраска +STR_LIVERY_DEFAULT :Окраска по умолчанию STR_LIVERY_STEAM :Паровоз STR_LIVERY_DIESEL :Тепловоз STR_LIVERY_ELECTRIC :Электровоз @@ -4840,9 +4848,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Реги STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Переключить проверку регистра при сравнении строк STR_AI_DEBUG_CONTINUE :{BLACK}Продолжить STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Продолжить игру -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Просмотр отладочной информации модуля ИИ +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Просмотрите выходные данные отладки этого AI. Ctrl-щелчок, чтобы открыть в новом окне STR_AI_GAME_SCRIPT :{BLACK}Игровой скрипт -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Показать журнал работы игрового скрипта +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Проверьте журнал игровых сценариев. Ctrl-щелчок, чтобы открыть в новом окне STR_ERROR_AI_NO_AI_FOUND :Не найдено подходящих модулей ИИ, поэтому конкуренты ничего делать не будут.{}Вы можете скачать модули ИИ через систему онлайн-контента. STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Один из запущенных ИИ / скриптов завершил свою работу аварийно. Пожалуйста, сообщите об этом автору скрипта, приложив снимок окна отладки. From 8ff0bef862896f16efaac07cecb8a92be92c7379 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 18:55:16 +0000 Subject: [PATCH 17/29] Codechange: Make widget index const to prevent changes. (#11658) This guards against future widget index manipulation. --- src/widget.cpp | 56 ++++++++++------------------------------------- src/widget_type.h | 17 +++++--------- 2 files changed, 17 insertions(+), 56 deletions(-) diff --git a/src/widget.cpp b/src/widget.cpp index 323e7157d2..85465c4743 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1208,15 +1208,15 @@ void NWidgetResizeBase::AssignSizePosition(SizingType sizing, int x, int y, uint * Initialization of a 'real' widget. * @param tp Type of the widget. * @param colour Colour of the widget. + * @param index Index of the widget. * @param fill_x Default horizontal filling. * @param fill_y Default vertical filling. * @param widget_data Data component of the widget. @see Widget::data * @param tool_tip Tool tip of the widget. @see Widget::tooltips */ -NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32_t widget_data, StringID tool_tip) : NWidgetResizeBase(tp, fill_x, fill_y) +NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, WidgetID index, uint fill_x, uint fill_y, uint32_t widget_data, StringID tool_tip) : NWidgetResizeBase(tp, fill_x, fill_y), index(index) { this->colour = colour; - this->index = -1; this->widget_data = widget_data; this->tool_tip = tool_tip; this->scrollbar_index = -1; @@ -1225,16 +1225,6 @@ NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y this->align = SA_CENTER; } -/** - * Set index of the nested widget in the widget array. - * @param index Index to use. - */ -void NWidgetCore::SetIndex(WidgetID index) -{ - assert(index >= 0); - this->index = index; -} - /** * Set data and tool tip of the nested widget. * @param widget_data Data to use. @@ -1374,14 +1364,8 @@ NWidgetCore *NWidgetContainer::GetWidgetFromPos(int x, int y) /** * Widgets stacked on top of each other. */ -NWidgetStacked::NWidgetStacked() : NWidgetContainer(NWID_SELECTION) -{ - this->index = -1; -} - -void NWidgetStacked::SetIndex(WidgetID index) +NWidgetStacked::NWidgetStacked(WidgetID index) : NWidgetContainer(NWID_SELECTION), index(index) { - this->index = index; } void NWidgetStacked::AdjustPaddingForZoom() @@ -1950,16 +1934,7 @@ NWidgetCore *NWidgetSpacer::GetWidgetFromPos(int, int) return nullptr; } -NWidgetMatrix::NWidgetMatrix() : NWidgetPIPContainer(NWID_MATRIX, NC_EQUALSIZE), index(-1), clicked(-1), count(-1) -{ -} - -void NWidgetMatrix::SetIndex(WidgetID index) -{ - this->index = index; -} - -void NWidgetMatrix::SetColour(Colours colour) +NWidgetMatrix::NWidgetMatrix(Colours colour, WidgetID index) : NWidgetPIPContainer(NWID_MATRIX, NC_EQUALSIZE), index(index), clicked(-1), count(-1) { this->colour = colour; } @@ -2191,10 +2166,9 @@ void NWidgetMatrix::GetScrollOffsets(int &start_x, int &start_y, int &base_offs_ * vertical container will be inserted while adding the first * child widget. */ -NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, NWidgetPIPContainer *child) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL) +NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, NWidgetPIPContainer *child) : NWidgetCore(tp, colour, index, 1, 1, 0x0, STR_NULL) { assert(tp == WWT_PANEL || tp == WWT_INSET || tp == WWT_FRAME); - if (index >= 0) this->SetIndex(index); this->child = child; this->SetAlignment(SA_TOP | SA_LEFT); } @@ -2399,9 +2373,8 @@ NWidgetBase *NWidgetBackground::GetWidgetOfType(WidgetType tp) return nwid; } -NWidgetViewport::NWidgetViewport(WidgetID index) : NWidgetCore(NWID_VIEWPORT, INVALID_COLOUR, 1, 1, 0x0, STR_NULL) +NWidgetViewport::NWidgetViewport(WidgetID index) : NWidgetCore(NWID_VIEWPORT, INVALID_COLOUR, index, 1, 1, 0x0, STR_NULL) { - this->SetIndex(index); } void NWidgetViewport::SetupSmallestSize(Window *) @@ -2559,10 +2532,9 @@ void Scrollbar::SetCapacityFromWidget(Window *w, WidgetID widget, int padding) * @param colour Colour of the scrollbar. * @param index Index of the widget. */ -NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, WidgetID index) : NWidgetCore(tp, colour, 1, 1, 0x0, STR_NULL), Scrollbar(tp != NWID_HSCROLLBAR) +NWidgetScrollbar::NWidgetScrollbar(WidgetType tp, Colours colour, WidgetID index) : NWidgetCore(tp, colour, index, 1, 1, 0x0, STR_NULL), Scrollbar(tp != NWID_HSCROLLBAR) { assert(tp == NWID_HSCROLLBAR || tp == NWID_VSCROLLBAR); - this->SetIndex(index); switch (this->type) { case NWID_HSCROLLBAR: @@ -2685,10 +2657,9 @@ Dimension NWidgetLeaf::dropdown_dimension = {0, 0}; * @param data Data of the widget. * @param tip Tooltip of the widget. */ -NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, WidgetID 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, index, 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); this->min_x = 0; this->min_y = 0; this->SetResize(0, 0); @@ -3153,11 +3124,8 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg case NWID_MATRIX: { if (*dest != nullptr) return nwid_begin; - NWidgetMatrix *nwm = new NWidgetMatrix(); - *dest = nwm; + *dest = new NWidgetMatrix(nwid_begin->u.widget.colour, nwid_begin->u.widget.index); *fill_dest = true; - nwm->SetIndex(nwid_begin->u.widget.index); - nwm->SetColour(nwid_begin->u.widget.colour); break; } @@ -3271,10 +3239,8 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg case NWID_SELECTION: { if (*dest != nullptr) return nwid_begin; - NWidgetStacked *nws = new NWidgetStacked(); - *dest = nws; + *dest = new NWidgetStacked(nwid_begin->u.widget.index); *fill_dest = true; - nws->SetIndex(nwid_begin->u.widget.index); break; } @@ -3394,7 +3360,7 @@ NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWi NWidgetHorizontal *hor_cont = dynamic_cast(nwid); NWidgetContainer *body; if (hor_cont != nullptr && hor_cont->GetWidgetOfType(WWT_CAPTION) != nullptr && hor_cont->GetWidgetOfType(WWT_SHADEBOX) != nullptr) { - *shade_select = new NWidgetStacked; + *shade_select = new NWidgetStacked(-1); root->Add(*shade_select); body = new NWidgetVertical; (*shade_select)->Add(body); diff --git a/src/widget_type.h b/src/widget_type.h index 5a7c686a27..8c2cac59f2 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -327,9 +327,8 @@ DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay) */ class NWidgetCore : public NWidgetResizeBase { public: - NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32_t widget_data, StringID tool_tip); + NWidgetCore(WidgetType tp, Colours colour, WidgetID index, uint fill_x, uint fill_y, uint32_t widget_data, StringID tool_tip); - 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,7 +347,7 @@ public: NWidgetDisplay disp_flags; ///< Flags that affect display and interaction with the widget. Colours colour; ///< Colour of this widget. - WidgetID index; ///< Index of the nested widget (\c -1 means 'not used'). + const 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 WidgetID scrollbar_index; ///< Index of an attached scrollbar. @@ -458,9 +457,7 @@ enum StackedZeroSizePlanes { */ class NWidgetStacked : public NWidgetContainer { public: - NWidgetStacked(); - - void SetIndex(WidgetID index); + NWidgetStacked(WidgetID index); void AdjustPaddingForZoom() override; void SetupSmallestSize(Window *w) override; @@ -473,7 +470,7 @@ public: bool SetDisplayedPlane(int plane); int shown_plane; ///< Plane being displayed (for #NWID_SELECTION only). - WidgetID index; ///< If non-negative, index in the #Window::widget_lookup. + const WidgetID index; ///< If non-negative, index in the #Window::widget_lookup. }; /** Nested widget container flags, */ @@ -557,10 +554,8 @@ public: */ class NWidgetMatrix : public NWidgetPIPContainer { public: - NWidgetMatrix(); + NWidgetMatrix(Colours colour, WidgetID index); - void SetIndex(WidgetID index); - void SetColour(Colours colour); void SetClicked(int clicked); void SetCount(int count); void SetScrollbar(Scrollbar *sb); @@ -573,7 +568,7 @@ public: NWidgetCore *GetWidgetFromPos(int x, int y) override; void Draw(const Window *w) override; protected: - WidgetID index; ///< If non-negative, index in the #Window::widget_lookup. + const WidgetID index; ///< If non-negative, index in the #Window::widget_lookup. Colours colour; ///< Colour of this widget. int clicked; ///< The currently clicked element. int count; ///< Amount of valid elements. From c2c65d66bad5802e0d97b4c76443a755ea9f6ed1 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 20:49:08 +0000 Subject: [PATCH 18/29] Codechange: Add GetParentWidget() to widgets. This allows to get parent widgets in the nested tree from bottom-up. --- src/widget.cpp | 6 ++++++ src/widget_type.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/widget.cpp b/src/widget.cpp index 85465c4743..151a6d40cb 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1319,6 +1319,8 @@ void NWidgetContainer::AdjustPaddingForZoom() */ void NWidgetContainer::Add(NWidgetBase *wid) { + assert(wid != nullptr); + wid->parent = this; assert(wid->next == nullptr && wid->prev == nullptr); if (this->head == nullptr) { @@ -2170,6 +2172,7 @@ NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, WidgetID ind { assert(tp == WWT_PANEL || tp == WWT_INSET || tp == WWT_FRAME); this->child = child; + if (this->child != nullptr) this->child->parent = this; this->SetAlignment(SA_TOP | SA_LEFT); } @@ -2190,6 +2193,7 @@ void NWidgetBackground::Add(NWidgetBase *nwid) if (this->child == nullptr) { this->child = new NWidgetVertical(); } + nwid->parent = this->child; this->child->Add(nwid); } @@ -2208,6 +2212,7 @@ void NWidgetBackground::SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_p if (this->child == nullptr) { this->child = new NWidgetVertical(); } + this->child->parent = this; this->child->SetPIP(pip_pre, pip_inter, pip_post); } @@ -2226,6 +2231,7 @@ void NWidgetBackground::SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_int if (this->child == nullptr) { this->child = new NWidgetVertical(); } + this->child->parent = this; this->child->SetPIPRatio(pip_ratio_pre, pip_ratio_inter, pip_ratio_post); } diff --git a/src/widget_type.h b/src/widget_type.h index 8c2cac59f2..9c2620cad6 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -144,6 +144,34 @@ public: virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0; virtual NWidgetBase *GetWidgetOfType(WidgetType tp); + /** + * Get parent widget of type NWID. + * @tparam NWID Type of the nested widget. + * @returns Parent widget, or nullptr if no widget of the specified type is found. + */ + template + NWID *GetParentWidget() + { + for (NWidgetBase *nwid_parent = this->parent; nwid_parent != nullptr; nwid_parent = nwid_parent->parent) { + if (NWID *nwid = dynamic_cast(nwid_parent); nwid != nullptr) return nwid; + } + return nullptr; + } + + /** + * Get parent widget of type NWID. + * @tparam NWID Type of the nested widget. + * @returns Parent widget, or nullptr if no widget of the specified type is found. + */ + template + const NWID *GetParentWidget() const + { + for (const NWidgetBase *nwid_parent = this->parent; nwid_parent != nullptr; nwid_parent = nwid_parent->parent) { + if (const NWID *nwid = dynamic_cast(nwid_parent); nwid != nullptr) return nwid; + } + return nullptr; + } + virtual bool IsHighlighted() const { return false; } virtual TextColour GetHighlightColour() const { return TC_INVALID; } virtual void SetHighlighted([[maybe_unused]] TextColour highlight_colour) {} @@ -213,6 +241,8 @@ public: RectPadding padding; ///< Padding added to the widget. Managed by parent container widget. (parent container may swap left and right for RTL) RectPadding uz_padding; ///< Unscaled padding, for resize calculation. + NWidgetBase *parent; ///< Parent widget of this widget, automatically filled in when added to container. + protected: inline void StoreSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height); }; From 628092f13362e4942646fea60f3c9154750e91fc Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 20:50:01 +0000 Subject: [PATCH 19/29] Codechange: Use GetParentWidget to find widget's NWidgetMatrix container. --- src/object_gui.cpp | 8 ++++---- src/rail_gui.cpp | 12 ++++++------ src/road_gui.cpp | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 046a55c9f9..8a198c8f89 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -333,7 +333,7 @@ public: * look nice in all layouts, we use the 4x4 layout (smallest previews) as starting point. For the bigger * previews in the layouts with less views we add space homogeneously on all sides, so the 4x4 preview-rectangle * is centered in the 2x1, 1x2 resp. 1x1 buttons. */ - const NWidgetMatrix *matrix = this->GetWidget(WID_BO_OBJECT_MATRIX); + const NWidgetMatrix *matrix = this->GetWidget(widget)->GetParentWidget(); uint matrix_height = matrix->current_y; DrawPixelInfo tmp_dpi; @@ -354,7 +354,7 @@ public: case WID_BO_SELECT_IMAGE: { ObjectClass *objclass = ObjectClass::Get(_selected_object_class); - int obj_index = objclass->GetIndexFromUI(this->GetWidget(WID_BO_SELECT_MATRIX)->GetCurrentElement()); + int obj_index = objclass->GetIndexFromUI(this->GetWidget(widget)->GetParentWidget()->GetCurrentElement()); if (obj_index < 0) break; const ObjectSpec *spec = objclass->GetSpec(obj_index); if (spec == nullptr) break; @@ -509,14 +509,14 @@ public: case WID_BO_SELECT_IMAGE: { ObjectClass *objclass = ObjectClass::Get(_selected_object_class); - int num_clicked = objclass->GetIndexFromUI(this->GetWidget(WID_BO_SELECT_MATRIX)->GetCurrentElement()); + int num_clicked = objclass->GetIndexFromUI(this->GetWidget(widget)->GetParentWidget()->GetCurrentElement()); if (num_clicked >= 0 && objclass->GetSpec(num_clicked)->IsAvailable()) this->SelectOtherObject(num_clicked); break; } case WID_BO_OBJECT_SPRITE: if (_selected_object_index != -1) { - _selected_object_view = this->GetWidget(WID_BO_OBJECT_MATRIX)->GetCurrentElement(); + _selected_object_view = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); this->SelectOtherObject(_selected_object_index); // Re-select the object for a different view. } break; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 494ba7d0e2..2f19b82205 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1285,7 +1285,7 @@ public: } case WID_BRAS_IMAGE: { - uint16_t type = this->GetWidget(WID_BRAS_MATRIX)->GetCurrentElement(); + uint16_t type = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); assert(type < _railstation.station_count); /* Check station availability callback */ const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type); @@ -1470,7 +1470,7 @@ public: } case WID_BRAS_IMAGE: { - uint16_t y = this->GetWidget(WID_BRAS_MATRIX)->GetCurrentElement(); + uint16_t y = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); if (y >= _railstation.station_count) return; /* Check station availability callback */ @@ -1480,7 +1480,7 @@ public: _railstation.station_type = y; this->CheckSelectedSize(statspec); - this->GetWidget(WID_BRAS_MATRIX)->SetClicked(_railstation.station_type); + this->GetWidget(widget)->GetParentWidget()->SetClicked(_railstation.station_type); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); @@ -2097,7 +2097,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { { switch (widget) { case WID_BRW_WAYPOINT: { - uint16_t type = this->list.at(this->GetWidget(WID_BRW_WAYPOINT_MATRIX)->GetCurrentElement()); + uint16_t type = this->list.at(this->GetWidget(widget)->GetParentWidget()->GetCurrentElement()); const StationSpec *statspec = this->waypoints->GetSpec(type); DrawPixelInfo tmp_dpi; @@ -2120,7 +2120,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { { switch (widget) { case WID_BRW_WAYPOINT: { - uint16_t sel = this->GetWidget(WID_BRW_WAYPOINT_MATRIX)->GetCurrentElement(); + uint16_t sel = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); assert(sel < this->list.size()); uint16_t type = this->list.at(sel); @@ -2129,7 +2129,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { if (!IsStationAvailable(statspec)) return; _cur_waypoint_type = type; - this->GetWidget(WID_BRW_WAYPOINT_MATRIX)->SetClicked(sel); + this->GetWidget(widget)->GetParentWidget()->SetClicked(sel); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 55cbc60e28..34cab6a898 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -1451,7 +1451,7 @@ public: } case WID_BROS_IMAGE: { - uint16_t type = this->GetWidget(WID_BROS_MATRIX)->GetCurrentElement(); + uint16_t type = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); assert(type < _roadstop_gui_settings.roadstop_count); const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(type); @@ -1549,7 +1549,7 @@ public: } case WID_BROS_IMAGE: { - uint16_t y = this->GetWidget(WID_BROS_MATRIX)->GetCurrentElement(); + uint16_t y = this->GetWidget(widget)->GetParentWidget()->GetCurrentElement(); if (y >= _roadstop_gui_settings.roadstop_count) return; const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(y); @@ -1559,7 +1559,7 @@ public: _roadstop_gui_settings.roadstop_type = y; - this->GetWidget(WID_BROS_MATRIX)->SetClicked(_roadstop_gui_settings.roadstop_type); + this->GetWidget(widget)->GetParentWidget()->SetClicked(_roadstop_gui_settings.roadstop_type); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); From 9a3934ae233cd7e61d578862c7963bec09c0197e Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 07:36:21 +0000 Subject: [PATCH 20/29] Codechange: Use vector/unique_ptr inside widget containers. This replaces a C-style double-linked-list which required all widgets to have next/prev pointers, and removes the need for manual pointer management. --- src/network/network_gui.cpp | 35 ++++++--- src/smallmap_gui.cpp | 10 ++- src/toolbar_gui.cpp | 34 +++++---- src/widget.cpp | 143 ++++++++++++------------------------ src/widget_type.h | 11 +-- 5 files changed, 98 insertions(+), 135 deletions(-) diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index bef7637ef4..0ce4e55be2 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -115,18 +115,18 @@ public: this->resize_y = 0; // We never resize in this direction /* First initialise some variables... */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->SetupSmallestSize(w); this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical()); } /* ... then in a second pass make sure the 'current' sizes are set. Won't change for most widgets. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->current_x = child_wid->smallest_x; child_wid->current_y = this->smallest_y; } - this->smallest_x = this->head->smallest_x + this->tail->smallest_x; // First and last are always shown, rest not + this->smallest_x = this->children.front()->smallest_x + this->children.back()->smallest_x; // First and last are always shown, rest not } void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override @@ -138,27 +138,38 @@ public: this->current_x = given_width; this->current_y = given_height; - given_width -= this->tail->smallest_x; + given_width -= this->children.back()->smallest_x; /* The first and last widget are always visible, determine which other should be visible */ - for (NWidgetBase *child_wid = this->head->next; child_wid->next != nullptr; child_wid = child_wid->next) { - if (given_width > ScaleGUITrad(MINIMUM_NAME_WIDTH_BEFORE_NEW_HEADER) + child_wid->smallest_x && child_wid->prev->current_x != 0) { - given_width -= child_wid->smallest_x; - child_wid->current_x = child_wid->smallest_x; /* Make visible. */ - } else { - child_wid->current_x = 0; /* Make invisible. */ + if (this->children.size() > 2) { + auto first = std::next(std::begin(this->children)); + auto last = std::prev(std::end(this->children)); + for (auto it = first; it != last; ++it) { + auto &child_wid = *it; + if (given_width > ScaleGUITrad(MINIMUM_NAME_WIDTH_BEFORE_NEW_HEADER) + child_wid->smallest_x && (*std::prev(it))->current_x != 0) { + given_width -= child_wid->smallest_x; + child_wid->current_x = child_wid->smallest_x; /* Make visible. */ + } else { + child_wid->current_x = 0; /* Make invisible. */ + } } } /* All remaining space goes to the first (name) widget */ - this->head->current_x = given_width; + this->children.front()->current_x = given_width; /* Now assign the widgets to their rightful place */ uint position = 0; // Place to put next child relative to origin of the container. - for (NWidgetBase *child_wid = rtl ? this->tail : this->head; child_wid != nullptr; child_wid = rtl ? child_wid->prev : child_wid->next) { + auto assign_position = [&](const std::unique_ptr &child_wid) { if (child_wid->current_x != 0) { child_wid->AssignSizePosition(sizing, x + position, y, child_wid->current_x, this->current_y, rtl); position += child_wid->current_x; } + }; + + if (rtl) { + std::for_each(std::rbegin(this->children), std::rend(this->children), assign_position); + } else { + std::for_each(std::begin(this->children), std::end(this->children), assign_position); } } }; diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 85012d66c1..a91760f646 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1852,8 +1852,9 @@ public: void SetupSmallestSize(Window *w) override { - NWidgetBase *display = this->head; - NWidgetBase *bar = display->next; + assert(this->children.size() == 2); + NWidgetBase *display = this->children.front().get(); + NWidgetBase *bar = this->children.back().get(); display->SetupSmallestSize(w); bar->SetupSmallestSize(w); @@ -1875,8 +1876,9 @@ public: this->current_x = given_width; this->current_y = given_height; - NWidgetBase *display = this->head; - NWidgetBase *bar = display->next; + assert(this->children.size() == 2); + NWidgetBase *display = this->children.front().get(); + NWidgetBase *bar = this->children.back().get(); if (sizing == ST_SMALLEST) { this->smallest_x = given_width; diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 2b3f12417a..396932196a 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -1347,7 +1347,7 @@ public: uint nbuttons = 0; /* First initialise some variables... */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->SetupSmallestSize(w); this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical()); if (this->IsButton(child_wid->type)) { @@ -1359,7 +1359,7 @@ public: } /* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->current_y = this->smallest_y; if (!this->IsButton(child_wid->type)) { child_wid->current_x = child_wid->smallest_x; @@ -1381,12 +1381,13 @@ public: uint 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]; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { - child_wid->current_x = 0; /* Hide widget, it will be revealed in the next step. */ - if (child_wid->type == NWID_SPACER) continue; - widgets[((NWidgetCore*)child_wid)->index] = child_wid; + /* Create us ourselves a quick lookup table from WidgetID to slot. */ + std::map lookup; + for (auto it = std::begin(this->children); it != std::end(this->children); ++it) { + NWidgetBase *nwid = it->get(); + nwid->current_x = 0; /* Hide widget, it will be revealed in the next step. */ + if (nwid->type == NWID_SPACER) continue; + lookup[dynamic_cast(nwid)->index] = std::distance(this->children.begin(), it); } /* Now assign the widgets to their rightful place */ @@ -1397,12 +1398,13 @@ public: uint button_i = 0; /* Index into the arrangement indices. The macro lastof cannot be used here! */ - const WidgetID *cur_wid = rtl ? &arrangement[arrangable_count - 1] : arrangement; + const WidgetID *slotp = 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 */ - if (spacer_space != 0) { - NWidgetBase *possible_spacer = rtl ? child_wid->next : child_wid->prev; + uint slot = lookup[*slotp]; + auto &child_wid = this->children[slot]; + /* If we have space to give to the spacers, do that. */ + if (spacer_space > 0 && slot > 0 && slot < this->children.size() - 1) { + const auto &possible_spacer = this->children[slot + (rtl ? 1 : -1)]; if (possible_spacer != nullptr && possible_spacer->type == NWID_SPACER) { uint add = spacer_space / (spacer_count - spacer_i); position += add; @@ -1423,9 +1425,9 @@ public: position += child_wid->current_x; if (rtl) { - cur_wid--; + slotp--; } else { - cur_wid++; + slotp++; } } } @@ -1783,7 +1785,7 @@ class NWidgetScenarioToolbarContainer : public NWidgetToolbarContainer { /* Find the size of panel_widths */ uint i = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { if (child_wid->type == NWID_SPACER || this->IsButton(child_wid->type)) continue; assert(i < lengthof(this->panel_widths)); diff --git a/src/widget.cpp b/src/widget.cpp index 151a6d40cb..fa5791dbb4 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1275,30 +1275,10 @@ NWidgetCore *NWidgetCore::GetWidgetFromPos(int x, int y) return (IsInsideBS(x, this->pos_x, this->current_x) && IsInsideBS(y, this->pos_y, this->current_y)) ? this : nullptr; } -/** - * Constructor container baseclass. - * @param tp Type of the container. - */ -NWidgetContainer::NWidgetContainer(WidgetType tp) : NWidgetBase(tp) -{ - this->head = nullptr; - this->tail = nullptr; -} - -NWidgetContainer::~NWidgetContainer() -{ - while (this->head != nullptr) { - NWidgetBase *wid = this->head->next; - delete this->head; - this->head = wid; - } - this->tail = nullptr; -} - NWidgetBase *NWidgetContainer::GetWidgetOfType(WidgetType tp) { if (this->type == tp) return this; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { NWidgetBase *nwid = child_wid->GetWidgetOfType(tp); if (nwid != nullptr) return nwid; } @@ -1307,7 +1287,7 @@ NWidgetBase *NWidgetContainer::GetWidgetOfType(WidgetType tp) void NWidgetContainer::AdjustPaddingForZoom() { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->AdjustPaddingForZoom(); } NWidgetBase::AdjustPaddingForZoom(); @@ -1321,31 +1301,19 @@ void NWidgetContainer::Add(NWidgetBase *wid) { assert(wid != nullptr); wid->parent = this; - assert(wid->next == nullptr && wid->prev == nullptr); - - if (this->head == nullptr) { - this->head = wid; - this->tail = wid; - } else { - assert(this->tail != nullptr); - assert(this->tail->next == nullptr); - - this->tail->next = wid; - wid->prev = this->tail; - this->tail = wid; - } + this->children.emplace_back(wid); } void NWidgetContainer::FillWidgetLookup(WidgetLookup &widget_lookup) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->FillWidgetLookup(widget_lookup); } } void NWidgetContainer::Draw(const Window *w) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->Draw(w); } @@ -1356,7 +1324,7 @@ NWidgetCore *NWidgetContainer::GetWidgetFromPos(int x, int y) { if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { NWidgetCore *nwid = child_wid->GetWidgetFromPos(x, y); if (nwid != nullptr) return nwid; } @@ -1372,7 +1340,7 @@ NWidgetStacked::NWidgetStacked(WidgetID index) : NWidgetContainer(NWID_SELECTION void NWidgetStacked::AdjustPaddingForZoom() { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->AdjustPaddingForZoom(); } NWidgetContainer::AdjustPaddingForZoom(); @@ -1401,11 +1369,11 @@ void NWidgetStacked::SetupSmallestSize(Window *w) /* First sweep, recurse down and compute minimal size and filling. */ this->smallest_x = 0; this->smallest_y = 0; - this->fill_x = (this->head != nullptr) ? 1 : 0; - this->fill_y = (this->head != nullptr) ? 1 : 0; - this->resize_x = (this->head != nullptr) ? 1 : 0; - this->resize_y = (this->head != nullptr) ? 1 : 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + this->fill_x = this->IsEmpty() ? 0 : 1; + this->fill_y = this->IsEmpty() ? 0 : 1; + this->resize_x = this->IsEmpty() ? 0 : 1; + this->resize_y = this->IsEmpty() ? 0 : 1; + for (const auto &child_wid : this->children) { child_wid->SetupSmallestSize(w); this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal()); @@ -1424,7 +1392,7 @@ void NWidgetStacked::AssignSizePosition(SizingType sizing, int x, int y, uint gi if (this->shown_plane >= SZSP_BEGIN) return; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint hor_step = (sizing == ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing); uint child_width = ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding.Horizontal(), hor_step); uint child_pos_x = (rtl ? child_wid->padding.right : child_wid->padding.left); @@ -1447,16 +1415,9 @@ void NWidgetStacked::Draw(const Window *w) { if (this->shown_plane >= SZSP_BEGIN) return; - int plane = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; plane++, child_wid = child_wid->next) { - if (plane == this->shown_plane) { - child_wid->Draw(w); - DrawOutline(w, this); - return; - } - } - - NOT_REACHED(); + assert(static_cast(this->shown_plane) < this->children.size()); + this->children[shown_plane]->Draw(w); + DrawOutline(w, this); } NWidgetCore *NWidgetStacked::GetWidgetFromPos(int x, int y) @@ -1464,13 +1425,9 @@ NWidgetCore *NWidgetStacked::GetWidgetFromPos(int x, int y) if (this->shown_plane >= SZSP_BEGIN) return nullptr; if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr; - int plane = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; plane++, child_wid = child_wid->next) { - if (plane == this->shown_plane) { - return child_wid->GetWidgetFromPos(x, y); - } - } - return nullptr; + + if (static_cast(this->shown_plane) >= this->children.size()) return nullptr; + return this->children[shown_plane]->GetWidgetFromPos(x, y); } /** @@ -1552,7 +1509,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w) /* 1a. Forward call, collect longest/widest child length. */ uint longest = 0; // Longest child found. uint max_vert_fill = 0; // Biggest vertical fill step. - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->SetupSmallestSize(w); longest = std::max(longest, child_wid->smallest_x); max_vert_fill = std::max(max_vert_fill, child_wid->GetVerticalStepSize(ST_SMALLEST)); @@ -1564,7 +1521,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w) [[maybe_unused]] uint max_smallest = this->smallest_y + 3 * max_vert_fill; // Upper limit to computing smallest height. uint cur_height = this->smallest_y; for (;;) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint step_size = child_wid->GetVerticalStepSize(ST_SMALLEST); uint child_height = child_wid->smallest_y + child_wid->padding.Vertical(); if (step_size > 1 && child_height < cur_height) { // Small step sizes or already fitting children are not interesting. @@ -1581,12 +1538,12 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w) } /* 2. For containers that must maintain equal width, extend child minimal size. */ if (this->flags & NC_EQUALSIZE) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { if (child_wid->fill_x == 1) child_wid->smallest_x = longest; } } /* 3. Compute smallest, fill, and resize values of the container. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { this->smallest_x += child_wid->smallest_x + child_wid->padding.Horizontal(); if (child_wid->fill_x > 0) { if (this->fill_x == 0 || this->fill_x > child_wid->fill_x) this->fill_x = child_wid->fill_x; @@ -1609,7 +1566,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint /* Compute additional width given to us. */ uint additional_length = given_width - (this->pip_pre + this->gaps * this->pip_inter + this->pip_post); - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { if (child_wid->smallest_x != 0 || child_wid->fill_x != 0) additional_length -= child_wid->smallest_x + child_wid->padding.Horizontal(); } @@ -1631,7 +1588,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint */ int num_changing_childs = 0; // Number of children that can change size. uint biggest_stepsize = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint hor_step = child_wid->GetHorizontalStepSize(sizing); if (hor_step > 0) { if (!(flags & NC_BIGFIRST)) num_changing_childs++; @@ -1646,7 +1603,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint /* First.5 loop: count how many children are of the biggest step size. */ if ((flags & NC_BIGFIRST) && biggest_stepsize > 0) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint hor_step = child_wid->GetHorizontalStepSize(sizing); if (hor_step == biggest_stepsize) { num_changing_childs++; @@ -1657,7 +1614,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint /* Second loop: Allocate the additional horizontal space over the resizing children, starting with the biggest resize steps. */ while (biggest_stepsize > 0) { uint next_biggest_stepsize = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint hor_step = child_wid->GetHorizontalStepSize(sizing); if (hor_step > biggest_stepsize) continue; // Already done if (hor_step == biggest_stepsize) { @@ -1674,7 +1631,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint if (num_changing_childs == 0 && (flags & NC_BIGFIRST) && biggest_stepsize > 0) { /* Second.5 loop: count how many children are of the updated biggest step size. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint hor_step = child_wid->GetHorizontalStepSize(sizing); if (hor_step == biggest_stepsize) { num_changing_childs++; @@ -1699,8 +1656,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint /* Third loop: Compute position and call the child. */ uint position = rtl ? this->current_x - pre : pre; // Place to put next child relative to origin of the container. - NWidgetBase *child_wid = this->head; - while (child_wid != nullptr) { + for (const auto &child_wid : this->children) { uint child_width = child_wid->current_x; uint child_x = x + (rtl ? position - child_width - child_wid->padding.left : position + child_wid->padding.left); uint child_y = y + child_wid->padding.top; @@ -1710,8 +1666,6 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, int x, int y, uint uint padded_child_width = child_width + child_wid->padding.Horizontal() + inter; position = rtl ? position - padded_child_width : position + padded_child_width; } - - child_wid = child_wid->next; } } @@ -1744,7 +1698,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w) /* 1a. Forward call, collect longest/widest child length. */ uint highest = 0; // Highest child found. uint max_hor_fill = 0; // Biggest horizontal fill step. - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { child_wid->SetupSmallestSize(w); highest = std::max(highest, child_wid->smallest_y); max_hor_fill = std::max(max_hor_fill, child_wid->GetHorizontalStepSize(ST_SMALLEST)); @@ -1756,7 +1710,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w) [[maybe_unused]] uint max_smallest = this->smallest_x + 3 * max_hor_fill; // Upper limit to computing smallest height. uint cur_width = this->smallest_x; for (;;) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint step_size = child_wid->GetHorizontalStepSize(ST_SMALLEST); uint child_width = child_wid->smallest_x + child_wid->padding.Horizontal(); if (step_size > 1 && child_width < cur_width) { // Small step sizes or already fitting children are not interesting. @@ -1773,12 +1727,12 @@ void NWidgetVertical::SetupSmallestSize(Window *w) } /* 2. For containers that must maintain equal width, extend children minimal size. */ if (this->flags & NC_EQUALSIZE) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { if (child_wid->fill_y == 1) child_wid->smallest_y = highest; } } /* 3. Compute smallest, fill, and resize values of the container. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { this->smallest_y += child_wid->smallest_y + child_wid->padding.Vertical(); if (child_wid->fill_y > 0) { if (this->fill_y == 0 || this->fill_y > child_wid->fill_y) this->fill_y = child_wid->fill_y; @@ -1801,7 +1755,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* Compute additional height given to us. */ uint additional_length = given_height - (this->pip_pre + this->gaps * this->pip_inter + this->pip_post); - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { if (child_wid->smallest_y != 0 || child_wid->fill_y != 0) additional_length -= child_wid->smallest_y + child_wid->padding.Vertical(); } @@ -1814,7 +1768,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* First loop: Find biggest stepsize, find number of children that want a piece of the pie, handle horizontal size for all children, handle vertical size for non-resizing child. */ int num_changing_childs = 0; // Number of children that can change size. uint biggest_stepsize = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint vert_step = child_wid->GetVerticalStepSize(sizing); if (vert_step > 0) { if (!(flags & NC_BIGFIRST)) num_changing_childs++; @@ -1829,7 +1783,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* First.5 loop: count how many children are of the biggest step size. */ if ((this->flags & NC_BIGFIRST) && biggest_stepsize > 0) { - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint vert_step = child_wid->GetVerticalStepSize(sizing); if (vert_step == biggest_stepsize) { num_changing_childs++; @@ -1840,7 +1794,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* Second loop: Allocate the additional vertical space over the resizing children, starting with the biggest resize steps. */ while (biggest_stepsize > 0) { uint next_biggest_stepsize = 0; - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint vert_step = child_wid->GetVerticalStepSize(sizing); if (vert_step > biggest_stepsize) continue; // Already done if (vert_step == biggest_stepsize) { @@ -1857,7 +1811,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g if (num_changing_childs == 0 && (flags & NC_BIGFIRST) && biggest_stepsize > 0) { /* Second.5 loop: count how many children are of the updated biggest step size. */ - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint vert_step = child_wid->GetVerticalStepSize(sizing); if (vert_step == biggest_stepsize) { num_changing_childs++; @@ -1882,7 +1836,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, int x, int y, uint g /* Third loop: Compute position and call the child. */ uint position = pre; // Place to put next child relative to origin of the container. - for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) { + for (const auto &child_wid : this->children) { uint child_x = x + (rtl ? child_wid->padding.right : child_wid->padding.left); uint child_height = child_wid->current_y; @@ -1974,7 +1928,7 @@ void NWidgetMatrix::SetCount(int count) * Then multiply that by the height of a widget, and add the pre * and post spacing "offsets". */ count = CeilDiv(count, this->sb->IsVertical() ? this->widgets_x : this->widgets_y); - count *= (this->sb->IsVertical() ? this->head->smallest_y : this->head->smallest_x) + this->pip_inter; + count *= (this->sb->IsVertical() ? this->children.front()->smallest_y : this->children.front()->smallest_x) + this->pip_inter; if (count > 0) count -= this->pip_inter; // We counted an inter too much in the multiplication above count += this->pip_pre + this->pip_post; this->sb->SetCount(count); @@ -2002,15 +1956,14 @@ int NWidgetMatrix::GetCurrentElement() const void NWidgetMatrix::SetupSmallestSize(Window *w) { - assert(this->head != nullptr); - assert(this->head->next == nullptr); + assert(this->children.size() == 1); - this->head->SetupSmallestSize(w); + this->children.front()->SetupSmallestSize(w); Dimension padding = { (uint)this->pip_pre + this->pip_post, (uint)this->pip_pre + this->pip_post}; - Dimension size = {this->head->smallest_x + padding.width, this->head->smallest_y + padding.height}; + Dimension size = {this->children.front()->smallest_x + padding.width, this->children.front()->smallest_y + padding.height}; Dimension fill = {0, 0}; - Dimension resize = {this->pip_inter + this->head->smallest_x, this->pip_inter + this->head->smallest_y}; + Dimension resize = {this->pip_inter + this->children.front()->smallest_x, this->pip_inter + this->children.front()->smallest_y}; if (this->index >= 0) w->UpdateWidgetSize(this->index, &size, padding, &fill, &resize); @@ -2032,8 +1985,8 @@ void NWidgetMatrix::AssignSizePosition(SizingType, int x, int y, uint given_widt this->current_y = given_height; /* Determine the size of the widgets, and the number of visible widgets on each of the axis. */ - this->widget_w = this->head->smallest_x + this->pip_inter; - this->widget_h = this->head->smallest_y + this->pip_inter; + this->widget_w = this->children.front()->smallest_x + this->pip_inter; + this->widget_h = this->children.front()->smallest_y + this->pip_inter; /* Account for the pip_inter is between widgets, so we need to account for that when * the division assumes pip_inter is used for all widgets. */ @@ -2072,7 +2025,7 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) this->current_element = (widget_row + start_y) * this->widgets_x + start_x + widget_col; if (this->current_element >= this->count) return nullptr; - NWidgetCore *child = dynamic_cast(this->head); + NWidgetCore *child = dynamic_cast(this->children.front().get()); assert(child != nullptr); child->AssignSizePosition(ST_RESIZE, this->pos_x + (rtl ? this->pip_post - widget_col * this->widget_w : this->pip_pre + widget_col * this->widget_w) + base_offs_x, @@ -2096,7 +2049,7 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y) AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi); /* Get the appropriate offsets so we can draw the right widgets. */ - NWidgetCore *child = dynamic_cast(this->head); + NWidgetCore *child = dynamic_cast(this->children.front().get()); assert(child != nullptr); int start_x, start_y, base_offs_x, base_offs_y; this->GetScrollOffsets(start_x, start_y, base_offs_x, base_offs_y); diff --git a/src/widget_type.h b/src/widget_type.h index 9c2620cad6..375ed88291 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -235,9 +235,6 @@ public: int pos_x; ///< Horizontal position of top-left corner of the widget in the window. int pos_y; ///< Vertical position of top-left corner of the widget in the window. - NWidgetBase *next; ///< Pointer to next widget in container. Managed by parent container widget. - NWidgetBase *prev; ///< Pointer to previous widget in container. Managed by parent container widget. - RectPadding padding; ///< Padding added to the widget. Managed by parent container widget. (parent container may swap left and right for RTL) RectPadding uz_padding; ///< Unscaled padding, for resize calculation. @@ -446,8 +443,7 @@ inline bool NWidgetCore::IsDisabled() const */ class NWidgetContainer : public NWidgetBase { public: - NWidgetContainer(WidgetType tp); - ~NWidgetContainer(); + NWidgetContainer(WidgetType tp) : NWidgetBase(tp) { } void AdjustPaddingForZoom() override; void Add(NWidgetBase *wid); @@ -457,13 +453,12 @@ public: NWidgetCore *GetWidgetFromPos(int x, int y) override; /** Return whether the container is empty. */ - inline bool IsEmpty() { return head == nullptr; } + inline bool IsEmpty() { return this->children.empty(); } NWidgetBase *GetWidgetOfType(WidgetType tp) override; protected: - NWidgetBase *head; ///< Pointer to first widget in container. - NWidgetBase *tail; ///< Pointer to last widget in container. + std::vector> children; ///< Child widgets in contaier. }; /** Display planes with zero size for #NWidgetStacked. */ From 7124b4eef12155051e824d09bbe8dc74773ef603 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 30 Dec 2023 07:36:22 +0000 Subject: [PATCH 21/29] Codechange: Use std::unique_ptr for all NWidgets. --- src/graph_gui.cpp | 18 +-- src/linkgraph/linkgraph_gui.cpp | 30 ++--- src/network/network_gui.cpp | 20 ++-- src/newgrf_gui.cpp | 40 +++---- src/osk_gui.cpp | 38 +++---- src/script/script_gui.cpp | 2 +- src/smallmap_gui.cpp | 8 +- src/station_gui.cpp | 8 +- src/tests/test_window_desc.cpp | 3 +- src/toolbar_gui.cpp | 14 +-- src/tree_gui.cpp | 12 +- src/widget.cpp | 196 +++++++++++++++----------------- src/widget_type.h | 18 +-- src/window.cpp | 1 - src/window_gui.h | 2 +- 15 files changed, 199 insertions(+), 211 deletions(-) diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 20186a6080..6952b8ec60 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -109,19 +109,19 @@ struct GraphLegendWindow : Window { * Construct a vertical list of buttons, one for each company. * @return Panel with company buttons. */ -static NWidgetBase *MakeNWidgetCompanyLines() +static std::unique_ptr MakeNWidgetCompanyLines() { - NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE); + auto vert = std::make_unique(NC_EQUALSIZE); vert->SetPadding(2, 2, 2, 2); uint sprite_height = GetSpriteSize(SPR_COMPANY_ICON, nullptr, ZOOM_LVL_OUT_4X).height; for (WidgetID widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) { - NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum); + auto panel = std::make_unique(WWT_PANEL, COLOUR_BROWN, widnum); panel->SetMinimalSize(246, sprite_height + WidgetDimensions::unscaled.framerect.Vertical()); panel->SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical(), FS_NORMAL); panel->SetFill(1, 1); panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP); - vert->Add(panel); + vert->Add(std::move(panel)); } return vert; } @@ -1337,7 +1337,7 @@ CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY; * Make a vertical list of panels for outputting score details. * @return Panel with performance details. */ -static NWidgetBase *MakePerformanceDetailPanels() +static std::unique_ptr MakePerformanceDetailPanels() { const StringID performance_tips[] = { STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP, @@ -1354,18 +1354,18 @@ static NWidgetBase *MakePerformanceDetailPanels() static_assert(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN); - NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE); + auto vert = std::make_unique(NC_EQUALSIZE); for (WidgetID widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) { - NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_BROWN, widnum); + auto panel = std::make_unique(WWT_PANEL, COLOUR_BROWN, widnum); panel->SetFill(1, 1); panel->SetDataTip(0x0, performance_tips[widnum - WID_PRD_SCORE_FIRST]); - vert->Add(panel); + vert->Add(std::move(panel)); } return vert; } /** Make a number of rows with buttons for each company for the performance rating detail window. */ -NWidgetBase *MakeCompanyButtonRowsGraphGUI() +std::unique_ptr MakeCompanyButtonRowsGraphGUI() { return MakeCompanyButtonRows(WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST, COLOUR_BROWN, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP); } diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index ad3661b44e..6f44f5c601 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -454,54 +454,54 @@ void LinkGraphOverlay::SetCompanyMask(CompanyMask company_mask) } /** Make a number of rows with buttons for each company for the linkgraph legend window. */ -NWidgetBase *MakeCompanyButtonRowsLinkGraphGUI() +std::unique_ptr MakeCompanyButtonRowsLinkGraphGUI() { return MakeCompanyButtonRows(WID_LGL_COMPANY_FIRST, WID_LGL_COMPANY_LAST, COLOUR_GREY, 3, STR_NULL); } -NWidgetBase *MakeSaturationLegendLinkGraphGUI() +std::unique_ptr MakeSaturationLegendLinkGraphGUI() { - NWidgetVertical *panel = new NWidgetVertical(NC_EQUALSIZE); + auto panel = std::make_unique(NC_EQUALSIZE); for (uint i = 0; i < lengthof(LinkGraphOverlay::LINK_COLOURS[0]); ++i) { - NWidgetBackground * wid = new NWidgetBackground(WWT_PANEL, COLOUR_DARK_GREEN, i + WID_LGL_SATURATION_FIRST); + auto wid = std::make_unique(WWT_PANEL, COLOUR_DARK_GREEN, i + WID_LGL_SATURATION_FIRST); wid->SetMinimalSize(50, 0); wid->SetMinimalTextLines(1, 0, FS_SMALL); wid->SetFill(1, 1); wid->SetResize(0, 0); - panel->Add(wid); + panel->Add(std::move(wid)); } return panel; } -NWidgetBase *MakeCargoesLegendLinkGraphGUI() +std::unique_ptr MakeCargoesLegendLinkGraphGUI() { uint num_cargo = static_cast(_sorted_cargo_specs.size()); static const uint ENTRIES_PER_COL = 5; - NWidgetHorizontal *panel = new NWidgetHorizontal(NC_EQUALSIZE); - NWidgetVertical *col = nullptr; + auto panel = std::make_unique(NC_EQUALSIZE); + std::unique_ptr col = nullptr; for (uint i = 0; i < num_cargo; ++i) { if (i % ENTRIES_PER_COL == 0) { - if (col != nullptr) panel->Add(col); - col = new NWidgetVertical(NC_EQUALSIZE); + if (col != nullptr) panel->Add(std::move(col)); + col = std::make_unique(NC_EQUALSIZE); } - NWidgetBackground * wid = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, i + WID_LGL_CARGO_FIRST); + auto wid = std::make_unique(WWT_PANEL, COLOUR_GREY, i + WID_LGL_CARGO_FIRST); wid->SetMinimalSize(25, 0); wid->SetMinimalTextLines(1, 0, FS_SMALL); wid->SetFill(1, 1); wid->SetResize(0, 0); - col->Add(wid); + col->Add(std::move(wid)); } /* Fill up last row */ for (uint i = num_cargo; i < Ceil(num_cargo, ENTRIES_PER_COL); ++i) { - NWidgetSpacer *spc = new NWidgetSpacer(25, 0); + auto spc = std::make_unique(25, 0); spc->SetMinimalTextLines(1, 0, FS_SMALL); spc->SetFill(1, 1); spc->SetResize(0, 0); - col->Add(spc); + col->Add(std::move(spc)); } /* If there are no cargo specs defined, then col won't have been created so don't add it. */ - if (col != nullptr) panel->Add(col); + if (col != nullptr) panel->Add(std::move(col)); return panel; } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 0ce4e55be2..29227844bf 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -89,21 +89,21 @@ class NWidgetServerListHeader : public NWidgetContainer { public: NWidgetServerListHeader() : NWidgetContainer(NWID_HORIZONTAL) { - NWidgetLeaf *leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME_TOOLTIP); + auto leaf = std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME, STR_NETWORK_SERVER_LIST_GAME_NAME_TOOLTIP); leaf->SetResize(1, 0); leaf->SetFill(1, 0); - this->Add(leaf); + this->Add(std::move(leaf)); - this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CLIENTS, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION_TOOLTIP)); - this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_MAPSIZE, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION_TOOLTIP)); - this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_DATE, STR_NETWORK_SERVER_LIST_DATE_CAPTION, STR_NETWORK_SERVER_LIST_DATE_CAPTION_TOOLTIP)); - this->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP)); + this->Add(std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_CLIENTS, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION, STR_NETWORK_SERVER_LIST_CLIENTS_CAPTION_TOOLTIP)); + this->Add(std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_MAPSIZE, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION, STR_NETWORK_SERVER_LIST_MAP_SIZE_CAPTION_TOOLTIP)); + this->Add(std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_DATE, STR_NETWORK_SERVER_LIST_DATE_CAPTION, STR_NETWORK_SERVER_LIST_DATE_CAPTION_TOOLTIP)); + this->Add(std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_YEARS, STR_NETWORK_SERVER_LIST_YEARS_CAPTION, STR_NETWORK_SERVER_LIST_YEARS_CAPTION_TOOLTIP)); - leaf = new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP); + leaf = std::make_unique(WWT_PUSHTXTBTN, COLOUR_WHITE, WID_NG_INFO, STR_EMPTY, STR_NETWORK_SERVER_LIST_INFO_ICONS_TOOLTIP); leaf->SetMinimalSize(14 + GetSpriteSize(SPR_LOCK, nullptr, ZOOM_LVL_OUT_4X).width + GetSpriteSize(SPR_BLOT, nullptr, ZOOM_LVL_OUT_4X).width, 12); leaf->SetFill(0, 1); - this->Add(leaf); + this->Add(std::move(leaf)); } void SetupSmallestSize(Window *w) override @@ -866,9 +866,9 @@ GUIGameServerList::FilterFunction * const NetworkGameWindow::filter_funcs[] = { &NGameSearchFilter }; -static NWidgetBase *MakeResizableHeader() +static std::unique_ptr MakeResizableHeader() { - return new NWidgetServerListHeader(); + return std::make_unique(); } static const NWidgetPart _nested_network_game_widgets[] = { diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index fd9dd69f87..57071d28d3 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1600,27 +1600,22 @@ NewGRFWindow::GUIGRFConfigList::FilterFunction * const NewGRFWindow::filter_func * - two column mode, put the #acs and the #avs underneath each other and the #inf next to it, or * - three column mode, put the #avs, #acs, and #inf each in its own column. */ -class NWidgetNewGRFDisplay : public NWidgetContainer { +class NWidgetNewGRFDisplay : public NWidgetBase { public: static const uint MAX_EXTRA_INFO_WIDTH; ///< Maximal additional width given to the panel. static const uint MIN_EXTRA_FOR_3_COLUMNS; ///< Minimal additional width needed before switching to 3 columns. - NWidgetBase *avs; ///< Widget with the available grfs list and buttons. - NWidgetBase *acs; ///< Widget with the active grfs list and buttons. - NWidgetBase *inf; ///< Info panel. + std::unique_ptr avs; ///< Widget with the available grfs list and buttons. + std::unique_ptr acs; ///< Widget with the active grfs list and buttons. + std::unique_ptr inf; ///< Info panel. bool editable; ///< Editable status of the parent NewGRF window (if \c false, drop all widgets that make the window editable). - NWidgetNewGRFDisplay(NWidgetBase *avs, NWidgetBase *acs, NWidgetBase *inf) : NWidgetContainer(NWID_HORIZONTAL) + NWidgetNewGRFDisplay(std::unique_ptr &&avs, std::unique_ptr &&acs, std::unique_ptr &&inf) : NWidgetBase(NWID_CUSTOM) + , avs(std::move(avs)) + , acs(std::move(acs)) + , inf(std::move(inf)) + , editable(true) // Temporary setting, 'real' value is set in SetupSmallestSize(). { - this->avs = avs; - this->acs = acs; - this->inf = inf; - - this->Add(this->avs); - this->Add(this->acs); - this->Add(this->inf); - - this->editable = true; // Temporary setting, 'real' value is set in SetupSmallestSize(). } void SetupSmallestSize(Window *w) override @@ -1785,6 +1780,13 @@ public: } } + void FillWidgetLookup(WidgetLookup &widget_lookup) override + { + this->avs->FillWidgetLookup(widget_lookup); + this->acs->FillWidgetLookup(widget_lookup); + this->inf->FillWidgetLookup(widget_lookup); + } + NWidgetCore *GetWidgetFromPos(int x, int y) override { if (!IsInsideBS(x, this->pos_x, this->current_x) || !IsInsideBS(y, this->pos_y, this->current_y)) return nullptr; @@ -1937,13 +1939,13 @@ static const NWidgetPart _nested_newgrf_infopanel_widgets[] = { }; /** Construct nested container widget for managing the lists and the info panel of the NewGRF GUI. */ -NWidgetBase* NewGRFDisplay() +std::unique_ptr NewGRFDisplay() { - NWidgetBase *avs = MakeNWidgets(std::begin(_nested_newgrf_availables_widgets), std::end(_nested_newgrf_availables_widgets), nullptr); - NWidgetBase *acs = MakeNWidgets(std::begin(_nested_newgrf_actives_widgets), std::end(_nested_newgrf_actives_widgets), nullptr); - NWidgetBase *inf = MakeNWidgets(std::begin(_nested_newgrf_infopanel_widgets), std::end(_nested_newgrf_infopanel_widgets), nullptr); + std::unique_ptr avs = MakeNWidgets(std::begin(_nested_newgrf_availables_widgets), std::end(_nested_newgrf_availables_widgets), nullptr); + std::unique_ptr acs = MakeNWidgets(std::begin(_nested_newgrf_actives_widgets), std::end(_nested_newgrf_actives_widgets), nullptr); + std::unique_ptr inf = MakeNWidgets(std::begin(_nested_newgrf_infopanel_widgets), std::end(_nested_newgrf_infopanel_widgets), nullptr); - return new NWidgetNewGRFDisplay(avs, acs, inf); + return std::make_unique(std::move(avs), std::move(acs), std::move(inf)); } /* Widget definition of the manage newgrfs window */ diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 627e264138..bdd1e0f0e3 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -222,32 +222,32 @@ static const int KEY_PADDING = 6; // Vertical padding for remaining key rows * @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, WidgetID widnum, uint16_t widdata) +static void AddKey(std::unique_ptr &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); if (widtype == NWID_SPACER) { if (!hor->IsEmpty()) key_width += INTER_KEY_SPACE; - NWidgetSpacer *spc = new NWidgetSpacer(key_width, 0); + auto spc = std::make_unique(key_width, 0); spc->SetMinimalTextLines(1, pad_y, FS_NORMAL); - hor->Add(spc); + hor->Add(std::move(spc)); } else { if (!hor->IsEmpty()) { - NWidgetSpacer *spc = new NWidgetSpacer(INTER_KEY_SPACE, 0); + auto spc = std::make_unique(INTER_KEY_SPACE, 0); spc->SetMinimalTextLines(1, pad_y, FS_NORMAL); - hor->Add(spc); + hor->Add(std::move(spc)); } - NWidgetLeaf *leaf = new NWidgetLeaf(widtype, COLOUR_GREY, widnum, widdata, STR_NULL); + auto leaf = std::make_unique(widtype, COLOUR_GREY, widnum, widdata, STR_NULL); leaf->SetMinimalSize(key_width, 0); leaf->SetMinimalTextLines(1, pad_y, FS_NORMAL); - hor->Add(leaf); + hor->Add(std::move(leaf)); } } /** Construct the top row keys (cancel, ok, backspace). */ -static NWidgetBase *MakeTopKeys() +static std::unique_ptr MakeTopKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontal(); + auto hor = std::make_unique(); AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_CANCEL, STR_BUTTON_CANCEL); AddKey(hor, TOP_KEY_PADDING, 6 * 2, WWT_TEXTBTN, WID_OSK_OK, STR_BUTTON_OK ); @@ -256,9 +256,9 @@ static NWidgetBase *MakeTopKeys() } /** Construct the row containing the digit keys. */ -static NWidgetBase *MakeNumberKeys() +static std::unique_ptr MakeNumberKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); + std::unique_ptr hor = std::make_unique(); for (WidgetID widnum = WID_OSK_NUMBERS_FIRST; widnum <= WID_OSK_NUMBERS_LAST; widnum++) { AddKey(hor, KEY_PADDING, 2, WWT_PUSHBTN, widnum, 0x0); @@ -267,9 +267,9 @@ static NWidgetBase *MakeNumberKeys() } /** Construct the qwerty row keys. */ -static NWidgetBase *MakeQwertyKeys() +static std::unique_ptr MakeQwertyKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); + std::unique_ptr hor = std::make_unique(); AddKey(hor, KEY_PADDING, 3, WWT_PUSHIMGBTN, WID_OSK_SPECIAL, SPR_OSK_SPECIAL); for (WidgetID widnum = WID_OSK_QWERTY_FIRST; widnum <= WID_OSK_QWERTY_LAST; widnum++) { @@ -280,9 +280,9 @@ static NWidgetBase *MakeQwertyKeys() } /** Construct the asdfg row keys. */ -static NWidgetBase *MakeAsdfgKeys() +static std::unique_ptr MakeAsdfgKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); + std::unique_ptr hor = std::make_unique(); AddKey(hor, KEY_PADDING, 4, WWT_IMGBTN, WID_OSK_CAPS, SPR_OSK_CAPS); for (WidgetID widnum = WID_OSK_ASDFG_FIRST; widnum <= WID_OSK_ASDFG_LAST; widnum++) { @@ -292,9 +292,9 @@ static NWidgetBase *MakeAsdfgKeys() } /** Construct the zxcvb row keys. */ -static NWidgetBase *MakeZxcvbKeys() +static std::unique_ptr MakeZxcvbKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontalLTR(); + std::unique_ptr hor = std::make_unique(); AddKey(hor, KEY_PADDING, 3, WWT_IMGBTN, WID_OSK_SHIFT, SPR_OSK_SHIFT); for (WidgetID widnum = WID_OSK_ZXCVB_FIRST; widnum <= WID_OSK_ZXCVB_LAST; widnum++) { @@ -305,9 +305,9 @@ static NWidgetBase *MakeZxcvbKeys() } /** Construct the spacebar row keys. */ -static NWidgetBase *MakeSpacebarKeys() +static std::unique_ptr MakeSpacebarKeys() { - NWidgetHorizontal *hor = new NWidgetHorizontal(); + auto hor = std::make_unique(); AddKey(hor, KEY_PADDING, 8, NWID_SPACER, 0, 0); AddKey(hor, KEY_PADDING, 13, WWT_PUSHTXTBTN, WID_OSK_SPACE, STR_EMPTY); diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index f89e7f3f59..8a8fa7b2ca 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -1229,7 +1229,7 @@ struct ScriptDebugWindow : public Window { }; /** Make a number of rows with buttons for each company for the Script debug window. */ -NWidgetBase *MakeCompanyButtonRowsScriptDebug() +std::unique_ptr MakeCompanyButtonRowsScriptDebug() { return MakeCompanyButtonRows(WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END, COLOUR_GREY, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP); } diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index a91760f646..51acb14a26 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1944,12 +1944,12 @@ static const NWidgetPart _nested_smallmap_bar[] = { EndContainer(), }; -static NWidgetBase *SmallMapDisplay() +static std::unique_ptr SmallMapDisplay() { - NWidgetContainer *map_display = new NWidgetSmallmapDisplay; + std::unique_ptr map_display = std::make_unique(); - MakeNWidgets(std::begin(_nested_smallmap_display), std::end(_nested_smallmap_display), map_display); - MakeNWidgets(std::begin(_nested_smallmap_bar), std::end(_nested_smallmap_bar), map_display); + map_display = MakeNWidgets(std::begin(_nested_smallmap_display), std::end(_nested_smallmap_display), std::move(map_display)); + map_display = MakeNWidgets(std::begin(_nested_smallmap_bar), std::end(_nested_smallmap_bar), std::move(map_display)); return map_display; } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 036bb665e1..eac09d48bc 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -716,18 +716,18 @@ const StringID CompanyStationsWindow::sorter_names[] = { * Make a horizontal row of cargo buttons, starting at widget #WID_STL_CARGOSTART. * @return Horizontal row. */ -static NWidgetBase *CargoWidgets() +static std::unique_ptr CargoWidgets() { - NWidgetHorizontal *container = new NWidgetHorizontal(); + auto container = std::make_unique(); for (uint i = 0; i < _sorted_standard_cargo_specs.size(); i++) { - NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_STL_CARGOSTART + i); + auto panel = std::make_unique(WWT_PANEL, COLOUR_GREY, WID_STL_CARGOSTART + i); panel->SetMinimalSize(14, 0); panel->SetMinimalTextLines(1, 0, FS_NORMAL); panel->SetResize(0, 0); panel->SetFill(0, 1); panel->SetDataTip(0, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE); - container->Add(panel); + container->Add(std::move(panel)); } return container; } diff --git a/src/tests/test_window_desc.cpp b/src/tests/test_window_desc.cpp index 419c6994ca..3cd8406666 100644 --- a/src/tests/test_window_desc.cpp +++ b/src/tests/test_window_desc.cpp @@ -90,9 +90,8 @@ TEST_CASE_METHOD(WindowDescTestsFixture, "WindowDesc - NWidgetPart validity") INFO(fmt::format("{}:{}", window_desc->file, window_desc->line)); NWidgetStacked *shade_select = nullptr; - NWidgetBase *root = nullptr; + std::unique_ptr root = nullptr; REQUIRE_NOTHROW(root = MakeWindowNWidgetTree(window_desc->nwid_begin, window_desc->nwid_end, &shade_select)); CHECK((root != nullptr)); - delete root; } diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 396932196a..4ca6ad5383 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -2122,7 +2122,7 @@ struct MainToolbarWindow : Window { }}; }; -static NWidgetBase *MakeMainToolbar() +static std::unique_ptr MakeMainToolbar() { /** Sprites to use for the different toolbar buttons */ static const SpriteID toolbar_button_sprites[] = { @@ -2159,7 +2159,7 @@ static NWidgetBase *MakeMainToolbar() SPR_IMG_SWITCH_TOOLBAR, // WID_TN_SWITCH_BAR }; - NWidgetMainToolbarContainer *hor = new NWidgetMainToolbarContainer(); + auto hor = std::make_unique(); for (WidgetID i = 0; i < WID_TN_END; i++) { switch (i) { case WID_TN_SMALL_MAP: @@ -2168,12 +2168,12 @@ static NWidgetBase *MakeMainToolbar() case WID_TN_ZOOM_IN: case WID_TN_BUILDING_TOOLS_START: case WID_TN_MUSIC_SOUND: - hor->Add(new NWidgetSpacer(0, 0)); + hor->Add(std::make_unique(0, 0)); break; } - NWidgetLeaf *leaf = new NWidgetLeaf(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i); + auto leaf = std::make_unique(i == WID_TN_SAVE ? WWT_IMGBTN_2 : WWT_IMGBTN, COLOUR_GREY, i, toolbar_button_sprites[i], STR_TOOLBAR_TOOLTIP_PAUSE_GAME + i); leaf->SetMinimalSize(20, 20); - hor->Add(leaf); + hor->Add(std::move(leaf)); } return hor; @@ -2514,9 +2514,9 @@ static const NWidgetPart _nested_toolb_scen_inner_widgets[] = { NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SWITCH_BAR), SetDataTip(SPR_IMG_SWITCH_TOOLBAR, STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR), }; -static NWidgetBase *MakeScenarioToolbar() +static std::unique_ptr MakeScenarioToolbar() { - return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), new NWidgetScenarioToolbarContainer()); + return MakeNWidgets(std::begin(_nested_toolb_scen_inner_widgets), std::end(_nested_toolb_scen_inner_widgets), std::make_unique()); } static const NWidgetPart _nested_toolb_scen_widgets[] = { diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 448df9a797..9a08cfef99 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -256,7 +256,7 @@ public: * get producing the correct result than dynamically building the widgets is. * @see NWidgetFunctionType */ -static NWidgetBase *MakeTreeTypeButtons() +static std::unique_ptr MakeTreeTypeButtons() { const byte type_base = _tree_base_by_landscape[_settings_game.game_creation.landscape]; const byte type_count = _tree_count_by_landscape[_settings_game.game_creation.landscape]; @@ -266,20 +266,20 @@ static NWidgetBase *MakeTreeTypeButtons() const int num_rows = CeilDiv(type_count, num_columns); byte cur_type = type_base; - NWidgetVertical *vstack = new NWidgetVertical(NC_EQUALSIZE); + auto vstack = std::make_unique(NC_EQUALSIZE); vstack->SetPIP(0, 1, 0); for (int row = 0; row < num_rows; row++) { - NWidgetHorizontal *hstack = new NWidgetHorizontal(NC_EQUALSIZE); + auto hstack = std::make_unique(NC_EQUALSIZE); hstack->SetPIP(0, 1, 0); - vstack->Add(hstack); for (int col = 0; col < num_columns; col++) { if (cur_type > type_base + type_count) break; - NWidgetBackground *button = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_BT_TYPE_BUTTON_FIRST + cur_type); + auto button = std::make_unique(WWT_PANEL, COLOUR_GREY, WID_BT_TYPE_BUTTON_FIRST + cur_type); button->SetDataTip(0x0, STR_PLANT_TREE_TOOLTIP); - hstack->Add(button); + hstack->Add(std::move(button)); cur_type++; } + vstack->Add(std::move(hstack)); } return vstack; diff --git a/src/widget.cpp b/src/widget.cpp index fa5791dbb4..18a04092bf 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1297,11 +1297,11 @@ void NWidgetContainer::AdjustPaddingForZoom() * Append widget \a wid to container. * @param wid Widget to append. */ -void NWidgetContainer::Add(NWidgetBase *wid) +void NWidgetContainer::Add(std::unique_ptr &&wid) { assert(wid != nullptr); wid->parent = this; - this->children.emplace_back(wid); + this->children.push_back(std::move(wid)); } void NWidgetContainer::FillWidgetLookup(WidgetLookup &widget_lookup) @@ -2121,19 +2121,14 @@ void NWidgetMatrix::GetScrollOffsets(int &start_x, int &start_y, int &base_offs_ * vertical container will be inserted while adding the first * child widget. */ -NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, NWidgetPIPContainer *child) : NWidgetCore(tp, colour, index, 1, 1, 0x0, STR_NULL) +NWidgetBackground::NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, std::unique_ptr &&child) : NWidgetCore(tp, colour, index, 1, 1, 0x0, STR_NULL) { assert(tp == WWT_PANEL || tp == WWT_INSET || tp == WWT_FRAME); - this->child = child; + this->child = std::move(child); if (this->child != nullptr) this->child->parent = this; this->SetAlignment(SA_TOP | SA_LEFT); } -NWidgetBackground::~NWidgetBackground() -{ - if (this->child != nullptr) delete this->child; -} - /** * Add a child to the parent. * @param nwid Nested widget to add to the background widget. @@ -2141,13 +2136,13 @@ NWidgetBackground::~NWidgetBackground() * Unless a child container has been given in the constructor, a parent behaves as a vertical container. * You can add several children to it, and they are put underneath each other. */ -void NWidgetBackground::Add(NWidgetBase *nwid) +void NWidgetBackground::Add(std::unique_ptr &&nwid) { if (this->child == nullptr) { - this->child = new NWidgetVertical(); + this->child = std::make_unique(); } - nwid->parent = this->child; - this->child->Add(nwid); + nwid->parent = this->child.get(); + this->child->Add(std::move(nwid)); } /** @@ -2163,7 +2158,7 @@ void NWidgetBackground::Add(NWidgetBase *nwid) void NWidgetBackground::SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post) { if (this->child == nullptr) { - this->child = new NWidgetVertical(); + this->child = std::make_unique(); } this->child->parent = this; this->child->SetPIP(pip_pre, pip_inter, pip_post); @@ -2182,7 +2177,7 @@ void NWidgetBackground::SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_p void NWidgetBackground::SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_ratio_post) { if (this->child == nullptr) { - this->child = new NWidgetVertical(); + this->child = std::make_unique(); } this->child->parent = this; this->child->SetPIPRatio(pip_ratio_pre, pip_ratio_inter, pip_ratio_post); @@ -3043,60 +3038,60 @@ bool NWidgetLeaf::ButtonHit(const Point &pt) * @param fill_dest Fill the composed widget with child widgets. * @return Pointer to remaining nested widget parts. */ -static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **dest, bool *fill_dest) +static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr &dest, bool *fill_dest) { - *dest = nullptr; + dest = nullptr; *fill_dest = false; while (nwid_begin < nwid_end) { switch (nwid_begin->type) { case NWID_SPACER: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetSpacer(0, 0); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(0, 0); break; case NWID_HORIZONTAL: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetHorizontal(nwid_begin->u.cont_flags); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.cont_flags); *fill_dest = true; break; case NWID_HORIZONTAL_LTR: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetHorizontalLTR(nwid_begin->u.cont_flags); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.cont_flags); *fill_dest = true; break; case WWT_PANEL: case WWT_INSET: case WWT_FRAME: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetBackground(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); *fill_dest = true; break; case NWID_VERTICAL: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetVertical(nwid_begin->u.cont_flags); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.cont_flags); *fill_dest = true; break; case NWID_MATRIX: { - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetMatrix(nwid_begin->u.widget.colour, nwid_begin->u.widget.index); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.widget.colour, nwid_begin->u.widget.index); *fill_dest = true; break; } case WPT_FUNCTION: { - if (*dest != nullptr) return nwid_begin; - *dest = nwid_begin->u.func_ptr(); + if (dest != nullptr) return nwid_begin; + dest = nwid_begin->u.func_ptr(); *fill_dest = false; break; } case WPT_RESIZE: { - NWidgetResizeBase *nwrb = dynamic_cast(*dest); + NWidgetResizeBase *nwrb = dynamic_cast(dest.get()); if (unlikely(nwrb == nullptr)) throw std::runtime_error("WPT_RESIZE requires NWidgetResizeBase"); assert(nwid_begin->u.xy.x >= 0 && nwid_begin->u.xy.y >= 0); nwrb->SetResize(nwid_begin->u.xy.x, nwid_begin->u.xy.y); @@ -3104,7 +3099,7 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_MINSIZE: { - NWidgetResizeBase *nwrb = dynamic_cast(*dest); + NWidgetResizeBase *nwrb = dynamic_cast(dest.get()); if (unlikely(nwrb == nullptr)) throw std::runtime_error("WPT_MINSIZE requires NWidgetResizeBase"); assert(nwid_begin->u.xy.x >= 0 && nwid_begin->u.xy.y >= 0); nwrb->SetMinimalSize(nwid_begin->u.xy.x, nwid_begin->u.xy.y); @@ -3112,7 +3107,7 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_MINTEXTLINES: { - NWidgetResizeBase *nwrb = dynamic_cast(*dest); + NWidgetResizeBase *nwrb = dynamic_cast(dest.get()); if (unlikely(nwrb == nullptr)) throw std::runtime_error("WPT_MINTEXTLINES requires NWidgetResizeBase"); assert(nwid_begin->u.text_lines.size >= FS_BEGIN && nwid_begin->u.text_lines.size < FS_END); nwrb->SetMinimalTextLines(nwid_begin->u.text_lines.lines, nwid_begin->u.text_lines.spacing, nwid_begin->u.text_lines.size); @@ -3120,28 +3115,28 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_TEXTSTYLE: { - NWidgetCore *nwc = dynamic_cast(*dest); + NWidgetCore *nwc = dynamic_cast(dest.get()); if (unlikely(nwc == nullptr)) throw std::runtime_error("WPT_TEXTSTYLE requires NWidgetCore"); nwc->SetTextStyle(nwid_begin->u.text_style.colour, nwid_begin->u.text_style.size); break; } case WPT_ALIGNMENT: { - NWidgetCore *nwc = dynamic_cast(*dest); + NWidgetCore *nwc = dynamic_cast(dest.get()); if (unlikely(nwc == nullptr)) throw std::runtime_error("WPT_ALIGNMENT requires NWidgetCore"); nwc->SetAlignment(nwid_begin->u.align.align); break; } case WPT_FILL: { - NWidgetResizeBase *nwrb = dynamic_cast(*dest); + NWidgetResizeBase *nwrb = dynamic_cast(dest.get()); if (unlikely(nwrb == nullptr)) throw std::runtime_error("WPT_FILL requires NWidgetResizeBase"); nwrb->SetFill(nwid_begin->u.xy.x, nwid_begin->u.xy.y); break; } case WPT_DATATIP: { - NWidgetCore *nwc = dynamic_cast(*dest); + NWidgetCore *nwc = dynamic_cast(dest.get()); if (unlikely(nwc == nullptr)) throw std::runtime_error("WPT_DATATIP requires NWidgetCore"); nwc->widget_data = nwid_begin->u.data_tip.data; nwc->tool_tip = nwid_begin->u.data_tip.tooltip; @@ -3149,15 +3144,15 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_PADDING: - if (unlikely(*dest == nullptr)) throw std::runtime_error("WPT_PADDING requires NWidgetBase"); - (*dest)->SetPadding(nwid_begin->u.padding); + if (unlikely(dest == nullptr)) throw std::runtime_error("WPT_PADDING requires NWidgetBase"); + dest->SetPadding(nwid_begin->u.padding); break; case WPT_PIPSPACE: { - NWidgetPIPContainer *nwc = dynamic_cast(*dest); + NWidgetPIPContainer *nwc = dynamic_cast(dest.get()); if (nwc != nullptr) nwc->SetPIP(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post); - NWidgetBackground *nwb = dynamic_cast(*dest); + NWidgetBackground *nwb = dynamic_cast(dest.get()); if (nwb != nullptr) nwb->SetPIP(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post); if (unlikely(nwc == nullptr && nwb == nullptr)) throw std::runtime_error("WPT_PIPSPACE requires NWidgetPIPContainer or NWidgetBackground"); @@ -3165,10 +3160,10 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_PIPRATIO: { - NWidgetPIPContainer *nwc = dynamic_cast(*dest); + NWidgetPIPContainer *nwc = dynamic_cast(dest.get()); if (nwc != nullptr) nwc->SetPIPRatio(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post); - NWidgetBackground *nwb = dynamic_cast(*dest); + NWidgetBackground *nwb = dynamic_cast(dest.get()); if (nwb != nullptr) nwb->SetPIPRatio(nwid_begin->u.pip.pre, nwid_begin->u.pip.inter, nwid_begin->u.pip.post); if (unlikely(nwc == nullptr && nwb == nullptr)) throw std::runtime_error("WPT_PIPRATIO requires NWidgetPIPContainer or NWidgetBackground"); @@ -3176,7 +3171,7 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg } case WPT_SCROLLBAR: { - NWidgetCore *nwc = dynamic_cast(*dest); + NWidgetCore *nwc = dynamic_cast(dest.get()); if (unlikely(nwc == nullptr)) throw std::runtime_error("WPT_SCROLLBAR requires NWidgetCore"); nwc->scrollbar_index = nwid_begin->u.widget.index; break; @@ -3186,27 +3181,27 @@ static const NWidgetPart *MakeNWidget(const NWidgetPart *nwid_begin, const NWidg return nwid_begin; case NWID_VIEWPORT: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetViewport(nwid_begin->u.widget.index); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.widget.index); break; case NWID_HSCROLLBAR: case NWID_VSCROLLBAR: - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetScrollbar(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index); break; case NWID_SELECTION: { - if (*dest != nullptr) return nwid_begin; - *dest = new NWidgetStacked(nwid_begin->u.widget.index); + if (dest != nullptr) return nwid_begin; + dest = std::make_unique(nwid_begin->u.widget.index); *fill_dest = true; break; } default: - if (*dest != nullptr) return nwid_begin; + if (dest != nullptr) return nwid_begin; assert((nwid_begin->type & WWT_MASK) < WWT_LAST || (nwid_begin->type & WWT_MASK) == NWID_BUTTON_DROPDOWN); - *dest = new NWidgetLeaf(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index, 0x0, STR_NULL); + dest = std::make_unique(nwid_begin->type, nwid_begin->u.widget.colour, nwid_begin->u.widget.index, 0x0, STR_NULL); break; } nwid_begin++; @@ -3233,33 +3228,32 @@ bool IsContainerWidgetType(WidgetType tp) * @param parent Pointer or container to use for storing the child widgets (*parent == nullptr or *parent == container or background widget). * @return Pointer to remaining nested widget parts. */ -static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetBase **parent) +static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr &parent) { /* If *parent == nullptr, only the first widget is read and returned. Otherwise, *parent must point to either * a #NWidgetContainer or a #NWidgetBackground object, and parts are added as much as possible. */ - NWidgetContainer *nwid_cont = dynamic_cast(*parent); - NWidgetBackground *nwid_parent = dynamic_cast(*parent); - assert(*parent == nullptr || (nwid_cont != nullptr && nwid_parent == nullptr) || (nwid_cont == nullptr && nwid_parent != nullptr)); + NWidgetContainer *nwid_cont = dynamic_cast(parent.get()); + NWidgetBackground *nwid_parent = dynamic_cast(parent.get()); + assert(parent == nullptr || (nwid_cont != nullptr && nwid_parent == nullptr) || (nwid_cont == nullptr && nwid_parent != nullptr)); for (;;) { - NWidgetBase *sub_widget = nullptr; + std::unique_ptr sub_widget = nullptr; bool fill_sub = false; - nwid_begin = MakeNWidget(nwid_begin, nwid_end, &sub_widget, &fill_sub); + nwid_begin = MakeNWidget(nwid_begin, nwid_end, sub_widget, &fill_sub); /* Break out of loop when end reached */ if (sub_widget == nullptr) break; /* If sub-widget is a container, recursively fill that container. */ if (fill_sub && IsContainerWidgetType(sub_widget->type)) { - NWidgetBase *sub_ptr = sub_widget; - nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, &sub_ptr); + nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, sub_widget); } /* Add sub_widget to parent container if available, otherwise return the widget to the caller. */ - if (nwid_cont != nullptr) nwid_cont->Add(sub_widget); - if (nwid_parent != nullptr) nwid_parent->Add(sub_widget); + if (nwid_cont != nullptr) nwid_cont->Add(std::move(sub_widget)); + if (nwid_parent != nullptr) nwid_parent->Add(std::move(sub_widget)); if (nwid_cont == nullptr && nwid_parent == nullptr) { - *parent = sub_widget; + parent = std::move(sub_widget); return nwid_begin; } } @@ -3279,15 +3273,14 @@ static const NWidgetPart *MakeWidgetTree(const NWidgetPart *nwid_begin, const NW * @return Root of the nested widget tree, a vertical container containing the entire GUI. * @ingroup NestedWidgetParts */ -NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetContainer *container) +std::unique_ptr MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr &&container) { - if (container == nullptr) container = new NWidgetVertical(); - NWidgetBase *cont_ptr = container; - [[maybe_unused]] const NWidgetPart *nwid_part = MakeWidgetTree(nwid_begin, nwid_end, &cont_ptr); + if (container == nullptr) container = std::make_unique(); + [[maybe_unused]] const NWidgetPart *nwid_part = MakeWidgetTree(nwid_begin, nwid_end, container); #ifdef WITH_ASSERT if (unlikely(nwid_part != nwid_end)) throw std::runtime_error("Did not consume all NWidgetParts"); #endif - return container; + return std::move(container); } /** @@ -3300,38 +3293,33 @@ NWidgetContainer *MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart * @return Root of the nested widget tree, a vertical container containing the entire GUI. * @ingroup NestedWidgetParts */ -NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetStacked **shade_select) +std::unique_ptr MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetStacked **shade_select) { + *shade_select = nullptr; + /* Read the first widget recursively from the array. */ - NWidgetBase *nwid = nullptr; - nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, &nwid); + std::unique_ptr nwid = nullptr; + nwid_begin = MakeWidgetTree(nwid_begin, nwid_end, nwid); assert(nwid != nullptr); - NWidgetContainer *root = new NWidgetVertical; - root->Add(nwid); - if (nwid_begin == nwid_end) { // There is no body at all. - *shade_select = nullptr; - return root; - } + NWidgetHorizontal *hor_cont = dynamic_cast(nwid.get()); + + auto root = std::make_unique(); + root->Add(std::move(nwid)); + if (nwid_begin == nwid_end) return root; // There is no body at all. - /* If the first widget looks like a titlebar, treat it as such. - * If it has a shading box, silently add a shade selection widget in the tree. */ - NWidgetHorizontal *hor_cont = dynamic_cast(nwid); - NWidgetContainer *body; if (hor_cont != nullptr && hor_cont->GetWidgetOfType(WWT_CAPTION) != nullptr && hor_cont->GetWidgetOfType(WWT_SHADEBOX) != nullptr) { - *shade_select = new NWidgetStacked(-1); - root->Add(*shade_select); - body = new NWidgetVertical; - (*shade_select)->Add(body); - } else { - *shade_select = nullptr; - body = root; + /* If the first widget has a title bar and a shade box, silently add a shade selection widget in the tree. */ + auto shade_stack = std::make_unique(-1); + *shade_select = shade_stack.get(); + /* Load the remaining parts into the shade stack. */ + shade_stack->Add(MakeNWidgets(nwid_begin, nwid_end, std::make_unique())); + root->Add(std::move(shade_stack)); + return root; } - /* Load the remaining parts into 'body'. */ - MakeNWidgets(nwid_begin, nwid_end, body); - - return root; + /* Load the remaining parts into 'root'. */ + return MakeNWidgets(nwid_begin, nwid_end, std::move(root)); } /** @@ -3343,11 +3331,11 @@ NWidgetContainer *MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWi * @param button_tooltip The tooltip-string of every button. * @return Panel with rows of company buttons. */ -NWidgetBase *MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip) +std::unique_ptr 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. - NWidgetHorizontal *hor = nullptr; // Storage for buttons in one row. + std::unique_ptr vert = nullptr; // Storage for all rows. + std::unique_ptr hor = nullptr; // Storage for buttons in one row. int hor_length = 0; Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON, nullptr, ZOOM_LVL_OUT_4X); @@ -3357,33 +3345,33 @@ NWidgetBase *MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, 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(); - vert->Add(hor); + if (vert == nullptr) vert = std::make_unique(); + vert->Add(std::move(hor)); hor = nullptr; hor_length = 0; } if (hor == nullptr) { - hor = new NWidgetHorizontal(); + hor = std::make_unique(); hor_length = 0; } - NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, button_colour, widnum); + auto panel = std::make_unique(WWT_PANEL, button_colour, widnum); panel->SetMinimalSize(sprite_size.width, sprite_size.height); panel->SetFill(1, 1); panel->SetResize(1, 0); panel->SetDataTip(0x0, button_tooltip); - hor->Add(panel); + hor->Add(std::move(panel)); hor_length++; } if (vert == nullptr) return hor; // All buttons fit in a single row. if (hor_length > 0 && hor_length < max_length) { /* Last row is partial, add a spacer at the end to force all buttons to the left. */ - NWidgetSpacer *spc = new NWidgetSpacer(sprite_size.width, sprite_size.height); + auto spc = std::make_unique(sprite_size.width, sprite_size.height); spc->SetFill(1, 1); spc->SetResize(1, 0); - hor->Add(spc); + hor->Add(std::move(spc)); } - if (hor != nullptr) vert->Add(hor); + if (hor != nullptr) vert->Add(std::move(hor)); return vert; } diff --git a/src/widget_type.h b/src/widget_type.h index 375ed88291..1f831090e2 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -84,6 +84,7 @@ enum WidgetType { NWID_BUTTON_DROPDOWN, ///< Button with a drop-down. NWID_HSCROLLBAR, ///< Horizontal scrollbar NWID_VSCROLLBAR, ///< Vertical scrollbar + NWID_CUSTOM, ///< General Custom widget. /* Nested widget part types. */ WPT_RESIZE, ///< Widget part for specifying resizing. @@ -446,7 +447,7 @@ public: NWidgetContainer(WidgetType tp) : NWidgetBase(tp) { } void AdjustPaddingForZoom() override; - void Add(NWidgetBase *wid); + void Add(std::unique_ptr &&wid); void FillWidgetLookup(WidgetLookup &widget_lookup) override; void Draw(const Window *w) override; @@ -631,10 +632,9 @@ public: */ class NWidgetBackground : public NWidgetCore { public: - NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, NWidgetPIPContainer *child = nullptr); - ~NWidgetBackground(); + NWidgetBackground(WidgetType tp, Colours colour, WidgetID index, std::unique_ptr &&child = nullptr); - void Add(NWidgetBase *nwid); + void Add(std::unique_ptr &&nwid); void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post); void SetPIPRatio(uint8_t pip_ratio_pre, uint8_t pip_ratio_inter, uint8_t pip_ratio_post); @@ -649,7 +649,7 @@ public: NWidgetBase *GetWidgetOfType(WidgetType tp) override; private: - NWidgetPIPContainer *child; ///< Child widget. + std::unique_ptr child; ///< Child widget. }; /** @@ -1029,7 +1029,7 @@ struct NWidgetPartAlignment { * Pointer to function returning a nested widget. * @return Nested widget (tree). */ -typedef NWidgetBase *NWidgetFunctionType(); +typedef std::unique_ptr NWidgetFunctionType(); /** * Partial widget specification to allow NWidgets to be written nested. @@ -1353,10 +1353,10 @@ static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr) } 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); +std::unique_ptr MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr &&container); +std::unique_ptr MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetStacked **shade_select); -NWidgetBase *MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip); +std::unique_ptr MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip); void SetupWidgetDimensions(); diff --git a/src/window.cpp b/src/window.cpp index ebe91b007b..8f99f252a4 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1088,7 +1088,6 @@ Window::~Window() assert(*this->z_position == nullptr); if (this->viewport != nullptr) DeleteWindowViewport(this); - delete this->nested_root; } /** diff --git a/src/window_gui.h b/src/window_gui.h index 49426c5000..b1bc06306c 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -259,7 +259,7 @@ public: ViewportData *viewport; ///< Pointer to viewport data, if present. const NWidgetCore *nested_focus; ///< Currently focused nested widget, or \c nullptr if no nested widget has focus. std::map querystrings; ///< QueryString associated to WWT_EDITBOX widgets. - NWidgetBase *nested_root; ///< Root of the nested tree. + std::unique_ptr nested_root; ///< Root of the nested tree. WidgetLookup widget_lookup; ///< Indexed access to the nested widget tree. Do not access directly, use #Window::GetWidget() instead. 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). From 934545a674b1ccb9a29d30e04d8a5d44c2eca45e Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 31 Dec 2023 15:47:32 +0000 Subject: [PATCH 22/29] Fix: Calculation of initial engine age was inaccurate. (#11660) Engine age in months was calculated as the difference in days / 32, instead of the actually difference in months. This would result in engines being artificially younger if a game was started at a later date. --- src/engine.cpp | 11 ++++++++--- src/engine_func.h | 2 +- src/saveload/oldloader_sl.cpp | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/engine.cpp b/src/engine.cpp index 80b8896cff..4f9b3b5da2 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -675,7 +675,7 @@ void SetYearEngineAgingStops() * @param aging_date The date used for age calculations. * @param seed Random seed. */ -void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32_t seed) +void StartupOneEngine(Engine *e, const TimerGameCalendar::YearMonthDay &aging_ymd, uint32_t seed) { const EngineInfo *ei = &e->info; @@ -699,7 +699,11 @@ void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32_t se * Note: TTDP uses fixed 1922 */ e->intro_date = ei->base_intro <= TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (TimerGameCalendar::Date)GB(r, 0, 9) + ei->base_intro; if (e->intro_date <= TimerGameCalendar::date) { - e->age = (aging_date - e->intro_date).base() >> 5; + TimerGameCalendar::YearMonthDay intro_ymd = TimerGameCalendar::ConvertDateToYMD(e->intro_date); + int aging_months = aging_ymd.year.base() * 12 + aging_ymd.month; + int intro_months = intro_ymd.year.base() * 12 + intro_ymd.month; + if (intro_ymd.day > 1) intro_months++; // Engines are introduced at the first month start at/after intro date. + e->age = aging_months - intro_months; e->company_avail = MAX_UVALUE(CompanyMask); e->flags |= ENGINE_AVAILABLE; } @@ -756,10 +760,11 @@ void StartupEngines() { /* Aging of vehicles stops, so account for that when starting late */ const TimerGameCalendar::Date aging_date = std::min(TimerGameCalendar::date, TimerGameCalendar::ConvertYMDToDate(_year_engine_aging_stops, 0, 1)); + TimerGameCalendar::YearMonthDay aging_ymd = TimerGameCalendar::ConvertDateToYMD(aging_date); uint32_t seed = Random(); for (Engine *e : Engine::Iterate()) { - StartupOneEngine(e, aging_date, seed); + StartupOneEngine(e, aging_ymd, seed); } for (Engine *e : Engine::Iterate()) { CalcEngineReliability(e, false); diff --git a/src/engine_func.h b/src/engine_func.h index 8036134c8e..533d13acfa 100644 --- a/src/engine_func.h +++ b/src/engine_func.h @@ -27,7 +27,7 @@ bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company); bool IsEngineRefittable(EngineID engine); void SetYearEngineAgingStops(); void CalcEngineReliability(Engine *e, bool new_month); -void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32_t seed); +void StartupOneEngine(Engine *e, const TimerGameCalendar::YearMonthDay &aging_ymd, uint32_t seed); uint GetTotalCapacityOfArticulatedParts(EngineID engine); diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 9668054b9d..9fd71b2017 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -399,6 +399,7 @@ static bool FixTTOEngines() } TimerGameCalendar::Date aging_date = std::min(TimerGameCalendar::date + CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameCalendar::ConvertYMDToDate(2050, 0, 1)); + TimerGameCalendar::YearMonthDay aging_ymd = TimerGameCalendar::ConvertDateToYMD(aging_date); for (EngineID i = 0; i < 256; i++) { int oi = ttd_to_tto[i]; @@ -407,7 +408,7 @@ static bool FixTTOEngines() if (oi == 255) { /* Default engine is used */ TimerGameCalendar::date += CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; - StartupOneEngine(e, aging_date, 0); + StartupOneEngine(e, aging_ymd, 0); CalcEngineReliability(e, false); e->intro_date -= CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; TimerGameCalendar::date -= CalendarTime::DAYS_TILL_ORIGINAL_BASE_YEAR; From 13348b7790b37e0ab4de28e33f5215db7148d908 Mon Sep 17 00:00:00 2001 From: translators Date: Sun, 31 Dec 2023 18:38:20 +0000 Subject: [PATCH 23/29] Update: Translations from eints galician: 13 changes by Xocko12 catalan: 47 changes by J0anJosep latvian: 14 changes by lexuslatvia french: 11 changes by ottdfevr portuguese: 52 changes by azulcosta --- src/lang/catalan.txt | 57 +++++++++++++++++++++++++++++------- src/lang/french.txt | 14 +++++++-- src/lang/galician.txt | 13 +++++++++ src/lang/latvian.txt | 26 +++++++++-------- src/lang/portuguese.txt | 64 +++++++++++++++++++++++++++++++++-------- 5 files changed, 137 insertions(+), 37 deletions(-) diff --git a/src/lang/catalan.txt b/src/lang/catalan.txt index 545bff89ab..6ea013392b 100644 --- a/src/lang/catalan.txt +++ b/src/lang/catalan.txt @@ -256,6 +256,9 @@ STR_UNITS_HEIGHT_IMPERIAL :{DECIMAL}{NBSP} STR_UNITS_HEIGHT_METRIC :{DECIMAL}{NBSP}m STR_UNITS_HEIGHT_SI :{G=Masculin}{DECIMAL}{NBSP}m +STR_UNITS_DAYS :{COMMA}{NBSP}di{P a es} +STR_UNITS_SECONDS :{COMMA}{NBSP}segon{P "" s} +STR_UNITS_TICKS :{COMMA}{NBSP}tic{P "" s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filtre: @@ -720,6 +723,7 @@ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Clica la STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Clica la pista de música per treure-la de la llista actual (només en llistes personalitzables) # Highscore window +STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}Millors companyies STR_HIGHSCORE_POSITION :{BIG_FONT}{BLACK}{COMMA}. STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN :Empresari STR_HIGHSCORE_PERFORMANCE_TITLE_ENTREPRENEUR :Emprenedor @@ -1488,7 +1492,7 @@ STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL :Original STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS :TerraGenesis STR_CONFIG_SETTING_TERRAIN_TYPE :Tipus de terreny: {STRING} -STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :(Només TerraGenesis) Escollir el tipus de terreny: des de molt pla fins a escarpat +STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :Escolliu l'altura dels turons i muntanyes del paisatge. STR_CONFIG_SETTING_INDUSTRY_DENSITY :Densitat d'indústries: {STRING} STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :Fixa el nombre d'indústries que s'haurien de generar i mantenir durant la partida @@ -1497,18 +1501,18 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Distància màx STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Limita a quina distància del mapa es poden construir refineries de petroli i plataformes petrolíferes. En mapes amb illes, serveix per assegurar que estan prop de la costa. En mapes de més de 256 caselles, aquest valor s'escala automàticament. STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Alçada dels estatges amb neu: {STRING} -STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Controla a partir de quina alçada apareix la neu en el paisatge subàrtic. La neu també afecta la generació d'indústries i els requisits per al creixement de les poblacions. Només es pot modificar a l'editor d'escenaris; altrament, es calcula fent servir la proporció de terreny nevat. +STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Tria a quina altura comença a aparèixer neu al paisatge subàrtic. La neu també afecta a la generació d'indústries i els requisits per al creixement de les poblacions. Només es pot modificar a l'editor d'escenaris; altrament, es calcula fent servir la proporció de terreny nevat. STR_CONFIG_SETTING_SNOW_COVERAGE :Terreny nevat: {STRING} -STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Controla la quantitat aproximada de terreny nevat que hi ha en els paisatges subàrtics. La neu afecta a la generació d'indústries i el creixement de les poblacions. Només s'usa durant la generació de mapes. El terreny d'alçada propera al nivell del mar mai està nevat. +STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Escolliu la quantitat aproximada de neu als paisatges subàrtics. La neu també afecta a la generació d'indústries i els requisits per al creixement de les poblacions. Només es fa servir durant la generació de mapes. A nivell de mar i a les caselles costeres mai hi haurà neu. STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}{NBSP}% STR_CONFIG_SETTING_DESERT_COVERAGE :Terreny desèrtic: {STRING} -STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Controla la quantitat aproximada de terreny desèrtic que hi ha en els paisatges tropicals. Els deserts afecten a la generació d'indústries. Només s'usa durant la generació de mapes. +STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Escolliu la quantitat aproximada de desert dels paisatges tropicals. El desert afecta a la generació d'indústries i els requisits de creixement de les poblacions. Només es fa servir durant la generació de mapes. STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE :{NUM}{NBSP}% STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Geografia del terreny: {STRING} -STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(Només TerraGenesis) Escollir la suavitat del paisatge: els terrenys suaus tenen menys turons i són regulars; els terrenys més rugosos són irregulars i tenen molts turons +STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :Trieu la forma i quantitat de turons. Els terrenys més suaus tenen menys turons i són més amples, mentre que els terrenys més irregulars tenen més turons i són més petits. ###length 4 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :Molt suau STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH :Suau @@ -1516,7 +1520,7 @@ STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH :Escarpat STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH :Molt escarpat STR_CONFIG_SETTING_VARIETY :Varietat: {STRING} -STR_CONFIG_SETTING_VARIETY_HELPTEXT :(Només TerraGenesis) Controla la varietat en la distribució de les zones muntanyoses i planes. Aquesta opció controla la distribució d'aquestes zones; si es vol modificar si el terreny és més o menys muntanyós s'han de modificar altres opcions +STR_CONFIG_SETTING_VARIETY_HELPTEXT :Trieu si el mapa ha de contenir muntanyes o àrees planes. Com més varietat, més diferències hi haurà entre l'elevació de les àrees muntanyoses i planes. STR_CONFIG_SETTING_RIVER_AMOUNT :Quantitat de rius: {STRING} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Escollir la quantitat de rius a generar @@ -1536,6 +1540,7 @@ STR_CONFIG_SETTING_ROAD_SIDE_LEFT :Conducció per STR_CONFIG_SETTING_ROAD_SIDE_RIGHT :Conducció per la dreta STR_CONFIG_SETTING_HEIGHTMAP_ROTATION :Rotació del mapa d'alçades: {STRING} +STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP :Escolliu de quina manera s'ha de rotar el mapa d'alçades per a encaixar-lo al món de la partida. ###length 2 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE :Antihorari STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE :Horari @@ -1656,7 +1661,12 @@ STR_CONFIG_SETTING_ADVANCED_VEHICLE_LISTS_HELPTEXT :Activa la utili STR_CONFIG_SETTING_LOADING_INDICATORS :Utilitza indicadors de càrrega: {STRING} STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Selecciona si els indicadors de càrrega seran mostrats sobre els vehicles en càrrega o descàrrega +STR_CONFIG_SETTING_TIMETABLE_MODE :Unitats de temps per als horaris: {STRING} +STR_CONFIG_SETTING_TIMETABLE_MODE_HELPTEXT :Seleccioneu les unitats de temps que es faran servir per als horaris. ###length 3 +STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Dies +STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Segons +STR_CONFIG_SETTING_TIMETABLE_MODE_TICKS :Tics STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Mostra l'arribada i la sortida als horaris: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Mostra als horaris l'arribada anticipadament i les hores de sortida @@ -2187,12 +2197,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Mostra e STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Mostra els esquemes de colors dels automòbils STR_LIVERY_SHIP_TOOLTIP :{BLACK}Mostra els esquemes de colors dels vaixells STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Mostra esquemes de colors dels avions +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Mostra els colors dels grups de trens. +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Mostra els colors dels grups de vehicles de carretera. +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Mostra els colors dels grups de vaixells. +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Mostra els colors dels grups d'aeronaus STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Escolleix el color primari per l'esquema triat. Ctr+Click establirà el color per a cada esquema STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Escolleix el color secundari per l'esquema triat. Ctrl+Click establirà el color per a cada esquema STR_LIVERY_PANEL_TOOLTIP :{BLACK}Selecciona un esquema de colors per canviar-lo, o diversos esquemes amb CTRL+Clic. Clica a la casella per canviar l'esquema +STR_LIVERY_TRAIN_GROUP_EMPTY :No hi ha grups de trens establerts +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :No hi ha grups de vehicles de carretera establerts +STR_LIVERY_SHIP_GROUP_EMPTY :No hi ha grups de vaixells establerts +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :No hi ha grups d'aeronaus establerts ###length 23 -STR_LIVERY_DEFAULT :Decoració estàndard +STR_LIVERY_DEFAULT :Decoració per defecte STR_LIVERY_STEAM :Locomotora a Vapor STR_LIVERY_DIESEL :Locomotora Dièsel STR_LIVERY_ELECTRIC :Locomotora Elèctrica @@ -2345,7 +2363,7 @@ STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP :{BLACK}El nom d STR_NETWORK_START_SERVER_SET_PASSWORD :{BLACK}Posa una contrasenya STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP :{BLACK}Protegeix la teva partida amb una contrasenya si no vols que sigui accessible a desconeguts -STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Visibilitat +STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Visibilitat: STR_NETWORK_START_SERVER_VISIBILITY_TOOLTIP :{BLACK}Permet establir si altres persones poden veure el vostre servidor a la llista pública. STR_NETWORK_START_SERVER_CLIENTS_SELECT :{BLACK}{NUM} client{P "" s} STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS :{BLACK}Màxim nombre de clients: @@ -3200,11 +3218,15 @@ STR_MAPGEN_MAPSIZE :{BLACK}Mida del STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}Selecciona la mida del mapa en cel·les. El nombre de cel·les disponibles serà lleugerament més petit STR_MAPGEN_BY :{BLACK}* STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Nombre de poblacions: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :{BLACK}Trieu la densitat de les poblacions o un nombre personalitzat. STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}Estil dels noms de les poblacions: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}Selecciona l'estil dels noms de poblacions STR_MAPGEN_DATE :{BLACK}Data: +STR_MAPGEN_DATE_TOOLTIP :{BLACK}Trieu la data d'inici. STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}Nombre d'indústries: +STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP :{BLACK}Trieu la densitat de les indústries o un nombre personalitzat. STR_MAPGEN_HEIGHTMAP_HEIGHT :{BLACK}Alçada del cim més alt: +STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}Trieu l'altura del cim més alt que el joc mirarà de crear, mesurat respecte el nivell de mar. STR_MAPGEN_HEIGHTMAP_HEIGHT_UP :{BLACK}Augmenta l'alçada màxima o l'alçada màxima dels cims en una unitat STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN :{BLACK}Redueix l'alçada màxima o l'alçada màxima dels cims en una unitat STR_MAPGEN_SNOW_COVERAGE :{BLACK}Proporció de terreny nevat: @@ -3217,10 +3239,12 @@ STR_MAPGEN_DESERT_COVERAGE_DOWN :{BLACK}Redueix STR_MAPGEN_DESERT_COVERAGE_TEXT :{BLACK}{NUM}{NBSP}% STR_MAPGEN_TERRAIN_TYPE :{BLACK}Tipus de terreny: STR_MAPGEN_SEA_LEVEL :{BLACK}Nivell de mar: +STR_MAPGEN_SEA_LEVEL_TOOLTIP :{BLACK}Seleccioneu el nivell de la mar STR_MAPGEN_QUANTITY_OF_RIVERS :{BLACK}Quantitat de rius: STR_MAPGEN_SMOOTHNESS :{BLACK}Suavitat: STR_MAPGEN_VARIETY :{BLACK}Varietat: STR_MAPGEN_GENERATE :{WHITE}Genera +STR_MAPGEN_GENERATE_TOOLTIP :{BLACK}Creeu el món i jugueu a l'OpenTTD! STR_MAPGEN_NEWGRF_SETTINGS :{BLACK}Configuració del NewGRF STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP :{BLACK}Mostra la configuració de NewGRF STR_MAPGEN_AI_SETTINGS :{BLACK}Configuració d'IA @@ -3253,6 +3277,7 @@ STR_MAPGEN_TOWN_NAME_CATALAN :Català # Strings for map borders at game generation STR_MAPGEN_BORDER_TYPE :{BLACK}Vores del mapa: +STR_MAPGEN_BORDER_TYPE_TOOLTIP :{BLACK}Escolliu les vores del món de la partida. STR_MAPGEN_NORTHWEST :{BLACK}Nord-oest STR_MAPGEN_NORTHEAST :{BLACK}Nord-est STR_MAPGEN_SOUTHEAST :{BLACK}Sud-est @@ -3265,7 +3290,9 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}Manual STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}Rotació del mapa d'alçades: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Nom del mapa d'alçades: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :{BLACK}El nom del fitxer imatge del mapa d'alçades STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Mida: +STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP :{BLACK}La mida de la imatge d'origen del mapa d'alçades. Per a obtenir bons resultats, cada costat hauria de coincidir amb una mida disponible de l'OpenTTD, com ara 256, 512 o 1024. STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}Alçada desitjada dels cims @@ -3280,6 +3307,7 @@ STR_SE_MAPGEN_FLAT_WORLD :{WHITE}Terreny STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP :{BLACK}Generar un terreny pla STR_SE_MAPGEN_RANDOM_LAND :{WHITE}Terreny aleatori STR_SE_MAPGEN_FLAT_WORLD_HEIGHT :{BLACK}Alçada del terreny pla: +STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP :{BLACK}Trieu l'altura de la terra per damunt del nivell de la mar. STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN :{BLACK}Mou l'alçada del terreny pla un pas avall STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP :{BLACK}Mou l'alçada del terreny pla un pas amunt @@ -4573,8 +4601,13 @@ STR_TIMETABLE_STATUS_ON_TIME :{BLACK}Actualme STR_TIMETABLE_STATUS_LATE :{BLACK}Actualment aquest vehicle va {STRING} tard STR_TIMETABLE_STATUS_EARLY :{BLACK}Actualment aquest vehicle va {STRING} d'hora STR_TIMETABLE_STATUS_NOT_STARTED :{BLACK}Aquest horari encara no ha començat +STR_TIMETABLE_STATUS_START_AT_DATE :{BLACK}Aquest horari començarà a {STRING} +STR_TIMETABLE_STATUS_START_IN_SECONDS :{BLACK}Aquest horari començarà en {COMMA}{NBSP}segons +STR_TIMETABLE_START :{BLACK}Comença l'horari +STR_TIMETABLE_START_TOOLTIP :{BLACK}Trieu quan ha de començar l'horari. Amb Ctrl+clic es distribuirà l'inici de tots els vehicles que comparteixen les ordres segons el seu ordre relatiu, si s'ha establert completament l'horari. +STR_TIMETABLE_START_SECONDS_QUERY :Segons fins que comenci l'horari STR_TIMETABLE_CHANGE_TIME :{BLACK}Canvia Temps STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Canvia el emps que l'ordre marcada hauria de prendre. Amb Ctrl+clic estableix el temps per a totes les ordres. @@ -4598,6 +4631,10 @@ STR_TIMETABLE_EXPECTED :{BLACK}Esperat STR_TIMETABLE_SCHEDULED :{BLACK}Planificat STR_TIMETABLE_EXPECTED_TOOLTIP :{BLACK}Canvia entre esperat i planificat +STR_TIMETABLE_ARRIVAL_DATE :A: {COLOUR}{DATE_TINY} +STR_TIMETABLE_DEPARTURE_DATE :S: {COLOUR}{DATE_TINY} +STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE :A: {COLOUR}{COMMA}{NBSP}s +STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE :S: {COLOUR}{COMMA}{NBSP}s # Date window (for timetable) @@ -4625,9 +4662,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Distinge STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Commuta la distinció entre majúscules i minúscules quan es comparin els missatges de registre d'IA amb la cadena de parada. STR_AI_DEBUG_CONTINUE :{BLACK}Continua STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Reprèn i continua l'execució de la IA. -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Mostra la sortida de depuració d'aquesta IA. +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Mostra la sortida de depuració d'aquesta IA. Feu Ctrl+clic per a mostrar-la en una finestra nova. STR_AI_GAME_SCRIPT :{BLACK}Script de partida -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Mostra el registre de l'script de partida. +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Mostra el registre de l'script de partida. Feu Ctrl+clic per a obrir-lo en una finestra nova. STR_ERROR_AI_NO_AI_FOUND :No s'ha trobat una IA adequada per carregar.{}Aquesta IA és una IA que no fa res.{}Podeu descarregar diverses IA via el sistema de «Contingut en línia». STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Un dels scripts que s'executava ha fallat. Si us plau, informeu l'autor de l'script amb una captura de pantalla de la finestra de depuració de l'script d'IA/partida. diff --git a/src/lang/french.txt b/src/lang/french.txt index 18444b3d74..19dded592e 100644 --- a/src/lang/french.txt +++ b/src/lang/french.txt @@ -2197,12 +2197,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Montrer STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Montrer les livrées de véhicules routiers STR_LIVERY_SHIP_TOOLTIP :{BLACK}Montrer les livrées de navires STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Montrer les livrées d'aéronefs +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Afficher les couleurs des groupes de trains +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Afficher les couleurs des groupes de véhicules +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Afficher les couleurs des groupes de bateaux +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Afficher les couleurs des groupes d'avions STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Choisir la couleur primaire de la livrée sélectionnée. Ctrl-clic appliquera cette couleur à toutes les livrées. STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Choisir la couleur secondaire de la livrée sélectionnée. Ctrl-clic appliquera cette couleur à toutes les livrées. STR_LIVERY_PANEL_TOOLTIP :{BLACK}Sélectionner la livrée à modifier ou plusieurs d'entre elles par Ctrl-clic. Cliquer sur la case à cocher pour en activer l'utilisation ou non. +STR_LIVERY_TRAIN_GROUP_EMPTY :Aucun groupe de trains +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Aucun groupe de véhicules +STR_LIVERY_SHIP_GROUP_EMPTY :Aucun groupe de bateaux +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Aucun groupe d'avions ###length 23 -STR_LIVERY_DEFAULT :Livrée standard +STR_LIVERY_DEFAULT :Livrée par défaut STR_LIVERY_STEAM :Locomotive à vapeur STR_LIVERY_DIESEL :Locomotive Diesel STR_LIVERY_ELECTRIC :Locomotive électrique @@ -4654,9 +4662,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Respecte STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Activer/Désactiver le respect de la casse pour comparer les messages d'IA avec la chaîne d'arrêt STR_AI_DEBUG_CONTINUE :{BLACK}Continuer STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Reprendre la partie et continuer l'IA -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Afficher la sortie de débogage de cette IA +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Afficher la sortie de débogage de cette IA. Ctrl+Click pour ouvrir dans une nouvelle fenêtre STR_AI_GAME_SCRIPT :{BLACK}Script de jeu -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Examiner le journal du script de jeu +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Examiner le journal du script de jeu. Ctrl+Click pour ouvrir dans une nouvelle fenêtre STR_ERROR_AI_NO_AI_FOUND :Aucune IA n'a été trouvée.{}Cette IA est factice et ne fera rien.{}Vous pouvez télécharger diverses IA via le système de «{NBSP}Contenu en ligne{NBSP}». STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}L'un des scripts a rencontré un problème. Merci de rapporter ceci à l'auteur du script avec une capture d'écran de la fenêtre de débogage de scripts. diff --git a/src/lang/galician.txt b/src/lang/galician.txt index 57b61945f1..a3e5aa123f 100644 --- a/src/lang/galician.txt +++ b/src/lang/galician.txt @@ -256,6 +256,7 @@ STR_UNITS_HEIGHT_IMPERIAL :{DECIMAL} pés STR_UNITS_HEIGHT_METRIC :{DECIMAL} m STR_UNITS_HEIGHT_SI :{DECIMAL} m +STR_UNITS_TICKS :{COMMA}{NBSP}tick{P "" s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filtrar: @@ -1657,6 +1658,8 @@ STR_CONFIG_SETTING_LOADING_INDICATORS :Usar indicadore STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Escolle se os indicadores de carga se amosan sobre os vehículos en carga/descarga ###length 3 +STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Días +STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Segundos STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Mostrar chegada e saída nos horarios: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Amosar chegadas e saídas anticipadas nos horarios @@ -2187,9 +2190,14 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Mostra-l STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Mostra-los esquemas de cor dos vehículos de estrada STR_LIVERY_SHIP_TOOLTIP :{BLACK}Mostra-los esquemas de cor dos barcos STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Mostra-los esquemas de cor das aeronaves +STR_LIVERY_TRAIN_GROUP_TOOLTIP :Amosa as cores dos grupos de trens +STR_LIVERY_SHIP_GROUP_TOOLTIP :Amosa as cores dos grupos de barcos STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Elixe a cor primaria para o esquema seleccionado. Ctrl+Click aplicará esta cor a tódolos esquemas STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Elixe a cor secundaria para o esquema seleccionado. Ctrl+Click aplicará esta cor a tódolos esquemas STR_LIVERY_PANEL_TOOLTIP :{BLACK}Selecciona un esquema de cor para cambialo, ou múltiples esquemas con CTRL+click. Pincha na caixa para cambia lo uso do esquema +STR_LIVERY_TRAIN_GROUP_EMPTY :Non se creou ningún grupo de trens +STR_LIVERY_SHIP_GROUP_EMPTY :Non se creou ningún grupo de barcos +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Non se crearon grupos de aeronaves ###length 23 STR_LIVERY_DEFAULT :Esquemas de cor estándar @@ -3200,6 +3208,7 @@ STR_MAPGEN_MAPSIZE :{BLACK}Tamaño STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK} Selecciona o tamaño do mapa en cadros. O número de cadros dispoñíbeis será sensiblemente menor STR_MAPGEN_BY :{BLACK}* STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Nº de cidades: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :Selecciona a densidade das cidades ou un número á túa escolla STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}Nomes das localidades: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}Selecciona o estilo dos nomes das cidades STR_MAPGEN_DATE :{BLACK}Data: @@ -3265,6 +3274,7 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}Manual STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}Rotación do mapa de alturas: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Nome do mapa de alturas: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :O nome do arquivo de imaxe do mapa de alturas. STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Tamaño: STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} @@ -4573,8 +4583,11 @@ STR_TIMETABLE_STATUS_ON_TIME :{BLACK}Este veh STR_TIMETABLE_STATUS_LATE :{BLACK}Este vehículo está retrasado {STRING} STR_TIMETABLE_STATUS_EARLY :{BLACK}Este vehículo vai adiantado {STRING} STR_TIMETABLE_STATUS_NOT_STARTED :{BLACK}Este horario aínda non comezóu +STR_TIMETABLE_STATUS_START_AT_DATE :{BLACK}Este horario comezará no seguinte horario{STRING} +STR_TIMETABLE_START :Empezar táboa de horarios +STR_TIMETABLE_START_SECONDS_QUERY :Segundos até empezar a táboa de horarios STR_TIMETABLE_CHANGE_TIME :{BLACK}Cambiar Tempo STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Cambiar o tempo que debería levar a orde seleccionada. Ctrl+Click cambia o tempo para todas as ordes diff --git a/src/lang/latvian.txt b/src/lang/latvian.txt index 4d4c04f8bc..9d58818a3e 100644 --- a/src/lang/latvian.txt +++ b/src/lang/latvian.txt @@ -1071,7 +1071,7 @@ STR_GAME_OPTIONS_BASE_GRF_TOOLTIP :{BLACK}Atlasiet STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP :{BLACK}Papildinformācija par pamata grafikas kopu STR_GAME_OPTIONS_BASE_SFX :{BLACK}Pamata skaņas kopa -STR_GAME_OPTIONS_BASE_SFX_TOOLTIP :{BLACK}Atlasīt lietošanai pamata skaņas kopu +STR_GAME_OPTIONS_BASE_SFX_TOOLTIP :{BLACK}Atlasiet izmantojamās pamata skaņas (nevar mainīt spēlē, tikai galvenajā izvēlnē) STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP :{BLACK}Papildinformācija par pamata skaņas kopu STR_GAME_OPTIONS_BASE_MUSIC :{BLACK}Pamata mūzikas kopa @@ -1301,7 +1301,7 @@ STR_CONFIG_SETTING_CATCHMENT :Atļaut realist STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :Atšķirīga lieluma apkalpojamās platības dažādu veidu stacijām un lidostām STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES :Uzņēmumu stacijas var apkalpot industrijas, kurām ir pievienotas neitrālas stacijas: {STRING} -STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :Ja ieslēgts, industrijas ar pievienotām stacijām (piemēram, naftas ieguves platformas) var apkalpot arī netālu esošās uzņēmumumam piederošās stacijas. Ja izslēgts, šīs industrijas var apkalpot tikai to pašu stacijas. Tuvumā esošās uzņēmumu stacijas nevarēs tās apkalpot, un pievienotās stacijas neapkalpos preču veidus, kas nav atbilstošas attiecīgajai industrijai. +STR_CONFIG_SETTING_SERVE_NEUTRAL_INDUSTRIES_HELPTEXT :Kad ieslēgts, nozares ar pievienotajām stacijām (piemēram, naftas ieguves platformām) var apkalpot arī uzņēmumam piederošas stacijas, kas uzbūvētas tuvumā. Ja tas ir atspējots, šīs nozares var apkalpot tikai tām pievienotās stacijas. Nevienas tuvumā esošās uzņēmuma stacijas nevarēs tos apkalpot, kā arī pievienotā stacija apkalpos neko citu kā tikai nozari STR_CONFIG_SETTING_EXTRADYNAMITE :Atļaut pilsētai piederošo ceļu, tiltu un tuneļu nojaukšanu: {STRING} STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :Padara vieglāku pilsētai piederošas infrastruktūras un ēku nojaukšanu @@ -1576,7 +1576,7 @@ STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREY_TO_RED :Pelēks uz sark STR_CONFIG_SETTING_LINKGRAPH_COLOURS_GREYSCALE :Pelēktonis STR_CONFIG_SETTING_SCROLLMODE :Skatvietas ritināšanas uzvedība: {STRING} -STR_CONFIG_SETTING_SCROLLMODE_HELPTEXT :Uzvedība, kad ritina karti +STR_CONFIG_SETTING_SCROLLMODE_HELPTEXT :Uzvedība, ritinot karti. Opcijas “peles pozīcija bloķēta” nedarbojas visās sistēmās, piemēram, tīmekļa versijās, skārienekrānos, Linux ar Wayland un citās ###length 4 STR_CONFIG_SETTING_SCROLLMODE_DEFAULT :Pārvietot skatvietu ar labo peles pogu, peles pozīcija ir fiksēta STR_CONFIG_SETTING_SCROLLMODE_RMB_LOCKED :Pārvietot karti ar labo peles pogu, peles pozīcija ir fiksēta @@ -1893,7 +1893,7 @@ STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS :Pilsētam ir at STR_CONFIG_SETTING_ALLOW_TOWN_LEVEL_CROSSINGS_HELPTEXT :Šā iestatījuma ieslēgšana pilsētām atļauj būvēt vienlīmeņa krustojumus STR_CONFIG_SETTING_NOISE_LEVEL :Lidostas izvietojuma ierobežojums, pamatojoties uz trokšņa līmeni: {STRING} -STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :Ja šis iestatījums ir izslēgts, tad katrā pilsētā var būt divas lidostas. Ja šis iestatījums ir ieslēgts, tad lidostu daudzums pilsētā ir ierobežots ar pilsētas piekrišanu troksnim, kas ir atkarīga no iedzīvotāju skaita, lidostas lieluma un attāluma +STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT :Ļaujiet pilsētām bloķēt lidostu būvniecību, pamatojoties uz to trokšņa pieļaujamo līmeni, kas ir balstīts uz pilsētas iedzīvotāju skaitu un lidostas lielumu un attālumu. Ja šis iestatījums ir izslēgts, pilsētās tiek atļautas tikai divas lidostas, ja vien vietējās iestādes attieksme nav "Atļaujoša" STR_CONFIG_SETTING_TOWN_FOUNDING :Pilsētu dibināšana: {STRING} STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT :Šā iestatījuma ieslēgšana atļauj spēlētājiem spēlē nodibināt jaunas pilsētas @@ -2432,6 +2432,7 @@ STR_NETWORK_CLIENT_LIST_NEW_COMPANY :(Jauna kompāni STR_NETWORK_CLIENT_LIST_NEW_COMPANY_TOOLTIP :{BLACK}Izveidot jaunu kompāniju un pievienoties tai STR_NETWORK_CLIENT_LIST_PLAYER_ICON_SELF_TOOLTIP :{BLACK}Tas esat jūs STR_NETWORK_CLIENT_LIST_PLAYER_ICON_HOST_TOOLTIP :{BLACK}Šis ir spēles īpašnieks +STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT :{BLACK}Klientu: {NUM}; uzņēmumu: {NUM}/{NUM} STR_NETWORK_CLIENT_LIST_CLIENT_COMPANY_COUNT_TOOLTIP :{BLACK}Pašlaik savienoto klientu skaits, uzņēmumu skaits un maksimālais servera administratora atļautais uzņēmumu skaits # Matches ConnectionType @@ -2908,7 +2909,7 @@ STR_OBJECT_CLASS_TRNS :Raidītāji STR_PLANT_TREE_CAPTION :{WHITE}Koki STR_PLANT_TREE_TOOLTIP :{BLACK}Izvēlēties koka veidu stādīšanai. Ja lauciņš jau ir koks, tas pievienos vairāk jauktu veidu kokus neatkarīgi no izvēlētā veida STR_TREES_RANDOM_TYPE :{BLACK}Nejauši izvēlēta veida koki -STR_TREES_RANDOM_TYPE_TOOLTIP :{BLACK}Izvietot nejaušus kokus. Shift pārslēdz būve/rādīt izmaksu tāmi +STR_TREES_RANDOM_TYPE_TOOLTIP :{BLACK}Novietojiet jaukta veida kokus. Ctrl atlasa apgabalu pa diagonāli. Shift pārslēdz celtniecību/rāda izmaksas STR_TREES_RANDOM_TREES_BUTTON :{BLACK}Nejauši koki STR_TREES_RANDOM_TREES_TOOLTIP :{BLACK}Stādīt nejaušus kokus visā ainavā STR_TREES_MODE_NORMAL_BUTTON :{BLACK}Normāls @@ -2983,8 +2984,8 @@ STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_CAPTION :{WHITE} Noņemt STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_QUERY :{YELLOW}Vai tiešām vēlaties noņemt visas nozares? # Industry cargoes window -STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION :{WHITE}Ražotnes '{STRING}' kravu ķēde -STR_INDUSTRY_CARGOES_CARGO_CAPTION :{WHITE}{STRING} kravas ražotņu ķēde +STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION :{WHITE}Nozares ķēde - {STRING} +STR_INDUSTRY_CARGOES_CARGO_CAPTION :{WHITE}Kravas ķēde - {STRING} STR_INDUSTRY_CARGOES_PRODUCERS :{WHITE}Ražotāji STR_INDUSTRY_CARGOES_CUSTOMERS :{WHITE}Patērētāji STR_INDUSTRY_CARGOES_HOUSES :{WHITE}Mājas @@ -3450,6 +3451,7 @@ STR_NEWGRF_ERROR_MSG_WARNING :{RED}Brīdināj STR_NEWGRF_ERROR_MSG_ERROR :{RED}Kļūda: {SILVER}{STRING} STR_NEWGRF_ERROR_MSG_FATAL :{RED}Fatāls: {SILVER}{STRING} STR_NEWGRF_ERROR_FATAL_POPUP :{WHITE}NewGRF "{STRING}" apstrādājas dēl neatgrieziniskās kļūdas:{}{STRING} +STR_NEWGRF_ERROR_POPUP :{WHITE}NewGRF "{STRING}"uzrāda kļūdu:{}{STRING} STR_NEWGRF_ERROR_VERSION_NUMBER :{1:STRING} nedarbosies kopā ar TTDPatch versiju (par ko ziņoja OpenTTD). STR_NEWGRF_ERROR_DOS_OR_WINDOWS :{1:STRING} ir paredzēts TTD versijai {2:STRING} STR_NEWGRF_ERROR_UNSET_SWITCH :{1:STRING} ir paredzēts lietošanai ar {2:STRING} @@ -3923,7 +3925,7 @@ STR_VEHICLE_LIST_NAME_AND_CARGO :{STRING} {STRIN STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT :Nosūtīt uz depo STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT :Nosūtīt uz depo STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT :Nosūtīt uz depo -STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR :Sūtīt uz angāru +STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR :Nosūtīt uz angāru STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP :{BLACK}Klikšķināt, lai apstādinātu visas mašīnas, kas ir sarakstā STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP :{BLACK}Klikšķināt, lai iedarbinātu visas mašīnas, kas ir saraks @@ -4630,7 +4632,7 @@ STR_TIMETABLE_CLEAR_SPEED :{BLACK}Nodzēst STR_TIMETABLE_CLEAR_SPEED_TOOLTIP :{BLACK}Dzēst iezīmētā pasūtījuma maksimālo braukšanas ātrumu. Ctrl+klikšķis notīra ātrumu visiem pasūtījumiem STR_TIMETABLE_RESET_LATENESS :{BLACK}Atiestatīt kavējuma skaitītāju -STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Atslēgt skaitītāju, lai transportlīdzeklis būtu laikā +STR_TIMETABLE_RESET_LATENESS_TOOLTIP :{BLACK}Atiestatiet kavējuma skaitītāju, lai transportlīdzeklis būtu laikā. Nospiežot taustiņu kombināciju Ctrl+klikšķis, tiks atiestatīta visa grupa, lai jaunākais transportlīdzeklis būtu laicīgi un visi pārējie ātrāk STR_TIMETABLE_AUTOFILL :{BLACK}Automātiska aizpildīšana STR_TIMETABLE_AUTOFILL_TOOLTIP :{BLACK}Automātiski aizpildiet kustības grafiku ar vērtībām no nākamā brauciena. Ctrl+noklikšķiniet, lai mēģinātu saglabāt gaidīšanas laiku @@ -4670,7 +4672,7 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Ievērot STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Pārslēgt lielo/mazo burtu ievērošanu, kad salīdzināt MI ziņojumus ar slēgšanas tekstu STR_AI_DEBUG_CONTINUE :{BLACK}Turpināt STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Atsākt un turpināt šo MI -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Attēlot šī MI atkļūdošanas izvadu +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Skatīt šī AI atkļūdošanas izeju. Ctrl-klikšķis, lai atvērtu jaunā logā STR_AI_GAME_SCRIPT :{BLACK}Spēles skripts STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Pārbaudiet spēles skripta žurnālu. Ctrl-klikšķis, lai atvērtu jaunā logā @@ -4700,7 +4702,7 @@ STR_AI_CONFIG_GAMESCRIPT_PARAM :{SILVER}Paramet STR_AI_CONFIG_AI :{SILVER}MI STR_AI_CONFIG_CHANGE_AI :{BLACK}Izvēlēties MI -STR_AI_CONFIG_CHANGE_GAMESCRIPT :{BLACK}Atlasiet spēles skriptu +STR_AI_CONFIG_CHANGE_GAMESCRIPT :{BLACK}Izvētaties spēles skriptu STR_AI_CONFIG_CHANGE_TOOLTIP :{BLACK}Ielādēt citu skriptu. Ctrl+klikšķis, lai parādītu visas pieejamās versijas STR_AI_CONFIG_CONFIGURE :{BLACK}Konfigurēt STR_AI_CONFIG_CONFIGURE_TOOLTIP :{BLACK}Konfigurēt skripta parametrus @@ -4730,7 +4732,7 @@ STR_SCREENSHOT_MINIMAP_SCREENSHOT :{BLACK}Minikart # Script Parameters STR_AI_SETTINGS_CAPTION :{WHITE}{STRING} Iestatījumi -STR_AI_SETTINGS_CAPTION_AI :{WHITE}MI Parametri +STR_AI_SETTINGS_CAPTION_AI :AI STR_AI_SETTINGS_CAPTION_GAMESCRIPT :Spēles skripts STR_AI_SETTINGS_CLOSE :{BLACK}Aizvērt STR_AI_SETTINGS_RESET :{BLACK}Atiestatīt diff --git a/src/lang/portuguese.txt b/src/lang/portuguese.txt index f48132918e..936f9e80d9 100644 --- a/src/lang/portuguese.txt +++ b/src/lang/portuguese.txt @@ -256,6 +256,9 @@ STR_UNITS_HEIGHT_IMPERIAL :{DECIMAL} pé(s STR_UNITS_HEIGHT_METRIC :{DECIMAL} m STR_UNITS_HEIGHT_SI :{DECIMAL} m +STR_UNITS_DAYS :{COMMA}{NBSP}dia{P "" s} +STR_UNITS_SECONDS :{COMMA}{NBSP}segundo{P "" s} +STR_UNITS_TICKS :{COMMA}{NBSP}tique{P "" s} # Common window strings STR_LIST_FILTER_TITLE :{BLACK}Filtro: @@ -720,6 +723,7 @@ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Clique n STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Faça clique numa faixa para a remover da lista (Personaliz. 1 ou Personaliz. 2 apenas) # Highscore window +STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}Melhores empresas STR_HIGHSCORE_POSITION :{BIG_FONT}{BLACK}{COMMA}. STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN :Negociante STR_HIGHSCORE_PERFORMANCE_TITLE_ENTREPRENEUR :Empresário @@ -1488,7 +1492,7 @@ STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL :Original STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS :TerraGenesis STR_CONFIG_SETTING_TERRAIN_TYPE :Tipo de terreno: {STRING} -STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :(Apenas TerraGenesis) Relevo do terreno +STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :Escolher a altura das colinas e montanhas da paisagem STR_CONFIG_SETTING_INDUSTRY_DENSITY :Densidade industrial: {STRING} STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :Define quantas indústrias devem ser geradas e que nível deve ser mantido durante o jogo @@ -1497,18 +1501,18 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Distância máx STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Refinarias de petróleo são construídas apenas próximo da borda do mapa, isto é, na costa para mapas de ilha STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Altura da linha de neve: {STRING} -STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Controla a que altura começa a neve no clima sub-ártico. A neve também afeta a geração de indústrias e os requisitos de crescimento das localidades. Só pode ser modificado no Editor de Cenário ou então é calculado por via da "cobertura de neve" +STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Escolher a que altura a neve começa na paisagem subártica. A neve também afeta a geração de indústrias e os requisitos de crescimento das localidades. Só pode ser modificado através do Editor de Cenários ou é calculado através da "cobertura de neve" STR_CONFIG_SETTING_SNOW_COVERAGE :Cobertura de neve: {STRING} -STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Controla a quantidade aproximada de neve no clima sub-ártico. A neve também afeta a geração das indústrias e os requisitos de crescimento das localidades. Usado apenas durante a geração do mapa. A terra logo acima do nível do mar está sempre sem neve +STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Escolher a quantidade aproximada de neve no clima subártico. A neve também afeta a geração de indústrias e os requisitos de crescimento das localidades. Usado apenas durante a geração do mapa. O nível do mar e as suas encostas nunca têm neve. STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_DESERT_COVERAGE :Cobertura do deserto: {STRING} -STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Controla a quantidade aproximada de deserto no clima tropical. O deserto também afeta a geração das indústrias. Usado apenas durante a geração do mapa +STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :Escolher a quantidade aproximada de deserto na paisagem tropical. O deserto também afeta a geração de indústrias e os requisitos de crescimento das localidades. Usado apenas durante a geração do mapa STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Rudeza do terreno: {STRING} -STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(Apenas TerraGenesis) Escolhe a frequência de montes: paisagens macias têm menos montes e mais espalhados. Paisagens duras têm muitos montes, que podem parecer repetitivos +STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :Escolher a forma e o número de colinas. As paisagens suaves têm poucas colinas, largas, enquanto as paisagens acidentadas possuem mais, colinas pequenas. ###length 4 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :Muito suave STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH :Suave @@ -1516,7 +1520,7 @@ STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH :Acidentado STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH :Muito acidentado STR_CONFIG_SETTING_VARIETY :Distribuição de variedade: {STRING} -STR_CONFIG_SETTING_VARIETY_HELPTEXT :(Apenas TerraGenesis) Controla se o mapa contém áreas planas e montanhosas. Como isto apenas torna o mapa mais plano, outras definições devem ser definidas como montanhosas +STR_CONFIG_SETTING_VARIETY_HELPTEXT :Escolher se o mapa contém tanto áreas montanhosas como áreas planas. Quanto maior a variedade, maiores as diferenças de altitude entre essas as áreas. STR_CONFIG_SETTING_RIVER_AMOUNT :Quantidade de rios: {STRING} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Escolhe quantos rios serão gerados @@ -1536,6 +1540,7 @@ STR_CONFIG_SETTING_ROAD_SIDE_LEFT :Circular pela e STR_CONFIG_SETTING_ROAD_SIDE_RIGHT :Circular pela direita STR_CONFIG_SETTING_HEIGHTMAP_ROTATION :Rotação mapa de alt.: {STRING} +STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP :Escolher de que forma a imagem topográfica será girada para caber no mundo do jogo ###length 2 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE :Sentido anti-horário STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE :Sentido horário @@ -1656,7 +1661,12 @@ STR_CONFIG_SETTING_ADVANCED_VEHICLE_LISTS_HELPTEXT :Ativar a utiliz STR_CONFIG_SETTING_LOADING_INDICATORS :Usar indicadores de carga: {STRING} STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Seleccionar se os indicadores de carga são mostrados acima de veículos em carga ou descarga +STR_CONFIG_SETTING_TIMETABLE_MODE :Unidades de tempo para horários: {STRING} +STR_CONFIG_SETTING_TIMETABLE_MODE_HELPTEXT :Selecionar as unidades de tempo usadas nos horários dos veículos ###length 3 +STR_CONFIG_SETTING_TIMETABLE_MODE_DAYS :Dias +STR_CONFIG_SETTING_TIMETABLE_MODE_SECONDS :Segundos +STR_CONFIG_SETTING_TIMETABLE_MODE_TICKS :Tiques STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Mostrar chegada e partida nos horários: {STRING} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Mostrar horários previstos de chegada e partida nas tabelas de horários @@ -2187,12 +2197,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Exibir e STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Exibir esquemas de cores dos veículos rodoviários STR_LIVERY_SHIP_TOOLTIP :{BLACK}Exibir esquemas de cores dos navios STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Exibir esquema de cores da aeronave +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de comboios +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de veículos rodoviários +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de navios +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de aeronaves STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Seleccione a cor primária para o veículo seleccionado. Ctrl+Clique vai usar esta cor para todos os esquemas STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Selecione a cor secundária para o esquema selecionado. Ctrl+Clique seleciona essa cor para todos os esquemas STR_LIVERY_PANEL_TOOLTIP :{BLACK}Seleccione o esquema de cores a alterar, ou esquemas múltiplos utilizando a tecla Ctrl com o botão esquerdo do rato. Marque a caixa para comutar a utilização do esquema de cores +STR_LIVERY_TRAIN_GROUP_EMPTY :Não estão configurados grupos de comboios +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Não estão configurados grupos de veículos rodoviários +STR_LIVERY_SHIP_GROUP_EMPTY :Não estão configurados grupos de navios +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Não estão configurados grupos de aeronaves ###length 23 -STR_LIVERY_DEFAULT :Estampagem Padrão +STR_LIVERY_DEFAULT :Pintura Padrão STR_LIVERY_STEAM :Locomotivas a Vapor STR_LIVERY_DIESEL :Locomotivas Diesel STR_LIVERY_ELECTRIC :Locomotivas Eléctricas @@ -2345,7 +2363,7 @@ STR_NETWORK_START_SERVER_NEW_GAME_NAME_TOOLTIP :{BLACK}O nome d STR_NETWORK_START_SERVER_SET_PASSWORD :{BLACK}Definir palavra-chave STR_NETWORK_START_SERVER_PASSWORD_TOOLTIP :{BLACK}Proteja o jogo com uma senha se não desejar que pessoas indesejadas se juntem -STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Visibilidade +STR_NETWORK_START_SERVER_VISIBILITY_LABEL :{BLACK}Visibilidade: STR_NETWORK_START_SERVER_VISIBILITY_TOOLTIP :{BLACK}Se as outras pessoas podem ver o seu servidor na lista pública STR_NETWORK_START_SERVER_CLIENTS_SELECT :{BLACK}{NUM} cliente{P "" s} STR_NETWORK_START_SERVER_NUMBER_OF_CLIENTS :{BLACK}Máximo de clientes: @@ -2580,7 +2598,7 @@ STR_CONTENT_SEARCH_EXTERNAL_TOOLTIP :{BLACK}Escolher STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER_CAPTION :{WHITE}Está a sair do OpenTTD! STR_CONTENT_SEARCH_EXTERNAL_DISCLAIMER :{WHITE}Os termos e condições para o download de conteúdo de sites externos variam.{}Terá que se referir aos sites externos para instruções em como instalar o conteúdo no OpenTTD.{}Pretende continuar? STR_CONTENT_FILTER_TITLE :{BLACK}Filtrar por etiqueta/nome: -STR_CONTENT_OPEN_URL :{BLACK}Visitar a página web +STR_CONTENT_OPEN_URL :{BLACK}Website STR_CONTENT_OPEN_URL_TOOLTIP :{BLACK}Visitar a página web para este conteúdo STR_CONTENT_DOWNLOAD_CAPTION :{BLACK}Descarregar STR_CONTENT_DOWNLOAD_CAPTION_TOOLTIP :{BLACK}Iniciar a descarga do conteúdo seleccionado @@ -3200,11 +3218,15 @@ STR_MAPGEN_MAPSIZE :{BLACK}Dim. do STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}Seleccionar o tamanho do mapa em mosaicos. O numero de mosaicos disponiveis será ligeiramente menor STR_MAPGEN_BY :{BLACK}* STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}Num. de localidades: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :{BLACK}Selecionar a densidade das cidades, ou um número personalizado STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}Nomes das localidades: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}Seleccionar o estilo dos nomes das localidades STR_MAPGEN_DATE :{BLACK}Data: +STR_MAPGEN_DATE_TOOLTIP :{BLACK}Selecionar a data inicial STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}Num. de indústrias: +STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP :{BLACK}Selecionar a densidade das indústrias, ou um número personalizado STR_MAPGEN_HEIGHTMAP_HEIGHT :{BLACK}Pico mais alto: +STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}Escolher o pico mais alto que o jogo tentará criar, medido em elevação acima do nível do mar STR_MAPGEN_HEIGHTMAP_HEIGHT_UP :{BLACK}Subir a altura máxima do pico mais alto do mapa em um STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN :{BLACK}Baixar a altura máxima do pico mais alto do mapa em um STR_MAPGEN_SNOW_COVERAGE :{BLACK}Cobertura de neve: @@ -3217,10 +3239,12 @@ STR_MAPGEN_DESERT_COVERAGE_DOWN :{BLACK}Diminuir STR_MAPGEN_DESERT_COVERAGE_TEXT :{BLACK}{NUM}% STR_MAPGEN_TERRAIN_TYPE :{BLACK}Tipo de terreno: STR_MAPGEN_SEA_LEVEL :{BLACK}Nível do mar: +STR_MAPGEN_SEA_LEVEL_TOOLTIP :{BLACK}Selecione o nível do mar STR_MAPGEN_QUANTITY_OF_RIVERS :{BLACK}Rios: STR_MAPGEN_SMOOTHNESS :{BLACK}Suavidade: STR_MAPGEN_VARIETY :{BLACK}Variedade da distribuição: STR_MAPGEN_GENERATE :{WHITE}Gerar +STR_MAPGEN_GENERATE_TOOLTIP :{BLACK}Criar o mapa e jogar OpenTTD! STR_MAPGEN_NEWGRF_SETTINGS :{BLACK}Definições de NewGRF STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP :{BLACK}Mostrar definições de NewGRF STR_MAPGEN_AI_SETTINGS :{BLACK}Definições de IA @@ -3253,6 +3277,7 @@ STR_MAPGEN_TOWN_NAME_CATALAN :Catalão # Strings for map borders at game generation STR_MAPGEN_BORDER_TYPE :{BLACK}Limites do mapa: +STR_MAPGEN_BORDER_TYPE_TOOLTIP :{BLACK}Escolher as bordas do mundo do jogo STR_MAPGEN_NORTHWEST :{BLACK}Noroeste STR_MAPGEN_NORTHEAST :{BLACK}Nordeste STR_MAPGEN_SOUTHEAST :{BLACK}Sudeste @@ -3265,7 +3290,9 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}Manual STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}Rotação mapa de alt.: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Nome mapa de alt.: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :{BLACK}O nome do ficheiro de imagem topográfica STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Tamanho: +STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP :{BLACK}As dimensões da imagem topográfica de origem. Para obter melhores resultados, cada aresta deve corresponder a um comprimento de aresta de mapa disponível no OpenTTD, tais como 256, 512, 1024, etc. STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}Altura do pico alvo @@ -3280,6 +3307,7 @@ STR_SE_MAPGEN_FLAT_WORLD :{WHITE}Terra pl STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP :{BLACK}Criar terra plana STR_SE_MAPGEN_RANDOM_LAND :{WHITE}Terra aleatória STR_SE_MAPGEN_FLAT_WORLD_HEIGHT :{BLACK}Altura da terra plana: +STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP :{BLACK}Escolher a elevação do terreno acima do nível do mar STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN :{BLACK}Mover altura da terra plana um nível abaixo STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP :{BLACK}Mover altura da terra plana um nível acima @@ -4573,8 +4601,13 @@ STR_TIMETABLE_STATUS_ON_TIME :{BLACK}Este ve STR_TIMETABLE_STATUS_LATE :{BLACK}Este veículo está presentemente atrasado {STRING} STR_TIMETABLE_STATUS_EARLY :{BLACK}Este veículo está presentemente adiantado {STRING} STR_TIMETABLE_STATUS_NOT_STARTED :{BLACK}Este horário ainda não começou +STR_TIMETABLE_STATUS_START_AT_DATE :{BLACK}Este horário tem início às {STRING} +STR_TIMETABLE_STATUS_START_IN_SECONDS :{BLACK}Este horário tem início em {COMMA} segundos +STR_TIMETABLE_START :{BLACK}Iniciar Horário +STR_TIMETABLE_START_TOOLTIP :{BLACK}Selecionar quando este horário começa. Ctrl+Clique distribui uniformemente o arranque de todos os veículos que partilham esta ordem com base na sua ordem relativa, se a ordem estiver completamente programada +STR_TIMETABLE_START_SECONDS_QUERY :Segundos até o horário iniciar STR_TIMETABLE_CHANGE_TIME :{BLACK}Mudar Tempo STR_TIMETABLE_WAIT_TIME_TOOLTIP :{BLACK}Mudar a duração do tempo que a ordem selecionada deve durar. Ctrl+Clique define o tempo para todas as ordens @@ -4598,6 +4631,10 @@ STR_TIMETABLE_EXPECTED :{BLACK}Esperado STR_TIMETABLE_SCHEDULED :{BLACK}Marcado STR_TIMETABLE_EXPECTED_TOOLTIP :{BLACK}Alternar entre tempo esperado e marcado +STR_TIMETABLE_ARRIVAL_DATE :A: {COLOUR}{DATE_TINY} +STR_TIMETABLE_DEPARTURE_DATE :D: {COLOUR}{DATE_TINY} +STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE :A: {COLOUR}{COMMA} seg +STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE :D: {COLOUR}{COMMA} seg # Date window (for timetable) @@ -4625,9 +4662,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Caso de STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Alternar o caso de igualdade quando se compara o resgisto da IA contra a string de paragem STR_AI_DEBUG_CONTINUE :{BLACK}Continuar STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Sair da pausa e continuar a IA -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Ver saída de depuração desta IA +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Ver saída de depuração desta IA. Ctrl+Clique para abrir numa nova janela STR_AI_GAME_SCRIPT :{BLACK}Script de jogo -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Verifique o registo do Script de jogo +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Verifique o registo do Script de jogo. Ctrl+Clique para abrir numa nova janela STR_ERROR_AI_NO_AI_FOUND :Não foi encontrada IA adequada para carregar.{}Esta IA é um pacote vazio e não fará nada.{}Pode descarregar várias IA através do sistema 'Conteúdo Online' STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Houve um erro num script. Por favor reporte isto ao autor do script com uma imagem da janela Depuramento de IA/Scripts de Jogo. @@ -4700,9 +4737,12 @@ STR_TEXTFILE_NAVBACK_TOOLTIP :{BLACK}Recuar n STR_TEXTFILE_NAVFORWARD_TOOLTIP :{BLACK}Avançar no histórico de navegação STR_TEXTFILE_WRAP_TEXT :{WHITE}Envolver o texto STR_TEXTFILE_WRAP_TEXT_TOOLTIP :{BLACK}Envolve o texto da janela de forma que não é necessário deslizar listagem -STR_TEXTFILE_VIEW_README :{BLACK}Ver leia-me +STR_TEXTFILE_VIEW_README :{BLACK}Leia-me +STR_TEXTFILE_VIEW_README_TOOLTIP :Ver "readme" para este conteúdo STR_TEXTFILE_VIEW_CHANGELOG :{BLACK}Lista de alterações +STR_TEXTFILE_VIEW_CHANGELOG_TOOLTIP :Ver o "log" de alterações para este conteúdo STR_TEXTFILE_VIEW_LICENCE :{BLACK}Licença +STR_TEXTFILE_VIEW_LICENCE_TOOLTIP :Ver a licença para este conteúdo ###length 5 STR_TEXTFILE_README_CAPTION :{WHITE}Leiame {STRING} de {STRING} STR_TEXTFILE_CHANGELOG_CAPTION :{WHITE}Lista de alterações {STRING} de {STRING} From 3e2060f1554f360a7ed46e836cd099b362734310 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 31 Dec 2023 23:31:01 +0000 Subject: [PATCH 24/29] Fix #11337: Station blocked/pylon/wire bits with CBID_STATION_TILE_LAYOUT (#11656) --- src/station_cmd.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 230e7dac3c..4cbfab5979 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1439,20 +1439,6 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp SetStationTileRandomBits(tile, GB(Random(), 0, 4)); SetAnimationFrame(tile, 0); - /* Should be the same as layout but axis component could be wrong... */ - StationGfx gfx = GetStationGfx(tile); - bool blocked = statspec != nullptr && HasBit(statspec->blocked, gfx); - /* Default stations do not draw pylons under roofs (gfx >= 4) */ - bool pylons = statspec != nullptr ? HasBit(statspec->pylons, gfx) : gfx < 4; - bool wires = statspec == nullptr || !HasBit(statspec->wires, gfx); - - SetStationTileBlocked(tile, blocked); - SetStationTileHavePylons(tile, pylons); - SetStationTileHaveWires(tile, wires); - - if (!blocked) c->infrastructure.rail[rt]++; - c->infrastructure.station++; - if (statspec != nullptr) { /* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */ uint32_t platinfo = GetPlatformInfo(AXIS_X, GetStationGfx(tile), plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false); @@ -1471,6 +1457,20 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp TriggerStationAnimation(st, tile, SAT_BUILT); } + /* Should be the same as layout but axis component could be wrong... */ + StationGfx gfx = GetStationGfx(tile); + bool blocked = statspec != nullptr && HasBit(statspec->blocked, gfx); + /* Default stations do not draw pylons under roofs (gfx >= 4) */ + bool pylons = statspec != nullptr ? HasBit(statspec->pylons, gfx) : gfx < 4; + bool wires = statspec == nullptr || !HasBit(statspec->wires, gfx); + + SetStationTileBlocked(tile, blocked); + SetStationTileHavePylons(tile, pylons); + SetStationTileHaveWires(tile, wires); + + if (!blocked) c->infrastructure.rail[rt]++; + c->infrastructure.station++; + tile += tile_delta; } while (--w); AddTrackToSignalBuffer(tile_track, track, _current_company); From f56a2d0f82b8e9b93754d1bc8e6c9420bfb8e903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Mon, 1 Jan 2024 00:43:10 +0100 Subject: [PATCH 25/29] Fix: Missing invalidations on gui.ai_developer_tools change (#11664) --- src/script/script_gui.cpp | 12 +++++++----- src/table/settings/gui_settings.ini | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index 8a8fa7b2ca..429298de1d 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -785,19 +785,14 @@ struct ScriptDebugWindow : public Window { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_SCRD_VSCROLLBAR); this->hscroll = this->GetScrollbar(WID_SCRD_HSCROLLBAR); - this->show_break_box = _settings_client.gui.ai_developer_tools; - this->GetWidget(WID_SCRD_BREAK_STRING_WIDGETS)->SetDisplayedPlane(this->show_break_box ? 0 : SZSP_HORIZONTAL); this->FinishInitNested(number); - if (!this->show_break_box) this->filter.break_check_enabled = false; - this->last_vscroll_pos = 0; this->autoscroll = true; this->highlight_row = -1; this->querystrings[WID_SCRD_BREAK_STR_EDIT_BOX] = &this->break_editbox; - SetWidgetsDisabledState(!this->show_break_box, WID_SCRD_BREAK_STR_ON_OFF_BTN, WID_SCRD_BREAK_STR_EDIT_BOX, WID_SCRD_MATCH_CASE_BTN); this->hscroll->SetStepSize(10); // Speed up horizontal scrollbar /* Restore the break string value from static variable, and enable the filter. */ @@ -813,6 +808,11 @@ struct ScriptDebugWindow : public Window { void OnInit() override { + this->show_break_box = _settings_client.gui.ai_developer_tools; + this->GetWidget(WID_SCRD_BREAK_STRING_WIDGETS)->SetDisplayedPlane(this->show_break_box ? 0 : SZSP_HORIZONTAL); + if (!this->show_break_box) this->filter.break_check_enabled = false; + SetWidgetsDisabledState(!this->show_break_box, WID_SCRD_BREAK_STR_ON_OFF_BTN, WID_SCRD_BREAK_STR_EDIT_BOX, WID_SCRD_MATCH_CASE_BTN); + this->InvalidateData(-1); } @@ -1120,6 +1120,8 @@ struct ScriptDebugWindow : public Window { */ void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override { + if (this->show_break_box != _settings_client.gui.ai_developer_tools) this->ReInit(); + /* If the log message is related to the active company tab, check the break string. * This needs to be done in gameloop-scope, so the AI is suspended immediately. */ if (!gui_scope && data == this->filter.script_debug_company && diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index 2986b25ebe..fa3eef9a9f 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -796,7 +796,7 @@ cat = SC_EXPERT var = gui.ai_developer_tools flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC def = false -post_cb = [](auto) { InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); } +post_cb = [](auto) { InvalidateWindowClassesData(WC_GAME_OPTIONS); InvalidateWindowClassesData(WC_SCRIPT_DEBUG); InvalidateWindowClassesData(WC_SCRIPT_SETTINGS); } cat = SC_EXPERT [SDTC_BOOL] From a672813bb040011a5474a20a1542972436b81503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Guilloux?= Date: Mon, 1 Jan 2024 01:07:47 +0100 Subject: [PATCH 26/29] Add: [Script] Optional filter parameter to ScriptVehicleList constructor (#11663) --- regression/regression/main.nut | 7 +++ regression/regression/result.txt | 2 + src/script/api/ai_changelog.hpp | 3 ++ src/script/api/game_changelog.hpp | 3 ++ src/script/api/script_vehiclelist.cpp | 70 ++++++++++++++++++++++++++- src/script/api/script_vehiclelist.hpp | 25 ++++++++++ 6 files changed, 108 insertions(+), 2 deletions(-) diff --git a/regression/regression/main.nut b/regression/regression/main.nut index f6fe45cc2e..100a47f3c9 100644 --- a/regression/regression/main.nut +++ b/regression/regression/main.nut @@ -1814,10 +1814,17 @@ function Regression::Vehicle() print(" GetLastErrorString(): " + AIError.GetLastErrorString()); local list = AIVehicleList(); + local in_depot = AIVehicleList(AIVehicle.IsInDepot); + local IsType = function(vehicle_id, type) { + return AIVehicle.GetVehicleType(vehicle_id) == type; + } + local rv_list = AIVehicleList(IsType, AIVehicle.VT_ROAD); print(""); print("--VehicleList--"); print(" Count(): " + list.Count()); + print(" InDepot Count(): " + in_depot.Count()); + print(" RoadVehicle Count(): " + rv_list.Count()); list.Valuate(AIVehicle.GetLocation); print(" Location ListDump:"); for (local i = list.Begin(); !list.IsEnd(); i = list.Next()) { diff --git a/regression/regression/result.txt b/regression/regression/result.txt index 59ecd46fb0..578f15e623 100644 --- a/regression/regression/result.txt +++ b/regression/regression/result.txt @@ -9391,6 +9391,8 @@ ERROR: IsEnd() is invalid as Begin() is never called --VehicleList-- Count(): 5 + InDepot Count(): 4 + RoadVehicle Count(): 2 Location ListDump: 13 => 33417 12 => 33417 diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp index 21534121cf..9695ab0fd2 100644 --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -24,6 +24,9 @@ * API removals: * \li AIError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore. * + * Other changes: + * \li AIVehicleList accepts an optional filter function + * * \b 13.0 * * API additions: diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index d6267c7aab..07b172440d 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -84,6 +84,9 @@ * API removals: * \li GSError::ERR_PRECONDITION_TOO_MANY_PARAMETERS, that error is never returned anymore. * + * Other changes: + * \li GSVehicleList accepts an optional filter function + * * \b 13.0 * * API additions: diff --git a/src/script/api/script_vehiclelist.cpp b/src/script/api/script_vehiclelist.cpp index a00ec91c85..6c09f3f88b 100644 --- a/src/script/api/script_vehiclelist.cpp +++ b/src/script/api/script_vehiclelist.cpp @@ -18,12 +18,78 @@ #include "../../safeguards.h" -ScriptVehicleList::ScriptVehicleList() +ScriptVehicleList::ScriptVehicleList(HSQUIRRELVM vm) { EnforceDeityOrCompanyModeValid_Void(); + + int nparam = sq_gettop(vm) - 1; + if (nparam >= 1) { + /* Make sure the filter function is really a function, and not any + * other type. It's parameter 2 for us, but for the user it's the + * first parameter they give. */ + SQObjectType valuator_type = sq_gettype(vm, 2); + if (valuator_type != OT_CLOSURE && valuator_type != OT_NATIVECLOSURE) { + throw sq_throwerror(vm, "parameter 1 has an invalid type (expected function)"); + } + + /* Push the function to call */ + sq_push(vm, 2); + } + + /* Don't allow docommand from a Valuator, as we can't resume in + * mid C++-code. */ + bool backup_allow = ScriptObject::GetAllowDoCommand(); + ScriptObject::SetAllowDoCommand(false); + for (const Vehicle *v : Vehicle::Iterate()) { - if ((v->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon()))) this->AddItem(v->index); + if (v->owner != ScriptObject::GetCompany() && !ScriptCompanyMode::IsDeity()) continue; + if (!v->IsPrimaryVehicle() && !(v->type == VEH_TRAIN && ::Train::From(v)->IsFreeWagon())) continue; + + if (nparam < 1) { + /* No filter, just add the item. */ + this->AddItem(v->index); + continue; + } + + /* Push the root table as instance object, this is what squirrel does for meta-functions. */ + sq_pushroottable(vm); + /* Push all arguments for the valuator function. */ + sq_pushinteger(vm, v->index); + for (int i = 0; i < nparam - 1; i++) { + sq_push(vm, i + 3); + } + + /* Call the function. Squirrel pops all parameters and pushes the return value. */ + if (SQ_FAILED(sq_call(vm, nparam + 1, SQTrue, SQTrue))) { + ScriptObject::SetAllowDoCommand(backup_allow); + throw sq_throwerror(vm, "failed to run filter"); + } + + /* Retrieve the return value */ + switch (sq_gettype(vm, -1)) { + case OT_BOOL: { + SQBool add; + sq_getbool(vm, -1, &add); + if (add) this->AddItem(v->index); + break; + } + + default: { + ScriptObject::SetAllowDoCommand(backup_allow); + throw sq_throwerror(vm, "return value of filter is not valid (not bool)"); + } + } + + /* Pop the return value. */ + sq_poptop(vm); } + + if (nparam >= 1) { + /* Pop the filter function */ + sq_poptop(vm); + } + + ScriptObject::SetAllowDoCommand(backup_allow); } ScriptVehicleList_Station::ScriptVehicleList_Station(StationID station_id) diff --git a/src/script/api/script_vehiclelist.hpp b/src/script/api/script_vehiclelist.hpp index 22de3e344c..942e50b7ce 100644 --- a/src/script/api/script_vehiclelist.hpp +++ b/src/script/api/script_vehiclelist.hpp @@ -20,7 +20,32 @@ */ class ScriptVehicleList : public ScriptList { public: +#ifdef DOXYGEN_API ScriptVehicleList(); + + /** + * Apply a filter when building the list. + * @param filter_function The function which will be doing the filtering. + * @param params The params to give to the filters (minus the first param, + * which is always the index-value). + * @note You can write your own filters and use them. Just remember that + * the first parameter should be the index-value, and it should return + * a bool. + * @note Example: + * ScriptVehicleList(ScriptVehicle.IsInDepot); + * function IsType(vehicle_id, type) + * { + * return ScriptVehicle.GetVehicleType(vehicle_id) == type; + * } + * ScriptVehicleList(IsType, ScriptVehicle.VT_ROAD); + */ + ScriptVehicleList(void *filter_function, int params, ...); +#else + /** + * The constructor wrapper from Squirrel. + */ + ScriptVehicleList(HSQUIRRELVM vm); +#endif }; /** From 88324a253ecb5bc0b458d2c726e0696434cb291e Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 1 Jan 2024 18:26:31 +0000 Subject: [PATCH 27/29] Fix #11644: Off by one error/buffer over-read in StrMakeValid (#11645) * Fix #11644: Off by one error in StrMakeValid UTF-8 decode overrun detection * Fix #11644: Off by one error in StrMakeValid buffer last character * Fix: Unnecessary string duplication at StrMakeValid call sites --- src/fileio.cpp | 2 +- src/ini_load.cpp | 2 +- src/string.cpp | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fileio.cpp b/src/fileio.cpp index b0edd86b5c..215da0f36b 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -486,7 +486,7 @@ static std::string ExtractString(char *buffer, size_t buffer_length) { size_t length = 0; for (; length < buffer_length && buffer[length] != '\0'; length++) {} - return StrMakeValid(std::string(buffer, length)); + return StrMakeValid(std::string_view(buffer, length)); } bool TarScanner::AddFile(const std::string &filename, size_t, [[maybe_unused]] const std::string &tar_filename) diff --git a/src/ini_load.cpp b/src/ini_load.cpp index cc7d681467..1a6eed76f5 100644 --- a/src/ini_load.cpp +++ b/src/ini_load.cpp @@ -284,7 +284,7 @@ void IniLoadFile::LoadFromDisk(const std::string &filename, Subdirectory subdir) if (!quoted && e == t) { item.value.reset(); } else { - item.value = StrMakeValid(std::string(t)); + item.value = StrMakeValid(std::string_view(t)); } } else { /* it's an orphan item */ diff --git a/src/string.cpp b/src/string.cpp index 020fd2fd47..4eb45c2886 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -141,7 +141,7 @@ static void StrMakeValid(T &dst, const char *str, const char *last, StringValida * would also reach the "last" byte of the string and a normal '\0' * termination will be placed after it. */ - if (len == 0 || str + len > last || len != Utf8Decode(&c, str)) { + if (len == 0 || str + len > last + 1 || len != Utf8Decode(&c, str)) { /* Maybe the next byte is still a valid character? */ str++; continue; @@ -211,8 +211,10 @@ void StrMakeValidInPlace(char *str, StringValidationSettings settings) */ std::string StrMakeValid(std::string_view str, StringValidationSettings settings) { + if (str.empty()) return {}; + auto buf = str.data(); - auto last = buf + str.size(); + auto last = buf + str.size() - 1; std::ostringstream dst; std::ostreambuf_iterator dst_iter(dst); From 3e4dee6d0c30221d8a28cd7306c3607fc2a3d93b Mon Sep 17 00:00:00 2001 From: translators Date: Mon, 1 Jan 2024 18:38:47 +0000 Subject: [PATCH 28/29] Update: Translations from eints english (us): 11 changes by 2TallTyler korean: 29 changes by telk5093 --- src/lang/english_US.txt | 14 +++++++++++--- src/lang/korean.txt | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/lang/english_US.txt b/src/lang/english_US.txt index 4f34c40b26..d22d9b13a1 100644 --- a/src/lang/english_US.txt +++ b/src/lang/english_US.txt @@ -2196,12 +2196,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Show tra STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Show road vehicle color schemes STR_LIVERY_SHIP_TOOLTIP :{BLACK}Show ship color schemes STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Show aircraft color schemes +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Show colors of train groups +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Show colors of road vehicle groups +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Show colors of ship groups +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Show colors of aircraft groups STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Choose the primary color for the selected scheme. Ctrl+Click will set this color for every scheme STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Choose the secondary color for the selected scheme. Ctrl+Click will set this color for every scheme STR_LIVERY_PANEL_TOOLTIP :{BLACK}Select a color scheme to change, or multiple schemes with Ctrl+Click. Click on the box to toggle use of the scheme +STR_LIVERY_TRAIN_GROUP_EMPTY :No train groups are set up +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :No road vehicle groups are set up +STR_LIVERY_SHIP_GROUP_EMPTY :No ship groups are set up +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :No aircraft groups are set up ###length 23 -STR_LIVERY_DEFAULT :Standard Livery +STR_LIVERY_DEFAULT :Default Livery STR_LIVERY_STEAM :Steam Engine STR_LIVERY_DIESEL :Diesel Engine STR_LIVERY_ELECTRIC :Electric Engine @@ -4653,9 +4661,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Match ca STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Toggle matching case when comparing AI log messages against the break string STR_AI_DEBUG_CONTINUE :{BLACK}Continue STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Unpause and continue the AI -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}View debug output of this AI +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}View debug output of this AI. Ctrl-Click to open in a new window STR_AI_GAME_SCRIPT :{BLACK}Game Script -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Check the Game Script log +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Check the Game Script log. Ctrl-Click to open in a new window STR_ERROR_AI_NO_AI_FOUND :No suitable AI found to load.{}This AI is a dummy AI and won't do anything.{}You can download several AIs via the 'Online Content' system STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}One of the running scripts crashed. Please report this to the script author with a screenshot of the AI/Game Script Debug Window diff --git a/src/lang/korean.txt b/src/lang/korean.txt index f475b6c2f4..3f74dd1e38 100644 --- a/src/lang/korean.txt +++ b/src/lang/korean.txt @@ -403,8 +403,8 @@ STR_TOOLBAR_TOOLTIP_SWITCH_TOOLBAR :{BLACK}툴바 STR_SCENEDIT_TOOLBAR_TOOLTIP_SAVE_SCENARIO_LOAD_SCENARIO :{BLACK}시나리오를 저장하거나, 불러오거나, 시나리오 에디터를 종료하거나, 게임을 종료합니다 STR_SCENEDIT_TOOLBAR_OPENTTD :{YELLOW}OpenTTD STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR :{YELLOW}시나리오 에디터 -STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD :{BLACK}시작년도를 1년 앞당깁니다. -STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD :{BLACK}시작년도를 1년 늦춥니다. +STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD :{BLACK}시작 일시를 1년 앞당깁니다. +STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD :{BLACK}시작 일시를 1년 늦춥니다. STR_SCENEDIT_TOOLBAR_TOOLTIP_SET_DATE :{BLACK}시작 연도를 입력하세요. STR_SCENEDIT_TOOLBAR_TOOLTIP_DISPLAY_MAP_TOWN_DIRECTORY :{BLACK}지도, 도시 목록 보여주기 STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION :{BLACK}지형을 생성합니다. @@ -1492,7 +1492,7 @@ STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL :오리지널 STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS :천지창조 STR_CONFIG_SETTING_TERRAIN_TYPE :지형 종류: {STRING} -STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :(천지창조 전용) 지형의 언덕 모양을 결정합니다. +STR_CONFIG_SETTING_TERRAIN_TYPE_HELPTEXT :지형의 언덕과 산지 모양을 결정합니다 STR_CONFIG_SETTING_INDUSTRY_DENSITY :산업시설 수: {STRING} STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :게임을 플레이하는 동안 얼마나 많은 산업시설이 생성되고 유지되어야 할 지를 설정합니다. @@ -1501,18 +1501,18 @@ STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :석유 관련 STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :정유 공장과 유전이 맵 가장자리에서 얼마나 멀리 떨어진 곳까지 건설될 수 있는지를 나타냅니다. 섬 맵에서는 이 설정을 이용해서 해당 산업시설이 해안에 가까이 있도록 조정할 수 있습니다. 256칸보다 큰 맵의 경우에는 이 값은 더 크게 조정됩니다. STR_CONFIG_SETTING_SNOWLINE_HEIGHT :설선 고도: {STRING} -STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :아한대 기후의 설선 고도를 조절합니다. 눈은 산업시설의 생성과 도시 성장에 영향을 미칩니다. 시나리오 에디터에서 수정할 수 있고 설정하지 않은 경우 "눈 비율" 설정을 따릅니다. +STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :아한대 기후의 설선 고도를 선택합니다. 눈은 산업시설의 생성과 도시 성장에 영향을 미칩니다. 시나리오 에디터에서 수정할 수 있고 설정하지 않은 경우 "눈 비율" 설정을 따릅니다. STR_CONFIG_SETTING_SNOW_COVERAGE :눈 비율: {STRING} -STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :아한대 기후에서 눈 지역의 양을 대략적으로 조절할 수 있습니다. 눈은 산업시설 생성과 도시 성장 요구사항에도 영향을 미칩니다. 지도를 생성할 때에만 사용하는 설정입니다. 해수면 바로 위에 있는 땅은 무조건 눈이 없을 것입니다. +STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :아한대 기후에서 눈 지역의 양을 대략적으로 선택합니다. 눈은 산업시설 생성과 도시 성장 요구 조건에도 영향을 미칩니다. 지도를 생성할 때에만 사용하는 설정입니다. 해수면 바로 위에 있는 땅은 무조건 눈이 없을 것입니다. STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_DESERT_COVERAGE :사막 비율: {STRING} -STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :아열대 기후에서 사막 지역의 양을 대략적으로 조절할 수 있습니다. 사막은 산업시설 생성에도 영향을 미칩니다. 지도를 생성할 때에만 사용하는 설정입니다 +STR_CONFIG_SETTING_DESERT_COVERAGE_HELPTEXT :아열대 기후에서 사막 지역의 양을 대략적으로 선택합니다. 사막은 산업시설 생성과 도시 성장 요구 조건에도 영향을 미칩니다. 지도를 생성할 때에만 사용하는 설정입니다 STR_CONFIG_SETTING_DESERT_COVERAGE_VALUE :{NUM}% STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :지형의 거친 정도: {STRING} -STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(천지창조 전용) 언덕의 빈도수를 선택합니다. 평탄한 지형은 개수가 적고 넓게 퍼진 언덕을 만듭니다. 거친 지형은 똑같아 보일 수 있는 많은 언덕이 생기게 됩니다. +STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :언덕의 모양과 빈도 수를 선택합니다. 평탄한 지형은 개수가 적고 넓게 퍼진 언덕을 만들고, 거친 지형은 작은 언덕이 많이 만듭니다. ###length 4 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :매우 부드럽게 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH :부드럽게 @@ -1520,7 +1520,7 @@ STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH :거칠게 STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH :매우 거칠게 STR_CONFIG_SETTING_VARIETY :산세 험준도: {STRING} -STR_CONFIG_SETTING_VARIETY_HELPTEXT :(천지창조 전용) 지도가 산지와 평지를 모두 갖도록 만들 것인 지를 결정합니다. 이 설정은 지형을 더 평평하게 만드므로, 다른 설정은 '산'으로 설정하시기 바랍니다. +STR_CONFIG_SETTING_VARIETY_HELPTEXT :지도가 산지와 평지를 모두 갖도록 만들 것인 지를 결정합니다. 더 높은 값을 사용할 수록, 산지와 평지 사이의 고도 차이가 더 많아집니다. STR_CONFIG_SETTING_RIVER_AMOUNT :강의 양: {STRING} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :강을 얼마나 만들지 선택하세요 @@ -1540,6 +1540,7 @@ STR_CONFIG_SETTING_ROAD_SIDE_LEFT :좌측통행 STR_CONFIG_SETTING_ROAD_SIDE_RIGHT :우측통행 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION :높이맵 회전: {STRING} +STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_TOOLTIP :높이맵을 게임 세계에 맞추기 위해 어느 방향으로 회전시킬지 선택합니다 ###length 2 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE :반시계방향 STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE :시계방향 @@ -2196,9 +2197,17 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}열차 STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}차량 색상 선택 STR_LIVERY_SHIP_TOOLTIP :{BLACK}선박 색상 선택 STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}항공기 색상 선택 +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}열차 그룹 색상 선택 +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}자동차 그룹 색상 선택 +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}선박 그룹 색상 선택 +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}항공기 그룹 색상 선택 STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}선택한 색상을 1차 색상으로 선택합니다. CTRL+클릭하면 모든 항목에 적용됩니다 STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}선택한 색상을 2차 색상으로 선택합니다. CTRL+클릭하면 모든 항목에 적용됩니다 STR_LIVERY_PANEL_TOOLTIP :{BLACK}색상 조합을 바꾸려면 선택하세요. 2개 이상 선택하려면 CTRL+클릭하세요. 네모를 클릭하여 체크하면 해당 색상 조합을 사용하게 됩니다 +STR_LIVERY_TRAIN_GROUP_EMPTY :열차 그룹을 설정하지 않았습니다 +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :자동차 그룹을 설정하지 않았습니다 +STR_LIVERY_SHIP_GROUP_EMPTY :선박 그룹을 설정하지 않았습니다 +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :항공기 그룹을 설정하지 않았습니다 ###length 23 STR_LIVERY_DEFAULT :기본 색상 @@ -3209,11 +3218,15 @@ STR_MAPGEN_MAPSIZE :{BLACK}지도 STR_MAPGEN_MAPSIZE_TOOLTIP :{BLACK}지도의 크기를 칸 수 기준으로 선택하세요. 사용 가능한 지도의 칸 수는 설정한 값보다 조금 작을 것입니다 STR_MAPGEN_BY :{BLACK}x STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}도시의 수: +STR_MAPGEN_NUMBER_OF_TOWNS_TOOLTIP :{BLACK}도시의 수를 선택하거나, 직접 그 개수를 입력합니다 STR_MAPGEN_TOWN_NAME_LABEL :{BLACK}도시 이름: STR_MAPGEN_TOWN_NAME_DROPDOWN_TOOLTIP :{BLACK}도시 이름 스타일을 선택하세요 STR_MAPGEN_DATE :{BLACK}날짜: +STR_MAPGEN_DATE_TOOLTIP :{BLACK}시작 일시를 선택합니다. STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}산업시설 수: +STR_MAPGEN_NUMBER_OF_INDUSTRIES_TOOLTIP :{BLACK}산업 시설의 수를 선택하거나, 직접 그 개수를 입력합니다 STR_MAPGEN_HEIGHTMAP_HEIGHT :{BLACK}가장 높은 지점의 높이: +STR_MAPGEN_HEIGHTMAP_HEIGHT_TOOLTIP :{BLACK}해수면을 기준으로, 게임이 생성하려고 하는 가장 높은 곳의 높이를 선택합니다. STR_MAPGEN_HEIGHTMAP_HEIGHT_UP :{BLACK}지도에서 가장 높은 지점의 최대 높이를 1만큼 높입니다 STR_MAPGEN_HEIGHTMAP_HEIGHT_DOWN :{BLACK}지도에서 가장 높은 지점의 최대 높이를 1만큼 낮춥니다 STR_MAPGEN_SNOW_COVERAGE :{BLACK}눈 비율: @@ -3226,10 +3239,12 @@ STR_MAPGEN_DESERT_COVERAGE_DOWN :{BLACK}사막 STR_MAPGEN_DESERT_COVERAGE_TEXT :{BLACK}{NUM}% STR_MAPGEN_TERRAIN_TYPE :{BLACK}지형 종류: STR_MAPGEN_SEA_LEVEL :{BLACK}해수면: +STR_MAPGEN_SEA_LEVEL_TOOLTIP :{BLACK}해수면 높이를 선택합니다 STR_MAPGEN_QUANTITY_OF_RIVERS :{BLACK}강: STR_MAPGEN_SMOOTHNESS :{BLACK}지표면을 깎는 방식: STR_MAPGEN_VARIETY :{BLACK}산세 험준도: STR_MAPGEN_GENERATE :{WHITE}만들기 +STR_MAPGEN_GENERATE_TOOLTIP :{BLACK}세계를 만들고 OpenTTD를 플레이해보세요! STR_MAPGEN_NEWGRF_SETTINGS :{BLACK}NewGRF 설정 STR_MAPGEN_NEWGRF_SETTINGS_TOOLTIP :{BLACK}NewGRF 설정 창을 엽니다 STR_MAPGEN_AI_SETTINGS :{BLACK}인공지능 설정 @@ -3262,6 +3277,7 @@ STR_MAPGEN_TOWN_NAME_CATALAN :카탈로니아 # Strings for map borders at game generation STR_MAPGEN_BORDER_TYPE :{BLACK}지도 가장자리: +STR_MAPGEN_BORDER_TYPE_TOOLTIP :{BLACK}게임 세계의 지도 가장자리를 선택합니다 STR_MAPGEN_NORTHWEST :{BLACK}북서 STR_MAPGEN_NORTHEAST :{BLACK}북동 STR_MAPGEN_SOUTHEAST :{BLACK}남동 @@ -3274,7 +3290,9 @@ STR_MAPGEN_BORDER_MANUAL :{BLACK}사용 STR_MAPGEN_HEIGHTMAP_ROTATION :{BLACK}높이맵 방향: STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}높이맵 이름: +STR_MAPGEN_HEIGHTMAP_NAME_TOOLTIP :{BLACK}높이맵 이미지 파일의 이름입니다 STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}크기: +STR_MAPGEN_HEIGHTMAP_SIZE_LABEL_TOOLTIP :{BLACK}원본 높이맵 이미지의 크기입니다. 최상의 조건을 위해서는, 이미지의 가로/세로 크기를 OpenTTD의 지도 크기와 같은 256, 512, 1024 등으로 맞추는 것이 좋습니다. STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} STR_MAPGEN_TERRAIN_TYPE_QUERY_CAPT :{WHITE}목표 정상 높이 @@ -3289,6 +3307,7 @@ STR_SE_MAPGEN_FLAT_WORLD :{WHITE}평평 STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP :{BLACK}평평한 땅 만들기 STR_SE_MAPGEN_RANDOM_LAND :{WHITE}무작위 지형 STR_SE_MAPGEN_FLAT_WORLD_HEIGHT :{BLACK}평지의 높이: +STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_TOOLTIP :{BLACK}해수면 위의 땅 높이를 선택합니다 STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_DOWN :{BLACK}평지의 높이를 1칸 낮춥니다 STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_UP :{BLACK}평지의 높이를 1칸 높입니다 @@ -4643,9 +4662,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}대소 STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}인공지능 기록 메시지에서 중단 문구를 검색할 때 대소문자를 구분할지 여부를 선택합니다 STR_AI_DEBUG_CONTINUE :{BLACK}계속 STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}중단된 인공지능의 연산을 재개합니다 -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}이 인공지능에서 출력된 기록 메시지를 보여줍니다 +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}이 인공지능에서 출력된 기록 메시지를 보여줍니다. CTRL + 클릭하면 새 창으로 엽니다 STR_AI_GAME_SCRIPT :{BLACK}게임 스크립트 -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}게임 스크립트 기록 체크 +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}게임 스크립트 기록을 확인합니다. CTRL + 클릭하면 새 창으로 엽니다 STR_ERROR_AI_NO_AI_FOUND :사용할 수 있는 인공지능이 없습니다.{}따라서 이 경쟁사는 아무 것도 하지 못하는 회사입니다.{}'온라인 컨텐츠 다운로드'에서 새로운 인공지능을 다운로드받으세요 STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}작동 중이던 스크립트 중 하나에서 오류가 발생하여 중단되었습니다. 인공지능/게임 스크립트 디버그 창에서 스크린샷을 찍어 스크립트 제작자에게 보고하십시오 From 502a52edd55362d681320141dfb037125e73d0dd Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Mon, 1 Jan 2024 19:13:29 +0000 Subject: [PATCH 29/29] Fix: Spurious cancellations of HTTP content downloads (#11668) --- src/network/network_content.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index c8854f536d..12e3ee3061 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -609,6 +609,8 @@ void ClientNetworkContentSocketHandler::OnReceiveData(const char *data, size_t l /* Ignore any latent data coming from a connection we closed. */ if (this->http_response_index == -2) return; + this->lastActivity = std::chrono::steady_clock::now(); + if (this->http_response_index == -1) { if (data != nullptr) { /* Append the rest of the response. */