Code commit
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using CustomizePlus.Configuration.Data.Version3;
|
||||
using CustomizePlus.Core.Data;
|
||||
using CustomizePlus.Profiles.Data;
|
||||
using CustomizePlus.Templates.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CustomizePlus.Configuration.Helpers;
|
||||
|
||||
internal static class V3ProfileToV4Converter
|
||||
{
|
||||
public static (Profile, Template) Convert(Version3Profile v3Profile)
|
||||
{
|
||||
var profile = new Profile
|
||||
{
|
||||
Name = $"{v3Profile.ProfileName} - {v3Profile.CharacterName}",
|
||||
CharacterName = v3Profile.CharacterName,
|
||||
CreationDate = v3Profile.CreationDate,
|
||||
ModifiedDate = DateTimeOffset.UtcNow,
|
||||
Enabled = v3Profile.Enabled,
|
||||
LimitLookupToOwnedObjects = v3Profile.OwnedOnly,
|
||||
UniqueId = Guid.NewGuid(),
|
||||
Templates = new List<Template>(1)
|
||||
};
|
||||
|
||||
var template = new Template
|
||||
{
|
||||
Name = $"{profile.Name}'s template",
|
||||
CreationDate = profile.CreationDate,
|
||||
ModifiedDate = profile.ModifiedDate,
|
||||
UniqueId = Guid.NewGuid(),
|
||||
Bones = new Dictionary<string, BoneTransform>(v3Profile.Bones.Count)
|
||||
};
|
||||
|
||||
foreach (var kvPair in v3Profile.Bones)
|
||||
template.Bones.Add(kvPair.Key,
|
||||
new BoneTransform { Translation = kvPair.Value.Translation, Rotation = kvPair.Value.Rotation, Scaling = kvPair.Value.Scaling });
|
||||
|
||||
profile.Templates.Add(template);
|
||||
|
||||
return (profile, template);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using CustomizePlus.Configuration.Data.Version3;
|
||||
using CustomizePlus.Profiles.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CustomizePlus.Configuration.Helpers;
|
||||
|
||||
internal static class V4ProfileToV3Converter
|
||||
{
|
||||
public static Version3Profile Convert(Profile v4Profile)
|
||||
{
|
||||
var profile = new Version3Profile
|
||||
{
|
||||
ProfileName = v4Profile.Name,
|
||||
CharacterName = v4Profile.CharacterName,
|
||||
CreationDate = v4Profile.CreationDate.DateTime,
|
||||
ModifiedDate = DateTime.UtcNow,
|
||||
Enabled = v4Profile.Enabled,
|
||||
OwnedOnly = v4Profile.LimitLookupToOwnedObjects,
|
||||
ConfigVersion = 3,
|
||||
Bones = new Dictionary<string, V3BoneTransform>()
|
||||
};
|
||||
|
||||
foreach (var template in v4Profile.Templates)
|
||||
{
|
||||
foreach (var kvPair in template.Bones) //not super optimal but whatever
|
||||
{
|
||||
profile.Bones[kvPair.Key] = new V3BoneTransform
|
||||
{
|
||||
Translation = kvPair.Value.Translation,
|
||||
Rotation = kvPair.Value.Rotation,
|
||||
Scaling = kvPair.Value.Scaling
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user