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 Jun 17, 2023
2 parents bc6f60e + bdb9b0c commit 1e22d1d
Show file tree
Hide file tree
Showing 31 changed files with 797 additions and 174 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.601.0</FileVersion>
<FileVersion>2023.617.0</FileVersion>
<Title>VRCOSC</Title>
<Authors>VolcanicArts</Authors>
<Company>VolcanicArts</Company>
<Nullable>enable</Nullable>
<AssemblyVersion>2023.601.0</AssemblyVersion>
<AssemblyVersion>2023.617.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\VRCOSC.Game\VRCOSC.Game.csproj" />
Expand Down
12 changes: 11 additions & 1 deletion VRCOSC.Game/ChatBox/Clips/Clip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public bool Evalulate()
if (currentEvent is not null) return true;

var localStates = States.Select(state => state.Copy(true)).ToList();
removeAbsentModules(localStates);
removeDisabledModules(localStates);
removeLessCompoundedStates(localStates);
removeInvalidStates(localStates);
Expand All @@ -178,6 +179,15 @@ public bool Evalulate()
return true;
}

private void removeAbsentModules(List<ClipState> localStates)
{
foreach (var clipState in localStates.ToImmutableList())
{
var stateValid = clipState.ModuleNames.All(moduleName => chatBoxManager.GameManager.ModuleManager.GetModule(moduleName) is not null);
if (!stateValid) localStates.Remove(clipState);
}
}

