diff --git a/PCK-Studio/Forms/Utilities/Skins/BoxEditor.Designer.cs b/PCK-Studio/Forms/Utilities/Skins/BoxEditor.Designer.cs
index 977fa989..c11b2ae1 100644
--- a/PCK-Studio/Forms/Utilities/Skins/BoxEditor.Designer.cs
+++ b/PCK-Studio/Forms/Utilities/Skins/BoxEditor.Designer.cs
@@ -67,7 +67,7 @@
this.closeButton.Text = "Save";
this.closeButton.Theme = MetroFramework.MetroThemeStyle.Dark;
this.closeButton.UseSelectable = true;
- this.closeButton.Click += new System.EventHandler(this.closeButton_Click);
+ this.closeButton.Click += new System.EventHandler(this.saveButton_Click);
//
// toolTip
//
diff --git a/PCK-Studio/Forms/Utilities/Skins/BoxEditor.cs b/PCK-Studio/Forms/Utilities/Skins/BoxEditor.cs
index 5922a566..07f06daa 100644
--- a/PCK-Studio/Forms/Utilities/Skins/BoxEditor.cs
+++ b/PCK-Studio/Forms/Utilities/Skins/BoxEditor.cs
@@ -1,62 +1,53 @@
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.IO;
+using System.Text.RegularExpressions;
using System.Windows.Forms;
-using PckStudio.Classes.Utils;
namespace PckStudio.Forms.Utilities.Skins
{
public partial class BoxEditor : MetroFramework.Forms.MetroForm
{
- public bool saved = false;
-
- public string out_box;
+ public string Result;
class BOX
{
- public BOX(string inBOX)
+ public string Parent;
+ public (float X, float Y, float Z) Pos;
+ public (float X, float Y, float Z) Size;
+ public float uvX, uvY;
+ public bool HideWithArmor;
+ public bool Mirror;
+ public float Inflation;
+
+ public BOX(string input)
{
- string[] arguments = inBOX.Split(' ');
+ string[] arguments = Regex.Split(input, @"\s+");
try
{
- parent = arguments[0];
- posX = float.Parse(arguments[1]);
- posY = float.Parse(arguments[2]);
- posZ = float.Parse(arguments[3]);
- sizeX = float.Parse(arguments[4]);
- sizeY = float.Parse(arguments[5]);
- sizeZ = float.Parse(arguments[6]);
+ Parent = arguments[0];
+ Pos.X = float.Parse(arguments[1]);
+ Pos.Y = float.Parse(arguments[2]);
+ Pos.Z = float.Parse(arguments[3]);
+ Size.X = float.Parse(arguments[4]);
+ Size.Y = float.Parse(arguments[5]);
+ Size.Z = float.Parse(arguments[6]);
uvX = float.Parse(arguments[7]);
uvY = float.Parse(arguments[8]);
- hideWithArmor = arguments[9] == "1";
- mirror = arguments[10] == "1";
- inflation = float.Parse(arguments[11]);
+ HideWithArmor = arguments[9] == "1";
+ Mirror = arguments[10] == "1";
+ Inflation = float.Parse(arguments[11]);
}
- catch (IndexOutOfRangeException ex2)
+ catch (IndexOutOfRangeException)
{
// This is normal as some box values can have less parameters but no more than 12
return;
}
catch (Exception ex)
{
- parent = "invalid";
+ Parent = string.Empty;
}
}
- public string parent;
- public float posX, posY, posZ;
- public float sizeX, sizeY, sizeZ;
- public float uvX, uvY;
- public bool hideWithArmor;
- public bool mirror;
- public float inflation;
}
public BoxEditor(string inBOX, bool hasInflation)
@@ -67,44 +58,35 @@ namespace PckStudio.Forms.Utilities.Skins
BOX box = new BOX(inBOX);
- if (box.parent == "invalid" || !parentComboBox.Items.Contains(box.parent))
+ if (string.IsNullOrEmpty(box.Parent) || !parentComboBox.Items.Contains(box.Parent))
{
throw new Exception("Failed to parse BOX value");
}
- parentComboBox.SelectedItem = parentComboBox.Items[parentComboBox.Items.IndexOf(box.parent)];
- PosXUpDown.Value = (decimal)box.posX;
- PosYUpDown.Value = (decimal)box.posY;
- PosZUpDown.Value = (decimal)box.posZ;
- SizeXUpDown.Value = (decimal)box.sizeX;
- SizeYUpDown.Value = (decimal)box.sizeY;
- SizeZUpDown.Value = (decimal)box.sizeZ;
+ parentComboBox.SelectedItem = parentComboBox.Items[parentComboBox.Items.IndexOf(box.Parent)];
+ PosXUpDown.Value = (decimal)box.Pos.X;
+ PosYUpDown.Value = (decimal)box.Pos.Y;
+ PosZUpDown.Value = (decimal)box.Pos.Z;
+ SizeXUpDown.Value = (decimal)box.Size.X;
+ SizeYUpDown.Value = (decimal)box.Size.Y;
+ SizeZUpDown.Value = (decimal)box.Size.Z;
uvXUpDown.Value = (decimal)box.uvX;
uvYUpDown.Value = (decimal)box.uvY;
- armorCheckBox.Checked = box.hideWithArmor;
- mirrorCheckBox.Checked = box.mirror;
- inflationUpDown.Value = (decimal)box.inflation;
+ armorCheckBox.Checked = box.HideWithArmor;
+ mirrorCheckBox.Checked = box.Mirror;
+ inflationUpDown.Value = (decimal)box.Inflation;
}
- private void closeButton_Click(object sender, EventArgs e)
+ private void saveButton_Click(object sender, EventArgs e)
{
- out_box =
- parentComboBox.SelectedItem.ToString() + " " +
- PosXUpDown.Value.ToString() + " " +
- PosYUpDown.Value.ToString() + " " +
- PosZUpDown.Value.ToString() + " " +
- SizeXUpDown.Value.ToString() + " " +
- SizeYUpDown.Value.ToString() + " " +
- SizeZUpDown.Value.ToString() + " " +
- uvXUpDown.Value.ToString() + " " +
- uvYUpDown.Value.ToString() + " " +
- (armorCheckBox.Checked ? "1 " : "0 ") +
- (mirrorCheckBox.Checked ? "1 " : "0 ") +
- inflationUpDown.Value.ToString();
- saved = true;
-
+ Result =
+ $"{parentComboBox.SelectedItem} " +
+ $"{PosXUpDown.Value} {PosYUpDown.Value} {PosZUpDown.Value} " +
+ $"{SizeXUpDown.Value} {SizeYUpDown.Value} {SizeZUpDown.Value} " +
+ $"{uvXUpDown.Value} {uvYUpDown.Value} " +
+ $"{(mirrorCheckBox.Checked ? "1 " : "0 ")} {(mirrorCheckBox.Checked ? "1 " : "0 ")} " +
+ $"{inflationUpDown.Value}";
DialogResult = DialogResult.OK;
-
Close();
}
}
diff --git a/PCK-Studio/Forms/Utilities/Skins/BoxEditor.resx b/PCK-Studio/Forms/Utilities/Skins/BoxEditor.resx
index 8766f298..db5d551f 100644
--- a/PCK-Studio/Forms/Utilities/Skins/BoxEditor.resx
+++ b/PCK-Studio/Forms/Utilities/Skins/BoxEditor.resx
@@ -120,4 +120,19 @@
17, 17
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
\ No newline at end of file
diff --git a/PCK-Studio/MainForm.cs b/PCK-Studio/MainForm.cs
index e49fed0f..1bb917e8 100644
--- a/PCK-Studio/MainForm.cs
+++ b/PCK-Studio/MainForm.cs
@@ -969,7 +969,7 @@ namespace PckStudio
using BoxEditor diag = new BoxEditor(property.Item2, IsSubPCKNode(treeViewMain.SelectedNode.FullPath));
if (diag.ShowDialog(this) == DialogResult.OK)
{
- file.properties[i] = new ValueTuple("BOX", diag.out_box);
+ file.properties[i] = new ValueTuple("BOX", diag.Result);
if (IsSubPCKNode(treeViewMain.SelectedNode.FullPath))
RebuildSubPCK(treeViewMain.SelectedNode);
ReloadMetaTreeView();