Merge branch 'main' into '3dSkinRenderer'

This commit is contained in:
miku-666
2024-04-21 14:00:22 +02:00
26 changed files with 251 additions and 1370 deletions

View File

@@ -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;
}
/// <summary>
/// Creates a new FTP Request
/// </summary>
/// <param name="uri"></param>
/// <param name="credentials"></param>
/// <param name="method">See <see cref="WebRequestMethods.Ftp"/></param>
/// <returns><see cref="FtpWebRequest"/></returns>
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<string> text = new List<string>();
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<string>();
}
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;
}
}
}

View File

@@ -21,11 +21,11 @@ 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.");
}
@@ -38,9 +38,9 @@ namespace PckStudio.Extensions
/// <param name="file"></param>
/// <returns>Non-zero base number on success, otherwise 0</returns>
/// <exception cref="InvalidOperationException"></exception>
internal static int GetSkinId(this PckFileData file)
internal static int GetSkinId(this PckAsset file)
{
if (file.Filetype != PckFileType.SkinFile)
if (file.Type != PckAssetType.SkinFile)
throw new InvalidOperationException("File is not a skin file");
string filename = Path.GetFileNameWithoutExtension(file.Filename);
@@ -58,9 +58,9 @@ namespace PckStudio.Extensions
return skinId;
}
internal static Skin GetSkin(this PckFileData file)
internal static Skin GetSkin(this PckAsset file)
{
if (file.Filetype != PckFileType.SkinFile)
if (file.Type != PckAssetType.SkinFile)
throw new InvalidOperationException("File is not a skin file");
//if (file.Properties.Contains("CAPEPATH"))
@@ -76,9 +76,9 @@ namespace PckStudio.Extensions
return new Skin(name, skinId, texture, anim, boxes, offsets);
}
internal static void SetSkin(this PckFileData file, Skin skin, LOCFile localizationFile)
internal static void SetSkin(this PckAsset file, Skin skin, LOCFile localizationFile)
{
if (file.Filetype != PckFileType.SkinFile)
if (file.Type != PckAssetType.SkinFile)
throw new InvalidOperationException("File is not a skin file");
file.SetTexture(skin.Texture);
@@ -122,23 +122,23 @@ namespace PckStudio.Extensions
}
}
internal static T GetDeserializedData<T>(this PckFileData file, IPckDeserializer<T> deserializer)
internal static T GetDeserializedData<T>(this PckAsset file, IPckDeserializer<T> deserializer)
{
return deserializer.Deserialize(file);
}
internal static T GetData<T>(this PckFileData file, IDataFormatReader<T> formatReader) where T : class
internal static T GetData<T>(this PckAsset file, IDataFormatReader<T> formatReader) where T : class
{
using var ms = new MemoryStream(file.Data);
return formatReader.FromStream(ms);
}
internal static void SetSerializedData<T>(this PckFileData file, T obj, IPckFileSerializer<T> serializer)
internal static void SetSerializedData<T>(this PckAsset file, T obj, IPckSerializer<T> serializer)
{
serializer.Serialize(obj, ref file);
}
internal static void SetData(this PckFileData file, IDataFormatWriter formatWriter)
internal static void SetData(this PckAsset file, IDataFormatWriter formatWriter)
{
using (var stream = new MemoryStream())
{
@@ -147,18 +147,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);
@@ -173,7 +173,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;

View File

@@ -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);

View File

