Skip to content

Commit a53fd14

Browse files
committed
Change: Provide a tools menu in the GL main menu
Makes it easier for OS-X users to find Object Viewer / Route Viewer
1 parent 4035eff commit a53fd14

File tree

6 files changed

+59
-2
lines changed

6 files changed

+59
-2
lines changed

assets/Languages/en-US.xlf

+3
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,9 @@
17111711
<trans-unit id="back">
17121712
<source>← Back</source>
17131713
</trans-unit>
1714+
<trans-unit id="tools">
1715+
<source>Tools</source>
1716+
</trans-unit>
17141717
<trans-unit id="customize_controls">
17151718
<source>Customise controls</source>
17161719
</trans-unit>

source/LibRender2/Menu/MenuTag.cs

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public enum MenuTag
4242
MenuExitToMainMenu,
4343
/// <summary>Enters the submenu for customising controls</summary>
4444
MenuControls,
45+
/// <summary>Enters the submenu for tools</summary>
46+
MenuTools,
4547
/// <summary>Enters the submenu for quitting the program</summary>
4648
MenuQuit,
4749
/// <summary>Returns to the simulation</summary>
@@ -88,12 +90,18 @@ public enum MenuTag
8890
UninstallOther,
8991
/// <summary>Shows the options menu</summary>
9092
Options,
93+
/// <summary>Shows the tools menu</summary>
94+
Tools,
9195
/// <summary>Toggles a switch</summary>
9296
ToggleSwitch,
9397
/// <summary>Selects the previous switch</summary>
9498
PreviousSwitch,
9599
/// <summary>Selects the next switch</summary>
96100
NextSwitch,
101+
/// <summary>Launches Object Viewer</summary>
102+
ObjectViewer,
103+
/// <summary>Launches Route Viewer</summary>
104+
RouteViewer,
97105

98106
// OBJECT VIEWER
99107
/// <summary>Displays a list of objects</summary>

source/LibRender2/Menu/MenuType.cs

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public enum MenuType
4141
Control,
4242
/// <summary>Resets the controls to default</summary>
4343
ControlReset,
44+
/// <summary>Provides a list of tools</summary>
45+
Tools,
4446
/// <summary>Quits the game</summary>
4547
Quit,
4648
/// <summary>The game start menu</summary>

source/OpenBVE/Game/Menu/Menu.SingleMenu.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public SingleMenu(AbstractMenu menu, MenuType menuType, int data = 0, double Max
8181
//Don't allow quitting or customisation of the controls in kiosk mode
8282
Items[1] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"options","title"}), MenuTag.Options, 0);
8383
Items[2] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"menu","customize_controls"}), MenuTag.MenuControls, 0);
84-
Items[3] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"packages","title"}), MenuTag.Packages, 0);
84+
Items[3] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"menu","tools"}), MenuTag.Tools, 0);
8585
Items[4] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"menu","quit"}), MenuTag.MenuQuit, 0);
8686
}
8787
else
@@ -479,7 +479,16 @@ public SingleMenu(AbstractMenu menu, MenuType menuType, int data = 0, double Max
479479
// method pictures mean we need top left at all times
480480
Align = TextAlignment.TopLeft;
481481
break;
482-
482+
case MenuType.Tools: // ask for quit confirmation
483+
Items = new MenuEntry[5];
484+
Items[0] = new MenuCaption(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "menu", "tools" }));
485+
Items[1] = new MenuCommand(menu, "Object Viewer", MenuTag.ObjectViewer, 0);
486+
Items[2] = new MenuCommand(menu, "Route Viewer", MenuTag.RouteViewer, 0);
487+
Items[3] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "packages", "title" }), MenuTag.Packages, 0);
488+
Items[4] = new MenuCommand(menu, Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "menu","back" }), MenuTag.MenuBack, 0);
489+
Selection = 1;
490+
Align = TextAlignment.TopLeft;
491+
break;
483492
case MenuType.Control:
484493
//Refresh the joystick list
485494
Program.Joysticks.RefreshJoysticks();

source/OpenBVE/Game/Menu/Menu.cs

+33
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using OpenBveApi.Interface;
44
using System;
55
using System.Collections.Generic;
6+
using System.Diagnostics;
67
using System.Drawing;
78
using System.IO;
89
using System.Text;
@@ -462,6 +463,9 @@ public override void ProcessCommand(Translations.Command cmd, double timeElapsed
462463
case MenuTag.MenuControls: // TO CONTROLS MENU
463464
Instance.PushMenu(MenuType.Controls);
464465
break;
466+
case MenuTag.MenuTools: // TO CONTROLS MENU
467+
Instance.PushMenu(MenuType.Tools);
468+
break;
465469
case MenuTag.BackToSim: // OUT OF MENU BACK TO SIMULATION
466470
Reset();
467471
Program.Renderer.CurrentInterface = InterfaceType.Normal;
@@ -549,6 +553,9 @@ public override void ProcessCommand(Translations.Command cmd, double timeElapsed
549553
case MenuTag.Options:
550554
Instance.PushMenu(MenuType.Options);
551555
break;
556+
case MenuTag.Tools:
557+
Instance.PushMenu(MenuType.Tools);
558+
break;
552559
case MenuTag.RouteList: // TO ROUTE LIST MENU
553560
Instance.PushMenu(MenuType.RouteList);
554561
routeDescriptionBox.Text = Translations.GetInterfaceString(HostApplication.OpenBve, new[] {"errors","route_please_select"});
@@ -707,6 +714,32 @@ public override void ProcessCommand(Translations.Command cmd, double timeElapsed
707714
previousSwitches.Insert(0, ns);
708715
Instance.PushMenu(Instance.Menus[CurrMenu].Type, 0, true);
709716
break;
717+
case MenuTag.ObjectViewer:
718+
string dir = AppDomain.CurrentDomain.BaseDirectory;
719+
string runCmd = Path.CombineFile(dir, "ObjectViewer.exe");
720+
721+
if (Program.CurrentHost.Platform != HostPlatform.MicrosoftWindows)
722+
{
723+
Process.Start("mono", runCmd);
724+
}
725+
else
726+
{
727+
Process.Start(runCmd);
728+
}
729+
break;
730+
case MenuTag.RouteViewer:
731+
dir = AppDomain.CurrentDomain.BaseDirectory;
732+
runCmd = Path.CombineFile(dir, "RouteViewer.exe");
733+
734+
if (Program.CurrentHost.Platform != HostPlatform.MicrosoftWindows)
735+
{
736+
Process.Start("mono", runCmd);
737+
}
738+
else
739+
{
740+
Process.Start(runCmd);
741+
}
742+
break;
710743
}
711744
}
712745
else if (menu.Items[menu.Selection] is MenuOption opt)

source/OpenBVE/System/Program.cs

+2
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ private static void Main(string[] args) {
277277
Translations.SetInGameLanguage(Translations.CurrentLanguageCode);
278278
}
279279

280+
result.ExperimentalGLMenu = true;
281+
280282
if (result.ExperimentalGLMenu)
281283
{
282284
result.Start = true;

0 commit comments

Comments
 (0)