Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/Controls/Default.controls
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; Current control configuration
; Current control configuration
; =============================
; This file was automatically generated. Please modify only if you know what you're doing.
; Last updated 2026.01.16
Expand Down Expand Up @@ -79,6 +79,7 @@ CAMERA_ZOOM_OUT, keyboard, Keypad0, 0
CAMERA_POI_PREVIOUS, keyboard, Keypad1, 0
CAMERA_POI_NEXT, keyboard, Keypad7, 0
CAMERA_RESET, keyboard, Keypad5, 0
CAMERA_GRAB_TOGGLE, mouse, 2, 0
CAMERA_RESTRICTION, keyboard, R, 2
TIMETABLE_TOGGLE, keyboard, T, 2
TIMETABLE_UP, keyboard, Up, 2
Expand Down
31 changes: 31 additions & 0 deletions assets/Languages/en-US.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,30 @@
<trans-unit id="assignment_joystick_axis_positive">
<source>positive direction</source>
</trans-unit>
<trans-unit id="selection_mouse">
<source>Mouse:</source>
</trans-unit>
<trans-unit id="selection_mouse_button">
<source>Button:</source>
</trans-unit>
<trans-unit id="assignment_mouse">
<source>Mouse</source>
</trans-unit>
<trans-unit id="assignment_mouse_left">
<source>Left Click</source>
</trans-unit>
<trans-unit id="assignment_mouse_middle">
<source>Middle Click</source>
</trans-unit>
<trans-unit id="assignment_mouse_right">
<source>Right Click</source>
</trans-unit>
<trans-unit id="assignment_mouse_scrollup">
<source>Scroll Up</source>
</trans-unit>
<trans-unit id="assignment_mouse_scrolldown">
<source>Scroll Down</source>
</trans-unit>
<trans-unit id="assignment_joystick_axis_invalid">
<source>invalid direction</source>
</trans-unit>
Expand Down Expand Up @@ -1216,6 +1240,9 @@
<trans-unit id="camera_transition_duration">
<source>Transition duration (sec):</source>
</trans-unit>
<trans-unit id="camera_zoom_scroll_speed">
<source>Zoom Scroll Speed:</source>
</trans-unit>
<trans-unit id="misc_simulation">
<source>Detail of simulation</source>
</trans-unit>
Expand Down Expand Up @@ -1312,6 +1339,7 @@
<trans-unit id="other_timetable_mode_prefercustom">
<source>Prefer custom timetable</source>
</trans-unit>