@@ -12,10 +12,10 @@ namespace PckStudio.Extensions
{
internal static class SkinExtensions
{
public static PckFileData CreateFile(this Skin skin, LOCFile localizationFile)
public static PckAsset CreateFile(this Skin skin, LOCFile localizationFile)
{
string skinId = skin.Id.ToString("d08");
PckFileData skinFile = new PckFileData($"dlcskin{skinId}.png", PckFileType.SkinFile);
PckAsset skinFile = new PckAsset($"dlcskin{skinId}.png", PckAssetType.SkinFile);
skinFile.AddProperty("DISPLAYNAME", skin.Name);
if (localizationFile is not null)
@@ -58,12 +58,12 @@ namespace PckStudio.Extensions
return skinFile;
}
public static PckFileData CreateCapeFile(this Skin skin)
public static PckAsset CreateCapeFile(this Skin skin)
{
if (!skin.HasCape)
throw new InvalidOperationException("Skin does not contain a cape.");
string skinId = skin.Id.ToString("d08");
PckFileData capeFile = new PckFileData($"dlccape{skinId}.png", PckFileType.CapeFile);
PckAsset capeFile = new PckAsset($"dlccape{skinId}.png", PckAssetType.CapeFile);
capeFile.SetTexture(skin.CapeTexture);
return capeFile;
}

View File

@@ -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."),

View File

@@ -1,428 +0,0 @@
namespace PckStudio.Features
{
partial class WiiUPanel
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@@ -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;
}
}
}

View File

@@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStripCaffiine.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@@ -12,7 +12,7 @@ namespace PckStudio.Popups
/// otherwise <see cref="string.Empty"/>
/// </summary>
public string Filepath => DialogResult == DialogResult.OK ? InputTextBox.Text : string.Empty;
public PckFileType Filetype => (PckFileType)(FileTypeComboBox.SelectedIndex + (FileTypeComboBox.SelectedIndex >= 3 ? 1 : 0));
public PckAssetType Filetype => (PckAssetType)(FileTypeComboBox.SelectedIndex + (FileTypeComboBox.SelectedIndex >= 3 ? 1 : 0));
public AddFilePrompt(string initialText) : this(initialText, -1)
{ }

View File

@@ -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();

View File

