Skip to content

Commit 1896d8b

Browse files
committed
Merge branch 'master' into release
2 parents a9861ec + a53fd14 commit 1896d8b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1869
-877
lines changed

OpenBVE.sln

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenBve", "source\OpenBVE\O
3131
{A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E} = {A2FC4D71-1ED9-40D4-B746-FE6AB3C7D55E}
3232
{ACAFCA35-01B7-479C-AD5F-9BCE0F8A597B} = {ACAFCA35-01B7-479C-AD5F-9BCE0F8A597B}
3333
{B520B1D7-3889-4C88-9E0F-CB96802D5CD1} = {B520B1D7-3889-4C88-9E0F-CB96802D5CD1}
34+
{C4BE7A1F-9CCD-4E78-8341-741ABDA8E026} = {C4BE7A1F-9CCD-4E78-8341-741ABDA8E026}
3435
{D3710390-CD0E-4E14-8E4F-80302D797D5E} = {D3710390-CD0E-4E14-8E4F-80302D797D5E}
3536
{D7561922-31A6-46DE-801F-C3C519B4B9C3} = {D7561922-31A6-46DE-801F-C3C519B4B9C3}
3637
{E9B64673-65B7-4D77-A4DB-4B441A7C9197} = {E9B64673-65B7-4D77-A4DB-4B441A7C9197}

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>

debian/openbve.desktop

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
[Desktop Entry]
22
Version=1.0
33
Type=Application
4-
Name=openBVE
4+
Name=OpenBVE
55
GenericName=Train simulator
6+
GenericName[ca]=Simulador ferroviari
67
GenericName[de]=Zugsimulation
8+
GenericName[ja]=列車運転シミュレーション
9+
GenericName[zh_HK]=列車模擬器
10+
GenericName[zh_TW]=列車模擬器
711
Categories=Game;Simulation;
812
Comment=Train/railway simulator compatible with 'BVE Trainsim' routes
13+
Comment[ca]=Simulador ferroviari compatible amb rutes del simulador BVE
14+
Comment[ja]=ライセンスフリー、オープンソースな無料のBve5形式にも対応した列車運転シミュレーション
15+
Comment[zh_HK]=與 'BVE Trainsim' 兼容的列車/鐵路模擬器
16+
Comment[zh_TW]=與 'BVE Trainsim' 兼容的列車/鐵路模擬器
917
Terminal=false
1018
TryExec=openbve
1119
Exec=openbve

installers/debian/usr/share/applications/openbve.desktop

+8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ Version=1.0
33
Type=Application
44
Name=OpenBVE
55
GenericName=Train simulator
6+
GenericName[ca]=Simulador ferroviari
67
GenericName[de]=Zugsimulation
8+
GenericName[ja]=列車運転シミュレーション
9+
GenericName[zh_HK]=列車模擬器
10+
GenericName[zh_TW]=列車模擬器
711
Categories=Game;Simulation;
812
Comment=Train/railway simulator compatible with 'BVE Trainsim' routes
13+
Comment[ca]=Simulador ferroviari compatible amb rutes del simulador BVE
14+
Comment[ja]=ライセンスフリー、オープンソースな無料のBve5形式にも対応した列車運転シミュレーション
15+
Comment[zh_HK]=與 'BVE Trainsim' 兼容的列車/鐵路模擬器
16+
Comment[zh_TW]=與 'BVE Trainsim' 兼容的列車/鐵路模擬器
917
Terminal=false
1018
TryExec=openbve
1119
Exec=openbve

source/InputDevicePlugins/DenshaDeGoInput/Controller.Ps2Ddgo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal class Ps2DdgoController : Controller
6262
private byte[] outputBuffer;
6363

6464
/// <summary>The setup packet needed to send data to the controller.</summary>
65-
private LibUsbDotNet.Main.UsbSetupPacket setupPacket = new LibUsbDotNet.Main.UsbSetupPacket(0x41, 0x09, 0x201, 0x0, 0x8);
65+
private readonly LibUsbDotNet.Main.UsbSetupPacket setupPacket = new LibUsbDotNet.Main.UsbSetupPacket(0x41, 0x09, 0x201, 0x0, 0x8);
6666

