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 Apr 28, 2023
2 parents b0bb0a7 + d00957a commit 2cbebca
Show file tree
Hide file tree
Showing 17 changed files with 279 additions and 53 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ P.S. The VRCOSC-Controls.unitypackage prefab is global controls for VRCOSC. It d
| Media | Windows Media integration. Allows for full control over Windows Media from your action menu | Previously Spotify integration | VRCOSC-Media.unitypackage |
| Hardware Stats | Displays your hardware's stats in the ChatBox | Requires VRCOSC to be run as administrator to display CPU temps | |
| SRanipal | A hot-swappable replacement for VRCFaceTracking's Vive face and eye tracking | No avatar work is needed. All parameters sent are the exact same as VRCFaceTracking | |
| AFK Display | Display in the ChatBox how long you've been AFK for | | |
| Speech To Text | Run Speech To Text and display the result in your ChatBox | You can choose to only run this when you're muted in-game | |
| HypeRate | Connects to [HypeRate.io](https://www.hyperate.io/) to display your live heartrate in-game | [Supported Devices](https://www.hyperate.io/supported-devices). Compatible with WearOS, Apple Watch, and all major dedicated heartrate monitors | VRCOSC-Heartrate.unitypackage |
| Pulsoid | Connects to [Pulsoid](https://pulsoid.net/) to display your live heartrate in-game | [Supported Devices](https://www.blog.pulsoid.net/monitors). Compatible with 200+ devices including WearOS, Apple Watch, and all dedicated heartrate monitors | VRCOSC-Heartrate.unitypackage |
| OpenVR Statistics | Gets statistics from your OpenVR (SteamVR) session | | VRCOSC-Trackers.unitypackage |
Expand Down
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.426.0</FileVersion>
<FileVersion>2023.428.0</FileVersion>
<Title>VRCOSC</Title>
<Authors>VolcanicArts</Authors>
<Company>VolcanicArts</Company>
<Nullable>enable</Nullable>
<AssemblyVersion>2023.426.0</AssemblyVersion>
<AssemblyVersion>2023.428.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />
Expand Down
13 changes: 9 additions & 4 deletions VRCOSC.Game/ChatBox/ChatBoxManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public bool SendEnabled
get => sendEnabled;
set
{
if (sendEnabled && !value) clearChatBox();
if (sendEnabled && !value) Clear();
sendEnabled = value;
}
}
Expand Down Expand Up @@ -65,6 +65,7 @@ public bool SendEnabled
private DateTimeOffset nextValidTime;
private bool isClear;
private bool isLoaded;
private string lastText = string.Empty;

public void Load(Storage storage, GameManager gameManager, NotificationContainer notification)
{
Expand Down Expand Up @@ -111,7 +112,7 @@ private bool loadClipData()
{
clip.AssociatedModules.ToImmutableList().ForEach(moduleName =>
{
if (!StateMetadata.ContainsKey(moduleName))
if (!StateMetadata.ContainsKey(moduleName) && !EventMetadata.ContainsKey(moduleName))
{
clip.AssociatedModules.Remove(moduleName);

Expand Down Expand Up @@ -193,6 +194,7 @@ public void Initialise(VRChatOscClient oscClient, Bindable<int> sendDelay, Dicti
nextValidTime = startTime;
isClear = true;
ModuleEnabledCache = moduleEnabledCache;
lastText = string.Empty;

Clips.ForEach(clip => clip.Initialise());
}
Expand Down Expand Up @@ -270,7 +272,7 @@ private void handleClip(Clip? clip)

if (clip is null)
{
if (!isClear) clearChatBox();
if (!isClear) Clear();
return;
}

Expand All @@ -280,10 +282,13 @@ private void handleClip(Clip? clip)

private void sendText(string text)
{
if (text == lastText) return;

lastText = text;
oscClient.SendValues(VRChatOscConstants.ADDRESS_CHATBOX_INPUT, new List<object> { text, true, false });
}

private void clearChatBox()
public void Clear()
{
sendText(string.Empty);
isClear = true;
Expand Down
7 changes: 1 addition & 6 deletions VRCOSC.Game/ChatBox/Clips/Clip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ public void Update()
setCurrentEvent();
}

public void Save()
{
chatBoxManager.Save();
}

private void auditEvents()
{
chatBoxManager.TriggeredEvents.ForEach(moduleEvent =>
Expand Down Expand Up @@ -251,7 +246,7 @@ private void addStatesOfAddedModules(NotifyCollectionChangedEventArgs e)
private void addStatesOfAddedModule(string moduleName)
{
var currentStateCopy = States.Select(clipState => clipState.Copy()).ToList();
var statesToAdd = chatBoxManager.StateMetadata[moduleName];
if (!chatBoxManager.StateMetadata.TryGetValue(moduleName, out var statesToAdd)) return;

foreach (var (newStateName, newStateMetadata) in statesToAdd)
{
Expand Down
28 changes: 13 additions & 15 deletions VRCOSC.Game/ChatBox/DefaultTimeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public static IEnumerable<Clip> GenerateDefaultTimeline(ChatBoxManager chatBoxMa
yield return generateClockClip(chatBoxManager);
yield return generateHwsClip(chatBoxManager);
yield return generateWeatherClip(chatBoxManager);
yield return generateHeartrateClip(chatBoxManager);
yield return generateChatBoxTextClip(chatBoxManager);
yield return generateMediaClip(chatBoxManager);
yield return generateSpeechToTextClip(chatBoxManager);
}

private static Clip generateClockClip(ChatBoxManager chatBoxManager)
Expand Down Expand Up @@ -57,43 +57,41 @@ private static Clip generateWeatherClip(ChatBoxManager chatBoxManager)
return clip;
}

private static Clip generateHeartrateClip(ChatBoxManager chatBoxManager)
private static Clip generateChatBoxTextClip(ChatBoxManager chatBoxManager)
{
var clip = chatBoxManager.CreateClip();
clip.Name.Value = @"Heartrate";
clip.Name.Value = @"ChatBox Text";
clip.Priority.Value = 3;
clip.Start.Value = 0;
clip.End.Value = 60;
clip.AssociatedModules.Add(@"hyperatemodule");
clip.AssociatedModules.Add(@"pulsoidmodule");
clip.GetStateFor(@"hyperatemodule", @"default")!.Enabled.Value = true;
clip.GetStateFor(@"pulsoidmodule", @"default")!.Enabled.Value = true;
clip.AssociatedModules.Add(@"chatboxtextmodule");
clip.GetStateFor(@"chatboxtextmodule", @"default")!.Enabled.Value = true;

return clip;
}

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

return clip;
}

private static Clip generateMediaClip(ChatBoxManager chatBoxManager)
private static Clip generateSpeechToTextClip(ChatBoxManager chatBoxManager)
{
var clip = chatBoxManager.CreateClip();
clip.Name.Value = @"Media";
clip.Name.Value = @"Speech To Text";
clip.Priority.Value = 5;
clip.Start.Value = 0;
clip.End.Value = 60;
clip.AssociatedModules.Add(@"mediamodule");
clip.GetStateFor(@"mediamodule", @"playing")!.Enabled.Value = true;
clip.AssociatedModules.Add(@"speechtotextmodule");
clip.GetEventFor(@"speechtotextmodule", @"textgenerated")!.Enabled.Value = true;

return clip;
}
Expand Down
10 changes: 7 additions & 3 deletions VRCOSC.Game/ChatBox/Serialisation/V1/TimelineSerialiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class TimelineSerialiser : ITimelineSerialiser
{
private const string file_name = @"chatbox.json";
private readonly Storage storage;
private readonly object saveLock = new();

public TimelineSerialiser(Storage storage)
{
Expand All @@ -20,9 +21,12 @@ public TimelineSerialiser(Storage storage)

public void Serialise(ChatBoxManager chatBoxManager)
{
using var stream = storage.CreateFileSafely(file_name);
using var writer = new StreamWriter(stream);
writer.Write(JsonConvert.SerializeObject(new SerialisableTimeline(chatBoxManager)));
lock (saveLock)
{
using var stream = storage.CreateFileSafely(file_name);
using var writer = new StreamWriter(stream);
writer.Write(JsonConvert.SerializeObject(new SerialisableTimeline(chatBoxManager)));
}
}

public SerialisableTimeline? Deserialise()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ protected override void LoadComplete()

private void filterFlows()
{
if (chatBoxManager.SelectedClip.Value is null) return;

if (showRelevantStates.Value)
{
var enabledModuleNames = chatBoxManager.GameManager.ModuleManager.GetEnabledModuleNames().Where(moduleName => chatBoxManager.SelectedClip.Value!.AssociatedModules.Contains(moduleName)).ToList();
Expand Down Expand Up @@ -297,7 +299,8 @@ private void associatedModulesOnCollectionChanged(object? sender, NotifyCollecti
});

statesTitle.Alpha = stateFlow.Children.Count == 0 ? 0 : 1;
eventsTitle.Alpha = separator.Alpha = eventFlow.Children.Count == 0 ? 0 : 1;
eventsTitle.Alpha = eventFlow.Children.Count == 0 ? 0 : 1;
separator.Alpha = stateFlow.Children.Count == 0 || eventFlow.Children.Count == 0 ? 0 : 1;

filterFlows();
}
Expand Down
13 changes: 5 additions & 8 deletions VRCOSC.Game/Graphics/ChatBox/Timeline/DrawableClip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,10 @@ protected override bool OnMouseDown(MouseDownEvent e)

protected override bool OnDragStart(DragStartEvent e) => true;

protected override void OnDragEnd(DragEndEvent e) => Clip.Save();
protected override void OnDragEnd(DragEndEvent e) => chatBoxManager.Save();

protected override void OnDrag(DragEvent e)
{
base.OnDrag(e);

chatBoxManager.SelectedClip.Value = Clip;

e.Target = timelineLayer;
Expand Down Expand Up @@ -156,6 +154,9 @@ private void updateSizeAndPosition()

private partial class ResizeDetector : Container
{
[Resolved]
private ChatBoxManager chatBoxManager { get; set; } = null!;

protected readonly Clip Clip;

private Box resizeBackground = null!;
Expand Down Expand Up @@ -189,7 +190,7 @@ private void load()

protected override bool OnDragStart(DragStartEvent e) => true;

protected override void OnDragEnd(DragEndEvent e) => Clip.Save();
protected override void OnDragEnd(DragEndEvent e) => chatBoxManager.Save();

protected override bool OnHover(HoverEvent e)
{
Expand Down Expand Up @@ -223,8 +224,6 @@ public StartResizeDetector(Clip clip)

protected override void OnDrag(DragEvent e)
{
base.OnDrag(e);

e.Target = timelineLayer;

var mousePosNormalised = e.MousePosition.X / timelineLayer.DrawWidth;
Expand Down Expand Up @@ -264,8 +263,6 @@ public EndResizeDetector(Clip clip)

protected override void OnDrag(DragEvent e)
{
base.OnDrag(e);

e.Target = timelineLayer;
var mousePosNormalised = e.MousePosition.X / timelineLayer.DrawWidth;
var newEnd = (int)Math.Ceiling(mousePosNormalised * chatBoxManager.TimelineLengthSeconds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private partial class IntegerDisplay : Container
[Resolved]
private ChatBoxManager chatBoxManager { get; set; } = null!;

private SpriteText text;
private SpriteText text = null!;

[BackgroundDependencyLoader]
private void load()
Expand Down
5 changes: 3 additions & 2 deletions VRCOSC.Game/Graphics/ChatBox/Timeline/TimelineEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private void generateGrid()
RelativeSizeAxes = Axes.Y,
RelativePositionAxes = Axes.X,
Width = grid_line_width,
X = chatBoxManager.TimelineResolution * i
X = i * chatBoxManager.TimelineResolution
});
}

Expand All @@ -190,8 +190,9 @@ private void generateGrid()
{
Colour = ThemeManager.Current[ThemeAttribute.Dark].Opacity(0.5f),
RelativeSizeAxes = Axes.X,
RelativePositionAxes = Axes.Y,
Height = grid_line_width,
Y = layerContainer.DrawHeight / 6 * i
Y = i / 6f
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osuTK;
using VRCOSC.Game.Graphics.Themes;
using VRCOSC.Game.Graphics.UI.Button;
using VRCOSC.Game.Graphics.UI.Text;
Expand Down Expand Up @@ -32,24 +31,32 @@ protected override Drawable CreateContent()
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.Relative, 0.75f),
new Dimension(GridSizeMode.Absolute, 5),
new Dimension()
},
Content = new[]
{
new[]
{
base.CreateContent(),
new TextButton
null,
new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.9f),
Text = attributeSingleWithButton.ButtonText,
Masking = true,
CornerRadius = 5,
Action = attributeSingleWithButton.ButtonAction,
BackgroundColour = ThemeManager.Current[ThemeAttribute.Action]
Padding = new MarginPadding(5),
Child = new TextButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Text = attributeSingleWithButton.ButtonText,
Masking = true,
CornerRadius = 5,
Action = attributeSingleWithButton.ButtonAction,
BackgroundColour = ThemeManager.Current[ThemeAttribute.Action]
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions VRCOSC.Game/Modules/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ private async Task stopAsync()

await OSCRouter.Disable();
ModuleManager.Stop();
ChatBoxManager.SetTyping(false);
ChatBoxManager.Clear();
ChatBoxManager.Shutdown();
Player.ResetAll();
await VRChatOscClient.Disable(OscClientFlag.Send);
Expand Down
2 changes: 1 addition & 1 deletion 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.426.0</Version>
<Version>2023.428.0</Version>
<Title>VRCOSC SDK</Title>
<Authors>VolcanicArts</Authors>
<Description>SDK for creating custom modules with VRCOSC</Description>
Expand Down
Loading

0 comments on commit 2cbebca

Please sign in to comment.