<trans-unit id="package_choose">
<source>Choose...</source>
</trans-unit>
Expand Down Expand Up @@ -2209,6 +2237,9 @@
<trans-unit id="camera_reset">
<source>Resets the camera view to default values</source>
</trans-unit>
<trans-unit id="camera_grab_toggle">
<source>Toggles camera grab (Mouse look)</source>
</trans-unit>
<trans-unit id="camera_restriction">
<source>Activates or deactivates interior view camera restriction</source>
</trans-unit>
Expand Down
59 changes: 58 additions & 1 deletion assets/Languages/id-ID.xlf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2.xsd">
<file datatype="plaintext" original="en-US.xlf" source-language="en-US" target-language="id-ID">
<body>
Expand Down Expand Up @@ -1156,6 +1156,38 @@
<source>positive direction</source>
<target>arah positif</target>
</trans-unit>
<trans-unit id="selection_mouse">
<source>Mouse:</source>
<target>Mouse:</target>
</trans-unit>
<trans-unit id="selection_mouse_button">
<source>Button:</source>
<target>Tombol:</target>
</trans-unit>
<trans-unit id="assignment_mouse">
<source>Mouse</source>
<target>Mouse</target>
</trans-unit>
<trans-unit id="assignment_mouse_left">
<source>Left Click</source>
<target>Klik Kiri</target>
</trans-unit>
<trans-unit id="assignment_mouse_middle">
<source>Middle Click</source>
<target>Klik Tengah</target>
</trans-unit>
<trans-unit id="assignment_mouse_right">
<source>Right Click</source>
<target>Klik Kanan</target>
</trans-unit>
<trans-unit id="assignment_mouse_scrollup">
<source>Scroll Up</source>
<target>Scroll Atas</target>
</trans-unit>
<trans-unit id="assignment_mouse_scrolldown">
<source>Scroll Down</source>
<target>Scroll Bawah</target>
</trans-unit>
<trans-unit id="assignment_joystick_axis_invalid">
<source>invalid direction</source>
<target>arah tidak valid</target>
Expand Down Expand Up @@ -1483,6 +1515,26 @@
<source>Miscellaneous</source>
<target>Lainnya</target>
</trans-unit>
<trans-unit id="camera">
<source>Camera options</source>
<target>Pengaturan kamera</target>
</trans-unit>
<trans-unit id="camera_interior_transition">
<source>Smooth interior transition</source>
<target>Transisi interior halus</target>
</trans-unit>
<trans-unit id="camera_exterior_transition">
<source>Smooth exterior transition</source>
<target>Transisi eksterior halus</target>
</trans-unit>
<trans-unit id="camera_transition_duration">
<source>Transition duration (sec):</source>
<target>Durasi transisi (detik):</target>
</trans-unit>
<trans-unit id="camera_zoom_scroll_speed">
<source>Zoom Scroll Speed:</source>
<target>Kecepatan Scroll Zoom:</target>
</trans-unit>
<trans-unit id="misc_simulation">
<source>Detail of simulation</source>
<target>Detail simulasi</target>
Expand Down Expand Up @@ -1609,6 +1661,7 @@
<source>Prefer custom timetable</source>
<target>Buat sendiri</target>
</trans-unit>

<trans-unit id="package_choose">
<source>Choose...</source>
<target>Pilih....</target>
Expand Down Expand Up @@ -2772,6 +2825,10 @@
<source>Resets the camera view to default values</source>
<target>Reset kamera</target>
</trans-unit>
<trans-unit id="camera_grab_toggle">
<source>Toggles camera grab (Mouse look)</source>
<target>Aktifkan/nonaktifkan kontrol kamera dengan mouse</target>
</trans-unit>
<trans-unit id="camera_restriction">
<source>Activates or deactivates interior view camera restriction</source>
<target>Aktifkan / matikan batasan kamera</target>
Expand Down
15 changes: 14 additions & 1 deletion source/OpenBVE/Game/Menu/Menu.Controls.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LibRender2.Primitives;
using LibRender2.Primitives;
using OpenBveApi.Colors;
using OpenBveApi.Hosts;
using OpenBveApi.Interface;
Expand Down Expand Up @@ -71,6 +71,19 @@ private static string GetControlDescription(int idx)
case ControlMethod.Invalid:
str = Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "menu", "joystick_notavailable" });
break;
case ControlMethod.Mouse:
str = Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "controls", "assignment_mouse" }) + " [";
switch (loadedControl.Element)
{
case 0: str += Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "controls", "assignment_mouse_left" }); break;
case 1: str += Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "controls", "assignment_mouse_middle" }); break;
case 2: str += Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "controls", "assignment_mouse_right" }); break;
case 3: str += Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "controls", "assignment_mouse_scrollup" }); break;
case 4: str += Translations.GetInterfaceString(HostApplication.OpenBve, new[] { "controls", "assignment_mouse_scrolldown" }); break;
default: str += loadedControl.Element; break;
}
str += "]";
break;
}

return str;
Expand Down
2 changes: 1 addition & 1 deletion source/OpenBVE/System/GameWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ protected override void OnRenderFrame(FrameEventArgs e)

