Skip to content

Commit e03b053

Browse files
committed
Merge branch 'dev' into main
2 parents 48a6fac + 97a4e32 commit e03b053

File tree

21 files changed

+217
-49
lines changed

21 files changed

+217
-49
lines changed

VRCOSC.Desktop/VRCOSC.Desktop.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
<ApplicationIcon>game.ico</ApplicationIcon>
77
<ApplicationManifest>app.manifest</ApplicationManifest>
88
<Version>0.0.0</Version>
9-
<FileVersion>2023.423.0</FileVersion>
9+
<FileVersion>2023.424.0</FileVersion>
1010
<Title>VRCOSC</Title>
1111
<Authors>VolcanicArts</Authors>
1212
<Company>VolcanicArts</Company>
1313
<Nullable>enable</Nullable>
14-
<AssemblyVersion>2023.423.0</AssemblyVersion>
14+
<AssemblyVersion>2023.424.0</AssemblyVersion>
1515
</PropertyGroup>
1616
<ItemGroup Label="Project References">
1717
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />

VRCOSC.Game/ChatBox/ChatBoxManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public void Initialise(VRChatOscClient oscClient, Bindable<int> sendDelay, Dicti
158158
{
159159
this.oscClient = oscClient;
160160
this.sendDelay = sendDelay;
161+
sendEnabled = true;
161162
startTime = DateTimeOffset.Now;
162163
nextValidTime = startTime;
163164
isClear = true;
@@ -215,6 +216,8 @@ private void evaluateClips()
215216

216217
private void handleClip(Clip? clip)
217218
{
219+
if (!sendEnabled) return;
220+
218221
if (clip is null)
219222
{
220223
if (!isClear) clearChatBox();

VRCOSC.Game/ChatBox/Clips/Clip.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public void InjectDependencies(ChatBoxManager chatBoxManager)
3939
AssociatedModules.BindCollectionChanged((_, _) => chatBoxManager.Save());
4040
Enabled.BindValueChanged(_ => chatBoxManager.Save());
4141
Name.BindValueChanged(_ => chatBoxManager.Save());
42+
Priority.BindValueChanged(_ => chatBoxManager.Save());
4243
Start.BindValueChanged(_ => chatBoxManager.Save());
4344
End.BindValueChanged(_ => chatBoxManager.Save());
4445
States.BindCollectionChanged((_, _) => chatBoxManager.Save());

VRCOSC.Game/Extensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,8 @@ public static string ToReadableName(this Type type)
4040
};
4141
}
4242
}
43+
44+
public static class TimeSpanExtensions
45+
{
46+
public static string Format(this TimeSpan timeSpan) => string.Format(timeSpan.TotalHours >= 1 ? @"{0:hh\:mm\:ss}" : @"{0:mm\:ss}", timeSpan);
47+
}

VRCOSC.Game/Graphics/ChatBox/SelectedClip/SelectedClipStateEditorContainer.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using osu.Framework.Graphics.Containers;
1111
using osu.Framework.Graphics.Shapes;
1212
using osu.Framework.Graphics.Sprites;
13+
using osu.Framework.Platform;
1314
using osuTK;
1415
using VRCOSC.Game.ChatBox;
1516
using VRCOSC.Game.Graphics.Themes;
@@ -20,6 +21,11 @@ namespace VRCOSC.Game.Graphics.ChatBox.SelectedClip;
2021

2122
public partial class SelectedClipStateEditorContainer : Container
2223
{
24+
private const string chatbox_v3_wiki_url = @"https://github.com/VolcanicArts/VRCOSC/wiki/ChatBox-V3";
25+
26+
[Resolved]
27+
private GameHost host { get; set; } = null!;
28+
2329
[Resolved]
2430
private ChatBoxManager chatBoxManager { get; set; } = null!;
2531

@@ -29,7 +35,7 @@ public partial class SelectedClipStateEditorContainer : Container
2935
private Container eventsTitle = null!;
3036
private FillFlowContainer<DrawableEvent> eventFlow = null!;
3137

32-
private Bindable<bool> showRelevantStates = new(true);
38+
private readonly Bindable<bool> showRelevantStates = new(true);
3339

3440
[BackgroundDependencyLoader]
3541
private void load()
@@ -192,7 +198,27 @@ private void load()
192198
}
193199
}
194200
}
195-
}
201+
},
202+
new Container
203+
{
204+
Anchor = Anchor.TopRight,
205+
Origin = Anchor.TopRight,
206+
Size = new Vector2(40),
207+
Padding = new MarginPadding(3),
208+
Child = new IconButton
209+
{
210+
Anchor = Anchor.Centre,
211+
Origin = Anchor.Centre,
212+
RelativeSizeAxes = Axes.Both,
213+
Icon = FontAwesome.Solid.Question,
214+
BackgroundColour = ThemeManager.Current[ThemeAttribute.Action],
215+
IconShadow = true,
216+
Masking = true,
217+
CornerRadius = 17,
218+
IconPadding = 6,
219+
Action = () => host.OpenUrlExternally(chatbox_v3_wiki_url)
220+
}
221+
},
196222
};
197223
}
198224

