Skip to content

Commit 2c5fa33

Browse files
committed
Allow VRCOSC to close with SteamVR
1 parent 6eda0ac commit 2c5fa33

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

VRCOSC.Game/Config/VRCOSCConfigManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ protected override void InitialiseDefaults()
2828
SetDefault(VRCOSCSetting.UpdateRepo, @"https://github.com/VolcanicArts/VRCOSC");
2929
SetDefault(VRCOSCSetting.Theme, ColourTheme.Dark);
3030
SetDefault(VRCOSCSetting.ChatBoxTimeSpan, 1500);
31+
SetDefault(VRCOSCSetting.AutoStopOpenVR, false);
3132
}
3233
}
3334

@@ -41,5 +42,6 @@ public enum VRCOSCSetting
4142
UpdateMode,
4243
UpdateRepo,
4344
Theme,
44-
ChatBoxTimeSpan
45+
ChatBoxTimeSpan,
46+
AutoStopOpenVR
4547
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License.
2+
// See the LICENSE file in the repository root for full license text.
3+
4+
using VRCOSC.Game.Config;
5+
6+
namespace VRCOSC.Game.Graphics.Settings;
7+
8+
public sealed partial class AutomationSection : SectionContainer
9+
{
10+
protected override string Title => "Automation";
11+
12+
protected override void GenerateItems()
13+
{
14+
AddToggle("Start/Stop with VRChat", "Auto start/stop modules on VRChat start/stop", ConfigManager.GetBindable<bool>(VRCOSCSetting.AutoStartStop));
15+
AddToggle("Close with SteamVR", "Should VRCOSC close when SteamVR closes?", ConfigManager.GetBindable<bool>(VRCOSCSetting.AutoStopOpenVR));
16+
}
17+
}

VRCOSC.Game/Graphics/Settings/ModulesSection.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

VRCOSC.Game/Graphics/Settings/SettingsScreen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public SettingsScreen()
5555
{
5656
new GeneralSection(),
5757
new OscSection(),
58-
new ModulesSection(),
58+
new AutomationSection(),
5959
new UpdateSection()
6060
}
6161
}

VRCOSC.Game/Modules/OpenVRInterface.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class OpenVRInterface
3232

3333
private readonly Storage storage;
3434
public bool HasInitialised { get; private set; }
35+
public Action? OnOpenVRShutdown;
3536

3637
public OpenVRInterface(Storage storage)
3738
{
@@ -127,6 +128,7 @@ public void Update()
127128
OpenVR.System.AcknowledgeQuit_Exiting();
128129
OpenVR.Shutdown();
129130
HasInitialised = false;
131+
OnOpenVRShutdown?.Invoke();
130132
return;
131133
}
132134
}

VRCOSC.Game/VRCOSCGame.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ protected override void LoadComplete()
9494
{
9595
if (e.NewValue == GameManagerState.Starting) SelectedTab.Value = Tab.Modules;
9696
}, true);
97+
98+
gameManager.OpenVRInterface.OnOpenVRShutdown += () =>
99+
{
100+
if (ConfigManager.Get<bool>(VRCOSCSetting.AutoStopOpenVR)) prepareForExit();
101+
};
97102
}
98103

99104
private void checkUpdates()

0 commit comments

Comments
 (0)