This commit is contained in:
Aaron van Geffen 2024-05-09 14:27:09 +02:00 committed by GitHub
commit fa2c7dc83d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 308 additions and 223 deletions

View File

@ -3699,6 +3699,8 @@ STR_6624 :Tile Inspector: Sort elements
STR_6625 :Invalid colour
STR_6626 :Animation is backwards
STR_6627 :Track speed too high!
STR_6628 :Align toolbar buttons horizontally centred
STR_6629 :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 #

View File

@ -166,6 +166,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,
@ -334,15 +335,19 @@ 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
// TODO: string ids -- aka "I don't want to do a full recompile on account of StringIds.h"
MakeWidget({ 10, TOOLBAR_GROUP_START + 14}, {280, 12}, WindowWidgetType::Checkbox, WindowColour::Tertiary, 6628, 6629 ),
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
};
@ -1527,6 +1532,14 @@ static Widget *window_options_page_widgets[] = {
#pragma endregion
#pragma region Controls tab events
void ToggleToolbarSetting(bool& setting)
{
setting ^= true;
ConfigSaveDefault();
Invalidate();
WindowInvalidateByClass(WindowClass::TopToolbar);
}
void ControlsMouseUp(WidgetIndex widgetIndex)
{
switch (widgetIndex)
@ -1550,47 +1563,29 @@ static Widget *window_options_page_widgets[] = {
ConfigSaveDefault();
Invalidate();
break;
case WIDX_TOOLBAR_BUTTONS_CENTRED:
ToggleToolbarSetting(gConfigInterface.ToolbarButtonsCentred);
break;
case WIDX_TOOLBAR_SHOW_FINANCES:
gConfigInterface.ToolbarShowFinances ^= 1;
ConfigSaveDefault();
Invalidate();
WindowInvalidateByClass(WindowClass::TopToolbar);
ToggleToolbarSetting(gConfigInterface.ToolbarShowFinances);
break;
case WIDX_TOOLBAR_SHOW_RESEARCH:
gConfigInterface.ToolbarShowResearch ^= 1;
ConfigSaveDefault();
Invalidate();
WindowInvalidateByClass(WindowClass::TopToolbar);
ToggleToolbarSetting(gConfigInterface.ToolbarShowResearch);
break;
case WIDX_TOOLBAR_SHOW_CHEATS:
gConfigInterface.ToolbarShowCheats ^= 1;
ConfigSaveDefault();
Invalidate();
WindowInvalidateByClass(WindowClass::TopToolbar);
ToggleToolbarSetting(gConfigInterface.ToolbarShowCheats);
break;
case WIDX_TOOLBAR_SHOW_NEWS:
gConfigInterface.ToolbarShowNews ^= 1;
ConfigSaveDefault();
Invalidate();
WindowInvalidateByClass(WindowClass::TopToolbar);
ToggleToolbarSetting(gConfigInterface.ToolbarShowNews);
break;
case WIDX_TOOLBAR_SHOW_MUTE:
gConfigInterface.ToolbarShowMute ^= 1;
ConfigSaveDefault();
Invalidate();
WindowInvalidateByClass(WindowClass::TopToolbar);
ToggleToolbarSetting(gConfigInterface.ToolbarShowMute);
break;
case WIDX_TOOLBAR_SHOW_CHAT:
gConfigInterface.ToolbarShowChat ^= 1;
ConfigSaveDefault();
Invalidate();
WindowInvalidateByClass(WindowClass::TopToolbar);
ToggleToolbarSetting(gConfigInterface.ToolbarShowChat);
break;
case WIDX_TOOLBAR_SHOW_ZOOM:
gConfigInterface.ToolbarShowZoom ^= 1;
ConfigSaveDefault();
Invalidate();
WindowInvalidateByClass(WindowClass::TopToolbar);
ToggleToolbarSetting(gConfigInterface.ToolbarShowZoom);
break;
case WIDX_WINDOW_BUTTONS_ON_THE_LEFT:
gConfigInterface.WindowButtonsOnTheLeft ^= 1;
@ -1655,6 +1650,7 @@ static Widget *window_options_page_widgets[] = {
SetCheckboxValue(WIDX_TRAP_CURSOR, gConfigGeneral.TrapCursor);
SetCheckboxValue(WIDX_INVERT_DRAG, gConfigGeneral.InvertViewportDrag);
SetCheckboxValue(WIDX_ZOOM_TO_CURSOR, gConfigGeneral.ZoomToCursor);
SetCheckboxValue(WIDX_TOOLBAR_BUTTONS_CENTRED, gConfigInterface.ToolbarButtonsCentred);
SetCheckboxValue(WIDX_TOOLBAR_SHOW_FINANCES, gConfigInterface.ToolbarShowFinances);
SetCheckboxValue(WIDX_TOOLBAR_SHOW_RESEARCH, gConfigInterface.ToolbarShowResearch);
SetCheckboxValue(WIDX_TOOLBAR_SHOW_CHEATS, gConfigInterface.ToolbarShowCheats);

View File

@ -209,78 +209,89 @@ namespace OpenRCT2::Ui::Windows
#pragma region Toolbar_widget_ordering
// clang-format off
// from left to right
static constexpr int32_t left_aligned_widgets_order[] = {
WIDX_PAUSE,
WIDX_FASTFORWARD,
WIDX_FILE_MENU,
WIDX_MUTE,
WIDX_NETWORK,
WIDX_CHAT,
WIDX_CHEATS,
WIDX_DEBUG,
static constexpr std::array kWidgetOrderLeftGroup = {
WIDX_PAUSE,
WIDX_FASTFORWARD,
WIDX_FILE_MENU,
WIDX_MUTE,
WIDX_NETWORK,
WIDX_CHAT,
WIDX_CHEATS,
WIDX_DEBUG,
WIDX_SEPARATOR,
WIDX_SEPARATOR,
WIDX_ZOOM_OUT,
WIDX_ZOOM_IN,
WIDX_ROTATE,
WIDX_VIEW_MENU,
WIDX_MAP,
};
WIDX_ZOOM_OUT,
WIDX_ZOOM_IN,
WIDX_ROTATE,
WIDX_VIEW_MENU,
WIDX_MAP,
};
// from right to left
static constexpr int32_t right_aligned_widgets_order[] = {
WIDX_NEWS,
WIDX_GUESTS,
WIDX_STAFF,
WIDX_PARK,
WIDX_RIDES,
WIDX_RESEARCH,
WIDX_FINANCES,
static constexpr std::array kWidgetOrderRightGroup = {
WIDX_CLEAR_SCENERY,
WIDX_LAND,
WIDX_WATER,
WIDX_SCENERY,
WIDX_PATH,
WIDX_CONSTRUCT_RIDE,
WIDX_SEPARATOR,
WIDX_SEPARATOR,
WIDX_CONSTRUCT_RIDE,
WIDX_PATH,
WIDX_SCENERY,
WIDX_WATER,
WIDX_LAND,
WIDX_CLEAR_SCENERY,
};
WIDX_FINANCES,
WIDX_RESEARCH,
WIDX_RIDES,
WIDX_PARK,
WIDX_STAFF,
WIDX_GUESTS,
WIDX_NEWS,
};
static constexpr size_t _totalToolbarElements = kWidgetOrderLeftGroup.size() + kWidgetOrderRightGroup.size();
// Make a combined version of both halves of the toolbar, with a separator halfway.
static constexpr std::array<int, _totalToolbarElements + 1> kWidgetOrderCombined = []() {
std::array<int, _totalToolbarElements + 1> combined;
auto halfWayPoint = std::copy(kWidgetOrderLeftGroup.begin(), kWidgetOrderLeftGroup.end(), combined.begin());
*halfWayPoint = WIDX_SEPARATOR;
std::copy(kWidgetOrderRightGroup.begin(), kWidgetOrderRightGroup.end(), halfWayPoint + 1);
return combined;
}();
#pragma endregion
static Widget _topToolbarWidgets[] = {
MakeRemapWidget({ 0, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TOOLBAR_PAUSE, STR_PAUSE_GAME_TIP ), // Pause
MakeRemapWidget({ 60, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TOOLBAR_FILE, STR_DISC_AND_GAME_OPTIONS_TIP ), // File menu
MakeRemapWidget({250, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_G2_TOOLBAR_MUTE, STR_TOOLBAR_MUTE_TIP ), // Mute
MakeRemapWidget({100, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_ZOOM_OUT, STR_ZOOM_OUT_TIP ), // Zoom out
MakeRemapWidget({130, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_ZOOM_IN, STR_ZOOM_IN_TIP ), // Zoom in
MakeRemapWidget({160, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_ROTATE, STR_ROTATE_TIP ), // Rotate camera
MakeRemapWidget({190, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_VIEW, STR_VIEW_OPTIONS_TIP ), // Transparency menu
MakeRemapWidget({220, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_MAP, STR_SHOW_MAP_TIP ), // Map
MakeRemapWidget({267, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_LAND, STR_ADJUST_LAND_TIP ), // Land
MakeRemapWidget({297, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_WATER, STR_ADJUST_WATER_TIP ), // Water
MakeRemapWidget({327, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_SCENERY, STR_PLACE_SCENERY_TIP ), // Scenery
MakeRemapWidget({357, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_FOOTPATH, STR_BUILD_FOOTPATH_TIP ), // Path
MakeRemapWidget({387, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_CONSTRUCT_RIDE, STR_BUILD_RIDE_TIP ), // Construct ride
MakeRemapWidget({490, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TOOLBAR_RIDES, STR_RIDES_IN_PARK_TIP ), // Rides
MakeRemapWidget({520, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TOOLBAR_PARK, STR_PARK_INFORMATION_TIP ), // Park
MakeRemapWidget({550, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TAB_TOOLBAR, STR_STAFF_TIP ), // Staff
MakeRemapWidget({560, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TOOLBAR_GUESTS, STR_GUESTS_TIP ), // Guests
MakeRemapWidget({560, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_CLEAR_SCENERY, STR_CLEAR_SCENERY_TIP ), // Clear scenery
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TAB_TOOLBAR, STR_GAME_SPEED_TIP ), // Fast forward
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TAB_TOOLBAR, STR_CHEATS_TIP ), // Cheats
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TAB_TOOLBAR, STR_DEBUG_TIP ), // Debug
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TAB_TOOLBAR, STR_SCENARIO_OPTIONS_FINANCIAL_TIP), // Finances
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TAB_TOOLBAR, STR_FINANCES_RESEARCH_TIP ), // Research
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TAB_TOOLBAR, STR_SHOW_RECENT_MESSAGES_TIP ), // News
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_G2_TOOLBAR_MULTIPLAYER, STR_SHOW_MULTIPLAYER_STATUS_TIP ), // Network
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TAB_TOOLBAR, STR_TOOLBAR_CHAT_TIP ), // Chat
MakeWidget ({ 0, 0}, {10, 1}, WindowWidgetType::Empty, WindowColour::Primary ), // Artificial widget separator
kWidgetsEnd,
};
static Widget _topToolbarWidgets[] = {
MakeRemapWidget({ 0, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TOOLBAR_PAUSE, STR_PAUSE_GAME_TIP ), // Pause
MakeRemapWidget({ 60, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TOOLBAR_FILE, STR_DISC_AND_GAME_OPTIONS_TIP ), // File menu
MakeRemapWidget({250, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_G2_TOOLBAR_MUTE, STR_TOOLBAR_MUTE_TIP ), // Mute
MakeRemapWidget({100, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_ZOOM_OUT, STR_ZOOM_OUT_TIP ), // Zoom out
MakeRemapWidget({130, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_ZOOM_IN, STR_ZOOM_IN_TIP ), // Zoom in
MakeRemapWidget({160, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_ROTATE, STR_ROTATE_TIP ), // Rotate camera
MakeRemapWidget({190, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_VIEW, STR_VIEW_OPTIONS_TIP ), // Transparency menu
MakeRemapWidget({220, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Secondary , SPR_TOOLBAR_MAP, STR_SHOW_MAP_TIP ), // Map
MakeRemapWidget({267, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_LAND, STR_ADJUST_LAND_TIP ), // Land
MakeRemapWidget({297, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_WATER, STR_ADJUST_WATER_TIP ), // Water
MakeRemapWidget({327, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_SCENERY, STR_PLACE_SCENERY_TIP ), // Scenery
MakeRemapWidget({357, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_FOOTPATH, STR_BUILD_FOOTPATH_TIP ), // Path
MakeRemapWidget({387, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_CONSTRUCT_RIDE, STR_BUILD_RIDE_TIP ), // Construct ride
MakeRemapWidget({490, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TOOLBAR_RIDES, STR_RIDES_IN_PARK_TIP ), // Rides
MakeRemapWidget({520, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TOOLBAR_PARK, STR_PARK_INFORMATION_TIP ), // Park
MakeRemapWidget({550, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TAB_TOOLBAR, STR_STAFF_TIP ), // Staff
MakeRemapWidget({560, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TOOLBAR_GUESTS, STR_GUESTS_TIP ), // Guests
MakeRemapWidget({560, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Tertiary , SPR_TOOLBAR_CLEAR_SCENERY, STR_CLEAR_SCENERY_TIP ), // Clear scenery
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TAB_TOOLBAR, STR_GAME_SPEED_TIP ), // Fast forward
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TAB_TOOLBAR, STR_CHEATS_TIP ), // Cheats
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TAB_TOOLBAR, STR_DEBUG_TIP ), // Debug
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TAB_TOOLBAR, STR_SCENARIO_OPTIONS_FINANCIAL_TIP), // Finances
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TAB_TOOLBAR, STR_FINANCES_RESEARCH_TIP ), // Research
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Quaternary, SPR_TAB_TOOLBAR, STR_SHOW_RECENT_MESSAGES_TIP ), // News
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_G2_TOOLBAR_MULTIPLAYER, STR_SHOW_MULTIPLAYER_STATUS_TIP ), // Network
MakeRemapWidget({ 30, 0}, {30, kTopToolbarHeight + 1}, WindowWidgetType::TrnBtn, WindowColour::Primary , SPR_TAB_TOOLBAR, STR_TOOLBAR_CHAT_TIP ), // Chat
MakeWidget ({ 0, 0}, {10, 1}, WindowWidgetType::Empty, WindowColour::Primary ), // Artificial widget separator
kWidgetsEnd,
};
// clang-format on
static void ScenarioSelectCallback(const utf8* path);
@ -2916,11 +2927,8 @@ static Widget _topToolbarWidgets[] = {
}
}
void OnPrepareDraw() override
void ResetWidgetToDefaultState()
{
int32_t x, widgetIndex, widgetWidth, firstAlignment;
Widget* widget;
// Enable / disable buttons
widgets[WIDX_PAUSE].type = WindowWidgetType::TrnBtn;
widgets[WIDX_FILE_MENU].type = WindowWidgetType::TrnBtn;
@ -2948,7 +2956,10 @@ static Widget _topToolbarWidgets[] = {
widgets[WIDX_DEBUG].type = gConfigGeneral.DebuggingTools ? WindowWidgetType::TrnBtn : WindowWidgetType::Empty;
widgets[WIDX_NEWS].type = WindowWidgetType::TrnBtn;
widgets[WIDX_NETWORK].type = WindowWidgetType::TrnBtn;
}
void HideDisabledButtons()
{
if (!gConfigInterface.ToolbarShowMute)
widgets[WIDX_MUTE].type = WindowWidgetType::Empty;
@ -2977,46 +2988,54 @@ static Widget _topToolbarWidgets[] = {
if ((GetGameState().Park.Flags & PARK_FLAGS_NO_MONEY) || !gConfigInterface.ToolbarShowFinances)
widgets[WIDX_FINANCES].type = WindowWidgetType::Empty;
}
if (gScreenFlags & SCREEN_FLAGS_EDITOR)
void ApplyEditorMode()
{
if ((gScreenFlags & SCREEN_FLAGS_EDITOR) == 0)
{
widgets[WIDX_PARK].type = WindowWidgetType::Empty;
widgets[WIDX_STAFF].type = WindowWidgetType::Empty;
widgets[WIDX_GUESTS].type = WindowWidgetType::Empty;
widgets[WIDX_FINANCES].type = WindowWidgetType::Empty;
widgets[WIDX_RESEARCH].type = WindowWidgetType::Empty;
widgets[WIDX_NEWS].type = WindowWidgetType::Empty;
widgets[WIDX_NETWORK].type = WindowWidgetType::Empty;
auto& gameState = GetGameState();
if (gameState.EditorStep != EditorStep::LandscapeEditor)
{
widgets[WIDX_LAND].type = WindowWidgetType::Empty;
widgets[WIDX_WATER].type = WindowWidgetType::Empty;
}
if (gameState.EditorStep != EditorStep::RollercoasterDesigner)
{
widgets[WIDX_RIDES].type = WindowWidgetType::Empty;
widgets[WIDX_CONSTRUCT_RIDE].type = WindowWidgetType::Empty;
widgets[WIDX_FASTFORWARD].type = WindowWidgetType::Empty;
}
if (gameState.EditorStep != EditorStep::LandscapeEditor
&& gameState.EditorStep != EditorStep::RollercoasterDesigner)
{
widgets[WIDX_MAP].type = WindowWidgetType::Empty;
widgets[WIDX_SCENERY].type = WindowWidgetType::Empty;
widgets[WIDX_PATH].type = WindowWidgetType::Empty;
widgets[WIDX_CLEAR_SCENERY].type = WindowWidgetType::Empty;
widgets[WIDX_ZOOM_OUT].type = WindowWidgetType::Empty;
widgets[WIDX_ZOOM_IN].type = WindowWidgetType::Empty;
widgets[WIDX_ROTATE].type = WindowWidgetType::Empty;
widgets[WIDX_VIEW_MENU].type = WindowWidgetType::Empty;
}
return;
}
widgets[WIDX_PARK].type = WindowWidgetType::Empty;
widgets[WIDX_STAFF].type = WindowWidgetType::Empty;
widgets[WIDX_GUESTS].type = WindowWidgetType::Empty;
widgets[WIDX_FINANCES].type = WindowWidgetType::Empty;
widgets[WIDX_RESEARCH].type = WindowWidgetType::Empty;
widgets[WIDX_NEWS].type = WindowWidgetType::Empty;
widgets[WIDX_NETWORK].type = WindowWidgetType::Empty;
auto& gameState = GetGameState();
if (gameState.EditorStep != EditorStep::LandscapeEditor)
{
widgets[WIDX_LAND].type = WindowWidgetType::Empty;
widgets[WIDX_WATER].type = WindowWidgetType::Empty;
}
if (gameState.EditorStep != EditorStep::RollercoasterDesigner)
{
widgets[WIDX_RIDES].type = WindowWidgetType::Empty;
widgets[WIDX_CONSTRUCT_RIDE].type = WindowWidgetType::Empty;
widgets[WIDX_FASTFORWARD].type = WindowWidgetType::Empty;
}
if (gameState.EditorStep != EditorStep::LandscapeEditor
&& gameState.EditorStep != EditorStep::RollercoasterDesigner)
{
widgets[WIDX_MAP].type = WindowWidgetType::Empty;
widgets[WIDX_SCENERY].type = WindowWidgetType::Empty;
widgets[WIDX_PATH].type = WindowWidgetType::Empty;
widgets[WIDX_CLEAR_SCENERY].type = WindowWidgetType::Empty;
widgets[WIDX_ZOOM_OUT].type = WindowWidgetType::Empty;
widgets[WIDX_ZOOM_IN].type = WindowWidgetType::Empty;
widgets[WIDX_ROTATE].type = WindowWidgetType::Empty;
widgets[WIDX_VIEW_MENU].type = WindowWidgetType::Empty;
}
}
void ApplyNetworkMode()
{
switch (NetworkGetMode())
{
case NETWORK_MODE_NONE:
@ -3030,85 +3049,10 @@ static Widget _topToolbarWidgets[] = {
widgets[WIDX_FASTFORWARD].type = WindowWidgetType::Empty;
break;
}
}
// Align left hand side toolbar buttons
firstAlignment = 1;
x = 0;
for (size_t i = 0; i < std::size(left_aligned_widgets_order); ++i)
{
widgetIndex = left_aligned_widgets_order[i];
widget = &widgets[widgetIndex];
if (widget->type == WindowWidgetType::Empty && widgetIndex != WIDX_SEPARATOR)
continue;
if (firstAlignment && widgetIndex == WIDX_SEPARATOR)
continue;
widgetWidth = widget->width();
widget->left = x;
x += widgetWidth;
widget->right = x;
x += 1;
firstAlignment = 0;
}
// Align right hand side toolbar buttons if necessary
int32_t screenWidth = ContextGetWidth();
firstAlignment = 1;
x = std::max(640, screenWidth);
for (size_t i = 0; i < std::size(right_aligned_widgets_order); ++i)
{
widgetIndex = right_aligned_widgets_order[i];
widget = &widgets[widgetIndex];
if (widget->type == WindowWidgetType::Empty && widgetIndex != WIDX_SEPARATOR)
continue;
if (firstAlignment && widgetIndex == WIDX_SEPARATOR)
continue;
widgetWidth = widget->width();
x -= 1;
widget->right = x;
x -= widgetWidth;
widget->left = x;
firstAlignment = 0;
}
// Footpath button pressed down
if (WindowFindByClass(WindowClass::Footpath) == nullptr)
pressed_widgets &= ~(1uLL << WIDX_PATH);
else
pressed_widgets |= (1uLL << WIDX_PATH);
bool paused = (gGamePaused & GAME_PAUSED_NORMAL);
if (paused || _waitingForPause)
{
pressed_widgets |= (1uLL << WIDX_PAUSE);
if (paused)
_waitingForPause = false;
}
else
pressed_widgets &= ~(1uLL << WIDX_PAUSE);
if (!OpenRCT2::Audio::gGameSoundsOff)
widgets[WIDX_MUTE].image = ImageId(SPR_G2_TOOLBAR_MUTE, FilterPaletteID::PaletteNull);
else
widgets[WIDX_MUTE].image = ImageId(SPR_G2_TOOLBAR_UNMUTE, FilterPaletteID::PaletteNull);
// Set map button to the right image.
if (widgets[WIDX_MAP].type != WindowWidgetType::Empty)
{
static constexpr uint32_t _imageIdByRotation[] = {
SPR_G2_MAP_NORTH,
SPR_G2_MAP_WEST,
SPR_G2_MAP_SOUTH,
SPR_G2_MAP_EAST,
};
uint32_t mapImageId = _imageIdByRotation[GetCurrentRotation()];
widgets[WIDX_MAP].image = ImageId(mapImageId, FilterPaletteID::PaletteNull);
}
void ApplyZoomState()
{
// Zoomed out/in disable. Not sure where this code is in the original.
const auto* mainWindow = WindowGetMain();
if (mainWindow == nullptr || mainWindow->viewport == nullptr)
@ -3131,6 +3075,139 @@ static Widget _topToolbarWidgets[] = {
}
}
void ApplyPausedState()
{
bool paused = (gGamePaused & GAME_PAUSED_NORMAL);
if (paused || _waitingForPause)
{
pressed_widgets |= (1uLL << WIDX_PAUSE);
if (paused)
_waitingForPause = false;
}
else
pressed_widgets &= ~(1uLL << WIDX_PAUSE);
}
void ApplyMapRotation()
{
// Set map button to the right image.
if (widgets[WIDX_MAP].type != WindowWidgetType::Empty)
{
static constexpr uint32_t _imageIdByRotation[] = {
SPR_G2_MAP_NORTH,
SPR_G2_MAP_WEST,
SPR_G2_MAP_SOUTH,
SPR_G2_MAP_EAST,
};
uint32_t mapImageId = _imageIdByRotation[GetCurrentRotation()];
widgets[WIDX_MAP].image = ImageId(mapImageId, FilterPaletteID::PaletteNull);
}
}
void ApplyAudioState()
{
if (!OpenRCT2::Audio::gGameSoundsOff)
widgets[WIDX_MUTE].image = ImageId(SPR_G2_TOOLBAR_MUTE, FilterPaletteID::PaletteNull);
else
widgets[WIDX_MUTE].image = ImageId(SPR_G2_TOOLBAR_UNMUTE, FilterPaletteID::PaletteNull);
}
void ApplyFootpathPressed()
{
// Footpath button pressed down
if (WindowFindByClass(WindowClass::Footpath) == nullptr)
pressed_widgets &= ~(1uLL << WIDX_PATH);
else
pressed_widgets |= (1uLL << WIDX_PATH);
}
// TODO: look into using std::span
template<typename T> uint16_t GetToolbarWidth(T toolbarItems)
{
bool firstItem = true;
auto totalWidth = 0;
for (auto widgetIndex : toolbarItems)
{
auto* widget = &widgets[widgetIndex];
if (widget->type == WindowWidgetType::Empty && widgetIndex != WIDX_SEPARATOR)
continue;
if (firstItem && widgetIndex == WIDX_SEPARATOR)
continue;
totalWidth += widget->width() + 1;
firstItem = false;
}
return totalWidth;
}
// TODO: look into using std::span
template<typename T> void AlignButtons(T toolbarItems, uint16_t xPos)
{
bool firstItem = true;
for (auto widgetIndex : toolbarItems)
{
auto* widget = &widgets[widgetIndex];
if (widget->type == WindowWidgetType::Empty && widgetIndex != WIDX_SEPARATOR)
continue;
if (firstItem && widgetIndex == WIDX_SEPARATOR)
continue;
auto widgetWidth = widget->width();
widget->left = xPos;
xPos += widgetWidth;
widget->right = xPos;
xPos += 1;
firstItem = false;
}
}
void AlignButtonsLeftRight()
{
// Align left hand side toolbar buttons
AlignButtons(kWidgetOrderLeftGroup, 0);
// Align right hand side toolbar buttons
auto totalWidth = GetToolbarWidth(kWidgetOrderRightGroup);
auto xPos = ContextGetWidth() - totalWidth;
AlignButtons(kWidgetOrderRightGroup, xPos);
}
void AlignButtonsCentre()
{
// First, we figure out how much space we'll be needing
auto totalWidth = GetToolbarWidth(kWidgetOrderCombined);
// We'll start from the centre of the UI...
auto xPos = (ContextGetWidth() - totalWidth) / 2;
// And finally, align the buttons in the centre
AlignButtons(kWidgetOrderCombined, xPos);
}
void OnPrepareDraw() override
{
ResetWidgetToDefaultState();
HideDisabledButtons();
ApplyEditorMode();
ApplyPausedState();
ApplyAudioState();
ApplyNetworkMode();
ApplyZoomState();
ApplyMapRotation();
ApplyFootpathPressed();
if (!gConfigInterface.ToolbarButtonsCentred)
AlignButtonsLeftRight();
else
AlignButtonsCentre();
}
void OnDraw(DrawPixelInfo& dpi) override
{
const auto& gameState = GetGameState();

View File

@ -327,6 +327,7 @@ namespace Config
if (reader->ReadSection("interface"))
{
auto model = &gConfigInterface;
model->ToolbarButtonsCentred = reader->GetBoolean("toolbar_buttons_centred", true);
model->ToolbarShowFinances = reader->GetBoolean("toolbar_show_finances", true);
model->ToolbarShowResearch = reader->GetBoolean("toolbar_show_research", true);
model->ToolbarShowCheats = reader->GetBoolean("toolbar_show_cheats", false);
@ -349,6 +350,7 @@ namespace Config
{
auto model = &gConfigInterface;
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);

View File

@ -115,6 +115,7 @@ struct GeneralConfiguration
struct InterfaceConfiguration
{
bool ToolbarButtonsCentred;
bool ToolbarShowFinances;
bool ToolbarShowResearch;
bool ToolbarShowCheats;

View File

@ -119,16 +119,23 @@ void Painter::PaintFPS(DrawPixelInfo& dpi)
if (!ShouldShowFPS())
return;
ScreenCoordsXY screenCoords(_uiContext->GetWidth() / 2, 2);
MeasureFPS();
char buffer[64]{};
FormatStringToBuffer(buffer, sizeof(buffer), "{OUTLINE}{WHITE}{INT32}", _currentFPS);
const int32_t stringWidth = GfxGetStringWidth(buffer, FontStyle::Medium);
// Draw Text
int32_t stringWidth = GfxGetStringWidth(buffer, FontStyle::Medium);
// Figure out where counter should be rendered
ScreenCoordsXY screenCoords(_uiContext->GetWidth() / 2, 2);
screenCoords.x = screenCoords.x - (stringWidth / 2);
// Move counter below toolbar if buttons are centred
const bool isTitle = gScreenFlags == SCREEN_FLAGS_TITLE_DEMO;
if (!isTitle && gConfigInterface.ToolbarButtonsCentred)
{
screenCoords.y = 30; // kTopToolbarHeight; don't want to include Window.h here
}
GfxDrawString(dpi, screenCoords, buffer);
// Make area dirty so the text doesn't get drawn over the last