From ea1a427c2a3be9550cde1df1a5bb75e0b3b6f3ee Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Thu, 15 Aug 2024 14:20:33 +0200 Subject: [PATCH] generateModel - Remove Import/Export buttons --- .../generateModel.Designer.cs | 33 ---- .../Forms/Skins-And-Textures/generateModel.cs | 176 ------------------ .../Skins-And-Textures/generateModel.resx | 118 ++---------- 3 files changed, 14 insertions(+), 313 deletions(-) diff --git a/PCK-Studio/Forms/Skins-And-Textures/generateModel.Designer.cs b/PCK-Studio/Forms/Skins-And-Textures/generateModel.Designer.cs index f4864d91..3639d52c 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/generateModel.Designer.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/generateModel.Designer.cs @@ -61,10 +61,7 @@ this.buttonEXPORT = new System.Windows.Forms.Button(); this.buttonIMPORT = new System.Windows.Forms.Button(); this.uvPictureBox = new PckStudio.ToolboxItems.InterpolationPictureBox(); - this.buttonImportModel = new System.Windows.Forms.Button(); this.displayBox = new System.Windows.Forms.PictureBox(); - this.buttonExportModel = new System.Windows.Forms.Button(); - this.OpenJSONButton = new System.Windows.Forms.Button(); this.buttonTemplate = new MetroFramework.Controls.MetroButton(); this.generateTextureCheckBox = new MetroFramework.Controls.MetroCheckBox(); this.checkGuide = new MetroFramework.Controls.MetroCheckBox(); @@ -333,14 +330,6 @@ this.uvPictureBox.Name = "uvPictureBox"; this.uvPictureBox.TabStop = false; // - // buttonImportModel - // - resources.ApplyResources(this.buttonImportModel, "buttonImportModel"); - this.buttonImportModel.ForeColor = System.Drawing.Color.White; - this.buttonImportModel.Name = "buttonImportModel"; - this.buttonImportModel.UseVisualStyleBackColor = true; - this.buttonImportModel.Click += new System.EventHandler(this.buttonImportModel_Click); - // // displayBox // this.displayBox.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(50)))), ((int)(((byte)(50)))), ((int)(((byte)(50))))); @@ -349,22 +338,6 @@ this.displayBox.Name = "displayBox"; this.displayBox.TabStop = false; // - // buttonExportModel - // - resources.ApplyResources(this.buttonExportModel, "buttonExportModel"); - this.buttonExportModel.ForeColor = System.Drawing.Color.White; - this.buttonExportModel.Name = "buttonExportModel"; - this.buttonExportModel.UseVisualStyleBackColor = true; - this.buttonExportModel.Click += new System.EventHandler(this.buttonExportModel_Click); - // - // OpenJSONButton - // - resources.ApplyResources(this.OpenJSONButton, "OpenJSONButton"); - this.OpenJSONButton.ForeColor = System.Drawing.Color.White; - this.OpenJSONButton.Name = "OpenJSONButton"; - this.OpenJSONButton.UseVisualStyleBackColor = true; - this.OpenJSONButton.Click += new System.EventHandler(this.OpenJSONButton_Click); - // // buttonTemplate // resources.ApplyResources(this.buttonTemplate, "buttonTemplate"); @@ -573,9 +546,6 @@ this.Controls.Add(this.buttonTemplate); this.Controls.Add(this.displayBox); this.Controls.Add(this.listViewBoxes); - this.Controls.Add(this.OpenJSONButton); - this.Controls.Add(this.buttonExportModel); - this.Controls.Add(this.buttonImportModel); this.Controls.Add(this.buttonEXPORT); this.Controls.Add(labelTextureMappingPreview); this.Controls.Add(this.uvPictureBox); @@ -625,10 +595,7 @@ private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem changeColorToolStripMenuItem; private System.Windows.Forms.Button buttonDone; - private System.Windows.Forms.Button OpenJSONButton; - private System.Windows.Forms.Button buttonExportModel; private System.Windows.Forms.PictureBox displayBox; - private System.Windows.Forms.Button buttonImportModel; private PckStudio.ToolboxItems.InterpolationPictureBox uvPictureBox; private System.Windows.Forms.Button buttonIMPORT; private System.Windows.Forms.Button buttonEXPORT; diff --git a/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs b/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs index 6d318052..6f125949 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs @@ -1166,62 +1166,6 @@ namespace PckStudio.Forms } } - // Exports model as csm file - private void buttonExportModel_Click(object sender, EventArgs e) - { - SaveFileDialog saveFileDialog = new SaveFileDialog(); - saveFileDialog.Filter = "Custom Skin Model File | *.CSM"; - if (saveFileDialog.ShowDialog(this) != DialogResult.OK) - return; - string contents = ""; - foreach (ListViewItem listViewItem in listViewBoxes.Items) - { - string str = ""; - foreach (ListViewItem.ListViewSubItem subItem in listViewItem.SubItems) - { - if (subItem.Text != "unchecked") - str = str + subItem.Text + Environment.NewLine; - } - contents += (listViewItem.Text + Environment.NewLine + listViewItem.Tag) + Environment.NewLine + str; - } - - File.WriteAllText(saveFileDialog.FileName, contents); - } - - - // Imports model from csm file - private void buttonImportModel_Click(object sender, EventArgs e) - { - OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.Filter = "Custom Skin Model File | *.CSM"; - openFileDialog.Title = "Select Custom Skin Model File"; - if (MessageBox.Show(this, "Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog(this) == DialogResult.OK) - { - listViewBoxes.Items.Clear(); - modelBoxes.Clear(); - StreamReader reader = new StreamReader(openFileDialog.FileName); - while (!reader.EndOfStream) - { - reader.ReadLine(); - string part = reader.ReadLine(); - reader.ReadLine(); - var posX = reader.ReadLine(); - var posY = reader.ReadLine(); - var posZ = reader.ReadLine(); - var sizeX = reader.ReadLine(); - var sizeY = reader.ReadLine(); - var sizeZ = reader.ReadLine(); - var uvX = reader.ReadLine(); - var uvY = reader.ReadLine(); - modelBoxes.Add(SkinBOX.FromString($"{part} {posX} {posY} {posZ} {sizeX} {sizeY} {sizeZ} {uvX} {uvY}")); - } - - } - comboParent.Enabled = true; - UpdateListView(); - Rerender(); - } - private void cloneToolStripMenuItem_Click(object sender, EventArgs e) { try @@ -1341,7 +1285,6 @@ namespace PckStudio.Forms e.Cancel = false;*/ } - //Del stuff using key private void delStuffUsingDelKey(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete && listViewBoxes.SelectedItems.Count != 0 && @@ -1357,124 +1300,5 @@ namespace PckStudio.Forms { Rerender(); } - - // TODO - private void OpenJSONButton_Click(object sender, EventArgs e) - { - OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.Filter = "JSON Model File | *.JSON"; - openFileDialog.Title = "Select JSON Model File"; - if (MessageBox.Show(this, "Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog(this) == DialogResult.OK) - { - listViewBoxes.Items.Clear(); - string str1 = JSONToCSM(openFileDialog.FileName); - int x = 0; - foreach (string str2 in str1.Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) - ++x; - int y = x / 11; - ListView listView = new ListView(); - int num3 = 0; - do - { - listView.Items.Add("BOX"); - ++num3; - } - while (num3 < y); - - - foreach (ListViewItem current in listView.Items) - { - ListViewItem listViewItem = new ListViewItem(); - int num4 = 0; - foreach (string text in str1.Split("\n\r".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)) - { - ++num4; - if (num4 == 1 + 11 * current.Index) - listViewItem.Text = text; - else if (num4 == 2 + 11 * current.Index) - listViewItem.Tag = text; - else if (num4 == 4 + 11 * current.Index) - listViewItem.SubItems.Add(text); - else if (num4 == 5 + 11 * current.Index) - listViewItem.SubItems.Add(text); - else if (num4 == 6 + 11 * current.Index) - listViewItem.SubItems.Add(text); - else if (num4 == 7 + 11 * current.Index) - listViewItem.SubItems.Add(text); - else if (num4 == 8 + 11 * current.Index) - listViewItem.SubItems.Add(text); - else if (num4 == 9 + 11 * current.Index) - listViewItem.SubItems.Add(text); - else if (num4 == 10 + 11 * current.Index) - listViewItem.SubItems.Add(text); - else if (num4 == 11 + 11 * current.Index) - { - listViewItem.SubItems.Add(text); - listViewBoxes.Items.Add(listViewItem); - } - } - } - } - Rerender(); - } - - [Obsolete("Just whyyyyy")] - public string JSONToCSM(string inputFilePath) - { - CSMJObject jsonDe = JsonConvert.DeserializeObject(File.ReadAllText(inputFilePath)); - StringBuilder sb = new StringBuilder(); - foreach (CSMJObjectGroup group in jsonDe.Groups) - { - string parent = group.Name; - foreach (int i in group.children) - { - string name = jsonDe.Elements[i].Name; - float posX = jsonDe.Elements[i].from[0] + group.origin[0]; - float posY = jsonDe.Elements[i].from[1] + group.origin[1]; - float posZ = jsonDe.Elements[i].from[2] + group.origin[2]; - float sizeX = jsonDe.Elements[i].to[0] - jsonDe.Elements[i].from[0]; - float sizeY = jsonDe.Elements[i].to[1] - jsonDe.Elements[i].from[1]; - float sizeZ = jsonDe.Elements[i].to[2] - jsonDe.Elements[i].from[2]; - float u = 0; - float v = 0; - - sb.AppendLine(name + "\n" + parent + "\n" + name + "\n" + posX + "\n" + posY + "\n" + posZ + "\n" + sizeX + "\n" + sizeY + "\n" + sizeZ + "\n" + u + "\n" + v); - } - } - return sb.ToString(); - } - } - - class CSMJObject - { - [JsonProperty("credit")] - public string Credit { get; set; } - - [JsonProperty("texture_size")] - public int[] TextureSize; - - [JsonProperty("elements")] - public CSMJObjectElement[] Elements; - - [JsonProperty("groups")] - public CSMJObjectGroup[] Groups; - } - - class CSMJObjectElement - { - [JsonProperty("name")] - public string Name { get; set; } - - public float[] from; - public float[] to; - } - - class CSMJObjectGroup - { - [JsonProperty("name")] - public string Name { get; set; } - - public float[] origin; - public int[] children; } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Skins-And-Textures/generateModel.resx b/PCK-Studio/Forms/Skins-And-Textures/generateModel.resx index 1fa4fc59..da2157ab 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/generateModel.resx +++ b/PCK-Studio/Forms/Skins-And-Textures/generateModel.resx @@ -151,7 +151,7 @@ $this - 22 + 19 False @@ -184,7 +184,7 @@ $this - 31 + 28 False @@ -217,7 +217,7 @@ $this - 30 + 27 False @@ -250,7 +250,7 @@ $this - 25 + 22 False @@ -283,7 +283,7 @@ $this - 19 + 16 17, 17 @@ -394,7 +394,7 @@ $this - 29 + 26 True @@ -424,7 +424,7 @@ $this - 28 + 25 Flat @@ -454,7 +454,7 @@ $this - 27 + 24 Flat @@ -484,7 +484,7 @@ $this - 26 + 23 4, 22 @@ -859,7 +859,7 @@ $this - 24 + 21 HEAD @@ -898,7 +898,7 @@ $this - 21 + 18 Flat @@ -928,7 +928,7 @@ $this - 18 + 15 Flat @@ -958,7 +958,7 @@ $this - 23 + 20 NoControl @@ -979,42 +979,12 @@ uvPictureBox - PckStudio.PictureBoxWithInterpolationMode, PCK-Studio, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null + PckStudio.ToolboxItems.InterpolationPictureBox, PCK-Studio, Version=7.0.0.2, Culture=neutral, PublicKeyToken=null $this - 20 - - - Flat - - - NoControl - - - 306, 677 - - - 106, 21 - - - 96 - - - OPEN CSM - - - buttonImportModel - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - 17 @@ -1044,66 +1014,6 @@ 13 - - Flat - - - NoControl - - - 418, 677 - - - 89, 21 - - - 97 - - - EXPORT CSM - - - buttonExportModel - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 16 - - - Flat - - - NoControl - - - 194, 677 - - - 106, 21 - - - 145 - - - OPEN JSON - - - OpenJSONButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 15 - 23, 511