Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
VolcanicArts committed Sep 28, 2023
2 parents a36b1ee + 04c9c67 commit 0ade081
Show file tree
Hide file tree
Showing 23 changed files with 797 additions and 104 deletions.
4 changes: 2 additions & 2 deletions VRCOSC.Desktop/VRCOSC.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<ApplicationIcon>game.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>0.0.0</Version>
<FileVersion>2023.826.0</FileVersion>
<FileVersion>2023.928.0</FileVersion>
<Title>VRCOSC</Title>
<Authors>VolcanicArts</Authors>
<Company>VolcanicArts</Company>
<Nullable>enable</Nullable>
<AssemblyVersion>2023.826.0</AssemblyVersion>
<AssemblyVersion>2023.928.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion VRCOSC.Game/ChatBox/Clips/Clip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private void removeAbsentModules(List<ClipState> localStates)
{
foreach (var clipState in localStates.ToImmutableList())
{
var stateValid = clipState.ModuleNames.All(moduleName => appManager.ModuleManager.GetModule(moduleName) is not null);
var stateValid = clipState.ModuleNames.All(moduleName => appManager.ModuleManager.IsModuleLoaded(moduleName));
if (!stateValid) localStates.Remove(clipState);
}
}
Expand Down
20 changes: 3 additions & 17 deletions VRCOSC.Game/ChatBox/DefaultTimeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public static IEnumerable<Clip> GenerateDefaultTimeline(ChatBoxManager chatBoxMa
yield return generateClockClip(chatBoxManager);
yield return generateHwsClip(chatBoxManager);
yield return generateWeatherClip(chatBoxManager);
yield return generateChatBoxTextClip(chatBoxManager);
yield return generateHeartrateClip(chatBoxManager);
yield return generateMediaClip(chatBoxManager);
yield return generateSpeechToTextClip(chatBoxManager);
Expand All @@ -24,7 +23,7 @@ private static Clip generateClockClip(ChatBoxManager chatBoxManager)
{
var clip = chatBoxManager.CreateClip();
clip.Name.Value = "Clock";
clip.Priority.Value = chatBoxManager.PriorityCount.Value - 7;
clip.Priority.Value = chatBoxManager.PriorityCount.Value - 6;
clip.Start.Value = 0;
clip.End.Value = 60;
clip.AssociatedModules.Add("clockmodule");
Expand All @@ -37,7 +36,7 @@ private static Clip generateHwsClip(ChatBoxManager chatBoxManager)
{
var clip = chatBoxManager.CreateClip();
clip.Name.Value = "Hardware Stats";
clip.Priority.Value = chatBoxManager.PriorityCount.Value - 6;
clip.Priority.Value = chatBoxManager.PriorityCount.Value - 5;
clip.Start.Value = 0;
clip.End.Value = 60;
clip.AssociatedModules.Add("hardwarestatsmodule");
Expand All @@ -50,7 +49,7 @@ private static Clip generateWeatherClip(ChatBoxManager chatBoxManager)
{
var clip = chatBoxManager.CreateClip();
clip.Name.Value = "Weather";
clip.Priority.Value = chatBoxManager.PriorityCount.Value - 5;
clip.Priority.Value = chatBoxManager.PriorityCount.Value - 4;
clip.Start.Value = 0;
clip.End.Value = 60;
clip.AssociatedModules.Add("weathermodule");
Expand All @@ -59,19 +58,6 @@ private static Clip generateWeatherClip(ChatBoxManager chatBoxManager)
return clip;
}

private static Clip generateChatBoxTextClip(ChatBoxManager chatBoxManager)
{
var clip = chatBoxManager.CreateClip();
clip.Name.Value = "ChatBox Text";
clip.Priority.Value = chatBoxManager.PriorityCount.Value - 4;
clip.Start.Value = 0;
clip.End.Value = 60;
clip.AssociatedModules.Add("chatboxtextmodule");
clip.GetStateFor("chatboxtextmodule", "default")!.Enabled.Value = true;

return clip;
}

private static Clip generateHeartrateClip(ChatBoxManager chatBoxManager)
{
var clip = chatBoxManager.CreateClip();
Expand Down
1 change: 1 addition & 0 deletions VRCOSC.Game/ChatBox/Serialisation/V1/TimelineSerialiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected override bool ExecuteAfterDeserialisation(SerialisableTimeline data)
if (index == -1) return;
clipState.States[index].Module = migration.SerialisedName;
clipState.Format = clipState.Format.Replace(migration.LegacySerialisedName.TrimEnd("module"), migration.SerialisedName.TrimEnd("module"));
migrationOccurred = true;
});
});
Expand Down
10 changes: 10 additions & 0 deletions VRCOSC.Game/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,14 @@ public static class AssemblyExtensions
public static class StringExtensions
{
public static string Truncate(this string value, int maxChars) => value.Length <= maxChars ? value : value[..maxChars] + "...";
public static string TrimEnd(this string s, string trimmer) => string.IsNullOrEmpty(s) || string.IsNullOrEmpty(trimmer) || !s.EndsWith(trimmer, StringComparison.OrdinalIgnoreCase) ? s : s[..^trimmer.Length];
}

