This commit is contained in:
miku-666
2023-06-11 19:45:38 +02:00
23 changed files with 3035 additions and 3005 deletions

View File

@@ -20,7 +20,7 @@ namespace PckStudio.Classes.Misc
{
new Button()
{
Label = "Check it out.",
Label = "Check it out!",
Url = Program.ProjectUrl,
}
};

View File

@@ -1,32 +0,0 @@
using OMI.Workers.Archive;
using System.IO;
namespace PckStudio.Classes.Utils.ARC
{
public static class ARCUtil
{
public static void Inject(Stream stream, (string filepath, byte[] data) entry)
{
var reader = new ARCFileReader();
var archive = reader.FromStream(stream);
archive.Add(entry.filepath, entry.data);
var writer = new ARCFileWriter(archive);
stream.Seek(0, SeekOrigin.Begin);
writer.WriteToStream(stream);
}
public static bool ContainsFile(Stream stream, string filepath)
{
var reader = new ARCFileReader();
var archive = reader.FromStream(stream);
return archive.ContainsKey(filepath);
}
public static void Remove(Stream stream, string filepath)
{
var reader = new ARCFileReader();
var archive = reader.FromStream(stream);
archive.Remove(filepath);
}
}
}

View File

@@ -251,7 +251,7 @@ namespace PckStudio.Features
private void addCustomPckToolStripMenuItem_Click(object sender, EventArgs e)
{
RenamePrompt prompt = new RenamePrompt(string.Empty);
TextPrompt prompt = new TextPrompt(string.Empty);
prompt.OKButton.Text = "OK";
prompt.TextLabel.Text = "Folder:";

View File

@@ -0,0 +1,121 @@
namespace PckStudio.Forms.Additional_Popups
{
partial class MultiTextPrompt
{
/// <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 Windows Form 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.PromptTextBox = new MetroFramework.Controls.MetroTextBox();
this.okBtn = new MetroFramework.Controls.MetroButton();
this.cancelBtn = new MetroFramework.Controls.MetroButton();
this.SuspendLayout();
//
// PromptTextBox
//
//
//
//
this.PromptTextBox.CustomButton.Image = null;
this.PromptTextBox.CustomButton.Location = new System.Drawing.Point(34, 1);
this.PromptTextBox.CustomButton.Name = "";
this.PromptTextBox.CustomButton.Size = new System.Drawing.Size(283, 283);
this.PromptTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
this.PromptTextBox.CustomButton.TabIndex = 1;
this.PromptTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
this.PromptTextBox.CustomButton.UseSelectable = true;
this.PromptTextBox.CustomButton.Visible = false;
this.PromptTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.PromptTextBox.Lines = new string[0];
this.PromptTextBox.Location = new System.Drawing.Point(20, 60);
this.PromptTextBox.MaxLength = 32767;
this.PromptTextBox.Multiline = true;
this.PromptTextBox.Name = "PromptTextBox";
this.PromptTextBox.PasswordChar = '\0';
this.PromptTextBox.PromptText = "Paste Multi-line text here...";
this.PromptTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.PromptTextBox.SelectedText = "";
this.PromptTextBox.SelectionLength = 0;
this.PromptTextBox.SelectionStart = 0;
this.PromptTextBox.ShortcutsEnabled = true;
this.PromptTextBox.ShowClearButton = true;
this.PromptTextBox.Size = new System.Drawing.Size(318, 285);
this.PromptTextBox.Style = MetroFramework.MetroColorStyle.Black;
this.PromptTextBox.TabIndex = 0;
this.PromptTextBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.PromptTextBox.UseSelectable = true;
this.PromptTextBox.WaterMark = "Paste Multi-line text here...";
this.PromptTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
this.PromptTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
//
// okBtn
//
this.okBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.okBtn.Location = new System.Drawing.Point(264, 351);
this.okBtn.Name = "okBtn";
this.okBtn.Size = new System.Drawing.Size(74, 23);
this.okBtn.TabIndex = 1;
this.okBtn.Text = "OK";
this.okBtn.Theme = MetroFramework.MetroThemeStyle.Dark;
this.okBtn.UseSelectable = true;
this.okBtn.Click += new System.EventHandler(this.okBtn_Click);
//
// cancelBtn
//
this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancelBtn.Location = new System.Drawing.Point(183, 351);
this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Size = new System.Drawing.Size(75, 23);
this.cancelBtn.TabIndex = 2;
this.cancelBtn.Text = "Cancel";
this.cancelBtn.Theme = MetroFramework.MetroThemeStyle.Dark;
this.cancelBtn.UseSelectable = true;
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
//
// TextPrompt
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(358, 385);
this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.okBtn);
this.Controls.Add(this.PromptTextBox);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(270, 335);
this.Name = "TextPrompt";
this.Padding = new System.Windows.Forms.Padding(20, 60, 20, 40);
this.Style = MetroFramework.MetroColorStyle.Black;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.ResumeLayout(false);
}
#endregion
private MetroFramework.Controls.MetroTextBox PromptTextBox;
private MetroFramework.Controls.MetroButton okBtn;
private MetroFramework.Controls.MetroButton cancelBtn;
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Windows.Forms;
namespace PckStudio.Forms.Additional_Popups
{
public partial class MultiTextPrompt : MetroFramework.Forms.MetroForm
{
public string[] TextOutput => DialogResult == DialogResult.OK ? PromptTextBox.Lines : Array.Empty<string>();
public MultiTextPrompt(string[] list = null)
{
InitializeComponent();
PromptTextBox.Lines = list;
}
private void okBtn_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void cancelBtn_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}

View File

@@ -0,0 +1,120 @@
<?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>
</root>

View File

@@ -28,61 +28,61 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NumericPrompt));
this.TextLabel = new System.Windows.Forms.Label();
this.OKButton = new System.Windows.Forms.Button();
this.ContextLabel = new MetroFramework.Controls.MetroLabel();
this.ValueUpDown = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.ValueUpDown)).BeginInit();
this.SuspendLayout();
//
// TextLabel
//
resources.ApplyResources(this.TextLabel, "TextLabel");
this.TextLabel.ForeColor = System.Drawing.Color.White;
this.TextLabel.Name = "TextLabel";
//
// OKButton
//
resources.ApplyResources(this.OKButton, "OKButton");
this.OKButton.ForeColor = System.Drawing.Color.White;
this.OKButton.Name = "OKButton";
this.OKButton.UseVisualStyleBackColor = true;
this.OKButton.Click += new System.EventHandler(this.OKBtn_Click);
//
// ContextLabel
//
resources.ApplyResources(this.ContextLabel, "ContextLabel");
this.ContextLabel.FontSize = MetroFramework.MetroLabelSize.Small;
this.ContextLabel.Name = "ContextLabel";
this.ContextLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
this.ContextLabel.WrapToLine = true;
//
// ValueUpDown
//
resources.ApplyResources(this.ValueUpDown, "ValueUpDown");
this.ValueUpDown.Name = "ValueUpDown";
//
// NumericPrompt
//
this.AcceptButton = this.OKButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.ValueUpDown);
this.Controls.Add(this.ContextLabel);
this.Controls.Add(this.OKButton);
this.Controls.Add(this.TextLabel);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NumericPrompt";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.Load += new System.EventHandler(this.RenamePrompt_Load);
((System.ComponentModel.ISupportInitialize)(this.ValueUpDown)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NumericPrompt));
this.TextLabel = new System.Windows.Forms.Label();
this.OKButton = new System.Windows.Forms.Button();
this.ContextLabel = new MetroFramework.Controls.MetroLabel();
this.ValueUpDown = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.ValueUpDown)).BeginInit();
this.SuspendLayout();
//
// TextLabel
//
resources.ApplyResources(this.TextLabel, "TextLabel");
this.TextLabel.ForeColor = System.Drawing.Color.White;
this.TextLabel.Name = "TextLabel";
//
// OKButton
//
resources.ApplyResources(this.OKButton, "OKButton");
this.OKButton.ForeColor = System.Drawing.Color.White;
this.OKButton.Name = "OKButton";
this.OKButton.UseVisualStyleBackColor = true;
this.OKButton.Click += new System.EventHandler(this.OKBtn_Click);
//
// ContextLabel
//
resources.ApplyResources(this.ContextLabel, "ContextLabel");
this.ContextLabel.FontSize = MetroFramework.MetroLabelSize.Small;
this.ContextLabel.Name = "ContextLabel";
this.ContextLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
this.ContextLabel.WrapToLine = true;
//
// ValueUpDown
//
resources.ApplyResources(this.ValueUpDown, "ValueUpDown");
this.ValueUpDown.Name = "ValueUpDown";
//
// NumericPrompt
//
this.AcceptButton = this.OKButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.ValueUpDown);
this.Controls.Add(this.ContextLabel);
this.Controls.Add(this.OKButton);
this.Controls.Add(this.TextLabel);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "NumericPrompt";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.Load += new System.EventHandler(this.RenamePrompt_Load);
((System.ComponentModel.ISupportInitialize)(this.ValueUpDown)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}

