mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-05 10:57:23 +00:00
CustomSkinEditor - Add functionality for setting skin parrt offsets
This commit is contained in:
31
PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs
generated
31
PCK-Studio/Forms/Editor/CustomSkinEditor.Designer.cs
generated
@@ -65,8 +65,11 @@
|
||||
this.skinPartsTabPage = new System.Windows.Forms.TabPage();
|
||||
this.skinOffsetsTabPage = new System.Windows.Forms.TabPage();
|
||||
this.offsetListBox = new System.Windows.Forms.ListBox();
|
||||
this.offsetTabContextMenu = new MetroFramework.Controls.MetroContextMenu(this.components);
|
||||
this.addOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.renderer3D1 = new PckStudio.Rendering.SkinRenderer();
|
||||
this.uvPictureBox = new PckStudio.ToolboxItems.InterpolationPictureBox();
|
||||
this.removeOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
label5 = new System.Windows.Forms.Label();
|
||||
label3 = new System.Windows.Forms.Label();
|
||||
label7 = new System.Windows.Forms.Label();
|
||||
@@ -83,6 +86,7 @@
|
||||
this.metroTabControl1.SuspendLayout();
|
||||
this.skinPartsTabPage.SuspendLayout();
|
||||
this.skinOffsetsTabPage.SuspendLayout();
|
||||
this.offsetTabContextMenu.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.uvPictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -376,9 +380,26 @@
|
||||
//
|
||||
// offsetListBox
|
||||
//
|
||||
this.offsetListBox.ContextMenuStrip = this.offsetTabContextMenu;
|
||||
resources.ApplyResources(this.offsetListBox, "offsetListBox");
|
||||
this.offsetListBox.FormattingEnabled = true;
|
||||
this.offsetListBox.Name = "offsetListBox";
|
||||
this.offsetListBox.DoubleClick += new System.EventHandler(this.offsetListBox_DoubleClick);
|
||||
//
|
||||
// offsetTabContextMenu
|
||||
//
|
||||
this.offsetTabContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.addOffsetToolStripMenuItem,
|
||||
this.removeOffsetToolStripMenuItem});
|
||||
this.offsetTabContextMenu.Name = "offsetTabContextMenu";
|
||||
resources.ApplyResources(this.offsetTabContextMenu, "offsetTabContextMenu");
|
||||
this.offsetTabContextMenu.Theme = MetroFramework.MetroThemeStyle.Dark;
|
||||
//
|
||||
// addOffsetToolStripMenuItem
|
||||
//
|
||||
this.addOffsetToolStripMenuItem.Name = "addOffsetToolStripMenuItem";
|
||||
resources.ApplyResources(this.addOffsetToolStripMenuItem, "addOffsetToolStripMenuItem");
|
||||
this.addOffsetToolStripMenuItem.Click += new System.EventHandler(this.addOffsetToolStripMenuItem_Click);
|
||||
//
|
||||
// renderer3D1
|
||||
//
|
||||
@@ -405,6 +426,12 @@
|
||||
this.uvPictureBox.Name = "uvPictureBox";
|
||||
this.uvPictureBox.TabStop = false;
|
||||
//
|
||||
// removeOffsetToolStripMenuItem
|
||||
//
|
||||
this.removeOffsetToolStripMenuItem.Name = "removeOffsetToolStripMenuItem";
|
||||
resources.ApplyResources(this.removeOffsetToolStripMenuItem, "removeOffsetToolStripMenuItem");
|
||||
this.removeOffsetToolStripMenuItem.Click += new System.EventHandler(this.removeOffsetToolStripMenuItem_Click);
|
||||
//
|
||||
// CustomSkinEditor
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
@@ -453,6 +480,7 @@
|
||||
this.metroTabControl1.ResumeLayout(false);
|
||||
this.skinPartsTabPage.ResumeLayout(false);
|
||||
this.skinOffsetsTabPage.ResumeLayout(false);
|
||||
this.offsetTabContextMenu.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.uvPictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
@@ -493,5 +521,8 @@
|
||||
private System.Windows.Forms.TabPage skinPartsTabPage;
|
||||
private System.Windows.Forms.TabPage skinOffsetsTabPage;
|
||||
private System.Windows.Forms.ListBox offsetListBox;
|
||||
private MetroFramework.Controls.MetroContextMenu offsetTabContextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem addOffsetToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem removeOffsetToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ using PckStudio.Internal;
|
||||
using PckStudio.Extensions;
|
||||
using PckStudio.IO.CSMB;
|
||||
using PckStudio.FileFormats;
|
||||
using System.Linq;
|
||||
using PckStudio.Forms.Additional_Popups;
|
||||
|
||||
namespace PckStudio.Forms.Editor
|
||||
{
|
||||
@@ -85,12 +87,13 @@ namespace PckStudio.Forms.Editor
|
||||
renderer3D1.Texture = skin.Texture;
|
||||
}
|
||||
|
||||
//skinOffsetListBindingSource = new BindingSource(renderer3D1.offsetSpecificMeshStorage, null);
|
||||
//offsetListBox.DataSource = skinOffsetListBindingSource;
|
||||
//offsetListBox.DisplayMember = "Value";
|
||||
skinOffsetListBindingSource = new BindingSource(renderer3D1.GetOffsets().ToArray(), null);
|
||||
offsetListBox.DataSource = skinOffsetListBindingSource;
|
||||
offsetListBox.DisplayMember = "Type";
|
||||
offsetListBox.ValueMember = "Value";
|
||||
|
||||
skinPartListBindingSource.ResetBindings(false);
|
||||
//skinOffsetListBindingSource.ResetBindings(false);
|
||||
skinOffsetListBindingSource.ResetBindings(false);
|
||||
}
|
||||
|
||||
private void GenerateUVTextureMap(SkinBOX skinBox)
|
||||
@@ -144,16 +147,12 @@ namespace PckStudio.Forms.Editor
|
||||
|
||||
private void buttonDone_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Debug.Fail("TODO: Implement");
|
||||
_skin.AdditionalBoxes.Clear();
|
||||
_skin.AdditionalBoxes.AddRange(renderer3D1.ModelData);
|
||||
|
||||
// TODO: Get part offset list/IEnumerable from renderer
|
||||
//_skin.PartOffsets.Clear();
|
||||
//_skin.PartOffsets.AddRange();
|
||||
|
||||
//_previewImage = renderer3D1.GetThumbnail();
|
||||
|
||||
_skin.PartOffsets.Clear();
|
||||
_skin.PartOffsets.AddRange(renderer3D1.GetOffsets());
|
||||
// just in case they're not the same instance
|
||||
_skin.ANIM = renderer3D1.ANIM;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
@@ -309,10 +308,52 @@ namespace PckStudio.Forms.Editor
|
||||
renderer3D1.ShowArmor = showArmorCheckbox.Checked;
|
||||
}
|
||||
|
||||
private void skinPartListBox_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
|
||||
private void skinPartListBox_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Delete)
|
||||
deleteToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
|
||||
private void ReloadOffsetList()
|
||||
{
|
||||
skinOffsetListBindingSource = new BindingSource(renderer3D1.GetOffsets().ToArray(), null);
|
||||
offsetListBox.DataSource = skinOffsetListBindingSource;
|
||||
skinOffsetListBindingSource.ResetBindings(false);
|
||||
}
|
||||
|
||||
private void addOffsetToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var offsets = renderer3D1.GetOffsets().Select(offset => offset.Type).ToList();
|
||||
string[] available = SkinPartOffset.ValidModelOffsetTypes.Where(s => !offsets.Contains(s)).ToArray();
|
||||
using ItemSelectionPopUp typeSelection = new ItemSelectionPopUp(available);
|
||||
using NumericPrompt valuePrompt = new NumericPrompt(0f, -100_000f, 100_000f);
|
||||
if (typeSelection.ShowDialog() == DialogResult.OK && valuePrompt.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
renderer3D1.SetPartOffset(typeSelection.SelectedItem, (float)valuePrompt.SelectedValue);
|
||||
ReloadOffsetList();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeOffsetToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (offsetListBox.SelectedItem is not SkinPartOffset offset)
|
||||
return;
|
||||
renderer3D1.SetPartOffset(offset.Type, 0f);
|
||||
ReloadOffsetList();
|
||||
}
|
||||
|
||||
private void offsetListBox_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
if (offsetListBox.SelectedItem is not SkinPartOffset offset)
|
||||
return;
|
||||
|
||||
using NumericPrompt valuePrompt = new NumericPrompt((float)offset.Value, -100_000f, 100_000f);
|
||||
valuePrompt.ToolTipText = "Set new Value for " + offset.Type;
|
||||
if (valuePrompt.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
renderer3D1.SetPartOffset(offset.Type, (float)valuePrompt.SelectedValue);
|
||||
ReloadOffsetList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1017,6 +1017,30 @@
|
||||
<data name=">>skinPartsTabPage.ZOrder" xml:space="preserve">
|
||||
<value>0</value>
|
||||
</data>
|
||||
<metadata name="offsetTabContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>204, 17</value>
|
||||
</metadata>
|
||||
<data name="addOffsetToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>180, 22</value>
|
||||
</data>
|
||||
<data name="addOffsetToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>Add Offset</value>
|
||||
</data>
|
||||
<data name="removeOffsetToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>180, 22</value>
|
||||
</data>
|
||||
<data name="removeOffsetToolStripMenuItem.Text" xml:space="preserve">
|
||||
<value>Remove Offset</value>
|
||||
</data>
|
||||
<data name="offsetTabContextMenu.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>181, 70</value>
|
||||
</data>
|
||||
<data name=">>offsetTabContextMenu.Name" xml:space="preserve">
|
||||
<value>offsetTabContextMenu</value>
|
||||
</data>
|
||||
<data name=">>offsetTabContextMenu.Type" xml:space="preserve">
|
||||
<value>MetroFramework.Controls.MetroContextMenu, MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a</value>
|
||||
</data>
|
||||
<data name="offsetListBox.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
|
||||
<value>Fill</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user