mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-22 01:06:35 +00:00
Update OMI and change PckFileData to PckAsset
This commit is contained in:
@@ -20,34 +20,34 @@ namespace PckStudio.Extensions
|
||||
{
|
||||
private const string MipMap = "MipMapLevel";
|
||||
|
||||
internal static Image GetTexture(this PckFileData file)
|
||||
internal static Image GetTexture(this PckAsset file)
|
||||
{
|
||||
if (file.Filetype != PckFileType.SkinFile &&
|
||||
file.Filetype != PckFileType.CapeFile &&
|
||||
file.Filetype != PckFileType.TextureFile)
|
||||
if (file.Type != PckAssetType.SkinFile &&
|
||||
file.Type != PckAssetType.CapeFile &&
|
||||
file.Type != PckAssetType.TextureFile)
|
||||
{
|
||||
throw new Exception("File is not suitable to contain image data.");
|
||||
}
|
||||
return file.GetDeserializedData(ImageDeserializer.DefaultDeserializer);
|
||||
}
|
||||
|
||||
internal static T GetDeserializedData<T>(this PckFileData file, IPckDeserializer<T> deserializer)
|
||||
internal static T GetDeserializedData<T>(this PckAsset file, IPckDeserializer<T> deserializer)
|
||||
{
|
||||
return deserializer.Deserialize(file);
|
||||
}
|
||||
|
||||
internal static T GetData<T>(this PckFileData file, IDataFormatReader<T> formatReader) where T : class
|
||||
internal static T GetData<T>(this PckAsset file, IDataFormatReader<T> formatReader) where T : class
|
||||
{
|
||||
using var ms = new MemoryStream(file.Data);
|
||||
return formatReader.FromStream(ms);
|
||||
}
|
||||
|
||||
internal static void SetSerializedData<T>(this PckFileData file, T obj, IPckSerializer<T> serializer)
|
||||
internal static void SetSerializedData<T>(this PckAsset file, T obj, IPckSerializer<T> serializer)
|
||||
{
|
||||
serializer.Serialize(obj, ref file);
|
||||
}
|
||||
|
||||
internal static void SetData(this PckFileData file, IDataFormatWriter formatWriter)
|
||||
internal static void SetData(this PckAsset file, IDataFormatWriter formatWriter)
|
||||
{
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
@@ -56,18 +56,18 @@ namespace PckStudio.Extensions
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SetTexture(this PckFileData file, Image image)
|
||||
internal static void SetTexture(this PckAsset file, Image image)
|
||||
{
|
||||
if (file.Filetype != PckFileType.SkinFile &&
|
||||
file.Filetype != PckFileType.CapeFile &&
|
||||
file.Filetype != PckFileType.TextureFile)
|
||||
if (file.Type != PckAssetType.SkinFile &&
|
||||
file.Type != PckAssetType.CapeFile &&
|
||||
file.Type != PckAssetType.TextureFile)
|
||||
{
|
||||
throw new Exception("File is not suitable to contain image data.");
|
||||
}
|
||||
file.SetSerializedData(image, ImageSerializer.DefaultSerializer);
|
||||
}
|
||||
|
||||
internal static bool IsMipmappedFile(this PckFileData file)
|
||||
internal static bool IsMipmappedFile(this PckAsset file)
|
||||
{
|
||||
// We only want to test the file name itself. ex: "terrainMipMapLevel2"
|
||||
string name = Path.GetFileNameWithoutExtension(file.Filename);
|
||||
@@ -82,7 +82,7 @@ namespace PckStudio.Extensions
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static string GetNormalPath(this PckFileData file)
|
||||
internal static string GetNormalPath(this PckAsset file)
|
||||
{
|
||||
if (!file.IsMipmappedFile())
|
||||
return file.Filename;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace PckStudio.Extensions
|
||||
{
|
||||
internal static class PckFileExtensions
|
||||
{
|
||||
internal static PckFileData CreateNewFileIf(this PckFile pck, bool condition, string filename, PckFileType filetype, IDataFormatWriter writer)
|
||||
internal static PckAsset CreateNewFileIf(this PckFile pck, bool condition, string filename, PckAssetType filetype, IDataFormatWriter writer)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
@@ -20,7 +20,7 @@ namespace PckStudio.Extensions
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static PckFileData CreateNewFile(this PckFile pck, string filename, PckFileType filetype, IDataFormatWriter writer)
|
||||
internal static PckAsset CreateNewFile(this PckFile pck, string filename, PckAssetType filetype, IDataFormatWriter writer)
|
||||
{
|
||||
var file = pck.CreateNewFile(filename, filetype);
|
||||
file.SetData(writer);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace PckStudio.Popups
|
||||
/// otherwise <see cref="string.Empty"/>
|
||||
/// </summary>
|
||||
public string Filepath => DialogResult == DialogResult.OK ? InputTextBox.Text : string.Empty;
|
||||
public PckFileType Filetype => (PckFileType)(FileTypeComboBox.SelectedIndex + (FileTypeComboBox.SelectedIndex >= 3 ? 1 : 0));
|
||||
public PckAssetType Filetype => (PckAssetType)(FileTypeComboBox.SelectedIndex + (FileTypeComboBox.SelectedIndex >= 3 ? 1 : 0));
|
||||
|
||||
public AddFilePrompt(string initialText) : this(initialText, -1)
|
||||
{ }
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public string defaultType = "yes";
|
||||
PckAudioFile audioFile = null;
|
||||
PckFileData audioPCK;
|
||||
PckAsset audioPCK;
|
||||
bool _isLittleEndian = false;
|
||||
MainForm parent = null;
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace PckStudio.Forms.Editor
|
||||
return (PckAudioFile.AudioCategory.EAudioType)Categories.IndexOf(category);
|
||||
}
|
||||
|
||||
public AudioEditor(PckFileData file, bool isLittleEndian)
|
||||
public AudioEditor(PckAsset file, bool isLittleEndian)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace PckStudio.Forms.Editor
|
||||
public partial class BehaviourEditor : MetroForm
|
||||
{
|
||||
// Behaviours File Format research by Miku and MattNL
|
||||
private readonly PckFileData _file;
|
||||
private readonly PckAsset _file;
|
||||
BehaviourFile behaviourFile;
|
||||
|
||||
private readonly List<EntityInfo> BehaviourData = Entities.BehaviourInfos;
|
||||
@@ -54,7 +54,7 @@ namespace PckStudio.Forms.Editor
|
||||
treeView1.EndUpdate();
|
||||
}
|
||||
|
||||
public BehaviourEditor(PckFileData file)
|
||||
public BehaviourEditor(PckAsset file)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@ namespace PckStudio.Forms.Editor
|
||||
ColorContainer colourfile;
|
||||
string clipboard_color = "#FFFFFF";
|
||||
|
||||
private readonly PckFileData _file;
|
||||
private readonly PckAsset _file;
|
||||
|
||||
List<TreeNode> colorCache = new List<TreeNode>();
|
||||
List<TreeNode> waterCache = new List<TreeNode>();
|
||||
List<TreeNode> underwaterCache = new List<TreeNode>();
|
||||
List<TreeNode> fogCache = new List<TreeNode>();
|
||||
|
||||
public COLEditor(PckFileData file)
|
||||
public COLEditor(PckAsset file)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
DataTable tbl;
|
||||
LOCFile currentLoc;
|
||||
PckFileData _file;
|
||||
PckAsset _file;
|
||||
|
||||
public LOCEditor(PckFileData file)
|
||||
public LOCEditor(PckAsset file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace PckStudio.Forms.Editor
|
||||
public partial class MaterialsEditor : MetroForm
|
||||
{
|
||||
// Materials File Format research by PhoenixARC
|
||||
private readonly PckFileData _file;
|
||||
private readonly PckAsset _file;
|
||||
MaterialContainer materialFile;
|
||||
|
||||
private readonly List<EntityInfo> MaterialData = Entities.BehaviourInfos;
|
||||
@@ -64,7 +64,7 @@ namespace PckStudio.Forms.Editor
|
||||
treeView1.EndUpdate();
|
||||
}
|
||||
|
||||
public MaterialsEditor(PckFileData file)
|
||||
public MaterialsEditor(PckAsset file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private bool AcquireColorTable(PckFile pckFile)
|
||||
{
|
||||
if (pckFile.TryGetFile("colours.col", PckFileType.ColourTableFile, out var colFile) &&
|
||||
if (pckFile.TryGetFile("colours.col", PckAssetType.ColourTableFile, out var colFile) &&
|
||||
colFile.Size > 0)
|
||||
{
|
||||
using var ms = new MemoryStream(colFile.Data);
|
||||
@@ -243,11 +243,11 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
if (animationButton.Enabled = _atlasType == "blocks" || _atlasType == "items")
|
||||
{
|
||||
PckFileData animationFile;
|
||||
PckAsset animationFile;
|
||||
|
||||
bool hasAnimation =
|
||||
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.png", PckFileType.TextureFile, out animationFile) ||
|
||||
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.tga", PckFileType.TextureFile, out animationFile);
|
||||
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.png", PckAssetType.TextureFile, out animationFile) ||
|
||||
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.tga", PckAssetType.TextureFile, out animationFile);
|
||||
animationButton.Text = hasAnimation ? "Edit Animation" : "Create Animation";
|
||||
|
||||
if (playAnimationsToolStripMenuItem.Checked &&
|
||||
@@ -535,7 +535,7 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
var file = _pckFile.GetOrCreate(
|
||||
$"res/textures/{_atlasType}/{_selectedTile.Tile.InternalName}.png",
|
||||
PckFileType.TextureFile
|
||||
PckAssetType.TextureFile
|
||||
);
|
||||
|
||||
var animation = file.GetDeserializedData(AnimationDeserializer.DefaultDeserializer);
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace PckStudio.Popups
|
||||
{
|
||||
public partial class AddNewSkin : MetroFramework.Forms.MetroForm
|
||||
{
|
||||
public PckFileData SkinFile => skin;
|
||||
public PckFileData CapeFile => cape;
|
||||
public PckAsset SkinFile => skin;
|
||||
public PckAsset CapeFile => cape;
|
||||
public bool HasCape => cape is not null;
|
||||
|
||||
private LOCFile currentLoc;
|
||||
private PckFileData skin = new PckFileData("dlcskinXYXYXYXY", PckFileType.SkinFile);
|
||||
private PckFileData cape;
|
||||
private PckAsset skin = new PckAsset("dlcskinXYXYXYXY", PckAssetType.SkinFile);
|
||||
private PckAsset cape;
|
||||
private SkinANIM anim = new SkinANIM();
|
||||
private Random rng = new Random();
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace PckStudio.Popups
|
||||
return;
|
||||
}
|
||||
capePictureBox.Image = Image.FromFile(ofd.FileName);
|
||||
cape ??= new PckFileData("dlccapeXYXYXYXY", PckFileType.CapeFile);
|
||||
cape ??= new PckAsset("dlccapeXYXYXYXY", PckAssetType.CapeFile);
|
||||
cape.SetData(File.ReadAllBytes(ofd.FileName));
|
||||
contextMenuCape.Items[0].Text = "Replace";
|
||||
capeLabel.Visible = false;
|
||||
|
||||
@@ -44,12 +44,12 @@ namespace PckStudio.Popups
|
||||
MessageBox.Show(this, "Please select a filetype before applying");
|
||||
}
|
||||
|
||||
private void applyBulkProperties(IReadOnlyCollection<PckFileData> files, int index)
|
||||
private void applyBulkProperties(IReadOnlyCollection<PckAsset> files, int index)
|
||||
{
|
||||
foreach (PckFileData file in files)
|
||||
foreach (PckAsset file in files)
|
||||
{
|
||||
if (file.Filetype == PckFileType.TexturePackInfoFile ||
|
||||
file.Filetype == PckFileType.SkinDataFile)
|
||||
if (file.Type == PckAssetType.TexturePackInfoFile ||
|
||||
file.Type == PckAssetType.SkinDataFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -65,15 +65,15 @@ namespace PckStudio.Popups
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1 || (Enum.IsDefined(typeof(PckFileType), index) && (int)file.Filetype == index))
|
||||
if (index == -1 || (Enum.IsDefined(typeof(PckAssetType), index) && (int)file.Type == index))
|
||||
{
|
||||
file.AddProperty(propertyKeyTextBox.Text, propertyValueTextBox.Text);
|
||||
}
|
||||
}
|
||||
|
||||
if (Enum.IsDefined(typeof(PckFileType), index))
|
||||
if (Enum.IsDefined(typeof(PckAssetType), index))
|
||||
{
|
||||
MessageBox.Show(this, $"Data added to {(PckFileType)index} entries");
|
||||
MessageBox.Show(this, $"Data added to {(PckAssetType)index} entries");
|
||||
return;
|
||||
}
|
||||
MessageBox.Show(this, "Data added to all entries");
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace PckStudio.Forms
|
||||
left,
|
||||
}
|
||||
|
||||
private PckFileData _file;
|
||||
private PckAsset _file;
|
||||
private SkinANIM _ANIM;
|
||||
|
||||
private static Color _backgroundColor = Color.FromArgb(0xff, 0x50, 0x50, 0x50);
|
||||
@@ -126,7 +126,7 @@ namespace PckStudio.Forms
|
||||
}
|
||||
}
|
||||
|
||||
public generateModel(PckFileData file)
|
||||
public generateModel(PckAsset file)
|
||||
{
|
||||
MessageBox.Show(this, "This feature is now considered deprecated and will no longer recieve updates. A better alternative is currently under development. Use at your own risk.", "Deprecated Feature", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
InitializeComponent();
|
||||
@@ -149,7 +149,7 @@ namespace PckStudio.Forms
|
||||
return sWhitespace.Replace(input, replacement);
|
||||
}
|
||||
|
||||
private void LoadData(PckFileData file)
|
||||
private void LoadData(PckAsset file)
|
||||
{
|
||||
comboParent.Enabled = file.GetMultipleProperties("BOX").All(kv => {
|
||||
var box = SkinBOX.FromString(kv.Value);
|
||||
|
||||
@@ -9,6 +9,6 @@ namespace PckStudio.Interfaces
|
||||
{
|
||||
internal interface IPckDeserializer<T>
|
||||
{
|
||||
public T Deserialize(PckFileData file);
|
||||
public T Deserialize(PckAsset file);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,6 @@ namespace PckStudio.Interfaces
|
||||
{
|
||||
internal interface IPckSerializer<T>
|
||||
{
|
||||
public void Serialize(T obj, ref PckFileData file);
|
||||
public void Serialize(T obj, ref PckAsset file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace PckStudio.Internal.Deserializer
|
||||
{
|
||||
public static readonly AnimationDeserializer DefaultDeserializer = new AnimationDeserializer();
|
||||
|
||||
public Animation Deserialize(PckFileData file)
|
||||
public Animation Deserialize(PckAsset file)
|
||||
{
|
||||
_ = file ?? throw new ArgumentNullException(nameof(file));
|
||||
if (file.Size > 0)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace PckStudio.Internal.Deserializer
|
||||
public static readonly ImageDeserializer DefaultDeserializer = new ImageDeserializer();
|
||||
private static Image EmptyImage = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
|
||||
|
||||
public Image Deserialize(PckFileData file)
|
||||
public Image Deserialize(PckAsset file)
|
||||
{
|
||||
using var stream = new MemoryStream(file.Data);
|
||||
try
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace PckStudio.Internal
|
||||
|
||||
private bool CheckForSkinAndCapeFiles(TreeNode node)
|
||||
{
|
||||
return node.TryGetTagData(out PckFileData file) &&
|
||||
(file.Filetype == PckFileType.SkinFile || file.Filetype == PckFileType.CapeFile);
|
||||
return node.TryGetTagData(out PckAsset file) &&
|
||||
(file.Type == PckAssetType.SkinFile || file.Type == PckAssetType.CapeFile);
|
||||
}
|
||||
|
||||
public int Compare(object x, object y)
|
||||
@@ -39,9 +39,9 @@ namespace PckStudio.Internal
|
||||
|
||||
private int InternalCompare(TreeNode first, TreeNode second)
|
||||
{
|
||||
if (first.IsTagOfType<PckFileData>() && !second.IsTagOfType<PckFileData>())
|
||||
if (first.IsTagOfType<PckAsset>() && !second.IsTagOfType<PckAsset>())
|
||||
return -1;
|
||||
if (!first.IsTagOfType<PckFileData>() && second.IsTagOfType<PckFileData>())
|
||||
if (!first.IsTagOfType<PckAsset>() && second.IsTagOfType<PckAsset>())
|
||||
return 1;
|
||||
|
||||
if (CheckForSkinAndCapeFiles(first))
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace PckStudio.Internal.Serializer
|
||||
{
|
||||
public static readonly AnimationSerializer DefaultSerializer = new AnimationSerializer();
|
||||
|
||||
public void Serialize(Animation animation, ref PckFileData file)
|
||||
public void Serialize(Animation animation, ref PckAsset file)
|
||||
{
|
||||
string anim = animation.BuildAnim();
|
||||
file.SetProperty("ANIM", anim);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace PckStudio.Internal.Serializer
|
||||
{
|
||||
public static readonly ImageSerializer DefaultSerializer = new ImageSerializer();
|
||||
|
||||
public void Serialize(Image obj, ref PckFileData file)
|
||||
public void Serialize(Image obj, ref PckAsset file)
|
||||
{
|
||||
var stream = new MemoryStream();
|
||||
try
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2
Vendor/OMI-Lib
vendored
2
Vendor/OMI-Lib
vendored
Submodule Vendor/OMI-Lib updated: a3505bbf31...06839b5367
Reference in New Issue
Block a user