View File

@@ -190,10 +190,10 @@
<value>Top</value>
</data>
<data name="ContextLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>28, 39</value>
<value>28, 27</value>
</data>
<data name="ContextLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>208, 39</value>
<value>208, 58</value>
</data>
<data name="ContextLabel.TabIndex" type="System.Int32, mscorlib">
<value>6</value>

View File

@@ -1,119 +0,0 @@
namespace PckStudio
{
partial class RenamePrompt
{
/// <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 Windows Form 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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RenamePrompt));
this.TextLabel = new System.Windows.Forms.Label();
this.OKButton = new System.Windows.Forms.Button();
this.InputTextBox = new MetroFramework.Controls.MetroTextBox();
this.contextLabel = new MetroFramework.Controls.MetroLabel();
this.SuspendLayout();
//
// TextLabel
//
resources.ApplyResources(this.TextLabel, "TextLabel");
this.TextLabel.ForeColor = System.Drawing.Color.White;
this.TextLabel.Name = "TextLabel";
//
// OKButton
//
resources.ApplyResources(this.OKButton, "OKButton");
this.OKButton.ForeColor = System.Drawing.Color.White;
this.OKButton.Name = "OKButton";
this.OKButton.UseVisualStyleBackColor = true;
this.OKButton.Click += new System.EventHandler(this.OKBtn_Click);
//
// InputTextBox
//
resources.ApplyResources(this.InputTextBox, "InputTextBox");
//
//
//
this.InputTextBox.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image")));
this.InputTextBox.CustomButton.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("resource.ImeMode")));
this.InputTextBox.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location")));
this.InputTextBox.CustomButton.Name = "";
this.InputTextBox.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size")));
this.InputTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
this.InputTextBox.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex")));
this.InputTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
this.InputTextBox.CustomButton.UseSelectable = true;
this.InputTextBox.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible")));
this.InputTextBox.Lines = new string[0];
this.InputTextBox.MaxLength = 255;
this.InputTextBox.Name = "InputTextBox";
this.InputTextBox.PasswordChar = '\0';
this.InputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.InputTextBox.SelectedText = "";
this.InputTextBox.SelectionLength = 0;
this.InputTextBox.SelectionStart = 0;
this.InputTextBox.ShortcutsEnabled = true;
this.InputTextBox.Style = MetroFramework.MetroColorStyle.White;
this.InputTextBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.InputTextBox.UseSelectable = true;
this.InputTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
this.InputTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
//
// contextLabel
//
resources.ApplyResources(this.contextLabel, "contextLabel");
this.contextLabel.FontSize = MetroFramework.MetroLabelSize.Small;
this.contextLabel.Name = "contextLabel";
this.contextLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
this.contextLabel.WrapToLine = true;
//
// RenamePrompt
//
this.AcceptButton = this.OKButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.contextLabel);
this.Controls.Add(this.InputTextBox);
this.Controls.Add(this.OKButton);
this.Controls.Add(this.TextLabel);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "RenamePrompt";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.Load += new System.EventHandler(this.RenamePrompt_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
public System.Windows.Forms.Button OKButton;
public System.Windows.Forms.Label TextLabel;
private MetroFramework.Controls.MetroTextBox InputTextBox;
public MetroFramework.Controls.MetroLabel contextLabel;
}
}

View File

