More RSTB fixes

This commit is contained in:
KillzXGaming 2019-06-11 18:05:07 -04:00
parent 4536246d6f
commit 9e132a68d3
9 changed files with 17 additions and 6 deletions

Binary file not shown.

View file

@ -1043,6 +1043,8 @@ namespace Bfres.Structs
v.boneWeights[j] = envelope.Value;
j++;
}
envelopes.Clear();
}
if (RigidIds.Count > 0)
@ -1079,6 +1081,9 @@ namespace Bfres.Structs
vtxIndex++;
}
nodeArrStrings.Clone();
nodeRigidIndex.Clone();
BonesNotMatched.Clear();
}
public void CreateNewBoundingBoxes()
@ -1240,7 +1245,6 @@ namespace Bfres.Structs
{
List<ushort> indices = new List<ushort>();
List<string> BoneNodes = new List<string>();
foreach (Vertex vtx in vertices)
{
foreach (int index in vtx.boneIds)
@ -1253,14 +1257,11 @@ namespace Bfres.Structs
STConsole.WriteLine($"Saving bone index {bone.Name} {index}");
indices.Add(ind);
}
}
}
indices.Sort();
STConsole.WriteLine($"Total Indices for {Text} {indices.Count}");
return indices;
}
public Vector3 TransformLocal(Vector3 position, int BoneIndex,bool IsSingleBind, bool IsPos = true)

View file

@ -27,7 +27,7 @@ namespace Switch_Toolbox.Library
var size = new RSTB.SizeCalculator().CalculateFileSize(FilePath, Data, IsWiiU, Force);
if (size == 0)
{
var result = MessageBox.Show("Error! Could not calculate size for resource entry! Do you want to remove it instead?", "Resource Table", MessageBoxButtons.YesNo);
var result = MessageBox.Show("Error! Could not calculate size for resource entry! Do you want to remove it instead?", "Resource Table", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.OK)
{
DeleteEntry(FilePath);
@ -41,6 +41,10 @@ namespace Switch_Toolbox.Library
uint OldSize = GetSize(FileName);
uint NewSize = (uint)ParseSize(FileName, Data, Force);
STConsole.WriteLine($"Setting RSTB Entry!");
STConsole.WriteLine($"{FileName} OldSize {OldSize}");
STConsole.WriteLine($"{FileName} NewSize {NewSize}");
SetSize(FileName, NewSize);
}

View file

@ -62,6 +62,8 @@ namespace Switch_Toolbox.Library.IO
{
string newFilePath = FilePath.Replace(Runtime.BotwGamePath, string.Empty).Remove(0, 1);
newFilePath = newFilePath.Replace(".s", ".");
newFilePath = newFilePath.Replace( @"\", "/");
string RealExtension = Path.GetExtension(newFilePath).Replace(".s", ".");
string RstbPath = Path.Combine($"{Runtime.BotwGamePath}",
@ -73,6 +75,8 @@ namespace Switch_Toolbox.Library.IO
//Create a backup first if one doesn't exist
if (!File.Exists($"{RstbPath}.backup"))
{
STConsole.WriteLine($"RSTB File found. Creating backup...");
BotwResourceTable.Write(new FileWriter($"{RstbPath}.backup"));
File.WriteAllBytes($"{RstbPath}.backup", EveryFileExplorer.YAZ0.Compress($"{RstbPath}.backup"));
}
@ -83,7 +87,9 @@ namespace Switch_Toolbox.Library.IO
else
FileLog += $"File NOT found in resource table! {newFilePath}";
BotwResourceTable.SetEntry(FilePath, Data);
STConsole.WriteLine(FileLog);
BotwResourceTable.SetEntry(newFilePath, Data);
BotwResourceTable.Write(new FileWriter(RstbPath));
File.WriteAllBytes(RstbPath, EveryFileExplorer.YAZ0.Compress(RstbPath));
}