private bool Autofix(params TPFTexInfo[] texes)
{
if (texes.Length == 0)
{
Overall.UpdateText("All textures are valid, skipping autofix.");
OverallProg.ChangeProgressBar(1, 1);
return true;
}
List<bool> results = new List<bool>();
OverallProg.ChangeProgressBar(0, texes.Length);
var fixedTexes = new Dictionary<uint, TPFTexInfo>();
foreach (TPFTexInfo tex in texes)
{
tex.AutofixSuccess = false;
// Heff: fix for skipping already fixed values, only skips when autofixing in bulk.
if (fixedTexes.ContainsKey(tex.Hash))
{
var dup = fixedTexes[tex.Hash];
tex.NumMips = dup.NumMips;
tex.Format = dup.Format;
tex.FilePath = dup.FilePath;
tex.FileName = dup.FileName;
tex.AutofixSuccess = true;
}
Overall.UpdateText("Fixing: " + tex.TexName);
DebugOutput.PrintLn("Fixing: " + tex.TexName + Environment.NewLine + " FORMAT -> Current: " + tex.Format + " Expected: " + tex.ExpectedFormat + Environment.NewLine + " MIPS -> Current: " + tex.NumMips + " Expected: " + tex.ExpectedMips);
// Heff: should we check like this for autofixsuccess here before trying to fix? See above "skip"
if (!tex.AutofixSuccess)
results.Add(AutofixInternal(tex));
if (tex.AutofixSuccess && !fixedTexes.ContainsKey(tex.Hash))
fixedTexes.Add(tex.Hash, tex);
// Heff: Cancellation check
if (cts.IsCancellationRequested)
return false;
RedrawTreeView();
}
Overall.UpdateText("Autofix complete." + (results.Any(t => !t) ? "Some errors occured. Manual fixing may be required." : ""));
OverallProg.ChangeProgressBar(1, 1);
// KFreon: Check those already checked.
CheckNodes(LoadedTexes);
return !results.Any(t => !t); // Inverts number of false entries
}