6767
/// <summary>
6868
/// Initializes PS2 Densha de GO! controller.

source/InputDevicePlugins/DenshaDeGoInput/LibUsb.UsbController.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ internal string ControllerName
104104
}
105105
catch
106106
{
107+
// ignored
107108
}
108109
return controllerName;
109110
}
@@ -119,8 +120,7 @@ internal void Unload()
119120
if (ControllerDevice != null)
120121
{
121122
// Send unload buffer to turn off controller
122-
int bytesWritten;
123-
ControllerDevice.ControlTransfer(ref SetupPacket, UnloadBuffer, UnloadBuffer.Length, out bytesWritten);
123+
ControllerDevice.ControlTransfer(ref SetupPacket, UnloadBuffer, UnloadBuffer.Length, out int _);
124124
IUsbDevice wholeUsbDevice = ControllerDevice as IUsbDevice;
125125
if (!ReferenceEquals(wholeUsbDevice, null))
126126
{
@@ -156,8 +156,7 @@ internal void Poll()
156156
// Ask for input
157157
if (ReadBuffer.Length > 0)
158158
{
159-
int readCount;
160-
ErrorCode readError = ControllerReader.Read(ReadBuffer, 0, ReadBuffer.Length, 100, out readCount);
159+
ErrorCode readError = ControllerReader.Read(ReadBuffer, 0, ReadBuffer.Length, 100, out int _);
161160

162161
if (readError == ErrorCode.DeviceNotFound || readError == ErrorCode.Win32Error || readError == ErrorCode.MonoApiError)
163162
{
@@ -167,8 +166,7 @@ internal void Poll()
167166
}
168167

169168
// Send output buffer
170-
int bytesWritten;
171-
ControllerDevice.ControlTransfer(ref SetupPacket, WriteBuffer, WriteBuffer.Length, out bytesWritten);
169+
ControllerDevice.ControlTransfer(ref SetupPacket, WriteBuffer, WriteBuffer.Length, out int _);
172170
}
173171
catch
174172
{

source/InputDevicePlugins/SanYingInput/ConfigForm.cs

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public void loadConfigurationFile(string path)
100100
}
101101
catch
102102
{
103+
// ignored
103104
}
104105
}
105106

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/ObjectViewer/InterfaceS.cs

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using ObjectViewer.Graphics;
33
using OpenBveApi;
4+
using OpenBveApi.Input;
45
using OpenBveApi.Interface;
56
using OpenBveApi.Objects;
67
using TrainManager.Trains;
@@ -9,7 +10,7 @@ namespace ObjectViewer {
910
// --- PluginManager.cs ---
1011
internal static class PluginManager {
1112
internal static class CurrentPlugin {
12-
internal static int[] Panel = new int[] { };
13+
internal static int[] Panel = { };
1314
}
1415
}
1516

@@ -48,15 +49,24 @@ internal class Options : BaseOptions
4849

4950
internal string ObjectSearchDirectory;
5051

52+
internal Key CameraMoveLeft;
53+
54+
internal Key CameraMoveRight;
55+
56+
internal Key CameraMoveUp;
57+
58+
internal Key CameraMoveDown;
59+
60+
internal Key CameraMoveForward;
61+
62+
internal Key CameraMoveBackward;
63+
5164
/// <summary>
5265
/// The mode of optimization to be performed on an object
5366
/// </summary>
5467
internal ObjectOptimizationMode ObjectOptimizationMode
5568
{
56-
get
57-
{
58-
return objectOptimizationMode;
59-
}
69+
get => objectOptimizationMode;
6070
set
6171
{
6272
objectOptimizationMode = value;

source/ObjectViewer/Options.cs

+62-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Windows.Forms;
66
using ObjectViewer.Graphics;
77
using OpenBveApi.Graphics;
8+
using OpenBveApi.Input;
89
using OpenBveApi.Objects;
910
using Path = OpenBveApi.Path;
1011

@@ -17,32 +18,38 @@ internal static void LoadOptions()
1718
Interface.CurrentOptions = new Interface.Options
1819
{
1920
ViewingDistance = 1000, // fixed
21+
CameraMoveLeft = Key.A,
22+
CameraMoveRight = Key.D,
23+
CameraMoveUp = Key.W,
24+
CameraMoveDown = Key.S,
25+
CameraMoveForward = Key.Q,
26+
CameraMoveBackward = Key.E
2027
};
2128
string optionsFolder = Path.CombineDirectory(Program.FileSystem.SettingsFolder, "1.5.0");
22-
if (!System.IO.Directory.Exists(optionsFolder))
29+
if (!Directory.Exists(optionsFolder))
2330
{
24-
System.IO.Directory.CreateDirectory(optionsFolder);
31+
Directory.CreateDirectory(optionsFolder);
2532
}
2633
CultureInfo Culture = CultureInfo.InvariantCulture;
2734
string configFile = Path.CombineFile(optionsFolder, "options_ov.cfg");
28-
if (!System.IO.File.Exists(configFile))
35+
if (!File.Exists(configFile))
2936
{
3037
//Attempt to load and upgrade a prior configuration file
3138
string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
3239
configFile = Path.CombineFile(Path.CombineDirectory(Path.CombineDirectory(assemblyFolder, "UserData"), "Settings"), "options_ov.cfg");
3340

34-
if (!System.IO.File.Exists(configFile))
41+
if (!File.Exists(configFile))
3542
{
3643
//If no route viewer specific configuration file exists, then try the main OpenBVE configuration file
3744
//Write out to a new routeviewer specific file though
3845
configFile = Path.CombineFile(Program.FileSystem.SettingsFolder, "1.5.0/options.cfg");
3946
}
4047
}
4148

42-
if (System.IO.File.Exists(configFile))
49+
if (File.Exists(configFile))
4350
{
4451
// load options
45-
string[] Lines = System.IO.File.ReadAllLines(configFile, new System.Text.UTF8Encoding());
52+
string[] Lines = File.ReadAllLines(configFile, new System.Text.UTF8Encoding());
4653
string Section = "";
4754
for (int i = 0; i < Lines.Length; i++)
4855
{
@@ -184,6 +191,47 @@ internal static void LoadOptions()
184191
break;
185192
}
186193
break;
194+
case "keys":
195+
switch (Key)
196+
{
197+
case "left":
198+
if (!Enum.TryParse(Value, out Interface.CurrentOptions.CameraMoveLeft))
199+
{
200+
Interface.CurrentOptions.CameraMoveLeft = OpenBveApi.Input.Key.A;
201+
}
202+
break;
203+
case "right":
204+
if (!Enum.TryParse(Value, out Interface.CurrentOptions.CameraMoveRight))
205+
{
206+
Interface.CurrentOptions.CameraMoveRight = OpenBveApi.Input.Key.D;
207+
}
208+
break;
209+
case "up":
210+
if (!Enum.TryParse(Value, out Interface.CurrentOptions.CameraMoveUp))
211+
{
212+
Interface.CurrentOptions.CameraMoveUp = OpenBveApi.Input.Key.W;
213+
}
214+
break;
215+
case "down":
216+
if (!Enum.TryParse(Value, out Interface.CurrentOptions.CameraMoveDown))
217+
{
218+
Interface.CurrentOptions.CameraMoveDown = OpenBveApi.Input.Key.S;
219+
}
220+
break;
221+
case "forward":
222+
if (!Enum.TryParse(Value, out Interface.CurrentOptions.CameraMoveForward))
223+
{
224+
Interface.CurrentOptions.CameraMoveForward = OpenBveApi.Input.Key.Q;
225+
}
226+
break;
227+
case "backward":
228+
if (!Enum.TryParse(Value, out Interface.CurrentOptions.CameraMoveBackward))
229+
{
230+
Interface.CurrentOptions.CameraMoveBackward = OpenBveApi.Input.Key.E;
231+
}
232+
break;
233+
}
234+
break;
187235
}
188236
}
189237
}
@@ -234,8 +282,15 @@ internal static void SaveOptions()
234282
Builder.AppendLine();
235283
Builder.AppendLine("[Folders]");
236284
Builder.AppendLine($"objectsearch = {Interface.CurrentOptions.ObjectSearchDirectory}");
285+
Builder.AppendLine("[Keys]");
286+
Builder.AppendLine("left = " + Interface.CurrentOptions.CameraMoveLeft);
287+
Builder.AppendLine("right = " + Interface.CurrentOptions.CameraMoveRight);
288+
Builder.AppendLine("up = " + Interface.CurrentOptions.CameraMoveUp);
289+
Builder.AppendLine("down = " + Interface.CurrentOptions.CameraMoveDown);
290+
Builder.AppendLine("forward = " + Interface.CurrentOptions.CameraMoveForward);
291+
Builder.AppendLine("backward = " + Interface.CurrentOptions.CameraMoveBackward);
237292
string configFile = Path.CombineFile(Program.FileSystem.SettingsFolder, "1.5.0/options_ov.cfg");
238-
System.IO.File.WriteAllText(configFile, Builder.ToString(), new System.Text.UTF8Encoding(true));
293+
File.WriteAllText(configFile, Builder.ToString(), new System.Text.UTF8Encoding(true));
239294
}
240295
catch
241296
{

source/ObjectViewer/ProgramS.cs

+18-16
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ internal static void RefreshObjects()
384384
// process events
385385
internal static void KeyDown(object sender, KeyboardKeyEventArgs e)
386386
{
387+
387388
switch (e.Key)
388389
{
389390
case Key.LShift:
@@ -502,26 +503,28 @@ internal static void KeyDown(object sender, KeyboardKeyEventArgs e)
502503
Game.Menu.ProcessCommand(Translations.Command.MenuDown, 0);
503504
}
504505
break;
505-
case Key.A:
506+
case var value when value == (Key)Interface.CurrentOptions.CameraMoveLeft:
506507
case Key.Keypad4:
507508
MoveX = -1;
508509
break;
509-
case Key.D:
510-
case Key.Keypad6:
510+
case var value when value == (Key)Interface.CurrentOptions.CameraMoveRight:
511+
case Key.Keypad6:
511512
MoveX = 1;
512513
break;
513-
case Key.Keypad8:
514+
case var value when value == (Key)Interface.CurrentOptions.CameraMoveUp:
515+
case Key.Keypad8:
514516
MoveY = 1;
515517
break;
516-
case Key.Keypad2:
518+
case var value when value == (Key)Interface.CurrentOptions.CameraMoveDown:
519+
case Key.Keypad2:
517520
MoveY = -1;
518521
break;
519-
case Key.W:
520-
case Key.Keypad9:
522+
case var value when value == (Key)Interface.CurrentOptions.CameraMoveForward:
523+
case Key.Keypad9:
521524
MoveZ = 1;
522525
break;
523-
case Key.S:
524-
case Key.Keypad3:
526+
case var value when value == (Key)Interface.CurrentOptions.CameraMoveBackward:
527+
case Key.Keypad3:
525528
MoveZ = -1;
526529
break;
527530
case Key.Keypad5:
@@ -631,19 +634,18 @@ internal static void KeyUp(object sender, KeyboardKeyEventArgs e)
631634
case Key.Down:
632635
RotateY = 0;
633636
break;
634-
case Key.A:
635-
case Key.D:
636-
case Key.Keypad4:
637+
case var value when value == (Key)Interface.CurrentOptions.CameraMoveLeft || value == (Key)Interface.CurrentOptions.CameraMoveRight:
638+
case Key.Keypad4:
637639
case Key.Keypad6:
638640
MoveX = 0;
639641
break;
640-
case Key.Keypad8:
642+
case var value when value == (Key)Interface.CurrentOptions.CameraMoveUp || value == (Key)Interface.CurrentOptions.CameraMoveDown:
643+
case Key.Keypad8:
641644
case Key.Keypad2:
642645
MoveY = 0;
643646
break;
644-
case Key.W:
645-
case Key.S:
646-
case Key.Keypad9:
647+
case var value when value == (Key)Interface.CurrentOptions.CameraMoveForward || value == (Key)Interface.CurrentOptions.CameraMoveBackward:
648+
case Key.Keypad9:
647649
case Key.Keypad3:
648650
MoveZ = 0;
649651
break;

0 commit comments

Comments
 (0)