From 99a04c25a43131104a6ca8bc74a68d12e4b2d67c Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sat, 20 Apr 2024 22:29:11 +0200 Subject: [PATCH 1/5] MainForm(Drag'n Drag) - Fix target node being null --- PCK-Studio/MainForm.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index a4010b49..d83e34d1 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -1445,6 +1445,9 @@ namespace PckStudio // Retrieve the node at the drop location. TreeNode targetNode = treeViewMain.GetNodeAt(targetPoint); + if (targetNode is null) + return; + bool isTargetPckFile = targetNode.IsTagOfType(); if (e.Data.GetData(dataFormat) is not TreeNode draggedNode) From d91f3cca52af07f75ede722b3ed89e37a1706478 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sun, 21 Apr 2024 01:05:42 +0200 Subject: [PATCH 2/5] Update OMI submodule ref to fix loc file reading issue --- Vendor/OMI-Lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vendor/OMI-Lib b/Vendor/OMI-Lib index 91878fe5..a3505bbf 160000 --- a/Vendor/OMI-Lib +++ b/Vendor/OMI-Lib @@ -1 +1 @@ -Subproject commit 91878fe55cb937bd7538685646bb2f3e15f2af82 +Subproject commit a3505bbf31e9bc6f3380b7d8df3bc7741d0355f0 From 034a3a0336594706f06de8f84e2bc42b246b79aa Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sun, 21 Apr 2024 01:20:53 +0200 Subject: [PATCH 3/5] Rename 'IPckFileSerializer' to 'IPckSerializer' To be more consistent with the name of 'IPckDeserializer' --- PCK-Studio/Extensions/PckFileDataExtensions.cs | 2 +- .../Interfaces/{IPckFileSerializer.cs => IPckSerializer.cs} | 2 +- PCK-Studio/Internal/Serializer/AnimationSerializer.cs | 2 +- PCK-Studio/Internal/Serializer/ImageSerializer.cs | 2 +- PCK-Studio/PckStudio.csproj | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename PCK-Studio/Interfaces/{IPckFileSerializer.cs => IPckSerializer.cs} (84%) diff --git a/PCK-Studio/Extensions/PckFileDataExtensions.cs b/PCK-Studio/Extensions/PckFileDataExtensions.cs index 6a691d9c..95896208 100644 --- a/PCK-Studio/Extensions/PckFileDataExtensions.cs +++ b/PCK-Studio/Extensions/PckFileDataExtensions.cs @@ -42,7 +42,7 @@ namespace PckStudio.Extensions return formatReader.FromStream(ms); } - internal static void SetSerializedData(this PckFileData file, T obj, IPckFileSerializer serializer) + internal static void SetSerializedData(this PckFileData file, T obj, IPckSerializer serializer) { serializer.Serialize(obj, ref file); } diff --git a/PCK-Studio/Interfaces/IPckFileSerializer.cs b/PCK-Studio/Interfaces/IPckSerializer.cs similarity index 84% rename from PCK-Studio/Interfaces/IPckFileSerializer.cs rename to PCK-Studio/Interfaces/IPckSerializer.cs index 1d7d2335..5ea89e0f 100644 --- a/PCK-Studio/Interfaces/IPckFileSerializer.cs +++ b/PCK-Studio/Interfaces/IPckSerializer.cs @@ -7,7 +7,7 @@ using OMI.Formats.Pck; namespace PckStudio.Interfaces { - internal interface IPckFileSerializer + internal interface IPckSerializer { public void Serialize(T obj, ref PckFileData file); } diff --git a/PCK-Studio/Internal/Serializer/AnimationSerializer.cs b/PCK-Studio/Internal/Serializer/AnimationSerializer.cs index 61756723..39febbb4 100644 --- a/PCK-Studio/Internal/Serializer/AnimationSerializer.cs +++ b/PCK-Studio/Internal/Serializer/AnimationSerializer.cs @@ -13,7 +13,7 @@ using PckStudio.Interfaces; namespace PckStudio.Internal.Serializer { - internal sealed class AnimationSerializer : IPckFileSerializer + internal sealed class AnimationSerializer : IPckSerializer { public static readonly AnimationSerializer DefaultSerializer = new AnimationSerializer(); diff --git a/PCK-Studio/Internal/Serializer/ImageSerializer.cs b/PCK-Studio/Internal/Serializer/ImageSerializer.cs index ed012ffc..5cf3f0ea 100644 --- a/PCK-Studio/Internal/Serializer/ImageSerializer.cs +++ b/PCK-Studio/Internal/Serializer/ImageSerializer.cs @@ -13,7 +13,7 @@ using PckStudio.IO.TGA; namespace PckStudio.Internal.Serializer { - internal sealed class ImageSerializer : IPckFileSerializer + internal sealed class ImageSerializer : IPckSerializer { public static readonly ImageSerializer DefaultSerializer = new ImageSerializer(); diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 44ad9d09..80d610ea 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -142,7 +142,7 @@ - + From 67ad95f62398b3bd5d6593349d5a7c617b483e94 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sun, 21 Apr 2024 13:06:28 +0200 Subject: [PATCH 4/5] Remove WiiUPanel.cs and FTPClient.cs --- PCK-Studio/Classes/Misc/FTPClient.cs | 271 -------------- PCK-Studio/Features/PckManager.cs | 2 +- PCK-Studio/Features/WiiUPanel.Designer.cs | 428 ---------------------- PCK-Studio/Features/WiiUPanel.cs | 290 --------------- PCK-Studio/Features/WiiUPanel.resx | 123 ------- PCK-Studio/PckStudio.csproj | 10 - 6 files changed, 1 insertion(+), 1123 deletions(-) delete mode 100644 PCK-Studio/Classes/Misc/FTPClient.cs delete mode 100644 PCK-Studio/Features/WiiUPanel.Designer.cs delete mode 100644 PCK-Studio/Features/WiiUPanel.cs delete mode 100644 PCK-Studio/Features/WiiUPanel.resx diff --git a/PCK-Studio/Classes/Misc/FTPClient.cs b/PCK-Studio/Classes/Misc/FTPClient.cs deleted file mode 100644 index 9752d65d..00000000 --- a/PCK-Studio/Classes/Misc/FTPClient.cs +++ /dev/null @@ -1,271 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Text; -using System.Xml.Linq; - -namespace PckStudio.Classes.Misc -{ - public class FTPClient : IDisposable - { - private Uri _host; - private ICredentials _credentials; - - private FtpWebRequest _request = null; - private FtpWebResponse _response = null; - private int _timeout = 1_000; // 1 sec - - public FTPClient(string host, string username) - : this(new Uri(host), username, string.Empty) { } - - public FTPClient(Uri host, string username) - : this(host, username, string.Empty) { } - - public FTPClient(string host, string username, string password) - : this(new Uri(host), username, password) { } - - public FTPClient(Uri uri, string username, string password) - : this(uri, new NetworkCredential(username, password)) { } - - public FTPClient(string host, ICredentials credentials) - : this(new Uri(host), credentials) { } - - public FTPClient(Uri host, ICredentials credentials) - { - if (host.Scheme != Uri.UriSchemeFtp) - { - throw new InvalidOperationException("Not a valid FTP Scheme"); - } - this._host = host; - _credentials = credentials; - } - - /// - /// Creates a new FTP Request - /// - /// - /// - /// See - /// - public static FtpWebRequest CreateRequest(Uri uri, ICredentials credentials, string method) - { - FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri); - request.Credentials = credentials; - request.Method = method; - return request; - } - - public void DownloadFile(string remoteFilepath, string localFilepath) - { - using (var fs = File.OpenWrite(localFilepath)) - { - DownloadFile(remoteFilepath, fs); - } - } - - public void DownloadFile(string remoteFilepath, Stream destination) - { - try - { - _request = CreateRequest(new Uri(_host, remoteFilepath), _credentials, WebRequestMethods.Ftp.DownloadFile); - SetRequestTimeout(); - - _response = (FtpWebResponse)_request.GetResponse(); - Stream responseStream = _response.GetResponseStream(); - - long destinationOrigin = destination.Position; - responseStream.CopyTo(destination); - destination.Position = destinationOrigin; - - responseStream.Close(); - _response.Close(); - _request = null; - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public string[] ListDirectory(string directory) - { - try - { - _request = CreateRequest(new Uri(_host, directory), _credentials, WebRequestMethods.Ftp.ListDirectory); - - SetRequestTimeout(); - - _response = (FtpWebResponse)_request.GetResponse(); - - Stream responseStream = _response.GetResponseStream(); - StreamReader streamReader = new StreamReader(responseStream); - - IList text = new List(); - - while (streamReader.Peek() != -1) - { - text.Add(streamReader.ReadLine()); - } - streamReader.Close(); - responseStream.Close(); - - _response.Close(); - _request = null; - return text.ToArray(); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - return Array.Empty(); - } - - public void UploadFile(string localFile, string remoteFile) - { - using (var fs = File.OpenRead(localFile)) - { - UploadFile(fs, remoteFile); - } - } - - public void UploadFile(Stream source, string remoteFile) - { - try - { - _request = CreateRequest(new Uri(_host, remoteFile), _credentials, WebRequestMethods.Ftp.UploadFile); - - SetRequestTimeout(); - - Stream requestStream = _request.GetRequestStream(); - source.CopyTo(requestStream); - requestStream.Close(); - - _response = (FtpWebResponse)_request.GetResponse(); - _response.Close(); - - _request = null; - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public void DeleteFile(string filename) - { - try - { - _request = CreateRequest(new Uri(_host, filename), _credentials, WebRequestMethods.Ftp.DeleteFile); - - SetRequestTimeout(); - - _response = (FtpWebResponse)_request.GetResponse(); - _response.Close(); - - _request = null; - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public void Rename(string name, string newName) - { - try - { - _request = CreateRequest(new Uri(_host, name), _credentials, WebRequestMethods.Ftp.Rename); - - SetRequestTimeout(); - - _request.RenameTo = newName; - _response = (FtpWebResponse)_request.GetResponse(); - _response.Close(); - _request = null; - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public void AppendFile(string serverFilepath, byte[] data) - { - try - { - _request = CreateRequest(new Uri(_host, serverFilepath), _credentials, WebRequestMethods.Ftp.AppendFile); - - SetRequestTimeout(); - - _request.ContentLength = data.Length; - - Stream requestStream = _request.GetRequestStream(); - requestStream.Write(data, 0, data.Length); - requestStream.Close(); - FtpWebResponse response = (FtpWebResponse)_request.GetResponse(); - - Console.WriteLine("Append status: {0}", response.StatusDescription); - - response.Close(); - _request = null; - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public void CreateDirectory(string name) - { - try - { - _request = CreateRequest(new Uri(_host, name), _credentials, WebRequestMethods.Ftp.MakeDirectory); - - SetRequestTimeout(); - - _response = (FtpWebResponse)_request.GetResponse(); - _response.Close(); - - _request = null; - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - } - } - - public long GetFileSize(string filepath) - { - _request = CreateRequest(new Uri(_host, filepath), _credentials, WebRequestMethods.Ftp.GetFileSize); - - SetRequestTimeout(); - - _response = (FtpWebResponse)_request.GetResponse(); - long contentLength = _response.ContentLength; - _response.Close(); - - _request = null; - return contentLength; - } - - public void SetTimeoutLimit(TimeSpan delay) - { - _timeout = (int)delay.TotalMilliseconds; - } - - private void SetRequestTimeout() - { - if (_request != null) - _request.Timeout = _timeout; - } - - public void Dispose() - { - _response?.Dispose(); - _request = null; - _response = null; - } - } -} \ No newline at end of file diff --git a/PCK-Studio/Features/PckManager.cs b/PCK-Studio/Features/PckManager.cs index 9c34b76f..9b5874c0 100644 --- a/PCK-Studio/Features/PckManager.cs +++ b/PCK-Studio/Features/PckManager.cs @@ -61,7 +61,7 @@ namespace PckStudio.Features currentlyShowingControl = currentlyShowingControlName switch { CemU => new CemuPanel(), - //WiiU => new WiiUPanel(), + //WiiU => throw new NotImplementedException($"{text}-Panel is currently not implemented."), //PS3 => throw new NotImplementedException($"{text}-Panel is currently not implemented."), //PSVita => throw new NotImplementedException($"{text}-Panel is currently not implemented."), //RPCS3 => throw new NotImplementedException($"{text}-Panel is currently not implemented."), diff --git a/PCK-Studio/Features/WiiUPanel.Designer.cs b/PCK-Studio/Features/WiiUPanel.Designer.cs deleted file mode 100644 index 26c792f3..00000000 --- a/PCK-Studio/Features/WiiUPanel.Designer.cs +++ /dev/null @@ -1,428 +0,0 @@ -namespace PckStudio.Features -{ - partial class WiiUPanel - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.myTablePanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.buttonServerToggle = new System.Windows.Forms.Button(); - this.IPv4TextBox = new MetroFramework.Controls.MetroTextBox(); - this.listViewPCKS = new System.Windows.Forms.ListView(); - this.contextMenuStripCaffiine = new System.Windows.Forms.ContextMenuStrip(this.components); - this.replaceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.replacePCKToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.radioButtonUSB = new System.Windows.Forms.RadioButton(); - this.TextBoxPackImage = new MetroFramework.Controls.MetroTextBox(); - this.radioButtonSystem = new System.Windows.Forms.RadioButton(); - this.buttonSelect = new System.Windows.Forms.Button(); - this.PackImageSelection = new System.Windows.Forms.Button(); - this.regionLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - this.radioButtonEur = new System.Windows.Forms.RadioButton(); - this.radioButtonUs = new System.Windows.Forms.RadioButton(); - this.radioButtonJap = new System.Windows.Forms.RadioButton(); - this.myTablePanel1.SuspendLayout(); - this.contextMenuStripCaffiine.SuspendLayout(); - this.regionLayoutPanel.SuspendLayout(); - this.SuspendLayout(); - // - // myTablePanel1 - // - this.myTablePanel1.BackColor = System.Drawing.Color.Black; - this.myTablePanel1.ColumnCount = 3; - this.myTablePanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.myTablePanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F)); - this.myTablePanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F)); - this.myTablePanel1.Controls.Add(this.buttonServerToggle, 2, 0); - this.myTablePanel1.Controls.Add(this.IPv4TextBox, 0, 0); - this.myTablePanel1.Controls.Add(this.listViewPCKS, 0, 4); - this.myTablePanel1.Controls.Add(this.radioButtonUSB); - this.myTablePanel1.Controls.Add(this.TextBoxPackImage, 0, 1); - this.myTablePanel1.Controls.Add(this.radioButtonSystem, 1, 2); - this.myTablePanel1.Controls.Add(this.buttonSelect, 0, 2); - this.myTablePanel1.Controls.Add(this.PackImageSelection, 2, 1); - this.myTablePanel1.Controls.Add(this.regionLayoutPanel, 0, 3); - this.myTablePanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.myTablePanel1.Location = new System.Drawing.Point(0, 0); - this.myTablePanel1.Margin = new System.Windows.Forms.Padding(0); - this.myTablePanel1.Name = "myTablePanel1"; - this.myTablePanel1.RowCount = 8; - this.myTablePanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.myTablePanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.myTablePanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 36F)); - this.myTablePanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 46F)); - this.myTablePanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.myTablePanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.myTablePanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.myTablePanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.myTablePanel1.Size = new System.Drawing.Size(430, 550); - this.myTablePanel1.TabIndex = 3; - // - // buttonServerToggle - // - this.buttonServerToggle.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.buttonServerToggle.BackColor = System.Drawing.Color.SpringGreen; - this.buttonServerToggle.Dock = System.Windows.Forms.DockStyle.Fill; - this.buttonServerToggle.Enabled = false; - this.buttonServerToggle.FlatAppearance.BorderSize = 0; - this.buttonServerToggle.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.buttonServerToggle.Font = new System.Drawing.Font("Segoe UI", 9.75F); - this.buttonServerToggle.ForeColor = System.Drawing.Color.White; - this.buttonServerToggle.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonServerToggle.Location = new System.Drawing.Point(289, 3); - this.buttonServerToggle.Name = "buttonServerToggle"; - this.buttonServerToggle.Size = new System.Drawing.Size(138, 27); - this.buttonServerToggle.TabIndex = 9; - this.buttonServerToggle.Text = "Start"; - this.buttonServerToggle.UseVisualStyleBackColor = false; - this.buttonServerToggle.Click += new System.EventHandler(this.buttonServerToggle_Click); - // - // IPv4TextBox - // - this.IPv4TextBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.myTablePanel1.SetColumnSpan(this.IPv4TextBox, 2); - // - // - // - this.IPv4TextBox.CustomButton.Image = null; - this.IPv4TextBox.CustomButton.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.IPv4TextBox.CustomButton.Location = new System.Drawing.Point(312, 1); - this.IPv4TextBox.CustomButton.Name = ""; - this.IPv4TextBox.CustomButton.Size = new System.Drawing.Size(25, 25); - this.IPv4TextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; - this.IPv4TextBox.CustomButton.TabIndex = 1; - this.IPv4TextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; - this.IPv4TextBox.CustomButton.UseSelectable = true; - this.IPv4TextBox.CustomButton.Visible = false; - this.IPv4TextBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.IPv4TextBox.IconRight = true; - this.IPv4TextBox.Lines = new string[0]; - this.IPv4TextBox.Location = new System.Drawing.Point(3, 3); - this.IPv4TextBox.MaxLength = 32767; - this.IPv4TextBox.Name = "IPv4TextBox"; - this.IPv4TextBox.PasswordChar = '\0'; - this.IPv4TextBox.PromptText = "Wii U IP"; - this.IPv4TextBox.ScrollBars = System.Windows.Forms.ScrollBars.None; - this.IPv4TextBox.SelectedText = ""; - this.IPv4TextBox.SelectionLength = 0; - this.IPv4TextBox.SelectionStart = 0; - this.IPv4TextBox.ShortcutsEnabled = true; - this.IPv4TextBox.Size = new System.Drawing.Size(280, 27); - this.IPv4TextBox.Style = MetroFramework.MetroColorStyle.Blue; - this.IPv4TextBox.TabIndex = 10; - this.IPv4TextBox.Theme = MetroFramework.MetroThemeStyle.Dark; - this.IPv4TextBox.UseSelectable = true; - this.IPv4TextBox.WaterMark = "Wii U IP"; - this.IPv4TextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); - this.IPv4TextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); - // - // listViewPCKS - // - this.listViewPCKS.Activation = System.Windows.Forms.ItemActivation.TwoClick; - this.myTablePanel1.SetColumnSpan(this.listViewPCKS, 3); - this.listViewPCKS.ContextMenuStrip = this.contextMenuStripCaffiine; - this.listViewPCKS.Dock = System.Windows.Forms.DockStyle.Fill; - this.listViewPCKS.Enabled = false; - this.listViewPCKS.HideSelection = false; - this.listViewPCKS.Location = new System.Drawing.Point(3, 151); - this.listViewPCKS.Name = "listViewPCKS"; - this.listViewPCKS.Size = new System.Drawing.Size(424, 396); - this.listViewPCKS.TabIndex = 3; - this.listViewPCKS.UseCompatibleStateImageBehavior = false; - this.listViewPCKS.View = System.Windows.Forms.View.Details; - this.listViewPCKS.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listViewPCKS_MouseDown); - // - // contextMenuStripCaffiine - // - this.contextMenuStripCaffiine.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.replaceToolStripMenuItem, - this.replacePCKToolStripMenuItem}); - this.contextMenuStripCaffiine.Name = "contextMenuStripCaffiine"; - this.contextMenuStripCaffiine.Size = new System.Drawing.Size(212, 48); - // - // replaceToolStripMenuItem - // - this.replaceToolStripMenuItem.Image = global::PckStudio.Properties.Resources.Replace; - this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem"; - this.replaceToolStripMenuItem.Size = new System.Drawing.Size(211, 22); - this.replaceToolStripMenuItem.Text = "Replace"; - this.replaceToolStripMenuItem.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage; - this.replaceToolStripMenuItem.Click += new System.EventHandler(this.replaceToolStripMenuItem_Click); - // - // replacePCKToolStripMenuItem - // - this.replacePCKToolStripMenuItem.Image = global::PckStudio.Properties.Resources.Replace; - this.replacePCKToolStripMenuItem.Name = "replacePCKToolStripMenuItem"; - this.replacePCKToolStripMenuItem.Size = new System.Drawing.Size(211, 22); - this.replacePCKToolStripMenuItem.Text = "Replace with external PCK"; - this.replacePCKToolStripMenuItem.Click += new System.EventHandler(this.replacePCKToolStripMenuItem_Click); - // - // radioButtonUSB - // - this.radioButtonUSB.Appearance = System.Windows.Forms.Appearance.Button; - this.radioButtonUSB.BackColor = System.Drawing.Color.Transparent; - this.radioButtonUSB.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonUSB.Dock = System.Windows.Forms.DockStyle.Fill; - this.radioButtonUSB.FlatAppearance.CheckedBackColor = System.Drawing.Color.Teal; - this.radioButtonUSB.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Aqua; - this.radioButtonUSB.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.radioButtonUSB.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.radioButtonUSB.Font = new System.Drawing.Font("Segoe UI", 12F); - this.radioButtonUSB.ForeColor = System.Drawing.Color.White; - this.radioButtonUSB.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.radioButtonUSB.Location = new System.Drawing.Point(289, 69); - this.radioButtonUSB.Name = "radioButtonUSB"; - this.radioButtonUSB.Size = new System.Drawing.Size(138, 30); - this.radioButtonUSB.TabIndex = 6; - this.radioButtonUSB.Text = "USB"; - this.radioButtonUSB.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonUSB.UseVisualStyleBackColor = false; - this.radioButtonUSB.Click += new System.EventHandler(this.radioButton_Click); - // - // TextBoxPackImage - // - this.TextBoxPackImage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.myTablePanel1.SetColumnSpan(this.TextBoxPackImage, 2); - // - // - // - this.TextBoxPackImage.CustomButton.Image = null; - this.TextBoxPackImage.CustomButton.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.TextBoxPackImage.CustomButton.Location = new System.Drawing.Point(312, 1); - this.TextBoxPackImage.CustomButton.Name = ""; - this.TextBoxPackImage.CustomButton.Size = new System.Drawing.Size(25, 25); - this.TextBoxPackImage.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; - this.TextBoxPackImage.CustomButton.TabIndex = 1; - this.TextBoxPackImage.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; - this.TextBoxPackImage.CustomButton.UseSelectable = true; - this.TextBoxPackImage.CustomButton.Visible = false; - this.TextBoxPackImage.Dock = System.Windows.Forms.DockStyle.Fill; - this.TextBoxPackImage.IconRight = true; - this.TextBoxPackImage.Lines = new string[0]; - this.TextBoxPackImage.Location = new System.Drawing.Point(3, 36); - this.TextBoxPackImage.MaxLength = 32767; - this.TextBoxPackImage.Name = "TextBoxPackImage"; - this.TextBoxPackImage.PasswordChar = '\0'; - this.TextBoxPackImage.PromptText = "Pack Image"; - this.TextBoxPackImage.ReadOnly = true; - this.TextBoxPackImage.ScrollBars = System.Windows.Forms.ScrollBars.None; - this.TextBoxPackImage.SelectedText = ""; - this.TextBoxPackImage.SelectionLength = 0; - this.TextBoxPackImage.SelectionStart = 0; - this.TextBoxPackImage.ShortcutsEnabled = true; - this.TextBoxPackImage.Size = new System.Drawing.Size(280, 27); - this.TextBoxPackImage.Style = MetroFramework.MetroColorStyle.Blue; - this.TextBoxPackImage.TabIndex = 11; - this.TextBoxPackImage.Theme = MetroFramework.MetroThemeStyle.Dark; - this.TextBoxPackImage.UseSelectable = true; - this.TextBoxPackImage.WaterMark = "Pack Image"; - this.TextBoxPackImage.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); - this.TextBoxPackImage.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); - // - // radioButtonSystem - // - this.radioButtonSystem.Appearance = System.Windows.Forms.Appearance.Button; - this.radioButtonSystem.BackColor = System.Drawing.Color.Transparent; - this.radioButtonSystem.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonSystem.Checked = true; - this.radioButtonSystem.Dock = System.Windows.Forms.DockStyle.Fill; - this.radioButtonSystem.FlatAppearance.CheckedBackColor = System.Drawing.Color.DodgerBlue; - this.radioButtonSystem.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Aqua; - this.radioButtonSystem.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.radioButtonSystem.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.radioButtonSystem.Font = new System.Drawing.Font("Segoe UI", 12F); - this.radioButtonSystem.ForeColor = System.Drawing.Color.White; - this.radioButtonSystem.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.radioButtonSystem.Location = new System.Drawing.Point(146, 69); - this.radioButtonSystem.Name = "radioButtonSystem"; - this.radioButtonSystem.Size = new System.Drawing.Size(137, 30); - this.radioButtonSystem.TabIndex = 5; - this.radioButtonSystem.TabStop = true; - this.radioButtonSystem.Text = "System"; - this.radioButtonSystem.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonSystem.UseVisualStyleBackColor = false; - this.radioButtonSystem.Click += new System.EventHandler(this.radioButton_Click); - // - // buttonSelect - // - this.buttonSelect.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonSelect.Dock = System.Windows.Forms.DockStyle.Fill; - this.buttonSelect.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.buttonSelect.Font = new System.Drawing.Font("Segoe UI", 12F); - this.buttonSelect.ForeColor = System.Drawing.Color.White; - this.buttonSelect.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.buttonSelect.Location = new System.Drawing.Point(3, 69); - this.buttonSelect.Name = "buttonSelect"; - this.buttonSelect.Size = new System.Drawing.Size(137, 30); - this.buttonSelect.TabIndex = 1; - this.buttonSelect.UseVisualStyleBackColor = true; - this.buttonSelect.Click += new System.EventHandler(this.buttonSelect_Click); - // - // PackImageSelection - // - this.PackImageSelection.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.PackImageSelection.BackColor = System.Drawing.Color.DarkCyan; - this.PackImageSelection.Dock = System.Windows.Forms.DockStyle.Fill; - this.PackImageSelection.Enabled = false; - this.PackImageSelection.FlatAppearance.BorderSize = 0; - this.PackImageSelection.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.PackImageSelection.Font = new System.Drawing.Font("Segoe UI", 9.75F); - this.PackImageSelection.ForeColor = System.Drawing.Color.White; - this.PackImageSelection.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.PackImageSelection.Location = new System.Drawing.Point(289, 36); - this.PackImageSelection.Name = "PackImageSelection"; - this.PackImageSelection.Size = new System.Drawing.Size(138, 27); - this.PackImageSelection.TabIndex = 12; - this.PackImageSelection.Text = "Browse"; - this.PackImageSelection.UseVisualStyleBackColor = false; - this.PackImageSelection.Click += new System.EventHandler(this.PackImageSelection_Click); - // - // regionLayoutPanel - // - this.regionLayoutPanel.ColumnCount = 3; - this.myTablePanel1.SetColumnSpan(this.regionLayoutPanel, 3); - this.regionLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.regionLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.regionLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); - this.regionLayoutPanel.Controls.Add(this.radioButtonEur, 0, 0); - this.regionLayoutPanel.Controls.Add(this.radioButtonUs, 1, 0); - this.regionLayoutPanel.Controls.Add(this.radioButtonJap, 2, 0); - this.regionLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.regionLayoutPanel.Location = new System.Drawing.Point(3, 105); - this.regionLayoutPanel.Name = "regionLayoutPanel"; - this.regionLayoutPanel.RowCount = 1; - this.regionLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.regionLayoutPanel.Size = new System.Drawing.Size(424, 40); - this.regionLayoutPanel.TabIndex = 13; - // - // radioButtonEur - // - this.radioButtonEur.Appearance = System.Windows.Forms.Appearance.Button; - this.radioButtonEur.AutoSize = true; - this.radioButtonEur.BackColor = System.Drawing.Color.Transparent; - this.radioButtonEur.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonEur.Checked = true; - this.radioButtonEur.Dock = System.Windows.Forms.DockStyle.Fill; - this.radioButtonEur.FlatAppearance.CheckedBackColor = System.Drawing.Color.DodgerBlue; - this.radioButtonEur.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Aqua; - this.radioButtonEur.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.radioButtonEur.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.radioButtonEur.Font = new System.Drawing.Font("Segoe UI", 12F); - this.radioButtonEur.ForeColor = System.Drawing.Color.White; - this.radioButtonEur.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.radioButtonEur.Location = new System.Drawing.Point(3, 3); - this.radioButtonEur.Name = "radioButtonEur"; - this.radioButtonEur.Size = new System.Drawing.Size(135, 34); - this.radioButtonEur.TabIndex = 1; - this.radioButtonEur.TabStop = true; - this.radioButtonEur.Text = "EUR"; - this.radioButtonEur.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonEur.UseVisualStyleBackColor = false; - this.radioButtonEur.Click += new System.EventHandler(this.radioButton_Click); - // - // radioButtonUs - // - this.radioButtonUs.Appearance = System.Windows.Forms.Appearance.Button; - this.radioButtonUs.AutoSize = true; - this.radioButtonUs.BackColor = System.Drawing.Color.Transparent; - this.radioButtonUs.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonUs.Dock = System.Windows.Forms.DockStyle.Fill; - this.radioButtonUs.FlatAppearance.CheckedBackColor = System.Drawing.Color.Teal; - this.radioButtonUs.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Aqua; - this.radioButtonUs.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.radioButtonUs.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.radioButtonUs.Font = new System.Drawing.Font("Segoe UI", 12F); - this.radioButtonUs.ForeColor = System.Drawing.Color.White; - this.radioButtonUs.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.radioButtonUs.Location = new System.Drawing.Point(144, 3); - this.radioButtonUs.Name = "radioButtonUs"; - this.radioButtonUs.Size = new System.Drawing.Size(135, 34); - this.radioButtonUs.TabIndex = 0; - this.radioButtonUs.Text = "US"; - this.radioButtonUs.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonUs.UseVisualStyleBackColor = false; - this.radioButtonUs.Click += new System.EventHandler(this.radioButton_Click); - // - // radioButtonJap - // - this.radioButtonJap.Appearance = System.Windows.Forms.Appearance.Button; - this.radioButtonJap.AutoSize = true; - this.radioButtonJap.BackColor = System.Drawing.Color.Transparent; - this.radioButtonJap.CheckAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonJap.Dock = System.Windows.Forms.DockStyle.Fill; - this.radioButtonJap.FlatAppearance.CheckedBackColor = System.Drawing.Color.Teal; - this.radioButtonJap.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Aqua; - this.radioButtonJap.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); - this.radioButtonJap.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.radioButtonJap.Font = new System.Drawing.Font("Segoe UI", 12F); - this.radioButtonJap.ForeColor = System.Drawing.Color.White; - this.radioButtonJap.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.radioButtonJap.Location = new System.Drawing.Point(285, 3); - this.radioButtonJap.Name = "radioButtonJap"; - this.radioButtonJap.Size = new System.Drawing.Size(136, 34); - this.radioButtonJap.TabIndex = 2; - this.radioButtonJap.Text = "JAP"; - this.radioButtonJap.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - this.radioButtonJap.UseVisualStyleBackColor = false; - this.radioButtonJap.Click += new System.EventHandler(this.radioButton_Click); - // - // WiiUPanel - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackColor = System.Drawing.SystemColors.ActiveCaptionText; - this.Controls.Add(this.myTablePanel1); - this.Name = "WiiUPanel"; - this.Size = new System.Drawing.Size(430, 550); - this.myTablePanel1.ResumeLayout(false); - this.contextMenuStripCaffiine.ResumeLayout(false); - this.regionLayoutPanel.ResumeLayout(false); - this.regionLayoutPanel.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TableLayoutPanel myTablePanel1; - private System.Windows.Forms.Button buttonServerToggle; - private System.Windows.Forms.Button buttonSelect; - private System.Windows.Forms.RadioButton radioButtonSystem; - private System.Windows.Forms.RadioButton radioButtonUSB; - private System.Windows.Forms.RadioButton radioButtonEur; - private System.Windows.Forms.RadioButton radioButtonUs; - private System.Windows.Forms.RadioButton radioButtonJap; - private MetroFramework.Controls.MetroTextBox IPv4TextBox; - private System.Windows.Forms.ListView listViewPCKS; - private MetroFramework.Controls.MetroTextBox TextBoxPackImage; - private System.Windows.Forms.Button PackImageSelection; - private System.Windows.Forms.ContextMenuStrip contextMenuStripCaffiine; - private System.Windows.Forms.ToolStripMenuItem replaceToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem replacePCKToolStripMenuItem; - private System.Windows.Forms.TableLayoutPanel regionLayoutPanel; - } -} diff --git a/PCK-Studio/Features/WiiUPanel.cs b/PCK-Studio/Features/WiiUPanel.cs deleted file mode 100644 index 8117e9f4..00000000 --- a/PCK-Studio/Features/WiiUPanel.cs +++ /dev/null @@ -1,290 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Net; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using OMI.Formats.Archive; -using OMI.Formats.Pck; -using OMI.Workers.Archive; -using OMI.Workers.Pck; -using PckStudio.Classes.Misc; - -namespace PckStudio.Features -{ - public partial class WiiUPanel : UserControl - { - string DLCPath = string.Empty; - string mod = string.Empty; - bool serverOn = false; - ConsoleArchive archive = new ConsoleArchive(); - PckFile currentPCK = null; - - private const string FtpUsername = "PCK_Studio_Client"; - // TODO: randomize per 'session'(instance) - private const string FtpSessionPassword = "a3262443"; - private ICredentials sessionCredentials = new NetworkCredential(FtpUsername, FtpSessionPassword); - - public WiiUPanel() - { - InitializeComponent(); - UpdateDLCPath(); - buttonServerToggle.Enabled = true; - if (listViewPCKS.Columns.Count == 0) - { - listViewPCKS.Columns.Add(DLCPath, listViewPCKS.Width); - } - } - - [Obsolete("Prompt user to use Aroma instead!")] - private void buttonSelect_Click(object sender, EventArgs e) - { - MessageBox.Show(this, "Please use Aroma's ftp Plugin!"); - return; - } - - private enum ButtonState - { - Start, - Stop, - Wait - } - - private void SetButtonState(ButtonState state) - { - switch(state) - { - case ButtonState.Start: - buttonServerToggle.BackColor = Color.FromArgb(68, 178, 13); - serverOn = false; - buttonServerToggle.Text = "Start"; - listViewPCKS.Enabled = false; - break; - case ButtonState.Stop: - serverOn = true; - buttonServerToggle.BackColor = Color.Red; - buttonServerToggle.Text = "Stop"; - listViewPCKS.Enabled = true; - break; - case ButtonState.Wait: - buttonServerToggle.BackColor = Color.MediumAquamarine; - buttonServerToggle.Text = "Wait.."; - break; - default: - break; - } - } - - private string GetConsoleDevice() - { - if (radioButtonSystem.Checked) - { - return "storage_mlc"; - } - if (radioButtonUSB.Checked) - { - return "storage_usb"; - } - throw new Exception("how did you get here ?"); - } - - private string GetConsoleRegion() - { - if (radioButtonEur.Checked) - { - return "101d7500"; - } - if (radioButtonUs.Checked) - { - return "101d9d00"; - } - if (radioButtonJap.Checked) - { - return "101dbe00"; - } - throw new Exception("how did you get here ?"); - } - - private string GetGameContentPath() - { - string device = GetConsoleDevice(); - string region = GetConsoleRegion(); - return $"{device}/usr/title/0005000e/{region}/content"; - } - - private void UpdateDLCPath() - { - DLCPath = $"{GetGameContentPath()}/WiiU/DLC/"; - } - - private void buttonServerToggle_Click(object sender, EventArgs e) - { - //Turn off server - if (serverOn) - { - listViewPCKS.Items.Clear(); - try - { - SetButtonState(ButtonState.Start); - } - catch (Exception ex) - { - MessageBox.Show(this, ex.ToString()); - } - return; - } - - if (!Regex.IsMatch(IPv4TextBox.Text, @"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")) - { - MessageBox.Show(this, "Please enter a valid Wii U IP!"); - return; - } - - // Turn on server - try - { - SetButtonState(ButtonState.Wait); - - ServicePointManager.Expect100Continue = true; - - using (var client = new FTPClient($"ftp://{IPv4TextBox.Text}", sessionCredentials)) - { - client.SetTimeoutLimit(TimeSpan.FromSeconds(10)); - string[] dirList = client.ListDirectory(DLCPath); - listViewPCKS.Items.AddRange(dirList.Select(s => new ListViewItem(s)).ToArray()); - foreach (ListViewItem pck in listViewPCKS.Items) - { - string[] res = client.ListDirectory($"{DLCPath}/{pck.Text}"); - if (res.Length != 1) - { - pck.Remove(); - } - } - } - - SetButtonState(ButtonState.Stop); - } - catch (Exception ex) - { - SetButtonState(ButtonState.Start); - MessageBox.Show(this, ex.ToString()); - } - } - - private void radioButton_Click(object sender, EventArgs e) - { - UpdateDLCPath(); - listViewPCKS.Columns[0].Text = DLCPath; - } - - private void listViewPCKS_MouseDown(object sender, MouseEventArgs e) - { - ListViewHitTestInfo hitTestInfo = listViewPCKS.HitTest(e.Location); - if (e.Button == MouseButtons.Right && hitTestInfo.Location != ListViewHitTestLocations.None) - { - contextMenuStripCaffiine.Show(this, Cursor.Position); - } - } - - private void replaceToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewPCKS.SelectedItems.Count != 0) - { - SetButtonState(ButtonState.Wait); - ReplacePck(mod); - MessageBox.Show(this, "PCK Replaced!"); - } - SetButtonState(ButtonState.Stop); - UpdateDLCPath(); - } - - private void replacePCKToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewPCKS.SelectedItems.Count != 0) - { - SetButtonState(ButtonState.Wait); - OpenFileDialog openPCK = new OpenFileDialog(); - openPCK.Filter = "PCK File|*.pck"; - - if (openPCK.ShowDialog(this) == DialogResult.OK) - { - ReplacePck(openPCK.FileName); - MessageBox.Show(this, "PCK Replaced!"); - } - } - SetButtonState(ButtonState.Stop); - UpdateDLCPath(); - } - - private void ReplacePck(string filename) - { - using (FTPClient client = new FTPClient($"ftp://{IPv4TextBox.Text}", sessionCredentials)) - client.UploadFile(filename, DLCPath + "/" + listViewPCKS.SelectedItems[0].Text + "/" + listViewPCKS.SelectedItems[0].Tag.ToString()); - if (!string.IsNullOrWhiteSpace(TextBoxPackImage.Text)) - { - string PackID = GetPackId(filename); - GetARCFromConsole(); - AddOrReplacePackImage(PackID); - SendARCToConsole(); - } - } - - private string GetPackId(string filepath) - { - var reader = new PckFileReader(); - currentPCK = reader.FromFile(filepath); - if (currentPCK is null) return string.Empty; - return currentPCK.TryGetFile("0", PckFileType.InfoFile, out var file) - ? file.GetProperty("PACKID") - : string.Empty; - } - - private void GetARCFromConsole() - { - using var ms = new MemoryStream(); - using (FTPClient client = new FTPClient($"ftp://{IPv4TextBox.Text}", sessionCredentials)) - { - client.DownloadFile(GetGameContentPath() + "/Common/Media/MediaWiiU.arc", ms); - ms.Position = 0; - var reader = new ARCFileReader(); - archive = reader.FromStream(ms); - } - } - - private void AddOrReplacePackImage(string packId) - { - string arcPath = $"Graphics\\PackGraphics\\{packId}.png"; - byte[] data = File.ReadAllBytes(TextBoxPackImage.Text); - if (archive.ContainsKey(arcPath)) archive[arcPath] = data; - else archive.Add(arcPath, data); - } - - private void SendARCToConsole() - { - using (FTPClient client = new FTPClient($"ftp://{IPv4TextBox.Text}", sessionCredentials)) - { - using (var ms = new MemoryStream()) - { - var writer = new ARCFileWriter(archive); - writer.WriteToStream(ms); - ms.Position = 0; - client.UploadFile(ms, GetGameContentPath() + "/Common/Media/MediaWiiU.arc"); - } - archive.Clear(); - //currentPCK?.Files.Clear(); - currentPCK = null; - } - GC.Collect(); - } - - private void PackImageSelection_Click(object sender, EventArgs e) - { - OpenFileDialog ofd = new OpenFileDialog(); - ofd.Filter = "Pack Image|*.png"; - if (ofd.ShowDialog(this) == DialogResult.OK) - TextBoxPackImage.Text = ofd.FileName; - } - } -} diff --git a/PCK-Studio/Features/WiiUPanel.resx b/PCK-Studio/Features/WiiUPanel.resx deleted file mode 100644 index 8a3a7dc8..00000000 --- a/PCK-Studio/Features/WiiUPanel.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index 80d610ea..22af6343 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -208,7 +208,6 @@ - @@ -250,12 +249,6 @@ CemuPanel.cs - - UserControl - - - WiiUPanel.cs - @@ -451,9 +444,6 @@ CemuPanel.cs - - WiiUPanel.cs - AddEntry.cs Designer From dc8c7ba41ab23a69bf1eb160744a3e4e64216142 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sun, 21 Apr 2024 13:20:13 +0200 Subject: [PATCH 5/5] Update OMI and change PckFileData to PckAsset --- .../Extensions/PckFileDataExtensions.cs | 28 +- PCK-Studio/Extensions/PckFileExtensions.cs | 4 +- .../Forms/Additional-Popups/AddFilePrompt.cs | 2 +- PCK-Studio/Forms/Editor/AudioEditor.cs | 4 +- PCK-Studio/Forms/Editor/BehaviourEditor.cs | 4 +- PCK-Studio/Forms/Editor/COLEditor.cs | 4 +- PCK-Studio/Forms/Editor/LOCEditor.cs | 4 +- PCK-Studio/Forms/Editor/MaterialsEditor.cs | 4 +- PCK-Studio/Forms/Editor/TextureAtlasEditor.cs | 10 +- .../Forms/Skins-And-Textures/AddNewSkin.cs | 10 +- .../Skins-And-Textures/AdvancedOptions.cs | 14 +- .../Forms/Skins-And-Textures/generateModel.cs | 6 +- PCK-Studio/Interfaces/IPckDeserializer.cs | 2 +- PCK-Studio/Interfaces/IPckSerializer.cs | 2 +- .../Deserializer/AnimationDeserializer.cs | 2 +- .../Deserializer/ImageDeserializer.cs | 2 +- PCK-Studio/Internal/PckNodeSorter.cs | 8 +- .../Serializer/AnimationSerializer.cs | 2 +- .../Internal/Serializer/ImageSerializer.cs | 2 +- PCK-Studio/MainForm.cs | 364 +++++++++--------- Vendor/OMI-Lib | 2 +- 21 files changed, 240 insertions(+), 240 deletions(-) diff --git a/PCK-Studio/Extensions/PckFileDataExtensions.cs b/PCK-Studio/Extensions/PckFileDataExtensions.cs index 95896208..cdc5a5fd 100644 --- a/PCK-Studio/Extensions/PckFileDataExtensions.cs +++ b/PCK-Studio/Extensions/PckFileDataExtensions.cs @@ -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(this PckFileData file, IPckDeserializer deserializer) + internal static T GetDeserializedData(this PckAsset file, IPckDeserializer deserializer) { return deserializer.Deserialize(file); } - internal static T GetData(this PckFileData file, IDataFormatReader formatReader) where T : class + internal static T GetData(this PckAsset file, IDataFormatReader formatReader) where T : class { using var ms = new MemoryStream(file.Data); return formatReader.FromStream(ms); } - internal static void SetSerializedData(this PckFileData file, T obj, IPckSerializer serializer) + internal static void SetSerializedData(this PckAsset file, T obj, IPckSerializer 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; diff --git a/PCK-Studio/Extensions/PckFileExtensions.cs b/PCK-Studio/Extensions/PckFileExtensions.cs index 45eca6a9..869b30d6 100644 --- a/PCK-Studio/Extensions/PckFileExtensions.cs +++ b/PCK-Studio/Extensions/PckFileExtensions.cs @@ -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); diff --git a/PCK-Studio/Forms/Additional-Popups/AddFilePrompt.cs b/PCK-Studio/Forms/Additional-Popups/AddFilePrompt.cs index 9e4bb343..69960382 100644 --- a/PCK-Studio/Forms/Additional-Popups/AddFilePrompt.cs +++ b/PCK-Studio/Forms/Additional-Popups/AddFilePrompt.cs @@ -12,7 +12,7 @@ namespace PckStudio.Popups /// otherwise /// 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) { } diff --git a/PCK-Studio/Forms/Editor/AudioEditor.cs b/PCK-Studio/Forms/Editor/AudioEditor.cs index 7658640e..2ed23b7b 100644 --- a/PCK-Studio/Forms/Editor/AudioEditor.cs +++ b/PCK-Studio/Forms/Editor/AudioEditor.cs @@ -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(); diff --git a/PCK-Studio/Forms/Editor/BehaviourEditor.cs b/PCK-Studio/Forms/Editor/BehaviourEditor.cs index 057de695..0dcf8099 100644 --- a/PCK-Studio/Forms/Editor/BehaviourEditor.cs +++ b/PCK-Studio/Forms/Editor/BehaviourEditor.cs @@ -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 BehaviourData = Entities.BehaviourInfos; @@ -54,7 +54,7 @@ namespace PckStudio.Forms.Editor treeView1.EndUpdate(); } - public BehaviourEditor(PckFileData file) + public BehaviourEditor(PckAsset file) { InitializeComponent(); diff --git a/PCK-Studio/Forms/Editor/COLEditor.cs b/PCK-Studio/Forms/Editor/COLEditor.cs index 78a222c3..8d82aa14 100644 --- a/PCK-Studio/Forms/Editor/COLEditor.cs +++ b/PCK-Studio/Forms/Editor/COLEditor.cs @@ -19,14 +19,14 @@ namespace PckStudio.Forms.Editor ColorContainer colourfile; string clipboard_color = "#FFFFFF"; - private readonly PckFileData _file; + private readonly PckAsset _file; List colorCache = new List(); List waterCache = new List(); List underwaterCache = new List(); List fogCache = new List(); - public COLEditor(PckFileData file) + public COLEditor(PckAsset file) { InitializeComponent(); diff --git a/PCK-Studio/Forms/Editor/LOCEditor.cs b/PCK-Studio/Forms/Editor/LOCEditor.cs index 56d5a607..78ac8b1c 100644 --- a/PCK-Studio/Forms/Editor/LOCEditor.cs +++ b/PCK-Studio/Forms/Editor/LOCEditor.cs @@ -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; diff --git a/PCK-Studio/Forms/Editor/MaterialsEditor.cs b/PCK-Studio/Forms/Editor/MaterialsEditor.cs index 75fbd5eb..2129b393 100644 --- a/PCK-Studio/Forms/Editor/MaterialsEditor.cs +++ b/PCK-Studio/Forms/Editor/MaterialsEditor.cs @@ -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 MaterialData = Entities.BehaviourInfos; @@ -64,7 +64,7 @@ namespace PckStudio.Forms.Editor treeView1.EndUpdate(); } - public MaterialsEditor(PckFileData file) + public MaterialsEditor(PckAsset file) { InitializeComponent(); _file = file; diff --git a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs index 5c6ad3e6..ec5b8f2c 100644 --- a/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs +++ b/PCK-Studio/Forms/Editor/TextureAtlasEditor.cs @@ -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); diff --git a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs index 10dc4771..911d09b4 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs @@ -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; diff --git a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs index 19d39a3f..ab5f6864 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AdvancedOptions.cs @@ -44,12 +44,12 @@ namespace PckStudio.Popups MessageBox.Show(this, "Please select a filetype before applying"); } - private void applyBulkProperties(IReadOnlyCollection files, int index) + private void applyBulkProperties(IReadOnlyCollection 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"); diff --git a/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs b/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs index 82df00a6..840a06c2 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs @@ -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); diff --git a/PCK-Studio/Interfaces/IPckDeserializer.cs b/PCK-Studio/Interfaces/IPckDeserializer.cs index 611acb82..6d5a361e 100644 --- a/PCK-Studio/Interfaces/IPckDeserializer.cs +++ b/PCK-Studio/Interfaces/IPckDeserializer.cs @@ -9,6 +9,6 @@ namespace PckStudio.Interfaces { internal interface IPckDeserializer { - public T Deserialize(PckFileData file); + public T Deserialize(PckAsset file); } } \ No newline at end of file diff --git a/PCK-Studio/Interfaces/IPckSerializer.cs b/PCK-Studio/Interfaces/IPckSerializer.cs index 5ea89e0f..0b20f8d5 100644 --- a/PCK-Studio/Interfaces/IPckSerializer.cs +++ b/PCK-Studio/Interfaces/IPckSerializer.cs @@ -9,6 +9,6 @@ namespace PckStudio.Interfaces { internal interface IPckSerializer { - public void Serialize(T obj, ref PckFileData file); + public void Serialize(T obj, ref PckAsset file); } } diff --git a/PCK-Studio/Internal/Deserializer/AnimationDeserializer.cs b/PCK-Studio/Internal/Deserializer/AnimationDeserializer.cs index 04f23dc0..e5d8f94e 100644 --- a/PCK-Studio/Internal/Deserializer/AnimationDeserializer.cs +++ b/PCK-Studio/Internal/Deserializer/AnimationDeserializer.cs @@ -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) diff --git a/PCK-Studio/Internal/Deserializer/ImageDeserializer.cs b/PCK-Studio/Internal/Deserializer/ImageDeserializer.cs index 4747fb96..0201e437 100644 --- a/PCK-Studio/Internal/Deserializer/ImageDeserializer.cs +++ b/PCK-Studio/Internal/Deserializer/ImageDeserializer.cs @@ -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 diff --git a/PCK-Studio/Internal/PckNodeSorter.cs b/PCK-Studio/Internal/PckNodeSorter.cs index 03cfd111..640db7d7 100644 --- a/PCK-Studio/Internal/PckNodeSorter.cs +++ b/PCK-Studio/Internal/PckNodeSorter.cs @@ -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() && !second.IsTagOfType()) + if (first.IsTagOfType() && !second.IsTagOfType()) return -1; - if (!first.IsTagOfType() && second.IsTagOfType()) + if (!first.IsTagOfType() && second.IsTagOfType()) return 1; if (CheckForSkinAndCapeFiles(first)) diff --git a/PCK-Studio/Internal/Serializer/AnimationSerializer.cs b/PCK-Studio/Internal/Serializer/AnimationSerializer.cs index 39febbb4..55bb59d8 100644 --- a/PCK-Studio/Internal/Serializer/AnimationSerializer.cs +++ b/PCK-Studio/Internal/Serializer/AnimationSerializer.cs @@ -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); diff --git a/PCK-Studio/Internal/Serializer/ImageSerializer.cs b/PCK-Studio/Internal/Serializer/ImageSerializer.cs index 5cf3f0ea..04e041fa 100644 --- a/PCK-Studio/Internal/Serializer/ImageSerializer.cs +++ b/PCK-Studio/Internal/Serializer/ImageSerializer.cs @@ -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 diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index d83e34d1..63373246 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -64,24 +64,24 @@ namespace PckStudio bool isSelectingTab = false; - readonly Dictionary> pckFileTypeHandler; + readonly Dictionary> pckFileTypeHandler; public MainForm() { InitializeComponent(); - skinToolStripMenuItem1.Click += (sender, e) => SetFileType(PckFileType.SkinFile); - capeToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.CapeFile); - textureToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.TextureFile); - languagesFileLOCToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.LocalisationFile); - gameRulesFileGRFToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.GameRulesFile); - audioPCKFileToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.AudioFile); - coloursCOLFileToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.ColourTableFile); - gameRulesHeaderGRHToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.GameRulesHeader); - skinsPCKToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.SkinDataFile); - modelsFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.ModelsFile); - behavioursFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.BehavioursFile); - entityMaterialsFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckFileType.MaterialFile); + skinToolStripMenuItem1.Click += (sender, e) => SetFileType(PckAssetType.SkinFile); + capeToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.CapeFile); + textureToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.TextureFile); + languagesFileLOCToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.LocalisationFile); + gameRulesFileGRFToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.GameRulesFile); + audioPCKFileToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.AudioFile); + coloursCOLFileToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.ColourTableFile); + gameRulesHeaderGRHToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.GameRulesHeader); + skinsPCKToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.SkinDataFile); + modelsFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.ModelsFile); + behavioursFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.BehavioursFile); + entityMaterialsFileBINToolStripMenuItem.Click += (sender, e) => SetFileType(PckAssetType.MaterialFile); treeViewMain.TreeViewNodeSorter = new PckNodeSorter(); @@ -92,31 +92,31 @@ namespace PckStudio labelVersion.Text = $"{Application.ProductName}: {Application.ProductVersion}"; ChangelogRichTextBox.Text = Resources.CHANGELOG; - pckFileTypeHandler = new Dictionary>(15) + pckFileTypeHandler = new Dictionary>(15) { - [PckFileType.SkinFile] = HandleSkinFile, - [PckFileType.CapeFile] = null, - [PckFileType.TextureFile] = HandleTextureFile, - [PckFileType.UIDataFile] = _ => throw new NotSupportedException("unused in-game"), - [PckFileType.InfoFile] = null, - [PckFileType.TexturePackInfoFile] = null, // HandleInnerPckFile, - [PckFileType.LocalisationFile] = HandleLocalisationFile, - [PckFileType.GameRulesFile] = HandleGameRuleFile, - [PckFileType.AudioFile] = HandleAudioFile, - [PckFileType.ColourTableFile] = HandleColourFile, - [PckFileType.GameRulesHeader] = HandleGameRuleFile, - [PckFileType.SkinDataFile] = null, // HandleInnerPckFile, - [PckFileType.ModelsFile] = null, //HandleModelsFile, // Note: Uncomment when implemented - [PckFileType.BehavioursFile] = HandleBehavioursFile, - [PckFileType.MaterialFile] = HandleMaterialFile, + [PckAssetType.SkinFile] = HandleSkinFile, + [PckAssetType.CapeFile] = null, + [PckAssetType.TextureFile] = HandleTextureFile, + [PckAssetType.UIDataFile] = _ => throw new NotSupportedException("unused in-game"), + [PckAssetType.InfoFile] = null, + [PckAssetType.TexturePackInfoFile] = null, // HandleInnerPckFile, + [PckAssetType.LocalisationFile] = HandleLocalisationFile, + [PckAssetType.GameRulesFile] = HandleGameRuleFile, + [PckAssetType.AudioFile] = HandleAudioFile, + [PckAssetType.ColourTableFile] = HandleColourFile, + [PckAssetType.GameRulesHeader] = HandleGameRuleFile, + [PckAssetType.SkinDataFile] = null, // HandleInnerPckFile, + [PckAssetType.ModelsFile] = null, //HandleModelsFile, // Note: Uncomment when implemented + [PckAssetType.BehavioursFile] = HandleBehavioursFile, + [PckAssetType.MaterialFile] = HandleMaterialFile, }; } // TODO: decide on how to handle embedded pck files - private void HandleInnerPckFile(PckFileData file) + private void HandleInnerPckFile(PckAsset file) { if (Settings.Default.LoadSubPcks && - (file.Filetype == PckFileType.SkinDataFile || file.Filetype == PckFileType.TexturePackInfoFile) && + (file.Type == PckAssetType.SkinDataFile || file.Type == PckAssetType.TexturePackInfoFile) && file.Size > 0 && treeViewMain.SelectedNode.Nodes.Count == 0) { try @@ -302,7 +302,7 @@ namespace PckStudio private void CheckForPasswordAndRemove() { - if (currentPCK.TryGetFile("0", PckFileType.InfoFile, out PckFileData file)) + if (currentPCK.TryGetFile("0", PckAssetType.InfoFile, out PckAsset file)) { file.RemoveProperties("LOCK"); } @@ -407,14 +407,14 @@ namespace PckStudio private void BuildPckTreeView(TreeNodeCollection root, PckFile pckFile) { - foreach (PckFileData file in pckFile.GetFiles()) + foreach (PckAsset file in pckFile.GetFiles()) { // fix any file paths that may be incorrect //if (file.Filename.StartsWith(parentPath)) // file.Filename = file.Filename.Remove(0, parentPath.Length); TreeNode node = BuildNodeTreeBySeperator(root, file.Filename, '/'); node.Tag = file; - SetNodeIcon(node, file.Filetype); + SetNodeIcon(node, file.Type); }; } @@ -427,7 +427,7 @@ namespace PckStudio treeViewMain.Nodes.Clear(); BuildPckTreeView(treeViewMain.Nodes, currentPCK); - if (isTemplateFile && currentPCK.HasFile("Skins.pck", PckFileType.SkinDataFile)) + if (isTemplateFile && currentPCK.HasFile("Skins.pck", PckAssetType.SkinDataFile)) { TreeNode skinsNode = treeViewMain.Nodes.Find("Skins.pck", false).FirstOrDefault(); TreeNode folderNode = CreateNode("Skins"); @@ -446,9 +446,9 @@ namespace PckStudio } } - private void HandleTextureFile(PckFileData file) + private void HandleTextureFile(PckAsset file) { - _ = file.IsMipmappedFile() && currentPCK.TryGetValue(file.GetNormalPath(), PckFileType.TextureFile, out file); + _ = file.IsMipmappedFile() && currentPCK.TryGetValue(file.GetNormalPath(), PckAssetType.TextureFile, out file); if (file.Size <= 0) { @@ -556,7 +556,7 @@ namespace PckStudio } } - private void HandleGameRuleFile(PckFileData file) + private void HandleGameRuleFile(PckAsset file) { const string use_deflate = "PS3"; const string use_xmem = "Xbox 360"; @@ -587,7 +587,7 @@ namespace PckStudio } } - private void HandleAudioFile(PckFileData file) + private void HandleAudioFile(PckAsset file) { try { @@ -607,20 +607,20 @@ namespace PckStudio } } - private void HandleLocalisationFile(PckFileData file) + private void HandleLocalisationFile(PckAsset file) { using LOCEditor locedit = new LOCEditor(file); wasModified = locedit.ShowDialog(this) == DialogResult.OK; UpdateRichPresence(); } - private void HandleColourFile(PckFileData file) + private void HandleColourFile(PckAsset file) { using COLEditor diag = new COLEditor(file); wasModified = diag.ShowDialog(this) == DialogResult.OK; } - public void HandleSkinFile(PckFileData file) + public void HandleSkinFile(PckAsset file) { if (file.HasProperty("BOX")) { @@ -639,18 +639,18 @@ namespace PckStudio skinViewer.ShowDialog(this); } - public void HandleModelsFile(PckFileData file) + public void HandleModelsFile(PckAsset file) { MessageBox.Show(this, "Models.bin support has not been implemented. You can use the Spark Editor for the time being to edit these files.", "Not implemented yet."); } - public void HandleBehavioursFile(PckFileData file) + public void HandleBehavioursFile(PckAsset file) { using BehaviourEditor edit = new BehaviourEditor(file); wasModified = edit.ShowDialog(this) == DialogResult.OK; } - public void HandleMaterialFile(PckFileData file) + public void HandleMaterialFile(PckAsset file) { using MaterialsEditor edit = new MaterialsEditor(file); wasModified = edit.ShowDialog(this) == DialogResult.OK; @@ -663,7 +663,7 @@ namespace PckStudio buttonEdit.Visible = false; previewPictureBox.Image = Resources.NoImageFound; viewFileInfoToolStripMenuItem.Visible = false; - if (e.Node.TryGetTagData(out PckFileData file)) + if (e.Node.TryGetTagData(out PckAsset file)) { viewFileInfoToolStripMenuItem.Visible = true; if (file.HasProperty("BOX")) @@ -678,11 +678,11 @@ namespace PckStudio buttonEdit.Visible = true; } - switch (file.Filetype) + switch (file.Type) { - case PckFileType.SkinFile: - case PckFileType.CapeFile: - case PckFileType.TextureFile: + case PckAssetType.SkinFile: + case PckAssetType.CapeFile: + case PckAssetType.TextureFile: { Image img = file.GetTexture(); @@ -706,7 +706,7 @@ namespace PckStudio if ((file.Filename.StartsWith(ResourceLocation.GetPathFromCategory(ResourceCategory.ItemAnimation)) || file.Filename.StartsWith(ResourceLocation.GetPathFromCategory(ResourceCategory.BlockAnimation))) && - file.Filetype == PckFileType.TextureFile + file.Type == PckAssetType.TextureFile && !file.IsMipmappedFile()) { buttonEdit.Text = "EDIT TILE ANIMATION"; @@ -715,22 +715,22 @@ namespace PckStudio } break; - case PckFileType.LocalisationFile: + case PckAssetType.LocalisationFile: buttonEdit.Text = "EDIT LOC"; buttonEdit.Visible = true; break; - case PckFileType.AudioFile: + case PckAssetType.AudioFile: buttonEdit.Text = "EDIT MUSIC CUES"; buttonEdit.Visible = true; break; - case PckFileType.ColourTableFile when file.Filename == "colours.col": + case PckAssetType.ColourTableFile when file.Filename == "colours.col": buttonEdit.Text = "EDIT COLORS"; buttonEdit.Visible = true; break; - case PckFileType.BehavioursFile when file.Filename == "behaviours.bin": + case PckAssetType.BehavioursFile when file.Filename == "behaviours.bin": buttonEdit.Text = "EDIT BEHAVIOURS"; buttonEdit.Visible = true; break; @@ -741,7 +741,7 @@ namespace PckStudio } } - private void extractFile(string outFilePath, PckFileData file) + private void extractFile(string outFilePath, PckAsset file) { File.WriteAllBytes(outFilePath, file.Data); if (file.PropertyCount > 0) @@ -754,7 +754,7 @@ namespace PckStudio } } - private void extractFolderFile(string outPath, PckFileData file) + private void extractFolderFile(string outPath, PckAsset file) { TreeNode node = treeViewMain.SelectedNode; @@ -779,7 +779,7 @@ namespace PckStudio { GetAllChildNodes(node.Nodes).ForEach(fileNode => { - if (fileNode.TryGetTagData(out PckFileData file)) + if (fileNode.TryGetTagData(out PckAsset file)) { extractFolderFile(outPath, file); } @@ -788,7 +788,7 @@ namespace PckStudio } else { - foreach (PckFileData _file in currentPCK.GetFiles()) + foreach (PckAsset _file in currentPCK.GetFiles()) { if (_file.Filename.StartsWith(selectedFolder)) { @@ -816,7 +816,7 @@ namespace PckStudio if (dialog.ShowDialog(Handle) == true) extractFolder(dialog.ResultPath); } - else if (node.TryGetTagData(out PckFileData file)) + else if (node.TryGetTagData(out PckAsset file)) { using SaveFileDialog exFile = new SaveFileDialog(); exFile.FileName = Path.GetFileName(file.Filename); @@ -862,16 +862,16 @@ namespace PckStudio private void replaceToolStripMenuItem_Click(object sender, EventArgs e) { - if (treeViewMain.SelectedNode.Tag is PckFileData file) + if (treeViewMain.SelectedNode.Tag is PckAsset file) { using var ofd = new OpenFileDialog(); // Suddenly, and randomly, this started throwing an exception because it wasn't formatted correctly? So now it's formatted correctly and now displays the file type name in the dialog. string extra_extensions = ""; - switch (file.Filetype) + switch (file.Type) { - case PckFileType.TextureFile: + case PckAssetType.TextureFile: if (Path.GetExtension(file.Filename) == ".png") extra_extensions = ";*.tga"; else if (Path.GetExtension(file.Filename) == ".tga") extra_extensions = ";*.png"; break; @@ -879,7 +879,7 @@ namespace PckStudio string fileExt = Path.GetExtension(file.Filename); - ofd.Filter = $"{file.Filetype} (*{fileExt}{extra_extensions})|*{fileExt}{extra_extensions}"; + ofd.Filter = $"{file.Type} (*{fileExt}{extra_extensions})|*{fileExt}{extra_extensions}"; if (ofd.ShowDialog(this) == DialogResult.OK) { string newFileExt = Path.GetExtension(ofd.FileName); @@ -899,12 +899,12 @@ namespace PckStudio /// /// File to remove /// True if the remove should be canceled, otherwise False - private bool BeforeFileRemove(PckFileData file) + private bool BeforeFileRemove(PckAsset file) { string itemPath = ResourceLocation.GetPathFromCategory(ResourceCategory.ItemAnimation); // warn the user about deleting compass.png and clock.png - if (file.Filetype == PckFileType.TextureFile && + if (file.Type == PckAssetType.TextureFile && (file.Filename == itemPath + "/compass.png" || file.Filename == itemPath + "/clock.png")) { if (MessageBox.Show(this, "Are you sure want to delete this file? If \"compass.png\" or \"clock.png\" are missing, your game will crash upon loading this pack.", "Warning", @@ -913,7 +913,7 @@ namespace PckStudio } // remove loc key if its a skin/cape - if (file.Filetype == PckFileType.SkinFile || file.Filetype == PckFileType.CapeFile) + if (file.Type == PckAssetType.SkinFile || file.Type == PckAssetType.CapeFile) { if (TryGetLocFile(out LOCFile locFile)) { @@ -935,7 +935,7 @@ namespace PckStudio string path = node.FullPath; - if (node.TryGetTagData(out PckFileData file)) + if (node.TryGetTagData(out PckAsset file)) { if (!BeforeFileRemove(file) && currentPCK.RemoveFile(file)) { @@ -960,7 +960,7 @@ namespace PckStudio if (node == null) return; string path = node.FullPath; - bool isFile = node.TryGetTagData(out var file); + bool isFile = node.TryGetTagData(out var file); using TextPrompt diag = new TextPrompt(isFile ? file.Filename : Path.GetFileName(node.FullPath)); @@ -968,7 +968,7 @@ namespace PckStudio { if (isFile) { - if (currentPCK.Contains(diag.NewText, file.Filetype)) + if (currentPCK.Contains(diag.NewText, file.Type)) { MessageBox.Show(this, $"{diag.NewText} already exists", "File already exists"); return; @@ -980,7 +980,7 @@ namespace PckStudio node.Text = diag.NewText; foreach (TreeNode childNode in GetAllChildNodes(node.Nodes)) { - if (childNode.Tag is PckFileData folderFile) + if (childNode.Tag is PckAsset folderFile) { if (folderFile.Filename == diag.NewText) continue; folderFile.Filename = childNode.FullPath; @@ -1000,14 +1000,14 @@ namespace PckStudio using AddNewSkin add = new AddNewSkin(locFile); if (add.ShowDialog(this) == DialogResult.OK) { - if (currentPCK.HasFile("Skins.pck", PckFileType.SkinDataFile)) // Prioritize Skins.pck + if (currentPCK.HasFile("Skins.pck", PckAssetType.SkinDataFile)) // Prioritize Skins.pck { TreeNode subPCK = treeViewMain.Nodes.Find("Skins.pck", false).FirstOrDefault(); if (subPCK.Nodes.ContainsKey("Skins")) add.SkinFile.Filename = add.SkinFile.Filename.Insert(0, "Skins/"); add.SkinFile.Filename = add.SkinFile.Filename.Insert(0, "Skins.pck/"); TreeNode newNode = new TreeNode(Path.GetFileName(add.SkinFile.Filename)); newNode.Tag = add.SkinFile; - SetNodeIcon(newNode, PckFileType.SkinFile); + SetNodeIcon(newNode, PckAssetType.SkinFile); subPCK.Nodes.Add(newNode); RebuildSubPCK(newNode.FullPath); } @@ -1018,14 +1018,14 @@ namespace PckStudio } if (add.HasCape) { - if (currentPCK.HasFile("Skins.pck", PckFileType.SkinDataFile)) // Prioritize Skins.pck + if (currentPCK.HasFile("Skins.pck", PckAssetType.SkinDataFile)) // Prioritize Skins.pck { TreeNode subPCK = treeViewMain.Nodes.Find("Skins.pck", false).FirstOrDefault(); if (subPCK.Nodes.ContainsKey("Skins")) add.CapeFile.Filename = add.CapeFile.Filename.Insert(0, "Skins/"); add.CapeFile.Filename = add.CapeFile.Filename.Insert(0, "Skins.pck/"); TreeNode newNode = new TreeNode(Path.GetFileName(add.CapeFile.Filename)); newNode.Tag = add.CapeFile; - SetNodeIcon(newNode, PckFileType.SkinFile); + SetNodeIcon(newNode, PckAssetType.SkinFile); subPCK.Nodes.Add(newNode); RebuildSubPCK(newNode.FullPath); } @@ -1042,20 +1042,20 @@ namespace PckStudio } } - private static PckFileData CreateNewAudioFile(bool isLittle) + private static PckAsset CreateNewAudioFile(bool isLittle) { PckAudioFile audioPck = new PckAudioFile(); audioPck.AddCategory(PckAudioFile.AudioCategory.EAudioType.Overworld); audioPck.AddCategory(PckAudioFile.AudioCategory.EAudioType.Nether); audioPck.AddCategory(PckAudioFile.AudioCategory.EAudioType.End); - PckFileData pckFileData = new PckFileData("audio.pck", PckFileType.AudioFile); + PckAsset pckFileData = new PckAsset("audio.pck", PckAssetType.AudioFile); pckFileData.SetData(new PckAudioFileWriter(audioPck, isLittle ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian)); return pckFileData; } private void audiopckToolStripMenuItem_Click(object sender, EventArgs e) { - if (currentPCK.Contains(PckFileType.AudioFile)) + if (currentPCK.Contains(PckAssetType.AudioFile)) { // the chance of this happening is really really slim but just in case MessageBox.Show(this, "There is already an audio file in this PCK!", "Can't create audio.pck"); @@ -1067,7 +1067,7 @@ namespace PckStudio return; } - PckFileData file = CreateNewAudioFile(LittleEndianCheckBox.Checked); + PckAsset file = CreateNewAudioFile(LittleEndianCheckBox.Checked); AudioEditor diag = new AudioEditor(file, LittleEndianCheckBox.Checked); if (diag.ShowDialog(this) == DialogResult.OK) { @@ -1085,7 +1085,7 @@ namespace PckStudio string animationFilepath = $"{ResourceLocation.GetPathFromCategory(diag.Category)}/{diag.SelectedTile}.png"; - if (currentPCK.Contains(animationFilepath, PckFileType.TextureFile)) + if (currentPCK.Contains(animationFilepath, PckAssetType.TextureFile)) { MessageBox.Show(this, $"{diag.SelectedTile} is already present.", "File already present"); return; @@ -1095,7 +1095,7 @@ namespace PckStudio if (animationEditor.ShowDialog() == DialogResult.OK) { wasModified = true; - PckFileData file = currentPCK.CreateNewFile(animationFilepath, PckFileType.TextureFile); + PckAsset file = currentPCK.CreateNewFile(animationFilepath, PckAssetType.TextureFile); file.SetSerializedData(animationEditor.Result, AnimationSerializer.DefaultSerializer); BuildMainTreeView(); ReloadMetaTreeView(); @@ -1141,9 +1141,9 @@ namespace PckStudio foreach (string node in s) { TreeNode parent = treeViewMain.Nodes.Find(node, true)[0]; - if (parent.TryGetTagData(out PckFileData f) && - (f.Filetype is PckFileType.TexturePackInfoFile || - f.Filetype is PckFileType.SkinDataFile)) + if (parent.TryGetTagData(out PckAsset f) && + (f.Type is PckAssetType.TexturePackInfoFile || + f.Type is PckAssetType.SkinDataFile)) return parent; } @@ -1161,7 +1161,7 @@ namespace PckStudio Debug.WriteLine(parent.Name); if (parent == null) return; - PckFileData parent_file = parent.Tag as PckFileData; + PckAsset parent_file = parent.Tag as PckAsset; PckFile parent_file_pck = new PckFileReader( LittleEndianCheckBox.Checked ? @@ -1169,19 +1169,19 @@ namespace PckStudio OMI.Endianness.BigEndian ).FromStream(new MemoryStream(parent_file.Data)); - if (parent_file.Filetype is PckFileType.TexturePackInfoFile || parent_file.Filetype is PckFileType.SkinDataFile) + if (parent_file.Type is PckAssetType.TexturePackInfoFile || parent_file.Type is PckAssetType.SkinDataFile) { Debug.WriteLine("Rebuilding " + parent_file.Filename); - PckFile newPCKFile = new PckFile(3, parent_file.Filetype is PckFileType.SkinDataFile); + PckFile newPCKFile = new PckFile(3, parent_file.Type is PckAssetType.SkinDataFile); bool hasSkinsFolder = false; // add original pck files to prevent data loss - foreach (PckFileData _fd in parent_file_pck.GetFiles()) + foreach (PckAsset _fd in parent_file_pck.GetFiles()) { - PckFileData new_file = newPCKFile.CreateNewFile(_fd.Filename, _fd.Filetype); + PckAsset new_file = newPCKFile.CreateNewFile(_fd.Filename, _fd.Type); // check for skins folder so files are placed consistently in final pck - if (_fd.Filename.StartsWith("Skins/") && parent_file.Filetype is PckFileType.SkinDataFile) hasSkinsFolder = true; + if (_fd.Filename.StartsWith("Skins/") && parent_file.Type is PckAssetType.SkinDataFile) hasSkinsFolder = true; foreach (var prop in _fd.GetProperties()) new_file.AddProperty(prop); new_file.SetData(_fd.Data); @@ -1189,11 +1189,11 @@ namespace PckStudio foreach (TreeNode node in GetAllChildNodes(parent.Nodes)) { - if (node.Tag is PckFileData node_file) + if (node.Tag is PckAsset node_file) { - PckFileData new_file = newPCKFile.CreateNewFile( + PckAsset new_file = newPCKFile.CreateNewFile( (hasSkinsFolder ? "Skins/" : String.Empty) - + node_file.Filename.Replace(parent_file.Filename + "/", String.Empty), node_file.Filetype); + + node_file.Filename.Replace(parent_file.Filename + "/", String.Empty), node_file.Type); foreach (var prop in node_file.GetProperties()) new_file.AddProperty(prop); new_file.SetData(node_file.Data); @@ -1214,14 +1214,14 @@ namespace PckStudio private void treeViewMain_DoubleClick(object sender, EventArgs e) { - if (treeViewMain.SelectedNode.TryGetTagData(out PckFileData file)) + if (treeViewMain.SelectedNode.TryGetTagData(out PckAsset file)) { if (file.Size <= 0) { Trace.WriteLine($"'{file.Filename}' has no data attached.", category: nameof(treeViewMain_DoubleClick)); return; } - pckFileTypeHandler[file.Filetype]?.Invoke(file); + pckFileTypeHandler[file.Type]?.Invoke(file); } } @@ -1237,13 +1237,13 @@ namespace PckStudio private void treeMeta_DoubleClick(object sender, EventArgs e) { if (treeMeta.SelectedNode is TreeNode subnode && subnode.Tag is KeyValuePair property && - treeViewMain.SelectedNode is TreeNode node && node.Tag is PckFileData file) + treeViewMain.SelectedNode is TreeNode node && node.Tag is PckAsset file) { if (file.HasProperty(property.Key)) { switch (property.Key) { - case "ANIM" when file.Filetype == PckFileType.SkinFile: + case "ANIM" when file.Type == PckAssetType.SkinFile: try { using ANIMEditor diag = new ANIMEditor(property.Value); @@ -1264,7 +1264,7 @@ namespace PckStudio } break; - case "BOX" when file.Filetype == PckFileType.SkinFile: + case "BOX" when file.Type == PckAssetType.SkinFile: try { using BoxEditor diag = new BoxEditor(property.Value, IsSubPCKNode(treeViewMain.SelectedNode.FullPath)); @@ -1307,7 +1307,7 @@ namespace PckStudio private void cloneFileToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode node = treeViewMain.SelectedNode; - if (node == null || !node.IsTagOfType()) + if (node == null || !node.IsTagOfType()) return; string path = node.FullPath; @@ -1317,11 +1317,11 @@ namespace PckStudio if (diag.ShowDialog(this) == DialogResult.OK) { - if (node.Tag is PckFileData file) + if (node.Tag is PckAsset file) { TreeNode newNode = new TreeNode(); newNode.Text = Path.GetFileName(diag.NewText); - var newFile = new PckFileData(diag.NewText, file.Filetype); + var newFile = new PckAsset(diag.NewText, file.Type); foreach (var property in file.GetProperties()) { newFile.AddProperty(property); @@ -1356,7 +1356,7 @@ namespace PckStudio private void deleteEntryToolStripMenuItem_Click(object sender, EventArgs e) { if (treeMeta.SelectedNode is TreeNode t && t.Tag is KeyValuePair property && - treeViewMain.SelectedNode is TreeNode main && main.Tag is PckFileData file && + treeViewMain.SelectedNode is TreeNode main && main.Tag is PckAsset file && file.RemoveProperty(property)) { treeMeta.SelectedNode.Remove(); @@ -1369,7 +1369,7 @@ namespace PckStudio { treeMeta.Nodes.Clear(); if (treeViewMain.SelectedNode is TreeNode node && - node.Tag is PckFileData file) + node.Tag is PckAsset file) { foreach (var property in file.GetProperties()) { @@ -1381,7 +1381,7 @@ namespace PckStudio private void addEntryToolStripMenuItem_Click_1(object sender, EventArgs e) { if (treeViewMain.SelectedNode is TreeNode t && - t.Tag is PckFileData file) + t.Tag is PckAsset file) { using AddPropertyPrompt addProperty = new AddPropertyPrompt(); if (addProperty.ShowDialog(this) == DialogResult.OK) @@ -1405,7 +1405,7 @@ namespace PckStudio if (e.Button != MouseButtons.Left || e.Item is not TreeNode node) return; - if ((node.TryGetTagData(out PckFileData file) && currentPCK.Contains(file.Filename, file.Filetype)) || node.Parent is TreeNode) + if ((node.TryGetTagData(out PckAsset file) && currentPCK.Contains(file.Filename, file.Type)) || node.Parent is TreeNode) { treeViewMain.DoDragDrop(node, DragDropEffects.Move); } @@ -1415,7 +1415,7 @@ namespace PckStudio { Point dragLocation = new Point(e.X, e.Y); TreeNode node = treeViewMain.GetNodeAt(treeViewMain.PointToClient(dragLocation)); - treeViewMain.SelectedNode = node.IsTagOfType() ? null : node; + treeViewMain.SelectedNode = node.IsTagOfType() ? null : node; } private void treeViewMain_DragEnter(object sender, DragEventArgs e) @@ -1448,7 +1448,7 @@ namespace PckStudio if (targetNode is null) return; - bool isTargetPckFile = targetNode.IsTagOfType(); + bool isTargetPckFile = targetNode.IsTagOfType(); if (e.Data.GetData(dataFormat) is not TreeNode draggedNode) { @@ -1483,7 +1483,7 @@ namespace PckStudio Debug.WriteLine($"Target drop location is {(isTargetPckFile ? "file" : "folder")}."); // Retrieve the node that was dragged. - if (draggedNode.TryGetTagData(out PckFileData draggedFile) && + if (draggedNode.TryGetTagData(out PckAsset draggedFile) && targetNode.FullPath != draggedFile.Filename) { Debug.WriteLine(draggedFile.Filename + " was droped onto " + targetNode.FullPath); @@ -1498,7 +1498,7 @@ namespace PckStudio } else { - List pckFiles = GetEndingNodes(draggedNode.Nodes).Where(t => t.IsTagOfType()).Select(t => t.Tag as PckFileData).ToList(); + List pckFiles = GetEndingNodes(draggedNode.Nodes).Where(t => t.IsTagOfType()).Select(t => t.Tag as PckAsset).ToList(); string oldPath = draggedNode.FullPath; string newPath = Path.Combine(isTargetPckFile ? Path.GetDirectoryName(targetNode.FullPath) : targetNode.FullPath, draggedNode.Text).Replace('\\', '/'); foreach (var pckFile in pckFiles) @@ -1554,15 +1554,15 @@ namespace PckStudio { var pack = new PckFile(3); - PckFileData zeroFile = pack.CreateNewFile("0", PckFileType.InfoFile); + PckAsset zeroFile = pack.CreateNewFile("0", PckAssetType.InfoFile); zeroFile.AddProperty("PACKID", packId); zeroFile.AddProperty("PACKVERSION", packVersion); var locFile = new LOCFile(); locFile.InitializeDefault(packName); - pack.CreateNewFile("localisation.loc", PckFileType.LocalisationFile, new LOCFileWriter(locFile, 2)); + pack.CreateNewFile("localisation.loc", PckAssetType.LocalisationFile, new LOCFileWriter(locFile, 2)); - pack.CreateNewFileIf(createSkinsPCK, "Skins.pck", PckFileType.SkinDataFile, new PckFileWriter(new PckFile(3, true), + pack.CreateNewFileIf(createSkinsPCK, "Skins.pck", PckAssetType.SkinDataFile, new PckFileWriter(new PckFile(3, true), LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian)); @@ -1576,13 +1576,13 @@ namespace PckStudio PckFile infoPCK = new PckFile(3); - PckFileData icon = infoPCK.CreateNewFile("icon.png", PckFileType.TextureFile); + PckAsset icon = infoPCK.CreateNewFile("icon.png", PckAssetType.TextureFile); icon.SetTexture(Resources.TexturePackIcon); - PckFileData comparison = infoPCK.CreateNewFile("comparison.png", PckFileType.TextureFile); + PckAsset comparison = infoPCK.CreateNewFile("comparison.png", PckAssetType.TextureFile); comparison.SetTexture(Resources.Comparison); - PckFileData texturepackInfo = pack.CreateNewFile($"{res}/{res}Info.pck", PckFileType.TexturePackInfoFile); + PckAsset texturepackInfo = pack.CreateNewFile($"{res}/{res}Info.pck", PckAssetType.TexturePackInfoFile); texturepackInfo.AddProperty("PACKID", "0"); texturepackInfo.AddProperty("DATAPATH", $"{res}Data.pck"); @@ -1594,7 +1594,7 @@ namespace PckStudio private PckFile InitializeMashUpPack(int packId, int packVersion, string packName, string res) { PckFile pack = InitializeTexturePack(packId, packVersion, packName, res, true); - PckFileData gameRuleFile = pack.CreateNewFile("GameRules.grf", PckFileType.GameRulesFile); + PckAsset gameRuleFile = pack.CreateNewFile("GameRules.grf", PckAssetType.GameRulesFile); GameRuleFile grfFile = new GameRuleFile(); grfFile.AddRule("MapOptions", new KeyValuePair("seed", "0"), @@ -1733,7 +1733,7 @@ namespace PckStudio if (contents.ShowDialog(this) == DialogResult.OK && Directory.Exists(contents.SelectedPath)) { string filepath = treeViewMain.SelectedNode?.FullPath ?? ""; - if (treeViewMain.SelectedNode is not null && treeViewMain.SelectedNode.IsTagOfType()) + if (treeViewMain.SelectedNode is not null && treeViewMain.SelectedNode.IsTagOfType()) filepath = treeViewMain.SelectedNode.Parent?.FullPath ?? ""; foreach (var fullfilename in Directory.GetFiles(contents.SelectedPath, "dlc*.png")) @@ -1743,12 +1743,12 @@ namespace PckStudio if (!filename.StartsWith("dlcskin") && !filename.StartsWith("dlccape")) continue; // sets file type based on wether its a cape or skin - PckFileType pckfiletype = filename.StartsWith("dlccape", StringComparison.OrdinalIgnoreCase) - ? PckFileType.CapeFile - : PckFileType.SkinFile; + PckAssetType pckfiletype = filename.StartsWith("dlccape", StringComparison.OrdinalIgnoreCase) + ? PckAssetType.CapeFile + : PckAssetType.SkinFile; string pckfilepath = Path.Combine(filepath, filename); - PckFileData newFile = currentPCK.CreateNewFile(pckfilepath, pckfiletype); + PckAsset newFile = currentPCK.CreateNewFile(pckfilepath, pckfiletype); byte[] filedata = File.ReadAllBytes(fullfilename); newFile.SetData(filedata); @@ -1774,8 +1774,8 @@ namespace PckStudio private bool TryGetLocFile(out LOCFile locFile) { - if (!currentPCK.TryGetFile("localisation.loc", PckFileType.LocalisationFile, out PckFileData locdata) && - !currentPCK.TryGetFile("languages.loc", PckFileType.LocalisationFile, out locdata)) + if (!currentPCK.TryGetFile("localisation.loc", PckAssetType.LocalisationFile, out PckAsset locdata) && + !currentPCK.TryGetFile("languages.loc", PckAssetType.LocalisationFile, out locdata)) { locFile = null; return false; @@ -1800,8 +1800,8 @@ namespace PckStudio private bool TrySetLocFile(in LOCFile locFile) { - if (!currentPCK.TryGetFile("localisation.loc", PckFileType.LocalisationFile, out PckFileData locdata) && - !currentPCK.TryGetFile("languages.loc", PckFileType.LocalisationFile, out locdata)) + if (!currentPCK.TryGetFile("localisation.loc", PckAssetType.LocalisationFile, out PckAsset locdata) && + !currentPCK.TryGetFile("languages.loc", PckAssetType.LocalisationFile, out locdata)) { return false; } @@ -1831,7 +1831,7 @@ namespace PckStudio { string skinNameImport = Path.GetFileName(contents.FileName); byte[] data = File.ReadAllBytes(contents.FileName); - PckFileData mfNew = currentPCK.CreateNewFile(skinNameImport, PckFileType.SkinFile); + PckAsset mfNew = currentPCK.CreateNewFile(skinNameImport, PckAssetType.SkinFile); mfNew.SetData(data); string propertyFile = Path.GetFileNameWithoutExtension(contents.FileName) + ".txt"; if (File.Exists(propertyFile)) @@ -1889,9 +1889,9 @@ namespace PckStudio TreeNodeCollection nodeCollection = treeViewMain.Nodes; if (treeViewMain.SelectedNode is TreeNode node) { - if (node.Tag is PckFileData fd && - (fd.Filetype != PckFileType.TexturePackInfoFile && - fd.Filetype != PckFileType.SkinDataFile)) + if (node.Tag is PckAsset fd && + (fd.Type != PckAssetType.TexturePackInfoFile && + fd.Type != PckAssetType.SkinDataFile)) { if (node.Parent is TreeNode parentNode) { @@ -2026,66 +2026,66 @@ namespace PckStudio SaveTemplate(); } - private void SetNodeIcon(TreeNode node, PckFileType type) + private void SetNodeIcon(TreeNode node, PckAssetType type) { switch (type) { - case PckFileType.AudioFile: + case PckAssetType.AudioFile: node.ImageIndex = 1; node.SelectedImageIndex = 1; break; - case PckFileType.LocalisationFile: + case PckAssetType.LocalisationFile: node.ImageIndex = 3; node.SelectedImageIndex = 3; break; - case PckFileType.TexturePackInfoFile: + case PckAssetType.TexturePackInfoFile: goto default; node.ImageIndex = 4; node.SelectedImageIndex = 4; break; - case PckFileType.ColourTableFile: + case PckAssetType.ColourTableFile: node.ImageIndex = 6; node.SelectedImageIndex = 6; break; - case PckFileType.ModelsFile: + case PckAssetType.ModelsFile: goto default; node.ImageIndex = 8; node.SelectedImageIndex = 8; break; - case PckFileType.SkinDataFile: + case PckAssetType.SkinDataFile: goto default; node.ImageIndex = 7; node.SelectedImageIndex = 7; break; - case PckFileType.GameRulesFile: + case PckAssetType.GameRulesFile: node.ImageIndex = 9; node.SelectedImageIndex = 9; break; - case PckFileType.GameRulesHeader: + case PckAssetType.GameRulesHeader: node.ImageIndex = 10; node.SelectedImageIndex = 10; break; - case PckFileType.InfoFile: + case PckAssetType.InfoFile: node.ImageIndex = 11; node.SelectedImageIndex = 11; break; - case PckFileType.SkinFile: + case PckAssetType.SkinFile: node.ImageIndex = 12; node.SelectedImageIndex = 12; break; - case PckFileType.CapeFile: + case PckAssetType.CapeFile: node.ImageIndex = 13; node.SelectedImageIndex = 13; break; - case PckFileType.TextureFile: + case PckAssetType.TextureFile: node.ImageIndex = 14; node.SelectedImageIndex = 14; break; - case PckFileType.BehavioursFile: + case PckAssetType.BehavioursFile: node.ImageIndex = 15; node.SelectedImageIndex = 15; break; - case PckFileType.MaterialFile: + case PckAssetType.MaterialFile: node.ImageIndex = 16; node.SelectedImageIndex = 16; break; @@ -2096,12 +2096,12 @@ namespace PckStudio } } - private void SetFileType(PckFileType type) + private void SetFileType(PckAssetType type) { - if (treeViewMain.SelectedNode.TryGetTagData(out PckFileData file)) + if (treeViewMain.SelectedNode.TryGetTagData(out PckAsset file)) { - Debug.WriteLine($"Setting {file.Filetype} to {type}"); - file.Filetype = type; + Debug.WriteLine($"Setting {file.Type} to {type}"); + file.Type = type; SetNodeIcon(treeViewMain.SelectedNode, type); RebuildSubPCK(treeViewMain.SelectedNode.FullPath); } @@ -2118,12 +2118,12 @@ namespace PckStudio renamePrompt.LabelText = "Path"; if (renamePrompt.ShowDialog(this) == DialogResult.OK && !string.IsNullOrEmpty(renamePrompt.NewText)) { - if (currentPCK.Contains(renamePrompt.NewText, PckFileType.TextureFile)) + if (currentPCK.Contains(renamePrompt.NewText, PckAssetType.TextureFile)) { MessageBox.Show(this, $"'{renamePrompt.NewText}' already exists.", "Import failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } - PckFileData file = currentPCK.CreateNewFile(renamePrompt.NewText, PckFileType.TextureFile, () => File.ReadAllBytes(fileDialog.FileName)); + PckAsset file = currentPCK.CreateNewFile(renamePrompt.NewText, PckAssetType.TextureFile, () => File.ReadAllBytes(fileDialog.FileName)); BuildMainTreeView(); wasModified = true; } @@ -2132,11 +2132,11 @@ namespace PckStudio private void viewFileInfoToolStripMenuItem_Click(object sender, EventArgs e) { - if (treeViewMain.SelectedNode.Tag is PckFileData file) + if (treeViewMain.SelectedNode.Tag is PckAsset file) { MessageBox.Show(this, "File path: " + file.Filename + - "\nAssigned File type: " + (int)file.Filetype + " (" + file.Filetype + ")" + + "\nAssigned File type: " + (int)file.Type + " (" + file.Type + ")" + "\nFile size: " + file.Size + "\nProperties count: " + file.PropertyCount , Path.GetFileName(file.Filename) + " file info"); @@ -2145,7 +2145,7 @@ namespace PckStudio private void generateMipMapTextureToolStripMenuItem_Click(object sender, EventArgs e) { - if (treeViewMain.SelectedNode.Tag is PckFileData file && file.Filetype == PckFileType.TextureFile) + if (treeViewMain.SelectedNode.Tag is PckAsset file && file.Type == PckAssetType.TextureFile) { string textureDirectory = Path.GetDirectoryName(file.Filename); string textureName = Path.GetFileNameWithoutExtension(file.Filename); @@ -2168,9 +2168,9 @@ namespace PckStudio { string mippedPath = $"{textureDirectory}/{textureName}MipMapLevel{i}{textureExtension}"; Debug.WriteLine(mippedPath); - if (currentPCK.HasFile(mippedPath, PckFileType.TextureFile)) - currentPCK.RemoveFile(currentPCK.GetFile(mippedPath, PckFileType.TextureFile)); - PckFileData MipMappedFile = new PckFileData(mippedPath, PckFileType.TextureFile); + if (currentPCK.HasFile(mippedPath, PckAssetType.TextureFile)) + currentPCK.RemoveFile(currentPCK.GetFile(mippedPath, PckAssetType.TextureFile)); + PckAsset MipMappedFile = new PckAsset(mippedPath, PckAssetType.TextureFile); Image originalTexture = file.GetTexture(); @@ -2198,12 +2198,12 @@ namespace PckStudio private void colourscolToolStripMenuItem_Click(object sender, EventArgs e) { - if (currentPCK.TryGetFile("colours.col", PckFileType.ColourTableFile, out _)) + if (currentPCK.TryGetFile("colours.col", PckAssetType.ColourTableFile, out _)) { MessageBox.Show(this, "A color table file already exists in this PCK and a new one cannot be created.", "Operation aborted"); return; } - PckFileData newColorFile = currentPCK.CreateNewFile("colours.col", PckFileType.ColourTableFile); + PckAsset newColorFile = currentPCK.CreateNewFile("colours.col", PckAssetType.ColourTableFile); newColorFile.SetData(Resources.tu69colours); BuildMainTreeView(); } @@ -2215,8 +2215,8 @@ namespace PckStudio private void as3DSTextureFileToolStripMenuItem_Click(object sender, EventArgs e) { - if (treeViewMain.SelectedNode.TryGetTagData(out PckFileData file) && - file.Filetype == PckFileType.SkinFile) + if (treeViewMain.SelectedNode.TryGetTagData(out PckAsset file) && + file.Type == PckAssetType.SkinFile) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "3DS Texture|*.3dst"; @@ -2232,7 +2232,7 @@ namespace PckStudio private void addMultipleEntriesToolStripMenuItem1_Click(object sender, EventArgs e) { - if (treeViewMain.SelectedNode.TryGetTagData(out PckFileData file)) + if (treeViewMain.SelectedNode.TryGetTagData(out PckAsset file)) { using (var input = new MultiTextPrompt()) { @@ -2255,8 +2255,8 @@ namespace PckStudio private void correctSkinDecimalsToolStripMenuItem_Click(object sender, EventArgs e) { - if (treeViewMain.SelectedNode.TryGetTagData(out PckFileData file) && - file.Filetype == PckFileType.SkinFile) + if (treeViewMain.SelectedNode.TryGetTagData(out PckAsset file) && + file.Type == PckAssetType.SkinFile) { foreach (KeyValuePair p in file.GetProperties().ToList()) { @@ -2271,13 +2271,13 @@ namespace PckStudio private void CreateSkinsPCKToolStripMenuItem1_Click(object sender, EventArgs e) { - if (currentPCK.TryGetFile("Skins.pck", PckFileType.SkinDataFile, out _)) + if (currentPCK.TryGetFile("Skins.pck", PckAssetType.SkinDataFile, out _)) { MessageBox.Show(this, "A Skins.pck file already exists in this PCK and a new one cannot be created.", "Operation aborted"); return; } - currentPCK.CreateNewFile("Skins.pck", PckFileType.SkinDataFile, new PckFileWriter(new PckFile(3, true), + currentPCK.CreateNewFile("Skins.pck", PckAssetType.SkinDataFile, new PckFileWriter(new PckFile(3, true), LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian)); BuildMainTreeView(); @@ -2291,7 +2291,7 @@ namespace PckStudio private void editAllEntriesToolStripMenuItem_Click(object sender, EventArgs e) { - if (treeViewMain.SelectedNode.TryGetTagData(out PckFileData file)) + if (treeViewMain.SelectedNode.TryGetTagData(out PckAsset file)) { string[] props = file.GetProperties().Select(p => p.Key + " " + p.Value).ToArray(); using (var input = new MultiTextPrompt(props)) @@ -2332,7 +2332,7 @@ namespace PckStudio MessageBox.Show(this, $"'{diag.Filepath}' of type {diag.Filetype} already exists.", "Import failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } - PckFileData file = currentPCK.CreateNewFile(diag.Filepath, diag.Filetype, () => File.ReadAllBytes(ofd.FileName)); + PckAsset file = currentPCK.CreateNewFile(diag.Filepath, diag.Filetype, () => File.ReadAllBytes(ofd.FileName)); RebuildSubPCK(treeViewMain.SelectedNode.FullPath); @@ -2345,24 +2345,24 @@ namespace PckStudio private void behavioursbinToolStripMenuItem_Click(object sender, EventArgs e) { - if (currentPCK.TryGetFile("behaviours.bin", PckFileType.BehavioursFile, out _)) + if (currentPCK.TryGetFile("behaviours.bin", PckAssetType.BehavioursFile, out _)) { MessageBox.Show(this, "A behaviours file already exists in this PCK and a new one cannot be created.", "Operation aborted"); return; } - currentPCK.CreateNewFile("behaviours.bin", PckFileType.BehavioursFile, BehaviourResources.BehaviourFileInitializer); + currentPCK.CreateNewFile("behaviours.bin", PckAssetType.BehavioursFile, BehaviourResources.BehaviourFileInitializer); BuildMainTreeView(); } private void entityMaterialsbinToolStripMenuItem_Click(object sender, EventArgs e) { - if (currentPCK.TryGetFile("entityMaterials.bin", PckFileType.MaterialFile, out _)) + if (currentPCK.TryGetFile("entityMaterials.bin", PckAssetType.MaterialFile, out _)) { MessageBox.Show(this, "A behaviours file already exists in this PCK and a new one cannot be created.", "Operation aborted"); return; } - currentPCK.CreateNewFile("entityMaterials.bin", PckFileType.MaterialFile, MaterialResources.MaterialsFileInitializer); + currentPCK.CreateNewFile("entityMaterials.bin", PckAssetType.MaterialFile, MaterialResources.MaterialsFileInitializer); BuildMainTreeView(); } @@ -2427,7 +2427,7 @@ namespace PckStudio private void addBOXEntryToolStripMenuItem1_Click(object sender, EventArgs e) { - if (treeViewMain.SelectedNode is TreeNode t && t.Tag is PckFileData file) + if (treeViewMain.SelectedNode is TreeNode t && t.Tag is PckAsset file) { using BoxEditor diag = new BoxEditor(SkinBOX.Empty, IsSubPCKNode(treeViewMain.SelectedNode.FullPath)); if (diag.ShowDialog(this) == DialogResult.OK) @@ -2443,7 +2443,7 @@ namespace PckStudio private void addANIMEntryToolStripMenuItem1_Click(object sender, EventArgs e) { - if (treeViewMain.SelectedNode.TryGetTagData(out PckFileData file)) + if (treeViewMain.SelectedNode.TryGetTagData(out PckAsset file)) { using ANIMEditor diag = new ANIMEditor(SkinANIM.Empty); if (diag.ShowDialog(this) == DialogResult.OK) @@ -2470,20 +2470,20 @@ namespace PckStudio [Obsolete] // the move functions are to eventually be removed in favor of drag and drop private void moveFile(int amount) { - if (treeViewMain.SelectedNode is not TreeNode t || t.Tag is not PckFileData) + if (treeViewMain.SelectedNode is not TreeNode t || t.Tag is not PckAsset) return; - PckFileData file = t.Tag as PckFileData; + PckAsset file = t.Tag as PckAsset; string path = t.FullPath; // skin and cape files only - if (!(file.Filetype == PckFileType.SkinFile || file.Filetype == PckFileType.CapeFile)) return; + if (!(file.Type == PckAssetType.SkinFile || file.Type == PckAssetType.CapeFile)) return; PckFile pck = currentPCK; bool IsSubPCK = IsSubPCKNode(path); if (IsSubPCK) { - using (var stream = new MemoryStream((GetSubPCK(path).Tag as PckFileData).Data)) + using (var stream = new MemoryStream((GetSubPCK(path).Tag as PckAsset).Data)) { var reader = new PckFileReader(LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian); pck = reader.FromStream(stream); @@ -2504,7 +2504,7 @@ namespace PckStudio { var writer = new PckFileWriter(pck, LittleEndianCheckBox.Checked ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian); writer.WriteToStream(stream); - (GetSubPCK(path).Tag as PckFileData).SetData(stream.ToArray()); + (GetSubPCK(path).Tag as PckAsset).SetData(stream.ToArray()); } } BuildMainTreeView(); @@ -2529,14 +2529,14 @@ namespace PckStudio { try { - if (treeViewMain.SelectedNode.Tag is PckFileData file && (file.Filetype is PckFileType.AudioFile || file.Filetype is PckFileType.SkinDataFile || file.Filetype is PckFileType.TexturePackInfoFile)) + if (treeViewMain.SelectedNode.Tag is PckAsset file && (file.Type is PckAssetType.AudioFile || file.Type is PckAssetType.SkinDataFile || file.Type is PckAssetType.TexturePackInfoFile)) { - IDataFormatReader reader = file.Filetype is PckFileType.AudioFile + IDataFormatReader reader = file.Type is PckAssetType.AudioFile ? new PckAudioFileReader(endianness == OMI.Endianness.BigEndian ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian) : new PckFileReader(endianness == OMI.Endianness.BigEndian ? OMI.Endianness.LittleEndian : OMI.Endianness.BigEndian); object pck = reader.FromStream(new MemoryStream(file.Data)); - IDataFormatWriter writer = file.Filetype is PckFileType.AudioFile + IDataFormatWriter writer = file.Type is PckAssetType.AudioFile ? new PckAudioFileWriter((PckAudioFile)pck, endianness) : new PckFileWriter((PckFile)pck, endianness); file.SetData(writer); @@ -2561,7 +2561,7 @@ namespace PckStudio private void SetModelVersion(int version) { - if (treeViewMain.SelectedNode.Tag is PckFileData file && file.Filetype is PckFileType.ModelsFile) + if (treeViewMain.SelectedNode.Tag is PckAsset file && file.Type is PckAssetType.ModelsFile) { try { diff --git a/Vendor/OMI-Lib b/Vendor/OMI-Lib index a3505bbf..06839b53 160000 --- a/Vendor/OMI-Lib +++ b/Vendor/OMI-Lib @@ -1 +1 @@ -Subproject commit a3505bbf31e9bc6f3380b7d8df3bc7741d0355f0 +Subproject commit 06839b53671c1280087633cdcf9eacab8aed46d6