1
0
mirror of synced 2024-11-30 18:24:39 +01:00

Some fixes.

Fix and cleanup repack method for archives.
Fix setting up original mip count (now is a optional setting).
Fixed format and some settings being applied for multiple selected textures.
This commit is contained in:
KillzXGaming 2019-12-10 16:59:40 -05:00
parent 851cbf380f
commit 56eecea8d3
4 changed files with 25 additions and 42 deletions

View File

@ -207,7 +207,7 @@ namespace Bfres.Structs
else
{
var setting = FTEX.SetImporterSettings(file);
setting.MipCount = ftex.MipCount;
setting.MipCountOriginal = (int)ftex.MipCount;
setting.Format = (GX2.GX2SurfaceFormat)FTEX.ConvertToGx2Format(ftex.Format);
settings.Add(setting);
}

View File

@ -146,6 +146,7 @@ namespace Bfres.Structs
{
GTXImporterSettings setting = SetImporterSettings(image, FileName);
setting.MipSwizzle = Tex2Swizzle;
setting.MipCountOriginal = (int)MipCount;
GTXTextureImporter importer = new GTXTextureImporter();
importer.LoadSetting(setting);

View File

@ -131,7 +131,7 @@ namespace FirstPlugin
}
private Thread Thread;
public void SetupSettings(TextureImporterSettings setting)
public void SetupSettings(TextureImporterSettings setting, bool setFormat = true)
{
if (setting.Format == SurfaceFormat.Invalid || SelectedIndex == -1)
return;
@ -143,11 +143,11 @@ namespace FirstPlugin
if (Thread != null && Thread.IsAlive)
Thread.Abort();
if (formatComboBox.SelectedItem is SurfaceDim)
if (formatComboBox.SelectedItem is SurfaceDim && setFormat)
setting.SurfaceDim = (SurfaceDim)formatComboBox.SelectedItem;
if (formatComboBox.SelectedItem is SurfaceFormat)
if (formatComboBox.SelectedItem is SurfaceFormat && setFormat)
{
setting.Format = (SurfaceFormat)formatComboBox.SelectedItem;
@ -297,7 +297,7 @@ namespace FirstPlugin
else
settings[index].MipCount = 1;
SetupSettings(settings[index]);
SetupSettings(settings[index], false);
}
}
@ -316,7 +316,7 @@ namespace FirstPlugin
{
if (formatComboBox.SelectedIndex > -1 && SelectedTexSettings != null)
{
SetupSettings(SelectedTexSettings);
SetupSettings(SelectedTexSettings, false);
}
}
@ -332,13 +332,13 @@ namespace FirstPlugin
if (SelectedTexSettings != null)
{
SelectedTexSettings.GammaFix = cnkGammaFix.Checked;
SetupSettings(SelectedTexSettings);
SetupSettings(SelectedTexSettings, false);
}
}
private void chkMultiThreading_CheckedChanged(object sender, EventArgs e) {
if (SelectedTexSettings != null) {
SetupSettings(SelectedTexSettings);
SetupSettings(SelectedTexSettings, false);
}
}
}

View File

@ -142,49 +142,31 @@ namespace Toolbox.Library
return filesExtracted.ToArray();
}
/// <summary>
/// S
/// </summary>
/// <param name="directory"></param>
/// <returns></returns>
public static List<Tuple<string, string>> ReadFiles(string directory)
{
var Files = new List<Tuple<string, string>>();
ProcessDirectory(directory, Files);
ProcessDirectory(directory, "", Files);
return Files;
}
private static void ProcessDirectory(string targetDirectory, List<Tuple<string, string>> FileList)
private static void ProcessDirectory(string targetDirectory, string directory,
List<Tuple<string, string>> FileList, string seperator = "/")
{
var fileEntries = GetRelativePaths(targetDirectory);
//Combine the target and current directory to get the full path for searching
string folder = Path.Combine(targetDirectory, directory);
foreach (string fileName in fileEntries)
{
char[] sep = { '\\' };
string[] fn = fileName.Split(sep);
string tempf = "";
for (int i = 0; i < fn.Length; i++)
{
tempf += fn[i];
if (fn.Length > 2 && (i != fn.Length - 1))
{
tempf += "/";
}
}
//Search sub directories. Remove target directory from path
foreach (string dir in Directory.GetDirectories(folder))
ProcessDirectory(targetDirectory, dir.Replace($"{targetDirectory}\\", string.Empty), FileList);
Console.WriteLine($"{tempf} {targetDirectory} {fileName}");
FileList.Add(Tuple.Create(fileName, $"{targetDirectory}/{fileName}"));
}
string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
foreach (string subdirectory in subdirectoryEntries)
ProcessDirectory(subdirectory, FileList);
}
private static IEnumerable<string> GetRelativePaths(string root)
{
int rootLength = root.Length + (root[root.Length - 1] == '\\' ? 0 : 1);
foreach (string path in Directory.GetFiles(root, "*", SearchOption.AllDirectories))
{
yield return path.Remove(0, rootLength);
}
//Search files. Remove target directory from path
foreach (string file in Directory.GetFiles(folder))
FileList.Add(Tuple.Create($"{file.Replace($"{targetDirectory}\\", string.Empty)}".Replace("\\", seperator), file));
}
private static void CreateDirectoryIfExists(string Dir)