diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 981921124a..a9808bb2be 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -87,12 +87,12 @@ jobs: matrix: include: - name: Clang - Debug - compiler: clang - cxxcompiler: clang++ + compiler: clang-15 + cxxcompiler: clang++-15 libraries: libsdl2-dev - name: Clang - Release - compiler: clang - cxxcompiler: clang++ + compiler: clang-15 + cxxcompiler: clang++-15 libraries: libsdl2-dev extra-cmake-parameters: -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPTION_USE_ASSERTS=OFF - name: GCC - SDL2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ebec96b2d..d865577674 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ set_directory_options() include(Static) set_static_if_needed() -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_CXX_EXTENSIONS NO) diff --git a/cmake/CompileFlags.cmake b/cmake/CompileFlags.cmake index ef0058661f..cb85fa95db 100644 --- a/cmake/CompileFlags.cmake +++ b/cmake/CompileFlags.cmake @@ -16,6 +16,13 @@ macro(compile_flags) endif() endif() + # Our strings are UTF-8. + if(MSVC) + add_compile_options(/utf-8) + else() + add_compile_options(-finput-charset=utf-8) + endif() + # Add some -D flags for Debug builds. We cannot use add_definitions(), because # it does not appear to support the $<> tags. add_compile_options( diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index e53045bf1e..e34200460a 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -26,7 +26,7 @@ #include "../safeguards.h" /** Widgets for the configure AI window. */ -static const NWidgetPart _nested_ai_config_widgets[] = { +static constexpr NWidgetPart _nested_ai_config_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_AI_CONFIG_CAPTION_AI, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 2b407a3c24..6cf897760e 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -186,7 +186,7 @@ static Hotkey airtoolbar_hotkeys[] = { }; HotkeyList BuildAirToolbarWindow::hotkeys("airtoolbar", airtoolbar_hotkeys, AirportToolbarGlobalHotkeys); -static const NWidgetPart _nested_air_toolbar_widgets[] = { +static constexpr NWidgetPart _nested_air_toolbar_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TOOLBAR_AIRCRAFT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -569,7 +569,7 @@ public: } }; -static const NWidgetPart _nested_build_airport_widgets[] = { +static constexpr NWidgetPart _nested_build_airport_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_AIRPORT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 4eaf9d4f39..a9f783f6c6 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -733,7 +733,7 @@ public: } }; -static const NWidgetPart _nested_replace_rail_vehicle_widgets[] = { +static constexpr NWidgetPart _nested_replace_rail_vehicle_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -797,7 +797,7 @@ static WindowDesc _replace_rail_vehicle_desc(__FILE__, __LINE__, std::begin(_nested_replace_rail_vehicle_widgets), std::end(_nested_replace_rail_vehicle_widgets) ); -static const NWidgetPart _nested_replace_road_vehicle_widgets[] = { +static constexpr NWidgetPart _nested_replace_road_vehicle_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -855,7 +855,7 @@ static WindowDesc _replace_road_vehicle_desc(__FILE__, __LINE__, std::begin(_nested_replace_road_vehicle_widgets), std::end(_nested_replace_road_vehicle_widgets) ); -static const NWidgetPart _nested_replace_vehicle_widgets[] = { +static constexpr NWidgetPart _nested_replace_vehicle_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_RV_CAPTION), SetMinimalSize(433, 14), SetDataTip(STR_REPLACE_VEHICLES_WHITE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/blitter/32bpp_anim_sse4.cpp b/src/blitter/32bpp_anim_sse4.cpp index 952147865d..bfe185d870 100644 --- a/src/blitter/32bpp_anim_sse4.cpp +++ b/src/blitter/32bpp_anim_sse4.cpp @@ -31,7 +31,7 @@ static FBlitter_32bppSSE4_Anim iFBlitter_32bppSSE4_Anim; IGNORE_UNINITIALIZED_WARNING_START template GNU_TARGET("sse4.1") -inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) +inline void Blitter_32bppSSE4_Anim::Draw(const BlitterParams *bp, ZoomLevel zoom) { const byte * const remap = bp->remap; Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left; diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index d5633c4760..73af7f32f6 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -31,7 +31,7 @@ #include "safeguards.h" /** Widgets for the background window to prevent smearing. */ -static const struct NWidgetPart _background_widgets[] = { +static constexpr NWidgetPart _background_widgets[] = { NWidget(WWT_PANEL, COLOUR_DARK_BLUE, WID_BB_BACKGROUND), SetResize(1, 1), EndContainer(), }; @@ -64,7 +64,7 @@ public: }; /** Nested widgets for the error window. */ -static const NWidgetPart _nested_bootstrap_errmsg_widgets[] = { +static constexpr NWidgetPart _nested_bootstrap_errmsg_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CAPTION, COLOUR_GREY, WID_BEM_CAPTION), SetDataTip(STR_MISSING_GRAPHICS_ERROR_TITLE, STR_NULL), EndContainer(), @@ -121,7 +121,7 @@ public: }; /** Nested widgets for the download window. */ -static const NWidgetPart _nested_bootstrap_download_status_window_widgets[] = { +static constexpr NWidgetPart _nested_bootstrap_download_status_window_widgets[] = { NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CONTENT_DOWNLOAD_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), NWidget(WWT_PANEL, COLOUR_GREY), NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.modalpopup), @@ -172,7 +172,7 @@ public: }; /** The widgets for the query. It has no close box as that sprite does not exist yet. */ -static const NWidgetPart _bootstrap_query_widgets[] = { +static constexpr NWidgetPart _bootstrap_query_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_MISSING_GRAPHICS_SET_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), EndContainer(), diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 5941903b2a..8736feb5b9 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -328,7 +328,7 @@ const StringID BuildBridgeWindow::sorter_names[] = { }; /** Widgets of the bridge gui. */ -static const NWidgetPart _nested_build_bridge_widgets[] = { +static constexpr NWidgetPart _nested_build_bridge_widgets[] = { /* Header */ NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 96f481576d..5a6889f7c3 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -56,7 +56,7 @@ uint GetEngineListHeight(VehicleType type) } /* Normal layout for roadvehicles, ships and airplanes. */ -static const NWidgetPart _nested_build_vehicle_widgets[] = { +static constexpr NWidgetPart _nested_build_vehicle_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_BV_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE), @@ -96,7 +96,7 @@ static const NWidgetPart _nested_build_vehicle_widgets[] = { }; /* Advanced layout for trains. */ -static const NWidgetPart _nested_build_vehicle_widgets_train_advanced[] = { +static constexpr NWidgetPart _nested_build_vehicle_widgets_train_advanced[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_BV_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE), diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index acf3a6b006..9860a69909 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -219,7 +219,7 @@ static bool IsCheatAllowed(CheatNetworkMode mode) static_assert(CHT_NUM_CHEATS == lengthof(_cheats_ui)); /** Widget definitions of the cheat GUI. */ -static const NWidgetPart _nested_cheat_widgets[] = { +static constexpr NWidgetPart _nested_cheat_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CHEATS, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/command_type.h b/src/command_type.h index baa3990f46..fba864b529 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -582,6 +582,11 @@ enum FlaggedCommands { CMD_ID_MASK = 0x00FF, ///< mask for the command ID }; +inline constexpr Commands operator|(const Commands &lhs, const FlaggedCommands &rhs) +{ + return static_cast(static_cast(lhs) | static_cast(rhs)); +} + static_assert(CMD_END <= CMD_ID_MASK + 1); /** diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 61029ba589..319a227c68 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -278,7 +278,7 @@ static void DrawYearColumn(const Rect &r, int year, const Expenses &tbl) DrawPrice(sum, r.left, r.right, y, TC_WHITE); } -static const NWidgetPart _nested_company_finances_widgets[] = { +static constexpr NWidgetPart _nested_company_finances_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_CF_CAPTION), SetDataTip(STR_FINANCES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -771,7 +771,7 @@ public: void SetSelectedGroup(CompanyID company, GroupID group) { - this->RaiseWidget(this->livery_class + WID_SCL_CLASS_GENERAL); + this->RaiseWidget(WID_SCL_CLASS_GENERAL + this->livery_class); const Group *g = Group::Get(group); switch (g->vehicle_type) { case VEH_TRAIN: this->livery_class = LC_GROUP_RAIL; break; @@ -781,7 +781,7 @@ public: default: NOT_REACHED(); } this->sel = group; - this->LowerWidget(this->livery_class + WID_SCL_CLASS_GENERAL); + this->LowerWidget(WID_SCL_CLASS_GENERAL + this->livery_class); this->groups.ForceRebuild(); this->BuildGroupList(company); @@ -987,9 +987,9 @@ public: case WID_SCL_GROUPS_ROAD: case WID_SCL_GROUPS_SHIP: case WID_SCL_GROUPS_AIRCRAFT: - this->RaiseWidget(this->livery_class + WID_SCL_CLASS_GENERAL); + this->RaiseWidget(WID_SCL_CLASS_GENERAL + this->livery_class); this->livery_class = (LiveryClass)(widget - WID_SCL_CLASS_GENERAL); - this->LowerWidget(this->livery_class + WID_SCL_CLASS_GENERAL); + this->LowerWidget(WID_SCL_CLASS_GENERAL + this->livery_class); /* Select the first item in the list */ if (this->livery_class < LC_GROUP_RAIL) { @@ -1121,7 +1121,7 @@ public: } }; -static const NWidgetPart _nested_select_company_livery_widgets[] = { +static constexpr NWidgetPart _nested_select_company_livery_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_SCL_CAPTION), SetDataTip(STR_LIVERY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1216,7 +1216,7 @@ void DrawCompanyManagerFace(CompanyManagerFace cmf, int colour, const Rect &r) } /** Nested widget description for the company manager face selection dialog */ -static const NWidgetPart _nested_select_company_manager_face_widgets[] = { +static constexpr NWidgetPart _nested_select_company_manager_face_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_SCMF_CAPTION), SetDataTip(STR_FACE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1795,7 +1795,7 @@ static void DoSelectCompanyManagerFace(Window *parent) new SelectCompanyManagerFaceWindow(&_select_company_manager_face_desc, parent); } -static const NWidgetPart _nested_company_infrastructure_widgets[] = { +static constexpr NWidgetPart _nested_company_infrastructure_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_CI_CAPTION), SetDataTip(STR_COMPANY_INFRASTRUCTURE_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2196,7 +2196,7 @@ static void ShowCompanyInfrastructure(CompanyID company) AllocateWindowDescFront(&_company_infrastructure_desc, company); } -static const NWidgetPart _nested_company_widgets[] = { +static constexpr NWidgetPart _nested_company_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_C_CAPTION), SetDataTip(STR_COMPANY_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2902,7 +2902,7 @@ private: Money company_value; ///< The value of the company for which the user can buy it. }; -static const NWidgetPart _nested_buy_company_widgets[] = { +static constexpr NWidgetPart _nested_buy_company_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE), NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE, WID_BC_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION_OTHER_COMPANY, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/company_type.h b/src/company_type.h index 8ff1f5697a..07a0d05822 100644 --- a/src/company_type.h +++ b/src/company_type.h @@ -35,6 +35,7 @@ enum Owner : byte { COMPANY_SPECTATOR = 255, ///< The client is spectating }; DECLARE_POSTFIX_INCREMENT(Owner) +DECLARE_ENUM_AS_ADDABLE(Owner) static const uint MAX_LENGTH_PRESIDENT_NAME_CHARS = 32; ///< The maximum length of a president name in characters including '\0' static const uint MAX_LENGTH_COMPANY_NAME_CHARS = 32; ///< The maximum length of a company name in characters including '\0' diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 167b83c87e..79e7da8483 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -100,7 +100,7 @@ static const char *IConsoleHistoryAdd(const char *cmd); static void IConsoleHistoryNavigate(int direction); static void IConsoleTabCompletion(); -static const struct NWidgetPart _nested_console_window_widgets[] = { +static constexpr NWidgetPart _nested_console_window_widgets[] = { NWidget(WWT_EMPTY, INVALID_COLOUR, WID_C_BACKGROUND), SetResize(1, 1), }; diff --git a/src/core/enum_type.hpp b/src/core/enum_type.hpp index 8687c62428..bd2d6e51fc 100644 --- a/src/core/enum_type.hpp +++ b/src/core/enum_type.hpp @@ -37,6 +37,12 @@ inline constexpr enum_type& operator ^= (enum_type& m1, enum_type m2) {m1 = m1 ^ m2; return m1;} \ inline constexpr enum_type operator ~(enum_type m) {return (enum_type)(~(std::underlying_type::type)m);} +/** Operator that allows this enumeration to be added to any other enumeration. */ +#define DECLARE_ENUM_AS_ADDABLE(EnumType) \ + template , OtherEnumType>::type> \ + constexpr OtherEnumType operator + (OtherEnumType m1, EnumType m2) { \ + return static_cast(static_cast::type>(m1) + static_cast::type>(m2)); \ + } /** * Informative template class exposing basic enumeration properties used by several diff --git a/src/core/geometry_type.hpp b/src/core/geometry_type.hpp index ce3caee3d9..98d9c6f073 100644 --- a/src/core/geometry_type.hpp +++ b/src/core/geometry_type.hpp @@ -57,13 +57,13 @@ struct RectPadding { * Get total horizontal padding of RectPadding. * @return total horizontal padding. */ - inline uint Horizontal() const { return this->left + this->right; } + constexpr uint Horizontal() const { return this->left + this->right; } /** * Get total vertical padding of RectPadding. * @return total vertical padding. */ - inline uint Vertical() const { return this->top + this->bottom; } + constexpr uint Vertical() const { return this->top + this->bottom; } }; inline const RectPadding RectPadding::zero{}; diff --git a/src/currency.cpp b/src/currency.cpp index 02374cd85f..93fc36db25 100644 --- a/src/currency.cpp +++ b/src/currency.cpp @@ -26,49 +26,49 @@ * | | | | | | | | */ /** The original currency specifications. */ static const CurrencySpec origin_currency_specs[CURRENCY_END] = { - { 1, "", CF_NOEURO, u8"\u00a3", "", "GBP", 0, STR_GAME_OPTIONS_CURRENCY_GBP }, ///< british pound - { 2, "", CF_NOEURO, "$", "", "USD", 0, STR_GAME_OPTIONS_CURRENCY_USD }, ///< american dollar - { 2, "", CF_ISEURO, u8"\u20ac", "", "EUR", 0, STR_GAME_OPTIONS_CURRENCY_EUR }, ///< euro - { 220, "", CF_NOEURO, u8"\u00a5", "", "JPY", 0, STR_GAME_OPTIONS_CURRENCY_JPY }, ///< japanese yen - { 27, "", 2002, "", NBSP "S.", "ATS", 1, STR_GAME_OPTIONS_CURRENCY_ATS }, ///< austrian schilling - { 81, "", 2002, "BEF" NBSP, "", "BEF", 0, STR_GAME_OPTIONS_CURRENCY_BEF }, ///< belgian franc - { 2, "", CF_NOEURO, "CHF" NBSP, "", "CHF", 0, STR_GAME_OPTIONS_CURRENCY_CHF }, ///< swiss franc - { 41, "", CF_NOEURO, "", NBSP u8"K\u010d", "CZK", 1, STR_GAME_OPTIONS_CURRENCY_CZK }, ///< czech koruna - { 4, "", 2002, "DM" NBSP, "", "DEM", 0, STR_GAME_OPTIONS_CURRENCY_DEM }, ///< deutsche mark - { 11, "", CF_NOEURO, "", NBSP "kr", "DKK", 1, STR_GAME_OPTIONS_CURRENCY_DKK }, ///< danish krone - { 333, "", 2002, "Pts" NBSP, "", "ESP", 0, STR_GAME_OPTIONS_CURRENCY_ESP }, ///< spanish peseta - { 12, "", 2002, "", NBSP "mk", "FIM", 1, STR_GAME_OPTIONS_CURRENCY_FIM }, ///< finnish markka - { 13, "", 2002, "FF" NBSP, "", "FRF", 0, STR_GAME_OPTIONS_CURRENCY_FRF }, ///< french franc - { 681, "", 2002, "", "Dr.", "GRD", 1, STR_GAME_OPTIONS_CURRENCY_GRD }, ///< greek drachma - { 378, "", CF_NOEURO, "", NBSP "Ft", "HUF", 1, STR_GAME_OPTIONS_CURRENCY_HUF }, ///< hungarian forint - { 130, "", CF_NOEURO, "", NBSP "Kr", "ISK", 1, STR_GAME_OPTIONS_CURRENCY_ISK }, ///< icelandic krona - { 3873, "", 2002, "", NBSP "L.", "ITL", 1, STR_GAME_OPTIONS_CURRENCY_ITL }, ///< italian lira - { 4, "", 2002, "NLG" NBSP, "", "NLG", 0, STR_GAME_OPTIONS_CURRENCY_NLG }, ///< dutch gulden - { 12, "", CF_NOEURO, "", NBSP "Kr", "NOK", 1, STR_GAME_OPTIONS_CURRENCY_NOK }, ///< norwegian krone - { 6, "", CF_NOEURO, "", NBSP u8"z\u0142", "PLN", 1, STR_GAME_OPTIONS_CURRENCY_PLN }, ///< polish zloty - { 5, "", CF_NOEURO, "", NBSP "Lei", "RON", 1, STR_GAME_OPTIONS_CURRENCY_RON }, ///< romanian leu - { 50, "", CF_NOEURO, "", NBSP "p", "RUR", 1, STR_GAME_OPTIONS_CURRENCY_RUR }, ///< russian rouble - { 479, "", 2007, "", NBSP "SIT", "SIT", 1, STR_GAME_OPTIONS_CURRENCY_SIT }, ///< slovenian tolar - { 13, "", CF_NOEURO, "", NBSP "Kr", "SEK", 1, STR_GAME_OPTIONS_CURRENCY_SEK }, ///< swedish krona - { 3, "", CF_NOEURO, "", NBSP "TL", "TRY", 1, STR_GAME_OPTIONS_CURRENCY_TRY }, ///< turkish lira - { 60, "", 2009, "", NBSP "Sk", "SKK", 1, STR_GAME_OPTIONS_CURRENCY_SKK }, ///< slovak koruna - { 4, "", CF_NOEURO, "R$" NBSP, "", "BRL", 0, STR_GAME_OPTIONS_CURRENCY_BRL }, ///< brazil real - { 31, "", 2011, "", NBSP "EEK", "EEK", 1, STR_GAME_OPTIONS_CURRENCY_EEK }, ///< estonian krooni - { 4, "", 2015, "", NBSP "Lt", "LTL", 1, STR_GAME_OPTIONS_CURRENCY_LTL }, ///< lithuanian litas - { 1850, "", CF_NOEURO, u8"\u20a9", "", "KRW", 0, STR_GAME_OPTIONS_CURRENCY_KRW }, ///< south korean won - { 13, "", CF_NOEURO, "R" NBSP, "", "ZAR", 0, STR_GAME_OPTIONS_CURRENCY_ZAR }, ///< south african rand - { 1, "", CF_NOEURO, "", "", "", 2, STR_GAME_OPTIONS_CURRENCY_CUSTOM }, ///< custom currency (add further languages below) - { 3, "", CF_NOEURO, "", NBSP "GEL", "GEL", 1, STR_GAME_OPTIONS_CURRENCY_GEL }, ///< Georgian Lari - { 4901, "", CF_NOEURO, "", NBSP "Rls", "IRR", 1, STR_GAME_OPTIONS_CURRENCY_IRR }, ///< Iranian Rial - { 80, "", CF_NOEURO, "", NBSP "rub", "RUB", 1, STR_GAME_OPTIONS_CURRENCY_RUB }, ///< New Russian Ruble - { 24, "", CF_NOEURO, "$", "", "MXN", 0, STR_GAME_OPTIONS_CURRENCY_MXN }, ///< Mexican peso - { 40, "", CF_NOEURO, "NTD" NBSP, "", "NTD", 0, STR_GAME_OPTIONS_CURRENCY_NTD }, ///< new taiwan dollar - { 8, "", CF_NOEURO, u8"\u00a5", "", "CNY", 0, STR_GAME_OPTIONS_CURRENCY_CNY }, ///< chinese renminbi - { 10, "", CF_NOEURO, "HKD" NBSP, "", "HKD", 0, STR_GAME_OPTIONS_CURRENCY_HKD }, ///< hong kong dollar - { 90, "", CF_NOEURO, u8"\u20b9", "", "INR", 0, STR_GAME_OPTIONS_CURRENCY_INR }, ///< Indian Rupee - { 19, "", CF_NOEURO, "Rp", "", "IDR", 0, STR_GAME_OPTIONS_CURRENCY_IDR }, ///< Indonesian Rupiah - { 5, "", CF_NOEURO, "RM", "", "MYR", 0, STR_GAME_OPTIONS_CURRENCY_MYR }, ///< Malaysian Ringgit - { 1, "", 2014, "", NBSP "Ls", "LVL", 1, STR_GAME_OPTIONS_CURRENCY_LVL }, ///< latvian lats + { 1, "", CF_NOEURO, "\u00a3", "", "GBP", 0, STR_GAME_OPTIONS_CURRENCY_GBP }, ///< british pound + { 2, "", CF_NOEURO, "$", "", "USD", 0, STR_GAME_OPTIONS_CURRENCY_USD }, ///< american dollar + { 2, "", CF_ISEURO, "\u20ac", "", "EUR", 0, STR_GAME_OPTIONS_CURRENCY_EUR }, ///< euro + { 220, "", CF_NOEURO, "\u00a5", "", "JPY", 0, STR_GAME_OPTIONS_CURRENCY_JPY }, ///< japanese yen + { 27, "", 2002, "", NBSP "S.", "ATS", 1, STR_GAME_OPTIONS_CURRENCY_ATS }, ///< austrian schilling + { 81, "", 2002, "BEF" NBSP, "", "BEF", 0, STR_GAME_OPTIONS_CURRENCY_BEF }, ///< belgian franc + { 2, "", CF_NOEURO, "CHF" NBSP, "", "CHF", 0, STR_GAME_OPTIONS_CURRENCY_CHF }, ///< swiss franc + { 41, "", CF_NOEURO, "", NBSP "K\u010d", "CZK", 1, STR_GAME_OPTIONS_CURRENCY_CZK }, ///< czech koruna + { 4, "", 2002, "DM" NBSP, "", "DEM", 0, STR_GAME_OPTIONS_CURRENCY_DEM }, ///< deutsche mark + { 11, "", CF_NOEURO, "", NBSP "kr", "DKK", 1, STR_GAME_OPTIONS_CURRENCY_DKK }, ///< danish krone + { 333, "", 2002, "Pts" NBSP, "", "ESP", 0, STR_GAME_OPTIONS_CURRENCY_ESP }, ///< spanish peseta + { 12, "", 2002, "", NBSP "mk", "FIM", 1, STR_GAME_OPTIONS_CURRENCY_FIM }, ///< finnish markka + { 13, "", 2002, "FF" NBSP, "", "FRF", 0, STR_GAME_OPTIONS_CURRENCY_FRF }, ///< french franc + { 681, "", 2002, "", "Dr.", "GRD", 1, STR_GAME_OPTIONS_CURRENCY_GRD }, ///< greek drachma + { 378, "", CF_NOEURO, "", NBSP "Ft", "HUF", 1, STR_GAME_OPTIONS_CURRENCY_HUF }, ///< hungarian forint + { 130, "", CF_NOEURO, "", NBSP "Kr", "ISK", 1, STR_GAME_OPTIONS_CURRENCY_ISK }, ///< icelandic krona + { 3873, "", 2002, "", NBSP "L.", "ITL", 1, STR_GAME_OPTIONS_CURRENCY_ITL }, ///< italian lira + { 4, "", 2002, "NLG" NBSP, "", "NLG", 0, STR_GAME_OPTIONS_CURRENCY_NLG }, ///< dutch gulden + { 12, "", CF_NOEURO, "", NBSP "Kr", "NOK", 1, STR_GAME_OPTIONS_CURRENCY_NOK }, ///< norwegian krone + { 6, "", CF_NOEURO, "", NBSP "z\u0142", "PLN", 1, STR_GAME_OPTIONS_CURRENCY_PLN }, ///< polish zloty + { 5, "", CF_NOEURO, "", NBSP "Lei", "RON", 1, STR_GAME_OPTIONS_CURRENCY_RON }, ///< romanian leu + { 50, "", CF_NOEURO, "", NBSP "p", "RUR", 1, STR_GAME_OPTIONS_CURRENCY_RUR }, ///< russian rouble + { 479, "", 2007, "", NBSP "SIT", "SIT", 1, STR_GAME_OPTIONS_CURRENCY_SIT }, ///< slovenian tolar + { 13, "", CF_NOEURO, "", NBSP "Kr", "SEK", 1, STR_GAME_OPTIONS_CURRENCY_SEK }, ///< swedish krona + { 3, "", CF_NOEURO, "", NBSP "TL", "TRY", 1, STR_GAME_OPTIONS_CURRENCY_TRY }, ///< turkish lira + { 60, "", 2009, "", NBSP "Sk", "SKK", 1, STR_GAME_OPTIONS_CURRENCY_SKK }, ///< slovak koruna + { 4, "", CF_NOEURO, "R$" NBSP, "", "BRL", 0, STR_GAME_OPTIONS_CURRENCY_BRL }, ///< brazil real + { 31, "", 2011, "", NBSP "EEK", "EEK", 1, STR_GAME_OPTIONS_CURRENCY_EEK }, ///< estonian krooni + { 4, "", 2015, "", NBSP "Lt", "LTL", 1, STR_GAME_OPTIONS_CURRENCY_LTL }, ///< lithuanian litas + { 1850, "", CF_NOEURO, "\u20a9", "", "KRW", 0, STR_GAME_OPTIONS_CURRENCY_KRW }, ///< south korean won + { 13, "", CF_NOEURO, "R" NBSP, "", "ZAR", 0, STR_GAME_OPTIONS_CURRENCY_ZAR }, ///< south african rand + { 1, "", CF_NOEURO, "", "", "", 2, STR_GAME_OPTIONS_CURRENCY_CUSTOM }, ///< custom currency (add further languages below) + { 3, "", CF_NOEURO, "", NBSP "GEL", "GEL", 1, STR_GAME_OPTIONS_CURRENCY_GEL }, ///< Georgian Lari + { 4901, "", CF_NOEURO, "", NBSP "Rls", "IRR", 1, STR_GAME_OPTIONS_CURRENCY_IRR }, ///< Iranian Rial + { 80, "", CF_NOEURO, "", NBSP "rub", "RUB", 1, STR_GAME_OPTIONS_CURRENCY_RUB }, ///< New Russian Ruble + { 24, "", CF_NOEURO, "$", "", "MXN", 0, STR_GAME_OPTIONS_CURRENCY_MXN }, ///< Mexican peso + { 40, "", CF_NOEURO, "NTD" NBSP, "", "NTD", 0, STR_GAME_OPTIONS_CURRENCY_NTD }, ///< new taiwan dollar + { 8, "", CF_NOEURO, "\u00a5", "", "CNY", 0, STR_GAME_OPTIONS_CURRENCY_CNY }, ///< chinese renminbi + { 10, "", CF_NOEURO, "HKD" NBSP, "", "HKD", 0, STR_GAME_OPTIONS_CURRENCY_HKD }, ///< hong kong dollar + { 90, "", CF_NOEURO, "\u20b9", "", "INR", 0, STR_GAME_OPTIONS_CURRENCY_INR }, ///< Indian Rupee + { 19, "", CF_NOEURO, "Rp", "", "IDR", 0, STR_GAME_OPTIONS_CURRENCY_IDR }, ///< Indonesian Rupiah + { 5, "", CF_NOEURO, "RM", "", "MYR", 0, STR_GAME_OPTIONS_CURRENCY_MYR }, ///< Malaysian Ringgit + { 1, "", 2014, "", NBSP "Ls", "LVL", 1, STR_GAME_OPTIONS_CURRENCY_LVL }, ///< latvian lats }; /** Array of currencies used by the system */ diff --git a/src/date_gui.cpp b/src/date_gui.cpp index df47ff2a2c..9bb03b7c47 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -301,7 +301,7 @@ struct SetMinutesWindow : SetDateWindow }; /** Widgets for the date setting window. */ -static const NWidgetPart _nested_set_date_widgets[] = { +static constexpr NWidgetPart _nested_set_date_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_DATE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -322,7 +322,7 @@ static const NWidgetPart _nested_set_date_widgets[] = { EndContainer() }; -static const NWidgetPart _nested_set_minutes_widgets[] = { +static constexpr NWidgetPart _nested_set_minutes_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_TIME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 4214e6be6c..c74cfbf841 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -38,7 +38,7 @@ #include "table/sprites.h" #include "table/strings.h" -static const NWidgetPart _nested_departures_list[] = { +static constexpr NWidgetPart _nested_departures_list[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_DB_CAPTION), SetDataTip(STR_DEPARTURES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 73d8ec2a57..86e44feef9 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -45,7 +45,7 @@ */ /** Nested widget definition for train depots. */ -static const NWidgetPart _nested_train_depot_widgets[] = { +static constexpr NWidgetPart _nested_train_depot_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_D_SHOW_RENAME), // rename button diff --git a/src/direction_func.h b/src/direction_func.h index d070e27e74..ef440d7bfb 100644 --- a/src/direction_func.h +++ b/src/direction_func.h @@ -71,7 +71,7 @@ inline DirDiff DirDifference(Direction d0, Direction d1) dbg_assert(IsValidDirection(d1)); /* Cast to uint so compiler can use bitmask. If the difference is negative * and we used int instead of uint, further "+ 8" would have to be added. */ - return (DirDiff)((uint)(d0 - d1) % 8); + return static_cast((static_cast(d0) - static_cast(d1)) % 8); } /** @@ -88,7 +88,7 @@ inline DirDiff DirDifference(Direction d0, Direction d1) inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta) { /* Cast to uint so compiler can use bitmask. Result can never be negative. */ - return (DirDiff)((uint)(d + delta) % 8); + return static_cast((static_cast(d) + static_cast(delta)) % 8); } /** @@ -105,7 +105,7 @@ inline Direction ChangeDir(Direction d, DirDiff delta) { dbg_assert(IsValidDirection(d)); /* Cast to uint so compiler can use bitmask. Result can never be negative. */ - return (Direction)((uint)(d + delta) % 8); + return static_cast((static_cast(d) + static_cast(delta)) % 8); } @@ -150,7 +150,7 @@ inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta) { dbg_assert(IsValidDiagDirection(d)); /* Cast to uint so compiler can use bitmask. Result can never be negative. */ - return (DiagDirection)((uint)(d + delta) % 4); + return static_cast((static_cast(d) + static_cast(delta)) % 4); } /** @@ -296,7 +296,7 @@ inline DiagDirection DirToDiagDirAlongAxis(Direction dir, Axis axis) * X 4, 5, 6 -> 2 0, 1, 2 -> 0 * Y 2, 3, 4 -> 1 0, 6, 7 -> 3 */ - return (DiagDirection)((((dir - axis) & 4) >> 1) | axis); + return (DiagDirection)((((static_cast(dir) - static_cast(axis)) & 4) >> 1) | axis); } #endif /* DIRECTION_FUNC_H */ diff --git a/src/direction_type.h b/src/direction_type.h index a3f9e24e5a..7dc0ea823e 100644 --- a/src/direction_type.h +++ b/src/direction_type.h @@ -83,9 +83,8 @@ enum DiagDirection : byte { DIAGDIR_END, ///< Used for iterations INVALID_DIAGDIR = 0xFF, ///< Flag for an invalid DiagDirection }; - -/** Allow incrementing of DiagDirection variables */ DECLARE_POSTFIX_INCREMENT(DiagDirection) +DECLARE_ENUM_AS_ADDABLE(DiagDirection) /** Define basic enum properties */ template <> struct EnumPropsT : MakeEnumPropsT {}; @@ -128,5 +127,6 @@ enum Axis : byte { }; /** Helper information for extract tool. */ template <> struct EnumPropsT : MakeEnumPropsT {}; +DECLARE_ENUM_AS_ADDABLE(Axis) #endif /* DIRECTION_TYPE_H */ diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index ccfc4bdf1e..ab5ce99d3f 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -326,7 +326,7 @@ HotkeyList BuildDocksToolbarWindow::hotkeys("dockstoolbar", dockstoolbar_hotkeys * Nested widget parts of docks toolbar, game version. * Position of #WID_DT_RIVER widget has changed. */ -static const NWidgetPart _nested_build_docks_toolbar_widgets[] = { +static constexpr NWidgetPart _nested_build_docks_toolbar_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -374,7 +374,7 @@ Window *ShowBuildDocksToolbar() * Nested widget parts of docks toolbar, scenario editor version. * Positions of #WID_DT_DEPOT, #WID_DT_STATION, and #WID_DT_BUOY widgets have changed. */ -static const NWidgetPart _nested_build_docks_scen_toolbar_widgets[] = { +static constexpr NWidgetPart _nested_build_docks_scen_toolbar_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WATERWAYS_TOOLBAR_CAPTION_SE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -479,7 +479,7 @@ public: }; /** Nested widget parts of a build dock station window. */ -static const NWidgetPart _nested_build_dock_station_widgets[] = { +static constexpr NWidgetPart _nested_build_dock_station_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_DOCK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -525,7 +525,7 @@ public: BuildDocksDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { this->InitNested(TRANSPORT_WATER); - this->LowerWidget(_ship_depot_direction + WID_BDD_X); + this->LowerWidget(WID_BDD_X + _ship_depot_direction); UpdateDocksDirection(); } @@ -569,9 +569,9 @@ public: switch (widget) { case WID_BDD_X: case WID_BDD_Y: - this->RaiseWidget(_ship_depot_direction + WID_BDD_X); + this->RaiseWidget(WID_BDD_X + _ship_depot_direction); _ship_depot_direction = (widget == WID_BDD_X ? AXIS_X : AXIS_Y); - this->LowerWidget(_ship_depot_direction + WID_BDD_X); + this->LowerWidget(WID_BDD_X + _ship_depot_direction); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); UpdateDocksDirection(); this->SetDirty(); @@ -580,7 +580,7 @@ public: } }; -static const NWidgetPart _nested_build_docks_depot_widgets[] = { +static constexpr NWidgetPart _nested_build_docks_depot_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_DEPOT_BUILD_SHIP_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index e735835475..7a86c9bc02 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -50,7 +50,7 @@ StringID GetEngineCategoryName(EngineID engine) } } -static const NWidgetPart _nested_engine_preview_widgets[] = { +static constexpr NWidgetPart _nested_engine_preview_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE), NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_ENGINE_PREVIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 2916163468..44164fa169 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -32,7 +32,7 @@ #include "safeguards.h" -static const NWidgetPart _nested_errmsg_widgets[] = { +static constexpr NWidgetPart _nested_errmsg_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_RED), NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION, STR_NULL), @@ -49,7 +49,7 @@ static WindowDesc _errmsg_desc(__FILE__, __LINE__, std::begin(_nested_errmsg_widgets), std::end(_nested_errmsg_widgets) ); -static const NWidgetPart _nested_errmsg_face_widgets[] = { +static constexpr NWidgetPart _nested_errmsg_face_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_RED), NWidget(WWT_CAPTION, COLOUR_RED, WID_EM_CAPTION), SetDataTip(STR_ERROR_MESSAGE_CAPTION_OTHER_COMPANY, STR_NULL), diff --git a/src/fileio_type.h b/src/fileio_type.h index 14acf07971..66d502d88a 100644 --- a/src/fileio_type.h +++ b/src/fileio_type.h @@ -89,7 +89,7 @@ enum FiosType { */ inline AbstractFileType GetAbstractFileType(FiosType fios_type) { - return static_cast(fios_type & FT_MASK); + return static_cast(static_cast(fios_type) & FT_MASK); } /** diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index 63a2b74500..87db5daae0 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -70,7 +70,7 @@ void LoadCheckData::Clear() } /** Load game/scenario with optional content download */ -static const NWidgetPart _nested_load_dialog_widgets[] = { +static constexpr NWidgetPart _nested_load_dialog_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION), @@ -131,7 +131,7 @@ static const NWidgetPart _nested_load_dialog_widgets[] = { }; /** Load heightmap with content download */ -static const NWidgetPart _nested_load_heightmap_dialog_widgets[] = { +static constexpr NWidgetPart _nested_load_heightmap_dialog_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION), @@ -176,7 +176,7 @@ static const NWidgetPart _nested_load_heightmap_dialog_widgets[] = { }; /** Save game/scenario */ -static const NWidgetPart _nested_save_dialog_widgets[] = { +static constexpr NWidgetPart _nested_save_dialog_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION), diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index e760a2681a..249d6b953c 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -363,7 +363,7 @@ static const char * GetAIName(int ai_index) } /** @hideinitializer */ -static const NWidgetPart _framerate_window_widgets[] = { +static constexpr NWidgetPart _framerate_window_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_FRW_CAPTION), SetDataTip(STR_FRAMERATE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -730,7 +730,7 @@ static WindowDesc _framerate_display_desc(__FILE__, __LINE__, /** @hideinitializer */ -static const NWidgetPart _frametime_graph_window_widgets[] = { +static constexpr NWidgetPart _frametime_graph_window_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_FGW_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE), diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index 55a8c95e05..0d6302795f 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -29,7 +29,7 @@ /** Widgets for the configure GS window. */ -static const NWidgetPart _nested_gs_config_widgets[] = { +static constexpr NWidgetPart _nested_gs_config_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_AI_CONFIG_CAPTION_GAMESCRIPT, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index ffe88d7693..508db423eb 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -70,7 +70,7 @@ void SetNewLandscapeType(byte landscape) } /** Widgets of GenerateLandscapeWindow when generating world */ -static const NWidgetPart _nested_generate_landscape_widgets[] = { +static constexpr NWidgetPart _nested_generate_landscape_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MAPGEN_WORLD_GENERATION_CAPTION, STR_NULL), @@ -208,7 +208,7 @@ static const NWidgetPart _nested_generate_landscape_widgets[] = { }; /** Widgets of GenerateLandscapeWindow when loading heightmap */ -static const NWidgetPart _nested_heightmap_load_widgets[] = { +static constexpr NWidgetPart _nested_heightmap_load_widgets[] = { /* Window header. */ NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), @@ -1408,7 +1408,7 @@ struct CreateScenarioWindow : public Window } }; -static const NWidgetPart _nested_create_scenario_widgets[] = { +static constexpr NWidgetPart _nested_create_scenario_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_SE_MAPGEN_CAPTION, STR_NULL), @@ -1481,7 +1481,7 @@ void ShowCreateScenario() new CreateScenarioWindow(&_create_scenario_desc, GLWM_SCENARIO); } -static const NWidgetPart _nested_generate_progress_widgets[] = { +static constexpr NWidgetPart _nested_generate_progress_widgets[] = { NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GENERATION_WORLD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), NWidget(WWT_PANEL, COLOUR_GREY), NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.modalpopup), diff --git a/src/gfx_type.h b/src/gfx_type.h index 8ae732a436..e9c44d7c4e 100644 --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -249,6 +249,7 @@ enum Colours : uint8_t { INVALID_COLOUR = 0xFF, }; template <> struct EnumPropsT : MakeEnumPropsT {}; +DECLARE_ENUM_AS_ADDABLE(Colours) /** Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palette.png */ enum TextColour { diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index c93ade358a..fa1b0ea58e 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -280,7 +280,7 @@ struct GoalListWindow : public Window { }; /** Widgets of the #GoalListWindow. */ -static const NWidgetPart _nested_goals_list_widgets[] = { +static constexpr NWidgetPart _nested_goals_list_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN, WID_GOAL_CAPTION), SetDataTip(STR_JUST_STRING1, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -406,7 +406,7 @@ struct GoalQuestionWindow : public Window { }; /** Widgets of the goal question window. */ -static const NWidgetPart _nested_goal_question_widgets_question[] = { +static constexpr NWidgetPart _nested_goal_question_widgets_question[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE), NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE, WID_GQ_CAPTION), SetDataTip(STR_GOAL_QUESTION_CAPTION_QUESTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -432,7 +432,7 @@ static const NWidgetPart _nested_goal_question_widgets_question[] = { EndContainer(), }; -static const NWidgetPart _nested_goal_question_widgets_info[] = { +static constexpr NWidgetPart _nested_goal_question_widgets_info[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE), NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE, WID_GQ_CAPTION), SetDataTip(STR_GOAL_QUESTION_CAPTION_INFORMATION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -458,7 +458,7 @@ static const NWidgetPart _nested_goal_question_widgets_info[] = { EndContainer(), }; -static const NWidgetPart _nested_goal_question_widgets_warning[] = { +static constexpr NWidgetPart _nested_goal_question_widgets_warning[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_YELLOW), NWidget(WWT_CAPTION, COLOUR_YELLOW, WID_GQ_CAPTION), SetDataTip(STR_GOAL_QUESTION_CAPTION_WARNING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -484,7 +484,7 @@ static const NWidgetPart _nested_goal_question_widgets_warning[] = { EndContainer(), }; -static const NWidgetPart _nested_goal_question_widgets_error[] = { +static constexpr NWidgetPart _nested_goal_question_widgets_error[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_RED), NWidget(WWT_CAPTION, COLOUR_RED, WID_GQ_CAPTION), SetDataTip(STR_GOAL_QUESTION_CAPTION_ERROR, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index d2bb26b255..43c25ef552 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -53,7 +53,7 @@ struct GraphLegendWindow : Window { this->InitNested(window_number); for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { - if (!HasBit(_legend_excluded_companies, c)) this->LowerWidget(c + WID_GL_FIRST_COMPANY); + if (!HasBit(_legend_excluded_companies, c)) this->LowerWidget(WID_GL_FIRST_COMPANY + c); this->OnInvalidateData(c); } @@ -61,7 +61,7 @@ struct GraphLegendWindow : Window { void DrawWidget(const Rect &r, WidgetID widget) const override { - if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, MAX_COMPANIES + WID_GL_FIRST_COMPANY)) return; + if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, WID_GL_FIRST_COMPANY + MAX_COMPANIES)) return; CompanyID cid = (CompanyID)(widget - WID_GL_FIRST_COMPANY); @@ -81,7 +81,7 @@ struct GraphLegendWindow : Window { 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; + if (!IsInsideMM(widget, WID_GL_FIRST_COMPANY, WID_GL_FIRST_COMPANY + MAX_COMPANIES)) return; ToggleBit(_legend_excluded_companies, widget - WID_GL_FIRST_COMPANY); this->ToggleWidgetLoweredState(widget); @@ -129,7 +129,7 @@ static std::unique_ptr MakeNWidgetCompanyLines() return vert; } -static const NWidgetPart _nested_graph_legend_widgets[] = { +static constexpr NWidgetPart _nested_graph_legend_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_KEY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -651,7 +651,7 @@ struct OperatingProfitGraphWindow : BaseGraphWindow { } }; -static const NWidgetPart _nested_operating_profit_widgets[] = { +static constexpr NWidgetPart _nested_operating_profit_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_OPERATING_PROFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -702,7 +702,7 @@ struct IncomeGraphWindow : BaseGraphWindow { } }; -static const NWidgetPart _nested_income_graph_widgets[] = { +static constexpr NWidgetPart _nested_income_graph_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_INCOME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -995,7 +995,7 @@ struct DeliveredCargoGraphWindow : ExcludingCargoBaseGraphWindow { } }; -static const NWidgetPart _nested_delivered_cargo_graph_widgets[] = { +static constexpr NWidgetPart _nested_delivered_cargo_graph_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_CARGO_DELIVERED_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1064,7 +1064,7 @@ struct PerformanceHistoryGraphWindow : BaseGraphWindow { } }; -static const NWidgetPart _nested_performance_history_widgets[] = { +static constexpr NWidgetPart _nested_performance_history_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1114,7 +1114,7 @@ struct CompanyValueGraphWindow : BaseGraphWindow { } }; -static const NWidgetPart _nested_company_value_graph_widgets[] = { +static constexpr NWidgetPart _nested_company_value_graph_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_COMPANY_VALUES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1444,7 +1444,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } }; -static const NWidgetPart _nested_cargo_payment_rates_widgets[] = { +static constexpr NWidgetPart _nested_cargo_payment_rates_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1673,9 +1673,9 @@ struct PerformanceRatingDetailWindow : Window { if (IsInsideMM(widget, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST + 1)) { /* Is it no on disable? */ if (!this->IsWidgetDisabled(widget)) { - this->RaiseWidget(this->company + WID_PRD_COMPANY_FIRST); + this->RaiseWidget(WID_PRD_COMPANY_FIRST + this->company); this->company = (CompanyID)(widget - WID_PRD_COMPANY_FIRST); - this->LowerWidget(this->company + WID_PRD_COMPANY_FIRST); + this->LowerWidget(WID_PRD_COMPANY_FIRST + this->company); this->SetDirty(); } } @@ -1700,13 +1700,13 @@ struct PerformanceRatingDetailWindow : Window { if (!gui_scope) return; /* Disable the companies who are not active */ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) { - this->SetWidgetDisabledState(i + WID_PRD_COMPANY_FIRST, !Company::IsValidID(i)); + this->SetWidgetDisabledState(WID_PRD_COMPANY_FIRST + i, !Company::IsValidID(i)); } /* Check if the currently selected company is still active. */ if (this->company != INVALID_COMPANY && !Company::IsValidID(this->company)) { /* Raise the widget for the previous selection. */ - this->RaiseWidget(this->company + WID_PRD_COMPANY_FIRST); + this->RaiseWidget(WID_PRD_COMPANY_FIRST + this->company); this->company = INVALID_COMPANY; } @@ -1718,7 +1718,7 @@ struct PerformanceRatingDetailWindow : Window { } /* Make sure the widget is lowered */ - this->LowerWidget(this->company + WID_PRD_COMPANY_FIRST); + this->LowerWidget(WID_PRD_COMPANY_FIRST + this->company); } }; @@ -1761,7 +1761,7 @@ std::unique_ptr MakeCompanyButtonRowsGraphGUI() 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[] = { +static constexpr NWidgetPart _nested_performance_rating_detail_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_PERFORMANCE_DETAIL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2010,7 +2010,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow { }; -static const NWidgetPart _nested_station_cargo_widgets[] = { +static constexpr NWidgetPart _nested_station_cargo_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_SCG_CAPTION), SetDataTip(STR_GRAPH_STATION_CARGO_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 0d4a42328c..fc2ed925ae 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -37,7 +37,7 @@ #include "safeguards.h" -static const NWidgetPart _nested_group_widgets[] = { +static constexpr NWidgetPart _nested_group_widgets[] = { NWidget(NWID_HORIZONTAL), // Window header NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_GL_CAPTION), diff --git a/src/help_gui.cpp b/src/help_gui.cpp index 3c34b0fb0a..ab41674aaf 100644 --- a/src/help_gui.cpp +++ b/src/help_gui.cpp @@ -166,7 +166,7 @@ private: } }; -static const NWidgetPart _nested_helpwin_widgets[] = { +static constexpr NWidgetPart _nested_helpwin_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_HELP_WINDOW_CAPTION, STR_NULL), diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index dd23255f90..9e4a4d8526 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -207,7 +207,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow { } }; -static const NWidgetPart _nested_highscore_widgets[] = { +static constexpr NWidgetPart _nested_highscore_widgets[] = { NWidget(WWT_PANEL, COLOUR_BROWN, WID_H_BACKGROUND), SetResize(1, 1), EndContainer(), }; diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 0f352c0d46..9cce35cd48 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -254,7 +254,7 @@ void CcBuildIndustry(const CommandCost &result, TileIndex tile, uint32_t p1, uin } } -static const NWidgetPart _nested_build_industry_widgets[] = { +static constexpr NWidgetPart _nested_build_industry_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_FUND_INDUSTRY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1170,7 +1170,7 @@ static void UpdateIndustryProduction(Industry *i) } /** Widget definition of the view industry gui */ -static const NWidgetPart _nested_industry_view_widgets[] = { +static constexpr NWidgetPart _nested_industry_view_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_CREAM), NWidget(WWT_CAPTION, COLOUR_CREAM, WID_IV_CAPTION), SetDataTip(STR_INDUSTRY_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1207,7 +1207,7 @@ void ShowIndustryViewWindow(int industry) } /** Widget definition of the industry directory gui */ -static const NWidgetPart _nested_industry_directory_widgets[] = { +static constexpr NWidgetPart _nested_industry_directory_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_INDUSTRY_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1918,7 +1918,7 @@ void ShowIndustryDirectory() } /** Widgets of the industry cargoes window. */ -static const NWidgetPart _nested_industry_cargoes_widgets[] = { +static constexpr NWidgetPart _nested_industry_cargoes_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN, WID_IC_CAPTION), SetDataTip(STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp index 1ca0bc2ee8..7fcaf9a28f 100644 --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -378,7 +378,7 @@ struct SelectGameWindow : public Window { } }; -static const NWidgetPart _nested_select_game_widgets[] = { +static constexpr NWidgetPart _nested_select_game_widgets[] = { NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_INTRO_CAPTION, STR_NULL), NWidget(WWT_PANEL, COLOUR_BROWN), NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.sparse), diff --git a/src/league_gui.cpp b/src/league_gui.cpp index 3faadad0c9..de02cfe8c2 100644 --- a/src/league_gui.cpp +++ b/src/league_gui.cpp @@ -186,7 +186,7 @@ public: } }; -static const NWidgetPart _nested_performance_league_widgets[] = { +static constexpr NWidgetPart _nested_performance_league_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_COMPANY_LEAGUE_TABLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -419,7 +419,7 @@ public: } }; -static const NWidgetPart _nested_script_league_widgets[] = { +static constexpr NWidgetPart _nested_script_league_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SLT_CAPTION), SetDataTip(STR_JUST_RAW_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index ad794e5d76..def3618f5f 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -736,7 +736,7 @@ std::unique_ptr MakeCargoesLegendLinkGraphGUI() } -static const NWidgetPart _nested_linkgraph_legend_widgets[] = { +static constexpr NWidgetPart _nested_linkgraph_legend_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_LGL_CAPTION), SetDataTip(STR_LINKGRAPH_LEGEND_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -897,9 +897,9 @@ bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, WidgetID widget, T void LinkGraphLegendWindow::UpdateOverlayCompanies() { uint32_t mask = 0; - for (uint c = 0; c < MAX_COMPANIES; c++) { - if (this->IsWidgetDisabled(c + WID_LGL_COMPANY_FIRST)) continue; - if (!this->IsWidgetLowered(c + WID_LGL_COMPANY_FIRST)) continue; + for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { + if (this->IsWidgetDisabled(WID_LGL_COMPANY_FIRST + c)) continue; + if (!this->IsWidgetLowered(WID_LGL_COMPANY_FIRST + c)) continue; SetBit(mask, c); } this->overlay->SetCompanyMask(mask); @@ -912,7 +912,7 @@ void LinkGraphLegendWindow::UpdateOverlayCargoes() { CargoTypes mask = 0; for (uint c = 0; c < num_cargo; c++) { - if (!this->IsWidgetLowered(c + WID_LGL_CARGO_FIRST)) continue; + if (!this->IsWidgetLowered(WID_LGL_CARGO_FIRST + c)) continue; SetBit(mask, _sorted_cargo_specs[c]->Index()); } this->overlay->SetCargoMask(mask); @@ -927,8 +927,8 @@ void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget, this->UpdateOverlayCompanies(); } } else if (widget == WID_LGL_COMPANIES_ALL || widget == WID_LGL_COMPANIES_NONE) { - for (uint c = 0; c < MAX_COMPANIES; c++) { - if (this->IsWidgetDisabled(c + WID_LGL_COMPANY_FIRST)) continue; + for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) { + if (this->IsWidgetDisabled(WID_LGL_COMPANY_FIRST + c)) continue; this->SetWidgetLoweredState(WID_LGL_COMPANY_FIRST + c, widget == WID_LGL_COMPANIES_ALL); } this->UpdateOverlayCompanies(); @@ -959,6 +959,6 @@ void LinkGraphLegendWindow::OnInvalidateData([[maybe_unused]] int data, [[maybe_ /* Disable the companies who are not active */ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) { - this->SetWidgetDisabledState(i + WID_LGL_COMPANY_FIRST, !Company::IsValidID(i)); + this->SetWidgetDisabledState(WID_LGL_COMPANY_FIRST + i, !Company::IsValidID(i)); } } diff --git a/src/livery.h b/src/livery.h index dc01c390a7..4ae1d1b235 100644 --- a/src/livery.h +++ b/src/livery.h @@ -61,7 +61,7 @@ DECLARE_POSTFIX_INCREMENT(LiveryScheme) template <> struct EnumPropsT : MakeEnumPropsT {}; /** List of different livery classes, used only by the livery GUI. */ -enum LiveryClass { +enum LiveryClass : byte { LC_OTHER, LC_RAIL, LC_ROAD, @@ -73,6 +73,7 @@ enum LiveryClass { LC_GROUP_AIRCRAFT, LC_END }; +DECLARE_ENUM_AS_ADDABLE(LiveryClass) /** Information about a particular livery. */ struct Livery { diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 7b5f576c1c..3bccda9b98 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -200,7 +200,7 @@ void FixTitleGameZoom(int zoom_adjust) UpdateViewportSizeZoom(vp); } -static const struct NWidgetPart _nested_main_window_widgets[] = { +static constexpr NWidgetPart _nested_main_window_widgets[] = { NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_M_VIEWPORT), SetResize(1, 1), }; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 5609b42ff6..424932ecb1 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -49,7 +49,7 @@ enum OskActivation { }; -static const NWidgetPart _nested_land_info_widgets[] = { +static constexpr NWidgetPart _nested_land_info_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_LAND_AREA_INFORMATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -412,7 +412,7 @@ void ShowLandInfo(TileIndex tile) new LandInfoWindow(tile); } -static const NWidgetPart _nested_about_widgets[] = { +static constexpr NWidgetPart _nested_about_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_ABOUT_OPENTTD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -438,73 +438,71 @@ static WindowDesc _about_desc(__FILE__, __LINE__, ); static const char * const _credits[] = { - u8"Original design by Chris Sawyer", - u8"Original graphics by Simon Foster", - u8"", - u8"The OpenTTD team (in alphabetical order):", - u8" Matthijs Kooijman (blathijs) - Pathfinder-guru, Debian port (since 0.3)", - u8" Christoph Elsenhans (frosch) - General coding (since 0.6)", - u8" Lo\u00efc Guilloux (glx) - General / Windows Expert (since 0.4.5)", - u8" Charles Pigott (LordAro) - General / Correctness police (since 1.9)", - u8" Michael Lutz (michi_cc) - Path based signals (since 0.7)", - u8" Niels Martin Hansen (nielsm) - Music system, general coding (since 1.9)", - u8" Owen Rudge (orudge) - Forum host, OS/2 port (since 0.1)", - u8" Peter Nelson (peter1138) - Spiritual descendant from NewGRF gods (since 0.4.5)", - u8" Remko Bijker (Rubidium) - Coder and way more (since 0.4.5)", - u8" Patric Stout (TrueBrain) - NoProgrammer (since 0.3), sys op", - u8" Tyler Trahan (2TallTyler) - General coding (since 13)", - u8"", - u8"Inactive Developers:", - u8" Grzegorz Duczy\u0144ski (adf88) - General coding (1.7 - 1.8)", - u8" Albert Hofkamp (Alberth) - GUI expert (0.7 - 1.9)", - u8" Jean-Fran\u00e7ois Claeys (Belugas) - GUI, NewGRF and more (0.4.5 - 1.0)", - u8" Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles (0.3 - 0.7)", - u8" Victor Fischer (Celestar) - Programming everywhere you need him to (0.3 - 0.6)", - u8" Ulf Hermann (fonsinchen) - Cargo Distribution (1.3 - 1.6)", - u8" Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;) (0.4.5 - 0.6)", - u8" Jonathan Coome (Maedhros) - High priest of the NewGRF Temple (0.5 - 0.6)", - u8" Attila B\u00e1n (MiHaMiX) - Developer WebTranslator 1 and 2 (0.3 - 0.5)", - u8" Ingo von Borstel (planetmaker) - General coding, Support (1.1 - 1.9)", - u8" Zden\u011bk Sojka (SmatZ) - Bug finder and fixer (0.6 - 1.3)", - u8" Jos\u00e9 Soler (Terkhen) - General coding (1.0 - 1.4)", - u8" Christoph Mallon (Tron) - Programmer, code correctness police (0.3 - 0.5)", - u8" Thijs Marinussen (Yexo) - AI Framework, General (0.6 - 1.3)", - u8" Leif Linse (Zuu) - AI/Game Script (1.2 - 1.6)", - u8"", - u8"Retired Developers:", - u8" Tam\u00e1s Farag\u00f3 (Darkvater) - Ex-Lead coder (0.3 - 0.5)", - u8" Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3 - 0.3)", - u8" Emil Djupfeld (egladil) - MacOSX (0.4.5 - 0.6)", - u8" Simon Sasburg (HackyKid) - Many bugfixes (0.4 - 0.4.5)", - u8" Ludvig Strigeus (ludde) - Original author of OpenTTD, main coder (0.1 - 0.3)", - u8" Cian Duffy (MYOB) - BeOS port / manual writing (0.1 - 0.3)", - u8" Petr Baudi\u0161 (pasky) - Many patches, NewGRF support (0.3 - 0.3)", - u8" Benedikt Br\u00fcggemeier (skidd13) - Bug fixer and code reworker (0.6 - 0.7)", - u8" Serge Paquet (vurlix) - 2nd contributor after ludde (0.1 - 0.3)", - u8"", - u8"Special thanks go out to:", - u8" Josef Drexler - For his great work on TTDPatch", - u8" Marcin Grzegorczyk - Track foundations and for describing TTD internals", - u8" Stefan Mei\u00dfner (sign_de) - For his work on the console", - u8" Mike Ragsdale - OpenTTD installer", - u8" Christian Rosentreter (tokai) - MorphOS / AmigaOS port", - u8" Richard Kempton (richK) - additional airports, initial TGP implementation", - u8" Alberto Demichelis - Squirrel scripting language \u00a9 2003-2008", - u8" L. Peter Deutsch - MD5 implementation \u00a9 1999, 2000, 2002", - u8" Michael Blunck - Pre-signals and semaphores \u00a9 2003", - u8" George - Canal/Lock graphics \u00a9 2003-2004", - u8" Andrew Parkhouse (andythenorth) - River graphics", - u8" David Dallaston (Pikka) - Tram tracks", - u8" All Translators - Who made OpenTTD a truly international game", - u8" Bug Reporters - Without whom OpenTTD would still be full of bugs!", - u8"", - u8"", - u8"Developer of this patchpack:", - u8" Jonathan G. Rennison (JGR)", - u8"", - u8"", - u8"And last but not least:", - u8" Chris Sawyer - For an amazing game!" + "Original design by Chris Sawyer", + "Original graphics by Simon Foster", + "", + "The OpenTTD team (in alphabetical order):", + " Matthijs Kooijman (blathijs) - Pathfinder-guru, Debian port (since 0.3)", + " Christoph Elsenhans (frosch) - General coding (since 0.6)", + " Lo\u00efc Guilloux (glx) - General / Windows Expert (since 0.4.5)", + " Charles Pigott (LordAro) - General / Correctness police (since 1.9)", + " Michael Lutz (michi_cc) - Path based signals (since 0.7)", + " Niels Martin Hansen (nielsm) - Music system, general coding (since 1.9)", + " Owen Rudge (orudge) - Forum host, OS/2 port (since 0.1)", + " Peter Nelson (peter1138) - Spiritual descendant from NewGRF gods (since 0.4.5)", + " Remko Bijker (Rubidium) - Coder and way more (since 0.4.5)", + " Patric Stout (TrueBrain) - NoProgrammer (since 0.3), sys op", + " Tyler Trahan (2TallTyler) - General coding (since 13)", + "", + "Inactive Developers:", + " Grzegorz Duczy\u0144ski (adf88) - General coding (1.7 - 1.8)", + " Albert Hofkamp (Alberth) - GUI expert (0.7 - 1.9)", + " Jean-Fran\u00e7ois Claeys (Belugas) - GUI, NewGRF and more (0.4.5 - 1.0)", + " Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles (0.3 - 0.7)", + " Victor Fischer (Celestar) - Programming everywhere you need him to (0.3 - 0.6)", + " Ulf Hermann (fonsinchen) - Cargo Distribution (1.3 - 1.6)", + " Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;) (0.4.5 - 0.6)", + " Jonathan Coome (Maedhros) - High priest of the NewGRF Temple (0.5 - 0.6)", + " Attila B\u00e1n (MiHaMiX) - Developer WebTranslator 1 and 2 (0.3 - 0.5)", + " Ingo von Borstel (planetmaker) - General coding, Support (1.1 - 1.9)", + " Zden\u011bk Sojka (SmatZ) - Bug finder and fixer (0.6 - 1.3)", + " Jos\u00e9 Soler (Terkhen) - General coding (1.0 - 1.4)", + " Christoph Mallon (Tron) - Programmer, code correctness police (0.3 - 0.5)", + " Thijs Marinussen (Yexo) - AI Framework, General (0.6 - 1.3)", + " Leif Linse (Zuu) - AI/Game Script (1.2 - 1.6)", + "", + "Retired Developers:", + " Tam\u00e1s Farag\u00f3 (Darkvater) - Ex-Lead coder (0.3 - 0.5)", + " Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3 - 0.3)", + " Emil Djupfeld (egladil) - MacOSX (0.4.5 - 0.6)", + " Simon Sasburg (HackyKid) - Many bugfixes (0.4 - 0.4.5)", + " Ludvig Strigeus (ludde) - Original author of OpenTTD, main coder (0.1 - 0.3)", + " Cian Duffy (MYOB) - BeOS port / manual writing (0.1 - 0.3)", + " Petr Baudi\u0161 (pasky) - Many patches, NewGRF support (0.3 - 0.3)", + " Benedikt Br\u00fcggemeier (skidd13) - Bug fixer and code reworker (0.6 - 0.7)", + " Serge Paquet (vurlix) - 2nd contributor after ludde (0.1 - 0.3)", + "", + "Special thanks go out to:", + " Josef Drexler - For his great work on TTDPatch", + " Marcin Grzegorczyk - Track foundations and for describing TTD internals", + " Stefan Mei\u00dfner (sign_de) - For his work on the console", + " Mike Ragsdale - OpenTTD installer", + " Christian Rosentreter (tokai) - MorphOS / AmigaOS port", + " Richard Kempton (richK) - additional airports, initial TGP implementation", + " Alberto Demichelis - Squirrel scripting language \u00a9 2003-2008", + " L. Peter Deutsch - MD5 implementation \u00a9 1999, 2000, 2002", + " Michael Blunck - Pre-signals and semaphores \u00a9 2003", + " George - Canal/Lock graphics \u00a9 2003-2004", + " Andrew Parkhouse (andythenorth) - River graphics", + " David Dallaston (Pikka) - Tram tracks", + " All Translators - Who made OpenTTD a truly international game", + " Bug Reporters - Without whom OpenTTD would still be full of bugs!", + "", + "Developer of this patchpack:", + " Jonathan G. Rennison (JGR)", + "", + "And last but not least:", + " Chris Sawyer - For an amazing game!" }; struct AboutWindow : public Window { @@ -692,7 +690,7 @@ void HideFillingPercent(TextEffectID *te_id) *te_id = INVALID_TE_ID; } -static const NWidgetPart _nested_tooltips_widgets[] = { +static constexpr NWidgetPart _nested_tooltips_widgets[] = { NWidget(WWT_EMPTY, INVALID_COLOUR, WID_TT_BACKGROUND), }; @@ -1125,7 +1123,7 @@ struct QueryStringWindow : public Window } }; -static const NWidgetPart _nested_query_string_widgets[] = { +static constexpr NWidgetPart _nested_query_string_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_QS_CAPTION), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_WHITE), @@ -1303,7 +1301,7 @@ struct QueryWindow : public Window { } }; -static const NWidgetPart _nested_query_widgets[] = { +static constexpr NWidgetPart _nested_query_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_RED), NWidget(WWT_CAPTION, COLOUR_RED, WID_Q_CAPTION), // The caption's string is set in the constructor @@ -1379,7 +1377,7 @@ void ShowQuery(std::string caption, std::string message, Window *parent, QueryCa if (focus) SetFocusedWindow(q); } -static const NWidgetPart _modifier_key_toggle_widgets[] = { +static constexpr NWidgetPart _modifier_key_toggle_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_MODIFIER_KEY_TOGGLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/music_gui.cpp b/src/music_gui.cpp index f16e802737..91586c7495 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -638,7 +638,7 @@ struct MusicTrackSelectionWindow : public Window { } }; -static const NWidgetPart _nested_music_track_selection_widgets[] = { +static constexpr NWidgetPart _nested_music_track_selection_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_MTS_CAPTION), SetDataTip(STR_PLAYLIST_MUSIC_SELECTION_SETNAME, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -870,7 +870,7 @@ struct MusicWindow : public Window { } }; -static const NWidgetPart _nested_music_window_widgets[] = { +static constexpr NWidgetPart _nested_music_window_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_MUSIC_JAZZ_JUKEBOX_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 61b1c595f4..8de529daf8 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -499,7 +499,7 @@ struct NetworkChatWindow : public Window { }; /** The widgets of the chat window. */ -static const NWidgetPart _nested_chat_window_widgets[] = { +static constexpr NWidgetPart _nested_chat_window_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY, WID_NC_CLOSE), NWidget(WWT_PANEL, COLOUR_GREY, WID_NC_BACKGROUND), diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 4d02a1cc67..35831a2437 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -81,7 +81,7 @@ void ShowContentTextfileWindow(TextfileType file_type, const ContentInfo *ci) } /** Nested widgets for the download window. */ -static const NWidgetPart _nested_network_content_download_status_window_widgets[] = { +static constexpr NWidgetPart _nested_network_content_download_status_window_widgets[] = { NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CONTENT_DOWNLOAD_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), NWidget(WWT_PANEL, COLOUR_GREY), NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.modalpopup), @@ -1036,7 +1036,7 @@ void BuildContentTypeStringList() } /** The widgets for the content list. */ -static const NWidgetPart _nested_network_content_list_widgets[] = { +static constexpr NWidgetPart _nested_network_content_list_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE), NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_CONTENT_TITLE, STR_NULL), diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 00b2cc09db..5c05722239 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -881,7 +881,7 @@ static std::unique_ptr MakeResizableHeader() return std::make_unique(); } -static const NWidgetPart _nested_network_game_widgets[] = { +static constexpr NWidgetPart _nested_network_game_widgets[] = { /* TOP */ NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE), @@ -1159,7 +1159,7 @@ struct NetworkStartServerWindow : public Window { } }; -static const NWidgetPart _nested_network_start_server_window_widgets[] = { +static constexpr NWidgetPart _nested_network_start_server_window_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE), NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_NETWORK_START_SERVER_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1247,7 +1247,7 @@ static void ShowNetworkStartServerWindow() extern void DrawCompanyIcon(CompanyID cid, int x, int y); -static const NWidgetPart _nested_client_list_widgets[] = { +static constexpr NWidgetPart _nested_client_list_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NETWORK_CLIENT_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2204,7 +2204,7 @@ struct NetworkJoinStatusWindow : Window { } }; -static const NWidgetPart _nested_network_join_status_window_widgets[] = { +static constexpr NWidgetPart _nested_network_join_status_window_widgets[] = { NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NETWORK_CONNECTING_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), NWidget(WWT_PANEL, COLOUR_GREY), NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.modalpopup), @@ -2312,7 +2312,7 @@ struct NetworkCompanyPasswordWindow : public Window { } }; -static const NWidgetPart _nested_network_company_password_window_widgets[] = { +static constexpr NWidgetPart _nested_network_company_password_window_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_COMPANY_PASSWORD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2429,7 +2429,7 @@ struct NetworkAskRelayWindow : public Window { } }; -static const NWidgetPart _nested_network_ask_relay_widgets[] = { +static constexpr NWidgetPart _nested_network_ask_relay_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_RED), NWidget(WWT_CAPTION, COLOUR_RED, WID_NAR_CAPTION), SetDataTip(STR_NETWORK_ASK_RELAY_CAPTION, STR_NULL), @@ -2524,7 +2524,7 @@ struct NetworkAskSurveyWindow : public Window { } }; -static const NWidgetPart _nested_network_ask_survey_widgets[] = { +static constexpr NWidgetPart _nested_network_ask_survey_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_NAS_CAPTION), SetDataTip(STR_NETWORK_ASK_SURVEY_CAPTION, STR_NULL), diff --git a/src/network/network_type.h b/src/network/network_type.h index 77c6915ecd..a875423b32 100644 --- a/src/network/network_type.h +++ b/src/network/network_type.h @@ -10,6 +10,8 @@ #ifndef NETWORK_TYPE_H #define NETWORK_TYPE_H +#include "../core/enum_type.hpp" + /** How many clients can we have */ static const uint MAX_CLIENTS = 255; @@ -86,12 +88,13 @@ enum NetworkPasswordType { * Destination of our chat messages. * @warning The values of the enum items are part of the admin network API. Only append at the end. */ -enum DestType { +enum DestType : byte { DESTTYPE_BROADCAST, ///< Send message/notice to all clients (All) DESTTYPE_TEAM, ///< Send message/notice to everyone playing the same company (Team) DESTTYPE_CLIENT, ///< Send message/notice to only a certain client (Private) DESTTYPE_BROADCAST_SS, ///< Send message/notice to all clients (All), but tag the broadcast to self as a self-send }; +DECLARE_ENUM_AS_ADDABLE(DestType) /** * Actions that can be used for NetworkTextMessage. diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index ae6eca7633..41d522dbec 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -1159,7 +1159,7 @@ struct NewGRFInspectWindow : Window { } }; -static const NWidgetPart _nested_newgrf_inspect_chain_widgets[] = { +static constexpr NWidgetPart _nested_newgrf_inspect_chain_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_NGRFI_CAPTION), SetDataTip(STR_NEWGRF_INSPECT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1196,7 +1196,7 @@ static const NWidgetPart _nested_newgrf_inspect_chain_widgets[] = { EndContainer(), }; -static const NWidgetPart _nested_newgrf_inspect_widgets[] = { +static constexpr NWidgetPart _nested_newgrf_inspect_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_NGRFI_CAPTION), SetDataTip(STR_NEWGRF_INSPECT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1662,7 +1662,7 @@ struct SpriteAlignerWindow : Window { bool SpriteAlignerWindow::centre = true; bool SpriteAlignerWindow::crosshair = true; -static const NWidgetPart _nested_sprite_aligner_widgets[] = { +static constexpr NWidgetPart _nested_sprite_aligner_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_SA_CAPTION), SetDataTip(STR_SPRITE_ALIGNER_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 0283aa2bd9..be41129dd8 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -521,7 +521,7 @@ struct NewGRFParametersWindow : public Window { GRFParameterInfo NewGRFParametersWindow::dummy_parameter_info(0); -static const NWidgetPart _nested_newgrf_parameter_widgets[] = { +static constexpr NWidgetPart _nested_newgrf_parameter_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), NWidget(WWT_CAPTION, COLOUR_MAUVE, WID_NP_CAPTION), @@ -1841,7 +1841,7 @@ public: const uint NWidgetNewGRFDisplay::MAX_EXTRA_INFO_WIDTH = 150; const uint NWidgetNewGRFDisplay::MIN_EXTRA_FOR_3_COLUMNS = 50; -static const NWidgetPart _nested_newgrf_actives_widgets[] = { +static constexpr NWidgetPart _nested_newgrf_actives_widgets[] = { NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), /* Left side, presets. */ NWidget(NWID_VERTICAL), @@ -1896,7 +1896,7 @@ static const NWidgetPart _nested_newgrf_actives_widgets[] = { EndContainer(), }; -static const NWidgetPart _nested_newgrf_availables_widgets[] = { +static constexpr NWidgetPart _nested_newgrf_availables_widgets[] = { NWidget(WWT_FRAME, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_INACTIVE_LIST, STR_NULL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), /* Left side, available grfs, filter edit box. */ NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0), @@ -1929,7 +1929,7 @@ static const NWidgetPart _nested_newgrf_availables_widgets[] = { EndContainer(), }; -static const NWidgetPart _nested_newgrf_infopanel_widgets[] = { +static constexpr NWidgetPart _nested_newgrf_infopanel_widgets[] = { NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), /* Right side, info panel. */ NWidget(WWT_PANEL, COLOUR_MAUVE), @@ -1982,7 +1982,7 @@ std::unique_ptr NewGRFDisplay() } /* Widget definition of the manage newgrfs window */ -static const NWidgetPart _nested_newgrf_widgets[] = { +static constexpr NWidgetPart _nested_newgrf_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_NEWGRF_SETTINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2065,7 +2065,7 @@ void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFC } /** Widget parts of the save preset window. */ -static const NWidgetPart _nested_save_preset_widgets[] = { +static constexpr NWidgetPart _nested_save_preset_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_SAVE_PRESET_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2219,7 +2219,7 @@ static void ShowSavePresetWindow(const char *initial_text) } /** Widgets for the progress window. */ -static const NWidgetPart _nested_scan_progress_widgets[] = { +static constexpr NWidgetPart _nested_scan_progress_widgets[] = { NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_NEWGRF_SCAN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), NWidget(WWT_PANEL, COLOUR_GREY), NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.modalpopup), diff --git a/src/news_gui.cpp b/src/news_gui.cpp index aeed218b0a..0678917cf8 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -80,7 +80,7 @@ static TileIndex GetReferenceTile(NewsReferenceType reftype, uint32_t ref) } /* Normal news items. */ -static const NWidgetPart _nested_normal_news_widgets[] = { +static constexpr NWidgetPart _nested_normal_news_widgets[] = { NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(WWT_CLOSEBOX, COLOUR_WHITE, WID_N_CLOSEBOX), SetPadding(0, 0, 0, 1), @@ -102,7 +102,7 @@ static WindowDesc _normal_news_desc(__FILE__, __LINE__, ); /* New vehicles news items. */ -static const NWidgetPart _nested_vehicle_news_widgets[] = { +static constexpr NWidgetPart _nested_vehicle_news_widgets[] = { NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(NWID_VERTICAL), @@ -129,7 +129,7 @@ static WindowDesc _vehicle_news_desc(__FILE__, __LINE__, ); /* Company news items. */ -static const NWidgetPart _nested_company_news_widgets[] = { +static constexpr NWidgetPart _nested_company_news_widgets[] = { NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(NWID_VERTICAL), @@ -157,7 +157,7 @@ static WindowDesc _company_news_desc(__FILE__, __LINE__, ); /* Thin news items. */ -static const NWidgetPart _nested_thin_news_widgets[] = { +static constexpr NWidgetPart _nested_thin_news_widgets[] = { NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(WWT_CLOSEBOX, COLOUR_WHITE, WID_N_CLOSEBOX), SetPadding(0, 0, 0, 1), @@ -180,7 +180,7 @@ static WindowDesc _thin_news_desc(__FILE__, __LINE__, ); /* Small news items. */ -static const NWidgetPart _nested_small_news_widgets[] = { +static constexpr NWidgetPart _nested_small_news_widgets[] = { /* Caption + close box. The caption is no WWT_CAPTION as the window shall not be moveable and so on. */ NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, WID_N_CLOSEBOX), @@ -1217,7 +1217,7 @@ struct MessageHistoryWindow : Window { } }; -static const NWidgetPart _nested_message_history[] = { +static constexpr NWidgetPart _nested_message_history[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_MESSAGE_HISTORY, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/object_gui.cpp b/src/object_gui.cpp index 18194fb22c..25fb51f343 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -706,7 +706,7 @@ BuildObjectWindow::GUIObjectClassList::FilterFunction * const BuildObjectWindow: &TagNameFilter, }; -static const NWidgetPart _nested_build_object_widgets[] = { +static constexpr NWidgetPart _nested_build_object_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_OBJECT_BUILD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 1a09837dc4..cb8548510b 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -377,7 +377,7 @@ static std::unique_ptr MakeCargoTypeOrdersRowsRight() } /** Widgets definition of CargoTypeOrdersWindow. */ -static const NWidgetPart _nested_cargo_type_orders_widgets[] = { +static constexpr NWidgetPart _nested_cargo_type_orders_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_CTO_CAPTION), SetDataTip(STR_NULL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -3652,7 +3652,7 @@ static Hotkey order_hotkeys[] = { HotkeyList OrdersWindow::hotkeys("order", order_hotkeys); /** Nested widget definition for "your" train orders. */ -static const NWidgetPart _nested_orders_train_widgets[] = { +static constexpr NWidgetPart _nested_orders_train_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -3801,7 +3801,7 @@ static WindowDesc _orders_train_desc(__FILE__, __LINE__, ); /** Nested widget definition for "your" orders (non-train). */ -static const NWidgetPart _nested_orders_widgets[] = { +static constexpr NWidgetPart _nested_orders_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -3953,7 +3953,7 @@ static WindowDesc _orders_desc(__FILE__, __LINE__, ); /** Nested widget definition for competitor orders. */ -static const NWidgetPart _nested_other_orders_widgets[] = { +static constexpr NWidgetPart _nested_other_orders_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index 2508121b53..f7f13d2685 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -318,7 +318,7 @@ static std::unique_ptr MakeSpacebarKeys() } -static const NWidgetPart _nested_osk_widgets[] = { +static constexpr NWidgetPart _nested_osk_widgets[] = { NWidget(WWT_CAPTION, COLOUR_GREY, WID_OSK_CAPTION), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_WHITE), NWidget(WWT_PANEL, COLOUR_GREY), NWidget(WWT_EDITBOX, COLOUR_GREY, WID_OSK_TEXT), SetMinimalSize(252, 12), SetPadding(2, 2, 2, 2), diff --git a/src/plans_gui.cpp b/src/plans_gui.cpp index 4e2c68a4e2..72823b2fd2 100644 --- a/src/plans_gui.cpp +++ b/src/plans_gui.cpp @@ -27,7 +27,7 @@ #include "table/strings.h" #include "table/sprites.h" -static const NWidgetPart _nested_plans_widgets[] = { +static constexpr NWidgetPart _nested_plans_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_PLN_CAPTION), SetDataTip(STR_PLANS_CAPTION, STR_NULL), diff --git a/src/programmable_signals_gui.cpp b/src/programmable_signals_gui.cpp index e11341b8ce..f89d3767cc 100644 --- a/src/programmable_signals_gui.cpp +++ b/src/programmable_signals_gui.cpp @@ -897,7 +897,7 @@ private: int current_aux_plane; }; -static const NWidgetPart _nested_program_widgets[] = { +static constexpr NWidgetPart _nested_program_widgets[] = { // Title bar NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 675035b6e2..4a04f65262 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1019,7 +1019,7 @@ static Hotkey railtoolbar_hotkeys[] = { }; HotkeyList BuildRailToolbarWindow::hotkeys("railtoolbar", railtoolbar_hotkeys, RailToolbarGlobalHotkeys); -static const NWidgetPart _nested_build_rail_widgets[] = { +static constexpr NWidgetPart _nested_build_rail_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_RAT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE), @@ -1238,12 +1238,12 @@ public: this->FinishInitNested(TRANSPORT_RAIL); - this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); + this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation); if (_settings_client.gui.station_dragdrop) { this->LowerWidget(WID_BRAS_PLATFORM_DRAG_N_DROP); } else { - this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN); - this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN); + this->LowerWidget(WID_BRAS_PLATFORM_NUM_BEGIN + _settings_client.gui.station_numtracks); + this->LowerWidget(WID_BRAS_PLATFORM_LEN_BEGIN + _settings_client.gui.station_platlength); } this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage); this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage); @@ -1570,9 +1570,9 @@ public: switch (widget) { case WID_BRAS_PLATFORM_DIR_X: case WID_BRAS_PLATFORM_DIR_Y: - this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); + this->RaiseWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation); _railstation.orientation = (Axis)(widget - WID_BRAS_PLATFORM_DIR_X); - this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X); + this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); CloseWindowById(WC_SELECT_STATION, 0); @@ -1585,7 +1585,7 @@ public: case WID_BRAS_PLATFORM_NUM_5: case WID_BRAS_PLATFORM_NUM_6: case WID_BRAS_PLATFORM_NUM_7: { - this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN); + this->RaiseWidget(WID_BRAS_PLATFORM_NUM_BEGIN + _settings_client.gui.station_numtracks); this->RaiseWidget(WID_BRAS_PLATFORM_DRAG_N_DROP); _settings_client.gui.station_numtracks = widget - WID_BRAS_PLATFORM_NUM_BEGIN; @@ -1766,7 +1766,7 @@ BuildRailStationWindow::GUIStationClassList::FilterFunction * const BuildRailSta &TagNameFilter, }; -static const NWidgetPart _nested_station_builder_widgets[] = { +static constexpr NWidgetPart _nested_station_builder_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_RAIL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2272,7 +2272,7 @@ static Hotkey signaltoolbar_hotkeys[] = { HotkeyList BuildSignalWindow::hotkeys("signaltoolbar", signaltoolbar_hotkeys); /** Nested widget definition of the build signal window */ -static const NWidgetPart _nested_signal_builder_widgets[] = { +static constexpr NWidgetPart _nested_signal_builder_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BS_CAPTION), SetDataTip(STR_BUILD_SIGNAL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2368,7 +2368,7 @@ struct BuildRailDepotWindow : public PickerWindowBase { BuildRailDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent) { this->InitNested(TRANSPORT_RAIL); - this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); + this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); } void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override @@ -2400,9 +2400,9 @@ struct BuildRailDepotWindow : public PickerWindowBase { case WID_BRAD_DEPOT_SE: case WID_BRAD_DEPOT_SW: case WID_BRAD_DEPOT_NW: - this->RaiseWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); + this->RaiseWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); _build_depot_direction = (DiagDirection)(widget - WID_BRAD_DEPOT_NE); - this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE); + this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; @@ -2411,7 +2411,7 @@ struct BuildRailDepotWindow : public PickerWindowBase { }; /** Nested widget definition of the build rail depot window */ -static const NWidgetPart _nested_build_depot_widgets[] = { +static constexpr NWidgetPart _nested_build_depot_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2644,7 +2644,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { /* static */ QueryString BuildRailWaypointWindow::editbox(BuildRailWaypointWindow::FILTER_LENGTH * MAX_CHAR_LENGTH, BuildRailWaypointWindow::FILTER_LENGTH); /** Nested widget definition for the build NewGRF rail waypoint window */ -static const NWidgetPart _nested_build_waypoint_widgets[] = { +static constexpr NWidgetPart _nested_build_waypoint_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 5d618f5265..66112d7615 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -937,7 +937,7 @@ static Hotkey tramtoolbar_hotkeys[] = { HotkeyList BuildRoadToolbarWindow::tram_hotkeys("tramtoolbar", tramtoolbar_hotkeys, TramToolbarGlobalHotkeys); -static const NWidgetPart _nested_build_road_widgets[] = { +static constexpr NWidgetPart _nested_build_road_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE), @@ -982,7 +982,7 @@ static WindowDesc _build_road_desc(__FILE__, __LINE__, &BuildRoadToolbarWindow::road_hotkeys ); -static const NWidgetPart _nested_build_tramway_widgets[] = { +static constexpr NWidgetPart _nested_build_tramway_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE), @@ -1043,7 +1043,7 @@ Window *ShowBuildRoadToolbar(RoadType roadtype) return AllocateWindowDescFront(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD); } -static const NWidgetPart _nested_build_road_scen_widgets[] = { +static constexpr NWidgetPart _nested_build_road_scen_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE), @@ -1080,7 +1080,7 @@ static WindowDesc _build_road_scen_desc(__FILE__, __LINE__, &BuildRoadToolbarWindow::road_hotkeys ); -static const NWidgetPart _nested_build_tramway_scen_widgets[] = { +static constexpr NWidgetPart _nested_build_tramway_scen_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE), @@ -1132,7 +1132,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase { { this->CreateNestedTree(); - this->LowerWidget(_build_depot_direction + WID_BROD_DEPOT_NE); + this->LowerWidget(WID_BROD_DEPOT_NE + _build_depot_direction); if (RoadTypeIsTram(_cur_roadtype)) { this->GetWidget(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION; for (WidgetID i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) { @@ -1172,9 +1172,9 @@ struct BuildRoadDepotWindow : public PickerWindowBase { case WID_BROD_DEPOT_NE: case WID_BROD_DEPOT_SW: case WID_BROD_DEPOT_SE: - this->RaiseWidget(_build_depot_direction + WID_BROD_DEPOT_NE); + this->RaiseWidget(WID_BROD_DEPOT_NE + _build_depot_direction); _build_depot_direction = (DiagDirection)(widget - WID_BROD_DEPOT_NE); - this->LowerWidget(_build_depot_direction + WID_BROD_DEPOT_NE); + this->LowerWidget(WID_BROD_DEPOT_NE + _build_depot_direction); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); break; @@ -1185,7 +1185,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase { } }; -static const NWidgetPart _nested_build_road_depot_widgets[] = { +static constexpr NWidgetPart _nested_build_road_depot_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1262,9 +1262,9 @@ private: const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type); if (spec == nullptr) return; if (_roadstop_gui_settings.orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) { - this->RaiseWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE); + this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation); _roadstop_gui_settings.orientation = DIAGDIR_END; - this->LowerWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE); + this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation); this->SetDirty(); CloseWindowById(WC_SELECT_STATION, 0); } @@ -1331,8 +1331,8 @@ public: this->GetWidget(i)->tool_tip = rti->strings.picker_tooltip[rs]; } - this->LowerWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE); - this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF); + this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation); + this->LowerWidget(WID_BROS_LT_OFF + _settings_client.gui.station_show_coverage); this->FinishInitNested(TRANSPORT_ROAD); @@ -1678,9 +1678,9 @@ public: const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type); if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) return; } - this->RaiseWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE); + this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation); _roadstop_gui_settings.orientation = (DiagDirection)(widget - WID_BROS_STATION_NE); - this->LowerWidget(_roadstop_gui_settings.orientation + WID_BROS_STATION_NE); + this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation); if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP); this->SetDirty(); CloseWindowById(WC_SELECT_STATION, 0); @@ -1771,7 +1771,7 @@ BuildRoadStationWindow::GUIRoadStopClassList::FilterFunction * const BuildRoadSt }; /** Widget definition of the build road station window */ -static const NWidgetPart _nested_road_station_picker_widgets[] = { +static constexpr NWidgetPart _nested_road_station_picker_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION), @@ -1860,7 +1860,7 @@ static WindowDesc _road_station_picker_desc(__FILE__, __LINE__, ); /** Widget definition of the build tram station window */ -static const NWidgetPart _nested_tram_station_picker_widgets[] = { +static constexpr NWidgetPart _nested_tram_station_picker_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION), @@ -2140,7 +2140,7 @@ struct BuildRoadWaypointWindow : PickerWindowBase { }; /** Nested widget definition for the build NewGRF road waypoint window */ -static const NWidgetPart _nested_build_waypoint_widgets[] = { +static constexpr NWidgetPart _nested_build_waypoint_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/schdispatch_gui.cpp b/src/schdispatch_gui.cpp index 1417da53fb..7e30c331dd 100644 --- a/src/schdispatch_gui.cpp +++ b/src/schdispatch_gui.cpp @@ -1014,7 +1014,7 @@ void CcSwapSchDispatchSchedules(const CommandCost &result, TileIndex tile, uint3 } } -static const NWidgetPart _nested_schdispatch_widgets[] = { +static constexpr NWidgetPart _nested_schdispatch_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_SCHDISPATCH_RENAME), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_SCHDISPATCH_RENAME_SCHEDULE_TOOLTIP), @@ -1234,7 +1234,7 @@ struct ScheduledDispatchAddSlotsWindow : Window { } }; -static const NWidgetPart _nested_scheduled_dispatch_add_widgets[] = { +static constexpr NWidgetPart _nested_scheduled_dispatch_add_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_TIME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/screenshot_gui.cpp b/src/screenshot_gui.cpp index c350c943b5..b3d8fac349 100644 --- a/src/screenshot_gui.cpp +++ b/src/screenshot_gui.cpp @@ -45,7 +45,7 @@ struct ScreenshotWindow : Window { } }; -static const NWidgetPart _nested_screenshot[] = { +static constexpr NWidgetPart _nested_screenshot[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_SCREENSHOT_CAPTION, 0), diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp index 92d5964cc8..f3d8ccc336 100644 --- a/src/script/api/script_group.cpp +++ b/src/script/api/script_group.cpp @@ -95,7 +95,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, IsValidGroup(group_id)); - return ScriptObject::DoCommand(0, group_id | GroupFlags::GF_REPLACE_PROTECTION, enable ? 1 : 0, CMD_SET_GROUP_FLAG); + return ScriptObject::DoCommand(0, group_id | static_cast(GroupFlags::GF_REPLACE_PROTECTION), enable ? 1 : 0, CMD_SET_GROUP_FLAG); } /* static */ bool ScriptGroup::GetAutoReplaceProtection(GroupID group_id) diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp index 1d057b0261..d0090ba2fb 100644 --- a/src/script/api/script_rail.cpp +++ b/src/script/api/script_rail.cpp @@ -250,7 +250,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, ::IsValidTile(tile)); EnforcePrecondition(false, rail_track != 0); - EnforcePrecondition(false, (rail_track & ~::TRACK_BIT_ALL) == 0); + EnforcePrecondition(false, (static_cast(rail_track) & ~static_cast(::TRACK_BIT_ALL)) == 0); EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0); EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType())); diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp index 449946ad4a..6141dc293c 100644 --- a/src/script/api/script_station.cpp +++ b/src/script/api/script_station.cpp @@ -210,7 +210,7 @@ template if (!IsValidStation(station_id)) return false; if (!HasExactlyOneBit(station_type)) return false; - return (::Station::Get(station_id)->facilities & station_type) != 0; + return (::Station::Get(station_id)->facilities & static_cast(station_type)) != 0; } /* static */ bool ScriptStation::HasRoadType(StationID station_id, ScriptRoad::RoadType road_type) diff --git a/src/script/api/script_stationlist.cpp b/src/script/api/script_stationlist.cpp index 1eabd43ed7..8f6a24db46 100644 --- a/src/script/api/script_stationlist.cpp +++ b/src/script/api/script_stationlist.cpp @@ -23,7 +23,7 @@ ScriptStationList::ScriptStationList(ScriptStation::StationType station_type) CompanyID owner = ScriptObject::GetCompany(); ScriptList::FillList(this, [is_deity, owner, station_type](const Station *st) { - return (is_deity || st->owner == owner) && (st->facilities & station_type) != 0; + return (is_deity || st->owner == owner) && (st->facilities & static_cast(station_type)) != 0; } ); } diff --git a/src/script/api/script_waypoint.cpp b/src/script/api/script_waypoint.cpp index 5f7bceaa61..84c2a4aeb6 100644 --- a/src/script/api/script_waypoint.cpp +++ b/src/script/api/script_waypoint.cpp @@ -34,5 +34,5 @@ if (!IsValidWaypoint(waypoint_id)) return false; if (!HasExactlyOneBit(waypoint_type)) return false; - return (::Waypoint::Get(waypoint_id)->facilities & waypoint_type) != 0; + return (::Waypoint::Get(waypoint_id)->facilities & static_cast(waypoint_type)) != 0; } diff --git a/src/script/api/script_waypointlist.cpp b/src/script/api/script_waypointlist.cpp index f137bea190..2332655c2e 100644 --- a/src/script/api/script_waypointlist.cpp +++ b/src/script/api/script_waypointlist.cpp @@ -23,7 +23,7 @@ ScriptWaypointList::ScriptWaypointList(ScriptWaypoint::WaypointType waypoint_typ CompanyID owner = ScriptObject::GetCompany(); ScriptList::FillList(this, [is_deity, owner, waypoint_type](const Waypoint *wp) { - return (is_deity || wp->owner == owner || wp->owner == OWNER_NONE) && (wp->facilities & waypoint_type) != 0; + return (is_deity || wp->owner == owner || wp->owner == OWNER_NONE) && (wp->facilities & static_cast(waypoint_type)) != 0; } ); } diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index b2ad3ef754..0912dae969 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -247,7 +247,7 @@ struct ScriptListWindow : public Window { }; /** Widgets for the AI list window. */ -static const NWidgetPart _nested_script_list_widgets[] = { +static constexpr NWidgetPart _nested_script_list_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), NWidget(WWT_CAPTION, COLOUR_MAUVE, WID_SCRL_CAPTION), SetDataTip(STR_AI_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -604,7 +604,7 @@ private: }; /** Widgets for the Script settings window. */ -static const NWidgetPart _nested_script_settings_widgets[] = { +static constexpr NWidgetPart _nested_script_settings_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), NWidget(WWT_CAPTION, COLOUR_MAUVE, WID_SCRS_CAPTION), SetDataTip(STR_AI_SETTINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1001,7 +1001,7 @@ struct ScriptDebugWindow : public Window { bool dead = valid && Company::Get(i)->ai_instance->IsDead(); bool paused = valid && Company::Get(i)->ai_instance->IsPaused(); - NWidgetCore *button = this->GetWidget(i + WID_SCRD_COMPANY_BUTTON_START); + NWidgetCore *button = this->GetWidget(WID_SCRD_COMPANY_BUTTON_START + i); button->SetDisabled(!valid); button->SetLowered(this->filter.script_debug_company == i); SetScriptButtonColour(*button, dead, paused); @@ -1266,7 +1266,7 @@ static Hotkey scriptdebug_hotkeys[] = { HotkeyList ScriptDebugWindow::hotkeys("aidebug", scriptdebug_hotkeys, ScriptDebugGlobalHotkeys); /** Widgets for the Script debug window. */ -static const NWidgetPart _nested_script_debug_widgets[] = { +static constexpr NWidgetPart _nested_script_debug_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_AI_DEBUG, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index afa5bbd7b7..b37e806415 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -867,7 +867,7 @@ struct GameOptionsWindow : Window { } }; -static const NWidgetPart _nested_game_options_widgets[] = { +static constexpr NWidgetPart _nested_game_options_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -3227,7 +3227,7 @@ struct GameSettingsWindow : Window { GameSettings *GameSettingsWindow::settings_ptr = nullptr; -static const NWidgetPart _nested_settings_selection_widgets[] = { +static constexpr NWidgetPart _nested_settings_selection_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), NWidget(WWT_CAPTION, COLOUR_MAUVE), SetDataTip(STR_CONFIG_SETTING_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -3534,7 +3534,7 @@ struct CustomCurrencyWindow : Window { } }; -static const NWidgetPart _nested_cust_currency_widgets[] = { +static constexpr NWidgetPart _nested_cust_currency_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_CURRENCY_WINDOW, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/signal_type.h b/src/signal_type.h index 5f2142d189..fe0f0817c4 100644 --- a/src/signal_type.h +++ b/src/signal_type.h @@ -53,6 +53,7 @@ struct SignalReference { TileIndex tile; Track track; }; +DECLARE_ENUM_AS_ADDABLE(SignalType) /** * These are states in which a signal can be. Currently these are only two, so diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 8d0abe59bc..5eed6ac481 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -357,7 +357,7 @@ static Hotkey signlist_hotkeys[] = { }; HotkeyList SignListWindow::hotkeys("signlist", signlist_hotkeys, SignListGlobalHotkeys); -static const NWidgetPart _nested_sign_list_widgets[] = { +static constexpr NWidgetPart _nested_sign_list_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SIL_CAPTION), SetDataTip(STR_SIGN_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -531,7 +531,7 @@ struct SignWindow : Window, SignList { } }; -static const NWidgetPart _nested_query_sign_edit_widgets[] = { +static constexpr NWidgetPart _nested_query_sign_edit_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_QES_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE), diff --git a/src/slope_func.h b/src/slope_func.h index 8ee7f78807..36f391f131 100644 --- a/src/slope_func.h +++ b/src/slope_func.h @@ -391,7 +391,7 @@ inline Foundation InclinedFoundation(Axis axis) inline Foundation HalftileFoundation(Corner corner) { dbg_assert(IsValidCorner(corner)); - return (Foundation)(FOUNDATION_HALFTILE_W + corner); + return static_cast(static_cast(FOUNDATION_HALFTILE_W) + static_cast(corner)); } /** @@ -403,7 +403,7 @@ inline Foundation HalftileFoundation(Corner corner) inline Foundation SpecialRailFoundation(Corner corner) { dbg_assert(IsValidCorner(corner)); - return (Foundation)(FOUNDATION_RAIL_W + corner); + return static_cast(static_cast(FOUNDATION_RAIL_W) + static_cast(corner)); } /** diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 714ead1d15..3cbdc9922d 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1067,7 +1067,7 @@ SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(des _smallmap_industry_highlight = INVALID_INDUSTRYTYPE; this->overlay = std::make_unique(this, WID_SM_MAP, 0, this->GetOverlayCompanyMask(), 1); this->InitNested(window_number); - this->LowerWidget(this->map_type + WID_SM_CONTOUR); + this->LowerWidget(WID_SM_CONTOUR + this->map_type); this->RebuildColourIndexIfNecessary(); @@ -1295,9 +1295,9 @@ void SmallMapWindow::RebuildColourIndexIfNecessary() */ void SmallMapWindow::SwitchMapType(SmallMapType map_type) { - this->RaiseWidget(this->map_type + WID_SM_CONTOUR); + this->RaiseWidget(WID_SM_CONTOUR + this->map_type); this->map_type = map_type; - this->LowerWidget(this->map_type + WID_SM_CONTOUR); + this->LowerWidget(WID_SM_CONTOUR + this->map_type); this->SetupWidgetData(); @@ -1725,7 +1725,7 @@ void SmallMapWindow::ScreenshotCallbackHandler(void *buf, uint y, uint pitch, ui this->DrawSmallMap(&dpi, false); } -SmallMapWindow::SmallMapType SmallMapWindow::map_type = SMT_CONTOUR; +SmallMapType SmallMapWindow::map_type = SMT_CONTOUR; bool SmallMapWindow::show_towns = true; int SmallMapWindow::map_height_limit = -1; @@ -1791,14 +1791,14 @@ public: }; /** Widget parts of the smallmap display. */ -static const NWidgetPart _nested_smallmap_display[] = { +static constexpr NWidgetPart _nested_smallmap_display[] = { NWidget(WWT_PANEL, COLOUR_BROWN, WID_SM_MAP_BORDER), NWidget(WWT_INSET, COLOUR_BROWN, WID_SM_MAP), SetMinimalSize(346, 140), SetResize(1, 1), SetPadding(2, 2, 2, 2), EndContainer(), EndContainer(), }; /** Widget parts of the smallmap legend bar + image buttons. */ -static const NWidgetPart _nested_smallmap_bar[] = { +static constexpr NWidgetPart _nested_smallmap_bar[] = { NWidget(WWT_PANEL, COLOUR_BROWN), NWidget(NWID_HORIZONTAL), NWidget(WWT_EMPTY, INVALID_COLOUR, WID_SM_LEGEND), SetResize(1, 1), @@ -1849,7 +1849,7 @@ static std::unique_ptr SmallMapDisplay() } -static const NWidgetPart _nested_smallmap_widgets[] = { +static constexpr NWidgetPart _nested_smallmap_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SM_CAPTION), SetDataTip(STR_SMALLMAP_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index 3950fc8df6..78d2d63489 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -65,20 +65,21 @@ struct LegendAndColour { bool col_break; ///< Perform a column break and go further at the next column. }; +/** Types of legends in the #WID_SM_LEGEND widget. */ +enum SmallMapType : byte { + SMT_CONTOUR, + SMT_VEHICLES, + SMT_INDUSTRY, + SMT_LINKSTATS, + SMT_ROUTES, + SMT_VEGETATION, + SMT_OWNER, +}; +DECLARE_ENUM_AS_ADDABLE(SmallMapType) + /** Class managing the smallmap window. */ class SmallMapWindow : public Window { protected: - /** Types of legends in the #WID_SM_LEGEND widget. */ - enum SmallMapType { - SMT_CONTOUR, - SMT_VEHICLES, - SMT_INDUSTRY, - SMT_LINKSTATS, - SMT_ROUTES, - SMT_VEGETATION, - SMT_OWNER, - }; - /** Available kinds of zoomlevel changes. */ enum ZoomLevelChange { ZLC_INITIALIZE, ///< Initialize zoom level. diff --git a/src/spritecache.cpp b/src/spritecache.cpp index cecaae6ed8..aa67650971 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -649,7 +649,7 @@ void ReadGRFSpriteOffsets(SpriteFile &file) length--; if (colour != 0) { static const ZoomLevel zoom_lvl_map[6] = {ZOOM_LVL_OUT_4X, ZOOM_LVL_NORMAL, ZOOM_LVL_OUT_2X, ZOOM_LVL_OUT_8X, ZOOM_LVL_OUT_16X, ZOOM_LVL_OUT_32X}; - if (zoom < 6) SetBit(offset.control_flags, zoom_lvl_map[zoom] + ((colour != SCC_PAL) ? SCC_32BPP_ZOOM_START : SCC_PAL_ZOOM_START)); + if (zoom < 6) SetBit(offset.control_flags, static_cast(zoom_lvl_map[zoom]) + static_cast((colour != SCC_PAL) ? SCC_32BPP_ZOOM_START : SCC_PAL_ZOOM_START)); } } } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index ef672883a7..9677627a3b 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -837,7 +837,7 @@ static std::unique_ptr CargoWidgets() return container; } -static const NWidgetPart _nested_company_stations_widgets[] = { +static constexpr NWidgetPart _nested_company_stations_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_STL_CAPTION), SetDataTip(STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -891,7 +891,7 @@ void ShowCompanyStations(CompanyID company) AllocateWindowDescFront(&_company_stations_desc, company); } -static const NWidgetPart _nested_station_view_widgets[] = { +static constexpr NWidgetPart _nested_station_view_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_IMGBTN, COLOUR_GREY, WID_SV_RENAME), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, 0x0), @@ -2514,7 +2514,7 @@ static const T *FindStationsNearby(TileArea ta, bool distant_join, IsSpecialized return nullptr; } -static const NWidgetPart _nested_select_station_widgets[] = { +static constexpr NWidgetPart _nested_select_station_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_JS_CAPTION), SetDataTip(STR_JOIN_STATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2747,7 +2747,7 @@ void ShowSelectWaypointIfNeeded(const CommandContainer &cmd, TileArea ta) ShowSelectBaseStationIfNeeded(cmd, ta); } -static const NWidgetPart _nested_station_rating_tooltip_widgets[] = { +static constexpr NWidgetPart _nested_station_rating_tooltip_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY, WID_TT_BACKGROUND), SetMinimalSize(64, 32), EndContainer(), }; diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 0db68b608c..f0ea68f21e 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -234,7 +234,7 @@ struct StatusBarWindow : Window { } }; -static const NWidgetPart _nested_main_status_widgets[] = { +static constexpr NWidgetPart _nested_main_status_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_PANEL, COLOUR_GREY, WID_S_LEFT), SetMinimalSize(160, 12), EndContainer(), NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_MIDDLE), SetMinimalSize(40, 12), SetDataTip(0x0, STR_STATUSBAR_TOOLTIP_SHOW_LAST_NEWS), SetResize(1, 0), diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 678947642c..1d6126911a 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -950,7 +950,7 @@ GUIStoryPageElementList::SortFunction * const StoryBookWindow::page_element_sort &PageElementOrderSorter, }; -static const NWidgetPart _nested_story_book_widgets[] = { +static constexpr NWidgetPart _nested_story_book_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SB_CAPTION), SetDataTip(STR_JUST_STRING1, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/string_type.h b/src/string_type.h index e5daa265fe..5eeba81294 100644 --- a/src/string_type.h +++ b/src/string_type.h @@ -15,10 +15,10 @@ #include /** A non-breaking space. */ -#define NBSP u8"\u00a0" +#define NBSP "\u00a0" /** A left-to-right marker, marks the next character as left-to-right. */ -#define LRM u8"\u200e" +#define LRM "\u200e" /** * Valid filter types for IsValidChar. diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 4336ab3b62..a647da317b 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -214,7 +214,7 @@ struct SubsidyListWindow : Window { } }; -static const NWidgetPart _nested_subsidies_list_widgets[] = { +static constexpr NWidgetPart _nested_subsidies_list_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_SUBSIDIES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/table/townname.h b/src/table/townname.h index 748b902c57..8b904ed21e 100644 --- a/src/table/townname.h +++ b/src/table/townname.h @@ -314,7 +314,7 @@ static const char * const _name_austrian_a2[] = { "Aus", "Alten", "Braun", - u8"V\u00f6sl", + "V\u00f6sl", "Mittern", "Nuss", "Neu", @@ -336,9 +336,9 @@ static const char * const _name_austrian_a2[] = { "Frauen", "Herren", "Hof", - u8"H\u00fctt", + "H\u00fctt", "Kaisers", - u8"K\u00f6nigs", + "K\u00f6nigs", "Knittel", "Lang", "Ober", @@ -350,7 +350,7 @@ static const char * const _name_austrian_a2[] = { "Stocker", "Unter", "Utten", - u8"V\u00f6sen", + "V\u00f6sen", "Vill", "Weissen", }; @@ -396,7 +396,7 @@ static const char * const _name_austrian_a5[] = { static const char * const _name_austrian_a6[] = { "Aegyd", - u8"Andr\u00e4", + "Andr\u00e4", "Georgen", "Jakob", "Johann", @@ -409,7 +409,7 @@ static const char * const _name_austrian_a6[] = { "Nikolai", "Oswald", "Peter", - u8"P\u00f6lten", + "P\u00f6lten", "Stefan", "Stephan", "Thomas", @@ -470,10 +470,10 @@ static const char * const _name_german_real[] = { "Gera", "Kassel", "Kiel", - u8"K\u00f6ln", - u8"L\u00fcbeck", + "K\u00f6ln", + "L\u00fcbeck", "Magdeburg", - u8"M\u00fcnchen", + "M\u00fcnchen", "Potsdam", "Stuttgart", "Wiesbaden", @@ -496,7 +496,7 @@ static const char * const _name_german_1[] = { "Cloppen", "Co", "Duis", - u8"D\u00fcssel", + "D\u00fcssel", "Dannen", "Elb", "Els", @@ -510,7 +510,7 @@ static const char * const _name_german_1[] = { "Frei", "Freuden", "Fried", - u8"F\u00fcrsten", + "F\u00fcrsten", "Hahn", "Ham", "Harz", @@ -531,10 +531,10 @@ static const char * const _name_german_1[] = { "Langen", "Lim", "Lohr", - u8"L\u00fcne", + "L\u00fcne", "Mel", "Michels", - u8"M\u00fchl", + "M\u00fchl", "Naum", "Nest", "Nord", @@ -542,7 +542,7 @@ static const char * const _name_german_1[] = { "Nien", "Nidda", "Nieder", - u8"N\u00fcrn", + "N\u00fcrn", "Ober", "Offen", "Osna", @@ -556,18 +556,18 @@ static const char * const _name_german_1[] = { "Regens", "Rott", "Ros", - u8"R\u00fcssels", + "R\u00fcssels", "Saal", "Saar", "Salz", - u8"Sch\u00f6ne", + "Sch\u00f6ne", "Schwein", "Sonder", "Sonnen", "Stein", "Strals", "Straus", - u8"S\u00fcd", + "S\u00fcd", "Ton", "Unter", "Ur", @@ -578,14 +578,14 @@ static const char * const _name_german_1[] = { "Wester", "Witten", "Wolfs", - u8"W\u00fcrz", + "W\u00fcrz", }; static const char * const _name_german_2[] = { "bach", "berg", - u8"br\u00fcck", - u8"br\u00fccken", + "br\u00fcck", + "br\u00fccken", "burg", "dorf", "feld", @@ -595,7 +595,7 @@ static const char * const _name_german_2[] = { "heim", "horst", "mund", - u8"m\u00fcnster", + "m\u00fcnster", "stadt", "wald", }; @@ -629,9 +629,9 @@ static const char * const _name_spanish_real[] = { "Morrocoy", "Cata", "Cataito", - u8"Ciudad Bol\u00edvar", + "Ciudad Bol\u00edvar", "Barquisimeto", - u8"M\u00e9rida", + "M\u00e9rida", "Puerto Ordaz", "Santa Elena", "San Juan", @@ -640,58 +640,58 @@ static const char * const _name_spanish_real[] = { "Santiago", "Barcelona", "Barinas", - u8"San Crist\u00f3bal", + "San Crist\u00f3bal", "San Francisco", - u8"San Mart\u00edn", + "San Mart\u00edn", "Guayana", "San Carlos", - u8"El Lim\u00f3n", + "El Lim\u00f3n", "Coro", "Coro Coro", "Puerto Ayacucho", "Elorza", "Arismendi", "Trujillo", - u8"Car\u00fapano", + "Car\u00fapano", "Anaco", "Lima", "Cuzco", "Iquitos", "Callao", "Huacho", - u8"Caman\u00e1", + "Caman\u00e1", "Puerto Chala", "Santa Cruz", "Quito", "Cuenca", - u8"Medell\u00edn", - u8"Tulc\u00e1n", + "Medell\u00edn", + "Tulc\u00e1n", "Esmeraldas", "Ibarra", "San Lorenzo", "Macas", - u8"Mora\u00f1a", + "Mora\u00f1a", "Machala", "Zamora", "Latacunga", "Tena", "Cochabamba", - u8"Ascensi\u00f3n", + "Ascensi\u00f3n", "Magdalena", "Santa Ana", "Manoa", "Sucre", "Oruro", "Uyuni", - u8"Potos\u00ed", + "Potos\u00ed", "Tupiza", "La Quiaca", - u8"Yacu\u00edba", + "Yacu\u00edba", "San Borja", "Fuerte Olimpo", - u8"Fort\u00edn Esteros", + "Fort\u00edn Esteros", "Campo Grande", - u8"Bogot\u00e1", + "Bogot\u00e1", "El Banco", "Zaragoza", "Neiva", @@ -719,7 +719,7 @@ static const char * const _name_french_real[] = { "Bordeaux", "Bayonne", "Montpellier", - u8"Mont\u00e9limar", + "Mont\u00e9limar", "Valence", "Digne", "Nice", @@ -727,16 +727,16 @@ static const char * const _name_french_real[] = { "St. Tropez", "Marseille", "Narbonne", - u8"S\u00e8te", + "S\u00e8te", "Aurillac", - u8"Gu\u00e9ret", + "Gu\u00e9ret", "Le Creusot", "Nevers", "Auxerre", "Versailles", "Meaux", - u8"Ch\u00e2lons", - u8"Compi\u00e8gne", + "Ch\u00e2lons", + "Compi\u00e8gne", "Metz", "Chaumont", "Langres", @@ -749,8 +749,8 @@ static const char * const _name_french_real[] = { "Le Mans", "Angers", "Nantes", - u8"Ch\u00e2teauroux", - u8"Orl\u00e9ans", + "Ch\u00e2teauroux", + "Orl\u00e9ans", "Lisieux", "Cherbourg", "Morlaix", @@ -761,7 +761,7 @@ static const char * const _name_french_real[] = { "Troyes", "Charolles", "Toulouse", - u8"Chamb\u00e9ry", + "Chamb\u00e9ry", "Tours", "St. Brieuc", "St. Malo", @@ -775,11 +775,11 @@ static const char * const _name_french_real[] = { "Albi", "Paris", "Biarritz", - u8"B\u00e9ziers", - u8"N\u00eemes", + "B\u00e9ziers", + "N\u00eemes", "Chamonix", - u8"Angoul\u00e8me", - u8"Alen\u00e7on", + "Angoul\u00e8me", + "Alen\u00e7on", }; static const char * const _name_silly_1[] = { @@ -907,7 +907,7 @@ static const char * const _name_swedish_2[] = { "Es", "Fin", "Fisk", - u8"Gr\u00f6n", + "Gr\u00f6n", "Hag", "Halm", "Karl", @@ -926,17 +926,17 @@ static const char * const _name_swedish_2[] = { "Skog", "Stock", "Stor", - u8"Str\u00f6m", + "Str\u00f6m", "Sund", - u8"S\u00f6der", + "S\u00f6der", "Tall", "Tratt", "Troll", "Upp", "Var", - u8"V\u00e4ster", - u8"\u00c4ngel", - u8"\u00d6ster", + "V\u00e4ster", + "\u00c4ngel", + "\u00d6ster", }; static const char * const _name_swedish_2a[] = { @@ -991,9 +991,9 @@ static const char * const _name_swedish_2b[] = { "o", "u", "y", - u8"\u00e5", - u8"\u00e4", - u8"\u00f6", + "\u00e5", + "\u00e4", + "\u00f6", }; static const char * const _name_swedish_2c[] = { @@ -1039,25 +1039,25 @@ static const char * const _name_swedish_3[] = { "hamn", "holm", "hus", - u8"h\u00e4ttan", + "h\u00e4ttan", "kulle", - u8"k\u00f6ping", + "k\u00f6ping", "lund", - u8"l\u00f6v", + "l\u00f6v", "sala", "skrona", - u8"sl\u00e4tt", - u8"sp\u00e5ng", + "sl\u00e4tt", + "sp\u00e5ng", "stad", "sund", "svall", "svik", - u8"s\u00e5ker", + "s\u00e5ker", "udde", "valla", "viken", - u8"\u00e4lv", - u8"\u00e5s", + "\u00e4lv", + "\u00e5s", }; static const char * const _name_dutch_1[] = { @@ -1224,7 +1224,7 @@ static const char * const _name_finnish_real[] = { "Espoo", "Helsinki", "Tapiola", - u8"J\u00e4rvel\u00e4", + "J\u00e4rvel\u00e4", "Lahti", "Kotka", "Hamina", @@ -1259,26 +1259,26 @@ static const char * const _name_finnish_1[] = { "Sauna", "Uusi", "Vanha", - u8"Kes\u00e4", + "Kes\u00e4", "Kuusi", "Pelto", "Tuomi", "Terva", "Olki", - u8"Hein\u00e4", - u8"Sein\u00e4", + "Hein\u00e4", + "Sein\u00e4", "Rova", "Koivu", "Kokko", - u8"M\u00e4nty", + "M\u00e4nty", "Pihlaja", - u8"Pet\u00e4j\u00e4", + "Pet\u00e4j\u00e4", "Kielo", "Kauha", "Viita", "Kivi", "Riihi", - u8"\u00c4\u00e4ne", + "\u00c4\u00e4ne", "Niini", }; @@ -1287,27 +1287,27 @@ static const char * const _name_finnish_2[] = { "Lohjan", "Savon", "Lapin", - u8"Pit\u00e4j\u00e4n", + "Pit\u00e4j\u00e4n", "Martin", "Kuusan", "Kemi", "Keri", - u8"H\u00e4meen", + "H\u00e4meen", "Kangas", }; static const char * const _name_finnish_3[] = { "harju", "linna", - u8"j\u00e4rvi", + "j\u00e4rvi", "kallio", - u8"m\u00e4ki", + "m\u00e4ki", "nummi", "joki", - u8"kyl\u00e4", + "kyl\u00e4", "lampi", "lahti", - u8"mets\u00e4", + "mets\u00e4", "suo", "laakso", "niitty", @@ -1320,56 +1320,56 @@ static const char * const _name_finnish_3[] = { static const char * const _name_polish_1_m[] = { "Wielki ", - u8"Ma\u0142y ", - u8"Z\u0142y ", + "Ma\u0142y ", + "Z\u0142y ", "Dobry ", "Nowy ", "Stary ", - u8"Z\u0142oty ", + "Z\u0142oty ", "Zielony ", - u8"Bia\u0142y ", + "Bia\u0142y ", "Modry ", - u8"D\u0119bowy ", + "D\u0119bowy ", }; static const char * const _name_polish_1_f[] = { "Wielka ", - u8"Ma\u0142a ", - u8"Z\u0142a ", + "Ma\u0142a ", + "Z\u0142a ", "Dobra ", "Nowa ", "Stara ", - u8"Z\u0142ota ", + "Z\u0142ota ", "Zielona ", - u8"Bia\u0142a ", + "Bia\u0142a ", "Modra ", - u8"D\u0119bowa ", + "D\u0119bowa ", }; static const char * const _name_polish_1_n[] = { "Wielkie ", - u8"Ma\u0142e ", - u8"Z\u0142e ", + "Ma\u0142e ", + "Z\u0142e ", "Dobre ", "Nowe ", "Stare ", - u8"Z\u0142ote ", + "Z\u0142ote ", "Zielone ", - u8"Bia\u0142e ", + "Bia\u0142e ", "Modre ", - u8"D\u0119bowe ", + "D\u0119bowe ", }; static const char * const _name_polish_2_o[] = { "Frombork", "Gniezno", "Olsztyn", - u8"Toru\u0144", + "Toru\u0144", "Bydgoszcz", "Terespol", - u8"Krak\u00f3w", - u8"Pozna\u0144", - u8"Wroc\u0142aw", + "Krak\u00f3w", + "Pozna\u0144", + "Wroc\u0142aw", "Katowice", "Cieszyn", "Bytom", @@ -1380,7 +1380,7 @@ static const char * const _name_polish_2_o[] = { "Malbork", "Sopot", "Sosnowiec", - u8"Gda\u0144sk", + "Gda\u0144sk", "Gdynia", "Sieradz", "Sandomierz", @@ -1388,9 +1388,9 @@ static const char * const _name_polish_2_o[] = { "Szczytno", "Szczecin", "Zakopane", - u8"Szklarska Por\u0119ba", + "Szklarska Por\u0119ba", "Bochnia", - u8"Golub-Dobrzy\u0144", + "Golub-Dobrzy\u0144", "Chojnice", "Ostrowiec", "Otwock", @@ -1400,13 +1400,13 @@ static const char * const _name_polish_2_o[] = { static const char * const _name_polish_2_m[] = { "Jarocin", "Gogolin", - u8"Tomasz\u00f3w", - u8"Piotrk\u00f3w", + "Tomasz\u00f3w", + "Piotrk\u00f3w", "Lidzbark", "Rypin", "Radzymin", - u8"Wo\u0142omin", - u8"Pruszk\u00f3w", + "Wo\u0142omin", + "Pruszk\u00f3w", "Olsztynek", "Rypin", "Cisek", @@ -1416,7 +1416,7 @@ static const char * const _name_polish_2_m[] = { "Lubicz", "Milicz", "Targ", - u8"Ostr\u00f3w", + "Ostr\u00f3w", "Ozimek", "Puck", "Rzepin", @@ -1429,7 +1429,7 @@ static const char * const _name_polish_2_m[] = { "Strzepcz", "Strzebielin", "Sochaczew", - u8"Gr\u0119bocin", + "Gr\u0119bocin", "Gniew", "Lubliniec", "Lubasz", @@ -1451,7 +1451,7 @@ static const char * const _name_polish_2_m[] = { static const char * const _name_polish_2_f[] = { "Szprotawa", "Pogorzelica", - u8"Mot\u0142awa", + "Mot\u0142awa", "Lubawa", "Nidzica", "Kruszwica", @@ -1505,7 +1505,7 @@ static const char * const _name_polish_2_n[] = { "Braniewo", "Sulinowo", "Chmielno", - u8"Jastrz\u0119bie", + "Jastrz\u0119bie", "Gryfino", "Koronowo", "Lubichowo", @@ -1514,182 +1514,182 @@ static const char * const _name_polish_2_n[] = { static const char * const _name_polish_3_m[] = { " Wybudowanie", - u8" \u015awi\u0119tokrzyski", - u8" G\u00f3rski", + " \u015awi\u0119tokrzyski", + " G\u00f3rski", " Morski", - u8" Zdr\u00f3j", + " Zdr\u00f3j", " Wody", " Bajoro", - u8" Kraje\u0144ski", - u8" \u015al\u0105ski", + " Kraje\u0144ski", + " \u015al\u0105ski", " Mazowiecki", " Pomorski", " Wielki", " Maly", - u8" Warmi\u0144ski", + " Warmi\u0144ski", " Mazurski", " Mniejszy", - u8" Wi\u0119kszy", - u8" G\u00f3rny", + " Wi\u0119kszy", + " G\u00f3rny", " Dolny", " Wielki", " Stary", " Nowy", " Wielkopolski", - u8" Wzg\u00f3rze", + " Wzg\u00f3rze", " Mosty", " Kujawski", - u8" Ma\u0142opolski", + " Ma\u0142opolski", " Podlaski", " Lesny", }; static const char * const _name_polish_3_f[] = { " Wybudowanie", - u8" \u015awi\u0119tokrzyska", - u8" G\u00f3rska", + " \u015awi\u0119tokrzyska", + " G\u00f3rska", " Morska", - u8" Zdr\u00f3j", + " Zdr\u00f3j", " Woda", " Bajoro", - u8" Kraje\u0144ska", - u8" \u015al\u0105ska", + " Kraje\u0144ska", + " \u015al\u0105ska", " Mazowiecka", " Pomorska", " Wielka", - u8" Ma\u0142a", - u8" Warmi\u0144ska", + " Ma\u0142a", + " Warmi\u0144ska", " Mazurska", " Mniejsza", - u8" Wi\u0119ksza", - u8" G\u00f3rna", + " Wi\u0119ksza", + " G\u00f3rna", " Dolna", " Wielka", " Stara", " Nowa", " Wielkopolska", - u8" Wzg\u00f3rza", + " Wzg\u00f3rza", " Mosty", " Kujawska", " Malopolska", " Podlaska", - u8" Le\u015bna", + " Le\u015bna", }; static const char * const _name_polish_3_n[] = { " Wybudowanie", - u8" \u015awietokrzyskie", - u8" G\u00f3rskie", + " \u015awietokrzyskie", + " G\u00f3rskie", " Morskie", - u8" Zdr\u00f3j", + " Zdr\u00f3j", " Wody", " Bajoro", - u8" Kraje\u0144skie", - u8" \u015al\u0105skie", + " Kraje\u0144skie", + " \u015al\u0105skie", " Mazowieckie", " Pomorskie", " Wielkie", - u8" Ma\u0142e", - u8" Warmi\u0144skie ", + " Ma\u0142e", + " Warmi\u0144skie ", " Mazurskie ", " Mniejsze", - u8" Wi\u0119ksze", - u8" G\u00f3rne", + " Wi\u0119ksze", + " G\u00f3rne", " Dolne", " Wielkie", " Stare", " Nowe", " Wielkopolskie", - u8" Wzg\u00f3rze", + " Wzg\u00f3rze", " Mosty", " Kujawskie", - u8" Ma\u0142opolskie", + " Ma\u0142opolskie", " Podlaskie", - u8" Le\u015bne", + " Le\u015bne", }; static const char * const _name_czech_real[] = { - u8"A\u0161", - u8"Bene\u0161ov", + "A\u0161", + "Bene\u0161ov", "Beroun", - u8"Bezdru\u017eice", + "Bezdru\u017eice", "Blansko", - u8"B\u0159eclav", + "B\u0159eclav", "Brno", - u8"Brunt\u00e1l", - u8"\u010cesk\u00e1 L\u00edpa", - u8"\u010cesk\u00e9 Bud\u011bjovice", - u8"\u010cesk\u00fd Krumlov", - u8"D\u011b\u010d\u00edn", - u8"Doma\u017elice", - u8"Dub\u00ed", - u8"Fr\u00fddek-M\u00edstek", - u8"Havl\u00ed\u010dk\u016fv Brod", - u8"Hodon\u00edn", - u8"Hradec Kr\u00e1lov\u00e9", + "Brunt\u00e1l", + "\u010cesk\u00e1 L\u00edpa", + "\u010cesk\u00e9 Bud\u011bjovice", + "\u010cesk\u00fd Krumlov", + "D\u011b\u010d\u00edn", + "Doma\u017elice", + "Dub\u00ed", + "Fr\u00fddek-M\u00edstek", + "Havl\u00ed\u010dk\u016fv Brod", + "Hodon\u00edn", + "Hradec Kr\u00e1lov\u00e9", "Humpolec", "Cheb", "Chomutov", "Chrudim", "Jablonec nad Nisou", - u8"Jesen\u00edk", - u8"Ji\u010d\u00edn", + "Jesen\u00edk", + "Ji\u010d\u00edn", "Jihlava", - u8"Jind\u0159ich\u016fv Hradec", + "Jind\u0159ich\u016fv Hradec", "Karlovy Vary", - u8"Karvin\u00e1", + "Karvin\u00e1", "Kladno", "Klatovy", - u8"Kol\u00edn", + "Kol\u00edn", "Kosmonosy", - u8"Krom\u011b\u0159\u00ed\u017e", - u8"Kutn\u00e1 Hora", + "Krom\u011b\u0159\u00ed\u017e", + "Kutn\u00e1 Hora", "Liberec", - u8"Litom\u011b\u0159ice", + "Litom\u011b\u0159ice", "Louny", - u8"Man\u011bt\u00edn", - u8"M\u011bln\u00edk", - u8"Mlad\u00e1 Boleslav", + "Man\u011bt\u00edn", + "M\u011bln\u00edk", + "Mlad\u00e1 Boleslav", "Most", - u8"N\u00e1chod", - u8"Nov\u00fd Ji\u010d\u00edn", + "N\u00e1chod", + "Nov\u00fd Ji\u010d\u00edn", "Nymburk", "Olomouc", "Opava", - u8"Or\u00e1\u010dov", + "Or\u00e1\u010dov", "Ostrava", "Pardubice", - u8"Pelh\u0159imov", - u8"Pol\u017eice", - u8"P\u00edsek", - u8"Plze\u0148", + "Pelh\u0159imov", + "Pol\u017eice", + "P\u00edsek", + "Plze\u0148", "Praha", "Prachatice", - u8"P\u0159erov", - u8"P\u0159\u00edbram", - u8"Prost\u011bjov", - u8"Rakovn\u00edk", + "P\u0159erov", + "P\u0159\u00edbram", + "Prost\u011bjov", + "Rakovn\u00edk", "Rokycany", - u8"Rudn\u00e1", - u8"Rychnov nad Kn\u011b\u017enou", + "Rudn\u00e1", + "Rychnov nad Kn\u011b\u017enou", "Semily", "Sokolov", "Strakonice", - u8"St\u0159edokluky", - u8"\u0160umperk", + "St\u0159edokluky", + "\u0160umperk", "Svitavy", - u8"T\u00e1bor", + "T\u00e1bor", "Tachov", "Teplice", - u8"T\u0159eb\u00ed\u010d", + "T\u0159eb\u00ed\u010d", "Trutnov", - u8"Uhersk\u00e9 Hradi\u0161t\u011b", - u8"\u00dast\u00ed nad Labem", - u8"\u00dast\u00ed nad Orlic\u00ed", - u8"Vset\u00edn", - u8"Vy\u0161kov", - u8"\u017d\u010f\u00e1r nad S\u00e1zavou", - u8"Zl\u00edn", + "Uhersk\u00e9 Hradi\u0161t\u011b", + "\u00dast\u00ed nad Labem", + "\u00dast\u00ed nad Orlic\u00ed", + "Vset\u00edn", + "Vy\u0161kov", + "\u017d\u010f\u00e1r nad S\u00e1zavou", + "Zl\u00edn", "Znojmo", }; @@ -1723,12 +1723,12 @@ enum CzechPattern { * by this. * XXX: [CZG_SMASC][CZP_PRIVL] needs special handling: -ovX -> -uv. */ static const char * const _name_czech_patmod[][3] = { - /* CZG_SMASC */ { u8"\u00ed", u8"\u00fd", "X" }, - /* CZG_SFEM */ { u8"\u00ed", u8"\u00e1", "a" }, - /* CZG_SNEUT */ { u8"\u00ed", u8"\u00e9", "o" }, - /* CZG_PMASC */ { u8"\u00ed", u8"\u00e9", "y" }, - /* CZG_PFEM */ { u8"\u00ed", u8"\u00e9", "y" }, - /* CZG_PNEUT */ { u8"\u00ed", u8"\u00e1", "a" } + /* CZG_SMASC */ { "\u00ed", "\u00fd", "X" }, + /* CZG_SFEM */ { "\u00ed", "\u00e1", "a" }, + /* CZG_SNEUT */ { "\u00ed", "\u00e9", "o" }, + /* CZG_PMASC */ { "\u00ed", "\u00e9", "y" }, + /* CZG_PFEM */ { "\u00ed", "\u00e9", "y" }, + /* CZG_PNEUT */ { "\u00ed", "\u00e1", "a" } }; /* This way the substantive can choose only some adjectives/endings: @@ -1768,52 +1768,52 @@ struct CzechNameAdj { /* Some of items which should be common are doubled. */ static const CzechNameAdj _name_czech_adj[] = { - { CZP_JARNI, CZC_ANY, u8"Horn\u00ed" }, - { CZP_JARNI, CZC_ANY, u8"Horn\u00ed" }, - { CZP_JARNI, CZC_ANY, u8"Doln\u00ed" }, - { CZP_JARNI, CZC_ANY, u8"Doln\u00ed" }, - { CZP_JARNI, CZC_ANY, u8"P\u0159edn\u00ed" }, - { CZP_JARNI, CZC_ANY, u8"Zadn\u00ed" }, - { CZP_JARNI, CZC_ANY, u8"Kosteln\u00ed" }, - { CZP_JARNI, CZC_ANY, u8"Havran\u00ed" }, - { CZP_JARNI, CZC_ANY, u8"\u0158\u00ed\u010dn\u00ed" }, - { CZP_JARNI, CZC_ANY, u8"Jezern\u00ed" }, - { CZP_MLADY, CZC_ANY, u8"Velk\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Velk\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Mal\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Mal\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Vysok\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"\u010cesk\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Moravsk\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Slov\u00e1ck\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Slezsk\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Uhersk\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Star\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Star\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Nov\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Nov\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Mlad\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Kr\u00e1lovsk\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Kamenn\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Cihlov\u00fd" }, - { CZP_MLADY, CZC_ANY, u8"Divn\u00fd" }, - { CZP_MLADY, CZC_COLOR, u8"\u010cerven\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"\u010cerven\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"\u010cerven\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"Zelen\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"\u017dlut\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"Siv\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"\u0160ed\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"B\u00edl\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"B\u00edl\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"Modr\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"R\u016f\u017eov\u00e1" }, - { CZP_MLADY, CZC_COLOR, u8"\u010cern\u00e1" }, - { CZP_PRIVL, CZC_ANY, u8"Kr\u00e1lova" }, + { CZP_JARNI, CZC_ANY, "Horn\u00ed" }, + { CZP_JARNI, CZC_ANY, "Horn\u00ed" }, + { CZP_JARNI, CZC_ANY, "Doln\u00ed" }, + { CZP_JARNI, CZC_ANY, "Doln\u00ed" }, + { CZP_JARNI, CZC_ANY, "P\u0159edn\u00ed" }, + { CZP_JARNI, CZC_ANY, "Zadn\u00ed" }, + { CZP_JARNI, CZC_ANY, "Kosteln\u00ed" }, + { CZP_JARNI, CZC_ANY, "Havran\u00ed" }, + { CZP_JARNI, CZC_ANY, "\u0158\u00ed\u010dn\u00ed" }, + { CZP_JARNI, CZC_ANY, "Jezern\u00ed" }, + { CZP_MLADY, CZC_ANY, "Velk\u00fd" }, + { CZP_MLADY, CZC_ANY, "Velk\u00fd" }, + { CZP_MLADY, CZC_ANY, "Mal\u00fd" }, + { CZP_MLADY, CZC_ANY, "Mal\u00fd" }, + { CZP_MLADY, CZC_ANY, "Vysok\u00fd" }, + { CZP_MLADY, CZC_ANY, "\u010cesk\u00fd" }, + { CZP_MLADY, CZC_ANY, "Moravsk\u00fd" }, + { CZP_MLADY, CZC_ANY, "Slov\u00e1ck\u00fd" }, + { CZP_MLADY, CZC_ANY, "Slezsk\u00fd" }, + { CZP_MLADY, CZC_ANY, "Uhersk\u00fd" }, + { CZP_MLADY, CZC_ANY, "Star\u00fd" }, + { CZP_MLADY, CZC_ANY, "Star\u00fd" }, + { CZP_MLADY, CZC_ANY, "Nov\u00fd" }, + { CZP_MLADY, CZC_ANY, "Nov\u00fd" }, + { CZP_MLADY, CZC_ANY, "Mlad\u00fd" }, + { CZP_MLADY, CZC_ANY, "Kr\u00e1lovsk\u00fd" }, + { CZP_MLADY, CZC_ANY, "Kamenn\u00fd" }, + { CZP_MLADY, CZC_ANY, "Cihlov\u00fd" }, + { CZP_MLADY, CZC_ANY, "Divn\u00fd" }, + { CZP_MLADY, CZC_COLOR, "\u010cerven\u00e1" }, + { CZP_MLADY, CZC_COLOR, "\u010cerven\u00e1" }, + { CZP_MLADY, CZC_COLOR, "\u010cerven\u00e1" }, + { CZP_MLADY, CZC_COLOR, "Zelen\u00e1" }, + { CZP_MLADY, CZC_COLOR, "\u017dlut\u00e1" }, + { CZP_MLADY, CZC_COLOR, "Siv\u00e1" }, + { CZP_MLADY, CZC_COLOR, "\u0160ed\u00e1" }, + { CZP_MLADY, CZC_COLOR, "B\u00edl\u00e1" }, + { CZP_MLADY, CZC_COLOR, "B\u00edl\u00e1" }, + { CZP_MLADY, CZC_COLOR, "Modr\u00e1" }, + { CZP_MLADY, CZC_COLOR, "R\u016f\u017eov\u00e1" }, + { CZP_MLADY, CZC_COLOR, "\u010cern\u00e1" }, + { CZP_PRIVL, CZC_ANY, "Kr\u00e1lova" }, { CZP_PRIVL, CZC_ANY, "Janova" }, { CZP_PRIVL, CZC_ANY, "Karlova" }, - { CZP_PRIVL, CZC_ANY, u8"Kry\u0161tofova" }, - { CZP_PRIVL, CZC_ANY, u8"Ji\u0159\u00edkova" }, + { CZP_PRIVL, CZC_ANY, "Kry\u0161tofova" }, + { CZP_PRIVL, CZC_ANY, "Ji\u0159\u00edkova" }, { CZP_PRIVL, CZC_ANY, "Petrova" }, { CZP_PRIVL, CZC_ANY, "Sudovo" }, }; @@ -1823,17 +1823,17 @@ static const CzechNameSubst _name_czech_subst_full[] = { { CZG_SMASC, CZA_ALL, CZC_COLOR, "Sedlec" }, { CZG_SMASC, CZA_ALL, CZC_COLOR, "Brod" }, { CZG_SMASC, CZA_ALL, CZC_COLOR, "Brod" }, - { CZG_SMASC, CZA_ALL, CZC_NONE, u8"\u00daval" }, - { CZG_SMASC, CZA_ALL, CZC_COLOR, u8"\u017d\u010f\u00e1r" }, + { CZG_SMASC, CZA_ALL, CZC_NONE, "\u00daval" }, + { CZG_SMASC, CZA_ALL, CZC_COLOR, "\u017d\u010f\u00e1r" }, { CZG_SMASC, CZA_ALL, CZC_COLOR, "Smrk" }, { CZG_SFEM, CZA_ALL, CZC_COLOR, "Hora" }, { CZG_SFEM, CZA_ALL, CZC_COLOR, "Lhota" }, { CZG_SFEM, CZA_ALL, CZC_COLOR, "Lhota" }, { CZG_SFEM, CZA_ALL, CZC_COLOR, "Hlava" }, - { CZG_SFEM, CZA_ALL, CZC_COLOR, u8"L\u00edpa" }, + { CZG_SFEM, CZA_ALL, CZC_COLOR, "L\u00edpa" }, { CZG_SNEUT, CZA_ALL, CZC_COLOR, "Pole" }, - { CZG_SNEUT, CZA_ALL, CZC_COLOR, u8"\u00dadol\u00ed" }, - { CZG_PMASC, CZA_ALL, CZC_NONE, u8"\u00davaly" }, + { CZG_SNEUT, CZA_ALL, CZC_COLOR, "\u00dadol\u00ed" }, + { CZG_PMASC, CZA_ALL, CZC_NONE, "\u00davaly" }, { CZG_PFEM, CZA_ALL, CZC_COLOR, "Luka" }, { CZG_PNEUT, CZA_ALL, CZC_COLOR, "Pole" }, }; @@ -1841,46 +1841,46 @@ static const CzechNameSubst _name_czech_subst_full[] = { /* TODO: More stems needed. --pasky */ static const CzechNameSubst _name_czech_subst_stem[] = { { CZG_SMASC, CZA_MIDDLE, CZC_COLOR, "Kostel" }, - { CZG_SMASC, CZA_MIDDLE, CZC_COLOR, u8"Kl\u00e1\u0161ter" }, + { CZG_SMASC, CZA_MIDDLE, CZC_COLOR, "Kl\u00e1\u0161ter" }, { CZG_SMASC, CZA_SHORT, CZC_COLOR, "Lhot" }, { CZG_SFEM, CZA_SHORT, CZC_COLOR, "Lhot" }, { CZG_SFEM, CZA_SHORT, CZC_COLOR, "Hur" }, { CZG_FREE, CZA_MIDDLE | CZA_LONG, CZC_NONE, "Sedl" }, { CZG_FREE, CZA_SHORT | CZA_MIDDLE | CZA_LONG, CZC_COLOR, "Hrad" }, { CZG_NFREE, CZA_MIDDLE, CZC_NONE, "Pras" }, - { CZG_NFREE, CZA_MIDDLE, CZC_NONE, u8"Ba\u017e" }, + { CZG_NFREE, CZA_MIDDLE, CZC_NONE, "Ba\u017e" }, { CZG_NFREE, CZA_MIDDLE, CZC_NONE, "Tes" }, - { CZG_NFREE, CZA_MIDDLE, CZC_NONE, u8"U\u017e" }, - { CZG_NFREE, CZA_MIDDLE | CZA_LONG, CZC_POSTFIX, u8"B\u0159" }, + { CZG_NFREE, CZA_MIDDLE, CZC_NONE, "U\u017e" }, + { CZG_NFREE, CZA_MIDDLE | CZA_LONG, CZC_POSTFIX, "B\u0159" }, { CZG_NFREE, CZA_MIDDLE | CZA_LONG, CZC_NONE, "Vod" }, { CZG_NFREE, CZA_MIDDLE | CZA_LONG, CZC_NONE, "Jan" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Prach" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Kunr" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Strak" }, - { CZG_NFREE, CZA_LONG, CZC_NONE, u8"V\u00edt" }, - { CZG_NFREE, CZA_LONG, CZC_NONE, u8"Vy\u0161" }, - { CZG_NFREE, CZA_LONG, CZC_NONE, u8"\u017dat" }, - { CZG_NFREE, CZA_LONG, CZC_NONE, u8"\u017der" }, - { CZG_NFREE, CZA_LONG, CZC_NONE, u8"St\u0159ed" }, + { CZG_NFREE, CZA_LONG, CZC_NONE, "V\u00edt" }, + { CZG_NFREE, CZA_LONG, CZC_NONE, "Vy\u0161" }, + { CZG_NFREE, CZA_LONG, CZC_NONE, "\u017dat" }, + { CZG_NFREE, CZA_LONG, CZC_NONE, "\u017der" }, + { CZG_NFREE, CZA_LONG, CZC_NONE, "St\u0159ed" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Harv" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Pruh" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Tach" }, - { CZG_NFREE, CZA_LONG, CZC_NONE, u8"P\u00edsn" }, + { CZG_NFREE, CZA_LONG, CZC_NONE, "P\u00edsn" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Jin" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Jes" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Jar" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Sok" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Hod" }, { CZG_NFREE, CZA_LONG, CZC_NONE, "Net" }, - { CZG_FREE, CZA_LONG, CZC_NONE, u8"Pra\u017e" }, + { CZG_FREE, CZA_LONG, CZC_NONE, "Pra\u017e" }, { CZG_FREE, CZA_LONG, CZC_NONE, "Nerat" }, { CZG_FREE, CZA_LONG, CZC_NONE, "Kral" }, { CZG_FREE, CZA_LONG, CZC_NONE, "Hut" }, { CZG_FREE, CZA_LONG, CZC_NOPOSTFIX, "Pan" }, - { CZG_FREE, CZA_SHORT | CZA_MIDDLE | CZA_LONG, CZC_NOPOSTFIX, u8"Odst\u0159ed" }, + { CZG_FREE, CZA_SHORT | CZA_MIDDLE | CZA_LONG, CZC_NOPOSTFIX, "Odst\u0159ed" }, { CZG_FREE, CZA_SHORT | CZA_MIDDLE | CZA_LONG, CZC_COLOR, "Mrat" }, { CZG_FREE, CZA_LONG, CZC_COLOR, "Hlav" }, - { CZG_FREE, CZA_SHORT | CZA_MIDDLE, CZC_NONE, u8"M\u011b\u0159" }, + { CZG_FREE, CZA_SHORT | CZA_MIDDLE, CZC_NONE, "M\u011b\u0159" }, { CZG_FREE, CZA_MIDDLE | CZA_LONG, CZC_NONE, "Lip" }, }; @@ -1894,47 +1894,47 @@ static const char * const _name_czech_subst_postfix[] = { /* This array must have the both neutral genders at the end! */ static const CzechNameSubst _name_czech_subst_ending[] = { { CZG_SMASC, CZA_SHORT | CZA_MIDDLE, CZC_ANY, "ec" }, - { CZG_SMASC, CZA_SHORT | CZA_MIDDLE, CZC_ANY, u8"\u00edn" }, + { CZG_SMASC, CZA_SHORT | CZA_MIDDLE, CZC_ANY, "\u00edn" }, { CZG_SMASC, CZA_SHORT | CZA_MIDDLE | CZA_LONG, CZC_ANY, "ov" }, { CZG_SMASC, CZA_SHORT | CZA_LONG, CZC_ANY, "kov" }, - { CZG_SMASC, CZA_LONG, CZC_POSTFIX, u8"\u00edn" }, - { CZG_SMASC, CZA_LONG, CZC_POSTFIX, u8"n\u00edk" }, + { CZG_SMASC, CZA_LONG, CZC_POSTFIX, "\u00edn" }, + { CZG_SMASC, CZA_LONG, CZC_POSTFIX, "n\u00edk" }, { CZG_SMASC, CZA_LONG, CZC_ANY, "burk" }, { CZG_SFEM, CZA_SHORT, CZC_ANY, "ka" }, { CZG_SFEM, CZA_MIDDLE, CZC_ANY, "inka" }, - { CZG_SFEM, CZA_MIDDLE, CZC_ANY, u8"n\u00e1" }, + { CZG_SFEM, CZA_MIDDLE, CZC_ANY, "n\u00e1" }, { CZG_SFEM, CZA_LONG, CZC_ANY, "ava" }, - { CZG_PMASC, CZA_LONG, CZC_POSTFIX, u8"\u00edky" }, + { CZG_PMASC, CZA_LONG, CZC_POSTFIX, "\u00edky" }, { CZG_PMASC, CZA_LONG, CZC_ANY, "upy" }, { CZG_PMASC, CZA_LONG, CZC_ANY, "olupy" }, { CZG_PFEM, CZA_LONG, CZC_ANY, "avy" }, { CZG_PFEM, CZA_SHORT | CZA_MIDDLE | CZA_LONG, CZC_ANY, "ice" }, - { CZG_PFEM, CZA_SHORT | CZA_MIDDLE | CZA_LONG, CZC_ANY, u8"i\u010dky" }, + { CZG_PFEM, CZA_SHORT | CZA_MIDDLE | CZA_LONG, CZC_ANY, "i\u010dky" }, { CZG_PNEUT, CZA_SHORT | CZA_MIDDLE, CZC_ANY, "na" }, { CZG_SNEUT, CZA_SHORT | CZA_MIDDLE, CZC_ANY, "no" }, - { CZG_SNEUT, CZA_LONG, CZC_ANY, u8"i\u0161t\u011b" }, + { CZG_SNEUT, CZA_LONG, CZC_ANY, "i\u0161t\u011b" }, }; static const char * const _name_czech_suffix[] = { "nad Cidlinou", - u8"nad Dyj\u00ed", + "nad Dyj\u00ed", "nad Jihlavou", "nad Labem", "nad Lesy", "nad Moravou", "nad Nisou", "nad Odrou", - u8"nad Ostravic\u00ed", - u8"nad S\u00e1zavou", + "nad Ostravic\u00ed", + "nad S\u00e1zavou", "nad Vltavou", - u8"pod Prad\u011bdem", - u8"pod Radho\u0161t\u011bm", - u8"pod \u0158\u00edpem", - u8"pod Sn\u011b\u017ekou", - u8"pod \u0160pi\u010d\u00e1kem", + "pod Prad\u011bdem", + "pod Radho\u0161t\u011bm", + "pod \u0158\u00edpem", + "pod Sn\u011b\u017ekou", + "pod \u0160pi\u010d\u00e1kem", "pod Sedlem", - u8"v \u010cech\u00e1ch", - u8"na Morav\u011b", + "v \u010cech\u00e1ch", + "na Morav\u011b", }; @@ -1944,197 +1944,197 @@ static const char * const _name_romanian_real[] = { "Alba Iulia", "Alexandria", "Babadag", - u8"Bac\u0103u", + "Bac\u0103u", "Baia Mare", - u8"B\u0103ile Herculane", - u8"B\u0103ile\u0219ti", - u8"B\u00e2rlad", + "B\u0103ile Herculane", + "B\u0103ile\u0219ti", + "B\u00e2rlad", "Bicaz", - u8"Bistri\u021ba", + "Bistri\u021ba", "Blaj", "Borsec", - u8"Boto\u0219ani", - u8"Br\u0103ila", - u8"Bra\u0219ov", - u8"Bucure\u0219ti", + "Boto\u0219ani", + "Br\u0103ila", + "Bra\u0219ov", + "Bucure\u0219ti", "Buftea", - u8"Buz\u0103u", - u8"C\u0103l\u0103ra\u0219i", - u8"Caransebe\u0219", - u8"Cernavod\u0103", + "Buz\u0103u", + "C\u0103l\u0103ra\u0219i", + "Caransebe\u0219", + "Cernavod\u0103", "Cluj-Napoca", - u8"Constan\u021ba", + "Constan\u021ba", "Covasna", "Craiova", "Dej", "Deva", "Dorohoi", "Drobeta-Turnu Severin", - u8"Dr\u0103g\u0103\u0219ani", - u8"F\u0103g\u0103ra\u0219", - u8"F\u0103lticeni", - u8"Fete\u0219ti", - u8"Foc\u0219ani", - u8"Gala\u021bi", + "Dr\u0103g\u0103\u0219ani", + "F\u0103g\u0103ra\u0219", + "F\u0103lticeni", + "Fete\u0219ti", + "Foc\u0219ani", + "Gala\u021bi", "Gheorgheni", "Giurgiu", - u8"H\u00e2r\u0219ova", + "H\u00e2r\u0219ova", "Hunedoara", - u8"Hu\u0219i", - u8"Ia\u0219i", + "Hu\u0219i", + "Ia\u0219i", "Isaccea", "Lugoj", - u8"M\u0103cin", + "M\u0103cin", "Mangalia", "Medgidia", - u8"Media\u0219", + "Media\u0219", "Miercurea Ciuc", "Mizil", "Motru", - u8"N\u0103s\u0103ud", - u8"N\u0103vodari", - u8"Odobe\u0219ti", - u8"Olteni\u021ba", - u8"One\u0219ti", + "N\u0103s\u0103ud", + "N\u0103vodari", + "Odobe\u0219ti", + "Olteni\u021ba", + "One\u0219ti", "Oradea", - u8"Or\u0219ova", - u8"Petro\u0219ani", - u8"Piatra Neam\u021b", - u8"Pite\u0219ti", - u8"Ploie\u0219ti", + "Or\u0219ova", + "Petro\u0219ani", + "Piatra Neam\u021b", + "Pite\u0219ti", + "Ploie\u0219ti", "Predeal", - u8"R\u00e2mnicu V\u00e2lcea", + "R\u00e2mnicu V\u00e2lcea", "Reghin", - u8"Re\u0219i\u021ba", + "Re\u0219i\u021ba", "Roman", - u8"Ro\u0219iorii de Vede", + "Ro\u0219iorii de Vede", "Satu Mare", - u8"Sebe\u0219", - u8"Sf\u00e2ntu Gheorghe", + "Sebe\u0219", + "Sf\u00e2ntu Gheorghe", "Sibiu", - u8"Sighi\u0219oara", + "Sighi\u0219oara", "Sinaia", "Slatina", "Slobozia", "Sovata", "Suceava", "Sulina", - u8"\u021a\u0103nd\u0103rei", - u8"T\u00e2rgovi\u0219te", - u8"T\u00e2rgu Jiu", - u8"T\u00e2rgu Mure\u0219", + "\u021a\u0103nd\u0103rei", + "T\u00e2rgovi\u0219te", + "T\u00e2rgu Jiu", + "T\u00e2rgu Mure\u0219", "Tecuci", - u8"Timi\u0219oara", + "Timi\u0219oara", "Tulcea", "Turda", - u8"Turnu M\u0103gurele", + "Turnu M\u0103gurele", "Urziceni", "Vaslui", "Vatra Dornei", "Victoria", "Videle", - u8"Zal\u0103u", + "Zal\u0103u", }; static const char * const _name_slovak_real[] = { "Bratislava", - u8"B\u00e1novce nad Bebravou", - u8"Bansk\u00e1 Bystrica", - u8"Bansk\u00e1 \u0160tiavnica", + "B\u00e1novce nad Bebravou", + "Bansk\u00e1 Bystrica", + "Bansk\u00e1 \u0160tiavnica", "Bardejov", "Brezno", "Brezova pod Bradlom", - u8"Byt\u010da", - u8"\u010cadca", - u8"\u010cierna nad Tisou", + "Byt\u010da", + "\u010cadca", + "\u010cierna nad Tisou", "Detva", - u8"Pre\u0161ov", + "Pre\u0161ov", "Dolny Kubin", - u8"Spi\u0161sk\u00e1 Nov\u00e1 Ves", - u8"Dunajsk\u00e1 Streda", - u8"Gab\u010d\u00edikovo", + "Spi\u0161sk\u00e1 Nov\u00e1 Ves", + "Dunajsk\u00e1 Streda", + "Gab\u010d\u00edikovo", "Galanta", "Gbely", "Gelnica", - u8"Handlov\u00e1", + "Handlov\u00e1", "Hlohovec", - u8"Hol\u00ed\u010d", - u8"Humenn\u00e9", + "Hol\u00ed\u010d", + "Humenn\u00e9", "Hurbanovo", "Kezmarok", - u8"Kom\u00e1rno", - u8"Ko\u0161ice", + "Kom\u00e1rno", + "Ko\u0161ice", "Kremnica", "Krompachy", "Kuty", "Leopoldov", - u8"Levo\u010da", - u8"Liptovsk\u00fd Mikul\u00e1\u0161", - u8"Lu\u010denec", + "Levo\u010da", + "Liptovsk\u00fd Mikul\u00e1\u0161", + "Lu\u010denec", "Malacky", "Martin", "Medzilaborce", "Michalovce", "Modra", "Myjava", - u8"N\u00e1mestovo", + "N\u00e1mestovo", "Nitra", - u8"Nov\u00e1 Ba\u0148a", - u8"Nov\u00e9 Mesto nad V\u00e1hom", - u8"Nov\u00e9 Z\u00e1mky", - u8"Partiz\u00e1nske", + "Nov\u00e1 Ba\u0148a", + "Nov\u00e9 Mesto nad V\u00e1hom", + "Nov\u00e9 Z\u00e1mky", + "Partiz\u00e1nske", "Pezinok", - u8"Pie\u0161\u0165any", - u8"Polt\u00e1r", + "Pie\u0161\u0165any", + "Polt\u00e1r", "Poprad", - u8"Pova\u017esk\u00e1 Bystrica", + "Pova\u017esk\u00e1 Bystrica", "Prievidza", - u8"P\u00fachov", - u8"Rev\u00faca", - u8"Rimavsk\u00e1 Sobota", - u8"Ro\u017e\u0148ava", - u8"Ru\u017eomberok", + "P\u00fachov", + "Rev\u00faca", + "Rimavsk\u00e1 Sobota", + "Ro\u017e\u0148ava", + "Ru\u017eomberok", "Sabinov", - u8"\u0160a\u013ea", + "\u0160a\u013ea", "Senec", "Senica", - u8"Sere\u010f", + "Sere\u010f", "Skalica", - u8"Sl\u00e1dkovi\u00cdovo", + "Sl\u00e1dkovi\u00cdovo", "Smolenice", "Snina", - u8"Star\u00e1 \u013dubov\u0148a", - u8"Star\u00e1 Tur\u00e1", - u8"Str\u00e1\u017eske", + "Star\u00e1 \u013dubov\u0148a", + "Star\u00e1 Tur\u00e1", + "Str\u00e1\u017eske", "Stropkov", "Stupava", - u8"\u0160t\u00farovo", - u8"\u0120ulekovo", - u8"Topo\u013e\u010dany", - u8"Trebi\u0161ov", - u8"Tren\u010d\u00edn", + "\u0160t\u00farovo", + "\u0120ulekovo", + "Topo\u013e\u010dany", + "Trebi\u0161ov", + "Tren\u010d\u00edn", "Trnava", - u8"Tur\u010dianske Teplice", - u8"Tvrdo\u0161\u00edn", - u8"Vr\u00e1ble", - u8"Vranov nad Top\u013eou", - u8"Z\u00e1horsk\u00e1 Bystrica", - u8"\u017ddiar", - u8"\u013diar nad Hronom", - u8"\u017dilina", - u8"Zlat\u00e9 Moravce", + "Tur\u010dianske Teplice", + "Tvrdo\u0161\u00edn", + "Vr\u00e1ble", + "Vranov nad Top\u013eou", + "Z\u00e1horsk\u00e1 Bystrica", + "\u017ddiar", + "\u013diar nad Hronom", + "\u017dilina", + "Zlat\u00e9 Moravce", "Zvolen", }; static const char * const _name_norwegian_1[] = { "Arna", "Aust", - u8"Bj\u00f8rk", - u8"Bj\u00f8rn", + "Bj\u00f8rk", + "Bj\u00f8rn", "Brand", - u8"B\u00f8ver", + "B\u00f8ver", "Drag", - u8"Dr\u00f8", + "Dr\u00f8", "Eids", "Egge", "Fager", @@ -2147,12 +2147,12 @@ static const char * const _name_norwegian_1[] = { "Gaus", "Galte", "Geir", - u8"Gl\u00f8s", + "Gl\u00f8s", "Gran", "Grind", "Grims", - u8"Gr\u00f8n", - u8"Gr\u00f8t", + "Gr\u00f8n", + "Gr\u00f8t", "Gulle", "Haka", "Hammer", @@ -2167,7 +2167,7 @@ static const char * const _name_norwegian_1[] = { "Kjerring", "Knatte", "Krok", - u8"K\u00f8y", + "K\u00f8y", "Lang", "Lauv", "Leir", @@ -2175,7 +2175,7 @@ static const char * const _name_norwegian_1[] = { "Logn", "Lo", "Lyng", - u8"L\u00f8n", + "L\u00f8n", "Mesna", "Mel", "Mo", @@ -2195,9 +2195,9 @@ static const char * const _name_norwegian_1[] = { "Sel", "Sol", "Sjur", - u8"Sk\u00e5r", - u8"Sl\u00e5tt", - u8"Stj\u00f8r", + "Sk\u00e5r", + "Sl\u00e5tt", + "Stj\u00f8r", "Stor", "Svart", "Svens", @@ -2210,7 +2210,7 @@ static const char * const _name_norwegian_1[] = { "Vest", "Vesle", "Vik", - u8"V\u00e5g", + "V\u00e5g", }; static const char * const _name_norwegian_2[] = { @@ -2225,7 +2225,7 @@ static const char * const _name_norwegian_2[] = { "bugen", "by", "bygd", - u8"b\u00f8", + "b\u00f8", "dal", "egga", "eid", @@ -2243,10 +2243,10 @@ static const char * const _name_norwegian_2[] = { "heim", "hella", "hovda", - u8"h\u00f8a", - u8"h\u00f8gda", + "h\u00f8a", + "h\u00f8gda", "kampen", - u8"kj\u00f8len", + "kj\u00f8len", "kollen", "kroken", "land", @@ -2261,7 +2261,7 @@ static const char * const _name_norwegian_2[] = { "rud", "sand", "set", - u8"sj\u00f8en", + "sj\u00f8en", "skogen", "slette", "snipa", @@ -2270,7 +2270,7 @@ static const char * const _name_norwegian_2[] = { "stulen", "sund", "svingen", - u8"s\u00e6tra", + "s\u00e6tra", "tinden", "tun", "vang", @@ -2278,9 +2278,9 @@ static const char * const _name_norwegian_2[] = { "veid", "vik", "voll", - u8"v\u00e5g", + "v\u00e5g", "um", - u8"\u00e5sen", + "\u00e5sen", }; static const char * const _name_norwegian_real[] = { @@ -2288,12 +2288,12 @@ static const char * const _name_norwegian_real[] = { "Arendal", "Askim", "Bergen", - u8"Bod\u00f8", + "Bod\u00f8", "Brevik", "Bryne", - u8"Br\u00f8nn\u00f8ysund", + "Br\u00f8nn\u00f8ysund", "Drammen", - u8"Dr\u00f8bak", + "Dr\u00f8bak", "Egersund", "Elverum", "Farsund", @@ -2301,10 +2301,10 @@ static const char * const _name_norwegian_real[] = { "Finnsnes", "Flekkefjord", "Flora", - u8"Fosnav\u00e5g", + "Fosnav\u00e5g", "Fredrikstad", - u8"F\u00f8rde", - u8"Gj\u00f8vik", + "F\u00f8rde", + "Gj\u00f8vik", "Grimstad", "Halden", "Hamar", @@ -2313,13 +2313,13 @@ static const char * const _name_norwegian_real[] = { "Haugesund", "Holmestrand", "Horten", - u8"J\u00f8rpeland", + "J\u00f8rpeland", "Kirkenes", "Kolvereid", "Kongsberg", "Kongsvinger", "Kopervik", - u8"Krager\u00f8", + "Krager\u00f8", "Kristiansand", "Kristiansund", "Langesund", @@ -2329,16 +2329,16 @@ static const char * const _name_norwegian_real[] = { "Levanger", "Lillehammer", "Lillesand", - u8"Lillestr\u00f8m", + "Lillestr\u00f8m", "Lyngdal", - u8"L\u00f8renskog", + "L\u00f8renskog", "Mandal", "Mo i Rana", "Molde", - u8"Mosj\u00f8en", + "Mosj\u00f8en", "Moss", "Mysen", - u8"M\u00e5l\u00f8y", + "M\u00e5l\u00f8y", "Namsos", "Narvik", "Notodden", @@ -2347,11 +2347,11 @@ static const char * const _name_norwegian_real[] = { "Otta", "Porsgrunn", "Ringerike", - u8"Ris\u00f8r", + "Ris\u00f8r", "Rjukan", "Sandefjord", "Sandnes", - u8"Sandnessj\u00f8en", + "Sandnessj\u00f8en", "Sandvika", "Sarpsborg", "Sauda", @@ -2362,152 +2362,152 @@ static const char * const _name_norwegian_real[] = { "Stathelle", "Stavanger", "Steinkjer", - u8"Stj\u00f8rdal", + "Stj\u00f8rdal", "Stokmarknes", "Stord", "Svelvik", - u8"Svolv\u00e6r", - u8"Troms\u00f8", + "Svolv\u00e6r", + "Troms\u00f8", "Trondheim", "Tvedestrand", - u8"T\u00f8nsberg", + "T\u00f8nsberg", "Ulsteinvik", - u8"Vads\u00f8", - u8"Vard\u00f8", - u8"Verdals\u00f8ra", - u8"\u00c5krehamn", - u8"\u00c5lesund", - u8"\u00c5ndalsnes", + "Vads\u00f8", + "Vard\u00f8", + "Verdals\u00f8ra", + "\u00c5krehamn", + "\u00c5lesund", + "\u00c5ndalsnes", }; static const char * const _name_hungarian_1[] = { "Nagy-", "Kis-", - u8"Fels\u0151-", - u8"Als\u00f3-", - u8"\u00daj-", + "Fels\u0151-", + "Als\u00f3-", + "\u00daj-", }; static const char * const _name_hungarian_2[] = { "Bodrog", - u8"Dr\u00e1va", + "Dr\u00e1va", "Duna", - u8"Hej\u0151", - u8"Hern\u00e1d", - u8"R\u00e1ba", - u8"Saj\u00f3", + "Hej\u0151", + "Hern\u00e1d", + "R\u00e1ba", + "Saj\u00f3", "Szamos", "Tisza", "Zala", "Balaton", - u8"Fert\u0151", + "Fert\u0151", "Bakony", - u8"Cserh\u00e1t", + "Cserh\u00e1t", "Bihar", - u8"Hajd\u00fa", - u8"J\u00e1sz", + "Hajd\u00fa", + "J\u00e1sz", "Kun", "Magyar", - u8"N\u00f3gr\u00e1d", - u8"Ny\u00edr", + "N\u00f3gr\u00e1d", + "Ny\u00edr", "Somogy", - u8"Sz\u00e9kely", + "Sz\u00e9kely", "Buda", - u8"Gy\u0151r", + "Gy\u0151r", "Pest", - u8"Feh\u00e9r", - u8"Cser\u00e9p", - u8"Erd\u0151", + "Feh\u00e9r", + "Cser\u00e9p", + "Erd\u0151", "Hegy", "Homok", - u8"Mez\u0151", + "Mez\u0151", "Puszta", - u8"S\u00e1r", - u8"Cs\u00e1sz\u00e1r", + "S\u00e1r", + "Cs\u00e1sz\u00e1r", "Herceg", - u8"Kir\u00e1ly", + "Kir\u00e1ly", "Nemes", - u8"P\u00fcsp\u00f6k", + "P\u00fcsp\u00f6k", "Szent", - u8"Alm\u00e1s", - u8"Szilv\u00e1s", + "Alm\u00e1s", + "Szilv\u00e1s", "Agg", "Aranyos", - u8"B\u00e9k\u00e9s", - u8"Egyh\u00e1zas", + "B\u00e9k\u00e9s", + "Egyh\u00e1zas", "Gagy", "Heves", "Kapos", - u8"T\u00e1pi\u00f3", + "T\u00e1pi\u00f3", "Torna", "Vas", - u8"V\u00e1mos", - u8"V\u00e1s\u00e1ros", + "V\u00e1mos", + "V\u00e1s\u00e1ros", }; static const char * const _name_hungarian_3[] = { - u8"ap\u00e1ti", - u8"b\u00e1ba", + "ap\u00e1ti", + "b\u00e1ba", "bikk", "dob", "fa", - u8"f\u00f6ld", + "f\u00f6ld", "hegyes", "kak", "kereszt", - u8"k\u00fcrt", - u8"lad\u00e1ny", - u8"m\u00e9rges", + "k\u00fcrt", + "lad\u00e1ny", + "m\u00e9rges", "szalonta", "telek", "vas", - u8"v\u00f6lgy", + "v\u00f6lgy", }; static const char * const _name_hungarian_4[] = { "alja", - u8"egyh\u00e1za", - u8"h\u00e1za", - u8"\u00far", - u8"v\u00e1r", + "egyh\u00e1za", + "h\u00e1za", + "\u00far", + "v\u00e1r", }; static const char * const _name_hungarian_real[] = { "Ajka", - u8"Asz\u00f3d", + "Asz\u00f3d", "Badacsony", "Baja", "Budapest", "Debrecen", "Eger", - u8"Fony\u00f3d", - u8"G\u00f6d\u00f6ll\u0151", - u8"Gy\u0151r", + "Fony\u00f3d", + "G\u00f6d\u00f6ll\u0151", + "Gy\u0151r", "Gyula", "Karcag", - u8"Kecskem\u00e9t", + "Kecskem\u00e9t", "Keszthely", - u8"Kisk\u00f6re", + "Kisk\u00f6re", "Kocsord", - u8"Kom\u00e1rom", - u8"K\u0151szeg", - u8"Mak\u00f3", - u8"Moh\u00e1cs", + "Kom\u00e1rom", + "K\u0151szeg", + "Mak\u00f3", + "Moh\u00e1cs", "Miskolc", - u8"\u00d3zd", + "\u00d3zd", "Paks", - u8"P\u00e1pa", - u8"P\u00e9cs", - u8"Polg\u00e1r", + "P\u00e1pa", + "P\u00e9cs", + "Polg\u00e1r", "Sarkad", - u8"Si\u00f3fok", + "Si\u00f3fok", "Szeged", "Szentes", "Szolnok", "Tihany", "Tokaj", - u8"V\u00e1c", - u8"Z\u00e1hony", + "V\u00e1c", + "Z\u00e1hony", "Zirc", }; @@ -2518,7 +2518,7 @@ static const char * const _name_swiss_real[] = { "Arosa", "Appenzell", "Arbon", - u8"Altst\u00e4tten", + "Altst\u00e4tten", "Baar", "Baden", "Bellinzona", @@ -2529,20 +2529,20 @@ static const char * const _name_swiss_real[] = { "Burgdorf", "Bern", "Basel", - u8"B\u00fclach", + "B\u00fclach", "Carouge", "Cham", "Chiasso", "Chur", "Davos", - u8"Del\u00e9mont", + "Del\u00e9mont", "Dietikon", - u8"D\u00fcbendorf", + "D\u00fcbendorf", "Emmen", - u8"Freienbach-Pf\u00e4ffikon", + "Freienbach-Pf\u00e4ffikon", "Fribourg", "Frauenfeld", - u8"Gen\u00e8ve", + "Gen\u00e8ve", "Glarus", "Gossau", "Grenchen", @@ -2554,9 +2554,9 @@ static const char * const _name_swiss_real[] = { "Jona", "Kriens", "Kloten", - u8"K\u00f6niz", + "K\u00f6niz", "Kreuzlingen", - u8"K\u00fcsnacht", + "K\u00fcsnacht", "Agen", "Lancy", "La Chaux-de-Fonds", @@ -2573,7 +2573,7 @@ static const char * const _name_swiss_real[] = { "Lyss", "Luzern", "Martigny", - u8"M\u00fcnchenstein", + "M\u00fcnchenstein", "Meyrin", "Montreux", "Monthey", @@ -2581,7 +2581,7 @@ static const char * const _name_swiss_real[] = { "Murten", "Moutier", "Muttenz", - u8"Neuch\u00e2tel", + "Neuch\u00e2tel", "Neuhausen am Rheinfall", "Nyon", "Olten", @@ -2610,11 +2610,11 @@ static const char * const _name_swiss_real[] = { "St. Moritz", "Sion", "Spiez", - u8"St\u00e4fa", + "St\u00e4fa", "Sursee", "Schwyz", "Thalwil", - u8"Th\u00f4nex", + "Th\u00f4nex", "Thun", "Uster", "Uzwil", @@ -2622,7 +2622,7 @@ static const char * const _name_swiss_real[] = { "Volketswil", "Versoix", "Vevey", - u8"W\u00e4denswil", + "W\u00e4denswil", "Wettingen", "Wil", "Wallisellen", @@ -2633,7 +2633,7 @@ static const char * const _name_swiss_real[] = { "Yverdon-les-Bains", "Zollikon", "Zofingen", - u8"Z\u00fcrich", + "Z\u00fcrich", "Zug", }; @@ -2643,12 +2643,12 @@ static const char * const _name_danish_1[] = { "Nye ", "Store ", "Kirke ", - u8"N\u00f8rre ", + "N\u00f8rre ", "Vester ", - u8"S\u00f8nder ", - u8"\u00d8ster ", + "S\u00f8nder ", + "\u00d8ster ", "Hvide ", - u8"H\u00f8je ", + "H\u00f8je ", "Kongens ", }; @@ -2660,7 +2660,7 @@ static const char * const _name_danish_2[] = { "Bede", "Birke", "Bjerring", - u8"Bj\u00e6ver", + "Bj\u00e6ver", "Blommens", "Blok", "Bolder", @@ -2673,7 +2673,7 @@ static const char * const _name_danish_2[] = { "Fredens", "Frederiks", "Fugle", - u8"F\u00e5re", + "F\u00e5re", "Gille", "Gis", "Givs", @@ -2690,11 +2690,11 @@ static const char * const _name_danish_2[] = { "Hol", "Horn", "Humle", - u8"H\u00f8j", - u8"H\u00f8r", + "H\u00f8j", + "H\u00f8r", "Is", "Jyde", - u8"J\u00e6gers", + "J\u00e6gers", "Karls", "Klov", "Kokke", @@ -2706,24 +2706,24 @@ static const char * const _name_danish_2[] = { "Ny", "Oks", "Ring", - u8"R\u00f8de", + "R\u00f8de", "Rung", - u8"R\u00f8r", + "R\u00f8r", "Rud", "Saks", "Salt", "Skam", "Silke", "Skod", - u8"Sk\u00e6l", - u8"Sk\u00e6r", + "Sk\u00e6l", + "Sk\u00e6r", "Sol", "Svend", "Svine", "Strand", "Stubbe", "Ting", - u8"Tj\u00e6re", + "Tj\u00e6re", "Tore", "Uger", "Ulf", @@ -2731,9 +2731,9 @@ static const char * const _name_danish_2[] = { "Vand", "Vej", "Vor", - u8"V\u00e6r", - u8"\u00d8r", - u8"\u00c5l", + "V\u00e6r", + "\u00d8r", + "\u00c5l", }; static const char * const _name_danish_3[] = { @@ -2746,21 +2746,21 @@ static const char * const _name_danish_3[] = { "strup", "holm", "hus", - u8"k\u00f8bing", + "k\u00f8bing", "lund", "lunde", "sund", "ovre", - u8"h\u00f8j", + "h\u00f8j", "dal", "sted", "sten", - u8"l\u00f8se", - u8"r\u00f8d", + "l\u00f8se", + "r\u00f8d", "magle", - u8"s\u00f8", + "s\u00f8", "bjerg", - u8"b\u00e6k", + "b\u00e6k", "drup", "lev", "bo", @@ -2770,32 +2770,32 @@ static const char * const _name_danish_3[] = { }; static const char * const _name_turkish_prefix[] = { - u8"Ak\u00e7a", - u8"Alt\u0131n", - u8"Bah\u00e7e", + "Ak\u00e7a", + "Alt\u0131n", + "Bah\u00e7e", "Boz", - u8"B\u00fcy\u00fck", - u8"\u00c7ay", - u8"Do\u011fu", + "B\u00fcy\u00fck", + "\u00c7ay", + "Do\u011fu", "Eski", - u8"G\u00fczel", - u8"K\u0131z\u0131l", - u8"K\u00fc\u00e7\u00fck", + "G\u00fczel", + "K\u0131z\u0131l", + "K\u00fc\u00e7\u00fck", "Orta", - u8"Sar\u0131", + "Sar\u0131", "Sultan", "Ulu", "Yeni", }; static const char * const _name_turkish_middle[] = { - u8"aga\u00e7", + "aga\u00e7", "ayva", - u8"\u00e7am", + "\u00e7am", "elma", "kurt", "pazar", - u8"yal\u0131", + "yal\u0131", }; static const char * const _name_turkish_suffix[] = { @@ -2804,10 +2804,10 @@ static const char * const _name_turkish_suffix[] = { "kale", "kaya", "kent", - u8"k\u00f6y", + "k\u00f6y", "ova", - u8"\u00f6z\u00fc", - u8"\u00f6ren", + "\u00f6z\u00fc", + "\u00f6ren", "pazar", "saray", "tepe", @@ -2817,48 +2817,48 @@ static const char * const _name_turkish_suffix[] = { static const char * const _name_turkish_real[] = { "Adana", - u8"Ad\u0131yaman", + "Ad\u0131yaman", "Afyon", - u8"A\u011fr\u0131", + "A\u011fr\u0131", "Amasya", "Antalya", "Artvin", - u8"Bal\u0131kesir", + "Bal\u0131kesir", "Bilecik", "Bitlis", "Bolu", "Burdur", "Bursa", - u8"\u00c7anakkale", - u8"\u00c7ank\u0131r\u0131", + "\u00c7anakkale", + "\u00c7ank\u0131r\u0131", "Denizli", - u8"Diyarbak\u0131r", + "Diyarbak\u0131r", "Edirne", - u8"Elaz\u0131\u011f", + "Elaz\u0131\u011f", "Erzurum", - u8"Eski\u015fehir", + "Eski\u015fehir", "Giresun", - u8"G\u00fcm\u00fc\u015fhane", + "G\u00fcm\u00fc\u015fhane", "Hatay", "Isparta", - u8"\u0130\u00e7el", - u8"\u0130stanbul", - u8"\u0130zmir", + "\u0130\u00e7el", + "\u0130stanbul", + "\u0130zmir", "Kars", "Kastamonu", "Kayseri", "Kirklareli", "Kocaeli", "Konya", - u8"K\u00fctahya", + "K\u00fctahya", "Malatya", "Manisa", - u8"Kahramanmara\u015f", + "Kahramanmara\u015f", "Mardin", - u8"Mu\u011fla", - u8"Mu\u015f", - u8"Nev\u015fehir", - u8"Ni\u011fde", + "Mu\u011fla", + "Mu\u015f", + "Nev\u015fehir", + "Ni\u011fde", "Rize", "Sakarya", "Samsun", @@ -2866,21 +2866,21 @@ static const char * const _name_turkish_real[] = { "Sinop", "Sivas", "Trabzon", - u8"\u015eanl\u0131urfa", + "\u015eanl\u0131urfa", "Van", "Yozgat", "Zonguldak", "Aksaray", "Bayburt", "Karaman", - u8"\u015e\u0131rnak", - u8"Bart\u0131n", + "\u015e\u0131rnak", + "Bart\u0131n", "Ardahan", - u8"I\u011fd\u0131r", + "I\u011fd\u0131r", "Yalova", - u8"Karab\u00fck", + "Karab\u00fck", "Osmaniye", - u8"D\u00fczce", + "D\u00fczce", }; static const char * const _name_italian_real[] = { @@ -3172,7 +3172,7 @@ static const char * const _name_catalan_real[] = { "Banyoles", "Figueres", "Balaguer", - u8"Vilafranca del Pened\u00e8s", + "Vilafranca del Pened\u00e8s", "La Seu d'Urgell", "El Pont de Suert", "Igualada", @@ -3188,21 +3188,21 @@ static const char * const _name_catalan_real[] = { "Ripoll", "Cervera", "Gandesa", - u8"Matar\u00f3", + "Matar\u00f3", "Montblanc", - u8"Vilanova i la Geltr\u00fa", - u8"T\u00e0rrega", + "Vilanova i la Geltr\u00fa", + "T\u00e0rrega", "Camprodon", - u8"Campdev\u00e0nol", + "Campdev\u00e0nol", "Cambrils", "Begur", "Setcases", "Palafrugell", "Begues", "El Bruc", - u8"Cadaqu\u00e9s", - u8"Collbat\u00f3", - u8"Cervell\u00f3", + "Cadaqu\u00e9s", + "Collbat\u00f3", + "Cervell\u00f3", "Esparreguera", "Abrera", "Alp", @@ -3213,7 +3213,7 @@ static const char * const _name_catalan_real[] = { "Molins de Rei", "Monistrol", "Rocallaura", - u8"Rub\u00ed", + "Rub\u00ed", "Ripollet", "Sitges", "Roses", @@ -3243,14 +3243,14 @@ static const char * const _name_catalan_pref[] = { "Sant Joan de ", "Sant Feliu de ", "Sant Quirze de ", - u8"Sant Sadurn\u00ed de ", + "Sant Sadurn\u00ed de ", "Santa Coloma de ", "Santa Margarida de ", "Santa Maria de ", - u8"Sant Mart\u00ed de ", + "Sant Mart\u00ed de ", "Sant Pere de ", - u8"Sant Juli\u00e0 de ", - u8"Sant Vicen\u00e7 de ", + "Sant Juli\u00e0 de ", + "Sant Vicen\u00e7 de ", }; @@ -3279,10 +3279,10 @@ static const char * const _name_catalan_2m[] = { "baix", "fosc", "pelat", - u8"vent\u00f3s", + "vent\u00f3s", "negre", "roig", - u8"gr\u00eds", + "gr\u00eds", }; static const char * const _name_catalan_2f[] = { @@ -3297,14 +3297,14 @@ static const char * const _name_catalan_2f[] = { }; static const char * const _name_catalan_3[] = { - u8" Desp\u00ed", + " Desp\u00ed", " Desvern", - u8" del Cam\u00ed", + " del Cam\u00ed", " de Mar", " de Dalt", " de Baix", - u8" del Vall\u00e8s", - u8" de Bergued\u00e0", + " del Vall\u00e8s", + " de Bergued\u00e0", " de Conflent", " de la Plana", }; @@ -3315,5 +3315,5 @@ static const char * const _name_catalan_river1[] = { " de Llobregat", " d'Ebre", " de Segre", - u8" de Francol\u00ed", + " de Francol\u00ed", }; diff --git a/src/tbtr_template_gui_create.cpp b/src/tbtr_template_gui_create.cpp index cf4d992550..089e00e39e 100644 --- a/src/tbtr_template_gui_create.cpp +++ b/src/tbtr_template_gui_create.cpp @@ -67,7 +67,7 @@ enum TemplateReplaceCreateWindowWidgets { TCW_CLONE, }; -static const NWidgetPart _widgets[] = { +static constexpr NWidgetPart _widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, TCW_CAPTION), SetDataTip(STR_TMPL_CREATEGUI_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/tbtr_template_gui_main.cpp b/src/tbtr_template_gui_main.cpp index 78d4a26e54..51cea979c2 100644 --- a/src/tbtr_template_gui_main.cpp +++ b/src/tbtr_template_gui_main.cpp @@ -99,7 +99,7 @@ enum TemplateReplaceWindowWidgets { TRW_WIDGET_SEL_TMPL_DISPLAY_CREATE, }; -static const NWidgetPart _widgets[] = { +static constexpr NWidgetPart _widgets[] = { // Title bar NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 0d35d78784..7beaef0c6f 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -386,7 +386,7 @@ static Hotkey terraform_hotkeys[] = { }; HotkeyList TerraformToolbarWindow::hotkeys("terraform", terraform_hotkeys, TerraformToolbarGlobalHotkeys); -static const NWidgetPart _nested_terraform_widgets[] = { +static constexpr NWidgetPart _nested_terraform_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_LANDSCAPING_TOOLBAR, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -517,7 +517,7 @@ static const int8_t _multi_terraform_coords[][2] = { {-28, 0}, {-24, -2}, {-20, -4}, {-16, -6}, {-12, -8}, { -8,-10}, { -4,-12}, { 0,-14}, { 4,-12}, { 8,-10}, { 12, -8}, { 16, -6}, { 20, -4}, { 24, -2}, { 28, 0}, }; -static const NWidgetPart _nested_scen_edit_land_gen_widgets[] = { +static constexpr NWidgetPart _nested_scen_edit_land_gen_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TERRAFORM_TOOLBAR_LAND_GENERATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 6dc8b5a41e..aca3d6b109 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -40,7 +40,7 @@ #include "safeguards.h" /** Widgets for the textfile window. */ -static const NWidgetPart _nested_textfile_widgets[] = { +static constexpr NWidgetPart _nested_textfile_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_MAUVE), NWidget(WWT_PUSHARROWBTN, COLOUR_MAUVE, WID_TF_NAVBACK), SetFill(0, 1), SetMinimalSize(15, 1), SetDataTip(AWV_DECREASE, STR_TEXTFILE_NAVBACK_TOOLTIP), @@ -803,7 +803,7 @@ static void Xunzip(byte **bufp, size_t *sizep) std::string_view sv_buf(buf, filesize); /* Check for the byte-order-mark, and skip it if needed. */ - if (StrStartsWith(sv_buf, u8"\ufeff")) sv_buf.remove_prefix(3); + if (StrStartsWith(sv_buf, "\ufeff")) sv_buf.remove_prefix(3); /* Update the filename. */ this->filepath = textfile; diff --git a/src/textfile_type.h b/src/textfile_type.h index a1c0c6569b..8482106f12 100644 --- a/src/textfile_type.h +++ b/src/textfile_type.h @@ -26,5 +26,6 @@ enum TextfileType { TFT_END, }; DECLARE_POSTFIX_INCREMENT(TextfileType) +DECLARE_ENUM_AS_ADDABLE(TextfileType) #endif /* TEXTFILE_TYPE_H */ diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 0294874e15..2141d52b3a 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -1172,7 +1172,7 @@ struct TimetableWindow : GeneralVehicleWindow { } }; -static const NWidgetPart _nested_timetable_widgets[] = { +static constexpr NWidgetPart _nested_timetable_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_VT_CAPTION), SetDataTip(STR_TIMETABLE_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 73dc0a5ab4..d124737e5b 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -2375,7 +2375,7 @@ static std::unique_ptr MakeMainToolbar() return hor; } -static const NWidgetPart _nested_toolbar_normal_widgets[] = { +static constexpr NWidgetPart _nested_toolbar_normal_widgets[] = { NWidgetFunction(MakeMainToolbar), }; @@ -2700,7 +2700,7 @@ static Hotkey scenedit_maintoolbar_hotkeys[] = { }; HotkeyList ScenarioEditorToolbarWindow::hotkeys("scenedit_maintoolbar", scenedit_maintoolbar_hotkeys); -static const NWidgetPart _nested_toolb_scen_inner_widgets[] = { +static constexpr NWidgetPart _nested_toolb_scen_inner_widgets[] = { NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_PAUSE), SetDataTip(SPR_IMG_PAUSE, STR_TOOLBAR_TOOLTIP_PAUSE_GAME), NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_FAST_FORWARD), SetDataTip(SPR_IMG_FASTFORWARD, STR_TOOLBAR_TOOLTIP_FORWARD), NWidget(WWT_IMGBTN, COLOUR_GREY, WID_TE_SETTINGS), SetDataTip(SPR_IMG_SETTINGS, STR_TOOLBAR_TOOLTIP_OPTIONS), @@ -2740,7 +2740,7 @@ static std::unique_ptr MakeScenarioToolbar() 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[] = { +static constexpr NWidgetPart _nested_toolb_scen_widgets[] = { NWidgetFunction(MakeScenarioToolbar), }; diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 37618d1a0d..13554bdc9c 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -53,7 +53,7 @@ typedef GUIList GUITownList; static void PlaceProc_House(TileIndex tile); -static const NWidgetPart _nested_town_authority_widgets[] = { +static constexpr NWidgetPart _nested_town_authority_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TA_CAPTION), SetDataTip(STR_LOCAL_AUTHORITY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -775,7 +775,7 @@ public: } }; -static const NWidgetPart _nested_town_game_view_widgets[] = { +static constexpr NWidgetPart _nested_town_game_view_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_PUSHIMGBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP), @@ -806,7 +806,7 @@ static WindowDesc _town_game_view_desc(__FILE__, __LINE__, std::begin(_nested_town_game_view_widgets), std::end(_nested_town_game_view_widgets) ); -static const NWidgetPart _nested_town_editor_view_widgets[] = { +static constexpr NWidgetPart _nested_town_editor_view_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_PUSHIMGBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP), @@ -847,7 +847,7 @@ void ShowTownViewWindow(TownID town) } } -static const NWidgetPart _nested_town_directory_widgets[] = { +static constexpr NWidgetPart _nested_town_directory_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_TOWN_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1263,7 +1263,7 @@ void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32_t p1, u if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy); } -static const NWidgetPart _nested_found_town_widgets[] = { +static constexpr NWidgetPart _nested_found_town_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_FOUND_TOWN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/town_type.h b/src/town_type.h index 9a1d2a0494..256c7d45a4 100644 --- a/src/town_type.h +++ b/src/town_type.h @@ -28,6 +28,7 @@ enum TownSize { TSZ_END, ///< Number of available town sizes. }; template <> struct EnumPropsT : MakeEnumPropsT {}; +DECLARE_ENUM_AS_ADDABLE(TownSize) enum Ratings { /* These refer to the maximums, so Appalling is -1000 to -400 @@ -92,6 +93,7 @@ enum TownLayout : byte { NUM_TLS, ///< Number of town layouts }; template <> struct EnumPropsT : MakeEnumPropsT {}; +DECLARE_ENUM_AS_ADDABLE(TownLayout) /** Town founding setting values. It needs to be 8bits, because we save and load it as such */ enum TownFounding : byte { diff --git a/src/townname.cpp b/src/townname.cpp index 672f9a2e6c..b1e2e4f486 100644 --- a/src/townname.cpp +++ b/src/townname.cpp @@ -497,7 +497,7 @@ static void MakeFinnishTownName(StringBuilder builder, uint32_t seed) if (view.find_first_of("aouAOU") != std::string_view::npos) { builder += "la"; } else { - builder += u8"l\u00e4"; + builder += "l\u00e4"; } return; } diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index fc20e9e761..71706f5f26 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -3528,7 +3528,7 @@ private: } }; -static const NWidgetPart _nested_program_widgets[] = { +static constexpr NWidgetPart _nested_program_widgets[] = { // Title bar NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), @@ -3667,7 +3667,7 @@ enum TraceRestrictSlotWindowWidgets { }; -static const NWidgetPart _nested_slot_widgets[] = { +static constexpr NWidgetPart _nested_slot_widgets[] = { NWidget(NWID_HORIZONTAL), // Window header NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_TRSL_CAPTION), SetDataTip(STR_TRACE_RESTRICT_SLOT_CAPTION, STR_NULL), @@ -4350,7 +4350,7 @@ enum TraceRestrictCounterWindowWidgets { }; -static const NWidgetPart _nested_counter_widgets[] = { +static constexpr NWidgetPart _nested_counter_widgets[] = { NWidget(NWID_HORIZONTAL), // Window header NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_TRCL_CAPTION), SetDataTip(STR_TRACE_RESTRICT_COUNTER_CAPTION, STR_NULL), diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 13ecc62e66..2b21d13556 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -150,7 +150,7 @@ public: } }; -static const NWidgetPart _nested_transparency_widgets[] = { +static constexpr NWidgetPart _nested_transparency_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TRANSPARENCY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index b7aee55544..95e1894574 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -278,7 +278,7 @@ static std::unique_ptr MakeTreeTypeButtons() return vstack; } -static const NWidgetPart _nested_build_trees_widgets[] = { +static constexpr NWidgetPart _nested_build_trees_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN), NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_PLANT_TREE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 0eefdbd3c5..f39bb8006d 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1384,7 +1384,7 @@ struct RefitWindow : public Window { } }; -static const NWidgetPart _nested_vehicle_refit_widgets[] = { +static constexpr NWidgetPart _nested_vehicle_refit_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_VR_CAPTION), SetDataTip(STR_REFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -1711,7 +1711,7 @@ void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index) ChangeFixedViewportRoutePath(from_index, to_index); } -static const NWidgetPart _nested_vehicle_list[] = { +static constexpr NWidgetPart _nested_vehicle_list[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VL_CAPTION_SELECTION), @@ -2754,7 +2754,7 @@ static_assert(WID_VD_DETAILS_CAPACITY_OF_EACH == WID_VD_DETAILS_CARGO_CARRIED + static_assert(WID_VD_DETAILS_TOTAL_CARGO == WID_VD_DETAILS_CARGO_CARRIED + TDW_TAB_TOTALS ); /** Vehicle details widgets (other than train). */ -static const NWidgetPart _nested_nontrain_vehicle_details_widgets[] = { +static constexpr NWidgetPart _nested_nontrain_vehicle_details_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_VD_CAPTION), SetDataTip(STR_VEHICLE_DETAILS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -2777,7 +2777,7 @@ static const NWidgetPart _nested_nontrain_vehicle_details_widgets[] = { }; /** Train details widgets. */ -static const NWidgetPart _nested_train_vehicle_details_widgets[] = { +static constexpr NWidgetPart _nested_train_vehicle_details_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_VD_CAPTION), SetDataTip(STR_VEHICLE_DETAILS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), @@ -3279,7 +3279,7 @@ struct VehicleDetailsWindow : Window { const Vehicle *v = Vehicle::Get(this->window_number); if (v->type == VEH_TRAIN) { - this->LowerWidget(this->tab + WID_VD_DETAILS_CARGO_CARRIED); + this->LowerWidget(WID_VD_DETAILS_CARGO_CARRIED + this->tab); this->vscroll->SetCount(GetTrainDetailsWndVScroll(v->index, this->tab)); } @@ -3405,7 +3405,7 @@ static void ShowVehicleDetailsWindow(const Vehicle *v) /* Unified vehicle GUI - Vehicle View Window */ /** Vehicle view widgets. */ -static const NWidgetPart _nested_vehicle_view_widgets[] = { +static constexpr NWidgetPart _nested_vehicle_view_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VV_RENAME), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_NULL /* filled in later */), diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index 5207ecef8e..93611d2f0a 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -22,12 +22,13 @@ void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit = false, bool is_virtual_train = false); /** The tabs in the train details window */ -enum TrainDetailsWindowTabs { +enum TrainDetailsWindowTabs : byte { TDW_TAB_CARGO = 0, ///< Tab with cargo carried by the vehicles TDW_TAB_INFO, ///< Tab with name and value of the vehicles TDW_TAB_CAPACITY, ///< Tab with cargo capacity of the vehicles TDW_TAB_TOTALS, ///< Tab with sum of total cargo transported }; +DECLARE_ENUM_AS_ADDABLE(TrainDetailsWindowTabs) /** Special values for vehicle-related windows for the data parameter of #InvalidateWindowData. */ enum VehicleInvalidateWindowData { diff --git a/src/vehicle_type.h b/src/vehicle_type.h index 3e35f579f5..99cf1f7f09 100644 --- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -37,6 +37,7 @@ enum VehicleType : byte { DECLARE_POSTFIX_INCREMENT(VehicleType) /** Helper information for extract tool. */ template <> struct EnumPropsT : MakeEnumPropsT {}; +DECLARE_ENUM_AS_ADDABLE(VehicleType) struct Vehicle; struct Train; diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 7c67ae2291..9b398eb15a 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -29,7 +29,7 @@ #include "safeguards.h" /* Extra Viewport Window Stuff */ -static const NWidgetPart _nested_extra_viewport_widgets[] = { +static constexpr NWidgetPart _nested_extra_viewport_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, WID_EV_CAPTION), SetDataTip(STR_EXTRA_VIEWPORT_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp index d1c6b7ac53..40dc116bee 100644 --- a/src/waypoint_gui.cpp +++ b/src/waypoint_gui.cpp @@ -217,7 +217,7 @@ public: }; /** The widgets of the waypoint view. */ -static const NWidgetPart _nested_waypoint_view_widgets[] = { +static constexpr NWidgetPart _nested_waypoint_view_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_W_RENAME), SetMinimalSize(12, 14), SetDataTip(SPR_RENAME, STR_BUOY_VIEW_CHANGE_BUOY_NAME), diff --git a/src/widget.cpp b/src/widget.cpp index e3135da010..e6c65d5f22 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -25,145 +25,6 @@ #include "safeguards.h" -/** Distances used in drawing widgets. */ -enum WidgetDrawDistances { - /* WWT_IMGBTN(_2) */ - WD_IMGBTN_LEFT = 1, ///< Left offset of the image in the button. - WD_IMGBTN_RIGHT = 1, ///< Right offset of the image in the button. - WD_IMGBTN_TOP = 1, ///< Top offset of image in the button. - WD_IMGBTN_BOTTOM = 1, ///< Bottom offset of image in the button. - - /* WWT_INSET */ - WD_INSET_LEFT = 2, ///< Left offset of string. - WD_INSET_RIGHT = 2, ///< Right offset of string. - WD_INSET_TOP = 1, ///< Top offset of string. - - WD_VSCROLLBAR_LEFT = 2, ///< Left offset of vertical scrollbar. - WD_VSCROLLBAR_RIGHT = 2, ///< Right offset of vertical scrollbar. - WD_VSCROLLBAR_TOP = 3, ///< Top offset of vertical scrollbar. - WD_VSCROLLBAR_BOTTOM = 3, ///< Bottom offset of vertical scrollbar. - - WD_HSCROLLBAR_LEFT = 3, ///< Left offset of horizontal scrollbar. - WD_HSCROLLBAR_RIGHT = 3, ///< Right offset of horizontal scrollbar. - WD_HSCROLLBAR_TOP = 2, ///< Top offset of horizontal scrollbar. - WD_HSCROLLBAR_BOTTOM = 2, ///< Bottom offset of horizontal scrollbar. - - /* Size of the pure frame bevel without any padding. */ - WD_BEVEL_LEFT = 1, ///< Width of left bevel border. - WD_BEVEL_RIGHT = 1, ///< Width of right bevel border. - WD_BEVEL_TOP = 1, ///< Height of top bevel border. - WD_BEVEL_BOTTOM = 1, ///< Height of bottom bevel border. - - /* FrameRect widgets, all text buttons, panel, editbox */ - WD_FRAMERECT_LEFT = 2, ///< Offset at left to draw the frame rectangular area - WD_FRAMERECT_RIGHT = 2, ///< Offset at right to draw the frame rectangular area - WD_FRAMERECT_TOP = 1, ///< Offset at top to draw the frame rectangular area - WD_FRAMERECT_BOTTOM = 1, ///< Offset at bottom to draw the frame rectangular area - - /* WWT_FRAME */ - WD_FRAMETEXT_LEFT = 6, ///< Left offset of the text of the frame. - WD_FRAMETEXT_RIGHT = 6, ///< Right offset of the text of the frame. - WD_FRAMETEXT_TOP = 6, ///< Top offset of the text of the frame - WD_FRAMETEXT_BOTTOM = 6, ///< Bottom offset of the text of the frame - - /* WWT_MATRIX */ - WD_MATRIX_LEFT = 2, ///< Offset at left of a matrix cell. - WD_MATRIX_RIGHT = 2, ///< Offset at right of a matrix cell. - WD_MATRIX_TOP = 3, ///< Offset at top of a matrix cell. - WD_MATRIX_BOTTOM = 1, ///< Offset at bottom of a matrix cell. - - /* WWT_SHADEBOX */ - WD_SHADEBOX_WIDTH = 12, ///< Width of a standard shade box widget. - WD_SHADEBOX_LEFT = 2, ///< Left offset of shade sprite. - WD_SHADEBOX_RIGHT = 2, ///< Right offset of shade sprite. - WD_SHADEBOX_TOP = 3, ///< Top offset of shade sprite. - WD_SHADEBOX_BOTTOM = 3, ///< Bottom offset of shade sprite. - - /* WWT_STICKYBOX */ - WD_STICKYBOX_WIDTH = 12, ///< Width of a standard sticky box widget. - WD_STICKYBOX_LEFT = 2, ///< Left offset of sticky sprite. - WD_STICKYBOX_RIGHT = 2, ///< Right offset of sticky sprite. - WD_STICKYBOX_TOP = 3, ///< Top offset of sticky sprite. - WD_STICKYBOX_BOTTOM = 3, ///< Bottom offset of sticky sprite. - - /* WWT_DEBUGBOX */ - WD_DEBUGBOX_WIDTH = 12, ///< Width of a standard debug box widget. - WD_DEBUGBOX_LEFT = 2, ///< Left offset of debug sprite. - WD_DEBUGBOX_RIGHT = 2, ///< Right offset of debug sprite. - WD_DEBUGBOX_TOP = 3, ///< Top offset of debug sprite. - WD_DEBUGBOX_BOTTOM = 3, ///< Bottom offset of debug sprite. - - /* WWT_DEFSIZEBOX */ - WD_DEFSIZEBOX_WIDTH = 12, ///< Width of a standard defsize box widget. - WD_DEFSIZEBOX_LEFT = 2, ///< Left offset of defsize sprite. - WD_DEFSIZEBOX_RIGHT = 2, ///< Right offset of defsize sprite. - WD_DEFSIZEBOX_TOP = 3, ///< Top offset of defsize sprite. - WD_DEFSIZEBOX_BOTTOM = 3, ///< Bottom offset of defsize sprite. - - /* WWT_RESIZEBOX */ - WD_RESIZEBOX_WIDTH = 12, ///< Width of a resize box widget. - WD_RESIZEBOX_LEFT = 2, ///< Left offset of resize sprite. - WD_RESIZEBOX_RIGHT = 2, ///< Right offset of resize sprite. - WD_RESIZEBOX_TOP = 2, ///< Top offset of resize sprite. - WD_RESIZEBOX_BOTTOM = 2, ///< Bottom offset of resize sprite. - - /* WWT_CLOSEBOX */ - WD_CLOSEBOX_WIDTH = 11, ///< Width of a close box widget. - WD_CLOSEBOX_LEFT = 2, ///< Left offset of closebox string. - WD_CLOSEBOX_RIGHT = 1, ///< Right offset of closebox string. - WD_CLOSEBOX_TOP = 2, ///< Top offset of closebox string. - WD_CLOSEBOX_BOTTOM = 2, ///< Bottom offset of closebox string. - - /* WWT_CAPTION */ - WD_CAPTION_HEIGHT = 14, ///< Height of a title bar. - WD_CAPTIONTEXT_LEFT = 2, ///< Offset of the caption text at the left. - WD_CAPTIONTEXT_RIGHT = 2, ///< Offset of the caption text at the right. - WD_CAPTIONTEXT_TOP = 2, ///< Offset of the caption text at the top. - WD_CAPTIONTEXT_BOTTOM = 2, ///< Offset of the caption text at the bottom. - - /* Dropdown widget. */ - WD_DROPDOWN_HEIGHT = 12, ///< Height of a drop down widget. - WD_DROPDOWNTEXT_LEFT = 2, ///< Left offset of the dropdown widget string. - WD_DROPDOWNTEXT_RIGHT = 2, ///< Right offset of the dropdown widget string. - WD_DROPDOWNTEXT_TOP = 1, ///< Top offset of the dropdown widget string. - WD_DROPDOWNTEXT_BOTTOM = 1, ///< Bottom offset of the dropdown widget string. - - WD_PAR_VSEP_NORMAL = 2, ///< Normal amount of vertical space between two paragraphs of text. - WD_PAR_VSEP_WIDE = 8, ///< Large amount of vertical space between two paragraphs of text. -}; - -const WidgetDimensions WidgetDimensions::unscaled = { - {WD_IMGBTN_LEFT, WD_IMGBTN_TOP, WD_IMGBTN_RIGHT, WD_IMGBTN_BOTTOM}, ///< imgbtn - {WD_INSET_LEFT, WD_INSET_TOP, WD_INSET_RIGHT, WD_BEVEL_BOTTOM}, ///< inset - {WD_VSCROLLBAR_LEFT, WD_VSCROLLBAR_TOP, WD_VSCROLLBAR_RIGHT, WD_VSCROLLBAR_BOTTOM}, ///< vscrollbar - {WD_HSCROLLBAR_LEFT, WD_HSCROLLBAR_TOP, WD_HSCROLLBAR_RIGHT, WD_HSCROLLBAR_BOTTOM}, ///< hscrollbar - {WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM}, ///< bevel - {WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM}, ///< fullbevel - {WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM}, ///< framerect - {WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM}, ///< frametext - {WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM}, ///< matrix - {WD_SHADEBOX_LEFT, WD_SHADEBOX_TOP, WD_SHADEBOX_RIGHT, WD_SHADEBOX_BOTTOM}, ///< shadebox - {WD_STICKYBOX_LEFT, WD_STICKYBOX_TOP, WD_STICKYBOX_RIGHT, WD_STICKYBOX_BOTTOM}, ///< stickybox - {WD_DEBUGBOX_LEFT, WD_DEBUGBOX_TOP, WD_DEBUGBOX_RIGHT, WD_DEBUGBOX_BOTTOM}, ///< debugbox - {WD_DEFSIZEBOX_LEFT, WD_DEFSIZEBOX_TOP, WD_DEFSIZEBOX_RIGHT, WD_DEFSIZEBOX_BOTTOM}, ///< defsizebox - {WD_RESIZEBOX_LEFT, WD_RESIZEBOX_TOP, WD_RESIZEBOX_RIGHT, WD_RESIZEBOX_BOTTOM}, ///< resizebox - {WD_CLOSEBOX_LEFT, WD_CLOSEBOX_TOP, WD_CLOSEBOX_RIGHT, WD_CLOSEBOX_BOTTOM}, ///< closebox - {WD_CAPTIONTEXT_LEFT, WD_CAPTIONTEXT_TOP, WD_CAPTIONTEXT_RIGHT, WD_CAPTIONTEXT_BOTTOM}, ///< captiontext - {WD_DROPDOWNTEXT_LEFT, WD_DROPDOWNTEXT_TOP, WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_BOTTOM}, ///< dropdowntext - {WD_BEVEL_LEFT, WD_BEVEL_TOP * 2, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM * 2}, ///< dropdownmenu - {20, 10, 20, 10}, ///< modalpopup - {3, 3, 3, 3}, ///< picker - {10, 8, 10, 8}, ///< sparse window padding - {10, 8, 10, 0}, ///< resizable sparse window padding - 1, ///< vsep_picker - WD_PAR_VSEP_NORMAL, ///< vsep_normal - 4, ///< vsep_sparse - WD_PAR_VSEP_WIDE, ///< vsep_wide - 2, ///< hsep_normal - 6, ///< hsep_wide - 10, ///< hsep_indent -}; - WidgetDimensions WidgetDimensions::scaled = {}; /** @@ -2718,50 +2579,50 @@ NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, WidgetID index, uint32_t case WWT_CAPTION: this->SetFill(1, 0); this->SetResize(1, 0); - this->SetMinimalSize(0, WD_CAPTION_HEIGHT); + this->SetMinimalSize(0, WidgetDimensions::WD_CAPTION_HEIGHT); this->SetMinimalTextLines(1, WidgetDimensions::unscaled.captiontext.Vertical(), FS_NORMAL); this->SetDataTip(data, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS); break; case WWT_STICKYBOX: this->SetFill(0, 0); - this->SetMinimalSize(WD_STICKYBOX_WIDTH, WD_CAPTION_HEIGHT); + this->SetMinimalSize(WidgetDimensions::WD_STICKYBOX_WIDTH, WidgetDimensions::WD_CAPTION_HEIGHT); this->SetDataTip(STR_NULL, STR_TOOLTIP_STICKY); break; case WWT_SHADEBOX: this->SetFill(0, 0); - this->SetMinimalSize(WD_SHADEBOX_WIDTH, WD_CAPTION_HEIGHT); + this->SetMinimalSize(WidgetDimensions::WD_SHADEBOX_WIDTH, WidgetDimensions::WD_CAPTION_HEIGHT); this->SetDataTip(STR_NULL, STR_TOOLTIP_SHADE); break; case WWT_DEBUGBOX: this->SetFill(0, 0); - this->SetMinimalSize(WD_DEBUGBOX_WIDTH, WD_CAPTION_HEIGHT); + this->SetMinimalSize(WidgetDimensions::WD_DEBUGBOX_WIDTH, WidgetDimensions::WD_CAPTION_HEIGHT); this->SetDataTip(STR_NULL, STR_TOOLTIP_DEBUG); break; case WWT_DEFSIZEBOX: this->SetFill(0, 0); - this->SetMinimalSize(WD_DEFSIZEBOX_WIDTH, WD_CAPTION_HEIGHT); + this->SetMinimalSize(WidgetDimensions::WD_DEFSIZEBOX_WIDTH, WidgetDimensions::WD_CAPTION_HEIGHT); this->SetDataTip(STR_NULL, STR_TOOLTIP_DEFSIZE); break; case WWT_RESIZEBOX: this->SetFill(0, 0); - this->SetMinimalSize(WD_RESIZEBOX_WIDTH, 12); + this->SetMinimalSize(WidgetDimensions::WD_RESIZEBOX_WIDTH, 12); this->SetDataTip(RWV_SHOW_BEVEL, STR_TOOLTIP_RESIZE); break; case WWT_CLOSEBOX: this->SetFill(0, 0); - this->SetMinimalSize(WD_CLOSEBOX_WIDTH, WD_CAPTION_HEIGHT); + this->SetMinimalSize(WidgetDimensions::WD_CLOSEBOX_WIDTH, WidgetDimensions::WD_CAPTION_HEIGHT); this->SetDataTip(STR_NULL, STR_TOOLTIP_CLOSE_WINDOW); break; case WWT_DROPDOWN: this->SetFill(0, 0); - this->SetMinimalSize(0, WD_DROPDOWN_HEIGHT); + this->SetMinimalSize(0, WidgetDimensions::WD_DROPDOWN_HEIGHT); this->SetAlignment(SA_TOP | SA_LEFT); break; diff --git a/src/widget_type.h b/src/widget_type.h index 7171b22925..bfed36cbf6 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -1085,7 +1085,7 @@ typedef std::unique_ptr NWidgetFunctionType(); */ struct NWidgetPart { WidgetType type; ///< Type of the part. @see NWidgetPartType. - union { + union NWidgetPartUnion { Point xy; ///< Part with an x/y size. NWidgetPartDataTip data_tip; ///< Part with a data/tooltip. NWidgetPartWidget widget; ///< Part with a start of a widget. @@ -1096,7 +1096,33 @@ struct NWidgetPart { NWidgetPartAlignment align; ///< Part with internal alignment. NWidgetFunctionType *func_ptr; ///< Part with a function call. NWidContainerFlags cont_flags; ///< Part with container flags. + + /* Constructors for each NWidgetPartUnion data type. */ + constexpr NWidgetPartUnion() : xy() {} + constexpr NWidgetPartUnion(Point xy) : xy(xy) {} + constexpr NWidgetPartUnion(NWidgetPartDataTip data_tip) : data_tip(data_tip) {} + constexpr NWidgetPartUnion(NWidgetPartWidget widget) : widget(widget) {} + constexpr NWidgetPartUnion(NWidgetPartPaddings padding) : padding(padding) {} + constexpr NWidgetPartUnion(NWidgetPartPIP pip) : pip(pip) {} + constexpr NWidgetPartUnion(NWidgetPartTextLines text_lines) : text_lines(text_lines) {} + constexpr NWidgetPartUnion(NWidgetPartTextStyle text_style) : text_style(text_style) {} + constexpr NWidgetPartUnion(NWidgetPartAlignment align) : align(align) {} + constexpr NWidgetPartUnion(NWidgetFunctionType *func_ptr) : func_ptr(func_ptr) {} + constexpr NWidgetPartUnion(NWidContainerFlags cont_flags) : cont_flags(cont_flags) {} } u; + + /* Constructors for each NWidgetPart data type. */ + explicit constexpr NWidgetPart(WidgetType type) : type(type), u() {} + constexpr NWidgetPart(WidgetType type, Point xy) : type(type), u(xy) {} + constexpr NWidgetPart(WidgetType type, NWidgetPartDataTip data_tip) : type(type), u(data_tip) {} + constexpr NWidgetPart(WidgetType type, NWidgetPartWidget widget) : type(type), u(widget) {} + constexpr NWidgetPart(WidgetType type, NWidgetPartPaddings padding) : type(type), u(padding) {} + constexpr NWidgetPart(WidgetType type, NWidgetPartPIP pip) : type(type), u(pip) {} + constexpr NWidgetPart(WidgetType type, NWidgetPartTextLines text_lines) : type(type), u(text_lines) {} + constexpr NWidgetPart(WidgetType type, NWidgetPartTextStyle text_style) : type(type), u(text_style) {} + constexpr NWidgetPart(WidgetType type, NWidgetPartAlignment align) : type(type), u(align) {} + constexpr NWidgetPart(WidgetType type, NWidgetFunctionType *func_ptr) : type(type), u(func_ptr) {} + constexpr NWidgetPart(WidgetType type, NWidContainerFlags cont_flags) : type(type), u(cont_flags) {} }; /** @@ -1105,15 +1131,9 @@ struct NWidgetPart { * @param dy Vertical resize step. 0 means no vertical resizing. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetResize(int16_t dx, int16_t dy) +constexpr NWidgetPart SetResize(int16_t dx, int16_t dy) { - NWidgetPart part; - - part.type = WPT_RESIZE; - part.u.xy.x = dx; - part.u.xy.y = dy; - - return part; + return NWidgetPart{WPT_RESIZE, Point{dx, dy}}; } /** @@ -1122,15 +1142,9 @@ inline NWidgetPart SetResize(int16_t dx, int16_t dy) * @param y Vertical minimal size. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetMinimalSize(int16_t x, int16_t y) +constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y) { - NWidgetPart part; - - part.type = WPT_MINSIZE; - part.u.xy.x = x; - part.u.xy.y = y; - - return part; + return NWidgetPart{WPT_MINSIZE, Point{x, y}}; } /** @@ -1140,16 +1154,9 @@ inline NWidgetPart SetMinimalSize(int16_t x, int16_t y) * @param size Font size of text. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size = FS_NORMAL) +constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size = FS_NORMAL) { - NWidgetPart part; - - part.type = WPT_MINTEXTLINES; - part.u.text_lines.lines = lines; - part.u.text_lines.spacing = spacing; - part.u.text_lines.size = size; - - return part; + return NWidgetPart{WPT_MINTEXTLINES, NWidgetPartTextLines{lines, spacing, size}}; } /** @@ -1158,15 +1165,9 @@ inline NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize * @param size Font size to draw string within widget. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetTextStyle(TextColour colour, FontSize size = FS_NORMAL) +constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size = FS_NORMAL) { - NWidgetPart part; - - part.type = WPT_TEXTSTYLE; - part.u.text_style.colour = colour; - part.u.text_style.size = size; - - return part; + return NWidgetPart{WPT_TEXTSTYLE, NWidgetPartTextStyle{colour, size}}; } /** @@ -1174,14 +1175,9 @@ inline NWidgetPart SetTextStyle(TextColour colour, FontSize size = FS_NORMAL) * @param align Alignment of text/image within widget. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetAlignment(StringAlignment align) +constexpr NWidgetPart SetAlignment(StringAlignment align) { - NWidgetPart part; - - part.type = WPT_ALIGNMENT; - part.u.align.align = align; - - return part; + return NWidgetPart{WPT_ALIGNMENT, NWidgetPartAlignment{align}}; } /** @@ -1190,15 +1186,9 @@ inline NWidgetPart SetAlignment(StringAlignment align) * @param fill_y Vertical filling step from minimal size. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetFill(uint fill_x, uint fill_y) +constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y) { - NWidgetPart part; - - part.type = WPT_FILL; - part.u.xy.x = fill_x; - part.u.xy.y = fill_y; - - return part; + return NWidgetPart{WPT_FILL, Point{fill_x, fill_y}}; } /** @@ -1206,13 +1196,9 @@ inline NWidgetPart SetFill(uint fill_x, uint fill_y) * (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL). * @ingroup NestedWidgetParts */ -inline NWidgetPart EndContainer() +constexpr NWidgetPart EndContainer() { - NWidgetPart part; - - part.type = WPT_ENDCONTAINER; - - return part; + return NWidgetPart{WPT_ENDCONTAINER}; } /** @@ -1221,15 +1207,9 @@ inline NWidgetPart EndContainer() * @param tip Tooltip of the widget. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetDataTip(uint32_t data, StringID tip) +constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip) { - NWidgetPart part; - - part.type = WPT_DATATIP; - part.u.data_tip.data = data; - part.u.data_tip.tooltip = tip; - - return part; + return NWidgetPart{WPT_DATATIP, NWidgetPartDataTip{data, tip}}; } /** @@ -1239,7 +1219,7 @@ inline NWidgetPart SetDataTip(uint32_t data, StringID tip) * @param tip Tooltip of the widget. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip) +constexpr NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip) { return SetDataTip((rows << MAT_ROW_START) | (cols << MAT_COL_START), tip); } @@ -1253,17 +1233,9 @@ inline NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip) * @param left The padding left of the widget. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left) +constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left) { - NWidgetPart part; - - part.type = WPT_PADDING; - part.u.padding.top = top; - part.u.padding.right = right; - part.u.padding.bottom = bottom; - part.u.padding.left = left; - - return part; + return NWidgetPart{WPT_PADDING, NWidgetPartPaddings{left, top, right, bottom}}; } /** @@ -1271,17 +1243,9 @@ inline NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_ * @param r The padding around the widget. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetPadding(const RectPadding &padding) +constexpr NWidgetPart SetPadding(const RectPadding &padding) { - NWidgetPart part; - - part.type = WPT_PADDING; - part.u.padding.left = padding.left; - part.u.padding.top = padding.top; - part.u.padding.right = padding.right; - part.u.padding.bottom = padding.bottom; - - return part; + return NWidgetPart{WPT_PADDING, NWidgetPartPaddings{padding}}; } /** @@ -1289,7 +1253,7 @@ inline NWidgetPart SetPadding(const RectPadding &padding) * @param padding The padding to use for all directions. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetPadding(uint8_t padding) +constexpr NWidgetPart SetPadding(uint8_t padding) { return SetPadding(padding, padding, padding, padding); } @@ -1301,16 +1265,9 @@ inline NWidgetPart SetPadding(uint8_t padding) * @param post The amount of space after the last widget. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post) +constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post) { - NWidgetPart part; - - part.type = WPT_PIPSPACE; - part.u.pip.pre = pre; - part.u.pip.inter = inter; - part.u.pip.post = post; - - return part; + return NWidgetPart{WPT_PIPSPACE, NWidgetPartPIP{pre, inter, post}}; } /** @@ -1320,16 +1277,9 @@ inline NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post) * @param post The ratio of space after the last widget. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post) +constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post) { - NWidgetPart part; - - part.type = WPT_PIPRATIO; - part.u.pip.pre = ratio_pre; - part.u.pip.inter = ratio_inter; - part.u.pip.post = ratio_post; - - return part; + return NWidgetPart{WPT_PIPRATIO, NWidgetPartPIP{ratio_pre, ratio_inter, ratio_post}}; } /** @@ -1339,14 +1289,9 @@ inline NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t r * @param index Widget index of the scrollbar. * @ingroup NestedWidgetParts */ -inline NWidgetPart SetScrollbar(WidgetID index) +constexpr NWidgetPart SetScrollbar(WidgetID index) { - NWidgetPart part; - - part.type = WPT_SCROLLBAR; - part.u.widget.index = index; - - return part; + return NWidgetPart{WPT_SCROLLBAR, NWidgetPartWidget{INVALID_COLOUR, index}}; } /** @@ -1358,15 +1303,9 @@ inline NWidgetPart SetScrollbar(WidgetID index) * Child widgets must have a index bigger than the parent index. * @ingroup NestedWidgetParts */ -inline NWidgetPart NWidget(WidgetType tp, Colours col, int idx = -1) +constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx = -1) { - NWidgetPart part; - - part.type = tp; - part.u.widget.colour = col; - part.u.widget.index = idx; - - return part; + return NWidgetPart{tp, NWidgetPartWidget{col, idx}}; } /** @@ -1375,14 +1314,9 @@ inline NWidgetPart NWidget(WidgetType tp, Colours col, int idx = -1) * @param cont_flags Flags for the containers (#NWID_HORIZONTAL and #NWID_VERTICAL). * @ingroup NestedWidgetParts */ -inline NWidgetPart NWidget(WidgetType tp, NWidContainerFlags cont_flags = NC_NONE) +constexpr NWidgetPart NWidget(WidgetType tp, NWidContainerFlags cont_flags = NC_NONE) { - NWidgetPart part; - - part.type = tp; - part.u.cont_flags = cont_flags; - - return part; + return NWidgetPart{tp, NWidContainerFlags{cont_flags}}; } /** @@ -1390,14 +1324,9 @@ inline NWidgetPart NWidget(WidgetType tp, NWidContainerFlags cont_flags = NC_NON * @param func_ptr Pointer to function that returns the tree. * @ingroup NestedWidgetParts */ -inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr) +constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr) { - NWidgetPart part; - - part.type = WPT_FUNCTION; - part.u.func_ptr = func_ptr; - - return part; + return NWidgetPart{WPT_FUNCTION, func_ptr}; } bool IsContainerWidgetType(WidgetType tp); diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 705085df3a..1ee898d678 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -21,7 +21,7 @@ #include "../safeguards.h" -static const NWidgetPart _nested_dropdown_menu_widgets[] = { +static constexpr NWidgetPart _nested_dropdown_menu_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_PANEL, COLOUR_END, WID_DM_ITEMS), SetScrollbar(WID_DM_SCROLL), EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_DM_SHOW_SCROLL), diff --git a/src/window_gui.h b/src/window_gui.h index 4e08b8d1d0..36251cf4bf 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -35,7 +35,8 @@ enum FrameFlags { DECLARE_ENUM_AS_BIT_SET(FrameFlags) -struct WidgetDimensions { +class WidgetDimensions { +public: RectPadding imgbtn; RectPadding inset; RectPadding vscrollbar; @@ -69,6 +70,151 @@ struct WidgetDimensions { static const WidgetDimensions unscaled; ///< Unscaled widget dimensions. static WidgetDimensions scaled; ///< Widget dimensions scaled for current zoom level. + +private: + /** + * Distances used in drawing widgets. + * These constants should not be used elsewhere, use scaled/unscaled WidgetDimensions instead. + */ + enum WidgetDrawDistances { + /* WWT_IMGBTN(_2) */ + WD_IMGBTN_LEFT = 1, ///< Left offset of the image in the button. + WD_IMGBTN_RIGHT = 2, ///< Right offset of the image in the button. + WD_IMGBTN_TOP = 1, ///< Top offset of image in the button. + WD_IMGBTN_BOTTOM = 2, ///< Bottom offset of image in the button. + + /* WWT_INSET */ + WD_INSET_LEFT = 2, ///< Left offset of string. + WD_INSET_RIGHT = 2, ///< Right offset of string. + WD_INSET_TOP = 1, ///< Top offset of string. + + WD_VSCROLLBAR_LEFT = 2, ///< Left offset of vertical scrollbar. + WD_VSCROLLBAR_RIGHT = 2, ///< Right offset of vertical scrollbar. + WD_VSCROLLBAR_TOP = 3, ///< Top offset of vertical scrollbar. + WD_VSCROLLBAR_BOTTOM = 3, ///< Bottom offset of vertical scrollbar. + + WD_HSCROLLBAR_LEFT = 3, ///< Left offset of horizontal scrollbar. + WD_HSCROLLBAR_RIGHT = 3, ///< Right offset of horizontal scrollbar. + WD_HSCROLLBAR_TOP = 2, ///< Top offset of horizontal scrollbar. + WD_HSCROLLBAR_BOTTOM = 2, ///< Bottom offset of horizontal scrollbar. + + /* Size of the pure frame bevel without any padding. */ + WD_BEVEL_LEFT = 1, ///< Width of left bevel border. + WD_BEVEL_RIGHT = 1, ///< Width of right bevel border. + WD_BEVEL_TOP = 1, ///< Height of top bevel border. + WD_BEVEL_BOTTOM = 1, ///< Height of bottom bevel border. + + /* FrameRect widgets, all text buttons, panel, editbox */ + WD_FRAMERECT_LEFT = 2, ///< Offset at left to draw the frame rectangular area + WD_FRAMERECT_RIGHT = 2, ///< Offset at right to draw the frame rectangular area + WD_FRAMERECT_TOP = 1, ///< Offset at top to draw the frame rectangular area + WD_FRAMERECT_BOTTOM = 1, ///< Offset at bottom to draw the frame rectangular area + + /* WWT_FRAME */ + WD_FRAMETEXT_LEFT = 6, ///< Left offset of the text of the frame. + WD_FRAMETEXT_RIGHT = 6, ///< Right offset of the text of the frame. + WD_FRAMETEXT_TOP = 6, ///< Top offset of the text of the frame + WD_FRAMETEXT_BOTTOM = 6, ///< Bottom offset of the text of the frame + + /* WWT_MATRIX */ + WD_MATRIX_LEFT = 2, ///< Offset at left of a matrix cell. + WD_MATRIX_RIGHT = 2, ///< Offset at right of a matrix cell. + WD_MATRIX_TOP = 3, ///< Offset at top of a matrix cell. + WD_MATRIX_BOTTOM = 1, ///< Offset at bottom of a matrix cell. + + /* WWT_SHADEBOX */ + WD_SHADEBOX_WIDTH = 12, ///< Width of a standard shade box widget. + WD_SHADEBOX_LEFT = 2, ///< Left offset of shade sprite. + WD_SHADEBOX_RIGHT = 2, ///< Right offset of shade sprite. + WD_SHADEBOX_TOP = 3, ///< Top offset of shade sprite. + WD_SHADEBOX_BOTTOM = 3, ///< Bottom offset of shade sprite. + + /* WWT_STICKYBOX */ + WD_STICKYBOX_WIDTH = 12, ///< Width of a standard sticky box widget. + WD_STICKYBOX_LEFT = 2, ///< Left offset of sticky sprite. + WD_STICKYBOX_RIGHT = 2, ///< Right offset of sticky sprite. + WD_STICKYBOX_TOP = 3, ///< Top offset of sticky sprite. + WD_STICKYBOX_BOTTOM = 3, ///< Bottom offset of sticky sprite. + + /* WWT_DEBUGBOX */ + WD_DEBUGBOX_WIDTH = 12, ///< Width of a standard debug box widget. + WD_DEBUGBOX_LEFT = 2, ///< Left offset of debug sprite. + WD_DEBUGBOX_RIGHT = 2, ///< Right offset of debug sprite. + WD_DEBUGBOX_TOP = 3, ///< Top offset of debug sprite. + WD_DEBUGBOX_BOTTOM = 3, ///< Bottom offset of debug sprite. + + /* WWT_DEFSIZEBOX */ + WD_DEFSIZEBOX_WIDTH = 12, ///< Width of a standard defsize box widget. + WD_DEFSIZEBOX_LEFT = 2, ///< Left offset of defsize sprite. + WD_DEFSIZEBOX_RIGHT = 2, ///< Right offset of defsize sprite. + WD_DEFSIZEBOX_TOP = 3, ///< Top offset of defsize sprite. + WD_DEFSIZEBOX_BOTTOM = 3, ///< Bottom offset of defsize sprite. + + /* WWT_RESIZEBOX */ + WD_RESIZEBOX_WIDTH = 12, ///< Width of a resize box widget. + WD_RESIZEBOX_LEFT = 2, ///< Left offset of resize sprite. + WD_RESIZEBOX_RIGHT = 2, ///< Right offset of resize sprite. + WD_RESIZEBOX_TOP = 2, ///< Top offset of resize sprite. + WD_RESIZEBOX_BOTTOM = 2, ///< Bottom offset of resize sprite. + + /* WWT_CLOSEBOX */ + WD_CLOSEBOX_WIDTH = 11, ///< Width of a close box widget. + WD_CLOSEBOX_LEFT = 2, ///< Left offset of closebox string. + WD_CLOSEBOX_RIGHT = 1, ///< Right offset of closebox string. + WD_CLOSEBOX_TOP = 2, ///< Top offset of closebox string. + WD_CLOSEBOX_BOTTOM = 2, ///< Bottom offset of closebox string. + + /* WWT_CAPTION */ + WD_CAPTION_HEIGHT = 14, ///< Height of a title bar. + WD_CAPTIONTEXT_LEFT = 2, ///< Offset of the caption text at the left. + WD_CAPTIONTEXT_RIGHT = 2, ///< Offset of the caption text at the right. + WD_CAPTIONTEXT_TOP = 2, ///< Offset of the caption text at the top. + WD_CAPTIONTEXT_BOTTOM = 2, ///< Offset of the caption text at the bottom. + + /* Dropdown widget. */ + WD_DROPDOWN_HEIGHT = 12, ///< Height of a drop down widget. + WD_DROPDOWNTEXT_LEFT = 2, ///< Left offset of the dropdown widget string. + WD_DROPDOWNTEXT_RIGHT = 2, ///< Right offset of the dropdown widget string. + WD_DROPDOWNTEXT_TOP = 1, ///< Top offset of the dropdown widget string. + WD_DROPDOWNTEXT_BOTTOM = 1, ///< Bottom offset of the dropdown widget string. + + WD_PAR_VSEP_NORMAL = 2, ///< Normal amount of vertical space between two paragraphs of text. + WD_PAR_VSEP_WIDE = 8, ///< Large amount of vertical space between two paragraphs of text. + }; + + friend NWidgetLeaf; +}; + +inline constexpr WidgetDimensions WidgetDimensions::unscaled = { + {WD_IMGBTN_LEFT, WD_IMGBTN_TOP, WD_IMGBTN_RIGHT, WD_IMGBTN_BOTTOM}, ///< imgbtn + {WD_INSET_LEFT, WD_INSET_TOP, WD_INSET_RIGHT, WD_BEVEL_BOTTOM}, ///< inset + {WD_VSCROLLBAR_LEFT, WD_VSCROLLBAR_TOP, WD_VSCROLLBAR_RIGHT, WD_VSCROLLBAR_BOTTOM}, ///< vscrollbar + {WD_HSCROLLBAR_LEFT, WD_HSCROLLBAR_TOP, WD_HSCROLLBAR_RIGHT, WD_HSCROLLBAR_BOTTOM}, ///< hscrollbar + {WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM}, ///< bevel + {WD_BEVEL_LEFT, WD_BEVEL_TOP, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM}, ///< fullbevel + {WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_FRAMERECT_RIGHT, WD_FRAMERECT_BOTTOM}, ///< framerect + {WD_FRAMETEXT_LEFT, WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM}, ///< frametext + {WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_MATRIX_RIGHT, WD_MATRIX_BOTTOM}, ///< matrix + {WD_SHADEBOX_LEFT, WD_SHADEBOX_TOP, WD_SHADEBOX_RIGHT, WD_SHADEBOX_BOTTOM}, ///< shadebox + {WD_STICKYBOX_LEFT, WD_STICKYBOX_TOP, WD_STICKYBOX_RIGHT, WD_STICKYBOX_BOTTOM}, ///< stickybox + {WD_DEBUGBOX_LEFT, WD_DEBUGBOX_TOP, WD_DEBUGBOX_RIGHT, WD_DEBUGBOX_BOTTOM}, ///< debugbox + {WD_DEFSIZEBOX_LEFT, WD_DEFSIZEBOX_TOP, WD_DEFSIZEBOX_RIGHT, WD_DEFSIZEBOX_BOTTOM}, ///< defsizebox + {WD_RESIZEBOX_LEFT, WD_RESIZEBOX_TOP, WD_RESIZEBOX_RIGHT, WD_RESIZEBOX_BOTTOM}, ///< resizebox + {WD_CLOSEBOX_LEFT, WD_CLOSEBOX_TOP, WD_CLOSEBOX_RIGHT, WD_CLOSEBOX_BOTTOM}, ///< closebox + {WD_CAPTIONTEXT_LEFT, WD_CAPTIONTEXT_TOP, WD_CAPTIONTEXT_RIGHT, WD_CAPTIONTEXT_BOTTOM}, ///< captiontext + {WD_DROPDOWNTEXT_LEFT, WD_DROPDOWNTEXT_TOP, WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_BOTTOM}, ///< dropdowntext + {WD_BEVEL_LEFT, WD_BEVEL_TOP * 2, WD_BEVEL_RIGHT, WD_BEVEL_BOTTOM * 2}, ///< dropdownmenu + {20, 10, 20, 10}, ///< modalpopup + {3, 3, 3, 3}, ///< picker + {10, 8, 10, 8}, ///< sparse window padding + {10, 8, 10, 1}, ///< resizable sparse window padding + 1, ///< vsep_picker + WD_PAR_VSEP_NORMAL, ///< vsep_normal + 4, ///< vsep_sparse + WD_PAR_VSEP_WIDE, ///< vsep_wide + 2, ///< hsep_normal + 6, ///< hsep_wide + 10, ///< hsep_indent }; /* widget.cpp */ diff --git a/src/zoning_gui.cpp b/src/zoning_gui.cpp index dc0f9deab3..f66e8041eb 100644 --- a/src/zoning_gui.cpp +++ b/src/zoning_gui.cpp @@ -158,7 +158,7 @@ struct ZoningWindow : public Window { } }; -static const NWidgetPart _nested_zoning_widgets[] = { +static constexpr NWidgetPart _nested_zoning_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, ZTW_CAPTION), SetDataTip(STR_ZONING_TOOLBAR, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), diff --git a/src/zoom_type.h b/src/zoom_type.h index c69f060168..68898dbf90 100644 --- a/src/zoom_type.h +++ b/src/zoom_type.h @@ -53,6 +53,7 @@ enum ZoomLevel : byte { ZOOM_LVL_SPR_COUNT = ZOOM_LVL_SPR_END - ZOOM_LVL_BEGIN, ///< Number of zoom levels to draw with sprites. }; DECLARE_POSTFIX_INCREMENT(ZoomLevel) +DECLARE_ENUM_AS_ADDABLE(ZoomLevel) inline uint8_t ZoomMask(ZoomLevel level) {