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 May 31, 2023
2 parents 5f7e8fa + 605bded commit 514b870
Show file tree
Hide file tree
Showing 143 changed files with 2,490 additions and 1,527 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.516.0</FileVersion>
<FileVersion>2023.531.0</FileVersion>
<Title>VRCOSC</Title>
<Authors>VolcanicArts</Authors>
<Company>VolcanicArts</Company>
<Nullable>enable</Nullable>
<AssemblyVersion>2023.516.0</AssemblyVersion>
<AssemblyVersion>2023.531.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />
Expand Down
2 changes: 0 additions & 2 deletions VRCOSC.Desktop/VRCOSCGameDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
using VRCOSC.Desktop.Updater;
using VRCOSC.Game;
using VRCOSC.Game.Graphics.Updater;
using VRCOSC.Modules;

namespace VRCOSC.Desktop;

public partial class VRCOSCGameDesktop : VRCOSCGame
{
protected override IVRCOSCSecrets GetSecrets() => new VRCOSCModuleSecrets();
protected override VRCOSCUpdateManager CreateUpdateManager() => new SquirrelUpdateManager();
}
4 changes: 2 additions & 2 deletions VRCOSC.Game.Tests/VRCOSC.Game.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Project">
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.22621.0</TargetFramework>
Expand All @@ -10,7 +10,7 @@
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
</ItemGroup>
</Project>
14 changes: 5 additions & 9 deletions VRCOSC.Game/ChatBox/Clips/Clip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,12 @@ private string formatText(IProvidesFormat formatter)
if (!chatBoxManager.ModuleEnabledCache[clipVariable.Module]) return;
chatBoxManager.VariableValues.TryGetValue((clipVariable.Module, clipVariable.Lookup), out var variableValue);
returnText = returnText.Replace(clipVariable.DisplayableFormat, variableValue ?? string.Empty);
chatBoxManager.VariableValues.Where(pair => pair.Key.Item2.StartsWith($"{clipVariable.Lookup}_")).ForEach(pair =>
{
returnText = returnText.Replace(clipVariable.DisplayableFormatWithSuffix(pair.Key.Item2.Split('_').Last()), pair.Value);
});
});

return returnText;
Expand Down Expand Up @@ -268,8 +272,6 @@ private void removeStatesOfRemovedModules(NotifyCollectionChangedEventArgs e)

private void addStatesOfAddedModules(NotifyCollectionChangedEventArgs e)
{
var checkDefaultState = !States.Any() && e.NewItems!.Count == 1;

foreach (string moduleName in e.NewItems!)
{
var currentStateCopy = States.Select(clipState => clipState.Copy()).ToList();
Expand All @@ -287,12 +289,6 @@ private void addStatesOfAddedModules(NotifyCollectionChangedEventArgs e)
States.AddRange(localCurrentStatesCopy);
States.Add(new ClipState(newStateMetadata));
}

if (checkDefaultState)
{
var defaultState = GetStateFor(moduleName, @"default");
if (defaultState is not null) defaultState.Enabled.Value = true;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions VRCOSC.Game/ChatBox/Clips/ClipVariable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public class ClipVariableMetadata
public required string Format { get; init; }

public string DisplayableFormat => $"{variable_start_char}{Module.Replace("module", string.Empty)}.{Format}{variable_end_char}";
public string DisplayableFormatWithSuffix(string suffix) => $"{variable_start_char}{Module.Replace("module", string.Empty)}.{Format}_{suffix}{variable_end_char}";
}
9 changes: 6 additions & 3 deletions VRCOSC.Game/ChatBox/Serialisation/V1/TimelineSerialiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// See the LICENSE file in the repository root for full license text.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using osu.Framework.Platform;
using VRCOSC.Game.ChatBox.Clips;
using VRCOSC.Game.ChatBox.Serialisation.V1.Structures;
using VRCOSC.Game.Graphics.Notifications;
using VRCOSC.Game.Managers;
Expand All @@ -25,8 +27,6 @@ public TimelineSerialiser(Storage storage, NotificationContainer notification, C

protected override void ExecuteAfterDeserialisation(ChatBoxManager chatBoxManager, SerialisableTimeline data)
{
chatBoxManager.Clips.Clear();

data.Clips.ForEach(clip =>
{
clip.AssociatedModules.ToImmutableList().ForEach(moduleName =>
Expand Down Expand Up @@ -54,6 +54,8 @@ protected override void ExecuteAfterDeserialisation(ChatBoxManager chatBoxManage
});
});

var createdClips = new List<Clip>();

data.Clips.ForEach(clip =>
{
var newClip = chatBoxManager.CreateClip();
Expand Down Expand Up @@ -85,9 +87,10 @@ protected override void ExecuteAfterDeserialisation(ChatBoxManager chatBoxManage
eventData.Length.Value = clipEvent.Length;
});
chatBoxManager.Clips.Add(newClip);
createdClips.Add(newClip);
});

chatBoxManager.Clips.ReplaceItems(createdClips);
chatBoxManager.SetTimelineLength(TimeSpan.FromTicks(data.Ticks));
}
}
17 changes: 17 additions & 0 deletions VRCOSC.Game/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// See the LICENSE file in the repository root for full license text.