@@ -1,42 +0,0 @@
using System;
using System.Windows.Forms;
using MetroFramework.Forms;
namespace PckStudio
{
public partial class RenamePrompt : MetroForm
{
/// <summary>
/// Text entered <c>only access when DialogResult == DialogResult.OK</c>
/// </summary>
public string NewText => InputTextBox.Text;
public RenamePrompt(string InitialText) : this(InitialText, -1)
{ }
public RenamePrompt(string InitialText, int maxChar)
{
InitializeComponent();
InputTextBox.Text = InitialText;
InputTextBox.MaxLength = maxChar < 0 ? short.MaxValue : maxChar;
}
private void OKBtn_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(InputTextBox.Text))
{
MessageBox.Show(this, "Please insert a value in the text box.", "Empty string");
}
else DialogResult = DialogResult.OK;
}
private void RenamePrompt_Load(object sender, EventArgs e)
{
if(String.IsNullOrEmpty(contextLabel.Text))
{
contextLabel.Visible = false;
Size = new System.Drawing.Size(264, 85);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
namespace PckStudio.Forms.Additional_Popups
namespace PckStudio
{
partial class TextPrompt
{
@@ -28,94 +28,92 @@
/// </summary>
private void InitializeComponent()
{
this.PromptTextBox = new MetroFramework.Controls.MetroTextBox();
this.okBtn = new MetroFramework.Controls.MetroButton();
this.cancelBtn = new MetroFramework.Controls.MetroButton();
this.SuspendLayout();
//
// PromptTextBox
//
//
//
//
this.PromptTextBox.CustomButton.Image = null;
this.PromptTextBox.CustomButton.Location = new System.Drawing.Point(34, 1);
this.PromptTextBox.CustomButton.Name = "";
this.PromptTextBox.CustomButton.Size = new System.Drawing.Size(283, 283);
this.PromptTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
this.PromptTextBox.CustomButton.TabIndex = 1;
this.PromptTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
this.PromptTextBox.CustomButton.UseSelectable = true;
this.PromptTextBox.CustomButton.Visible = false;
this.PromptTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.PromptTextBox.Lines = new string[0];
this.PromptTextBox.Location = new System.Drawing.Point(20, 60);
this.PromptTextBox.MaxLength = 32767;
this.PromptTextBox.Multiline = true;
this.PromptTextBox.Name = "PromptTextBox";
this.PromptTextBox.PasswordChar = '\0';
this.PromptTextBox.PromptText = "Paste Multi-line text here...";
this.PromptTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.PromptTextBox.SelectedText = "";
this.PromptTextBox.SelectionLength = 0;
this.PromptTextBox.SelectionStart = 0;
this.PromptTextBox.ShortcutsEnabled = true;
this.PromptTextBox.ShowClearButton = true;
this.PromptTextBox.Size = new System.Drawing.Size(318, 285);
this.PromptTextBox.Style = MetroFramework.MetroColorStyle.Black;
this.PromptTextBox.TabIndex = 0;
this.PromptTextBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.PromptTextBox.UseSelectable = true;
this.PromptTextBox.WaterMark = "Paste Multi-line text here...";
this.PromptTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
this.PromptTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
//
// okBtn
//
this.okBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.okBtn.Location = new System.Drawing.Point(264, 351);
this.okBtn.Name = "okBtn";
this.okBtn.Size = new System.Drawing.Size(74, 23);
this.okBtn.TabIndex = 1;
this.okBtn.Text = "OK";
this.okBtn.Theme = MetroFramework.MetroThemeStyle.Dark;
this.okBtn.UseSelectable = true;
this.okBtn.Click += new System.EventHandler(this.okBtn_Click);
//
// cancelBtn
//
this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancelBtn.Location = new System.Drawing.Point(183, 351);
this.cancelBtn.Name = "cancelBtn";
this.cancelBtn.Size = new System.Drawing.Size(75, 23);
this.cancelBtn.TabIndex = 2;
this.cancelBtn.Text = "Cancel";
this.cancelBtn.Theme = MetroFramework.MetroThemeStyle.Dark;
this.cancelBtn.UseSelectable = true;
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
//
// TextPrompt
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(358, 385);
this.Controls.Add(this.cancelBtn);
this.Controls.Add(this.okBtn);
this.Controls.Add(this.PromptTextBox);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(270, 335);
this.Name = "TextPrompt";
this.Padding = new System.Windows.Forms.Padding(20, 60, 20, 40);
this.Style = MetroFramework.MetroColorStyle.Black;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.ResumeLayout(false);
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TextPrompt));
this.TextLabel = new System.Windows.Forms.Label();
this.OKButton = new System.Windows.Forms.Button();
this.InputTextBox = new MetroFramework.Controls.MetroTextBox();
this.contextLabel = new MetroFramework.Controls.MetroLabel();
this.SuspendLayout();
//
// TextLabel
//
resources.ApplyResources(this.TextLabel, "TextLabel");
this.TextLabel.ForeColor = System.Drawing.Color.White;
this.TextLabel.Name = "TextLabel";
//
// OKButton
//
resources.ApplyResources(this.OKButton, "OKButton");
this.OKButton.ForeColor = System.Drawing.Color.White;
this.OKButton.Name = "OKButton";
this.OKButton.UseVisualStyleBackColor = true;
this.OKButton.Click += new System.EventHandler(this.OKBtn_Click);
//
// InputTextBox
//
resources.ApplyResources(this.InputTextBox, "InputTextBox");
//
//
//
this.InputTextBox.CustomButton.Image = ((System.Drawing.Image)(resources.GetObject("resource.Image")));
this.InputTextBox.CustomButton.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("resource.ImeMode")));
this.InputTextBox.CustomButton.Location = ((System.Drawing.Point)(resources.GetObject("resource.Location")));
this.InputTextBox.CustomButton.Name = "";
this.InputTextBox.CustomButton.Size = ((System.Drawing.Size)(resources.GetObject("resource.Size")));
this.InputTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
this.InputTextBox.CustomButton.TabIndex = ((int)(resources.GetObject("resource.TabIndex")));
this.InputTextBox.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
this.InputTextBox.CustomButton.UseSelectable = true;
this.InputTextBox.CustomButton.Visible = ((bool)(resources.GetObject("resource.Visible")));
this.InputTextBox.Lines = new string[0];
this.InputTextBox.MaxLength = 255;
this.InputTextBox.Name = "InputTextBox";
this.InputTextBox.PasswordChar = '\0';
this.InputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.None;
this.InputTextBox.SelectedText = "";
this.InputTextBox.SelectionLength = 0;
this.InputTextBox.SelectionStart = 0;
this.InputTextBox.ShortcutsEnabled = true;
this.InputTextBox.Style = MetroFramework.MetroColorStyle.White;
this.InputTextBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.InputTextBox.UseSelectable = true;
this.InputTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
this.InputTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
//
// contextLabel
//
resources.ApplyResources(this.contextLabel, "contextLabel");
this.contextLabel.FontSize = MetroFramework.MetroLabelSize.Small;
this.contextLabel.Name = "contextLabel";
this.contextLabel.Theme = MetroFramework.MetroThemeStyle.Dark;
this.contextLabel.WrapToLine = true;
//
// TextPrompt
//
this.AcceptButton = this.OKButton;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.contextLabel);
this.Controls.Add(this.InputTextBox);
this.Controls.Add(this.OKButton);
this.Controls.Add(this.TextLabel);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "TextPrompt";
this.Resizable = false;
this.ShadowType = MetroFramework.Forms.MetroFormShadowType.DropShadow;
this.Style = MetroFramework.MetroColorStyle.Silver;
this.Theme = MetroFramework.MetroThemeStyle.Dark;
this.Load += new System.EventHandler(this.RenamePrompt_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private MetroFramework.Controls.MetroTextBox PromptTextBox;
private MetroFramework.Controls.MetroButton okBtn;
private MetroFramework.Controls.MetroButton cancelBtn;
}
public System.Windows.Forms.Button OKButton;
public System.Windows.Forms.Label TextLabel;
private MetroFramework.Controls.MetroTextBox InputTextBox;
public MetroFramework.Controls.MetroLabel contextLabel;
}
}