@@ -21,7 +21,7 @@ namespace PckStudio.Forms.Editor
public partial class BehaviourEditor : MetroForm
{
// Behaviours File Format research by Miku and MattNL
private readonly PckFileData _file;
private readonly PckAsset _file;
BehaviourFile behaviourFile;
private readonly List<EntityInfo> BehaviourData = Entities.BehaviourInfos;
@@ -54,7 +54,7 @@ namespace PckStudio.Forms.Editor
treeView1.EndUpdate();
}
public BehaviourEditor(PckFileData file)
public BehaviourEditor(PckAsset file)
{
InitializeComponent();

View File

@@ -19,14 +19,14 @@ namespace PckStudio.Forms.Editor
ColorContainer colourfile;
string clipboard_color = "#FFFFFF";
private readonly PckFileData _file;
private readonly PckAsset _file;
List<TreeNode> colorCache = new List<TreeNode>();
List<TreeNode> waterCache = new List<TreeNode>();
List<TreeNode> underwaterCache = new List<TreeNode>();
List<TreeNode> fogCache = new List<TreeNode>();
public COLEditor(PckFileData file)
public COLEditor(PckAsset file)
{
InitializeComponent();

View File

@@ -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;

View File

@@ -19,7 +19,7 @@ namespace PckStudio.Forms.Editor
public partial class MaterialsEditor : MetroForm
{
// Materials File Format research by PhoenixARC
private readonly PckFileData _file;
private readonly PckAsset _file;
MaterialContainer materialFile;
private readonly List<EntityInfo> MaterialData = Entities.BehaviourInfos;
@@ -64,7 +64,7 @@ namespace PckStudio.Forms.Editor
treeView1.EndUpdate();
}
public MaterialsEditor(PckFileData file)
public MaterialsEditor(PckAsset file)
{
InitializeComponent();
_file = file;

View File

@@ -170,7 +170,7 @@ namespace PckStudio.Forms.Editor
private bool AcquireColorTable(PckFile pckFile)
{
if (pckFile.TryGetFile("colours.col", PckFileType.ColourTableFile, out var colFile) &&
if (pckFile.TryGetFile("colours.col", PckAssetType.ColourTableFile, out var colFile) &&
colFile.Size > 0)
{
using var ms = new MemoryStream(colFile.Data);
@@ -243,11 +243,11 @@ namespace PckStudio.Forms.Editor
if (animationButton.Enabled = _atlasType == "blocks" || _atlasType == "items")
{
PckFileData animationFile;
PckAsset animationFile;
bool hasAnimation =
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.png", PckFileType.TextureFile, out animationFile) ||
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.tga", PckFileType.TextureFile, out animationFile);
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.png", PckAssetType.TextureFile, out animationFile) ||
_pckFile.TryGetValue($"res/textures/{_atlasType}/{dataTile.Tile.InternalName}.tga", PckAssetType.TextureFile, out animationFile);
animationButton.Text = hasAnimation ? "Edit Animation" : "Create Animation";
if (playAnimationsToolStripMenuItem.Checked &&
@@ -535,7 +535,7 @@ namespace PckStudio.Forms.Editor
{
var file = _pckFile.GetOrCreate(
$"res/textures/{_atlasType}/{_selectedTile.Tile.InternalName}.png",
PckFileType.TextureFile
PckAssetType.TextureFile
);
var animation = file.GetDeserializedData(AnimationDeserializer.DefaultDeserializer);

View File

@@ -44,12 +44,12 @@ namespace PckStudio.Popups
MessageBox.Show(this, "Please select a filetype before applying");
}
private void applyBulkProperties(IReadOnlyCollection<PckFileData> files, int index)
private void applyBulkProperties(IReadOnlyCollection<PckAsset> files, int index)
{
foreach (PckFileData file in files)
foreach (PckAsset file in files)
{
if (file.Filetype == PckFileType.TexturePackInfoFile ||
file.Filetype == PckFileType.SkinDataFile)
if (file.Type == PckAssetType.TexturePackInfoFile ||
file.Type == PckAssetType.SkinDataFile)
{
try
{
@@ -65,15 +65,15 @@ namespace PckStudio.Popups
}
}
if (index == -1 || (Enum.IsDefined(typeof(PckFileType), index) && (int)file.Filetype == index))
if (index == -1 || (Enum.IsDefined(typeof(PckAssetType), index) && (int)file.Type == index))
{
file.AddProperty(propertyKeyTextBox.Text, propertyValueTextBox.Text);
}
}
if (Enum.IsDefined(typeof(PckFileType), index))
if (Enum.IsDefined(typeof(PckAssetType), index))
{
MessageBox.Show(this, $"Data added to {(PckFileType)index} entries");
MessageBox.Show(this, $"Data added to {(PckAssetType)index} entries");
return;
}
MessageBox.Show(this, "Data added to all entries");

View File

@@ -9,6 +9,6 @@ namespace PckStudio.Interfaces
{
internal interface IPckDeserializer<T>
{
public T Deserialize(PckFileData file);
public T Deserialize(PckAsset file);
}
}

View File

@@ -7,8 +7,8 @@ using OMI.Formats.Pck;
namespace PckStudio.Interfaces
{
internal interface IPckFileSerializer<T>
internal interface IPckSerializer<T>
{
public void Serialize(T obj, ref PckFileData file);
public void Serialize(T obj, ref PckAsset file);
}
}

View File

@@ -16,7 +16,7 @@ namespace PckStudio.Internal.Deserializer
{
public static readonly AnimationDeserializer DefaultDeserializer = new AnimationDeserializer();
public Animation Deserialize(PckFileData file)
public Animation Deserialize(PckAsset file)
{
_ = file ?? throw new ArgumentNullException(nameof(file));
if (file.Size > 0)

View File

@@ -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

View File

@@ -15,8 +15,8 @@ namespace PckStudio.Internal
private bool CheckForSkinAndCapeFiles(TreeNode node)
{
return node.TryGetTagData(out PckFileData file) &&
(file.Filetype == PckFileType.SkinFile || file.Filetype == PckFileType.CapeFile);
return node.TryGetTagData(out PckAsset file) &&
(file.Type == PckAssetType.SkinFile || file.Type == PckAssetType.CapeFile);
}
public int Compare(object x, object y)
@@ -39,9 +39,9 @@ namespace PckStudio.Internal
private int InternalCompare(TreeNode first, TreeNode second)
{
if (first.IsTagOfType<PckFileData>() && !second.IsTagOfType<PckFileData>())
if (first.IsTagOfType<PckAsset>() && !second.IsTagOfType<PckAsset>())
return -1;
if (!first.IsTagOfType<PckFileData>() && second.IsTagOfType<PckFileData>())
if (!first.IsTagOfType<PckAsset>() && second.IsTagOfType<PckAsset>())
return 1;
if (CheckForSkinAndCapeFiles(first))

View File

@@ -13,11 +13,11 @@ using PckStudio.Interfaces;
namespace PckStudio.Internal.Serializer
{
internal sealed class AnimationSerializer : IPckFileSerializer<Animation>
internal sealed class AnimationSerializer : IPckSerializer<Animation>
{
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);

View File

@@ -13,11 +13,11 @@ using PckStudio.IO.TGA;
namespace PckStudio.Internal.Serializer
{
internal sealed class ImageSerializer : IPckFileSerializer<Image>
internal sealed class ImageSerializer : IPckSerializer<Image>
{
public static readonly ImageSerializer DefaultSerializer = new ImageSerializer();
public void Serialize(Image obj, ref PckFileData file)
public void Serialize(Image obj, ref PckAsset file)
{
var stream = new MemoryStream();
try

File diff suppressed because it is too large Load Diff

View File

@@ -150,7 +150,7 @@
<Compile Include="Internal\Serializer\AnimationSerializer.cs" />
<Compile Include="Internal\Deserializer\AnimationDeserializer.cs" />
<Compile Include="Interfaces\IPckDeserializer.cs" />
<Compile Include="Interfaces\IPckFileSerializer.cs" />
<Compile Include="Interfaces\IPckSerializer.cs" />
<Compile Include="Internal\Json\Entities.cs" />
<Compile Include="Internal\Json\EntityInfo.cs" />
<Compile Include="Internal\ResourceCategory.cs" />
@@ -254,7 +254,6 @@
<Compile Include="Classes\IO\PSM\PSMFileWriter.cs" />
<Compile Include="Classes\IO\PckAudio\PckAudioFileReader.cs" />
<Compile Include="Classes\IO\PckAudio\PckAudioFileWriter.cs" />
<Compile Include="Classes\Misc\FTPClient.cs" />
<Compile Include="Classes\Misc\FileCacher.cs" />
<Compile Include="Classes\Misc\OpenFolderDialog.cs" />
<Compile Include="Internal\ApplicationScope.cs" />
@@ -273,12 +272,6 @@
<Compile Include="Features\CemuPanel.Designer.cs">
<DependentUpon>CemuPanel.cs</DependentUpon>
</Compile>
<Compile Include="Features\WiiUPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Features\WiiUPanel.Designer.cs">
<DependentUpon>WiiUPanel.cs</DependentUpon>
</Compile>
<Compile Include="Classes\IO\TGA\TGAFileData.cs" />
<Compile Include="Classes\IO\TGA\TGADataTypeCode.cs" />
<Compile Include="Classes\IO\TGA\TGAException.cs" />
@@ -474,9 +467,6 @@
<EmbeddedResource Include="Features\CemuPanel.resx">
<DependentUpon>CemuPanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Features\WiiUPanel.resx">
<DependentUpon>WiiUPanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Additional-Popups\EntityForms\AddEntry.resx">
<DependentUpon>AddEntry.cs</DependentUpon>
<SubType>Designer</SubType>

2
Vendor/OMI-Lib vendored