From e423575411baba37fa81712332148bdce22580e0 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Wed, 8 May 2024 21:19:57 +0200 Subject: [PATCH] Add a config setting to toggle toolbar mode --- data/language/en-GB.txt | 2 ++ distribution/changelog.txt | 1 + src/openrct2-ui/windows/Options.cpp | 29 ++++++++++++++++++-------- src/openrct2-ui/windows/TopToolbar.cpp | 2 +- src/openrct2/config/Config.cpp | 2 ++ src/openrct2/config/Config.h | 1 + src/openrct2/localisation/StringIds.h | 3 +++ 7 files changed, 30 insertions(+), 10 deletions(-) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index a4d760c681..45b5541601 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3700,6 +3700,8 @@ STR_6625 :Invalid colour STR_6626 :Animation is backwards STR_6627 :Track speed too high! STR_6628 :Can only be placed on path edges! +STR_6629 :Align toolbar buttons horizontally centred +STR_6630 :This setting will align toolbar the buttons horizontally in the centre of the screen. The traditional way of aligning them is to in left and right corner. ############# # Scenarios # diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 93c91721e3..7327a6a4bd 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.4.12 (in development) ------------------------------------------------------------------------ +- Feature: [#622] Add option to align the top toolbar buttons horizontally centred (off by default). - Feature: [#21714] [Plugin] Costume assignment is now tailored to each staff type. - Feature: [#21913] [Plugin] Allow precise and safe control of peep animations. - Improved: [#21981] Rendering performance of the map window has been improved considerably. diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 6a01166012..7d54601bbe 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -169,6 +169,7 @@ enum WindowOptionsWidgetIdx { WIDX_THEMES_DROPDOWN, WIDX_THEMES_BUTTON, WIDX_TOOLBAR_BUTTONS_GROUP, + WIDX_TOOLBAR_BUTTONS_CENTRED, WIDX_TOOLBAR_BUTTONS_SHOW_FOR_LABEL, WIDX_TOOLBAR_SHOW_FINANCES, WIDX_TOOLBAR_SHOW_RESEARCH, @@ -337,15 +338,18 @@ static Widget window_options_controls_and_interface_widgets[] = { MakeWidget({155, THEMES_GROUP_START + 30}, {145, 13}, WindowWidgetType::Button, WindowColour::Secondary, STR_EDIT_THEMES_BUTTON, STR_EDIT_THEMES_BUTTON_TIP), // Themes button #undef THEMES_GROUP_START #define TOOLBAR_GROUP_START 215 - MakeWidget({ 5, TOOLBAR_GROUP_START + 0}, {300, 92}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_TOOLBAR_BUTTONS_GROUP ), // Toolbar buttons group - MakeWidget({ 10, TOOLBAR_GROUP_START + 14}, {280, 12}, WindowWidgetType::Label, WindowColour::Secondary, STR_SHOW_TOOLBAR_BUTTONS_FOR ), - MakeWidget({ 24, TOOLBAR_GROUP_START + 31}, {122, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_FINANCES_BUTTON_ON_TOOLBAR, STR_FINANCES_BUTTON_ON_TOOLBAR_TIP ), // Finances - MakeWidget({ 24, TOOLBAR_GROUP_START + 46}, {122, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_RESEARCH_BUTTON_ON_TOOLBAR, STR_RESEARCH_BUTTON_ON_TOOLBAR_TIP ), // Research - MakeWidget({155, TOOLBAR_GROUP_START + 31}, {145, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_CHEATS_BUTTON_ON_TOOLBAR, STR_CHEATS_BUTTON_ON_TOOLBAR_TIP ), // Cheats - MakeWidget({155, TOOLBAR_GROUP_START + 46}, {145, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_SHOW_RECENT_MESSAGES_ON_TOOLBAR, STR_SHOW_RECENT_MESSAGES_ON_TOOLBAR_TIP), // Recent messages - MakeWidget({ 24, TOOLBAR_GROUP_START + 61}, {162, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_MUTE_BUTTON_ON_TOOLBAR, STR_MUTE_BUTTON_ON_TOOLBAR_TIP ), // Mute - MakeWidget({155, TOOLBAR_GROUP_START + 61}, {145, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_CHAT_BUTTON_ON_TOOLBAR, STR_CHAT_BUTTON_ON_TOOLBAR_TIP ), // Chat - MakeWidget({ 24, TOOLBAR_GROUP_START + 76}, {122, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_ZOOM_BUTTON_ON_TOOLBAR, STR_ZOOM_BUTTON_ON_TOOLBAR_TIP ), // Zoom + + + MakeWidget({ 5, TOOLBAR_GROUP_START + 0}, {300,107}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_TOOLBAR_BUTTONS_GROUP ), // Toolbar buttons group + MakeWidget({ 10, TOOLBAR_GROUP_START + 14}, {280, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary, STR_OPTIONS_TOOLBAR_BUTTONS_CENTRED, STR_OPTIONS_TOOLBAR_BUTTONS_CENTRED_TIP), + MakeWidget({ 10, TOOLBAR_GROUP_START + 31}, {280, 12}, WindowWidgetType::Label, WindowColour::Secondary, STR_SHOW_TOOLBAR_BUTTONS_FOR ), + MakeWidget({ 24, TOOLBAR_GROUP_START + 46}, {122, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_FINANCES_BUTTON_ON_TOOLBAR, STR_FINANCES_BUTTON_ON_TOOLBAR_TIP ), // Finances + MakeWidget({ 24, TOOLBAR_GROUP_START + 61}, {122, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_RESEARCH_BUTTON_ON_TOOLBAR, STR_RESEARCH_BUTTON_ON_TOOLBAR_TIP ), // Research + MakeWidget({155, TOOLBAR_GROUP_START + 46}, {145, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_CHEATS_BUTTON_ON_TOOLBAR, STR_CHEATS_BUTTON_ON_TOOLBAR_TIP ), // Cheats + MakeWidget({155, TOOLBAR_GROUP_START + 61}, {145, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_SHOW_RECENT_MESSAGES_ON_TOOLBAR, STR_SHOW_RECENT_MESSAGES_ON_TOOLBAR_TIP), // Recent messages + MakeWidget({ 24, TOOLBAR_GROUP_START + 76}, {162, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_MUTE_BUTTON_ON_TOOLBAR, STR_MUTE_BUTTON_ON_TOOLBAR_TIP ), // Mute + MakeWidget({155, TOOLBAR_GROUP_START + 76}, {145, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_CHAT_BUTTON_ON_TOOLBAR, STR_CHAT_BUTTON_ON_TOOLBAR_TIP ), // Chat + MakeWidget({ 24, TOOLBAR_GROUP_START + 91}, {122, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_ZOOM_BUTTON_ON_TOOLBAR, STR_ZOOM_BUTTON_ON_TOOLBAR_TIP ), // Zoom kWidgetsEnd, #undef TOOLBAR_GROUP_START }; @@ -1557,6 +1561,12 @@ static Widget *window_options_page_widgets[] = { Config::Save(); Invalidate(); break; + case WIDX_TOOLBAR_BUTTONS_CENTRED: + Config::Get().interface.ToolbarButtonsCentred ^= 1; + Config::Save(); + Invalidate(); + WindowInvalidateByClass(WindowClass::TopToolbar); + break; case WIDX_TOOLBAR_SHOW_FINANCES: Config::Get().interface.ToolbarShowFinances ^= 1; Config::Save(); @@ -1662,6 +1672,7 @@ static Widget *window_options_page_widgets[] = { SetCheckboxValue(WIDX_TRAP_CURSOR, Config::Get().general.TrapCursor); SetCheckboxValue(WIDX_INVERT_DRAG, Config::Get().general.InvertViewportDrag); SetCheckboxValue(WIDX_ZOOM_TO_CURSOR, Config::Get().general.ZoomToCursor); + SetCheckboxValue(WIDX_TOOLBAR_BUTTONS_CENTRED, Config::Get().interface.ToolbarButtonsCentred); SetCheckboxValue(WIDX_TOOLBAR_SHOW_FINANCES, Config::Get().interface.ToolbarShowFinances); SetCheckboxValue(WIDX_TOOLBAR_SHOW_RESEARCH, Config::Get().interface.ToolbarShowResearch); SetCheckboxValue(WIDX_TOOLBAR_SHOW_CHEATS, Config::Get().interface.ToolbarShowCheats); diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index a6c622905e..d8e1ab379e 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -3216,7 +3216,7 @@ namespace OpenRCT2::Ui::Windows ApplyMapRotation(); ApplyFootpathPressed(); - if (false) + if (!Config::Get().interface.ToolbarButtonsCentred) AlignButtonsLeftRight(); else AlignButtonsCentre(); diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 42d719f34d..06a775aa27 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -335,6 +335,7 @@ namespace OpenRCT2::Config if (reader->ReadSection("interface")) { auto model = &_config.interface; + model->ToolbarButtonsCentred = reader->GetBoolean("toolbar_buttons_centred", false); model->ToolbarShowFinances = reader->GetBoolean("toolbar_show_finances", true); model->ToolbarShowResearch = reader->GetBoolean("toolbar_show_research", true); model->ToolbarShowCheats = reader->GetBoolean("toolbar_show_cheats", false); @@ -357,6 +358,7 @@ namespace OpenRCT2::Config { auto model = &_config.interface; writer->WriteSection("interface"); + writer->WriteBoolean("toolbar_buttons_centred", model->ToolbarButtonsCentred); writer->WriteBoolean("toolbar_show_finances", model->ToolbarShowFinances); writer->WriteBoolean("toolbar_show_research", model->ToolbarShowResearch); writer->WriteBoolean("toolbar_show_cheats", model->ToolbarShowCheats); diff --git a/src/openrct2/config/Config.h b/src/openrct2/config/Config.h index b65fc3348e..de86f0a7e0 100644 --- a/src/openrct2/config/Config.h +++ b/src/openrct2/config/Config.h @@ -119,6 +119,7 @@ namespace OpenRCT2::Config struct Interface { + bool ToolbarButtonsCentred; bool ToolbarShowFinances; bool ToolbarShowResearch; bool ToolbarShowCheats; diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index 96850e4f0e..92107db8a1 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3856,6 +3856,9 @@ enum : uint16_t STR_CAN_ONLY_BE_PLACED_ON_PATH_EDGES = 6628, + STR_OPTIONS_TOOLBAR_BUTTONS_CENTRED = 6629, + STR_OPTIONS_TOOLBAR_BUTTONS_CENTRED_TIP = 6630, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working /* MAX_STR_COUNT = 32768 */ // MAX_STR_COUNT - upper limit for number of strings, not the current count strings };