2022-12-17 00:06:06 +09:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.Immutable;
|
|
|
|
|
using VRC.SDK3.Avatars.ScriptableObjects;
|
|
|
|
|
|
2022-12-17 16:51:34 +09:00
|
|
|
|
namespace nadena.dev.modular_avatar.core.editor
|
|
|
|
|
{
|
2022-12-18 18:55:27 +09:00
|
|
|
|
internal static class ClonedMenuMappings
|
2022-12-17 21:23:50 +09:00
|
|
|
|
{
|
2022-12-18 19:03:13 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Map to link the cloned menu from the clone source.
|
|
|
|
|
/// If one menu is specified for multiple installers, they are replicated separately, so there is a one-to-many relationship.
|
|
|
|
|
/// </summary>
|
2022-12-18 16:44:44 +09:00
|
|
|
|
private static readonly Dictionary<VRCExpressionsMenu, ImmutableList<VRCExpressionsMenu>> ClonedMappings =
|
|
|
|
|
new Dictionary<VRCExpressionsMenu, ImmutableList<VRCExpressionsMenu>>();
|
2022-12-17 00:06:06 +09:00
|
|
|
|
|
2022-12-18 19:03:13 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Map to link the clone source from the cloned menu.
|
|
|
|
|
/// Map is the opposite of ClonedMappings.
|
|
|
|
|
/// </summary>
|
2022-12-17 16:51:34 +09:00
|
|
|
|
private static readonly Dictionary<VRCExpressionsMenu, VRCExpressionsMenu> OriginalMapping =
|
2022-12-17 00:06:06 +09:00
|
|
|
|
new Dictionary<VRCExpressionsMenu, VRCExpressionsMenu>();
|
|
|
|
|
|
2022-12-17 16:51:34 +09:00
|
|
|
|
public static void Clear()
|
|
|
|
|
{
|
2022-12-17 00:06:06 +09:00
|
|
|
|
ClonedMappings.Clear();
|
|
|
|
|
OriginalMapping.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-17 16:51:34 +09:00
|
|
|
|
public static void Add(VRCExpressionsMenu original, VRCExpressionsMenu clonedMenu)
|
|
|
|
|
{
|
2022-12-18 16:44:44 +09:00
|
|
|
|
if (!ClonedMappings.TryGetValue(original, out ImmutableList<VRCExpressionsMenu> clonedMenus))
|
2022-12-17 16:51:34 +09:00
|
|
|
|
{
|
2022-12-18 16:44:44 +09:00
|
|
|
|
clonedMenus = ImmutableList<VRCExpressionsMenu>.Empty;
|
2022-12-17 00:06:06 +09:00
|
|
|
|
}
|
|
|
|
|
ClonedMappings[original] = clonedMenus.Add(clonedMenu);
|
|
|
|
|
OriginalMapping[clonedMenu] = original;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-18 16:44:44 +09:00
|
|
|
|
public static bool TryGetClonedMenus(VRCExpressionsMenu original, out ImmutableList<VRCExpressionsMenu> clonedMenus)
|
2022-12-17 16:51:34 +09:00
|
|
|
|
{
|
2022-12-17 00:06:06 +09:00
|
|
|
|
return ClonedMappings.TryGetValue(original, out clonedMenus);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-17 16:51:34 +09:00
|
|
|
|
public static VRCExpressionsMenu GetOriginal(VRCExpressionsMenu cloned)
|
|
|
|
|
{
|
2022-12-17 00:06:06 +09:00
|
|
|
|
return OriginalMapping.TryGetValue(cloned, out VRCExpressionsMenu original) ? original : null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|