public static class IntegerExtensions
{
public static int Modulo(this int x, int m)
{
var r = x % m;
return r < 0 ? r + m : r;
}
}
4 changes: 3 additions & 1 deletion VRCOSC.Game/Graphics/UI/Text/IntTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ namespace VRCOSC.Game.Graphics.UI.Text;
public partial class IntTextBox : ValidationTextBox<int>
{
public bool AllowNegative { get; init; } = false;
public int? Minimum { get; init; }
public int? Maximum { get; init; }

public IntTextBox()
{
EmptyIsValid = false;
}

protected override bool IsTextValid(string text) => int.TryParse(text, out var intText) && (intText >= 0 || AllowNegative);
protected override bool IsTextValid(string text) => int.TryParse(text, out var intText) && (intText >= 0 || AllowNegative) && (Minimum is null || intText >= Minimum) && (Maximum is null || intText <= Maximum);

protected override int GetConvertedText() => int.Parse(Current.Value);
}
7 changes: 5 additions & 2 deletions VRCOSC.Game/Managers/StartupManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License.
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License.
// See the LICENSE file in the repository root for full license text.

using System;
Expand Down Expand Up @@ -71,7 +71,10 @@ public void Start()
if (Process.GetProcessesByName(processName).Any()) return;
Process.Start(new ProcessStartInfo(instance.FilePath.Value, instance.LaunchArguments.Value));
Process.Start(new ProcessStartInfo(instance.FilePath.Value, instance.LaunchArguments.Value)
{
WorkingDirectory = Path.GetDirectoryName(instance.FilePath.Value)
});
logger.Log($"Running file {instance.FilePath.Value}" + (string.IsNullOrEmpty(instance.LaunchArguments.Value) ? string.Empty : $" with launch arguments {instance.LaunchArguments.Value}"));
}
catch (Exception e)
Expand Down
9 changes: 6 additions & 3 deletions VRCOSC.Game/Modules/Bases/Heartrate/HeartrateModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace VRCOSC.Game.Modules.Bases.Heartrate;
public abstract class HeartrateModule<T> : ChatBoxModule where T : HeartrateProvider
{
private const int reconnection_delay = 2000;
private const int reconnection_limit = 3;
private const int reconnection_limit = 30;

protected T? HeartrateProvider;

Expand Down Expand Up @@ -59,7 +59,7 @@ protected override void OnModuleStart()
ChangeStateTo(HeartrateState.Default);
}

