From 9e248ee6e58c133f289c6014918fa8312d9824fd Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sat, 12 Aug 2023 10:29:07 +0200 Subject: [PATCH] Renamed addnewskin to AddNewSkin --- ...kin.Designer.cs => AddNewSkin.Designer.cs} | 20 ++- .../{addnewskin.cs => AddNewSkin.cs} | 148 +++++++----------- .../{addnewskin.resx => AddNewSkin.resx} | 6 + PCK-Studio/MainForm.cs | 2 +- PCK-Studio/PckStudio.csproj | 14 +- 5 files changed, 81 insertions(+), 109 deletions(-) rename PCK-Studio/Forms/Skins-And-Textures/{addnewskin.Designer.cs => AddNewSkin.Designer.cs} (97%) rename PCK-Studio/Forms/Skins-And-Textures/{addnewskin.cs => AddNewSkin.cs} (64%) rename PCK-Studio/Forms/Skins-And-Textures/{addnewskin.resx => AddNewSkin.resx} (99%) diff --git a/PCK-Studio/Forms/Skins-And-Textures/addnewskin.Designer.cs b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.Designer.cs similarity index 97% rename from PCK-Studio/Forms/Skins-And-Textures/addnewskin.Designer.cs rename to PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.Designer.cs index c88af519..3aa1d4b1 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/addnewskin.Designer.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.Designer.cs @@ -1,6 +1,6 @@ -namespace PckStudio +namespace PckStudio.Popups { - partial class addNewSkin + partial class AddNewSkin { /// /// Required designer variable. @@ -30,7 +30,7 @@ { this.components = new System.ComponentModel.Container(); System.Windows.Forms.Label label3; - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(addNewSkin)); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddNewSkin)); System.Windows.Forms.Label label2; System.Windows.Forms.Label label1; this.textTheme = new System.Windows.Forms.TextBox(); @@ -111,7 +111,7 @@ // resources.ApplyResources(this.replaceToolStripMenuItem1, "replaceToolStripMenuItem1"); this.replaceToolStripMenuItem1.Name = "replaceToolStripMenuItem1"; - this.replaceToolStripMenuItem1.Click += new System.EventHandler(this.replaceToolStripMenuItem1_Click); + this.replaceToolStripMenuItem1.Click += new System.EventHandler(this.capePictureBox_Click); // // buttonDone // @@ -173,7 +173,6 @@ resources.ApplyResources(this.labelSelectTexture, "labelSelectTexture"); this.labelSelectTexture.ForeColor = System.Drawing.Color.White; this.labelSelectTexture.Name = "labelSelectTexture"; - this.labelSelectTexture.Click += new System.EventHandler(this.pictureBox1_Click); // // radioSERVER // @@ -282,7 +281,6 @@ resources.ApplyResources(this.label4, "label4"); this.label4.ForeColor = System.Drawing.Color.White; this.label4.Name = "label4"; - this.label4.Click += new System.EventHandler(this.replaceToolStripMenuItem1_Click); // // buttonAnimGen // @@ -299,7 +297,7 @@ this.capePictureBox.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default; this.capePictureBox.Name = "capePictureBox"; this.capePictureBox.TabStop = false; - this.capePictureBox.Click += new System.EventHandler(this.replaceToolStripMenuItem1_Click); + this.capePictureBox.Click += new System.EventHandler(this.capePictureBox_Click); // // skinPictureBoxTexture // @@ -308,7 +306,7 @@ this.skinPictureBoxTexture.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; this.skinPictureBoxTexture.Name = "skinPictureBoxTexture"; this.skinPictureBoxTexture.TabStop = false; - this.skinPictureBoxTexture.Click += new System.EventHandler(this.pictureBox1_Click); + this.skinPictureBoxTexture.Click += new System.EventHandler(this.skinPictureBoxTexture_Click); // // addNewSkin // @@ -363,13 +361,13 @@ private System.Windows.Forms.PictureBox displayBox; private System.Windows.Forms.RadioButton radioAUTO; private System.Windows.Forms.RadioButton radioLOCAL; - private System.Windows.Forms.Label labelSelectTexture; private System.Windows.Forms.RadioButton radioSERVER; private MetroFramework.Controls.MetroTextBox textSkinID; private MetroFramework.Controls.MetroTextBox textSkinName; private MetroFramework.Controls.MetroTextBox textThemeName; - private System.Windows.Forms.Label label4; private PictureBoxWithInterpolationMode skinPictureBoxTexture; private System.Windows.Forms.Button buttonAnimGen; - } + private System.Windows.Forms.Label labelSelectTexture; + private System.Windows.Forms.Label label4; + } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Skins-And-Textures/addnewskin.cs b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs similarity index 64% rename from PCK-Studio/Forms/Skins-And-Textures/addnewskin.cs rename to PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs index baad3b6c..8922ea33 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/addnewskin.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs @@ -10,23 +10,24 @@ using PckStudio.Internal; using PckStudio.Forms.Editor; using PckStudio.Classes.IO._3DST; using PckStudio.Properties; +using PckStudio.Forms; -namespace PckStudio +namespace PckStudio.Popups { - public partial class addNewSkin : MetroFramework.Forms.MetroForm + public partial class AddNewSkin : MetroFramework.Forms.MetroForm { public PckFile.FileData SkinFile => skin; public PckFile.FileData CapeFile => cape; - public bool HasCape = false; + public bool HasCape { get; private set; } = false; - LOCFile currentLoc; - PckFile.FileData skin = new PckFile.FileData("dlcskinXYXYXYXY", PckFile.FileData.FileType.SkinFile); - PckFile.FileData cape = new PckFile.FileData("dlccapeXYXYXYXY", PckFile.FileData.FileType.CapeFile); - SkinANIM anim = new SkinANIM(); + private LOCFile currentLoc; + private PckFile.FileData skin = new PckFile.FileData("dlcskinXYXYXYXY", PckFile.FileData.FileType.SkinFile); + private PckFile.FileData cape = new PckFile.FileData("dlccapeXYXYXYXY", PckFile.FileData.FileType.CapeFile); + private SkinANIM anim = new SkinANIM(); - eSkinType skinType; + private eSkinType skinType; - enum eSkinType : int + private enum eSkinType { Invalid = -1, _64x64, @@ -36,7 +37,7 @@ namespace PckStudio Custom, } - public addNewSkin(LOCFile loc) + public AddNewSkin(LOCFile loc) { InitializeComponent(); currentLoc = loc; @@ -50,67 +51,33 @@ namespace PckStudio case 64: anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64, true); MessageBox.Show("64x64 Skin Detected"); - skinPictureBoxTexture.Width = skinPictureBoxTexture.Height; - if (skinType != eSkinType._64x64 && skinType != eSkinType._64x64HD) - { - buttonSkin.Location = new Point(buttonSkin.Location.X - skinPictureBoxTexture.Width, buttonSkin.Location.Y); - } - //comboBoxSkinType.Text = "Steve (64x64)"; skinType = eSkinType._64x64; break; case 32: - anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64, false); - anim.SetFlag(SkinAnimFlag.SLIM_MODEL, false); + anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64 | SkinAnimFlag.SLIM_MODEL, false); MessageBox.Show("64x32 Skin Detected"); - skinPictureBoxTexture.Width = skinPictureBoxTexture.Height * 2; - if (skinType == eSkinType._64x64) - { - buttonSkin.Location = new Point(buttonSkin.Location.X + skinPictureBoxTexture.Width / 2, buttonSkin.Location.Y); - } - if (skinType == eSkinType._64x64HD) - { - buttonSkin.Location = new Point(buttonSkin.Location.X + skinPictureBoxTexture.Width / 2, buttonSkin.Location.Y); - } - //comboBoxSkinType.Text = "Default (64x32)"; skinType = eSkinType._64x32; break; default: - if (img.Width == img.Height) // 64x64 HD + if (img.Width == img.Height) { anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64, true); MessageBox.Show("64x64 HD Skin Detected"); - skinPictureBoxTexture.Width = skinPictureBoxTexture.Height; - if (skinType != eSkinType._64x64 && skinType != eSkinType._64x64HD) - { - buttonSkin.Location = new Point(buttonSkin.Location.X - skinPictureBoxTexture.Width, buttonSkin.Location.Y); - } - //comboBoxSkinType.Text = "Steve (64x64)"; skinType = eSkinType._64x64HD; - } - else if (img.Height == img.Width / 2) // 64x32 HD - { - anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64, false); - anim.SetFlag(SkinAnimFlag.SLIM_MODEL, false); - MessageBox.Show("64x32 HD Skin Detected"); - skinPictureBoxTexture.Width = skinPictureBoxTexture.Height * 2; - if (skinType == eSkinType._64x64) - { - buttonSkin.Location = new Point(buttonSkin.Location.X + skinPictureBoxTexture.Width / 2, buttonSkin.Location.Y); - } - if (skinType == eSkinType._64x64HD) - { - buttonSkin.Location = new Point(buttonSkin.Location.X + skinPictureBoxTexture.Width / 2, buttonSkin.Location.Y); - } - //comboBoxSkinType.Text = "Default (64x32)"; - skinType = eSkinType._64x32HD; - } - else //If dimensions don't fit any skin type //Invalid - { - MessageBox.Show("Not a Valid Skin File"); - skinType = eSkinType.Invalid; return; } - break; + + if (img.Height == img.Width / 2) + { + anim.SetFlag(SkinAnimFlag.RESOLUTION_64x64 | SkinAnimFlag.SLIM_MODEL, false); + MessageBox.Show("64x32 HD Skin Detected"); + skinType = eSkinType._64x32HD; + return; + } + + MessageBox.Show("Not a Valid Skin File"); + skinType = eSkinType.Invalid; + return; } skinPictureBoxTexture.Image = img; @@ -120,48 +87,49 @@ namespace PckStudio private void DrawModel() { - Bitmap bmp = new Bitmap(displayBox.Width, displayBox.Height); bool isSlim = anim.GetFlag(SkinAnimFlag.SLIM_MODEL); - using (Graphics g = Graphics.FromImage(bmp)) + Pen outlineColor = Pens.Black; + Brush fillColor = Brushes.Gray; + using (Graphics g = Graphics.FromImage(displayBox.Image)) { if(!anim.GetFlag(SkinAnimFlag.HEAD_DISABLED)) { //Head - g.DrawRectangle(Pens.Black, 70, 15, 40, 40); - g.FillRectangle(Brushes.Gray, 71, 16, 39, 39); + g.DrawRectangle(outlineColor, 70, 15, 40, 40); + g.FillRectangle(fillColor, 71, 16, 39, 39); } if (!anim.GetFlag(SkinAnimFlag.BODY_DISABLED)) { //Body - g.DrawRectangle(Pens.Black, 70, 55, 40, 60); - g.FillRectangle(Brushes.Gray, 71, 56, 39, 59); + g.DrawRectangle(outlineColor, 70, 55, 40, 60); + g.FillRectangle(fillColor, 71, 56, 39, 59); } if (!anim.GetFlag(SkinAnimFlag.RIGHT_ARM_DISABLED)) { //Arm0 - g.DrawRectangle(Pens.Black , isSlim ? 55 : 50, 55, isSlim ? 15 : 20, 60); - g.FillRectangle(Brushes.Gray, isSlim ? 56 : 51, 56, isSlim ? 14 : 19, 59); + g.DrawRectangle(outlineColor, isSlim ? 55 : 50, 55, isSlim ? 15 : 20, 60); + g.FillRectangle(fillColor , isSlim ? 56 : 51, 56, isSlim ? 14 : 19, 59); } if (!anim.GetFlag(SkinAnimFlag.LEFT_ARM_DISABLED)) { //Arm1 - g.DrawRectangle(Pens.Black, 110, 55, isSlim ? 15 : 20, 60); - g.FillRectangle(Brushes.Gray, 111, 56, isSlim ? 14 : 19, 59); + g.DrawRectangle(outlineColor, 110, 55, isSlim ? 15 : 20, 60); + g.FillRectangle(fillColor, 111, 56, isSlim ? 14 : 19, 59); } if (!anim.GetFlag(SkinAnimFlag.RIGHT_LEG_DISABLED)) { //Leg0 - g.DrawRectangle(Pens.Black, 70, 115, 20, 60); - g.FillRectangle(Brushes.Gray, 71, 116, 19, 59); + g.DrawRectangle(outlineColor, 70, 115, 20, 60); + g.FillRectangle(fillColor, 71, 116, 19, 59); } if (!anim.GetFlag(SkinAnimFlag.LEFT_LEG_DISABLED)) { //Leg1 - g.DrawRectangle(Pens.Black, 90, 115, 20, 60); - g.FillRectangle(Brushes.Gray, 91, 116, 19, 59); + g.DrawRectangle(outlineColor, 90, 115, 20, 60); + g.FillRectangle(fillColor, 91, 116, 19, 59); } } - displayBox.Image = bmp; + displayBox.Invalidate(); } private void addnewskin_Load(object sender, EventArgs e) @@ -188,22 +156,22 @@ namespace PckStudio } } - private void replaceToolStripMenuItem1_Click(object sender, EventArgs e) + private void capePictureBox_Click(object sender, EventArgs e) { - using (var ofd1 = new OpenFileDialog()) + using (var ofd = new OpenFileDialog()) { - ofd1.Filter = "PNG Files|*.png"; - ofd1.Title = "Select a PNG File"; - if (ofd1.ShowDialog() == DialogResult.OK) + ofd.Filter = "PNG Files|*.png"; + ofd.Title = "Select a PNG File"; + if (ofd.ShowDialog() == DialogResult.OK) { - var img = Image.FromFile(ofd1.FileName); + var img = Image.FromFile(ofd.FileName); if (img.Width == img.Height * 2) { HasCape = true; capePictureBox.SizeMode = PictureBoxSizeMode.StretchImage; capePictureBox.InterpolationMode = InterpolationMode.NearestNeighbor; - capePictureBox.Image = Image.FromFile(ofd1.FileName); - cape.SetData(File.ReadAllBytes(ofd1.FileName)); + capePictureBox.Image = Image.FromFile(ofd.FileName); + cape.SetData(File.ReadAllBytes(ofd.FileName)); contextMenuCape.Items[0].Text = "Replace"; } else @@ -324,25 +292,25 @@ namespace PckStudio textSkinID.Enabled = radioLOCAL.Checked; } - private void pictureBox1_Click(object sender, EventArgs e) + private void skinPictureBoxTexture_Click(object sender, EventArgs e) { - using (var ofdd = new OpenFileDialog()) + using (var ofd = new OpenFileDialog()) { - ofdd.Filter = "PNG Files|*.png|3DS Texture|*.3dst"; - ofdd.Title = "Select a Skin Texture File"; - if (ofdd.ShowDialog() == DialogResult.OK) + ofd.Filter = "PNG Files|*.png|3DS Texture|*.3dst"; + ofd.Title = "Select a Skin Texture File"; + if (ofd.ShowDialog() == DialogResult.OK) { - if (ofdd.FileName.EndsWith(".3dst")) + if (ofd.FileName.EndsWith(".3dst")) { - using (var fs = File.OpenRead(ofdd.FileName)) + using (var fs = File.OpenRead(ofd.FileName)) { var reader = new _3DSTextureReader(); CheckImage(reader.FromStream(fs)); - textSkinName.Text = Path.GetFileNameWithoutExtension(ofdd.FileName); + textSkinName.Text = Path.GetFileNameWithoutExtension(ofd.FileName); } return; } - CheckImage(Image.FromFile(ofdd.FileName)); + CheckImage(Image.FromFile(ofd.FileName)); } } } diff --git a/PCK-Studio/Forms/Skins-And-Textures/addnewskin.resx b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.resx similarity index 99% rename from PCK-Studio/Forms/Skins-And-Textures/addnewskin.resx rename to PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.resx index 82481bdd..60675bd8 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/addnewskin.resx +++ b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.resx @@ -502,6 +502,9 @@ True + + False + Microsoft Sans Serif, 8.25pt, style=Underline @@ -688,6 +691,9 @@ True + + False + Microsoft Sans Serif, 8.25pt, style=Underline diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index 05a28f96..fdc0b968 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -774,7 +774,7 @@ namespace PckStudio MessageBox.Show("No .loc file found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - using (addNewSkin add = new addNewSkin(locFile)) + using (AddNewSkin add = new AddNewSkin(locFile)) if (add.ShowDialog() == DialogResult.OK) { diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index befbe069..31879f0c 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -331,11 +331,11 @@ AddPropertyPrompt.cs - + Form - - addNewSkin.cs + + AddNewSkin.cs Form @@ -532,11 +532,11 @@ AddPropertyPrompt.cs - - addNewSkin.cs + + AddNewSkin.cs - - addNewSkin.cs + + AddNewSkin.cs Designer