VRCOSC.Game/Graphics/ModuleRun/ParameterDisplay.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using osu.Framework.Graphics.Sprites;
1212
using VRCOSC.Game.Graphics.TabBar;
1313
using VRCOSC.Game.Graphics.Themes;
14+
using VRCOSC.Game.OSC.VRChat;
1415

1516
namespace VRCOSC.Game.Graphics.ModuleRun;
1617

@@ -95,7 +96,7 @@ public void ClearContent()
9596

9697
public void AddEntry(string key, object value)
9798
{
98-
if (selectedTab.Value != Tab.Modules) return;
99+
if (selectedTab.Value != Tab.Modules && key != VRChatOscConstants.ADDRESS_CHATBOX_INPUT && key != VRChatOscConstants.ADDRESS_CHATBOX_TYPING) return;
99100

100101
Schedule(() =>
101102
{
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 osu.Framework.Graphics.Sprites;
5+
using VRCOSC.Game.Graphics.Themes;
6+
7+
namespace VRCOSC.Game.Graphics.Notifications;
8+
9+
public partial class PortInUseNotification : BasicNotification
10+
{
11+
public PortInUseNotification(int port)
12+
{
13+
Title = "OSC Error";
14+
Description = $"OSC port {port} is already in use by another program";
15+
Icon = FontAwesome.Solid.ExclamationTriangle;
16+
Colour = ThemeManager.Current[ThemeAttribute.Failure];
17+
}
18+
19+
public PortInUseNotification(string message)
20+
{
21+
Title = "OSC Error";
22+
Description = message;
23+
Icon = FontAwesome.Solid.ExclamationTriangle;
24+
Colour = ThemeManager.Current[ThemeAttribute.Failure];
25+
}
26+
}

VRCOSC.Game/Graphics/Router/RouterScreen.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using osu.Framework.Graphics.Containers;
77
using osu.Framework.Graphics.Shapes;
88
using osu.Framework.Graphics.Sprites;
9+
using osu.Framework.Platform;
910
using osuTK;
1011
using VRCOSC.Game.Graphics.Themes;
1112
using VRCOSC.Game.Graphics.UI.Button;
@@ -14,6 +15,11 @@ namespace VRCOSC.Game.Graphics.Router;
1415

1516
public partial class RouterScreen : Container
1617
{
18+
private const string vrcosc_router_wiki_url = @"https://github.com/VolcanicArts/VRCOSC/wiki/VRCOSC-Router";
19+
20+
[Resolved]
21+
private GameHost host { get; set; } = null!;
22+
1723
[Resolved]
1824
private RouterManager routerManager { get; set; } = null!;
1925

@@ -91,6 +97,26 @@ private void load()
9197
}
9298
}
9399
}
100+
},
101+
new Container
102+
{
103+
Anchor = Anchor.TopRight,
104+
Origin = Anchor.TopRight,
105+
Size = new Vector2(70),
106+
Padding = new MarginPadding(10),
107+
Child = new IconButton
108+
{
109+
Anchor = Anchor.Centre,
110+
Origin = Anchor.Centre,
111+
RelativeSizeAxes = Axes.Both,
112+
Icon = FontAwesome.Solid.Question,
113+
BackgroundColour = ThemeManager.Current[ThemeAttribute.Action],
114+
IconShadow = true,
115+
Masking = true,
116+
CornerRadius = 25,
117+
IconPadding = 6,
118+
Action = () => host.OpenUrlExternally(vrcosc_router_wiki_url)
119+
}
94120
}
95121
};
96122

VRCOSC.Game/Modules/GameManager.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,38 @@ private async Task startAsync()
213213

214214
await Task.Delay(startstop_delay);
215215

216-
VRChatOscClient.Enable(OscClientFlag.Send);
216+
enableOscFlag(OscClientFlag.Send);
217217
Player.Initialise();
218218
ChatBoxManager.Initialise(VRChatOscClient, configManager.GetBindable<int>(VRCOSCSetting.ChatBoxTimeSpan), moduleEnabled);
219219
sendControlValues();
220220
ModuleManager.Start();
221-
VRChatOscClient.Enable(OscClientFlag.Receive);
221+
enableOscFlag(OscClientFlag.Receive);
222222