private void attemptReconnection()
private async void attemptReconnection()
{
if (connectionCount >= reconnection_limit)
{
Expand All @@ -70,7 +70,10 @@ private void attemptReconnection()
Log("Attempting reconnection...");
Thread.Sleep(reconnection_delay);

HeartrateProvider?.Teardown();
if (HeartrateProvider is null) return;

await HeartrateProvider.Teardown();

HeartrateProvider?.Initialise();
connectionCount++;
}
Expand Down
4 changes: 2 additions & 2 deletions VRCOSC.Game/Modules/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ protected T GetSetting<T>(Enum lookup)
#region Parameters

/// <summary>
/// Allows for sending a parameter that hasn't been registed. Only use this when absolutely necessary
/// Allows for sending a parameter that hasn't been registered. Only use this when absolutely necessary
/// </summary>
protected void SendParameter<T>(string parameterName, T value) where T : struct
protected void SendParameter(string parameterName, object value)
{
scheduler.Add(() => oscClient.SendValue($"{VRChatOscConstants.ADDRESS_AVATAR_PARAMETERS_PREFIX}/{parameterName}", value));
}
Expand Down
6 changes: 3 additions & 3 deletions VRCOSC.Game/VRCOSC.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<LangVersion>11</LangVersion>
<PackageId>VolcanicArts.VRCOSC.SDK</PackageId>
<Version>2023.826.0</Version>
<Version>2023.928.0</Version>
<Title>VRCOSC SDK</Title>
<Authors>VolcanicArts</Authors>
<Description>SDK for creating custom modules with VRCOSC</Description>
Expand All @@ -19,8 +19,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.2" />
<PackageReference Include="Octokit" Version="7.1.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.823.0" />
<PackageReference Include="Octokit" Version="8.0.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.904.0" />
<PackageReference Include="PInvoke.User32" Version="0.7.124" />
<PackageReference Include="PolySharp" Version="1.13.2">
<PrivateAssets>all</PrivateAssets>
Expand Down
4 changes: 2 additions & 2 deletions VRCOSC.Game/VRCOSCGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected override void LoadComplete()
notificationContainer.Notify(new TimedNotification
{
Title = "Join The Community!",
Description = "Click to join the Discord server",
Description = "Click to join the Discord server!",
Icon = FontAwesome.Brands.Discord,
Colour = Colour4.FromHex("7289DA"),
ClickCallback = () => host.OpenUrlExternally(discord_invite_url),
Expand All @@ -119,7 +119,7 @@ protected override void LoadComplete()
notificationContainer.Notify(new TimedNotification
{
Title = "Enjoying the app?",
Description = "Click to buy me a coffee",
Description = "Click to support me!",
Icon = FontAwesome.Solid.Coffee,
Colour = Colour4.FromHex("ff5f5f"),
ClickCallback = () => host.OpenUrlExternally(kofi_url),
Expand Down
26 changes: 25 additions & 1 deletion VRCOSC.Modules/Clock/ClockModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ protected override void CreateAttributes()
CreateVariable(ClockVariable.Minutes, "Minutes", "m");
CreateVariable(ClockVariable.Seconds, "Seconds", "s");
CreateVariable(ClockVariable.Period, "AM/PM", "period");
CreateVariable(ClockVariable.Symbol, "Symbol", "symbol");

CreateState(ClockState.Default, "Default", $"Local Time/v{GetVariableFormat(ClockVariable.Hours)}:{GetVariableFormat(ClockVariable.Minutes)}{GetVariableFormat(ClockVariable.Period)}");
}
Expand Down Expand Up @@ -81,6 +82,28 @@ private void updateVariables()
SetVariableValue(ClockVariable.Minutes, minuteText);
SetVariableValue(ClockVariable.Seconds, secondText);
SetVariableValue(ClockVariable.Period, periodText);
SetVariableValue(ClockVariable.Symbol, getClockSymbol(time));
}

private static string getClockSymbol(DateTime time)
{
var offset = getClockSymbolCharacter(time);

var surrogate1 = 0xD800 + ((offset - 0x10000) >> 10);
var surrogate2 = 0xDC00 + ((offset - 0x10000) & 0x3FF);

var newCodePoint = ((surrogate1 - 0xD800) << 10) + (surrogate2 - 0xDC00) + 0x10000;

return char.ConvertFromUtf32(newCodePoint);
}

private static int getClockSymbolCharacter(DateTime time)
{
const int base_code_point = 128336;
const int half_past_base = 128348;

var hour = (time.Hour + 11) % 12;
return time.Minute >= 30 ? half_past_base + hour : base_code_point + hour;
}

private static float getSmoothedSeconds(DateTime time) => time.Second + time.Millisecond / 1000f;
Expand Down Expand Up @@ -126,7 +149,8 @@ private enum ClockVariable
Hours,
Minutes,
Seconds,
Period
Period,
Symbol
}

private enum ClockMode
Expand Down
Loading

0 comments on commit 0ade081

Please sign in to comment.