From dfe9912e28959d4cbe46364e4f0e9e216e7cb0c4 Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Fri, 19 Jan 2024 18:52:27 +0100 Subject: [PATCH] Rename generateModel to CustomSkinEditor --- .../Forms/Skins-And-Textures/AddNewSkin.cs | 2 +- ...igner.cs => CustomModelEditor.Designer.cs} | 232 ++--- .../Skins-And-Textures/CustomModelEditor.cs | 490 +++++++++++ ...odel.ja.resx => CustomModelEditor.ja.resx} | 0 ...erateModel.resx => CustomModelEditor.resx} | 464 +++------- .../Forms/Skins-And-Textures/generateModel.cs | 801 ------------------ PCK-Studio/Internal/SkinBOX.cs | 2 +- PCK-Studio/MainForm.cs | 2 +- PCK-Studio/PckStudio.csproj | 17 +- 9 files changed, 679 insertions(+), 1331 deletions(-) rename PCK-Studio/Forms/Skins-And-Textures/{generateModel.Designer.cs => CustomModelEditor.Designer.cs} (73%) create mode 100644 PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.cs rename PCK-Studio/Forms/Skins-And-Textures/{generateModel.ja.resx => CustomModelEditor.ja.resx} (100%) rename PCK-Studio/Forms/Skins-And-Textures/{generateModel.resx => CustomModelEditor.resx} (95%) delete mode 100644 PCK-Studio/Forms/Skins-And-Textures/generateModel.cs diff --git a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs index 3f34cb3d..d21349fe 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/AddNewSkin.cs @@ -280,7 +280,7 @@ namespace PckStudio.Popups skin.SetData(Resources.classic_template, ImageFormat.Png); - using generateModel generate = new generateModel(skin); + using CustomModelEditor generate = new CustomModelEditor(skin); if (generate.ShowDialog() == DialogResult.OK) { diff --git a/PCK-Studio/Forms/Skins-And-Textures/generateModel.Designer.cs b/PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.Designer.cs similarity index 73% rename from PCK-Studio/Forms/Skins-And-Textures/generateModel.Designer.cs rename to PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.Designer.cs index a6b0c538..6f7d7ee0 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/generateModel.Designer.cs +++ b/PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.Designer.cs @@ -1,6 +1,6 @@ namespace PckStudio.Forms { - partial class generateModel + partial class CustomModelEditor { /// /// Required designer variable. @@ -29,9 +29,8 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.Label label6; - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(generateModel)); System.Windows.Forms.Label label5; + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomModelEditor)); System.Windows.Forms.Label label3; System.Windows.Forms.Label label7; System.Windows.Forms.Label labelTextureMappingPreview; @@ -41,8 +40,7 @@ this.cloneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.changeColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.buttonDone = new System.Windows.Forms.Button(); - this.labelView = new System.Windows.Forms.Label(); + this.buttonDone = new MetroFramework.Controls.MetroButton(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.tabBody = new System.Windows.Forms.TabControl(); this.tabArmor = new System.Windows.Forms.TabPage(); @@ -56,13 +54,11 @@ this.label13 = new System.Windows.Forms.Label(); this.offsetHead = new System.Windows.Forms.TextBox(); this.label12 = new System.Windows.Forms.Label(); - this.comboParent = new System.Windows.Forms.ComboBox(); - this.buttonEXPORT = new System.Windows.Forms.Button(); - this.buttonIMPORT = new System.Windows.Forms.Button(); - this.buttonImportModel = new System.Windows.Forms.Button(); - this.buttonExportModel = new System.Windows.Forms.Button(); - this.OpenJSONButton = new System.Windows.Forms.Button(); - this.buttonTemplate = new MetroFramework.Controls.MetroButton(); + this.buttonEXPORT = new MetroFramework.Controls.MetroButton(); + this.buttonIMPORT = new MetroFramework.Controls.MetroButton(); + this.buttonImportModel = new MetroFramework.Controls.MetroButton(); + this.buttonExportModel = new MetroFramework.Controls.MetroButton(); + this.OpenJSONButton = new MetroFramework.Controls.MetroButton(); this.generateTextureCheckBox = new MetroFramework.Controls.MetroCheckBox(); this.checkGuide = new MetroFramework.Controls.MetroCheckBox(); this.checkBoxArmor = new MetroFramework.Controls.MetroCheckBox(); @@ -74,19 +70,9 @@ this.PosZUpDown = new System.Windows.Forms.NumericUpDown(); this.PosYUpDown = new System.Windows.Forms.NumericUpDown(); this.PosXUpDown = new System.Windows.Forms.NumericUpDown(); - this.Part = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.X = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Y = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Z = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this._Width = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this._Height = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Length = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.U = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.V = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.listViewBoxes = new System.Windows.Forms.ListView(); this.renderer3D1 = new PckStudio.Rendering.SkinRenderer(); this.uvPictureBox = new PckStudio.ToolboxItems.InterpolationPictureBox(); - label6 = new System.Windows.Forms.Label(); + this.listBox1 = new System.Windows.Forms.ListBox(); label5 = new System.Windows.Forms.Label(); label3 = new System.Windows.Forms.Label(); label7 = new System.Windows.Forms.Label(); @@ -107,12 +93,6 @@ ((System.ComponentModel.ISupportInitialize)(this.uvPictureBox)).BeginInit(); this.SuspendLayout(); // - // label6 - // - resources.ApplyResources(label6, "label6"); - label6.ForeColor = System.Drawing.Color.White; - label6.Name = "label6"; - // // label5 // resources.ApplyResources(label5, "label5"); @@ -170,28 +150,22 @@ // resources.ApplyResources(this.changeColorToolStripMenuItem, "changeColorToolStripMenuItem"); this.changeColorToolStripMenuItem.Name = "changeColorToolStripMenuItem"; - this.changeColorToolStripMenuItem.Click += new System.EventHandler(this.changeColorToolStripMenuItem_Click); // // buttonDone // - this.buttonDone.DialogResult = System.Windows.Forms.DialogResult.OK; resources.ApplyResources(this.buttonDone, "buttonDone"); + this.buttonDone.DialogResult = System.Windows.Forms.DialogResult.OK; this.buttonDone.ForeColor = System.Drawing.Color.White; this.buttonDone.Name = "buttonDone"; - this.buttonDone.UseVisualStyleBackColor = true; + this.buttonDone.Theme = MetroFramework.MetroThemeStyle.Dark; + this.buttonDone.UseSelectable = true; this.buttonDone.Click += new System.EventHandler(this.buttonDone_Click); // - // labelView - // - resources.ApplyResources(this.labelView, "labelView"); - this.labelView.ForeColor = System.Drawing.Color.White; - this.labelView.Name = "labelView"; - // // groupBox1 // + resources.ApplyResources(this.groupBox1, "groupBox1"); this.groupBox1.Controls.Add(this.tabBody); this.groupBox1.ForeColor = System.Drawing.Color.White; - resources.ApplyResources(this.groupBox1, "groupBox1"); this.groupBox1.Name = "groupBox1"; this.groupBox1.TabStop = false; // @@ -233,7 +207,6 @@ // resources.ApplyResources(this.offsetArms, "offsetArms"); this.offsetArms.Name = "offsetArms"; - this.offsetArms.TextChanged += new System.EventHandler(this.offsetHead_TextChanged); // // label14 // @@ -245,13 +218,11 @@ // resources.ApplyResources(this.offsetBody, "offsetBody"); this.offsetBody.Name = "offsetBody"; - this.offsetBody.TextChanged += new System.EventHandler(this.offsetHead_TextChanged); // // offsetLegs // resources.ApplyResources(this.offsetLegs, "offsetLegs"); this.offsetLegs.Name = "offsetLegs"; - this.offsetLegs.TextChanged += new System.EventHandler(this.offsetHead_TextChanged); // // label10 // @@ -269,7 +240,6 @@ // resources.ApplyResources(this.offsetHead, "offsetHead"); this.offsetHead.Name = "offsetHead"; - this.offsetHead.TextChanged += new System.EventHandler(this.offsetHead_TextChanged); // // label12 // @@ -277,26 +247,13 @@ this.label12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(0))))); this.label12.Name = "label12"; // - // comboParent - // - this.comboParent.FormattingEnabled = true; - this.comboParent.Items.AddRange(new object[] { - resources.GetString("comboParent.Items"), - resources.GetString("comboParent.Items1"), - resources.GetString("comboParent.Items2"), - resources.GetString("comboParent.Items3"), - resources.GetString("comboParent.Items4"), - resources.GetString("comboParent.Items5")}); - resources.ApplyResources(this.comboParent, "comboParent"); - this.comboParent.Name = "comboParent"; - this.comboParent.SelectedValueChanged += new System.EventHandler(this.comboParent_SelectedIndexChanged); - // // buttonEXPORT // resources.ApplyResources(this.buttonEXPORT, "buttonEXPORT"); this.buttonEXPORT.ForeColor = System.Drawing.Color.White; this.buttonEXPORT.Name = "buttonEXPORT"; - this.buttonEXPORT.UseVisualStyleBackColor = true; + this.buttonEXPORT.Theme = MetroFramework.MetroThemeStyle.Dark; + this.buttonEXPORT.UseSelectable = true; this.buttonEXPORT.Click += new System.EventHandler(this.buttonEXPORT_Click); // // buttonIMPORT @@ -304,7 +261,8 @@ resources.ApplyResources(this.buttonIMPORT, "buttonIMPORT"); this.buttonIMPORT.ForeColor = System.Drawing.Color.White; this.buttonIMPORT.Name = "buttonIMPORT"; - this.buttonIMPORT.UseVisualStyleBackColor = true; + this.buttonIMPORT.Theme = MetroFramework.MetroThemeStyle.Dark; + this.buttonIMPORT.UseSelectable = true; this.buttonIMPORT.Click += new System.EventHandler(this.buttonIMPORT_Click); // // buttonImportModel @@ -312,7 +270,8 @@ resources.ApplyResources(this.buttonImportModel, "buttonImportModel"); this.buttonImportModel.ForeColor = System.Drawing.Color.White; this.buttonImportModel.Name = "buttonImportModel"; - this.buttonImportModel.UseVisualStyleBackColor = true; + this.buttonImportModel.Theme = MetroFramework.MetroThemeStyle.Dark; + this.buttonImportModel.UseSelectable = true; this.buttonImportModel.Click += new System.EventHandler(this.buttonImportModel_Click); // // buttonExportModel @@ -320,7 +279,8 @@ resources.ApplyResources(this.buttonExportModel, "buttonExportModel"); this.buttonExportModel.ForeColor = System.Drawing.Color.White; this.buttonExportModel.Name = "buttonExportModel"; - this.buttonExportModel.UseVisualStyleBackColor = true; + this.buttonExportModel.Theme = MetroFramework.MetroThemeStyle.Dark; + this.buttonExportModel.UseSelectable = true; this.buttonExportModel.Click += new System.EventHandler(this.buttonExportModel_Click); // // OpenJSONButton @@ -328,17 +288,10 @@ resources.ApplyResources(this.OpenJSONButton, "OpenJSONButton"); this.OpenJSONButton.ForeColor = System.Drawing.Color.White; this.OpenJSONButton.Name = "OpenJSONButton"; - this.OpenJSONButton.UseVisualStyleBackColor = true; + this.OpenJSONButton.Theme = MetroFramework.MetroThemeStyle.Dark; + this.OpenJSONButton.UseSelectable = true; this.OpenJSONButton.Click += new System.EventHandler(this.OpenJSONButton_Click); // - // buttonTemplate - // - resources.ApplyResources(this.buttonTemplate, "buttonTemplate"); - this.buttonTemplate.Name = "buttonTemplate"; - this.buttonTemplate.Theme = MetroFramework.MetroThemeStyle.Dark; - this.buttonTemplate.UseSelectable = true; - this.buttonTemplate.Click += new System.EventHandler(this.buttonTemplate_Click); - // // generateTextureCheckBox // resources.ApplyResources(this.generateTextureCheckBox, "generateTextureCheckBox"); @@ -362,168 +315,96 @@ // // SizeXUpDown // + resources.ApplyResources(this.SizeXUpDown, "SizeXUpDown"); this.SizeXUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); this.SizeXUpDown.DecimalPlaces = 1; this.SizeXUpDown.ForeColor = System.Drawing.SystemColors.Menu; - resources.ApplyResources(this.SizeXUpDown, "SizeXUpDown"); this.SizeXUpDown.Name = "SizeXUpDown"; - this.SizeXUpDown.ValueChanged += new System.EventHandler(this.SizeXUpDown_ValueChanged); // // SizeYUpDown // + resources.ApplyResources(this.SizeYUpDown, "SizeYUpDown"); this.SizeYUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); this.SizeYUpDown.DecimalPlaces = 1; this.SizeYUpDown.ForeColor = System.Drawing.SystemColors.Menu; - resources.ApplyResources(this.SizeYUpDown, "SizeYUpDown"); this.SizeYUpDown.Name = "SizeYUpDown"; - this.SizeYUpDown.ValueChanged += new System.EventHandler(this.SizeYUpDown_ValueChanged); // // SizeZUpDown // + resources.ApplyResources(this.SizeZUpDown, "SizeZUpDown"); this.SizeZUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); this.SizeZUpDown.DecimalPlaces = 1; this.SizeZUpDown.ForeColor = System.Drawing.SystemColors.Menu; - resources.ApplyResources(this.SizeZUpDown, "SizeZUpDown"); this.SizeZUpDown.Name = "SizeZUpDown"; - this.SizeZUpDown.ValueChanged += new System.EventHandler(this.SizeZUpDown_ValueChanged); // // TextureXUpDown // + resources.ApplyResources(this.TextureXUpDown, "TextureXUpDown"); this.TextureXUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); this.TextureXUpDown.ForeColor = System.Drawing.SystemColors.Menu; - resources.ApplyResources(this.TextureXUpDown, "TextureXUpDown"); this.TextureXUpDown.Maximum = new decimal(new int[] { 64, 0, 0, 0}); this.TextureXUpDown.Name = "TextureXUpDown"; - this.TextureXUpDown.ValueChanged += new System.EventHandler(this.TextureXUpDown_ValueChanged); // // TextureYUpDown // + resources.ApplyResources(this.TextureYUpDown, "TextureYUpDown"); this.TextureYUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); this.TextureYUpDown.ForeColor = System.Drawing.SystemColors.Menu; - resources.ApplyResources(this.TextureYUpDown, "TextureYUpDown"); this.TextureYUpDown.Maximum = new decimal(new int[] { 64, 0, 0, 0}); this.TextureYUpDown.Name = "TextureYUpDown"; - this.TextureYUpDown.ValueChanged += new System.EventHandler(this.TextureYUpDown_ValueChanged); // // PosZUpDown // + resources.ApplyResources(this.PosZUpDown, "PosZUpDown"); this.PosZUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); this.PosZUpDown.DecimalPlaces = 1; this.PosZUpDown.ForeColor = System.Drawing.SystemColors.Menu; - resources.ApplyResources(this.PosZUpDown, "PosZUpDown"); this.PosZUpDown.Minimum = new decimal(new int[] { 100, 0, 0, -2147483648}); this.PosZUpDown.Name = "PosZUpDown"; - this.PosZUpDown.ValueChanged += new System.EventHandler(this.PosZUpDown_ValueChanged); // // PosYUpDown // + resources.ApplyResources(this.PosYUpDown, "PosYUpDown"); this.PosYUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); this.PosYUpDown.DecimalPlaces = 1; this.PosYUpDown.ForeColor = System.Drawing.SystemColors.Menu; - resources.ApplyResources(this.PosYUpDown, "PosYUpDown"); this.PosYUpDown.Minimum = new decimal(new int[] { 100, 0, 0, -2147483648}); this.PosYUpDown.Name = "PosYUpDown"; - this.PosYUpDown.ValueChanged += new System.EventHandler(this.PosYUpDown_ValueChanged); // // PosXUpDown // + resources.ApplyResources(this.PosXUpDown, "PosXUpDown"); this.PosXUpDown.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(17)))), ((int)(((byte)(17)))), ((int)(((byte)(17))))); this.PosXUpDown.DecimalPlaces = 1; this.PosXUpDown.ForeColor = System.Drawing.SystemColors.Menu; - resources.ApplyResources(this.PosXUpDown, "PosXUpDown"); this.PosXUpDown.Minimum = new decimal(new int[] { 100, 0, 0, -2147483648}); this.PosXUpDown.Name = "PosXUpDown"; - this.PosXUpDown.ValueChanged += new System.EventHandler(this.PosXUpDown_ValueChanged); - // - // Part - // - resources.ApplyResources(this.Part, "Part"); - // - // X - // - resources.ApplyResources(this.X, "X"); - // - // Y - // - resources.ApplyResources(this.Y, "Y"); - // - // Z - // - resources.ApplyResources(this.Z, "Z"); - // - // _Width - // - resources.ApplyResources(this._Width, "_Width"); - // - // _Height - // - resources.ApplyResources(this._Height, "_Height"); - // - // Length - // - resources.ApplyResources(this.Length, "Length"); - // - // U - // - resources.ApplyResources(this.U, "U"); - // - // V - // - resources.ApplyResources(this.V, "V"); - // - // listViewBoxes - // - this.listViewBoxes.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.listViewBoxes.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.Part, - this.X, - this.Y, - this.Z, - this._Width, - this._Height, - this.Length, - this.U, - this.V}); - this.listViewBoxes.ContextMenuStrip = this.contextMenuStrip1; - this.listViewBoxes.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); - this.listViewBoxes.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.listViewBoxes.HideSelection = false; - this.listViewBoxes.LabelEdit = true; - resources.ApplyResources(this.listViewBoxes, "listViewBoxes"); - this.listViewBoxes.MultiSelect = false; - this.listViewBoxes.Name = "listViewBoxes"; - this.listViewBoxes.UseCompatibleStateImageBehavior = false; - this.listViewBoxes.View = System.Windows.Forms.View.Details; - this.listViewBoxes.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged); - this.listViewBoxes.Click += new System.EventHandler(this.listView1_Click); - this.listViewBoxes.DoubleClick += new System.EventHandler(this.listView1_DoubleClick); - this.listViewBoxes.KeyDown += new System.Windows.Forms.KeyEventHandler(this.delStuffUsingDelKey); // // renderer3D1 // resources.ApplyResources(this.renderer3D1, "renderer3D1"); this.renderer3D1.ANIM = skinANIM1; - this.renderer3D1.BackColor = System.Drawing.Color.DarkGray; + this.renderer3D1.BackColor = System.Drawing.Color.DimGray; this.renderer3D1.CameraTarget = ((OpenTK.Vector2)(resources.GetObject("renderer3D1.CameraTarget"))); this.renderer3D1.Name = "renderer3D1"; this.renderer3D1.Texture = null; @@ -532,16 +413,26 @@ // // uvPictureBox // - this.uvPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; resources.ApplyResources(this.uvPictureBox, "uvPictureBox"); + this.uvPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.uvPictureBox.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; this.uvPictureBox.Name = "uvPictureBox"; this.uvPictureBox.TabStop = false; // - // generateModel + // listBox1 + // + this.listBox1.ContextMenuStrip = this.contextMenuStrip1; + this.listBox1.FormattingEnabled = true; + resources.ApplyResources(this.listBox1, "listBox1"); + this.listBox1.Name = "listBox1"; + this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged); + this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick); + // + // CustomModelEditor // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.listBox1); this.Controls.Add(this.renderer3D1); this.Controls.Add(this.PosZUpDown); this.Controls.Add(this.PosYUpDown); @@ -554,30 +445,23 @@ this.Controls.Add(this.checkBoxArmor); this.Controls.Add(this.checkGuide); this.Controls.Add(this.generateTextureCheckBox); - this.Controls.Add(this.buttonTemplate); - 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); - this.Controls.Add(this.comboParent); - this.Controls.Add(label6); this.Controls.Add(this.buttonIMPORT); this.Controls.Add(this.groupBox1); this.Controls.Add(label7); - this.Controls.Add(this.labelView); this.Controls.Add(this.buttonDone); this.Controls.Add(label3); this.Controls.Add(label5); this.MaximizeBox = false; - this.Name = "generateModel"; + this.Name = "CustomModelEditor"; this.Style = MetroFramework.MetroColorStyle.Silver; this.Theme = MetroFramework.MetroThemeStyle.Dark; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.generateModel_FormClosing); - this.Load += new System.EventHandler(this.generateModel_Load); - this.SizeChanged += new System.EventHandler(this.generateModel_SizeChanged); this.contextMenuStrip1.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.tabBody.ResumeLayout(false); @@ -604,14 +488,13 @@ private System.Windows.Forms.ToolStripMenuItem cloneToolStripMenuItem; 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.Button buttonImportModel; + private MetroFramework.Controls.MetroButton buttonDone; + private MetroFramework.Controls.MetroButton OpenJSONButton; + private MetroFramework.Controls.MetroButton buttonExportModel; + private MetroFramework.Controls.MetroButton buttonImportModel; private PckStudio.ToolboxItems.InterpolationPictureBox uvPictureBox; - private System.Windows.Forms.Button buttonIMPORT; - private System.Windows.Forms.Button buttonEXPORT; - private System.Windows.Forms.ComboBox comboParent; + private MetroFramework.Controls.MetroButton buttonIMPORT; + private MetroFramework.Controls.MetroButton buttonEXPORT; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.TabControl tabBody; private System.Windows.Forms.TabPage tabPage1; @@ -625,8 +508,6 @@ private System.Windows.Forms.TextBox offsetHead; private System.Windows.Forms.Label label12; private System.Windows.Forms.TabPage tabArmor; - private System.Windows.Forms.Label labelView; - private MetroFramework.Controls.MetroButton buttonTemplate; private MetroFramework.Controls.MetroCheckBox generateTextureCheckBox; private MetroFramework.Controls.MetroCheckBox checkGuide; private MetroFramework.Controls.MetroCheckBox checkBoxArmor; @@ -638,16 +519,7 @@ private System.Windows.Forms.NumericUpDown PosZUpDown; private System.Windows.Forms.NumericUpDown PosYUpDown; private System.Windows.Forms.NumericUpDown PosXUpDown; - private System.Windows.Forms.ColumnHeader Part; - private System.Windows.Forms.ColumnHeader X; - private System.Windows.Forms.ColumnHeader Y; - private System.Windows.Forms.ColumnHeader Z; - private System.Windows.Forms.ColumnHeader _Width; - private System.Windows.Forms.ColumnHeader _Height; - private System.Windows.Forms.ColumnHeader Length; - private System.Windows.Forms.ColumnHeader U; - private System.Windows.Forms.ColumnHeader V; - private System.Windows.Forms.ListView listViewBoxes; private Rendering.SkinRenderer renderer3D1; + private System.Windows.Forms.ListBox listBox1; } } \ No newline at end of file diff --git a/PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.cs b/PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.cs new file mode 100644 index 00000000..68ef0909 --- /dev/null +++ b/PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.cs @@ -0,0 +1,490 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; +using System.Linq; +using System.Windows.Forms; +using System.Collections; +using System.IO; +using System.Text.RegularExpressions; + +using Newtonsoft.Json; +using MetroFramework.Forms; +using OMI.Formats.Pck; +using PckStudio.Internal; +using PckStudio.Extensions; +using System.Diagnostics; +using System.Text; +using PckStudio.Forms.Editor; + +namespace PckStudio.Forms +{ + public partial class CustomModelEditor : MetroForm + { + private Image _previewImage; + public Image PreviewImage => _previewImage; + + private PckFileData _file; + + private static GraphicsConfig _graphicsConfig = new GraphicsConfig() + { + InterpolationMode = InterpolationMode.NearestNeighbor, + PixelOffsetMode = PixelOffsetMode.HighQuality, + }; + + private static readonly string[] ValidModelBoxTypes = new string[] + { + // Base 64x32 Parts + "HEAD", + "BODY", + "ARM0", + "ARM1", + "LEG0", + "LEG1", + + // 64x64 Overlay Parts + "HEADWEAR", + "JACKET", + "SLEEVE0", + "SLEEVE1", + "WAIST", + "PANTS0", + "PANTS1", + + // Armor Parts + "BODYARMOR", + "ARMARMOR0", + "ARMARMOR1", + "BELT", + "LEGGING0", + "LEGGING1", + "SOCK0", + "SOCK1", + "BOOT0", + "BOOT1" + }; + + private static readonly string[] ValidModelOffsetTypes = new string[] + { + // Body Offsets + "HEAD", + "BODY", + "ARM0", + "ARM1", + "LEG0", + "LEG1", + + // Armor Offsets + "HELMET", + "CHEST", "BODYARMOR", + "SHOULDER0", "ARMARMOR0", + "SHOULDER1", "ARMARMOR0", + "BELT", + "LEGGING0", + "LEGGING1", + "SOCK0", "BOOT0", + "SOCK1", "BOOT1", + + "TOOL0", + "TOOL1", + }; + + List modelOffsets = new List(); + + private readonly struct ModelOffset + { + public readonly string Name; + public readonly float YOffset; + + public ModelOffset(string name, float yOffset) + { + Name = name; + YOffset = yOffset; + } + public (string, string) ToProperty() + { + string value = $"{Name} Y {YOffset}"; + return ("OFFSET", value.Replace(',','.')); + } + } + + public CustomModelEditor(PckFileData file) + { + InitializeComponent(); + + _file = file; + if (_file.Size > 0) + { + uvPictureBox.Image = renderer3D1.Texture = _file.GetTexture(); + } + //comboParent.Items.AddRange(ValidModelBoxTypes); + LoadModelData(file.Properties); + } + + private static readonly Regex sWhitespace = new Regex(@"\s+"); + public static string ReplaceWhitespace(string input, string replacement) + { + return sWhitespace.Replace(input, replacement); + } + + private void LoadModelData(PckFileProperties properties) + { + renderer3D1.ANIM = properties.GetPropertyValue("ANIM", SkinANIM.FromString); + var boxProperties = properties.GetProperties("BOX"); + + Array.ForEach(boxProperties, kv => renderer3D1.ModelData.Add(SkinBOX.FromString(kv.Value))); + listBox1.DataSource = renderer3D1.ModelData; + listBox1.DisplayMember = "Type"; + + properties.GetProperties("OFFSET").All(kv => { + string[] offset = ReplaceWhitespace(kv.Value, ",").TrimEnd('\n', '\r', ' ').Split(','); + if (offset.Length < 3) + return false; + string name = offset[0]; + if (offset[1] != "Y") + return false; + float value = float.Parse(offset[2]); + if (ValidModelOffsetTypes.Contains(name)) + { + modelOffsets.Add(new ModelOffset(name, value)); + return true; + } + return false; + }); + } + + private void GenerateUVTextureMap() + { + Random rng = new Random(); + using (Graphics graphics = Graphics.FromImage(uvPictureBox.Image)) + { + graphics.ApplyConfig(_graphicsConfig); + //foreach (var part in modelBoxes) + //{ + // float width = part.Size.X * 2; + // float height = part.Size.Y * 2; + // float length = part.Size.Z * 2; + // float u = part.UV.X * 2; + // float v = part.UV.Y * 2; + // int argb = rng.Next(-16777216, -1); // 0xFF000000 - 0xFFFFFFFF + // var color = Color.FromArgb(argb); + // Brush brush = new SolidBrush(color); + // graphics.FillRectangle(brush, u + length, v, width, length); + // graphics.FillRectangle(brush, u + length + width, v, width, length); + // graphics.FillRectangle(brush, u, length + v, length, height); + // graphics.FillRectangle(brush, u + length, v + length, width, height); + // graphics.FillRectangle(brush, u + length + width, v + length, width, height); + // graphics.FillRectangle(brush, u + length + width * 2, v + length, length, height); + //} + } + uvPictureBox.Invalidate(); + } + + private void createToolStripMenuItem_Click(object sender, EventArgs e) + { + var boxEditor = new BoxEditor(SkinBOX.Empty, false); + if (boxEditor.ShowDialog() == DialogResult.OK) + renderer3D1.ModelData.Add(boxEditor.Result); + } + + //Export Current Skin Texture + private void buttonEXPORT_Click(object sender, EventArgs e) + { + Bitmap bitmap = new Bitmap(uvPictureBox.Image, 64, 64); + using SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.Filter = "PNG Image Files | *.png"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + bitmap.Save(saveFileDialog.FileName, ImageFormat.Png); + } + } + + //Imports Skin Texture + private void buttonIMPORT_Click(object sender, EventArgs e) + { + OpenFileDialog openFileDialog = new OpenFileDialog(); + openFileDialog.Filter = "PNG Image Files | *.png"; + openFileDialog.Title = "Select Skin Texture"; + + if (openFileDialog.ShowDialog() == DialogResult.OK) // skins can only be a 1:1 ratio (base 64x64) or a 2:1 ratio (base 64x32) + { + using (var img = Image.FromFile(openFileDialog.FileName)) + { + if ((img.Width == img.Height || img.Height == img.Width / 2)) + { + generateTextureCheckBox.Checked = false; + using (Graphics graphics = Graphics.FromImage(uvPictureBox.Image)) + { + graphics.ApplyConfig(_graphicsConfig); + graphics.DrawImage(img, 0, 0, img.Width, img.Height); + } + uvPictureBox.Invalidate(); + } + else + { + MessageBox.Show(this, "Not a valid skin file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + // Creates Model Data and Finalizes + private void buttonDone_Click(object sender, EventArgs e) + { + foreach (var part in renderer3D1.ModelData) + { + _file.Properties.Add("BOX", part); + } + var img = new Bitmap(renderer3D1.Size.Width, renderer3D1.Size.Height); + renderer3D1.DrawToBitmap(img, renderer3D1.Bounds); + _previewImage = img; + DialogResult = DialogResult.OK; + } + + // 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() != 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); + } + + [Obsolete("Kept for backwards compatibility, remove later.")] + 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("Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog() == DialogResult.OK) + { + renderer3D1.ModelData.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(); + renderer3D1.ModelData.Add(SkinBOX.FromString($"{part} {PosX} {PosY} {PosZ} {SizeX} {SizeY} {SizeZ} {UvX} {UvY}")); + } + } + } + + private void cloneToolStripMenuItem_Click(object sender, EventArgs e) + { + //try + //{ + // ListViewItem listViewItem = new ListViewItem(); + // var selected = listViewBoxes.SelectedItems[0]; + // listViewItem.Text = selected.Text; + // listViewItem.Tag = selected.Tag; + // int num = 0; + // foreach (ListViewItem.ListViewSubItem subItem in selected.SubItems) + // { + // if (num > 0) + // listViewItem.SubItems.Add(subItem.Text); + // ++num; + // } + // listViewBoxes.Items.Add(listViewItem); + //} + //catch (Exception ex) + //{ + // Console.WriteLine(ex.Message); + // MessageBox.Show("Please Select a Part"); + //} + } + + private void deleteToolStripMenuItem_Click(object sender, EventArgs e) + { + if (listBox1.SelectedItem is SkinBOX box) + { + renderer3D1.ModelData.Remove(box); + } + } + + private void generateModel_FormClosing(object sender, FormClosingEventArgs e) + { + /*if (MessageBox.Show("You done here?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) + { + e.Cancel = true; + return; + } + e.Cancel = false;*/ + } + + //Del stuff using key + private void delStuffUsingDelKey(object sender, KeyEventArgs e) + { + //if (e.KeyCode == Keys.Delete && listViewBoxes.SelectedItems.Count != 0 && + // listViewBoxes.SelectedItems[0].Tag is SkinBOX part) + //{ + // if (modelBoxes.Remove(part)) + // listViewBoxes.SelectedItems[0].Remove(); + + //} + } + + 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("Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog() == DialogResult.OK) + { + //listViewBoxes.Items.Clear(); + string str1 = JSONToCSM(File.ReadAllText(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); + } + } + } + } + + } + + [Obsolete("Will be removed")] + public string JSONToCSM(string inputJson) + { + CSMJObject jsonDe = JsonConvert.DeserializeObject(inputJson); + 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(); + } + + private void renderer3D1_TextureChanging(object sender, Rendering.TextureChangingEventArgs e) + { + // TODO: add validation for 64x64 and 64x32 + uvPictureBox.Image = e.NewTexture; + } + + private void listBox1_DoubleClick(object sender, EventArgs e) + { + if (listBox1.SelectedItem is SkinBOX box) + { + var boxEditor = new BoxEditor(box, false); + if (boxEditor.ShowDialog() == DialogResult.OK) + { + renderer3D1.ModelData[listBox1.SelectedIndex] = boxEditor.Result; + listBox1.Update(); + } + } + } + + private void listBox1_SelectedIndexChanged(object sender, EventArgs e) + { + //renderer3D1.SelectedIndex = listBox1.SelectedIndex; + } + } + + 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.ja.resx b/PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.ja.resx similarity index 100% rename from PCK-Studio/Forms/Skins-And-Textures/generateModel.ja.resx rename to PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.ja.resx diff --git a/PCK-Studio/Forms/Skins-And-Textures/generateModel.resx b/PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.resx similarity index 95% rename from PCK-Studio/Forms/Skins-And-Textures/generateModel.resx rename to PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.resx index a86ee9ab..78ab88b5 100644 --- a/PCK-Studio/Forms/Skins-And-Textures/generateModel.resx +++ b/PCK-Studio/Forms/Skins-And-Textures/CustomModelEditor.resx @@ -117,51 +117,21 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - False - - - - True - - - - NoControl - - - - 23, 459 - - - 38, 13 - - - 137 - - - Parent - - - label6 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 22 - False + + + Top, Right + + True NoControl + 691, 357 @@ -184,11 +154,14 @@ $this - 29 + 25 False + + Top, Right + True @@ -217,7 +190,7 @@ $this - 28 + 24 False @@ -250,11 +223,14 @@ $this - 25 + 22 False + + Top, Right + True @@ -283,7 +259,7 @@ $this - 19 + 18 17, 17 @@ -300,7 +276,7 @@ 151, 26 - Create + Add Cube @@ -338,6 +314,9 @@ Delete + + False + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO @@ -366,14 +345,11 @@ System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Flat - - - NoControl + + Bottom, Right - 654, 676 + 653, 663 130, 22 @@ -388,43 +364,16 @@ buttonDone - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MetroFramework.Controls.MetroButton, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a $this - 27 + 23 - - True - - - NoControl - - - 289, 647 - - - 33, 13 - - - 102 - - - View: - - - labelView - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 26 + + Top, Right 4, 22 @@ -799,52 +748,10 @@ $this - 24 - - - HEAD - - - BODY - - - ARM0 - - - ARM1 - - - LEG0 - - - LEG1 - - - 23, 484 - - - 114, 21 - - - 134 - - - comboParent - - - System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - 21 - - Flat - - - NoControl + + Top, Right 722, 206 @@ -862,19 +769,16 @@ buttonEXPORT - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MetroFramework.Controls.MetroButton, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a $this - 18 + 17 - - Flat - - - NoControl + + Top, Right 655, 206 @@ -892,22 +796,22 @@ buttonIMPORT - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MetroFramework.Controls.MetroButton, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a $this - 23 + 20 - - Flat + + Bottom, Left - - NoControl + + False - 306, 677 + 306, 663 106, 21 @@ -922,22 +826,22 @@ buttonImportModel - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MetroFramework.Controls.MetroButton, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a $this - 17 + 16 - - Flat + + Bottom, Left - - NoControl + + False - 418, 677 + 418, 663 89, 21 @@ -952,22 +856,22 @@ buttonExportModel - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MetroFramework.Controls.MetroButton, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a $this - 16 + 15 - - Flat + + Bottom, Left - - NoControl + + False - 194, 677 + 194, 663 106, 21 @@ -982,43 +886,19 @@ OpenJSONButton - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MetroFramework.Controls.MetroButton, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a $this - 15 - - - 23, 511 - - - 114, 21 - - - 146 - - - Load Template - - - buttonTemplate - - - MetroFramework.Controls.MetroButton, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a - - - $this - - - 13 + 14 True - 23, 556 + 23, 547 140, 15 @@ -1039,13 +919,13 @@ $this - 12 + 13 True - 23, 577 + 23, 568 84, 15 @@ -1066,13 +946,13 @@ $this - 11 + 12 True - 23, 598 + 23, 589 129, 15 @@ -1093,7 +973,10 @@ $this - 10 + 11 + + + Top, Right 658, 275 @@ -1117,7 +1000,10 @@ $this - 9 + 10 + + + Top, Right 658, 301 @@ -1141,7 +1027,10 @@ $this - 8 + 9 + + + Top, Right 658, 327 @@ -1165,7 +1054,10 @@ $this - 7 + 8 + + + Top, Right 682, 233 @@ -1186,7 +1078,10 @@ $this - 6 + 7 + + + Top, Right 731, 234 @@ -1207,7 +1102,10 @@ $this - 5 + 6 + + + Top, Right 657, 425 @@ -1231,7 +1129,10 @@ $this - 2 + 3 + + + Top, Right 658, 399 @@ -1255,7 +1156,10 @@ $this - 3 + 4 + + + Top, Right 658, 373 @@ -1279,97 +1183,7 @@ $this - 4 - - - Part - - - 40 - - - X - - - Center - - - 30 - - - Y - - - Center - - - 30 - - - Z - - - Center - - - 30 - - - Width - - - Center - - - Height - - - Center - - - Length - - - Center - - - U - - - Center - - - 25 - - - V - - - Center - - - 25 - - - 23, 59 - - - 165, 378 - - - 132 - - - listViewBoxes - - - System.Windows.Forms.ListView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 14 + 5 Top, Bottom, Left, Right @@ -1385,7 +1199,7 @@ 194, 59 - 449, 574 + 449, 577 0 @@ -1400,7 +1214,10 @@ $this - 1 + 2 + + + Top, Right NoControl @@ -1427,7 +1244,28 @@ $this - 20 + 19 + + + 23, 56 + + + 165, 485 + + + 161 + + + listBox1 + + + System.Windows.Forms.ListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 True @@ -1439,7 +1277,7 @@ 6, 13 - 806, 721 + 806, 707 @@ -3957,7 +3795,7 @@ CenterParent - Model Generator + Custom Model Editor createToolStripMenuItem @@ -3983,62 +3821,8 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Part - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - X - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Y - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Z - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - _Width - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - _Height - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Length - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - U - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - V - - - System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - generateModel + CustomModelEditor MetroFramework.Forms.MetroForm, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a diff --git a/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs b/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs deleted file mode 100644 index df13f7aa..00000000 --- a/PCK-Studio/Forms/Skins-And-Textures/generateModel.cs +++ /dev/null @@ -1,801 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.Linq; -using System.Windows.Forms; -using System.Collections; -using System.IO; -using System.Text.RegularExpressions; - -using Newtonsoft.Json; -using MetroFramework.Forms; -using OMI.Formats.Pck; -using PckStudio.Internal; -using PckStudio.Extensions; -using System.Runtime.CompilerServices; -using System.Diagnostics; -using System.Text; - -namespace PckStudio.Forms -{ - public partial class generateModel : MetroForm - { - private Image _previewImage; - public Image PreviewImage => _previewImage; - - private PckFileData _file; - - private static Color _backgroundColor = Color.FromArgb(0xff, 0x50, 0x50, 0x50); - private static GraphicsConfig _graphicsConfig = new GraphicsConfig() - { - InterpolationMode = InterpolationMode.NearestNeighbor, - PixelOffsetMode = PixelOffsetMode.HighQuality, - }; - - private static readonly string[] ValidModelBoxTypes = new string[] - { - // Base 64x32 Parts - "HEAD", - "BODY", - "ARM0", - "ARM1", - "LEG0", - "LEG1", - - // 64x64 Overlay Parts - "HEADWEAR", - "JACKET", - "SLEEVE0", - "SLEEVE1", - "WAIST", - "PANTS0", - "PANTS1", - - // Armor Parts - "BODYARMOR", - "ARMARMOR0", - "ARMARMOR1", - "BELT", - "LEGGING0", - "LEGGING1", - "SOCK0", - "SOCK1", - "BOOT0", - "BOOT1" - }; - - private static readonly string[] ValidModelOffsetTypes = new string[] - { - // Body Offsets - "HEAD", - "BODY", - "ARM0", - "ARM1", - "LEG0", - "LEG1", - - // Armor Offsets - "HELMET", - "CHEST", "BODYARMOR", - "SHOULDER0", "ARMARMOR0", - "SHOULDER1", "ARMARMOR0", - "BELT", - "LEGGING0", - "LEGGING1", - "SOCK0", "BOOT0", - "SOCK1", "BOOT1", - - "TOOL0", - "TOOL1", - }; - - List modelBoxes = new List(); - List modelOffsets = new List(); - - private class ModelOffset - { - public string Name; - public float YOffset; - - public ModelOffset(string name, float yOffset) - { - Name = name; - YOffset = yOffset; - } - public (string, string) ToProperty() - { - string value = $"{Name} Y {YOffset}"; - return ("OFFSET", value.Replace(',','.')); - } - } - - public generateModel(PckFileData file) - { - InitializeComponent(); - - _file = file; - if (_file.Size > 0) - { - uvPictureBox.Image = renderer3D1.Texture = _file.GetTexture(); - } - comboParent.Items.Clear(); - comboParent.Items.AddRange(ValidModelBoxTypes); - LoadModelData(file.Properties); - } - - private static readonly Regex sWhitespace = new Regex(@"\s+"); - public static string ReplaceWhitespace(string input, string replacement) - { - return sWhitespace.Replace(input, replacement); - } - - private void LoadModelData(PckFileProperties properties) - { - renderer3D1.ANIM = properties.GetPropertyValue("ANIM", SkinANIM.FromString); - var boxProperties = properties.GetProperties("BOX"); - var data = boxProperties.Select(kv => SkinBOX.FromString(kv.Value)); - listViewBoxes.Items.AddRange(data.Select(box => new ListViewItem(box.ToString())).ToArray()); - renderer3D1.ModelData.AddRange(data); - renderer3D1.UploadModelData(); - - properties.GetProperties("OFFSET").All(kv => { - string[] offset = ReplaceWhitespace(kv.Value, ",").TrimEnd('\n', '\r', ' ').Split(','); - if (offset.Length < 3) - return false; - string name = offset[0]; - if (offset[1] != "Y") - return false; - float value = float.Parse(offset[2]); - if (ValidModelOffsetTypes.Contains(name)) - { - modelOffsets.Add(new ModelOffset(name, value)); - return true; - } - return false; - }); - - UpdateListView(); - } - - //Rename model part/item - private void listView1_DoubleClick_1(object sender, EventArgs e) - { - listViewBoxes.SelectedItems[0].BeginEdit(); - } - - private void GenerateUVTextureMap() - { - Random rng = new Random(); - using (Graphics graphics = Graphics.FromImage(uvPictureBox.Image)) - { - graphics.ApplyConfig(_graphicsConfig); - foreach (var part in modelBoxes) - { - float width = part.Size.X * 2; - float height = part.Size.Y * 2; - float length = part.Size.Z * 2; - float u = part.UV.X * 2; - float v = part.UV.Y * 2; - int argb = rng.Next(-16777216, -1); // 0xFF000000 - 0xFFFFFFFF - var color = Color.FromArgb(argb); - Brush brush = new SolidBrush(color); - graphics.FillRectangle(brush, u + length, v, width, length); - graphics.FillRectangle(brush, u + length + width, v, width, length); - graphics.FillRectangle(brush, u, length + v, length, height); - graphics.FillRectangle(brush, u + length, v + length, width, height); - graphics.FillRectangle(brush, u + length + width, v + length, width, height); - graphics.FillRectangle(brush, u + length + width * 2, v + length, length, height); - } - } - uvPictureBox.Invalidate(); - } - - private void DrawGuideLines(Graphics g) - { - throw new NotImplementedException(); - //Point center = new Point(displayBox.Height / 2, displayBox.Width / 2); - //int headbodyY = center.Y + 25; //25 - //int legY = center.Y + 85; // - 80; - //bool isSide = direction == ViewDirection.left || direction == ViewDirection.right; - //if (!isSide) - //{ - // g.DrawLine(Pens.Red, 0, headbodyY + float.Parse(offsetHead.Text) * 5, displayBox.Width, headbodyY + float.Parse(offsetHead.Text) * 5); - // g.DrawLine(Pens.Green, 0, headbodyY + float.Parse(offsetBody.Text) * 5, displayBox.Width, headbodyY + float.Parse(offsetBody.Text) * 5); - // g.DrawLine(Pens.Blue, 0, headbodyY + float.Parse(offsetArms.Text) * 5, displayBox.Width, headbodyY + float.Parse(offsetArms.Text) * 5); - // g.DrawLine(Pens.Purple, 0, legY + float.Parse(offsetLegs.Text) * 5, displayBox.Width, legY + float.Parse(offsetLegs.Text) * 5); - //} - //g.DrawLine(Pens.Red, center.X, 0, center.X, displayBox.Height); - //g.DrawLine(Pens.Blue, center.X + 30, 0, center.X + 30, displayBox.Height); - //g.DrawLine(Pens.Blue, center.X - 30, 0, center.X - 30, displayBox.Height); - //g.DrawLine(Pens.Purple, center.X - 10, 0, center.X - 10, displayBox.Height); - //g.DrawLine(Pens.Purple, center.X + 10, 0, center .X + 10, displayBox.Height); - } - - private void DrawArmorOffsets(Graphics g) - { - throw new NotImplementedException(); - //int centerPointHeight = displayBox.Height / 2; - //int centerPointWidth = displayBox.Width / 2; - //int headbodyY = centerPointHeight + 25; //25 - //int armY = centerPointHeight + 35; // - 60; - //int legY = centerPointHeight + 85; // - 80; - //SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(80, 50, 50, 75)); - //g.FillRectangle(semiTransBrush, centerPointWidth, (float)(headbodyY - 40 /*+ offsetHelmet.Value * 5*/), 40, 40); // Helmet - //bool isSide = direction == ViewDirection.left || direction == ViewDirection.right; - //if (isSide) - //{ - // g.FillRectangle(semiTransBrush, centerPointWidth - 10, headbodyY, 20, 60); // Chest - // g.FillRectangle(semiTransBrush, centerPointWidth - 10, (float)(legY + 40 /*+ offsetBoots.Value * 5*/), 20, 20); // Boots - // g.FillRectangle(semiTransBrush, centerPointWidth - 10, (float)(legY /*+ offsetPants.Value * 5*/), 20, 40); // Pants - // g.FillRectangle(semiTransBrush, centerPointWidth - 5, (float)(armY + 45 /*+ offsetTool.Value * 5*/), 10, 10); // Tools - //} - //else - //{ - // g.FillRectangle(semiTransBrush, centerPointWidth - 20, headbodyY, 40, 60); // Chest - // g.FillRectangle(semiTransBrush, centerPointWidth - 35, (float)(armY + 45 /*+ offsetTool.Value * 5*/), 10, 10); // Tool0 - // g.FillRectangle(semiTransBrush, centerPointWidth + 25, (float)(armY + 45 /*+ offsetTool.Value * 5*/), 10, 10); // Tool1 - // g.FillRectangle(semiTransBrush, centerPointWidth - 20, (float)(legY /*+ offsetPants.Value * 5*/), 20, 40); // Pants0 - // g.FillRectangle(semiTransBrush, centerPointWidth, (float)(legY /*+ offsetPants.Value * 5*/), 20, 40); // Pants1 - // g.FillRectangle(semiTransBrush, centerPointWidth - 20, (float)(legY + 40 /*+ offsetBoots.Value * 5*/), 20, 20); // Boot0 - // g.FillRectangle(semiTransBrush, centerPointWidth, (float)(legY + 40 /*+ offsetBoots.Value * 5*/), 20, 20); // Boot1 - //} - - } - - private void generateModel_Load(object sender, EventArgs e) - { - if (Screen.PrimaryScreen.Bounds.Height >= 780 && Screen.PrimaryScreen.Bounds.Width >= 1080) { - return; - } - } - - private void createToolStripMenuItem_Click(object sender, EventArgs e) - { - modelBoxes.Add(SkinBOX.Empty); - UpdateListView(); - } - - private void listView1_SelectedIndexChanged(object sender, EventArgs e) - { - changeColorToolStripMenuItem.Visible = false; - if (listViewBoxes.SelectedItems.Count != 0 && listViewBoxes.SelectedItems[0].Tag is SkinBOX) - { - changeColorToolStripMenuItem.Visible = true; - var part = listViewBoxes.SelectedItems[0].Tag as SkinBOX; - //graphics.DrawRectangle(Pens.Yellow, x + (float)double.Parse(this.selected.SubItems[3].Text) * 5 - 1, y + (float)double.Parse(this.selected.SubItems[2].Text) * 5 - 1, (float)double.Parse(this.selected.SubItems[6].Text) * 5 + 2, (float)double.Parse(this.selected.SubItems[5].Text) * 5 + 2); - //graphics.DrawRectangle(Pens.Black, x + (float)double.Parse(this.selected.SubItems[3].Text) * 5, y + (float)double.Parse(this.selected.SubItems[2].Text) * 5, (float)double.Parse(this.selected.SubItems[6].Text) * 5, (float)double.Parse(this.selected.SubItems[5].Text) * 5); - comboParent.Text = part.Type; - PosXUpDown.Value = (decimal)part.Pos.X; - PosYUpDown.Value = (decimal)part.Pos.Y; - PosZUpDown.Value = (decimal)part.Pos.Z; - SizeXUpDown.Value = (decimal)part.Size.X; - SizeYUpDown.Value = (decimal)part.Size.Y; - SizeZUpDown.Value = (decimal)part.Size.Z; - TextureXUpDown.Value = (decimal)part.UV.X; - TextureYUpDown.Value = (decimal)part.UV.Y; - } - } - - //Changes Item Model Class - private void comboParent_SelectedIndexChanged(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - part.Type = comboParent.Text; - buttonIMPORT.Enabled = true; - buttonEXPORT.Enabled = true; - SizeXUpDown.Enabled = true; - SizeYUpDown.Enabled = true; - SizeZUpDown.Enabled = true; - PosXUpDown.Enabled = true; - PosYUpDown.Enabled = true; - PosZUpDown.Enabled = true; - TextureXUpDown.Enabled = true; - TextureYUpDown.Enabled = true; - } - } - - private void SizeXUpDown_ValueChanged(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - part.Size.X = (float)SizeXUpDown.Value; - } - UpdateListView(); - } - - private void SizeYUpDown_ValueChanged(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - part.Size.Y = (float)SizeYUpDown.Value; - } - UpdateListView(); - } - - private void SizeZUpDown_ValueChanged(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - part.Size.Z = (float)SizeZUpDown.Value; - } - UpdateListView(); - } - - private void PosXUpDown_ValueChanged(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - part.Pos.X = (float)PosXUpDown.Value; - } - UpdateListView(); - } - - private void PosYUpDown_ValueChanged(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - part.Pos.Y = (float)PosYUpDown.Value; - } - UpdateListView(); - } - - private void PosZUpDown_ValueChanged(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - part.Pos.Z = (float)PosZUpDown.Value; - } - UpdateListView(); - } - - //Sets Texture X-Offset - private void TextureXUpDown_ValueChanged(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - part.UV.X = (int)TextureXUpDown.Value; - } - UpdateListView(); - } - - //Sets texture Y-Offset - private void TextureYUpDown_ValueChanged(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - part.UV.Y = (int)TextureYUpDown.Value; - } - UpdateListView(); - } - - //Export Current Skin Texture - private void buttonEXPORT_Click(object sender, EventArgs e) - { - Bitmap bitmap = new Bitmap(uvPictureBox.Image, 64, 64); - using SaveFileDialog saveFileDialog = new SaveFileDialog(); - saveFileDialog.Filter = "PNG Image Files | *.png"; - if (saveFileDialog.ShowDialog() == DialogResult.OK) - { - bitmap.Save(saveFileDialog.FileName, ImageFormat.Png); - } - } - - //Imports Skin Texture - private void buttonIMPORT_Click(object sender, EventArgs e) - { - OpenFileDialog openFileDialog = new OpenFileDialog(); - openFileDialog.Filter = "PNG Image Files | *.png"; - openFileDialog.Title = "Select Skin Texture"; - - if (openFileDialog.ShowDialog() == DialogResult.OK) // skins can only be a 1:1 ratio (base 64x64) or a 2:1 ratio (base 64x32) - { - using (var img = Image.FromFile(openFileDialog.FileName)) - { - if ((img.Width == img.Height || img.Height == img.Width / 2)) - { - generateTextureCheckBox.Checked = false; - using (Graphics graphics = Graphics.FromImage(uvPictureBox.Image)) - { - graphics.ApplyConfig(_graphicsConfig); - graphics.DrawImage(img, 0, 0, img.Width, img.Height); - } - uvPictureBox.Invalidate(); - } - else - { - MessageBox.Show(this, "Not a valid skin file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - } - - // Creates Model Data and Finalizes - private void buttonDone_Click(object sender, EventArgs e) - { - foreach (var part in modelBoxes) - { - _file.Properties.Add("BOX", part); - } - var img = new Bitmap(renderer3D1.Size.Width, renderer3D1.Size.Height); - renderer3D1.DrawToBitmap(img, renderer3D1.Bounds); - _previewImage = img; - DialogResult = DialogResult.OK; - } - - // Trigger Dialog to select model part/item color - private void listView1_DoubleClick(object sender, EventArgs e) - { - ColorDialog colorDialog = new ColorDialog(); - if (colorDialog.ShowDialog() == DialogResult.OK) - listViewBoxes.SelectedItems[0].ForeColor = colorDialog.Color; - } - - //Re-renders head with updated x-offset - private void offsetHead_TextChanged(object sender, EventArgs e) - { - - } - - //Re-renders body with updated x-offset - private void offsetBody_TextAlignChanged(object sender, EventArgs e) - { - - } - - //Loads in model template(Steve) - private void buttonTemplate_Click(object sender, EventArgs e) - { - modelBoxes.Add(SkinBOX.FromString("HEAD -4 -8 -4 8 8 8 0 0 0 0 0")); - modelBoxes.Add(SkinBOX.FromString("BODY -4 0 -2 8 12 4 16 16 0 0 0")); - modelBoxes.Add(SkinBOX.FromString("ARM0 -3 -2 -2 4 12 4 40 16 0 0 0")); - modelBoxes.Add(SkinBOX.FromString("ARM1 -1 -2 -2 4 12 4 40 16 0 1 0")); - modelBoxes.Add(SkinBOX.FromString("LEG0 -2 0 -2 4 12 4 0 16 0 0 0")); - modelBoxes.Add(SkinBOX.FromString("LEG1 -2 0 -2 4 12 4 0 16 0 1 0")); - comboParent.Enabled = true; - UpdateListView(); - } - - private void UpdateListView() - { - listViewBoxes.Items.Clear(); - foreach (var part in modelBoxes) - { - ListViewItem listViewItem = new ListViewItem(part.Type); - listViewItem.Tag = part; - listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Pos.X.ToString())); - listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Pos.Y.ToString())); - listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Pos.Z.ToString())); - listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Size.X.ToString())); - listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Size.Y.ToString())); - listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Size.Z.ToString())); - listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.UV.X.ToString())); - listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.UV.Y.ToString())); - listViewBoxes.Items.Add(listViewItem); - } - } - - // 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() != 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("Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog() == 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(); - } - - private void cloneToolStripMenuItem_Click(object sender, EventArgs e) - { - try - { - ListViewItem listViewItem = new ListViewItem(); - var selected = listViewBoxes.SelectedItems[0]; - listViewItem.Text = selected.Text; - listViewItem.Tag = selected.Tag; - int num = 0; - foreach (ListViewItem.ListViewSubItem subItem in selected.SubItems) - { - if (num > 0) - listViewItem.SubItems.Add(subItem.Text); - ++num; - } - listViewBoxes.Items.Add(listViewItem); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - MessageBox.Show("Please Select a Part"); - } - } - - private void deleteToolStripMenuItem_Click(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems[0] == null) - return; - listViewBoxes.SelectedItems[0].Remove(); - } - - private void changeColorToolStripMenuItem_Click(object sender, EventArgs e) - { - ColorDialog colorDialog = new ColorDialog(); - if (colorDialog.ShowDialog() == DialogResult.OK) - listViewBoxes.SelectedItems[0].ForeColor = colorDialog.Color; - } - - //Re-renders tool with updated x-offset - private void offsetTool_TextChanged(object sender, EventArgs e) - { - - } - - //Re-renders helmet with updated x-offset - private void offsetHelmet_TextChanged(object sender, EventArgs e) - { - - } - - //Re-renders pants with updated x-offset - private void offsetPants_TextChanged(object sender, EventArgs e) - { - - } - - //Re-renders leggings with updated x-offset - private void offsetLeggings_TextChanged(object sender, EventArgs e) - { - - } - - //Re-renders boots with updated x-offset - private void offsetBoots_TextChanged(object sender, EventArgs e) - { - - } - - //Item Selection - private void listView1_Click(object sender, EventArgs e) - { - if (listViewBoxes.SelectedItems.Count != 0 && listViewBoxes.SelectedItems[0] != null && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - comboParent.Text = part.Type; - PosXUpDown.Value = (decimal)part.Pos.X; - PosYUpDown.Value = (decimal)part.Pos.Y; - PosZUpDown.Value = (decimal)part.Pos.Z; - SizeXUpDown.Value = (decimal)part.Size.X; - SizeYUpDown.Value = (decimal)part.Size.Y; - SizeZUpDown.Value = (decimal)part.Size.Z; - TextureXUpDown.Value = (decimal)part.UV.X; - TextureYUpDown.Value = (decimal)part.UV.Y; - SizeXUpDown.Enabled = true; - SizeYUpDown.Enabled = true; - SizeZUpDown.Enabled = true; - PosXUpDown.Enabled = true; - PosYUpDown.Enabled = true; - PosZUpDown.Enabled = true; - TextureXUpDown.Enabled = true; - TextureYUpDown.Enabled = true; - comboParent.Enabled = true; - return; - } - SizeXUpDown.Enabled = false; - SizeYUpDown.Enabled = false; - SizeZUpDown.Enabled = false; - PosXUpDown.Enabled = false; - PosYUpDown.Enabled = false; - PosZUpDown.Enabled = false; - TextureXUpDown.Enabled = false; - TextureYUpDown.Enabled = false; - comboParent.Enabled = false; - - } - - //currently scrapped - private void generateModel_FormClosing(object sender, FormClosingEventArgs e) - { - /*if (MessageBox.Show("You done here?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) - { - e.Cancel = true; - return; - } - e.Cancel = false;*/ - } - - //Del stuff using key - private void delStuffUsingDelKey(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Delete && listViewBoxes.SelectedItems.Count != 0 && - listViewBoxes.SelectedItems[0].Tag is SkinBOX part) - { - if (modelBoxes.Remove(part)) - listViewBoxes.SelectedItems[0].Remove(); - - } - } - - private void generateModel_SizeChanged(object sender, EventArgs e) - { - - } - - // 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("Import custom model project file? Your current work will be lost!", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1) == DialogResult.Yes && openFileDialog.ShowDialog() == 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); - } - } - } - } - - } - - [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(); - } - - private void renderer3D1_TextureChanging(object sender, Rendering.TextureChangingEventArgs e) - { - uvPictureBox.Image = e.NewTexture; - } - } - - 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/Internal/SkinBOX.cs b/PCK-Studio/Internal/SkinBOX.cs index 8a88e28e..75345f74 100644 --- a/PCK-Studio/Internal/SkinBOX.cs +++ b/PCK-Studio/Internal/SkinBOX.cs @@ -24,7 +24,7 @@ namespace PckStudio.Internal { public static readonly SkinBOX Empty = new SkinBOX("HEAD", new Vector3(-4, -8, -4), new Vector3(8), Vector2.Zero); - public string Type; + public string Type { get; set; } public Vector3 Pos; public Vector3 Size; public Vector2 UV; diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs index cabd5d12..29e58f09 100644 --- a/PCK-Studio/MainForm.cs +++ b/PCK-Studio/MainForm.cs @@ -429,7 +429,7 @@ namespace PckStudio { if (file.Properties.HasProperty("BOX")) { - using generateModel generate = new generateModel(file); + using CustomModelEditor generate = new CustomModelEditor(file); if (generate.ShowDialog() == DialogResult.OK) { entryDataTextBox.Text = entryTypeTextBox.Text = string.Empty; diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index dfa4121a..8f9c9719 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -396,11 +396,11 @@ MainForm.cs - + Form - - generateModel.cs + + CustomModelEditor.cs Form @@ -571,11 +571,11 @@ MainForm.cs Designer - - generateModel.cs + + CustomModelEditor.cs - - generateModel.cs + + CustomModelEditor.cs Designer @@ -735,6 +735,9 @@ 13.0.3 + + 3.3.3 + 3.3.3