private void removeDisabledModules(List<ClipState> localStates)
{
foreach (var clipState in localStates.ToImmutableList())
Expand Down Expand Up @@ -250,7 +260,7 @@ private void populateAvailableVariables()
{
AvailableVariables.Clear();

foreach (var module in AssociatedModules)
foreach (var module in AssociatedModules.Where(moduleName => chatBoxManager.GameManager.ModuleManager.GetModule(moduleName) is not null))
{
AvailableVariables.AddRange(chatBoxManager.VariableMetadata[module].Values);
}
Expand Down
9 changes: 7 additions & 2 deletions VRCOSC.Game/ChatBox/Clips/ClipEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ namespace VRCOSC.Game.ChatBox.Clips;

public class ClipEvent : IProvidesFormat
{
public readonly string Module;
public readonly string Lookup;
public readonly string Name;

public string Module { get; init; } = null!;
public string Lookup { get; init; } = null!;

public Bindable<string> Format = new()
{
Default = string.Empty,
Expand All @@ -22,6 +23,10 @@ public class ClipEvent : IProvidesFormat

public bool IsDefault => Format.IsDefault && Enabled.IsDefault && Length.IsDefault;

public ClipEvent()
{
}

public ClipEvent(ClipEventMetadata metadata)
{
Module = metadata.Module;
Expand Down
4 changes: 2 additions & 2 deletions VRCOSC.Game/ChatBox/Clips/ClipState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace VRCOSC.Game.ChatBox.Clips;

public class ClipState : IProvidesFormat
{
public List<(string, string)> States { get; private init; } = null!;
public List<(string, string)> States { get; init; } = null!;

public Bindable<string> Format = new()
{
Expand Down Expand Up @@ -43,7 +43,7 @@ public ClipState Copy(bool includeData = false)
return copy;
}

private ClipState() { }
public ClipState() { }

public ClipState(ClipStateMetadata metadata)
{
Expand Down
68 changes: 33 additions & 35 deletions VRCOSC.Game/ChatBox/Serialisation/V1/TimelineSerialiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using osu.Framework.Platform;
using VRCOSC.Game.ChatBox.Clips;
Expand All @@ -27,33 +26,6 @@ public TimelineSerialiser(Storage storage, NotificationContainer notification, C

protected override void ExecuteAfterDeserialisation(ChatBoxManager chatBoxManager, SerialisableTimeline data)
{
data.Clips.ForEach(clip =>
{
clip.AssociatedModules.ToImmutableList().ForEach(moduleName =>
{
if (!chatBoxManager.StateMetadata.ContainsKey(moduleName) && !chatBoxManager.EventMetadata.ContainsKey(moduleName))
{
clip.AssociatedModules.Remove(moduleName);

clip.States.ToImmutableList().ForEach(clipState =>
{
clipState.States.RemoveAll(pair => pair.Module == moduleName);
});

clip.Events.RemoveAll(clipEvent => clipEvent.Module == moduleName);

return;
}

clip.States.ToImmutableList().ForEach(clipState =>
{
clipState.States.RemoveAll(pair => !chatBoxManager.StateMetadata[pair.Module].ContainsKey(pair.Lookup));
});

clip.Events.RemoveAll(clipEvent => !chatBoxManager.EventMetadata[clipEvent.Module].ContainsKey(clipEvent.Lookup));
});
});

var createdClips = new List<Clip>();

data.Clips.ForEach(clip =>
Expand All @@ -71,20 +43,46 @@ protected override void ExecuteAfterDeserialisation(ChatBoxManager chatBoxManage
clip.States.ForEach(clipState =>
{
var stateData = newClip.GetStateFor(clipState.States.Select(state => state.Module), clipState.States.Select(state => state.Lookup));
if (stateData is null) return;

stateData.Enabled.Value = clipState.Enabled;
stateData.Format.Value = clipState.Format;
if (stateData is not null)
{
stateData.Enabled.Value = clipState.Enabled;
stateData.Format.Value = clipState.Format;
}
else
{
// In the case that a module no longer exists (I.E, a custom module has loaded incorrectly), still load the data so it doesn't get lost
newClip.States.Add(new ClipState
{
States = clipState.States.Select(state => (state.Lookup, state.Module)).ToList(),
Enabled = { Value = clipState.Enabled },
Format = { Value = clipState.Format }
});
}
});

clip.Events.ForEach(clipEvent =>
{
var eventData = newClip.GetEventFor(clipEvent.Module, clipEvent.Lookup);
if (eventData is null) return;

eventData.Enabled.Value = clipEvent.Enabled;
eventData.Format.Value = clipEvent.Format;
eventData.Length.Value = clipEvent.Length;
if (eventData is not null)
{
eventData.Enabled.Value = clipEvent.Enabled;
eventData.Format.Value = clipEvent.Format;
eventData.Length.Value = clipEvent.Length;
}
else
{
// In the case that a module no longer exists (I.E, a custom module has loaded incorrectly), still load the data so it doesn't get lost
newClip.Events.Add(new ClipEvent
{
Lookup = clipEvent.Lookup,
Module = clipEvent.Module,
Enabled = { Value = clipEvent.Enabled },
Format = { Value = clipEvent.Format },
Length = { Value = clipEvent.Length }
});
}
});

createdClips.Add(newClip);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private void associatedModulesOnCollectionChanged(object? sender, NotifyCollecti

// TODO - Don't regenerate whole

chatBoxManager.SelectedClip.Value?.States.ForEach(clipState =>
chatBoxManager.SelectedClip.Value?.States.Where(clipState => clipState.ModuleNames.All(moduleName => chatBoxManager.GameManager.ModuleManager.GetModule(moduleName) is not null)).ForEach(clipState =>
{
DrawableState drawableState;

Expand All @@ -297,7 +297,7 @@ private void associatedModulesOnCollectionChanged(object? sender, NotifyCollecti
stateFlow.SetLayoutPosition(drawableState, clipState.States.Count);
});

chatBoxManager.SelectedClip.Value?.Events.ForEach(clipEvent =>
chatBoxManager.SelectedClip.Value?.Events.Where(clipEvent => chatBoxManager.GameManager.ModuleManager.GetModule(clipEvent.Module) is not null).ForEach(clipEvent =>
{
eventFlow.Add(new DrawableEvent(clipEvent)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace VRCOSC.Game.Graphics.ModuleAttributes.Attributes;

public abstract partial class AttributeCardList<TAttribute, TInstance> : AttributeCard<TAttribute> where TAttribute : ModuleAttributeList<TInstance>
{
private FillFlowContainer contentFlow = null!;
private FillFlowContainer listFlow = null!;

protected AttributeCardList(TAttribute attributeData)
Expand All @@ -26,7 +27,7 @@ protected AttributeCardList(TAttribute attributeData)
[BackgroundDependencyLoader]
private void load()
{
Content.Add(listFlow = new FillFlowContainer
Content.Add(contentFlow = new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Expand All @@ -36,8 +37,22 @@ private void load()
AutoSizeEasing = Easing.OutQuint,
AutoSizeDuration = 150,
LayoutEasing = Easing.OutQuint,
LayoutDuration = 150
LayoutDuration = 150,
Child = listFlow = new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Spacing = new Vector2(0, 5),
AutoSizeEasing = Easing.OutQuint,
AutoSizeDuration = 150,
LayoutEasing = Easing.OutQuint,
LayoutDuration = 150
}
});

contentFlow.SetLayoutPosition(listFlow, float.MaxValue);
}

protected override void LoadComplete()
Expand All @@ -60,7 +75,7 @@ private void attributeOnCollectionChanged(object? sender, NotifyCollectionChange

protected override void OnSetDefault()
{
listFlow.RemoveAll(d => d.GetType() == typeof(GridContainer), true);
listFlow.Clear();
AttributeData.Attribute.ForEach(OnInstanceAdd);
}

Expand All @@ -69,11 +84,17 @@ private void addInstance()
AttributeData.Attribute.Add(CreateInstance());
}

protected void AddToFlow(Drawable drawable)
protected void AddToContent(Drawable drawable, float depth)
{
contentFlow.Add(drawable);
contentFlow.SetLayoutPosition(drawable, depth);
}

protected void AddToList(Drawable drawable)
{
GridContainer gridInstance;

var position = listFlow[^1].Position;
var position = listFlow.Count > 0 ? listFlow[^1].Position : Vector2.Zero;

listFlow.Add(gridInstance = new GridContainer
{
Expand Down Expand Up @@ -114,7 +135,7 @@ protected void AddToFlow(Drawable drawable)
IconShadow = true,
Action = () =>
{
AttributeData.Attribute.RemoveAt(listFlow.IndexOf(gridInstance) - 1);
AttributeData.Attribute.RemoveAt(listFlow.IndexOf(gridInstance));
gridInstance.RemoveAndDisposeImmediately();
}
}
Expand Down Expand Up @@ -146,8 +167,8 @@ private void addAdditionIcon()
}
};

listFlow.Add(iconWrapper);
listFlow.SetLayoutPosition(iconWrapper, float.MaxValue);
contentFlow.Add(iconWrapper);
contentFlow.SetLayoutPosition(iconWrapper, float.MaxValue);
}

protected override void Dispose(bool isDisposing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public MutableKeyValuePairAttributeCardList(MutableKeyValuePairListAttribute att

protected override void OnInstanceAdd(MutableKeyValuePair instance)
{
AddToFlow(new GridContainer
AddToList(new GridContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public StringTextAttributeCardList(ModuleStringListAttribute attributeData)

protected override void OnInstanceAdd(Bindable<string> instance)
{
AddToFlow(new StringTextBox
AddToList(new StringTextBox
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Expand Down
30 changes: 0 additions & 30 deletions VRCOSC.Game/Graphics/ModuleListing/ModulesHeader.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License.
// See the LICENSE file in the repository root for full license text.

using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osuTK;
using VRCOSC.Game.Graphics.Screen;
using VRCOSC.Game.Graphics.Themes;
using VRCOSC.Game.Graphics.UI.Button;

namespace VRCOSC.Game.Graphics.ModuleListing;

public sealed partial class ModulesHeader : BaseHeader
{
[Resolved]
private ModulesScreen modulesScreen { get; set; } = null!;

protected override string Title => "Modules";
protected override string SubTitle => "Select modules and edit settings/parameters";

// protected override Drawable CreateRightShoulder() => new Container
// {
// Anchor = Anchor.Centre,
// Origin = Anchor.Centre,
// RelativeSizeAxes = Axes.Both,
// Child = new IconButton
// {
// Anchor = Anchor.Centre,
// Origin = Anchor.Centre,
// RelativeSizeAxes = Axes.Both,
// FillMode = FillMode.Fit,
// Size = new Vector2(0.8f),
// Icon = FontAwesome.Solid.Download,
// IconShadow = true,
// CornerRadius = 10,
// BackgroundColour = ThemeManager.Current[ThemeAttribute.Action],
// Action = () => modulesScreen.ShowRepoListing()
// }
// };
}
11 changes: 10 additions & 1 deletion VRCOSC.Game/Graphics/Notifications/ExceptionNotification.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
// Copyright (c) VolcanicArts. Licensed under the GPL-3.0 License.
// See the LICENSE file in the repository root for full license text.

using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Platform;
using VRCOSC.Game.Graphics.Themes;

namespace VRCOSC.Game.Graphics.Notifications;

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

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

public ExceptionNotification(string message)
{
Title = "Exception Detected";
Description = message;
Description = message + ".\nClick to open logs";
Icon = FontAwesome.Solid.ExclamationTriangle;
Colour = ThemeManager.Current[ThemeAttribute.Failure];
ClickCallback += () => host.OpenFileExternally(storage.GetStorageForDirectory("logs").GetFullPath("runtime.log"));
}
}
Loading

0 comments on commit 1e22d1d

Please sign in to comment.