Create TopToolbar::InitFileMenu()

This commit is contained in:
Gymnasiast 2024-04-20 19:58:32 +02:00 committed by Michael Steenbeek
parent 9e236d1b5a
commit a00f478104
No known key found for this signature in database
GPG Key ID: 92EB181D74FDE5EF
1 changed files with 73 additions and 66 deletions

View File

@ -309,6 +309,8 @@ static Widget _topToolbarWidgets[] = {
void RotateMenuDropdown(int16_t dropdownIndex);
void InitFileMenu(Widget& widget);
void InitCheatsMenu(Widget& widget);
void CheatsMenuDropdown(int16_t dropdownIndex);
@ -2560,77 +2562,12 @@ static Widget _topToolbarWidgets[] = {
void OnMouseDown(WidgetIndex widgetIndex) override
{
int32_t numItems = 0;
Widget& widget = widgets[widgetIndex];
switch (widgetIndex)
{
case WIDX_FILE_MENU:
if (gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
{
gDropdownItems[numItems++].Format = STR_ABOUT;
gDropdownItems[numItems++].Format = STR_OPTIONS;
gDropdownItems[numItems++].Format = STR_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_GIANT_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_FILE_BUG_ON_GITHUB;
if (OpenRCT2::GetContext()->HasNewVersionInfo())
gDropdownItems[numItems++].Format = STR_UPDATE_AVAILABLE;
gDropdownItems[numItems++].Format = STR_EMPTY;
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
gDropdownItems[numItems++].Format = STR_QUIT_ROLLERCOASTER_DESIGNER;
else
gDropdownItems[numItems++].Format = STR_QUIT_TRACK_DESIGNS_MANAGER;
gDropdownItems[numItems++].Format = STR_EXIT_OPENRCT2;
}
else if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
{
gDropdownItems[numItems++].Format = STR_LOAD_LANDSCAPE;
gDropdownItems[numItems++].Format = STR_SAVE_LANDSCAPE;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_ABOUT;
gDropdownItems[numItems++].Format = STR_OPTIONS;
gDropdownItems[numItems++].Format = STR_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_GIANT_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_FILE_BUG_ON_GITHUB;
if (OpenRCT2::GetContext()->HasNewVersionInfo())
gDropdownItems[numItems++].Format = STR_UPDATE_AVAILABLE;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_QUIT_SCENARIO_EDITOR;
gDropdownItems[numItems++].Format = STR_EXIT_OPENRCT2;
}
else
{
gDropdownItems[numItems++].Format = STR_NEW_GAME;
gDropdownItems[numItems++].Format = STR_LOAD_GAME;
gDropdownItems[numItems++].Format = STR_SAVE_GAME;
gDropdownItems[numItems++].Format = STR_SAVE_GAME_AS;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_ABOUT;
gDropdownItems[numItems++].Format = STR_OPTIONS;
gDropdownItems[numItems++].Format = STR_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_GIANT_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_FILE_BUG_ON_GITHUB;
if (OpenRCT2::GetContext()->HasNewVersionInfo())
gDropdownItems[numItems++].Format = STR_UPDATE_AVAILABLE;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_QUIT_TO_MENU;
gDropdownItems[numItems++].Format = STR_EXIT_OPENRCT2;
}
WindowDropdownShowText(
{ windowPos.x + widget.left, windowPos.y + widget.top }, widget.height() + 1, colours[0] | 0x80,
Dropdown::Flag::StayOpen, numItems);
InitFileMenu(widget);
break;
case WIDX_CHEATS:
InitCheatsMenu(widget);
@ -3709,6 +3646,76 @@ static Widget _topToolbarWidgets[] = {
}
}
void TopToolbar::InitFileMenu(Widget& widget)
{
int32_t numItems = 0;
if (gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))
{
gDropdownItems[numItems++].Format = STR_ABOUT;
gDropdownItems[numItems++].Format = STR_OPTIONS;
gDropdownItems[numItems++].Format = STR_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_GIANT_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_FILE_BUG_ON_GITHUB;
if (OpenRCT2::GetContext()->HasNewVersionInfo())
gDropdownItems[numItems++].Format = STR_UPDATE_AVAILABLE;
gDropdownItems[numItems++].Format = STR_EMPTY;
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
gDropdownItems[numItems++].Format = STR_QUIT_ROLLERCOASTER_DESIGNER;
else
gDropdownItems[numItems++].Format = STR_QUIT_TRACK_DESIGNS_MANAGER;
gDropdownItems[numItems++].Format = STR_EXIT_OPENRCT2;
}
else if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
{
gDropdownItems[numItems++].Format = STR_LOAD_LANDSCAPE;
gDropdownItems[numItems++].Format = STR_SAVE_LANDSCAPE;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_ABOUT;
gDropdownItems[numItems++].Format = STR_OPTIONS;
gDropdownItems[numItems++].Format = STR_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_GIANT_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_FILE_BUG_ON_GITHUB;
if (OpenRCT2::GetContext()->HasNewVersionInfo())
gDropdownItems[numItems++].Format = STR_UPDATE_AVAILABLE;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_QUIT_SCENARIO_EDITOR;
gDropdownItems[numItems++].Format = STR_EXIT_OPENRCT2;
}
else
{
gDropdownItems[numItems++].Format = STR_NEW_GAME;
gDropdownItems[numItems++].Format = STR_LOAD_GAME;
gDropdownItems[numItems++].Format = STR_SAVE_GAME;
gDropdownItems[numItems++].Format = STR_SAVE_GAME_AS;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_ABOUT;
gDropdownItems[numItems++].Format = STR_OPTIONS;
gDropdownItems[numItems++].Format = STR_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_GIANT_SCREENSHOT;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_FILE_BUG_ON_GITHUB;
if (OpenRCT2::GetContext()->HasNewVersionInfo())
gDropdownItems[numItems++].Format = STR_UPDATE_AVAILABLE;
gDropdownItems[numItems++].Format = STR_EMPTY;
gDropdownItems[numItems++].Format = STR_QUIT_TO_MENU;
gDropdownItems[numItems++].Format = STR_EXIT_OPENRCT2;
}
WindowDropdownShowText(
{ windowPos.x + widget.left, windowPos.y + widget.top }, widget.height() + 1, colours[0] | 0x80,
Dropdown::Flag::StayOpen, numItems);
}
void TopToolbar::InitCheatsMenu(Widget& widget)
{
using namespace Dropdown;