223-
OSCRouter.Initialise(routerManager.Store);
224-
OSCRouter.Enable();
223+
try
224+
{
225+
OSCRouter.Initialise(routerManager.Store);
226+
OSCRouter.Enable();
227+
}
228+
catch
229+
{
230+
notifications.Notify(new PortInUseNotification("Cannot initialise a port from OSCRouter"));
231+
}
225232

226233
State.Value = GameManagerState.Started;
227234
}
228235

236+
private void enableOscFlag(OscClientFlag flag)
237+
{
238+
try
239+
{
240+
VRChatOscClient.Enable(flag);
241+
}
242+
catch
243+
{
244+
notifications.Notify(new PortInUseNotification(flag == OscClientFlag.Send ? configManager.Get<int>(VRCOSCSetting.SendPort) : configManager.Get<int>(VRCOSCSetting.ReceivePort)));
245+
}
246+
}
247+
229248
public void Stop() => Schedule(() => _ = stopAsync());
230249

231250
private async Task stopAsync()
@@ -283,13 +302,8 @@ private bool initialiseOscClient()
283302

284303
private void checkForOpenVR() => Task.Run(() =>
285304
{
286-
static bool isOpenVROpen() => Process.GetProcessesByName(@"vrmonitor").Any();
287-
288-
if (isOpenVROpen())
289-
{
290-
OVRClient.Init();
291-
OVRClient.SetAutoLaunch(configManager.Get<bool>(VRCOSCSetting.AutoStartOpenVR));
292-
}
305+
OVRClient.Init();
306+
OVRClient.SetAutoLaunch(configManager.Get<bool>(VRCOSCSetting.AutoStartOpenVR));
293307
});
294308

295309
private void checkForVRChat()

VRCOSC.Game/OSC/VRChat/VRChatOscConstants.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static class VRChatOscConstants
1414
public const string ADDRESS_CHATBOX_INPUT = @"/chatbox/input";
1515
public const string ADDRESS_CHATBOX_TYPING = @"/chatbox/typing";
1616

17-
public const int UPDATE_FREQUENCY = 20;
18-
public const int UPDATE_DELTA = (int)(1f / UPDATE_FREQUENCY * 1000f);
19-
public static readonly TimeSpan UPDATE_TIME_SPAN = TimeSpan.FromMilliseconds(UPDATE_DELTA);
17+
public const double UPDATE_FREQUENCY_SECONDS = 20;
18+
public const double UPDATE_DELTA_MILLISECONDS = 1000d / UPDATE_FREQUENCY_SECONDS;
19+
public static readonly TimeSpan UPDATE_TIME_SPAN = TimeSpan.FromMilliseconds(UPDATE_DELTA_MILLISECONDS);
2020
}

VRCOSC.Game/OpenVR/OVRClient.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public void Init()
3838
{
3939
if (HasInitialised) return;
4040

41-
HasInitialised = OVRHelper.InitialiseOpenVR(Metadata.ApplicationType);
42-
43-
if (!HasInitialised) return;
41+
if (!OVRHelper.InitialiseOpenVR(Metadata.ApplicationType)) return;
4442

4543
Valve.VR.OpenVR.Applications.AddApplicationManifest(Metadata.ApplicationManifest, false);
4644
System.Init();
4745
Input.Init();
46+
47+
HasInitialised = true;
4848
}
4949

5050
public void Update()
@@ -84,8 +84,10 @@ private void shutdown()
8484
OnShutdown?.Invoke();
8585
}
8686

87-
public static void SetAutoLaunch(bool value)
87+
public void SetAutoLaunch(bool value)
8888
{
89+
if (!HasInitialised) return;
90+
8991
Valve.VR.OpenVR.Applications.SetApplicationAutoLaunch("volcanicarts.vrcosc", value);
9092
}
9193
}