using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;

namespace VRCOSC.Game;
Expand Down Expand Up @@ -66,3 +69,17 @@ public static class Colour4Extensions
colour.A
);
}

public static class BindableListExtensions
{
public static void ReplaceItems<T>(this BindableList<T> source, IEnumerable<T> items) => source.ReplaceRange(0, source.Count, items);
}

public static class AssemblyExtensions
{
public static T? GetAssemblyAttribute<T>(this System.Reflection.Assembly ass) where T : Attribute
{
var attributes = ass.GetCustomAttributes(typeof(T), false);
return attributes.Length == 0 ? null : attributes.OfType<T>().SingleOrDefault();
}
}
26 changes: 26 additions & 0 deletions VRCOSC.Game/Github/GitHubProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License.
// See the LICENSE file in the repository root for full license text.

using System;
using System.Threading.Tasks;
using Octokit;

namespace VRCOSC.Game.Github;

public class GitHubProvider
{
private readonly GitHubClient client;

public GitHubProvider(string appName)
{
client = new GitHubClient(new ProductHeaderValue(appName));
}

public Task<Release> GetLatestReleaseFor(Uri repoUrl)
{
var userName = repoUrl.Segments[^2].TrimEnd(new[] { '/' });
var repoName = repoUrl.Segments[^1].TrimEnd(new[] { '/' });

return client.Repository.Release.GetLatest(userName, repoName);
}
}
6 changes: 5 additions & 1 deletion VRCOSC.Game/Graphics/About/AboutHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Platform;
using VRCOSC.Game.Config;
using VRCOSC.Game.Graphics.Screen;

namespace VRCOSC.Game.Graphics.About;

