mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-17 17:48:30 +00:00
Move skin related classes into 'Internal/Skin'
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get the skin id of the skin <paramref name="file"/>
|
||||
/// Tries to get the skin id of the skin <paramref name="asset"/>
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <param name="asset"></param>
|
||||
/// <returns>Non-zero base number on success, otherwise 0</returns>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using PckStudio.Internal;
|
||||
using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Extensions
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using PckStudio.Internal;
|
||||
using PckStudio.Internal.Skin;
|
||||
using PckStudio.Properties;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ using PckStudio.Forms;
|
||||
using PckStudio.Extensions;
|
||||
using System.Linq;
|
||||
using System.Diagnostics;
|
||||
using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Popups
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Internal.FileFormats
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using OMI;
|
||||
using PckStudio.Internal;
|
||||
using System;
|
||||
using OpenTK;
|
||||
using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Internal.IO.PSM
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -19,7 +19,7 @@ using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PckStudio.Internal
|
||||
namespace PckStudio.Internal.Skin
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Skin Anim value where flags can be set
|
||||
@@ -17,7 +17,7 @@
|
||||
**/
|
||||
using System;
|
||||
|
||||
namespace PckStudio.Internal
|
||||
namespace PckStudio.Internal.Skin
|
||||
{
|
||||
/// <summary>
|
||||
/// For usage see <see cref="SkinANIM"/>
|
||||
@@ -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
|
||||
@@ -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<SkinBOX>
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace PckStudio.Internal
|
||||
namespace PckStudio.Internal.Skin
|
||||
{
|
||||
public sealed class SkinMetaData
|
||||
{
|
||||
@@ -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
|
||||
{
|
||||
@@ -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
|
||||
{
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -167,15 +167,15 @@
|
||||
<Compile Include="Internal\Json\EntityInfo.cs" />
|
||||
<Compile Include="Internal\ResourceCategory.cs" />
|
||||
<Compile Include="External\Format\BlockBenchModel.cs" />
|
||||
<Compile Include="Internal\Skin.cs" />
|
||||
<Compile Include="Internal\SkinMetaData.cs" />
|
||||
<Compile Include="Internal\SkinModelInfo.cs" />
|
||||
<Compile Include="Internal\SkinPartOffset.cs" />
|
||||
<Compile Include="Internal\Skin\Skin.cs" />
|
||||
<Compile Include="Internal\Skin\SkinMetaData.cs" />
|
||||
<Compile Include="Internal\Skin\SkinModelInfo.cs" />
|
||||
<Compile Include="Internal\Skin\SkinPartOffset.cs" />
|
||||
<Compile Include="Internal\CommitInfo.cs" />
|
||||
<Compile Include="Internal\ResourceLocation.cs" />
|
||||
<Compile Include="Internal\Serializer\ImageSerializer.cs" />
|
||||
<Compile Include="Internal\SkinAnimFlag.cs" />
|
||||
<Compile Include="Internal\SkinAnimMask.cs" />
|
||||
<Compile Include="Internal\Skin\SkinAnimFlag.cs" />
|
||||
<Compile Include="Internal\Skin\SkinAnimMask.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
@@ -275,9 +275,9 @@
|
||||
<Compile Include="Internal\Json\Tiles.cs" />
|
||||
<Compile Include="Internal\Profiler.cs" />
|
||||
<Compile Include="Internal\SettingsManager.cs" />
|
||||
<Compile Include="Internal\SkinBOX.cs" />
|
||||
<Compile Include="Internal\Skin\SkinBOX.cs" />
|
||||
<Compile Include="Extensions\ImageExtensions.cs" />
|
||||
<Compile Include="Internal\SkinANIM.cs" />
|
||||
<Compile Include="Internal\Skin\SkinANIM.cs" />
|
||||
<Compile Include="Forms\Features\CemuPanel.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -19,6 +19,7 @@ using System;
|
||||
using OpenTK;
|
||||
using PckStudio.Extensions;
|
||||
using PckStudio.Internal;
|
||||
using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using PckStudio.Extensions;
|
||||
using PckStudio.Internal;
|
||||
using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ using System.Linq;
|
||||
using OpenTK;
|
||||
using PckStudio.Extensions;
|
||||
using PckStudio.Internal;
|
||||
using PckStudio.Internal.Skin;
|
||||
|
||||
namespace PckStudio.Rendering
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user