VRCOSC.Game/OpenVR/OVRHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ private static void error(string methodName, ETrackedDeviceProperty property, ET
2828
internal static bool InitialiseOpenVR(EVRApplicationType applicationType)
2929
{
3030
var err = new EVRInitError();
31-
var state = Valve.VR.OpenVR.InitInternal(ref err, applicationType);
32-
return err == EVRInitError.None && state != 0;
31+
Valve.VR.OpenVR.Init(ref err, applicationType);
32+
return err == EVRInitError.None;
3333
}
3434

3535
internal static float GetFrameTimeMilli()

VRCOSC.Game/Providers/Media/WindowsMediaProvider.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public async Task<bool> Hook()
4242

4343
public void UnHook()
4444
{
45-
sessionManager!.CurrentSessionChanged -= onCurrentSessionChanged;
45+
if (sessionManager is null) return;
46+
47+
sessionManager.CurrentSessionChanged -= onCurrentSessionChanged;
4648
sessionManager.SessionsChanged -= sessionsChanged;
4749

4850
sessions.Clear();

VRCOSC.Game/VRCOSC.Game.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Nullable>enable</Nullable>
55
<LangVersion>11</LangVersion>
66
<PackageId>VolcanicArts.VRCOSC.SDK</PackageId>
7-
<Version>2023.423.0</Version>
7+
<Version>2023.424.0</Version>
88
<Title>VRCOSC SDK</Title>
99
<Authors>VolcanicArts</Authors>
1010
<Description>SDK for creating custom modules with VRCOSC</Description>

VRCOSC.Modules/AFK/AFKModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class AFKModule : ChatBoxModule
1111
public override string Description => "Display text and time since going AFK";
1212
public override string Author => "VolcanicArts";
1313
public override ModuleType Type => ModuleType.General;
14-
protected override TimeSpan DeltaUpdate => TimeSpan.FromSeconds(1.5f);
14+
protected override TimeSpan DeltaUpdate => TimeSpan.FromSeconds(1);
1515

1616
private DateTime? afkBegan;
1717

VRCOSC.Modules/Clock/ClockModule.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,31 @@ protected override void OnModuleUpdate()
6060
SendParameter(ClockParameter.Minutes, minuteNormalised);
6161
SendParameter(ClockParameter.Seconds, secondNormalised);
6262

63-
var hourText = GetSetting<ClockMode>(ClockSetting.Mode) == ClockMode.Twelve ? (time.Hour % 12).ToString("00") : time.Hour.ToString("00");
64-
var minuteText = time.Minute.ToString("00");
65-
var secondText = time.Second.ToString("00");
66-
var periodText = time.Hour >= 12 ? "pm" : "am";
63+
string hourText, minuteText, secondText, periodText;
64+
65+
if (GetSetting<ClockMode>(ClockSetting.Mode) == ClockMode.Twelve)
66+
{
67+
var formattedTime = time.ToString("hh:mm:ss tt");
68+
var timeSplitPeriod = formattedTime.Split(new[] { ' ' }, 2);
69+
var timeText = timeSplitPeriod[0];
70+
71+
var timeTextSplit = timeText.Split(new[] { ':' }, 3);
72+
73+
hourText = timeTextSplit[0];
74+
minuteText = timeTextSplit[1];
75+
secondText = timeTextSplit[2];
76+
periodText = timeSplitPeriod[1].ToLowerInvariant();
77+
}
78+
else
79+
{
80+
var formattedTime = time.ToString("HH:mm:ss");
81+
var timeTextSplit = formattedTime.Split(new[] { ':' }, 3);
82+
83+
hourText = timeTextSplit[0];
84+
minuteText = timeTextSplit[1];
85+
secondText = timeTextSplit[2];
86+
periodText = string.Empty;
87+
}
6788

6889
SetVariableValue(ClockVariable.Hours, hourText);
6990
SetVariableValue(ClockVariable.Minutes, minuteText);

VRCOSC.Modules/Media/MediaModule.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Diagnostics;
55
using Windows.Media;
66
using osu.Framework.Bindables;
7+
using VRCOSC.Game;
78
using VRCOSC.Game.Modules;
89
using VRCOSC.Game.Modules.ChatBox;
910
using VRCOSC.Game.Providers.Media;
@@ -116,8 +117,8 @@ private void updateVariables()
116117
SetVariableValue(MediaVariable.AlbumTitle, mediaProvider.State.AlbumTitle);
117118
SetVariableValue(MediaVariable.AlbumArtist, mediaProvider.State.AlbumArtist);
118119
SetVariableValue(MediaVariable.AlbumTrackCount, mediaProvider.State.AlbumTrackCount.ToString());
119-
SetVariableValue(MediaVariable.Time, mediaProvider.State.Position?.Position.ToString(@"mm\:ss"));
120-
SetVariableValue(MediaVariable.Duration, mediaProvider.State.Position?.EndTime.ToString(@"mm\:ss"));
120+
SetVariableValue(MediaVariable.Time, mediaProvider.State.Position?.Position.Format());
121+
SetVariableValue(MediaVariable.Duration, mediaProvider.State.Position?.EndTime.Format());
121122
SetVariableValue(MediaVariable.Volume, (mediaProvider.State.Volume * 100).ToString("##0"));
122123
}
123124

0 commit comments

Comments
 (0)