View File

@@ -1,25 +1,42 @@
using System;
using System.Windows.Forms;
using MetroFramework.Forms;
namespace PckStudio.Forms.Additional_Popups
namespace PckStudio
{
public partial class TextPrompt : MetroFramework.Forms.MetroForm
{
public string[] TextOutput => DialogResult == DialogResult.OK ? PromptTextBox.Lines : Array.Empty<string>();
public TextPrompt(string[] list = null)
public partial class TextPrompt : MetroForm
{
/// <summary>
/// Text entered <c>only access when DialogResult == DialogResult.OK</c>
/// </summary>
public string NewText => InputTextBox.Text;
public TextPrompt(string InitialText) : this(InitialText, -1)
{ }
public TextPrompt(string InitialText, int maxChar)
{
InitializeComponent();
InputTextBox.Text = InitialText;
InputTextBox.MaxLength = maxChar < 0 ? short.MaxValue : maxChar;
}
private void OKBtn_Click(object sender, EventArgs e)
{
InitializeComponent();
PromptTextBox.Lines = list;
if (String.IsNullOrEmpty(InputTextBox.Text))
{
MessageBox.Show(this, "Please insert a value in the text box.", "Empty string");
}
else DialogResult = DialogResult.OK;
}
private void okBtn_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void cancelBtn_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
private void RenamePrompt_Load(object sender, EventArgs e)
{
if(String.IsNullOrEmpty(contextLabel.Text))
{
contextLabel.Visible = false;
Size = new System.Drawing.Size(264, 85);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -246,7 +246,7 @@ namespace PckStudio.Forms.Editor
while (!SkinANIM.IsValidANIM(value))
{
if (!string.IsNullOrWhiteSpace(value)) MessageBox.Show($"The following value \"{value}\" is not valid. Please try again.");
RenamePrompt diag = new RenamePrompt(value);
TextPrompt diag = new TextPrompt(value);
diag.TextLabel.Text = "ANIM";
diag.OKButton.Text = "Ok";
if (diag.ShowDialog() == DialogResult.OK)

View File

@@ -205,7 +205,7 @@ namespace PckStudio.Forms.Editor
? GrfTreeView.SelectedNode.Nodes
: GrfTreeView.Nodes;
using (RenamePrompt prompt = new RenamePrompt(""))
using (TextPrompt prompt = new TextPrompt(""))
{
prompt.OKButton.Text = "Add";
if (MessageBox.Show($"Add Game Rule to {parentRule.Name}", "Attention",

View File

@@ -61,7 +61,7 @@ namespace PckStudio.Forms.Editor
private void addDisplayIDToolStripMenuItem_Click(object sender, EventArgs e)
{
if (treeViewLocKeys.SelectedNode is TreeNode)
using (RenamePrompt prompt = new RenamePrompt(""))
using (TextPrompt prompt = new TextPrompt(""))
{
prompt.OKButton.Text = "Add";
if (prompt.ShowDialog() == DialogResult.OK &&

View File

@@ -72,14 +72,14 @@
// addToolStripMenuItem
//
this.addToolStripMenuItem.Name = "addToolStripMenuItem";
this.addToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.addToolStripMenuItem.Size = new System.Drawing.Size(126, 22);
this.addToolStripMenuItem.Text = "Add Entry";
this.addToolStripMenuItem.Click += new System.EventHandler(this.addToolStripMenuItem_Click);
//
// removeToolStripMenuItem
//
this.removeToolStripMenuItem.Name = "removeToolStripMenuItem";
this.removeToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.removeToolStripMenuItem.Size = new System.Drawing.Size(126, 22);
this.removeToolStripMenuItem.Text = "Remove";
this.removeToolStripMenuItem.Click += new System.EventHandler(this.removeToolStripMenuItem_Click);
//
@@ -135,6 +135,7 @@
this.materialComboBox.FormattingEnabled = true;
this.materialComboBox.ItemHeight = 23;
this.materialComboBox.Items.AddRange(new object[] {
"entity",
"entity_alphatest",
"entity_emissive_alpha",
"entity_emissive_alpha_only",

View File

@@ -30,8 +30,8 @@ namespace PckStudio.Forms.Utilities
new MaterialContainer.Material("zombie_pigman", "entity"),
new MaterialContainer.Material("phantom", "entity_emissive_alpha"),
new MaterialContainer.Material("phantom_invisible", "entity_emissive_alpha_only"),
new MaterialContainer.Material("sheep", "entity_emissive_change_color"),
new MaterialContainer.Material("shulker", "entity_emissive_change_color"),
new MaterialContainer.Material("sheep", "entity_change_color"),
new MaterialContainer.Material("shulker", "entity_change_color"),
new MaterialContainer.Material("skeleton", "entity_alphatest"),
new MaterialContainer.Material("spider", "entity_emissive_alpha"),
new MaterialContainer.Material("spider_invisible", "entity_emissive_alpha_only"),

View File

@@ -117,6 +117,9 @@
this.settingsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuMetaTree = new System.Windows.Forms.ContextMenuStrip(this.components);
this.addEntryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.addEntryToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.addBOXEntryToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.addANIMEntryToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.addMultipleEntriesToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.deleteEntryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editAllEntriesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -143,9 +146,6 @@
this.treeViewMain = new System.Windows.Forms.TreeView();
this.imageList = new System.Windows.Forms.ImageList(this.components);
this.LittleEndianCheckBox = new MetroFramework.Controls.MetroCheckBox();
this.addEntryToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.addBOXEntryToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.addANIMEntryToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.pictureBoxImagePreview = new PckStudio.PictureBoxWithInterpolationMode();
this.contextMenuPCKEntries.SuspendLayout();
this.menuStrip.SuspendLayout();
@@ -559,8 +559,8 @@
//
// addCustomPackImageToolStripMenuItem
//
resources.ApplyResources(this.addCustomPackImageToolStripMenuItem, "addCustomPackImageToolStripMenuItem");
this.addCustomPackImageToolStripMenuItem.Name = "addCustomPackImageToolStripMenuItem";
resources.ApplyResources(this.addCustomPackImageToolStripMenuItem, "addCustomPackImageToolStripMenuItem");
this.addCustomPackImageToolStripMenuItem.Click += new System.EventHandler(this.addCustomPackIconToolStripMenuItem_Click);
//
// openPckManagerToolStripMenuItem
@@ -780,6 +780,24 @@
resources.ApplyResources(this.addEntryToolStripMenuItem, "addEntryToolStripMenuItem");
this.addEntryToolStripMenuItem.Name = "addEntryToolStripMenuItem";
//
// addEntryToolStripMenuItem1
//
this.addEntryToolStripMenuItem1.Name = "addEntryToolStripMenuItem1";
resources.ApplyResources(this.addEntryToolStripMenuItem1, "addEntryToolStripMenuItem1");
this.addEntryToolStripMenuItem1.Click += new System.EventHandler(this.addEntryToolStripMenuItem_Click_1);
//
// addBOXEntryToolStripMenuItem1
//
this.addBOXEntryToolStripMenuItem1.Name = "addBOXEntryToolStripMenuItem1";
resources.ApplyResources(this.addBOXEntryToolStripMenuItem1, "addBOXEntryToolStripMenuItem1");
this.addBOXEntryToolStripMenuItem1.Click += new System.EventHandler(this.addBOXEntryToolStripMenuItem1_Click);
//
// addANIMEntryToolStripMenuItem1
//
this.addANIMEntryToolStripMenuItem1.Name = "addANIMEntryToolStripMenuItem1";
resources.ApplyResources(this.addANIMEntryToolStripMenuItem1, "addANIMEntryToolStripMenuItem1");
this.addANIMEntryToolStripMenuItem1.Click += new System.EventHandler(this.addANIMEntryToolStripMenuItem1_Click);
//
// addMultipleEntriesToolStripMenuItem1
//
resources.ApplyResources(this.addMultipleEntriesToolStripMenuItem1, "addMultipleEntriesToolStripMenuItem1");
@@ -1074,24 +1092,6 @@
this.LittleEndianCheckBox.Theme = MetroFramework.MetroThemeStyle.Dark;
this.LittleEndianCheckBox.UseSelectable = true;
//
// addEntryToolStripMenuItem1
//
this.addEntryToolStripMenuItem1.Name = "addEntryToolStripMenuItem1";
resources.ApplyResources(this.addEntryToolStripMenuItem1, "addEntryToolStripMenuItem1");
this.addEntryToolStripMenuItem1.Click += new System.EventHandler(this.addEntryToolStripMenuItem_Click_1);
//
// addBOXEntryToolStripMenuItem1
//
this.addBOXEntryToolStripMenuItem1.Name = "addBOXEntryToolStripMenuItem1";
resources.ApplyResources(this.addBOXEntryToolStripMenuItem1, "addBOXEntryToolStripMenuItem1");
this.addBOXEntryToolStripMenuItem1.Click += new System.EventHandler(this.addBOXEntryToolStripMenuItem1_Click);
//
// addANIMEntryToolStripMenuItem1
//
this.addANIMEntryToolStripMenuItem1.Name = "addANIMEntryToolStripMenuItem1";
resources.ApplyResources(this.addANIMEntryToolStripMenuItem1, "addANIMEntryToolStripMenuItem1");
this.addANIMEntryToolStripMenuItem1.Click += new System.EventHandler(this.addANIMEntryToolStripMenuItem1_Click);
//
// pictureBoxImagePreview
//
resources.ApplyResources(this.pictureBoxImagePreview, "pictureBoxImagePreview");

View File

@@ -8,16 +8,17 @@ using System.Drawing.Drawing2D;
using System.Diagnostics;
using System.Drawing.Imaging;
using OMI.Formats.Archive;
using OMI.Formats.Pck;
using OMI.Formats.GameRule;
using OMI.Formats.Languages;
using OMI.Workers.Archive;
using OMI.Workers.Pck;
using OMI.Workers.GameRule;
using OMI.Workers.Language;
using PckStudio.Properties;
using PckStudio.Classes.FileTypes;
using PckStudio.Classes.Utils.ARC;
using PckStudio.Forms;
using PckStudio.Forms.Utilities;
using PckStudio.Forms.Editor;
@@ -666,7 +667,7 @@ namespace PckStudio
string newFileExt = Path.GetExtension(ofd.FileName);
file.SetData(File.ReadAllBytes(ofd.FileName));
file.Filename = file.Filename.Replace(fileExt, newFileExt);
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath)) RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
wasModified = true;
BuildMainTreeView();
}
@@ -723,7 +724,7 @@ namespace PckStudio
node.Remove();
wasModified = true;
}
if (IsSubPCKNode(path)) RebuildSubPCK(node);
RebuildSubPCK(path);
}
private void renameFileToolStripMenuItem_Click(object sender, EventArgs e)
@@ -732,9 +733,7 @@ namespace PckStudio
if (node == null) return;
string path = node.FullPath;
bool sub = IsSubPCKNode(path);
using RenamePrompt diag = new RenamePrompt(node.Tag is null ? Path.GetFileName(node.FullPath) : node.FullPath);
using TextPrompt diag = new TextPrompt(node.Tag is null ? Path.GetFileName(node.FullPath) : node.FullPath);
if (diag.ShowDialog(this) == DialogResult.OK)
{
@@ -754,7 +753,7 @@ namespace PckStudio
}
}
wasModified = true;
if (sub) RebuildSubPCK(node);
RebuildSubPCK(path);
BuildMainTreeView();
}
}
@@ -779,7 +778,7 @@ namespace PckStudio
newNode.Tag = add.SkinFile;
SetPckFileIcon(newNode, PckFile.FileData.FileType.SkinFile);
subPCK.Nodes.Add(newNode);
RebuildSubPCK(newNode);
RebuildSubPCK(newNode.FullPath);
}
else
{
@@ -797,7 +796,7 @@ namespace PckStudio
newNode.Tag = add.CapeFile;
SetPckFileIcon(newNode, PckFile.FileData.FileType.SkinFile);
subPCK.Nodes.Add(newNode);
RebuildSubPCK(newNode);
RebuildSubPCK(newNode.FullPath);
}
else
{
@@ -908,26 +907,32 @@ namespace PckStudio
return childNodes;
}
TreeNode GetSubPCK(TreeNode child)
TreeNode GetSubPCK(string childPath)
{
TreeNode parent = child;
while (parent.Parent != null)
string parentPath = childPath.Replace('\\', '/');
Console.WriteLine(parentPath);
string[] s = parentPath.Split('/');
Console.WriteLine(s.Length);
foreach (var node in s)
{
parent = parent.Parent;
Console.WriteLine(parent.Text);
TreeNode parent = treeViewMain.Nodes.Find(node, true)[0];
if (parent.Tag is PckFile.FileData f &&
(f.Filetype is PckFile.FileData.FileType.TexturePackInfoFile ||
f.Filetype is PckFile.FileData.FileType.SkinDataFile))
return parent;
}
return null;
}
void RebuildSubPCK(TreeNode childNode)
void RebuildSubPCK(string childPath)
{
// Support for if a file is edited within a PCK File
// Support for if a file is edited within a nested PCK File (AKA SubPCK)
TreeNode parent = GetSubPCK(childNode);
if(!IsSubPCKNode(childPath)) return;
TreeNode parent = GetSubPCK(childPath);
Console.WriteLine(parent.Name);
if (parent == null) return;
PckFile.FileData parent_file = parent.Tag as PckFile.FileData;
@@ -992,8 +997,7 @@ namespace PckStudio
if (diag.ShowDialog(this) == DialogResult.OK)
{
file.Properties[i] = new KeyValuePair<string, string>("ANIM", diag.ResultAnim.ToString());
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath))
RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
ReloadMetaTreeView();
wasModified = true;
}
@@ -1013,8 +1017,7 @@ namespace PckStudio
if (diag.ShowDialog(this) == DialogResult.OK)
{
file.Properties[i] = new KeyValuePair<string, string>("BOX", diag.Result.ToString());
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath))
RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
ReloadMetaTreeView();
wasModified = true;
}
@@ -1037,8 +1040,7 @@ namespace PckStudio
if (addProperty.ShowDialog() == DialogResult.OK)
{
file.Properties[i] = addProperty.Property;
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath))
RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
ReloadMetaTreeView();
wasModified = true;
}
@@ -1050,43 +1052,46 @@ namespace PckStudio
private void cloneFileToolStripMenuItem_Click(object sender, EventArgs e)
{
TreeNode node = treeViewMain.SelectedNode;
PckFile.FileData mfO = node.Tag as PckFile.FileData;
if (node == null) return;
string path = node.FullPath;
// Creates new empty file entry
PckFile.FileData mf = new PckFile.FileData(string.Empty, mfO.Filetype);
mf.SetData(mfO.Data);
string dirName = Path.GetDirectoryName(mfO.Filename);
using TextPrompt diag = new TextPrompt(node.Tag is null ? Path.GetFileName(node.FullPath) : node.FullPath);
diag.contextLabel.Text = $"Creating a clone of \"{path}\". Ensure that the path isn't yet.";
diag.OKButton.Text = "Clone";
int clone_number = 0;
string nameWithoutExt = Path.GetFileNameWithoutExtension(mfO.Filename);
string newFileName = mfO.Filename;
do
if (diag.ShowDialog(this) == DialogResult.OK)
{
clone_number++;
string clone_str = "_clone" + clone_number.ToString();
bool isClone = nameWithoutExt.Contains("_clone");
if (isClone) newFileName = nameWithoutExt.Remove(nameWithoutExt.Length - 7) + clone_str + Path.GetExtension(mfO.Filename);
else newFileName = nameWithoutExt + clone_str + Path.GetExtension(mfO.Filename);
if (node.Tag is PckFile.FileData file)
{
TreeNode newNode = new TreeNode();
newNode.Text = Path.GetFileName(diag.NewText);
var NewFile = new PckFile.FileData(diag.NewText, file.Filetype);
file.Properties.ForEach(p => NewFile.Properties.Add(p));
NewFile.SetData(file.Data);
NewFile.Filename = diag.NewText;
newNode.Tag = NewFile;
newNode.ImageIndex = node.ImageIndex;
newNode.SelectedImageIndex = node.SelectedImageIndex;
if (GetAllChildNodes(treeViewMain.Nodes).Find(n => n.FullPath == diag.NewText) != null)
{
MessageBox.Show(
this,
$"A file with the path \"{diag.NewText}\" already exists. " +
$"Please try again with a different name.",
"Key already exists");
return;
}
if (node.Parent == null) treeViewMain.Nodes.Insert(node.Index + 1, newNode); //adds generated file node
else node.Parent.Nodes.Insert(node.Index + 1, newNode);//adds generated file node to selected folder
if (!IsSubPCKNode(node.FullPath)) currentPCK.Files.Insert(node.Index + 1, NewFile);
else RebuildSubPCK(node.FullPath);
BuildMainTreeView();
wasModified = true;
}
}
while (currentPCK.HasFile(dirName + (string.IsNullOrEmpty(dirName) ? "" : "/") + newFileName, mf.Filetype));
mf.Filename = dirName + (string.IsNullOrEmpty(dirName) ? "" : "/") + newFileName; //sets minfile name to file name
foreach (var entry in mfO.Properties)
{
mf.Properties.Add(entry);
}
TreeNode newNode = new TreeNode();
newNode.Text = newFileName;
newNode.Tag = mf;
newNode.ImageIndex = node.ImageIndex;
newNode.SelectedImageIndex = node.SelectedImageIndex;
if (node.Parent == null) treeViewMain.Nodes.Insert(node.Index + 1, newNode); //adds generated minefile node
else node.Parent.Nodes.Insert(node.Index + 1, newNode);//adds generated minefile node to selected folder
if (!IsSubPCKNode(node.FullPath)) currentPCK.Files.Insert(node.Index + 1, mf);
else RebuildSubPCK(node);
}
private void deleteEntryToolStripMenuItem_Click(object sender, EventArgs e)
@@ -1096,7 +1101,7 @@ namespace PckStudio
file.Properties.Remove(property))
{
treeMeta.SelectedNode.Remove();
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath)) RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
wasModified = true;
}
}
@@ -1123,7 +1128,7 @@ namespace PckStudio
if (addProperty.ShowDialog() == DialogResult.OK)
{
file.Properties.Add(addProperty.Property);
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath)) RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
ReloadMetaTreeView();
wasModified = true;
}
@@ -1284,7 +1289,7 @@ namespace PckStudio
private void skinPackToolStripMenuItem_Click(object sender, EventArgs e)
{
checkSaveState();
RenamePrompt namePrompt = new RenamePrompt("");
TextPrompt namePrompt = new TextPrompt("");
namePrompt.OKButton.Text = "Ok";
if (namePrompt.ShowDialog() == DialogResult.OK)
{
@@ -1635,7 +1640,7 @@ namespace PckStudio
private void folderToolStripMenuItem_Click(object sender, EventArgs e)
{
RenamePrompt folderNamePrompt = new RenamePrompt("");
TextPrompt folderNamePrompt = new TextPrompt("");
if(treeViewMain.SelectedNode is not null) folderNamePrompt.contextLabel.Text = $"New folder at the location of \"{treeViewMain.SelectedNode.FullPath}\"";
folderNamePrompt.OKButton.Text = "Add";
if (folderNamePrompt.ShowDialog() == DialogResult.OK)
@@ -1898,7 +1903,7 @@ namespace PckStudio
Debug.WriteLine($"Setting {file.Filetype} to {type}");
file.Filetype = type;
SetPckFileIcon(t, type);
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath)) RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
}
}
@@ -1908,7 +1913,7 @@ namespace PckStudio
fileDialog.Filter = "Texture File(*.png;*.tga)|*.png;*.tga";
if (fileDialog.ShowDialog() == DialogResult.OK)
{
using RenamePrompt renamePrompt = new RenamePrompt(Path.GetFileName(fileDialog.FileName));
using TextPrompt renamePrompt = new TextPrompt(Path.GetFileName(fileDialog.FileName));
renamePrompt.TextLabel.Text = "Path";
if (renamePrompt.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(renamePrompt.NewText))
{
@@ -2034,7 +2039,7 @@ namespace PckStudio
if (treeViewMain.SelectedNode is TreeNode node &&
node.Tag is PckFile.FileData file)
{
using (var input = new TextPrompt())
using (var input = new MultiTextPrompt())
{
if (input.ShowDialog(this) == DialogResult.OK)
{
@@ -2046,7 +2051,7 @@ namespace PckStudio
file.Properties.Add((line.Substring(0, idx), line.Substring(idx + 1)));
}
ReloadMetaTreeView();
if (IsSubPCKNode(node.FullPath)) RebuildSubPCK(node);
RebuildSubPCK(node.FullPath);
wasModified = true;
}
}
@@ -2062,36 +2067,95 @@ namespace PckStudio
file.Properties[file.Properties.IndexOf(p)] = new KeyValuePair<string, string>(p.Key, p.Value.Replace(',','.'));
}
ReloadMetaTreeView();
if (IsSubPCKNode(node.FullPath)) RebuildSubPCK(node);
RebuildSubPCK(node.FullPath);
wasModified = true;
}
}
private void addCustomPackIconToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!currentPCK.TryGetFile("0", PckFile.FileData.FileType.InfoFile, out PckFile.FileData file) ||
string.IsNullOrEmpty(file.Properties.GetPropertyValue("PACKID"))
)
string packID = "0";
using NumericPrompt numericPrompt = new NumericPrompt(0);
numericPrompt.Minimum = 0; // TODO: put min pack ID value (keeping this 0 just to be safe)
numericPrompt.Maximum = int.MinValue; // TODO: put max pack ID value
numericPrompt.ContextLabel.Text = "Please insert the desired Pack ID";
numericPrompt.TextLabel.Text = "Pack ID";
if (currentPCK is not null)
{
MessageBox.Show("No PackID is present in this pack. To avoid this error, please open a PCK with a PackID before trying again.", "Operation Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error);
DialogResult prompt = MessageBox.Show(this,
"Would you like to use the current PackID? You can enter any PackID if not.",
"",
MessageBoxButtons.YesNoCancel);
switch (prompt)
{
case DialogResult.Yes:
if (!currentPCK.TryGetFile("0", PckFile.FileData.FileType.InfoFile, out PckFile.FileData file) ||
string.IsNullOrEmpty(file.Properties.GetPropertyValue("PACKID")))
{
MessageBox.Show(this,
"No PackID is present in this PCK. " +
"To avoid this error, ensure that the PCK has a proper PackID property on the \"0\" Info file before trying again.",
"Operation Aborted", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
packID = file.Properties.GetPropertyValue("PACKID");
break;
case DialogResult.No:
break;
case DialogResult.Cancel:
default:
MessageBox.Show(this, "Operation cancelled");
return;
}
}
else if (numericPrompt.ShowDialog(this) == DialogResult.OK) packID = numericPrompt.SelectedValue.ToString();
else
{
MessageBox.Show(this, "Operation cancelled");
return;
}
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Minecraft Archive|*.arc";
if (dialog.ShowDialog(this) == DialogResult.OK)
OpenFileDialog arcDialog = new OpenFileDialog();
OpenFileDialog iconDialog = new OpenFileDialog();
arcDialog.Filter = "Minecraft Archive|*.arc";
iconDialog.Filter = "Pack Icon|*.png";
if (arcDialog.ShowDialog(this) == DialogResult.OK)
{
string filepath = dialog.FileName;
dialog.Filter = "Pack Icon|*.png";
if (dialog.ShowDialog(this) == DialogResult.OK)
using (var fs = File.OpenRead(arcDialog.FileName))
{
using (var fs = File.OpenRead(filepath))
var reader = new ARCFileReader();
ConsoleArchive archive = reader.FromStream(fs);
if (iconDialog.ShowDialog(this) == DialogResult.OK)
{
ARCUtil.Inject(fs, (
string.Format("Graphics\\PackGraphics\\{0}.png", file.Properties.GetPropertyValue("PACKID")),
File.ReadAllBytes(dialog.FileName))
);
MessageBox.Show("Successfully added Pack Icon to Archive!", "Successfully Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
string key = string.Format("Graphics\\PackGraphics\\{0}.png", packID);
if (archive.Keys.Contains(key))
{
DialogResult prompt = MessageBox.Show(this,
"This pack already has a pack icon present in the chosen file. Would you like to replace the pack icon?",
"Icon already exists",
MessageBoxButtons.YesNoCancel);
switch (prompt)
{
case DialogResult.Yes:
archive.Remove(key); // remove file so it can be injected
break;
case DialogResult.No:
case DialogResult.Cancel:
default:
MessageBox.Show(this, "Operation cancelled");
return;
}
}
archive.Add(key, File.ReadAllBytes(iconDialog.FileName));
var writer = new ARCFileWriter(archive);
writer.WriteToFile(arcDialog.FileName);
MessageBox.Show($"Successfully added {key} to Archive!", "Successfully Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
@@ -2129,7 +2193,7 @@ namespace PckStudio
node.Tag is PckFile.FileData file)
{
var props = file.Properties.Select(p => p.Key + " " + p.Value);
using (var input = new TextPrompt(props.ToArray()))
using (var input = new MultiTextPrompt(props.ToArray()))
{
if (input.ShowDialog(this) == DialogResult.OK)
{
@@ -2142,7 +2206,7 @@ namespace PckStudio
file.Properties.Add((line.Substring(0, idx).Replace(":", string.Empty), line.Substring(idx + 1)));
}
ReloadMetaTreeView();
if (IsSubPCKNode(node.FullPath)) RebuildSubPCK(node);
RebuildSubPCK(node.FullPath);
wasModified = true;
}
}
@@ -2166,7 +2230,7 @@ namespace PckStudio
diag.Filetype,
() => File.ReadAllBytes(ofd.FileName));
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath)) RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
//else treeViewMain.Nodes.Add();
BuildMainTreeView();
@@ -2301,8 +2365,7 @@ namespace PckStudio
if (diag.ShowDialog(this) == DialogResult.OK)
{
file.Properties.Add("BOX", diag.Result);
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath))
RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
ReloadMetaTreeView();
wasModified = true;
}
@@ -2318,8 +2381,7 @@ namespace PckStudio
if (diag.ShowDialog(this) == DialogResult.OK)
{
file.Properties.Add("ANIM", diag.ResultAnim);
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath))
RebuildSubPCK(treeViewMain.SelectedNode);
RebuildSubPCK(treeViewMain.SelectedNode.FullPath);
ReloadMetaTreeView();
wasModified = true;
}

