From b187e48b716e6d77bc8d44d6e995745905b9cb9b Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sat, 22 Jun 2024 00:28:24 +0200 Subject: [PATCH] Move skin related classes into 'Internal/Skin' --- PCK-Studio/Extensions/PckAssetExtensions.cs | 52 +++++++++---------- PCK-Studio/Extensions/SkinBOXExtensions.cs | 1 + PCK-Studio/Extensions/SkinExtensions.cs | 1 + PCK-Studio/Forms/Editor/ANIMEditor.cs | 1 + PCK-Studio/Forms/Editor/BoxEditor.cs | 2 +- PCK-Studio/Forms/Editor/CustomSkinEditor.cs | 3 +- .../Forms/Skins-And-Textures/AddNewSkin.cs | 1 + PCK-Studio/Internal/FileFormats/PSMFile.cs | 1 + PCK-Studio/Internal/IO/PSM/PSMFileReader.cs | 1 + PCK-Studio/Internal/IO/PSM/PSMFileWriter.cs | 1 + PCK-Studio/Internal/ModelImporter.cs | 2 +- PCK-Studio/Internal/ModelPartSpecifics.cs | 3 +- PCK-Studio/Internal/{ => Skin}/Skin.cs | 2 +- PCK-Studio/Internal/{ => Skin}/SkinANIM.cs | 2 +- .../Internal/{ => Skin}/SkinAnimFlag.cs | 2 +- .../Internal/{ => Skin}/SkinAnimMask.cs | 2 +- PCK-Studio/Internal/{ => Skin}/SkinBOX.cs | 2 +- .../Internal/{ => Skin}/SkinMetaData.cs | 2 +- .../Internal/{ => Skin}/SkinModelInfo.cs | 2 +- .../Internal/{ => Skin}/SkinPartOffset.cs | 2 +- PCK-Studio/MainForm.cs | 1 + PCK-Studio/PckStudio.csproj | 16 +++--- PCK-Studio/Rendering/Cube.cs | 1 + PCK-Studio/Rendering/CubeGroupMesh.cs | 1 + PCK-Studio/Rendering/CubeMesh.cs | 1 + PCK-Studio/Rendering/SkinRenderer.cs | 1 + 26 files changed, 58 insertions(+), 48 deletions(-) rename PCK-Studio/Internal/{ => Skin}/Skin.cs (97%) rename PCK-Studio/Internal/{ => Skin}/SkinANIM.cs (99%) rename PCK-Studio/Internal/{ => Skin}/SkinAnimFlag.cs (98%) rename PCK-Studio/Internal/{ => Skin}/SkinAnimMask.cs (98%) rename PCK-Studio/Internal/{ => Skin}/SkinBOX.cs (99%) rename PCK-Studio/Internal/{ => Skin}/SkinMetaData.cs (82%) rename PCK-Studio/Internal/{ => Skin}/SkinModelInfo.cs (97%) rename PCK-Studio/Internal/{ => Skin}/SkinPartOffset.cs (98%) diff --git a/PCK-Studio/Extensions/PckAssetExtensions.cs b/PCK-Studio/Extensions/PckAssetExtensions.cs index 76a70386..881057c2 100644 --- a/PCK-Studio/Extensions/PckAssetExtensions.cs +++ b/PCK-Studio/Extensions/PckAssetExtensions.cs @@ -14,6 +14,7 @@ using PckStudio.Internal; using PckStudio.Interfaces; using PckStudio.Internal.Deserializer; using PckStudio.Internal.Serializer; +using PckStudio.Internal.Skin; namespace PckStudio.Extensions { @@ -33,27 +34,27 @@ namespace PckStudio.Extensions } /// - /// Tries to get the skin id of the skin + /// Tries to get the skin id of the skin /// - /// + /// /// Non-zero base number on success, otherwise 0 /// - internal static int GetSkinId(this PckAsset file) + internal static int GetSkinId(this PckAsset asset) { - if (file.Type != PckAssetType.SkinFile) + if (asset.Type != PckAssetType.SkinFile) throw new InvalidOperationException("File is not a skin file"); - string filename = Path.GetFileNameWithoutExtension(file.Filename); + string filename = Path.GetFileNameWithoutExtension(asset.Filename); if (!filename.StartsWith("dlcskin")) { - Trace.TraceWarning($"[{nameof(GetSkin)}] File does not start with 'dlcskin'"); + Trace.TraceWarning($"[{nameof(GetSkinId)}] File does not start with 'dlcskin'"); return 0; } int skinId = 0; if (!int.TryParse(filename.Substring("dlcskin".Length), out skinId)) { - Trace.TraceWarning($"[{nameof(GetSkin)}] Failed to parse Skin Id"); + Trace.TraceWarning($"[{nameof(GetSkinId)}] Failed to parse Skin Id"); } return skinId; } @@ -63,9 +64,6 @@ namespace PckStudio.Extensions if (file.Type != PckAssetType.SkinFile) throw new InvalidOperationException("File is not a skin file"); - //if (file.Properties.Contains("CAPEPATH")) - // Debug.WriteLine($"[{nameof(GetSkin)}] TODO: add cape texture/path."); - int skinId = file.GetSkinId(); string name = file.GetProperty("DISPLAYNAME"); @@ -76,49 +74,49 @@ namespace PckStudio.Extensions return new Skin(name, skinId, texture, anim, boxes, offsets); } - internal static void SetSkin(this PckAsset file, Skin skin, LOCFile localizationFile) + internal static void SetSkin(this PckAsset asset, Skin skin, LOCFile localizationFile) { - if (file.Type != PckAssetType.SkinFile) - throw new InvalidOperationException("File is not a skin file"); + if (asset.Type != PckAssetType.SkinFile) + throw new InvalidOperationException("Asset is not a skin file"); - file.SetTexture(skin.Model.Texture); + asset.SetTexture(skin.Model.Texture); string skinId = skin.MetaData.Id.ToString("d08"); // TODO: keep filepath - file.Filename = $"dlcskin{skinId}.png"; + asset.Filename = $"dlcskin{skinId}.png"; string skinLocKey = $"IDS_dlcskin{skinId}_DISPLAYNAME"; - file.SetProperty("DISPLAYNAME", skin.MetaData.Name); - file.SetProperty("DISPLAYNAMEID", skinLocKey); + asset.SetProperty("DISPLAYNAME", skin.MetaData.Name); + asset.SetProperty("DISPLAYNAMEID", skinLocKey); localizationFile.AddLocKey(skinLocKey, skin.MetaData.Name); if (!string.IsNullOrEmpty(skin.MetaData.Theme)) { - file.SetProperty("THEMENAME", skin.MetaData.Theme); - file.SetProperty("THEMENAMEID", $"IDS_dlcskin{skinId}_THEMENAME"); + asset.SetProperty("THEMENAME", skin.MetaData.Theme); + asset.SetProperty("THEMENAMEID", $"IDS_dlcskin{skinId}_THEMENAME"); localizationFile.AddLocKey($"IDS_dlcskin{skinId}_THEMENAME", skin.MetaData.Theme); } if (skin.HasCape) { - file.SetProperty("CAPEPATH", $"dlccape{skinId}.png"); + asset.SetProperty("CAPEPATH", $"dlccape{skinId}.png"); } - file.SetProperty("ANIM", skin.Model.ANIM.ToString()); - file.SetProperty("GAME_FLAGS", "0x18"); - file.SetProperty("FREE", "1"); + asset.SetProperty("ANIM", skin.Model.ANIM.ToString()); + asset.SetProperty("GAME_FLAGS", "0x18"); + asset.SetProperty("FREE", "1"); - file.RemoveProperties("BOX"); - file.RemoveProperties("OFFSET"); + asset.RemoveProperties("BOX"); + asset.RemoveProperties("OFFSET"); foreach (SkinBOX box in skin.Model.AdditionalBoxes) { - file.AddProperty(box.ToProperty()); + asset.AddProperty(box.ToProperty()); } foreach (SkinPartOffset offset in skin.Model.PartOffsets) { - file.AddProperty(offset.ToProperty()); + asset.AddProperty(offset.ToProperty()); } } diff --git a/PCK-Studio/Extensions/SkinBOXExtensions.cs b/PCK-Studio/Extensions/SkinBOXExtensions.cs index 7a403099..0fbe8ac8 100644 --- a/PCK-Studio/Extensions/SkinBOXExtensions.cs +++ b/PCK-Studio/Extensions/SkinBOXExtensions.cs @@ -7,6 +7,7 @@ using System.Numerics; using System.Text; using System.Threading.Tasks; using PckStudio.Internal; +using PckStudio.Internal.Skin; namespace PckStudio.Extensions { diff --git a/PCK-Studio/Extensions/SkinExtensions.cs b/PCK-Studio/Extensions/SkinExtensions.cs index 9c4d90f8..4f17b689 100644 --- a/PCK-Studio/Extensions/SkinExtensions.cs +++ b/PCK-Studio/Extensions/SkinExtensions.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using OMI.Formats.Languages; using OMI.Formats.Pck; using PckStudio.Internal; +using PckStudio.Internal.Skin; namespace PckStudio.Extensions { diff --git a/PCK-Studio/Forms/Editor/ANIMEditor.cs b/PCK-Studio/Forms/Editor/ANIMEditor.cs index 49f40357..8a252355 100644 --- a/PCK-Studio/Forms/Editor/ANIMEditor.cs +++ b/PCK-Studio/Forms/Editor/ANIMEditor.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using PckStudio.Internal; using PckStudio.Forms.Additional_Popups; using PckStudio.Properties; +using PckStudio.Internal.Skin; namespace PckStudio.Forms.Editor { diff --git a/PCK-Studio/Forms/Editor/BoxEditor.cs b/PCK-Studio/Forms/Editor/BoxEditor.cs index 54c393f7..3761d8d9 100644 --- a/PCK-Studio/Forms/Editor/BoxEditor.cs +++ b/PCK-Studio/Forms/Editor/BoxEditor.cs @@ -1,6 +1,6 @@ using System; using System.Windows.Forms; -using PckStudio.Internal; +using PckStudio.Internal.Skin; using PckStudio.Properties; namespace PckStudio.Forms.Editor diff --git a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs index e9033f90..b3424346 100644 --- a/PCK-Studio/Forms/Editor/CustomSkinEditor.cs +++ b/PCK-Studio/Forms/Editor/CustomSkinEditor.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Drawing; +using System.Diagnostics; using System.Windows.Forms; using System.Drawing.Imaging; using System.Drawing.Drawing2D; @@ -8,8 +9,8 @@ using MetroFramework.Forms; using PckStudio.Internal; using PckStudio.Extensions; +using PckStudio.Internal.Skin; using PckStudio.Forms.Additional_Popups; -using System.Diagnostics; namespace PckStudio.Forms.Editor { diff --git a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs index a2d79378..7f4b8f6c 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs @@ -14,6 +14,7 @@ using PckStudio.Forms; using PckStudio.Extensions; using System.Linq; using System.Diagnostics; +using PckStudio.Internal.Skin; namespace PckStudio.Popups { diff --git a/PCK-Studio/Internal/FileFormats/PSMFile.cs b/PCK-Studio/Internal/FileFormats/PSMFile.cs index 61e59432..1a0f2088 100644 --- a/PCK-Studio/Internal/FileFormats/PSMFile.cs +++ b/PCK-Studio/Internal/FileFormats/PSMFile.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using PckStudio.Internal.Skin; namespace PckStudio.Internal.FileFormats { diff --git a/PCK-Studio/Internal/IO/PSM/PSMFileReader.cs b/PCK-Studio/Internal/IO/PSM/PSMFileReader.cs index 66992ab7..ebee9bd3 100644 --- a/PCK-Studio/Internal/IO/PSM/PSMFileReader.cs +++ b/PCK-Studio/Internal/IO/PSM/PSMFileReader.cs @@ -5,6 +5,7 @@ using OMI; using OMI.Workers; using PckStudio.Internal.FileFormats; using PckStudio.Internal; +using PckStudio.Internal.Skin; namespace PckStudio.Internal.IO.PSM { diff --git a/PCK-Studio/Internal/IO/PSM/PSMFileWriter.cs b/PCK-Studio/Internal/IO/PSM/PSMFileWriter.cs index 4359c54e..05bce442 100644 --- a/PCK-Studio/Internal/IO/PSM/PSMFileWriter.cs +++ b/PCK-Studio/Internal/IO/PSM/PSMFileWriter.cs @@ -6,6 +6,7 @@ using OMI; using PckStudio.Internal; using System; using OpenTK; +using PckStudio.Internal.Skin; namespace PckStudio.Internal.IO.PSM { diff --git a/PCK-Studio/Internal/ModelImporter.cs b/PCK-Studio/Internal/ModelImporter.cs index 74595615..48ece975 100644 --- a/PCK-Studio/Internal/ModelImporter.cs +++ b/PCK-Studio/Internal/ModelImporter.cs @@ -33,6 +33,7 @@ using PckStudio.Internal.IO.PSM; using PckStudio.Internal.FileFormats; using PckStudio.Forms.Additional_Popups; using System.Drawing; +using PckStudio.Internal.Skin; namespace PckStudio.Internal { @@ -64,7 +65,6 @@ namespace PckStudio.Internal } } - // TODO: flip bottom texture of each box... internal static void Export(string fileName, SkinModelInfo model) { if (model is null) diff --git a/PCK-Studio/Internal/ModelPartSpecifics.cs b/PCK-Studio/Internal/ModelPartSpecifics.cs index 9aeb57d1..c34a8519 100644 --- a/PCK-Studio/Internal/ModelPartSpecifics.cs +++ b/PCK-Studio/Internal/ModelPartSpecifics.cs @@ -2,9 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; -using System.Text; -using System.Threading.Tasks; using PckStudio.Extensions; +using PckStudio.Internal.Skin; namespace PckStudio.Internal { diff --git a/PCK-Studio/Internal/Skin.cs b/PCK-Studio/Internal/Skin/Skin.cs similarity index 97% rename from PCK-Studio/Internal/Skin.cs rename to PCK-Studio/Internal/Skin/Skin.cs index f7c7dc3a..d123a820 100644 --- a/PCK-Studio/Internal/Skin.cs +++ b/PCK-Studio/Internal/Skin/Skin.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PckStudio.Internal +namespace PckStudio.Internal.Skin { public sealed class Skin { diff --git a/PCK-Studio/Internal/SkinANIM.cs b/PCK-Studio/Internal/Skin/SkinANIM.cs similarity index 99% rename from PCK-Studio/Internal/SkinANIM.cs rename to PCK-Studio/Internal/Skin/SkinANIM.cs index 98b9bf03..0ad59124 100644 --- a/PCK-Studio/Internal/SkinANIM.cs +++ b/PCK-Studio/Internal/Skin/SkinANIM.cs @@ -19,7 +19,7 @@ using System; using System.Collections.Specialized; using System.Text.RegularExpressions; -namespace PckStudio.Internal +namespace PckStudio.Internal.Skin { /// /// Represents a Skin Anim value where flags can be set diff --git a/PCK-Studio/Internal/SkinAnimFlag.cs b/PCK-Studio/Internal/Skin/SkinAnimFlag.cs similarity index 98% rename from PCK-Studio/Internal/SkinAnimFlag.cs rename to PCK-Studio/Internal/Skin/SkinAnimFlag.cs index 456c4c91..9a7ad7f3 100644 --- a/PCK-Studio/Internal/SkinAnimFlag.cs +++ b/PCK-Studio/Internal/Skin/SkinAnimFlag.cs @@ -17,7 +17,7 @@ **/ using System; -namespace PckStudio.Internal +namespace PckStudio.Internal.Skin { /// /// For usage see diff --git a/PCK-Studio/Internal/SkinAnimMask.cs b/PCK-Studio/Internal/Skin/SkinAnimMask.cs similarity index 98% rename from PCK-Studio/Internal/SkinAnimMask.cs rename to PCK-Studio/Internal/Skin/SkinAnimMask.cs index 05a3b097..84faa82b 100644 --- a/PCK-Studio/Internal/SkinAnimMask.cs +++ b/PCK-Studio/Internal/Skin/SkinAnimMask.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace PckStudio.Internal +namespace PckStudio.Internal.Skin { [Flags] public enum SkinAnimMask : int diff --git a/PCK-Studio/Internal/SkinBOX.cs b/PCK-Studio/Internal/Skin/SkinBOX.cs similarity index 99% rename from PCK-Studio/Internal/SkinBOX.cs rename to PCK-Studio/Internal/Skin/SkinBOX.cs index 59b78e55..0123831a 100644 --- a/PCK-Studio/Internal/SkinBOX.cs +++ b/PCK-Studio/Internal/Skin/SkinBOX.cs @@ -21,7 +21,7 @@ using System.Diagnostics; using System.Linq; using System.Numerics; -namespace PckStudio.Internal +namespace PckStudio.Internal.Skin { public class SkinBOX : ICloneable, IEquatable { diff --git a/PCK-Studio/Internal/SkinMetaData.cs b/PCK-Studio/Internal/Skin/SkinMetaData.cs similarity index 82% rename from PCK-Studio/Internal/SkinMetaData.cs rename to PCK-Studio/Internal/Skin/SkinMetaData.cs index 0c952cb6..64ec92d1 100644 --- a/PCK-Studio/Internal/SkinMetaData.cs +++ b/PCK-Studio/Internal/Skin/SkinMetaData.cs @@ -1,4 +1,4 @@ -namespace PckStudio.Internal +namespace PckStudio.Internal.Skin { public sealed class SkinMetaData { diff --git a/PCK-Studio/Internal/SkinModelInfo.cs b/PCK-Studio/Internal/Skin/SkinModelInfo.cs similarity index 97% rename from PCK-Studio/Internal/SkinModelInfo.cs rename to PCK-Studio/Internal/Skin/SkinModelInfo.cs index 8916935a..73793daa 100644 --- a/PCK-Studio/Internal/SkinModelInfo.cs +++ b/PCK-Studio/Internal/Skin/SkinModelInfo.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using OMI.Formats.Pck; -namespace PckStudio.Internal +namespace PckStudio.Internal.Skin { public sealed class SkinModelInfo { diff --git a/PCK-Studio/Internal/SkinPartOffset.cs b/PCK-Studio/Internal/Skin/SkinPartOffset.cs similarity index 98% rename from PCK-Studio/Internal/SkinPartOffset.cs rename to PCK-Studio/Internal/Skin/SkinPartOffset.cs index d747a18a..11f9e868 100644 --- a/PCK-Studio/Internal/SkinPartOffset.cs +++ b/PCK-Studio/Internal/Skin/SkinPartOffset.cs @@ -6,7 +6,7 @@ using System.Diagnostics; using System.Text.RegularExpressions; using System.Collections.Generic; -namespace PckStudio.Internal +namespace PckStudio.Internal.Skin { public readonly struct SkinPartOffset { diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 808f98c2..fb452ef9 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -35,6 +35,7 @@ using PckStudio.Internal.Json; using PckStudio.Internal.Deserializer; using PckStudio.Internal.Serializer; using OMI.Workers; +using PckStudio.Internal.Skin; namespace PckStudio { diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 31e1a151..90a21c5e 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -167,15 +167,15 @@ - - - - + + + + - - + + True True @@ -275,9 +275,9 @@ - + - + UserControl diff --git a/PCK-Studio/Rendering/Cube.cs b/PCK-Studio/Rendering/Cube.cs index 59ccdc88..a93c0a50 100644 --- a/PCK-Studio/Rendering/Cube.cs +++ b/PCK-Studio/Rendering/Cube.cs @@ -19,6 +19,7 @@ using System; using OpenTK; using PckStudio.Extensions; using PckStudio.Internal; +using PckStudio.Internal.Skin; namespace PckStudio.Rendering { diff --git a/PCK-Studio/Rendering/CubeGroupMesh.cs b/PCK-Studio/Rendering/CubeGroupMesh.cs index b14948b6..2cf475f4 100644 --- a/PCK-Studio/Rendering/CubeGroupMesh.cs +++ b/PCK-Studio/Rendering/CubeGroupMesh.cs @@ -22,6 +22,7 @@ using OpenTK; using OpenTK.Graphics.OpenGL; using PckStudio.Extensions; using PckStudio.Internal; +using PckStudio.Internal.Skin; namespace PckStudio.Rendering { diff --git a/PCK-Studio/Rendering/CubeMesh.cs b/PCK-Studio/Rendering/CubeMesh.cs index 10deb8d5..3b8e35f8 100644 --- a/PCK-Studio/Rendering/CubeMesh.cs +++ b/PCK-Studio/Rendering/CubeMesh.cs @@ -23,6 +23,7 @@ using System.Linq; using OpenTK; using PckStudio.Extensions; using PckStudio.Internal; +using PckStudio.Internal.Skin; namespace PckStudio.Rendering { diff --git a/PCK-Studio/Rendering/SkinRenderer.cs b/PCK-Studio/Rendering/SkinRenderer.cs index d62d45c0..16332a1a 100644 --- a/PCK-Studio/Rendering/SkinRenderer.cs +++ b/PCK-Studio/Rendering/SkinRenderer.cs @@ -35,6 +35,7 @@ using System.IO; using PckStudio.Rendering.Texture; using PckStudio.Rendering.Shader; using System.Linq; +using PckStudio.Internal.Skin; namespace PckStudio.Rendering {