Replaced ModelPart class and added support for HD Skins

This commit is contained in:
MattNL
2023-04-25 20:07:33 -04:00
parent 779a2bb655
commit 39171fb41a

View File

@@ -4,12 +4,14 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Numerics;
using System.Windows.Forms;
using System.Collections;
using System.IO;
using Newtonsoft.Json;
using MetroFramework.Forms;
using PckStudio.Classes.FileTypes;
using PckStudio.Classes.Models;
using System.Text.RegularExpressions;
using OMI.Formats.Pck;
@@ -89,39 +91,9 @@ namespace PckStudio
"TOOL1",
};
List<ModelPart> modelParts = new List<ModelPart>();
List<SkinBox> modelBoxes = new List<SkinBox>();
List<ModelOffset> modelOffsets = new List<ModelOffset>();
class ModelPart
{
public string Type;
public float X, Y, Z;
public float Width;
public float Height;
public float Length;
public int U, V;
public ModelPart(string type, float x, float y, float z, float width, float height, float length, int u, int v)
{
Type = type;
X = x;
Y = y;
Z = z;
Width = width;
Height = height;
Length = length;
U = u;
V = v;
}
public ValueTuple<string, string> ToProperty()
{
string value = $"{Type} {X} {Y} {Z} {Width} {Height} {Length} {U} {V}";
return new ValueTuple<string, string>("BOX", value.Replace(',', '.'));
}
}
class ModelOffset
{
public string Name;
@@ -164,56 +136,14 @@ namespace PckStudio
{
case "BOX":
{
string[] Format = ReplaceWhitespace(property.Item2, ",").TrimEnd('\n', '\r', ' ').Split(',');
if (Format.Length < 9)
{
Console.WriteLine($"'{property.Item1}' property has too few arguments: {property.Item2}");
continue;
}
string name = Format[0];
SkinBox box = new SkinBox(property.Item2);
string name = box.Type;
if (ValidModelBoxTypes.Contains(name))
{
// %10ls = name
// %f
// %f
// %f
// %f
// %f
// %f
// %f
// %f
// %d
// %d
// %f
try
{
float x = float.Parse(Format[1]);
float y = float.Parse(Format[2]);
float z = float.Parse(Format[3]);
float sizeX = float.Parse(Format[4]);
float sizeY = float.Parse(Format[5]);
float sizeZ = float.Parse(Format[6]);
int u = int.Parse(Format[7]);
int v = int.Parse(Format[8]);
modelParts.Add(new ModelPart(name, x, y, z, sizeX, sizeY, sizeZ, u, v));
}
catch (FormatException ex)
{
Console.WriteLine(ex.Message);
MessageBox.Show("A Format Exception was thrown\nFailed to parse BOX value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (OverflowException ex)
{
Console.WriteLine(ex.Message);
MessageBox.Show("An Overflow Exception was thrown\nFailed to parse BOX value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
if (Format.Length >= 11)
{
string unk1 = Format[9];
string unk2 = Format[10];
Console.WriteLine($"{unk1} | {unk2}");
modelBoxes.Add(box);
}
comboParent.Enabled = true;
break;
}
@@ -272,25 +202,28 @@ namespace PckStudio
float legY = (displayBox.Height / 2) + 85; // -80;
float groundLevel = (displayBox.Height / 2) + 145;
graphics.DrawLine(Pens.White, 0, groundLevel, displayBox.Width, groundLevel);
float gfx_scale = texturePreview.Image.Width / 64; // used for displaying larger graphics properly; 64 is the base skin width for all models
// Chooses Render settings based on current direction
foreach (ListViewItem listViewItem in listViewBoxes.Items)
{
if (!(listViewItem.Tag is ModelPart)) continue;
ModelPart part = listViewItem.Tag as ModelPart;
if (!(listViewItem.Tag is SkinBox)) continue;
SkinBox part = listViewItem.Tag as SkinBox;
float x = displayBox.Width / 2;
float y = 0;
switch (direction)
{
case eViewDirection.front:
{
//Sets X & Y based on model part class
// listViewItem.Text -> part.Type
// listViewItem.SubItems[1] -> part.X
// listViewItem.SubItems[2] -> part.Y
// listViewItem.SubItems[3] -> part.Z
// listViewItem.SubItems[4] -> part.Width
// listViewItem.SubItems[5] -> part.Height
// listViewItem.SubItems[6] -> part.Length
// listViewItem.SubItems[1] -> part.Pos.X
// listViewItem.SubItems[2] -> part.Pos.Y
// listViewItem.SubItems[3] -> part.Pos.Z
// listViewItem.SubItems[4] -> part.Size.X
// listViewItem.SubItems[5] -> part.Size.Y
// listViewItem.SubItems[6] -> part.Size.Z
// listViewItem.SubItems[7] -> part.U
// listViewItem.SubItems[8] -> part.V
switch (part.Type)
@@ -327,20 +260,19 @@ namespace PckStudio
if (!checkTextureGenerate.Checked)
{
RectangleF destRect = new RectangleF(
x + part.X * 5,
y + part.Y * 5,
part.Width * 5,
part.Height * 5);
x + part.Pos.X * 5,
y + part.Pos.Y * 5,
part.Size.X * 5,
part.Size.Y * 5);
RectangleF srcRect = new RectangleF(
part.U + part.Length,
part.V + part.Length,
part.Width,
part.Height);
graphics.DrawImage(texturePreview.Image, destRect, srcRect, GraphicsUnit.Pixel);
(part.U + part.Size.Z) * gfx_scale,
(part.V + part.Size.Z) * gfx_scale,
part.Size.X * gfx_scale,
part.Size.Y * gfx_scale);
}
else
{
graphics.FillRectangle(new SolidBrush(listViewItem.ForeColor), x + part.X * 5, y + part.Y * 5, part.Width * 5, part.Height * 5);
graphics.FillRectangle(new SolidBrush(listViewItem.ForeColor), x + part.Pos.X * 5, y + part.Pos.Y * 5, part.Size.X * 5, part.Size.Y * 5);
}
break;
@@ -380,21 +312,21 @@ namespace PckStudio
if (!checkTextureGenerate.Checked)
{
RectangleF destRect = new RectangleF(
x + part.Z * 5,
y + part.Y * 5,
part.Length * 5,
part.Height * 5);
x + part.Pos.Z * 5,
y + part.Pos.Y * 5,
part.Size.Z * 5,
part.Size.Y * 5);
RectangleF srcRect = new RectangleF(
part.U + part.Length + part.Width,
part.V + part.Length,
part.Length,
part.Height);
(part.U + part.Size.Z + part.Size.X) * gfx_scale,
(part.V + part.Size.Z) * gfx_scale,
part.Size.Z * gfx_scale,
part.Size.Y * gfx_scale);
graphics.DrawImage(texturePreview.Image, destRect, srcRect, GraphicsUnit.Pixel);
}
else
{
//Draws Part
graphics.FillRectangle(new SolidBrush(listViewItem.ForeColor), x + part.Z * 5, y + part.Y * 5, part.Length * 5, part.Height * 5);
graphics.FillRectangle(new SolidBrush(listViewItem.ForeColor), x + part.Pos.Z * 5, y + part.Pos.Y * 5, part.Size.Z * 5, part.Size.Y * 5);
}
bitmapModelPreview.RotateFlip(RotateFlipType.RotateNoneFlipX);
break;
@@ -433,21 +365,21 @@ namespace PckStudio
if (!checkTextureGenerate.Checked)
{
RectangleF destRect = new RectangleF(
x + part.X * 5,
y + part.Y * 5,
part.Width * 5,
part.Height * 5);
x + part.Pos.X * 5,
y + part.Pos.Y * 5,
part.Size.X * 5,
part.Size.Y * 5);
RectangleF srcRect = new RectangleF(
part.U + part.Length * 2 + part.Width,
part.V + part.Length,
part.Width,
part.Height);
(part.U + part.Size.Z * 2 + part.Size.X) * gfx_scale,
(part.V + part.Size.Z) * gfx_scale,
part.Size.X * gfx_scale,
part.Size.Y * gfx_scale);
graphics.DrawImage(texturePreview.Image, destRect, srcRect, GraphicsUnit.Pixel);
}
else
{
//Draws Part
graphics.FillRectangle(new SolidBrush(listViewItem.ForeColor), x + part.X * 5, y + part.Y * 5, part.Width * 5, part.Height * 5);
graphics.FillRectangle(new SolidBrush(listViewItem.ForeColor), x + part.Pos.X * 5, y + part.Pos.Y * 5, part.Size.X * 5, part.Size.Y * 5);
}
bitmapModelPreview.RotateFlip(RotateFlipType.RotateNoneFlipX);
break;
@@ -483,21 +415,21 @@ namespace PckStudio
if (!checkTextureGenerate.Checked)
{
RectangleF destRect = new RectangleF(
x + part.Z * 5,
y + part.Y * 5,
part.Length * 5,
part.Height * 5);
x + part.Pos.Z * 5,
y + part.Pos.Y * 5,
part.Size.Z * 5,
part.Size.Y * 5);
RectangleF srcRect = new RectangleF(
part.U + part.Length + part.Width,
part.V + part.Length,
part.Length,
part.Height);
(part.U + part.Size.Z + part.Size.X) * gfx_scale,
(part.V + part.Size.Z) * gfx_scale,
part.Size.Z * gfx_scale,
part.Size.Y * gfx_scale);
graphics.DrawImage(texturePreview.Image, destRect, srcRect, GraphicsUnit.Pixel);
}
else
{
//Draws Part
graphics.FillRectangle(new SolidBrush(listViewItem.ForeColor), x + part.Z * 5, y + part.Y * 5, part.Length * 5, part.Height * 5);
graphics.FillRectangle(new SolidBrush(listViewItem.ForeColor), x + part.Pos.Z * 5, y + part.Pos.Y * 5, part.Size.Z * 5, part.Size.Y * 5);
}
break;
}
@@ -519,13 +451,13 @@ namespace PckStudio
Bitmap bitmapAutoTexture = new Bitmap(texturePreview.Width, texturePreview.Height);
using (Graphics graphics = Graphics.FromImage(bitmapAutoTexture))
{
foreach (var part in modelParts)
foreach (var part in modelBoxes)
{
float width = part.Width * 2;
float height = part.Height * 2;
float length = part.Length * 2;
int u = part.U * 2;
int v = part.V * 2;
float width = part.Size.X * 2;
float height = part.Size.Y * 2;
float length = part.Size.Z * 2;
float u = part.U * 2;
float v = part.V * 2;
Random r = new Random();
Brush brush = new SolidBrush(Color.FromArgb(r.Next(int.MinValue, int.MaxValue)));
graphics.FillRectangle(brush, u + length, v, width, length);
@@ -851,7 +783,7 @@ namespace PckStudio
//Creates Item
private void createToolStripMenuItem_Click(object sender, EventArgs e)
{
modelParts.Add(new ModelPart("New Part", 0, 0, 0, 0, 0, 0, 0, 0));
modelBoxes.Add(new SkinBox("NEW_BOX 0 0 0 1 1 1 0 0 0 0 0"));
updateListView();
render();
}
@@ -861,21 +793,21 @@ namespace PckStudio
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
changeColorToolStripMenuItem.Visible = false;
if (listViewBoxes.SelectedItems.Count != 0 && listViewBoxes.SelectedItems[0].Tag is ModelPart)
if (listViewBoxes.SelectedItems.Count != 0 && listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
changeColorToolStripMenuItem.Visible = true;
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
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.X;
PosYUpDown.Value = (decimal)part.Y;
PosZUpDown.Value = (decimal)part.Z;
SizeXUpDown.Value = (decimal)part.Width;
SizeYUpDown.Value = (decimal)part.Height;
SizeZUpDown.Value = (decimal)part.Length;
TextureXUpDown.Value = part.U;
TextureYUpDown.Value = part.V;
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.U;
TextureYUpDown.Value = (decimal)part.V;
render();
}
}
@@ -885,9 +817,9 @@ namespace PckStudio
private void comboParent_SelectedIndexChanged(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
part.Type = comboParent.Text;
buttonIMPORT.Enabled = true;
buttonEXPORT.Enabled = true;
@@ -906,10 +838,10 @@ namespace PckStudio
private void SizeXUpDown_ValueChanged(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
part.Width = (float)SizeXUpDown.Value;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
part.Size.X = (float)SizeXUpDown.Value;
}
updateListView();
render();
@@ -918,10 +850,10 @@ namespace PckStudio
private void SizeYUpDown_ValueChanged(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
part.Height = (float)SizeYUpDown.Value;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
part.Size.Y = (float)SizeYUpDown.Value;
}
updateListView();
render();
@@ -930,10 +862,10 @@ namespace PckStudio
private void SizeZUpDown_ValueChanged(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
part.Length = (float)SizeZUpDown.Value;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
part.Size.Z = (float)SizeZUpDown.Value;
}
updateListView();
render();
@@ -942,10 +874,10 @@ namespace PckStudio
private void PosXUpDown_ValueChanged(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
part.X = (float)PosXUpDown.Value;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
part.Pos.X = (float)PosXUpDown.Value;
}
updateListView();
render();
@@ -955,10 +887,10 @@ namespace PckStudio
private void PosYUpDown_ValueChanged(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
part.Y = (float)PosYUpDown.Value;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
part.Pos.Y = (float)PosYUpDown.Value;
}
updateListView();
render();
@@ -968,10 +900,10 @@ namespace PckStudio
private void PosZUpDown_ValueChanged(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
part.Z = (float)PosZUpDown.Value;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
part.Pos.Z = (float)PosZUpDown.Value;
}
updateListView();
render();
@@ -1010,9 +942,9 @@ namespace PckStudio
private void TextureXUpDown_ValueChanged(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
part.U = (int)TextureXUpDown.Value;
}
updateListView();
@@ -1024,9 +956,9 @@ namespace PckStudio
private void TextureYUpDown_ValueChanged(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
part.V = (int)TextureXUpDown.Value;
}
updateListView();
@@ -1073,7 +1005,7 @@ namespace PckStudio
private void buttonDone_Click(object sender, EventArgs e)
{
Bitmap bitmap1 = new Bitmap(displayBox.Width, displayBox.Height);
foreach (var part in modelParts)
foreach (var part in modelBoxes)
{
boxes.Add(part.ToProperty());
}
@@ -1122,12 +1054,12 @@ namespace PckStudio
//Loads in model template(Steve)
private void buttonTemplate_Click(object sender, EventArgs e)
{
modelParts.Add(new ModelPart("HEAD", -4, -8, -4, 8, 8, 8, 0, 0));
modelParts.Add(new ModelPart("BODY", -4, 0, -2, 8, 12, 4, 16, 16));
modelParts.Add(new ModelPart("ARM0", -3, -2, -2, 4, 12, 4, 40, 16));
modelParts.Add(new ModelPart("ARM1", -1, -2, -2, 4, 12, 4, 40, 16));
modelParts.Add(new ModelPart("LEG0", -2, 0, -2, 4, 12, 4, 0, 16));
modelParts.Add(new ModelPart("LEG1", -2, 0, -2, 4, 12, 4, 0, 16));
modelBoxes.Add(new SkinBox("HEAD -4 -8 -4 8 8 8 0 0 0 0 0"));
modelBoxes.Add(new SkinBox("BODY -4 0 -2 8 12 4 16 16 0 0 0"));
modelBoxes.Add(new SkinBox("ARM0 -3 -2 -2 4 12 4 40 16 0 0 0"));
modelBoxes.Add(new SkinBox("ARM1 -1 -2 -2 4 12 4 40 16 0 1 0"));
modelBoxes.Add(new SkinBox("LEG0 -2 0 -2 4 12 4 0 16 0 0 0"));
modelBoxes.Add(new SkinBox("LEG1 -2 0 -2 4 12 0 16 0 1 0"));
comboParent.Enabled = true;
updateListView();
render();
@@ -1136,16 +1068,16 @@ namespace PckStudio
private void updateListView()
{
listViewBoxes.Items.Clear();
foreach (var part in modelParts)
foreach (var part in modelBoxes)
{
ListViewItem listViewItem = new ListViewItem(part.Type);
listViewItem.Tag = part;
listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.X.ToString()));
listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Y.ToString()));
listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Z.ToString()));
listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Width.ToString()));
listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Height.ToString()));
listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.Length.ToString()));
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.U.ToString()));
listViewItem.SubItems.Add(new ListViewItem.ListViewSubItem(listViewItem, part.V.ToString()));
listViewBoxes.Items.Add(listViewItem);
@@ -1186,11 +1118,10 @@ namespace PckStudio
listViewBoxes.Items.Clear();
string str1 = File.ReadAllText(openFileDialog.FileName);
modelParts.Clear();
modelBoxes.Clear();
List<string> lines = str1.Split(new[] { "\n\r", "\n" }, StringSplitOptions.None).ToList();
if (string.IsNullOrEmpty(lines[lines.Count - 1]))
lines.RemoveAt(lines.Count - 1);
int currentLine = 0;
int passedlines = 0;
for (int i = 0; i < lines.Count;)
{
@@ -1202,11 +1133,12 @@ namespace PckStudio
float SizeX = float.Parse(lines[6 + passedlines]);
float SizeY = float.Parse(lines[7 + passedlines]);
float SizeZ = float.Parse(lines[8 + passedlines]);
int UvX = int.Parse(lines[9 + passedlines]);
int UvY = int.Parse(lines[10 + passedlines]);
float UvX = float.Parse(lines[9 + passedlines]);
float UvY = float.Parse(lines[10 + passedlines]);
passedlines += 11;
i += 11;
modelParts.Add(new ModelPart(parent, PosX, PosY, PosZ, SizeX, SizeY, SizeZ, UvX, UvY));
// CSM doesn't support armor, mirror, or scale values as far as I know of - May
modelBoxes.Add(new SkinBox($"{parent} {PosX} {PosY} {PosZ} {SizeX} {SizeY} {SizeZ} {UvX} {UvY} {false} {false} {0}"));
}
}
comboParent.Enabled = true;
@@ -1293,18 +1225,18 @@ namespace PckStudio
private void listView1_Click(object sender, EventArgs e)
{
if (listViewBoxes.SelectedItems.Count != 0 && listViewBoxes.SelectedItems[0] != null &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
var part = listViewBoxes.SelectedItems[0].Tag as ModelPart;
var part = listViewBoxes.SelectedItems[0].Tag as SkinBox;
comboParent.Text = part.Type;
PosXUpDown.Value = (decimal)part.X;
PosYUpDown.Value = (decimal)part.Y;
PosZUpDown.Value = (decimal)part.Z;
SizeXUpDown.Value = (decimal)part.Width;
SizeYUpDown.Value = (decimal)part.Height;
SizeZUpDown.Value = (decimal)part.Length;
TextureXUpDown.Value = part.U;
TextureYUpDown.Value = part.V;
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.U;
TextureYUpDown.Value = (decimal)part.V;
SizeXUpDown.Enabled = true;
SizeYUpDown.Enabled = true;
SizeZUpDown.Enabled = true;
@@ -1343,9 +1275,9 @@ namespace PckStudio
private void delStuffUsingDelKey(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete && listViewBoxes.SelectedItems.Count != 0 &&
listViewBoxes.SelectedItems[0].Tag is ModelPart)
listViewBoxes.SelectedItems[0].Tag is SkinBox)
{
if (modelParts.Remove(listViewBoxes.SelectedItems[0].Tag as ModelPart))
if (modelBoxes.Remove(listViewBoxes.SelectedItems[0].Tag as SkinBox))
listViewBoxes.SelectedItems[0].Remove();
render();
}