View File

@@ -673,9 +673,6 @@
<data name="editToolStripMenuItem.Text" xml:space="preserve">
<value>Edit</value>
</data>
<data name="addCustomPackImageToolStripMenuItem.Enabled" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="addCustomPackImageToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>195, 22</value>
</data>
@@ -24172,19 +24169,19 @@
<value>298, 17</value>
</metadata>
<data name="addEntryToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>160, 22</value>
</data>
<data name="addEntryToolStripMenuItem1.Text" xml:space="preserve">
<value>Add Entry</value>
</data>
<data name="addBOXEntryToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>160, 22</value>
</data>
<data name="addBOXEntryToolStripMenuItem1.Text" xml:space="preserve">
<value>Add BOX Entry</value>
</data>
<data name="addANIMEntryToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing">
<value>180, 22</value>
<value>160, 22</value>
</data>
<data name="addANIMEntryToolStripMenuItem1.Text" xml:space="preserve">
<value>Add ANIM Entry</value>
@@ -24239,7 +24236,7 @@
<value>Edit All Entries</value>
</data>
<data name="contextMenuMetaTree.Size" type="System.Drawing.Size, System.Drawing">
<value>182, 114</value>
<value>182, 92</value>
</data>
<data name="&gt;&gt;contextMenuMetaTree.Name" xml:space="preserve">
<value>contextMenuMetaTree</value>
@@ -29617,6 +29614,24 @@
<data name="&gt;&gt;addEntryToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;addEntryToolStripMenuItem1.Name" xml:space="preserve">
<value>addEntryToolStripMenuItem1</value>
</data>
<data name="&gt;&gt;addEntryToolStripMenuItem1.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;addBOXEntryToolStripMenuItem1.Name" xml:space="preserve">
<value>addBOXEntryToolStripMenuItem1</value>
</data>
<data name="&gt;&gt;addBOXEntryToolStripMenuItem1.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;addANIMEntryToolStripMenuItem1.Name" xml:space="preserve">
<value>addANIMEntryToolStripMenuItem1</value>
</data>
<data name="&gt;&gt;addANIMEntryToolStripMenuItem1.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;addMultipleEntriesToolStripMenuItem1.Name" xml:space="preserve">
<value>addMultipleEntriesToolStripMenuItem1</value>
</data>
@@ -29641,24 +29656,6 @@
<data name="&gt;&gt;imageList.Type" xml:space="preserve">
<value>System.Windows.Forms.ImageList, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;addEntryToolStripMenuItem1.Name" xml:space="preserve">
<value>addEntryToolStripMenuItem1</value>
</data>
<data name="&gt;&gt;addEntryToolStripMenuItem1.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;addBOXEntryToolStripMenuItem1.Name" xml:space="preserve">
<value>addBOXEntryToolStripMenuItem1</value>
</data>
<data name="&gt;&gt;addBOXEntryToolStripMenuItem1.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;addANIMEntryToolStripMenuItem1.Name" xml:space="preserve">
<value>addANIMEntryToolStripMenuItem1</value>
</data>
<data name="&gt;&gt;addANIMEntryToolStripMenuItem1.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>MainForm</value>
</data>

