From 695375d93c674f6cf9b544ce66618797ba2f2845 Mon Sep 17 00:00:00 2001 From: RisaDev <151885272+RisaDev@users.noreply.github.com> Date: Sun, 4 Feb 2024 22:26:40 +0300 Subject: [PATCH] v2/v3 clipboard support --- .../Data/Version2/V2BoneEditsContainer.cs | 16 ++++ .../Data/Version2/Version2Profile.cs | 14 +++ .../Helpers/V2ProfileToV3Converter.cs | 38 ++++++++ CustomizePlus/CustomizePlus.csproj | 3 - .../Templates/TemplateFileSystemSelector.cs | 90 ++++++++++++++----- CustomizePlus/UI/Windows/PopupSystem.cs | 2 + 6 files changed, 139 insertions(+), 24 deletions(-) create mode 100644 CustomizePlus/Configuration/Data/Version2/V2BoneEditsContainer.cs create mode 100644 CustomizePlus/Configuration/Data/Version2/Version2Profile.cs create mode 100644 CustomizePlus/Configuration/Helpers/V2ProfileToV3Converter.cs diff --git a/CustomizePlus/Configuration/Data/Version2/V2BoneEditsContainer.cs b/CustomizePlus/Configuration/Data/Version2/V2BoneEditsContainer.cs new file mode 100644 index 0000000..5748ed4 --- /dev/null +++ b/CustomizePlus/Configuration/Data/Version2/V2BoneEditsContainer.cs @@ -0,0 +1,16 @@ +using System; +using System.Numerics; + +namespace CustomizePlus.Configuration.Data.Version2; + +[Serializable] +public struct V2BoneEditsContainer +{ + public Vector3 Position { get; set; } = Vector3.Zero; + public Vector3 Rotation { get; set; } = Vector3.Zero; + public Vector3 Scale { get; set; } = Vector3.One; + + public V2BoneEditsContainer() + { + } +} diff --git a/CustomizePlus/Configuration/Data/Version2/Version2Profile.cs b/CustomizePlus/Configuration/Data/Version2/Version2Profile.cs new file mode 100644 index 0000000..71ca3ae --- /dev/null +++ b/CustomizePlus/Configuration/Data/Version2/Version2Profile.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; + +namespace CustomizePlus.Configuration.Data.Version2; + +[Serializable] +public class Version2Profile +{ + public static Dictionary BoneVisibility = new(); + public string CharacterName { get; set; } = string.Empty; + public string ScaleName { get; set; } = string.Empty; + public bool BodyScaleEnabled { get; set; } = true; + public Dictionary Bones { get; set; } = new(); +} diff --git a/CustomizePlus/Configuration/Helpers/V2ProfileToV3Converter.cs b/CustomizePlus/Configuration/Helpers/V2ProfileToV3Converter.cs new file mode 100644 index 0000000..9bdff0b --- /dev/null +++ b/CustomizePlus/Configuration/Helpers/V2ProfileToV3Converter.cs @@ -0,0 +1,38 @@ +using CustomizePlus.Configuration.Data.Version2; +using CustomizePlus.Configuration.Data.Version3; +using CustomizePlus.Core.Data; +using System.Numerics; + +namespace CustomizePlus.Configuration.Helpers; + +internal static class V2ProfileToV3Converter +{ + public static Version3Profile Convert(Version2Profile v2Profile) + { + Version3Profile newProfile = new() + { + CharacterName = v2Profile.CharacterName, + ProfileName = v2Profile.ScaleName, + Enabled = v2Profile.BodyScaleEnabled + }; + + foreach (var kvp in v2Profile.Bones) + { + var novelValues = kvp.Value.Position != Vector3.Zero + || kvp.Value.Rotation != Vector3.Zero + || kvp.Value.Scale != Vector3.One; + + if (novelValues || kvp.Key == Constants.RootBoneName) + { + newProfile.Bones[kvp.Key] = new V3BoneTransform + { + Translation = kvp.Value.Position, + Rotation = kvp.Value.Rotation, + Scaling = kvp.Value.Scale + }; + } + } + + return newProfile; + } +} diff --git a/CustomizePlus/CustomizePlus.csproj b/CustomizePlus/CustomizePlus.csproj index cda8f33..ece3318 100644 --- a/CustomizePlus/CustomizePlus.csproj +++ b/CustomizePlus/CustomizePlus.csproj @@ -25,11 +25,8 @@ - - - diff --git a/CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplateFileSystemSelector.cs b/CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplateFileSystemSelector.cs index fedc51e..aedc471 100644 --- a/CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplateFileSystemSelector.cs +++ b/CustomizePlus/UI/Windows/MainWindow/Tabs/Templates/TemplateFileSystemSelector.cs @@ -26,6 +26,11 @@ using CustomizePlus.Profiles.Data; using CustomizePlus.Templates.Events; using CustomizePlus.Profiles.Events; using CustomizePlus.Templates.Data; +using CustomizePlus.Configuration.Helpers; +using CustomizePlus.Configuration.Data.Version3; +using CustomizePlus.GameData.Data; +using static OtterGui.Classes.MessageService; +using CustomizePlus.Configuration.Data.Version2; namespace CustomizePlus.UI.Windows.MainWindow.Tabs.Templates; @@ -90,6 +95,8 @@ public class TemplateFileSystemSelector : FileSystemSelector ProfileConverter.ConvertFromConfigV0(json), - //2 => ProfileConverter.ConvertFromConfigV2(json), - //3 => - 4 => JsonConvert.DeserializeObject