mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-07-06 10:38:07 +00:00
Move PckFile processing to OMI lib
This commit is contained in:
@@ -1,171 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
public class PCKFile
|
||||
{
|
||||
public int type { get; }
|
||||
public List<FileData> Files { get; } = new List<FileData>();
|
||||
|
||||
public const string XMLVersionString = "XMLVERSION";
|
||||
|
||||
public class FileData
|
||||
{
|
||||
public enum FileType : int
|
||||
{
|
||||
SkinFile = 0, // *.png
|
||||
CapeFile = 1, // *.png
|
||||
TextureFile = 2, // *.png
|
||||
UIDataFile = 3, // *.fui ????
|
||||
/// <summary>
|
||||
/// "0" file
|
||||
/// </summary>
|
||||
InfoFile = 4,
|
||||
/// <summary>
|
||||
/// (x16|x32|x64)Info.pck
|
||||
/// </summary>
|
||||
TexturePackInfoFile = 5,
|
||||
/// <summary>
|
||||
/// languages.loc/localisation.loc
|
||||
/// </summary>
|
||||
LocalisationFile = 6,
|
||||
/// <summary>
|
||||
/// GameRules.grf
|
||||
/// </summary>
|
||||
GameRulesFile = 7,
|
||||
/// <summary>
|
||||
/// audio.pck
|
||||
/// </summary>
|
||||
AudioFile = 8,
|
||||
/// <summary>
|
||||
/// colours.col
|
||||
/// </summary>
|
||||
ColourTableFile = 9,
|
||||
/// <summary>
|
||||
/// GameRules.grh
|
||||
/// </summary>
|
||||
GameRulesHeader = 10,
|
||||
/// <summary>
|
||||
/// Skins.pck
|
||||
/// </summary>
|
||||
SkinDataFile = 11,
|
||||
/// <summary>
|
||||
/// models.bin
|
||||
/// </summary>
|
||||
ModelsFile = 12,
|
||||
/// <summary>
|
||||
/// behaviours.bin
|
||||
/// </summary>
|
||||
BehavioursFile = 13,
|
||||
/// <summary>
|
||||
/// entityMaterials.bin
|
||||
/// </summary>
|
||||
MaterialFile = 14,
|
||||
}
|
||||
|
||||
public string Filename {
|
||||
get => filename;
|
||||
set => filename = value.Replace('\\', '/');
|
||||
}
|
||||
|
||||
public FileType Filetype { get; set; }
|
||||
public byte[] Data => _data;
|
||||
public int Size => _data is null ? 0 : _data.Length;
|
||||
public PCKProperties Properties { get; } = new PCKProperties();
|
||||
|
||||
private string filename;
|
||||
private byte[] _data = new byte[0];
|
||||
|
||||
public FileData(string name, FileType type)
|
||||
{
|
||||
Filetype = type;
|
||||
Filename = name;
|
||||
}
|
||||
|
||||
public FileData(string name, FileType type, int dataSize) : this(name, type)
|
||||
{
|
||||
_data = new byte[dataSize];
|
||||
}
|
||||
|
||||
public FileData(FileData file) : this(file.Filename, file.Filetype)
|
||||
{
|
||||
Properties = file.Properties;
|
||||
SetData(file.Data);
|
||||
}
|
||||
|
||||
public void SetData(byte[] data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public PCKFile(int type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<string> GetPropertyList()
|
||||
{
|
||||
var LUT = new List<string>();
|
||||
Files.ForEach(file => file.Properties.ForEach(pair =>
|
||||
{
|
||||
if (!LUT.Contains(pair.property))
|
||||
LUT.Add(pair.property);
|
||||
})
|
||||
);
|
||||
return LUT;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates and adds new <see cref="FileData"/> object.
|
||||
/// </summary>
|
||||
/// <param name="name">Filename</param>
|
||||
/// <param name="type">Filetype</param>
|
||||
/// <returns>Added <see cref="FileData"/> object</returns>
|
||||
public FileData CreateNew(string name, FileData.FileType type)
|
||||
{
|
||||
var file = new FileData(name, type);
|
||||
Files.Add(file);
|
||||
return file;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks wether a file with <paramref name="filepath"/> and <paramref name="type"/> exists
|
||||
/// </summary>
|
||||
/// <param name="filepath">Path to the file in the pck</param>
|
||||
/// <param name="type">Type of the file <see cref="FileData.FileType"/></param>
|
||||
/// <returns>True when file exists, otherwise false </returns>
|
||||
public bool HasFile(string filepath, FileData.FileType type)
|
||||
{
|
||||
return GetFile(filepath, type) is FileData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first file that Equals <paramref name="filepath"/> and <paramref name="type"/>
|
||||
/// </summary>
|
||||
/// <param name="filepath">Path to the file in the pck</param>
|
||||
/// <param name="type">Type of the file <see cref="FileData.FileType"/></param>
|
||||
/// <returns>FileData if found, otherwise null</returns>
|
||||
public FileData GetFile(string filepath, FileData.FileType type)
|
||||
{
|
||||
return Files.FirstOrDefault(file => file.Filename.Equals(filepath) && file.Filetype.Equals(type));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a file with <paramref name="filepath"/> and <paramref name="type"/>.
|
||||
/// </summary>
|
||||
/// <param name="filepath">Path to the file in the pck</param>
|
||||
/// <param name="type">Type of the file <see cref="FileData.FileType"/></param>
|
||||
/// <param name="file">If succeeded <paramref name="file"/> will be non-null, otherwise null</param>
|
||||
/// <returns>True if succeeded, otherwise false</returns>
|
||||
public bool TryGetFile(string filepath, FileData.FileType type, out FileData file)
|
||||
{
|
||||
file = GetFile(filepath, type);
|
||||
return file is FileData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PckStudio.Classes.FileTypes
|
||||
{
|
||||
public class PCKProperties : List<(string property, string value)>
|
||||
{
|
||||
public bool Contains(string property)
|
||||
{
|
||||
return HasProperty(property);
|
||||
}
|
||||
|
||||
public bool HasProperty(string property)
|
||||
{
|
||||
return GetProperty(property) != default;
|
||||
}
|
||||
|
||||
public (string, string) GetProperty(string property)
|
||||
{
|
||||
return this.FirstOrDefault(p => p.property.Equals(property));
|
||||
}
|
||||
|
||||
public T GetPropertyValue<T>(string property, Func<string, T> func)
|
||||
{
|
||||
return func(GetPropertyValue(property));
|
||||
}
|
||||
|
||||
public string GetPropertyValue(string property)
|
||||
{
|
||||
return GetProperty(property).Item2;
|
||||
}
|
||||
|
||||
public (string, string)[] GetProperties(string property)
|
||||
{
|
||||
return FindAll(p => p.property == property).ToArray();
|
||||
}
|
||||
|
||||
public bool HasMoreThanOneOf(string property)
|
||||
{
|
||||
return GetProperties(property).Length > 1;
|
||||
}
|
||||
|
||||
public void SetProperty(string property, string value)
|
||||
{
|
||||
if (HasProperty(property))
|
||||
{
|
||||
this[IndexOf(GetProperty(property))] = (property, value);
|
||||
return;
|
||||
}
|
||||
Add((property, value));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace PckStudio.Classes.IO.PCK
|
||||
{
|
||||
internal class PCKFileReader : StreamDataReader<PCKFile>
|
||||
{
|
||||
private PCKFile _file;
|
||||
private IList<string> _propertyList;
|
||||
|
||||
public static PCKFile Read(Stream stream, bool isLittleEndian)
|
||||
{
|
||||
return new PCKFileReader(isLittleEndian).ReadFromStream(stream);
|
||||
}
|
||||
|
||||
private PCKFileReader(bool isLittleEndian) : base(isLittleEndian)
|
||||
{
|
||||
}
|
||||
|
||||
protected override PCKFile ReadFromStream(Stream stream)
|
||||
{
|
||||
int pck_type = ReadInt(stream);
|
||||
if (pck_type > 0xf0_00_00) // 03 00 00 00 == true
|
||||
throw new OverflowException(nameof(pck_type));
|
||||
else if (pck_type < 3) throw new Exception(pck_type.ToString());
|
||||
_file = new PCKFile(pck_type);
|
||||
ReadLookUpTable(stream);
|
||||
ReadFileEntries(stream);
|
||||
ReadFileContents(stream);
|
||||
return _file;
|
||||
}
|
||||
|
||||
private void ReadLookUpTable(Stream stream)
|
||||
{
|
||||
int count = ReadInt(stream);
|
||||
_propertyList = new List<string>(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
int index = ReadInt(stream);
|
||||
string value = ReadString(stream);
|
||||
_propertyList.Insert(index, value);
|
||||
}
|
||||
if (_propertyList.Contains(PCKFile.XMLVersionString))
|
||||
Console.WriteLine(ReadInt(stream)); // xml version num ??
|
||||
}
|
||||
|
||||
private void ReadFileEntries(Stream stream)
|
||||
{
|
||||
int file_entry_count = ReadInt(stream);
|
||||
for (; 0 < file_entry_count; file_entry_count--)
|
||||
{
|
||||
int file_size = ReadInt(stream);
|
||||
var file_type = (PCKFile.FileData.FileType)ReadInt(stream);
|
||||
string file_name = ReadString(stream).Replace('\\', '/');
|
||||
var entry = new PCKFile.FileData(file_name, file_type, file_size);
|
||||
_file.Files.Add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReadFileContents(Stream stream)
|
||||
{
|
||||
foreach (var file in _file.Files)
|
||||
{
|
||||
int property_count = ReadInt(stream);
|
||||
for (; 0 < property_count; property_count--)
|
||||
{
|
||||
string key = _propertyList[ReadInt(stream)];
|
||||
string value = ReadString(stream);
|
||||
file.Properties.Add((key, value));
|
||||
}
|
||||
stream.Read(file.Data, 0, file.Size);
|
||||
};
|
||||
}
|
||||
|
||||
private string ReadString(Stream stream)
|
||||
{
|
||||
int len = ReadInt(stream);
|
||||
string s = ReadString(stream, len, IsUsingLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode);
|
||||
ReadInt(stream); // padding
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace PckStudio.Classes.IO.PCK
|
||||
{
|
||||
internal class PCKFileWriter : StreamDataWriter
|
||||
{
|
||||
private PCKFile _pckfile;
|
||||
private IList<string> _propertyList;
|
||||
|
||||
public static void Write(Stream stream, PCKFile file, bool isLittleEndian, bool isSkinsPCK = false)
|
||||
{
|
||||
new PCKFileWriter(file, isLittleEndian, isSkinsPCK).WriteToStream(stream);
|
||||
}
|
||||
|
||||
private PCKFileWriter(PCKFile file, bool isLittleEndian, bool isSkinsPCK) : base(isLittleEndian)
|
||||
{
|
||||
_pckfile = file;
|
||||
_propertyList = _pckfile.GetPropertyList();
|
||||
if (!_propertyList.Contains(PCKFile.XMLVersionString) && isSkinsPCK)
|
||||
_propertyList.Insert(0, PCKFile.XMLVersionString);
|
||||
}
|
||||
|
||||
protected override void WriteToStream(Stream stream)
|
||||
{
|
||||
WriteInt(stream, _pckfile.type);
|
||||
WriteLookUpTable(stream);
|
||||
WriteFileEntries(stream);
|
||||
WriteFileContents(stream);
|
||||
}
|
||||
|
||||
private void WriteString(Stream stream, string s)
|
||||
{
|
||||
WriteInt(stream, s.Length);
|
||||
WriteString(stream, s, IsUsingLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode);
|
||||
WriteInt(stream, 0); // padding
|
||||
}
|
||||
|
||||
private void WriteLookUpTable(Stream stream)
|
||||
{
|
||||
WriteInt(stream, _propertyList.Count);
|
||||
foreach (var entry in _propertyList)
|
||||
{
|
||||
WriteInt(stream, _propertyList.IndexOf(entry));
|
||||
WriteString(stream, entry);
|
||||
};
|
||||
if (_propertyList.Contains(PCKFile.XMLVersionString))
|
||||
WriteInt(stream, 0x1337); // :^)
|
||||
}
|
||||
|
||||
private void WriteFileEntries(Stream stream)
|
||||
{
|
||||
WriteInt(stream, _pckfile.Files.Count);
|
||||
foreach (var file in _pckfile.Files)
|
||||
{
|
||||
WriteInt(stream, file.Size);
|
||||
WriteInt(stream, (int)file.Filetype);
|
||||
WriteString(stream, file.Filename);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteFileContents(Stream stream)
|
||||
{
|
||||
foreach (var file in _pckfile.Files)
|
||||
{
|
||||
WriteInt(stream, file.Properties.Count);
|
||||
foreach (var property in file.Properties)
|
||||
{
|
||||
if (!_propertyList.Contains(property.Item1))
|
||||
throw new Exception("Tag not in Look Up Table: " + property.Item1);
|
||||
WriteInt(stream, _propertyList.IndexOf(property.Item1));
|
||||
WriteString(stream, property.Item2);
|
||||
}
|
||||
WriteBytes(stream, file.Data, file.Size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,12 +17,13 @@ using PckStudio.Forms.Utilities;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Diagnostics;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class AnimationEditor : MetroForm
|
||||
{
|
||||
PCKFile.FileData animationFile;
|
||||
PckFile.FileData animationFile;
|
||||
Animation currentAnimation;
|
||||
AnimationPlayer player;
|
||||
|
||||
@@ -237,7 +238,7 @@ namespace PckStudio.Forms.Editor
|
||||
}
|
||||
}
|
||||
|
||||
public AnimationEditor(PCKFile.FileData file)
|
||||
public AnimationEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.IO.PCK;
|
||||
using PckStudio.Forms.Additional_Popups.Audio;
|
||||
using OMI.Formats.Languages;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
// Audio Editor by MattNL
|
||||
// additional work and optimization by Miku-666
|
||||
@@ -22,7 +23,7 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public string defaultType = "yes";
|
||||
PCKAudioFile audioFile = null;
|
||||
PCKFile.FileData audioPCK;
|
||||
PckFile.FileData audioPCK;
|
||||
LOCFile loc;
|
||||
bool _isLittleEndian = false;
|
||||
MainForm parent = null;
|
||||
@@ -51,7 +52,7 @@ namespace PckStudio.Forms.Editor
|
||||
return (PCKAudioFile.AudioCategory.EAudioType)Categories.IndexOf(category);
|
||||
}
|
||||
|
||||
public AudioEditor(PCKFile.FileData file, LOCFile locFile, bool isLittleEndian)
|
||||
public AudioEditor(PckFile.FileData file, LOCFile locFile, bool isLittleEndian)
|
||||
{
|
||||
InitializeComponent();
|
||||
loc = locFile;
|
||||
|
||||
@@ -6,18 +6,18 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Forms.Additional_Popups.EntityForms;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OMI.Formats.Behaviour;
|
||||
using OMI.Workers.Behaviour;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class BehaviourEditor : MetroForm
|
||||
{
|
||||
// Behaviours File Format research by Miku and MattNL
|
||||
private readonly PCKFile.FileData _file;
|
||||
private readonly PckFile.FileData _file;
|
||||
BehaviourFile behaviourFile;
|
||||
|
||||
void SetUpTree()
|
||||
@@ -56,7 +56,7 @@ namespace PckStudio.Forms.Editor
|
||||
treeView1.EndUpdate();
|
||||
}
|
||||
|
||||
public BehaviourEditor(PCKFile.FileData file)
|
||||
public BehaviourEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
|
||||
@@ -6,8 +6,8 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using OMI.Formats.Color;
|
||||
using OMI.Formats.Pck;
|
||||
using OMI.Workers.Color;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
@@ -17,14 +17,14 @@ namespace PckStudio.Forms.Editor
|
||||
ColorContainer colourfile;
|
||||
ColorContainer.Color clipboard_color;
|
||||
|
||||
private readonly PCKFile.FileData _file;
|
||||
private readonly PckFile.FileData _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(PCKFile.FileData file)
|
||||
public COLEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
|
||||
@@ -11,12 +11,13 @@ using OMI.Formats.GameRule;
|
||||
using OMI.Workers.GameRule;
|
||||
using System.Diagnostics;
|
||||
using PckStudio.Forms.Additional_Popups.Audio;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class GameRuleFileEditor : MetroFramework.Forms.MetroForm
|
||||
{
|
||||
private PCKFile.FileData _pckfile;
|
||||
private PckFile.FileData _pckfile;
|
||||
private GameRuleFile _file;
|
||||
|
||||
public GameRuleFileEditor()
|
||||
@@ -34,7 +35,7 @@ namespace PckStudio.Forms.Editor
|
||||
compressionTypeComboBox.SelectedIndex = compressionTypeComboBox.Items.IndexOf(dialog.Category);
|
||||
}
|
||||
|
||||
public GameRuleFileEditor(PCKFile.FileData file) : this()
|
||||
public GameRuleFileEditor(PckFile.FileData file) : this()
|
||||
{
|
||||
_pckfile = file;
|
||||
using (var stream = new MemoryStream(file.Data))
|
||||
|
||||
@@ -6,10 +6,10 @@ using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using PckStudio.Classes.Misc;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Forms.Additional_Popups.Loc;
|
||||
using OMI.Formats.Languages;
|
||||
using OMI.Workers.Language;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
@@ -17,9 +17,9 @@ namespace PckStudio.Forms.Editor
|
||||
{
|
||||
DataTable tbl;
|
||||
LOCFile currentLoc;
|
||||
PCKFile.FileData _file;
|
||||
PckFile.FileData _file;
|
||||
|
||||
public LOCEditor(PCKFile.FileData file)
|
||||
public LOCEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
|
||||
@@ -8,15 +8,15 @@ using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.IO.Materials;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
public partial class MaterialsEditor : MetroForm
|
||||
{
|
||||
// Behaviours File Format research by Miku and MattNL
|
||||
private readonly PCKFile.FileData _file;
|
||||
private readonly PckFile.FileData _file;
|
||||
MaterialsFile materialFile;
|
||||
|
||||
void SetUpTree()
|
||||
@@ -46,7 +46,7 @@ namespace PckStudio.Forms.Editor
|
||||
treeView1.EndUpdate();
|
||||
}
|
||||
|
||||
public MaterialsEditor(PCKFile.FileData file)
|
||||
public MaterialsEditor(PckFile.FileData file)
|
||||
{
|
||||
InitializeComponent();
|
||||
_file = file;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using OMI.Formats.Pck;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
@@ -10,9 +10,9 @@ namespace PckStudio
|
||||
{
|
||||
public partial class AdvancedOptions : MetroFramework.Forms.MetroForm
|
||||
{
|
||||
PCKFile currentPCK;
|
||||
PckFile currentPCK;
|
||||
|
||||
public AdvancedOptions(PCKFile currentPCKIn)
|
||||
public AdvancedOptions(PckFile currentPCKIn)
|
||||
{
|
||||
InitializeComponent();
|
||||
currentPCK = currentPCKIn;
|
||||
@@ -26,7 +26,7 @@ namespace PckStudio
|
||||
{
|
||||
case "All":
|
||||
{
|
||||
foreach (PCKFile.FileData file in currentPCK.Files)
|
||||
foreach (PckFile.FileData file in currentPCK.Files)
|
||||
{
|
||||
file.Properties.Add((entryTypeTextBox.Text, entryDataTextBox.Text));
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace PckStudio
|
||||
break;
|
||||
case "64x64":
|
||||
{
|
||||
foreach (PCKFile.FileData file in currentPCK.Files)
|
||||
foreach (PckFile.FileData file in currentPCK.Files)
|
||||
{
|
||||
MemoryStream png = new MemoryStream(file.Data);
|
||||
if (Path.GetExtension(file.Filename) == ".png" &&
|
||||
@@ -49,7 +49,7 @@ namespace PckStudio
|
||||
break;
|
||||
case "64x32":
|
||||
{
|
||||
foreach (PCKFile.FileData file in currentPCK.Files)
|
||||
foreach (PckFile.FileData file in currentPCK.Files)
|
||||
{
|
||||
MemoryStream png = new MemoryStream(file.Data);
|
||||
if (Path.GetExtension(file.Filename) == ".png" &&
|
||||
@@ -63,7 +63,7 @@ namespace PckStudio
|
||||
break;
|
||||
case "PNG Files":
|
||||
{
|
||||
foreach (PCKFile.FileData file in currentPCK.Files)
|
||||
foreach (PckFile.FileData file in currentPCK.Files)
|
||||
{
|
||||
MemoryStream png = new MemoryStream(file.Data);
|
||||
if (Path.GetExtension(file.Filename) == ".png")
|
||||
|
||||
@@ -3,28 +3,27 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System.Drawing.Imaging;
|
||||
using PckStudio.Classes.Utils;
|
||||
using PckStudio.Classes._3ds.Utils;
|
||||
using OMI.Formats.Languages;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio
|
||||
{
|
||||
public partial class addNewSkin : MetroFramework.Forms.MetroForm
|
||||
{
|
||||
|
||||
public PCKFile.FileData SkinFile => skin;
|
||||
public PCKFile.FileData CapeFile => cape;
|
||||
public PckFile.FileData SkinFile => skin;
|
||||
public PckFile.FileData CapeFile => cape;
|
||||
public bool HasCape = false;
|
||||
|
||||
LOCFile currentLoc;
|
||||
PCKFile.FileData skin = new PCKFile.FileData("dlcskinXYXYXYXY", PCKFile.FileData.FileType.SkinFile);
|
||||
PCKFile.FileData cape = new PCKFile.FileData("dlccapeXYXYXYXY", PCKFile.FileData.FileType.CapeFile);
|
||||
PckFile.FileData skin = new PckFile.FileData("dlcskinXYXYXYXY", PckFile.FileData.FileType.SkinFile);
|
||||
PckFile.FileData cape = new PckFile.FileData("dlccapeXYXYXYXY", PckFile.FileData.FileType.CapeFile);
|
||||
SkinANIM anim = new SkinANIM();
|
||||
|
||||
eSkinType skinType;
|
||||
PCKProperties generatedModel = new PCKProperties();
|
||||
PckFile.PCKProperties generatedModel = new PckFile.PCKProperties();
|
||||
|
||||
enum eSkinType : int
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ using Newtonsoft.Json;
|
||||
using MetroFramework.Forms;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System.Text.RegularExpressions;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio
|
||||
{
|
||||
@@ -28,7 +29,7 @@ namespace PckStudio
|
||||
right
|
||||
}
|
||||
|
||||
PCKProperties boxes;
|
||||
PckFile.PCKProperties boxes;
|
||||
|
||||
Color backgroundColor = Color.FromArgb(0xff, 0x50, 0x50, 0x50);
|
||||
|
||||
@@ -127,7 +128,7 @@ namespace PckStudio
|
||||
}
|
||||
|
||||
|
||||
public generateModel(PCKProperties skinProperties, PictureBox preview)
|
||||
public generateModel(PckFile.PCKProperties skinProperties, PictureBox preview)
|
||||
{
|
||||
InitializeComponent();
|
||||
boxes = skinProperties;
|
||||
|
||||
@@ -4,9 +4,9 @@ using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using PckStudio.Properties;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using System.Drawing.Imaging;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
@@ -19,9 +19,9 @@ namespace PckStudio.Forms.Utilities
|
||||
|
||||
public static Image[] tileImages => _tileImages ??= Resources.terrain_sheet.CreateImageList(16).Concat(Resources.items_sheet.CreateImageList(16)).ToArray();
|
||||
|
||||
public static PCKFile.FileData CreateNewAnimationFile(Image source, string tileName, bool isItem)
|
||||
public static PckFile.FileData CreateNewAnimationFile(Image source, string tileName, bool isItem)
|
||||
{
|
||||
PCKFile.FileData file = new PCKFile.FileData($"res/textures/{GetAnimationSection(isItem)}/{tileName}.png", PCKFile.FileData.FileType.TextureFile);
|
||||
PckFile.FileData file = new PckFile.FileData($"res/textures/{GetAnimationSection(isItem)}/{tileName}.png", PckFile.FileData.FileType.TextureFile);
|
||||
file.Properties.Add(("ANIM", string.Empty));
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
|
||||
@@ -4,10 +4,10 @@ using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using PckStudio.Properties;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using OMI.Formats.Behaviour;
|
||||
using OMI.Workers.Behaviour;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
@@ -18,9 +18,9 @@ namespace PckStudio.Forms.Utilities
|
||||
|
||||
public static Image[] entityImages => _entityImages ??= Resources.entities_sheet.CreateImageList(32).ToArray();
|
||||
|
||||
public static PCKFile.FileData CreateNewBehaviourFile()
|
||||
public static PckFile.FileData CreateNewBehaviourFile()
|
||||
{
|
||||
PCKFile.FileData file = new PCKFile.FileData($"behaviours.bin", PCKFile.FileData.FileType.BehavioursFile);
|
||||
PckFile.FileData file = new PckFile.FileData($"behaviours.bin", PckFile.FileData.FileType.BehavioursFile);
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using PckStudio.Properties;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.IO.Materials;
|
||||
using PckStudio.Classes.Extentions;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
@@ -16,9 +17,9 @@ namespace PckStudio.Forms.Utilities
|
||||
private static Image[] _entityImages;
|
||||
public static Image[] entityImages => _entityImages ??= Resources.entities_sheet.CreateImageList(32).ToArray();
|
||||
|
||||
public static PCKFile.FileData CreateNewMaterialsFile()
|
||||
public static PckFile.FileData CreateNewMaterialsFile()
|
||||
{
|
||||
PCKFile.FileData file = new PCKFile.FileData($"entityMaterials.bin", PCKFile.FileData.FileType.MaterialFile);
|
||||
PckFile.FileData file = new PckFile.FileData($"entityMaterials.bin", PckFile.FileData.FileType.MaterialFile);
|
||||
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
|
||||
@@ -6,12 +6,13 @@ using System.Windows.Forms;
|
||||
using MetroFramework.Forms;
|
||||
using PckStudio.Properties;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms.Utilities
|
||||
{
|
||||
public partial class TextureConverterUtility : MetroForm
|
||||
{
|
||||
public TextureConverterUtility(TreeView tv0, PCKFile pck)
|
||||
public TextureConverterUtility(TreeView tv0, PckFile pck)
|
||||
{
|
||||
InitializeComponent();
|
||||
TView = tv0;
|
||||
@@ -23,7 +24,7 @@ namespace PckStudio.Forms.Utilities
|
||||
|
||||
bool ToPC = true;
|
||||
|
||||
PCKFile Pck;
|
||||
PckFile Pck;
|
||||
|
||||
TreeView TView;
|
||||
|
||||
@@ -313,13 +314,13 @@ namespace PckStudio.Forms.Utilities
|
||||
switch (tn.Text)
|
||||
{
|
||||
case ("terrain.png"):
|
||||
Terrain = Image.FromStream(new MemoryStream(((PCKFile.FileData)(tn.Tag)).Data));
|
||||
Terrain = Image.FromStream(new MemoryStream(((PckFile.FileData)(tn.Tag)).Data));
|
||||
break;
|
||||
case ("items.png"):
|
||||
Items = Image.FromStream(new MemoryStream(((PCKFile.FileData)(tn.Tag)).Data));
|
||||
Items = Image.FromStream(new MemoryStream(((PckFile.FileData)(tn.Tag)).Data));
|
||||
break;
|
||||
case ("art"):
|
||||
painting = Image.FromStream(new MemoryStream(((PCKFile.FileData)(tn.Nodes[0].Tag)).Data));
|
||||
painting = Image.FromStream(new MemoryStream(((PckFile.FileData)(tn.Nodes[0].Tag)).Data));
|
||||
break;
|
||||
case ("mob"):
|
||||
EntityNode = tn;
|
||||
@@ -429,7 +430,7 @@ namespace PckStudio.Forms.Utilities
|
||||
string Outpath = "assets\\minecraft\\textures\\";
|
||||
|
||||
|
||||
foreach (PCKFile.FileData mf in Pck.Files)
|
||||
foreach (PckFile.FileData mf in Pck.Files)
|
||||
{
|
||||
FileInfo file = new FileInfo(Environment.CurrentDirectory + "\\Temp\\" + @"\" + mf.Filename);
|
||||
file.Directory.Create(); // If the directory already exists, this method does nothing.
|
||||
@@ -454,7 +455,7 @@ namespace PckStudio.Forms.Utilities
|
||||
string Outpath = "assets\\minecraft\\textures\\";
|
||||
|
||||
|
||||
foreach (PCKFile.FileData mf in Pck.Files)
|
||||
foreach (PckFile.FileData mf in Pck.Files)
|
||||
{
|
||||
FileInfo file = new FileInfo(Environment.CurrentDirectory + "\\Temp\\" + @"\" + mf.Filename);
|
||||
file.Directory.Create(); // If the directory already exists, this method does nothing.
|
||||
@@ -479,7 +480,7 @@ namespace PckStudio.Forms.Utilities
|
||||
string Outpath = "assets\\minecraft\\textures\\";
|
||||
|
||||
|
||||
foreach (PCKFile.FileData mf in Pck.Files)
|
||||
foreach (PckFile.FileData mf in Pck.Files)
|
||||
{
|
||||
FileInfo file = new FileInfo(Environment.CurrentDirectory + "\\Temp\\" + @"\" + mf.Filename);
|
||||
file.Directory.Create(); // If the directory already exists, this method does nothing.
|
||||
|
||||
@@ -13,6 +13,8 @@ using PckStudio.Classes.IO.PCK;
|
||||
using PckStudio.Classes.Misc;
|
||||
using OMI.Formats.Archive;
|
||||
using OMI.Workers.Archive;
|
||||
using OMI.Workers.Pck;
|
||||
using OMI.Formats.Pck;
|
||||
|
||||
namespace PckStudio.Forms
|
||||
{
|
||||
@@ -106,7 +108,7 @@ namespace PckStudio.Forms
|
||||
}
|
||||
}
|
||||
List<pckDir> pcks = new List<pckDir>();
|
||||
PCKFile currentPCK = null;
|
||||
PckFile currentPCK = null;
|
||||
|
||||
private void updateDatabase()
|
||||
{
|
||||
@@ -430,10 +432,14 @@ namespace PckStudio.Forms
|
||||
|
||||
private string GetPackID(string filename)
|
||||
{
|
||||
var fs = File.OpenRead(filename);
|
||||
currentPCK = PCKFileReader.Read(fs, false);
|
||||
fs.Close();
|
||||
return currentPCK.GetFile("0", PCKFile.FileData.FileType.InfoFile).Properties.GetProperty("PACKID").Item2;
|
||||
var reader = new PckFileReader();
|
||||
currentPCK = reader.FromFile(filename);
|
||||
if (currentPCK.TryGetFile("0", PckFile.FileData.FileType.InfoFile, out var file) &&
|
||||
file.Properties.HasProperty("PACKID"))
|
||||
{
|
||||
file.Properties.GetProperty("PACKID");
|
||||
}
|
||||
throw new KeyNotFoundException();
|
||||
}
|
||||
|
||||
private void GetARCFromConsole()
|
||||
|
||||
@@ -17,6 +17,8 @@ using PckStudio;
|
||||
using System.IO.Compression;
|
||||
using PckStudio.Classes.FileTypes;
|
||||
using PckStudio.Classes.IO.PCK;
|
||||
using OMI.Formats.Pck;
|
||||
using OMI.Workers.Pck;
|
||||
|
||||
namespace PckStudio.Forms
|
||||
{
|
||||
@@ -134,16 +136,14 @@ namespace PckStudio.Forms
|
||||
//MessageBox.Show(root);//debug thingy to make sure filepath is correct
|
||||
|
||||
//add all skins to a list
|
||||
List<PCKFile.FileData> skinsList = new List<PCKFile.FileData>();
|
||||
List<PCKFile.FileData> capesList = new List<PCKFile.FileData>();
|
||||
List<PckFile.FileData> skinsList = new List<PckFile.FileData>();
|
||||
List<PckFile.FileData> capesList = new List<PckFile.FileData>();
|
||||
|
||||
PCKFile pck = null;
|
||||
using (var stream = File.OpenRead(Program.AppData + "/PCK-Center/myPcks/" + mod + ".pck"))
|
||||
{
|
||||
pck = PCKFileReader.Read(stream, false); // sets opened pck
|
||||
}
|
||||
PCKFile currentPCK = pck; //sets opened pck
|
||||
foreach (PCKFile.FileData skin in currentPCK.Files)
|
||||
PckFile pck = null;
|
||||
|
||||
var reader = new PckFileReader();
|
||||
PckFile currentPCK = reader.FromFile(Program.AppData + "/PCK-Center/myPcks/" + mod + ".pck");
|
||||
foreach (PckFile.FileData skin in currentPCK.Files)
|
||||
{
|
||||
if (skin.Filename.Count() == 19)
|
||||
{
|
||||
@@ -177,7 +177,7 @@ namespace PckStudio.Forms
|
||||
writeSkins.WriteLine(" \"skins\": [");
|
||||
|
||||
int skinAmount = 0;
|
||||
foreach (PCKFile.FileData newSkin in skinsList)
|
||||
foreach (PckFile.FileData newSkin in skinsList)
|
||||
{
|
||||
skinAmount += 1;
|
||||
string skinName = "skinName";
|
||||
@@ -234,7 +234,7 @@ namespace PckStudio.Forms
|
||||
{
|
||||
writeSkins.WriteLine("{");
|
||||
int newSkinCount = 0;
|
||||
foreach (PCKFile.FileData newSkin in skinsList)
|
||||
foreach (PckFile.FileData newSkin in skinsList)
|
||||
{
|
||||
|
||||
newSkinCount += 1;
|
||||
@@ -1022,7 +1022,7 @@ namespace PckStudio.Forms
|
||||
}
|
||||
|
||||
//adds skin textures
|
||||
foreach (PCKFile.FileData skinTexture in skinsList)
|
||||
foreach (PckFile.FileData skinTexture in skinsList)
|
||||
{
|
||||
var ms = new MemoryStream(skinTexture.Data);
|
||||
Bitmap saveSkin = new Bitmap(Image.FromStream(ms));
|
||||
@@ -1042,7 +1042,7 @@ namespace PckStudio.Forms
|
||||
}
|
||||
|
||||
//adds cape textures
|
||||
foreach (PCKFile.FileData capeTexture in capesList)
|
||||
foreach (PckFile.FileData capeTexture in capesList)
|
||||
{
|
||||
File.WriteAllBytes(root + "/" + capeTexture.Filename, capeTexture.Data);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -192,10 +192,6 @@
|
||||
<Compile Include="Classes\Utils\ARC\ARCUtil.cs" />
|
||||
<Compile Include="Classes\Extentions\ImageExtentions.cs" />
|
||||
<Compile Include="Classes\Utils\SkinANIM.cs" />
|
||||
<Compile Include="Classes\FileTypes\PCKProperties.cs" />
|
||||
<Compile Include="Classes\FileTypes\PCKFile.cs" />
|
||||
<Compile Include="Classes\IO\PCK\PCKFileReader.cs" />
|
||||
<Compile Include="Classes\IO\PCK\PCKFileWriter.cs" />
|
||||
<Compile Include="Classes\IO\StreamDataReader.cs" />
|
||||
<Compile Include="Classes\IO\StreamDataWriter.cs" />
|
||||
<Compile Include="Classes\Models\DefaultModels\Steve64x32Model.cs" />
|
||||
|
||||
2
Vendor/OMI-Lib
vendored
2
Vendor/OMI-Lib
vendored
Submodule Vendor/OMI-Lib updated: 16280e2f0a...f94605028c
Reference in New Issue
Block a user