1
0
mirror of synced 2025-02-21 21:10:27 +01:00

BFRES Wii U : Fix updating bone order from updating dictionary keys.

This commit is contained in:
KillzXGaming 2019-12-06 20:31:39 -05:00
parent d1b0819c53
commit 4de9f3eca7

View File

@ -699,20 +699,18 @@ namespace Bfres.Structs
if (dialog.ShowDialog() == DialogResult.OK) { RenameBone(dialog.textBox1.Text); } if (dialog.ShowDialog() == DialogResult.OK) { RenameBone(dialog.textBox1.Text); }
} }
//Method to readjust the dictionaries for the skeleton //Method to re-adjust the dictionaries for the skeleton
public void RenameBone(string Name) public void RenameBone(string Name)
{ {
if (((FSKL)skeletonParent).node.SkeletonU != null) if (((FSKL)skeletonParent).node.SkeletonU != null)
{ {
var Skeleton = ((FSKL)skeletonParent).node.SkeletonU; var Skeleton = ((FSKL)skeletonParent).node.SkeletonU;
Skeleton.Bones.Remove(BoneU);
if (Skeleton.Bones.ContainsKey(Name)) if (Skeleton.Bones.ContainsKey(Name))
{ {
MessageBox.Show("A bone with the same name exits! Make sure to use a unique name!", MessageBox.Show("A bone with the same name exits! Make sure to use a unique name!",
"Bone Rename", MessageBoxButtons.OK, MessageBoxIcon.Error); "Bone Rename", MessageBoxButtons.OK, MessageBoxIcon.Error);
Skeleton.Bones.Add(BoneName, BoneU);
return; return;
} }
@ -720,9 +718,8 @@ namespace Bfres.Structs
Text = Name; Text = Name;
BoneName = Name; BoneName = Name;
//Adjust dictionaries //Adjust dictionary
Skeleton.Bones.Remove(BoneU); UpdateBoneKeys(Skeleton.Bones.Values.ToList());
Skeleton.Bones.Add(Name, BoneU);
} }
else else
{ {
@ -732,6 +729,15 @@ namespace Bfres.Structs
} }
} }
private void UpdateBoneKeys(List<ResU.Bone> bones)
{
var Skeleton = ((FSKL)skeletonParent).node.SkeletonU;
Skeleton.Bones.Clear();
for (int i = 0; i < bones.Count; i++)
Skeleton.Bones.Add(bones[i].Name, bones[i]);
}
public void CloneBaseInstance(STBone genericBone) public void CloneBaseInstance(STBone genericBone)
{ {
Text = genericBone.Text; Text = genericBone.Text;