View File

@@ -216,7 +216,6 @@
<Compile Include="Classes\Models\DefaultModels\Steve64x64Model.cs" />
<Compile Include="Internals\ApplicationScope.cs" />
<Compile Include="Internals\SkinBOX.cs" />
<Compile Include="Classes\Utils\ARC\ARCUtil.cs" />
<Compile Include="Extensions\ImageExtensions.cs" />
<Compile Include="Internals\SkinANIM.cs" />
<Compile Include="Classes\Models\DefaultModels\Steve64x32Model.cs" />
@@ -281,18 +280,18 @@
<Compile Include="Forms\Additional-Popups\AddFilePrompt.Designer.cs">
<DependentUpon>AddFilePrompt.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Additional-Popups\RenamePrompt.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Additional-Popups\RenamePrompt.Designer.cs">
<DependentUpon>RenamePrompt.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Additional-Popups\TextPrompt.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Additional-Popups\TextPrompt.Designer.cs">
<DependentUpon>TextPrompt.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Additional-Popups\MultiTextPrompt.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\Additional-Popups\MultiTextPrompt.Designer.cs">
<DependentUpon>MultiTextPrompt.cs</DependentUpon>
</Compile>
<Compile Include="Forms\Editor\Animation.cs" />
<Compile Include="Forms\Editor\AnimationPictureBox.cs">
<SubType>Component</SubType>
@@ -508,12 +507,12 @@
<DependentUpon>NumericPrompt.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Additional-Popups\RenamePrompt.resx">
<DependentUpon>RenamePrompt.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Additional-Popups\TextPrompt.resx">
<DependentUpon>TextPrompt.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Additional-Popups\MultiTextPrompt.resx">
<DependentUpon>MultiTextPrompt.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\Editor\MaterialsEditor.resx">
<DependentUpon>MaterialsEditor.cs</DependentUpon>
@@ -782,6 +781,9 @@
<Name>SharpMss32</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Classes\Utils\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.