Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
poi-vrc committed Aug 24, 2023
1 parent 0256e87 commit b309bde
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* File: CabinetConfig.cs
* Project: DressingTools
* Created Date: Saturday, Aug 24th 2023, 05:08:11 pm
* Author: chocopoi ([email protected])
* -----
* Copyright (c) 2023 chocopoi
*
* This file is part of DressingTools.
*
* DressingTools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* DressingTools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DressingTools. If not, see <https://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.Globalization;
using Chocopoi.DressingTools.Lib.Serialization;
using Chocopoi.DressingTools.Lib.Wearable.Modules;
using Chocopoi.DressingTools.Lib.Wearable.Serializers;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Chocopoi.DressingTools.Lib.Wearable
{
public class CabinetConfig : VersionedObject
{
public static readonly SerializationVersion CurrentConfigVersion = new SerializationVersion(1, 0, 0);
private static readonly Dictionary<int, ISerializer> Serializers = new Dictionary<int, ISerializer>() {
{ 1, null },
};

public override SerializationVersion Version { get; set; }

public string AvatarArmatureName { get; set; }
public bool GroupDynamics { get; set; }
public bool GroupDynamicsSeparateGameObjects { get; set; }
public bool AnimationGenerationWriteDefaults { get; set; }

public CabinetConfig()
{
}

public override ISerializer GetSerializerByVersion(SerializationVersion version)
{
if (version == null)
{
return null;
}
return Serializers.ContainsKey(version.Major) ? Serializers[version.Major] : null;
}

public static CabinetConfig Deserialize(string json)
{
// TODO: perform schema check
var jObject = JObject.Parse(json);
return Deserialize(jObject);
}

public static CabinetConfig Deserialize(JObject jObject)
{
var config = new CabinetConfig();
config.DeserializeFrom(jObject);
return config;
}

public CabinetConfig Clone()
{
// a tricky and easier way to copy
return Deserialize(Serialize());
}

public override string ToString()
{
return Serialize().ToString(Formatting.None);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* File: ModuleProviderBase.cs
* Project: DressingTools
* Created Date: Saturday, Aug 24nd 2023, 15:31:11 am
* Created Date: Saturday, Aug 24th 2023, 15:31:11 am
* Author: chocopoi ([email protected])
* -----
* Copyright (c) 2023 chocopoi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* File: WearableModuleProviderBase.cs
* Project: DressingTools
* Created Date: Saturday, Aug 24nd 2023, 15:31:11 am
* Created Date: Saturday, Aug 24th 2023, 15:31:11 am
* Author: chocopoi ([email protected])
* -----
* Copyright (c) 2023 chocopoi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* File: WearableModuleProviderLocator.cs
* Project: DressingTools
* Created Date: Saturday, Aug 24nd 2023, 03:53:21 pm
* Created Date: Saturday, Aug 24th 2023, 03:53:21 pm
* Author: chocopoi ([email protected])
* -----
* Copyright (c) 2023 chocopoi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* File: IWearableConfigSerializer.cs
* File: WearableV1Serializer.cs
* Project: DressingTools
* Created Date: Saturday, Aug 22nd 2023, 16:35:11 pm
* Author: chocopoi ([email protected])
Expand All @@ -24,7 +24,7 @@

namespace Chocopoi.DressingTools.Lib.Wearable.Serializers
{
public class Version1Serializer : ISerializer
public class WearableV1Serializer : ISerializer
{
private class ModuleConverter : JsonConverter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class WearableConfig : VersionedObject
{
public static readonly SerializationVersion CurrentConfigVersion = new SerializationVersion(1, 0, 0);
private static readonly Dictionary<int, ISerializer> Serializers = new Dictionary<int, ISerializer>() {
{ 1, new Version1Serializer() },
{ 1, new WearableV1Serializer() },
};

public override SerializationVersion Version { get; set; }
Expand Down

0 comments on commit b309bde

Please sign in to comment.