Skip to content

Commit

Permalink
Change: Provide a tools menu in the GL main menu
Browse files Browse the repository at this point in the history
Makes it easier for OS-X users to find Object Viewer / Route Viewer
  • Loading branch information
leezer3 committed Oct 4, 2024
1 parent 4035eff commit a53fd14
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
3 changes: 3 additions & 0 deletions assets/Languages/en-US.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,9 @@
<trans-unit id="back">
<source>← Back</source>
</trans-unit>
<trans-unit id="tools">
<source>Tools</source>
</trans-unit>
<trans-unit id="customize_controls">
<source>Customise controls</source>
</trans-unit>
Expand Down
8 changes: 8 additions & 0 deletions source/LibRender2/Menu/MenuTag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public enum MenuTag
MenuExitToMainMenu,
/// <summary>Enters the submenu for customising controls</summary>
MenuControls,
/// <summary>Enters the submenu for tools</summary>
MenuTools,
/// <summary>Enters the submenu for quitting the program</summary>
MenuQuit,
/// <summary>Returns to the simulation</summary>
Expand Down Expand Up @@ -88,12 +90,18 @@ public enum MenuTag
UninstallOther,
/// <summary>Shows the options menu</summary>
Options,
/// <summary>Shows the tools menu</summary>
Tools,
/// <summary>Toggles a switch</summary>
ToggleSwitch,
/// <summary>Selects the previous switch</summary>
PreviousSwitch,
/// <summary>Selects the next switch</summary>
NextSwitch,
/// <summary>Launches Object Viewer</summary>
ObjectViewer,
/// <summary>Launches Route Viewer</summary>
RouteViewer,

// OBJECT VIEWER
/// <summary>Displays a list of objects</summary>
Expand Down
2 changes: 2 additions & 0 deletions source/LibRender2/Menu/MenuType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public enum MenuType
Control,
/// <summary>Resets the controls to default</summary>
ControlReset,
/// <summary>Provides a list of tools</summary>
Tools,
/// <summary>Quits the game</summary>
Quit,
/// <summary>The game start menu</summary>
Expand Down
13 changes: 11 additions & 2 deletions source/OpenBVE/Game/Menu/Menu.SingleMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public SingleMenu(AbstractMenu menu, MenuType menuType, int data = 0, double Max
//Don't allow quitting or customisation of the controls in kiosk mode
Items[1] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"options","title"}), MenuTag.Options, 0);
Items[2] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"menu","customize_controls"}), MenuTag.MenuControls, 0);
Items[3] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"packages","title"}), MenuTag.Packages, 0);
Items[3] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"menu","tools"}), MenuTag.Tools, 0);
Items[4] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"menu","quit"}), MenuTag.MenuQuit, 0);
}
else
Expand Down Expand Up @@ -479,7 +479,16 @@ public SingleMenu(AbstractMenu menu, MenuType menuType, int data = 0, double Max
// method pictures mean we need top left at all times
Align = TextAlignment.TopLeft;
break;

case MenuType.Tools: // ask for quit confirmation
Items = new MenuEntry[5];
Items[0] = new MenuCaption(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "menu", "tools" }));
Items[1] = new MenuCommand(menu, "Object Viewer", MenuTag.ObjectViewer, 0);
Items[2] = new MenuCommand(menu, "Route Viewer", MenuTag.RouteViewer, 0);
Items[3] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "packages", "title" }), MenuTag.Packages, 0);
Items[4] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "menu","back" }), MenuTag.MenuBack, 0);
Selection = 1;
Align = TextAlignment.TopLeft;
break;
case MenuType.Control:
//Refresh the joystick list
Program.Joysticks.RefreshJoysticks();
Expand Down
33 changes: 33 additions & 0 deletions source/OpenBVE/Game/Menu/Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using OpenBveApi.Interface;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -462,6 +463,9 @@ public override void ProcessCommand(Translations.Command cmd, double timeElapsed
case MenuTag.MenuControls: // TO CONTROLS MENU
Instance.PushMenu(MenuType.Controls);
break;
case MenuTag.MenuTools: // TO CONTROLS MENU
Instance.PushMenu(MenuType.Tools);
break;
case MenuTag.BackToSim: // OUT OF MENU BACK TO SIMULATION
Reset();
Program.Renderer.CurrentInterface = InterfaceType.Normal;
Expand Down Expand Up @@ -549,6 +553,9 @@ public override void ProcessCommand(Translations.Command cmd, double timeElapsed
case MenuTag.Options:
Instance.PushMenu(MenuType.Options);
break;
case MenuTag.Tools:
Instance.PushMenu(MenuType.Tools);
break;
case MenuTag.RouteList: // TO ROUTE LIST MENU
Instance.PushMenu(MenuType.RouteList);
routeDescriptionBox.Text = Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"errors","route_please_select"});
Expand Down Expand Up @@ -707,6 +714,32 @@ public override void ProcessCommand(Translations.Command cmd, double timeElapsed
previousSwitches.Insert(0, ns);
Instance.PushMenu(Instance.Menus[CurrMenu].Type, 0, true);
break;
case MenuTag.ObjectViewer:
string dir = AppDomain.CurrentDomain.BaseDirectory;
string runCmd = Path.CombineFile(dir, "ObjectViewer.exe");

if (Program.CurrentHost.Platform != HostPlatform.MicrosoftWindows)
{
Process.Start("mono", runCmd);
}
else
{
Process.Start(runCmd);
}
break;
case MenuTag.RouteViewer:
dir = AppDomain.CurrentDomain.BaseDirectory;
runCmd = Path.CombineFile(dir, "RouteViewer.exe");

if (Program.CurrentHost.Platform != HostPlatform.MicrosoftWindows)
{
Process.Start("mono", runCmd);
}
else
{
Process.Start(runCmd);
}
break;
}
}
else if (menu.Items[menu.Selection] is MenuOption opt)
Expand Down
2 changes: 2 additions & 0 deletions source/OpenBVE/System/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ private static void Main(string[] args) {
Translations.SetInGameLanguage(Translations.CurrentLanguageCode);
}

result.ExperimentalGLMenu = true;

if (result.ExperimentalGLMenu)
{
result.Start = true;
Expand Down

0 comments on commit a53fd14

Please sign in to comment.