public partial class AboutHeader : BaseHeader
{
[Resolved]
private GameHost host { get; set; } = null!;

[Resolved]
private VRCOSCConfigManager configManager { get; set; } = null!;

private Bindable<string> versionBindable = null!;

protected override string Title => $"VRCOSC {versionBindable.Value}";
protected override string Title => $"{host.Name} {versionBindable.Value}";

protected override string SubTitle => "Copyright VolcanicArts 2023. See license file in repository root for more information";

Expand Down
43 changes: 32 additions & 11 deletions VRCOSC.Game/Graphics/About/AboutScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Framework.Platform;
using osuTK;
using VRCOSC.Game.Graphics.Screen;
using VRCOSC.Game.Graphics.Themes;
using VRCOSC.Game.Graphics.UI.Button;

namespace VRCOSC.Game.Graphics.About;
Expand All @@ -34,7 +35,7 @@ public sealed partial class AboutScreen : BaseScreen
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.5f, 0.9f),
Direction = FillDirection.Full,
Direction = FillDirection.Vertical,
Spacing = new Vector2(5)
}
}
Expand All @@ -45,19 +46,40 @@ private void load()
{
RelativeSizeAxes = Axes.Both;

buttonFlow.AddRange(new[]
buttonFlow.AddRange(new Drawable[]
{
new AboutButton
new FillFlowContainer
{
Icon = FontAwesome.Brands.Github,
BackgroundColour = Colour4.FromHex("272b33"),
Action = () => host.OpenUrlExternally("https://github.com/VolcanicArts/VRCOSC")
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
new AboutButton
{
Icon = FontAwesome.Brands.Github,
BackgroundColour = Colour4.FromHex("272b33"),
Action = () => host.OpenUrlExternally("https://github.com/VolcanicArts/VRCOSC")
},
new AboutButton
{
Icon = FontAwesome.Brands.Discord,
BackgroundColour = Colour4.FromHex("7289DA"),
Action = () => host.OpenUrlExternally("https://discord.gg/vj4brHyvT5")
}
}
},
new AboutButton
new TextButton
{
Icon = FontAwesome.Brands.Discord,
BackgroundColour = Colour4.FromHex("7289DA"),
Action = () => host.OpenUrlExternally("https://discord.gg/vj4brHyvT5")
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Size = new Vector2(150, 50),
BackgroundColour = ThemeManager.Current[ThemeAttribute.Action],
CornerRadius = 5,
Text = "Donate",
Action = () => host.OpenUrlExternally("https://ko-fi.com/volcanicarts")
}
});
}
Expand All @@ -81,7 +103,6 @@ private void load()
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Size = new Vector2(0.9f),
Masking = true,
CornerRadius = 10,
Icon = Icon,
BackgroundColour = BackgroundColour,
Expand Down
85 changes: 80 additions & 5 deletions VRCOSC.Game/Graphics/ChatBox/ChatBoxScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osuTK;
using VRCOSC.Game.Graphics.ChatBox.SelectedClip;
using VRCOSC.Game.Graphics.ChatBox.Timeline;
using VRCOSC.Game.Graphics.ChatBox.Timeline.Menu.Clip;
using VRCOSC.Game.Graphics.ChatBox.Timeline.Menu.Layer;
using VRCOSC.Game.Graphics.Themes;
using VRCOSC.Game.Graphics.UI.Button;
using osu.Framework.Platform;
using VRCOSC.Game.Managers;
using VRCOSC.Game.Processes;

namespace VRCOSC.Game.Graphics.ChatBox;

Expand Down Expand Up @@ -63,12 +68,33 @@ private void load()
null,
new Drawable[]
{
new TimelineLengthContainer
new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Width = 300,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.Y,
AutoSizeAxes = Axes.X,
Spacing = new Vector2(5, 0),
Direction = FillDirection.Horizontal,
Children = new Drawable[]
{
new ImportButton(),
new ExportButton()
}
},
new TimelineLengthContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Width = 300,
}
}
}
},
null,
Expand All @@ -88,4 +114,53 @@ private void load()
clipMenu
};
}

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

public ImportButton()
{
Anchor = Anchor.CentreLeft;
Origin = Anchor.CentreLeft;
Size = new Vector2(110, 30);
Text = "Import Config";
FontSize = 18;
CornerRadius = 5;
BackgroundColour = ThemeManager.Current[ThemeAttribute.Action];
BorderThickness = 2;
}

protected override void LoadComplete()
{
Action += () => WinForms.OpenFileDialog(@"chatbox.json|*.json", fileName => Schedule(() => chatBoxManager.Import(fileName)));
}
}

private partial class ExportButton : TextButton
{
[Resolved]
private GameHost host { get; set; } = null!;

[Resolved]
private Storage storage { get; set; } = null!;

public ExportButton()
{
Anchor = Anchor.CentreLeft;
Origin = Anchor.CentreLeft;
Size = new Vector2(110, 30);
Text = "Export Config";
FontSize = 18;
CornerRadius = 5;
BackgroundColour = ThemeManager.Current[ThemeAttribute.Action];
BorderThickness = 2;
}

protected override void LoadComplete()
{
Action += () => host.PresentFileExternally(storage.GetFullPath(@"chatbox.json"));
}
}
}
Loading

0 comments on commit 514b870

Please sign in to comment.