MainLoop.UpdateControlRepeats(RealTimeElapsed);
MainLoop.ProcessKeyboard();
MainLoop.UpdateMouse(RealTimeElapsed);
MainLoop.ProcessControls(TimeElapsed);
MainLoop.UpdateMouse(RealTimeElapsed);
if (Program.Joysticks.AttachedJoysticks.TryGetTypedValue(AbstractRailDriver.Guid, out AbstractRailDriver railDriver))
{
if (Interface.CurrentOptions.RailDriverMPH)
Expand Down
16 changes: 15 additions & 1 deletion source/OpenBVE/System/Input/Controls.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -332,6 +332,20 @@ internal static void LoadControls(string FileOrNull, out Control[] Controls)

}
}
else if (Method == ControlMethod.Mouse & Terms.Length >= 3)
{
if (int.TryParse(Terms[2], out int CurrentButton))
{
Controls[Length].Method = Method;
Controls[Length].Element = CurrentButton;
Controls[Length].Option = 0;
if (Terms.Length >= 4 && int.TryParse(Terms[3], NumberStyles.Integer, Culture, out int Option))
{
Controls[Length].Option = Option;
}
Valid = true;
}
}

if (!Valid)
{
Expand Down
48 changes: 39 additions & 9 deletions source/OpenBVE/System/Input/ProcessControls.Analog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using LibRender2.Cameras;
using LibRender2.Overlays;
using OpenBveApi.Interface;
Expand Down Expand Up @@ -217,29 +217,49 @@ private static void ProcessAnalogControl(double TimeElapsed, ref Control Control
case Translations.Command.CameraMoveRight:
case Translations.Command.CameraMoveUp:
case Translations.Command.CameraMoveDown:
Program.Renderer.Camera.Move(Control.Command, Control.AnalogState);
double moveFactor = Control.AnalogState;
if (Control.Method == ControlMethod.Mouse && Control.Element >= 3)
{
moveFactor *= Interface.CurrentOptions.ZoomScrollSpeed;
}
Program.Renderer.Camera.Move(Control.Command, moveFactor);
break;
case Translations.Command.CameraRotateLeft:
case Translations.Command.CameraRotateRight:
case Translations.Command.CameraRotateUp:
case Translations.Command.CameraRotateDown:
case Translations.Command.CameraRotateCCW:
case Translations.Command.CameraRotateCW:
Program.Renderer.Camera.Rotate(Control.Command, Control.AnalogState);
double rotateFactor = Control.AnalogState;
if (Control.Method == ControlMethod.Mouse && Control.Element >= 3)
{
rotateFactor *= 10.0; // Boost scroll rotation
}
Program.Renderer.Camera.Rotate(Control.Command, rotateFactor);
break;
case Translations.Command.CameraZoomIn:
// camera zoom in
if (TimeElapsed > 0.0)
{
Program.Renderer.Camera.AlignmentDirection.Zoom = -CameraProperties.ZoomTopSpeed * Control.AnalogState;
double factor = Control.AnalogState;
if (Control.Method == ControlMethod.Mouse && Control.Element >= 3)
{
factor *= Interface.CurrentOptions.ZoomScrollSpeed;
}
Program.Renderer.Camera.AlignmentDirection.Zoom = -CameraProperties.ZoomTopSpeed * factor;
}

break;
case Translations.Command.CameraZoomOut:
// camera zoom out
if (TimeElapsed > 0.0)
{
Program.Renderer.Camera.AlignmentDirection.Zoom = CameraProperties.ZoomTopSpeed * Control.AnalogState;
double factor = Control.AnalogState;
if (Control.Method == ControlMethod.Mouse && Control.Element >= 3)
{
factor *= Interface.CurrentOptions.ZoomScrollSpeed;
}
Program.Renderer.Camera.AlignmentDirection.Zoom = CameraProperties.ZoomTopSpeed * factor;
}

break;
Expand All @@ -248,15 +268,20 @@ private static void ProcessAnalogControl(double TimeElapsed, ref Control Control
if (TimeElapsed > 0.0)
{
const double scrollSpeed = 250.0;
double timetableFactor = Control.AnalogState;
if (Control.Method == ControlMethod.Mouse && Control.Element >= 3)
{
timetableFactor *= 5.0;
}
switch (Program.Renderer.CurrentTimetable)
{
case DisplayedTimetable.Default:
Timetable.DefaultTimetablePosition += scrollSpeed * Control.AnalogState * TimeElapsed;
Timetable.DefaultTimetablePosition += scrollSpeed * timetableFactor * TimeElapsed;
if (Timetable.DefaultTimetablePosition > 0.0)
Timetable.DefaultTimetablePosition = 0.0;
break;
case DisplayedTimetable.Custom:
Timetable.CustomTimetablePosition += scrollSpeed * Control.AnalogState * TimeElapsed;
Timetable.CustomTimetablePosition += scrollSpeed * timetableFactor * TimeElapsed;
if (Timetable.CustomTimetablePosition > 0.0)
Timetable.CustomTimetablePosition = 0.0;
break;
Expand All @@ -269,10 +294,15 @@ private static void ProcessAnalogControl(double TimeElapsed, ref Control Control
if (TimeElapsed > 0.0)
{
const double scrollSpeed = 250.0;
double timetableFactor = Control.AnalogState;
if (Control.Method == ControlMethod.Mouse && Control.Element >= 3)
{
timetableFactor *= 5.0;
}
switch (Program.Renderer.CurrentTimetable)
{
case DisplayedTimetable.Default:
Timetable.DefaultTimetablePosition -= scrollSpeed * Control.AnalogState * TimeElapsed;
Timetable.DefaultTimetablePosition -= scrollSpeed * timetableFactor * TimeElapsed;
double max;
if (Timetable.DefaultTimetableTexture != null)
{
Expand All @@ -291,7 +321,7 @@ private static void ProcessAnalogControl(double TimeElapsed, ref Control Control

break;
case DisplayedTimetable.Custom:
Timetable.CustomTimetablePosition -= scrollSpeed * Control.AnalogState * TimeElapsed;
Timetable.CustomTimetablePosition -= scrollSpeed * timetableFactor * TimeElapsed;
Texture texture = Timetable.CurrentCustomTimetableDaytimeTexture ?? Timetable.CurrentCustomTimetableNighttimeTexture;
if (texture != null)
{
Expand Down
16 changes: 16 additions & 0 deletions source/OpenBVE/System/Input/ProcessControls.Digital.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using OpenBveApi.Motor;
using OpenBveApi.Routes;
using OpenBveApi.Runtime;
using OpenTK.Input;
using RouteManager2.MessageManager;
using RouteManager2.SignalManager;
using RouteManager2.Stations;
Expand Down Expand Up @@ -573,6 +574,19 @@ private static void ProcessDigitalControl(double TimeElapsed, ref Control Contro
break;
}

break;
case Translations.Command.CameraGrabToggle:
if (Program.Renderer.CurrentInterface == InterfaceType.Normal)
{
MainLoop.MouseGrabEnabled = !MainLoop.MouseGrabEnabled;
if (MainLoop.MouseGrabEnabled)
{
Program.Renderer.GameWindow.CursorVisible = false;
System.Drawing.Point center = Program.Renderer.GameWindow.PointToScreen(new System.Drawing.Point(Program.Renderer.GameWindow.ClientRectangle.Width / 2, Program.Renderer.GameWindow.ClientRectangle.Height / 2));
Mouse.SetPosition(center.X, center.Y);
}
MainLoop.MouseGrabIgnoreOnce = true;
}
break;
case Translations.Command.DeviceConstSpeed:
// const speed
Expand Down Expand Up @@ -941,6 +955,8 @@ private static void ProcessDigitalControl(double TimeElapsed, ref Control Contro
break;
case Translations.Command.MenuActivate:
// menu
MainLoop.MouseGrabEnabled = false;
Program.Renderer.GameWindow.CursorVisible = true;
Game.Menu.PushMenu(MenuType.Top);
break;
case Translations.Command.MiscPause:
Expand Down
Loading