Progress on twilight princess hd file table
This commit is contained in:
parent
9e132a68d3
commit
bd7a173876
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -23,21 +23,16 @@ namespace Switch_Toolbox.Library
|
||||
|
||||
public Dictionary<string, uint> FileSizes = new Dictionary<string, uint>();
|
||||
public Dictionary<string, DecompressedTableEntry> DecompressedFileSizes = new Dictionary<string, DecompressedTableEntry>();
|
||||
|
||||
public static void SetTables(IFileFormat FileFormat)
|
||||
{
|
||||
//Read the tables
|
||||
TPFileSizeTable CompressedFileTbl = new TPFileSizeTable();
|
||||
CompressedFileTbl.ReadCompressedTable(new FileReader($"{Runtime.TpGamePath}/FileSizeList.txt"));
|
||||
|
||||
TPFileSizeTable DecompressedFileTbl = new TPFileSizeTable();
|
||||
DecompressedFileTbl.ReadDecompressedTable(new FileReader($"{Runtime.TpGamePath}/DecompressedSizeList.txt"));
|
||||
public bool IsInFileSizeList(string FileName) => FileSizes.ContainsKey(FileName);
|
||||
public bool IsInDecompressedFileSizeList(string FileName) => DecompressedFileSizes.ContainsKey(FileName);
|
||||
|
||||
// var tableSave = new MemoryStream();
|
||||
// CompressedFileTbl.Write(new FileWriter(tableSave));
|
||||
// File.WriteAllBytes($"{Runtime.TpGamePath}/FileSizeListTEST.txt", tableSave.ToArray());
|
||||
// bool IsSuccess = CompressedFileTbl.TrySetSize(FileName, IFileInfo.CompressedSize, IFileInfo.DecompressedSize, ArchiveSizes);
|
||||
public void SetFileSizeEntry(string FileName, uint Size) {
|
||||
FileSizes[FileName] = Size;
|
||||
}
|
||||
|
||||
public void SetDecompressedFileSizeEntry(string FileName, uint Size) {
|
||||
DecompressedFileSizes[FileName].Size = Size;
|
||||
}
|
||||
|
||||
public void ReadCompressedTable(FileReader reader)
|
||||
@ -63,6 +58,8 @@ namespace Switch_Toolbox.Library
|
||||
entry.Precentage = reader.ReadString(BinaryStringFormat.ZeroTerminated);
|
||||
entry.FilePath = reader.ReadString(BinaryStringFormat.ZeroTerminated);
|
||||
|
||||
Console.WriteLine($"Size {Size} Size2 {Size2} {entry.Precentage} {entry.FilePath}");
|
||||
|
||||
uint sizeNum = 0;
|
||||
uint sizeNum2 = 0;
|
||||
|
||||
@ -76,23 +73,6 @@ namespace Switch_Toolbox.Library
|
||||
}
|
||||
}
|
||||
|
||||
public bool TrySetSize(string Path, uint DecompSize, uint CompSize, Dictionary<string, uint> ArchiveFiles = null)
|
||||
{
|
||||
string RelativePath = Path.Replace(Runtime.TpGamePath, string.Empty);
|
||||
|
||||
if (FileSizes.ContainsKey(RelativePath))
|
||||
{
|
||||
if (UseCompressedSizes)
|
||||
FileSizes[RelativePath] = CompSize;
|
||||
else
|
||||
FileSizes[RelativePath] = DecompSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void WriteCompressedTable(FileWriter writer)
|
||||
{
|
||||
foreach (var file in FileSizes)
|
||||
|
@ -25,6 +25,32 @@ namespace Switch_Toolbox.Library
|
||||
ReadOnly = true;
|
||||
}
|
||||
|
||||
public static void WriteLine(object line, int ColorKeyIndex)
|
||||
{
|
||||
if (console == null)
|
||||
return;
|
||||
|
||||
if (ColorKeyIndex == 0)
|
||||
WriteLine(line.ToString(), Color.Red);
|
||||
else if (ColorKeyIndex == 1)
|
||||
WriteLine(line.ToString(), Color.Green);
|
||||
else
|
||||
WriteLine(line.ToString());
|
||||
}
|
||||
|
||||
public static void WriteLine(string line, int ColorKeyIndex)
|
||||
{
|
||||
if (console == null)
|
||||
return;
|
||||
|
||||
if (ColorKeyIndex == 0)
|
||||
WriteLine(line.ToString(), Color.Red);
|
||||
else if (ColorKeyIndex == 1)
|
||||
WriteLine(line.ToString(), Color.Green);
|
||||
else
|
||||
WriteLine(line.ToString());
|
||||
}
|
||||
|
||||
public static void WriteLine(object line, Color? color = null)
|
||||
{
|
||||
if (console == null)
|
||||
|
@ -39,7 +39,7 @@ namespace Switch_Toolbox.Library.IO
|
||||
|
||||
FileFormat.IFileInfo.CompressedSize = (uint)FinalData.Length;
|
||||
|
||||
DetailsLog += "\n" + SatisfyFileTables(FileName, FinalData,
|
||||
DetailsLog += "\n" + SatisfyFileTables(FileFormat, FileName, FinalData,
|
||||
FileFormat.IFileInfo.DecompressedSize,
|
||||
FileFormat.IFileInfo.CompressedSize,
|
||||
FileFormat.IFileInfo.FileIsCompressed);
|
||||
@ -51,7 +51,7 @@ namespace Switch_Toolbox.Library.IO
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
||||
private static string SatisfyFileTables(string FilePath, byte[] Data, uint DecompressedSize, uint CompressedSize, bool IsCompressed)
|
||||
private static string SatisfyFileTables(IFileFormat FileFormat, string FilePath, byte[] Data, uint DecompressedSize, uint CompressedSize, bool IsCompressed)
|
||||
{
|
||||
string FileLog = "";
|
||||
|
||||
@ -83,11 +83,17 @@ namespace Switch_Toolbox.Library.IO
|
||||
|
||||
//Now apply the file table then save the table
|
||||
if (BotwResourceTable.IsInTable(newFilePath))
|
||||
{
|
||||
FileLog += $"File found in resource table! {newFilePath}";
|
||||
STConsole.WriteLine(FileLog, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileLog += $"File NOT found in resource table! {newFilePath}";
|
||||
STConsole.WriteLine(FileLog, 0);
|
||||
|
||||
}
|
||||
|
||||
STConsole.WriteLine(FileLog);
|
||||
|
||||
BotwResourceTable.SetEntry(newFilePath, Data);
|
||||
BotwResourceTable.Write(new FileWriter(RstbPath));
|
||||
@ -96,7 +102,51 @@ namespace Switch_Toolbox.Library.IO
|
||||
|
||||
if (Runtime.ResourceTables.TpTable && IsTPHDFile)
|
||||
{
|
||||
string newFilePath = FilePath.Replace(Runtime.BotwGamePath, string.Empty).Remove(0, 1);
|
||||
newFilePath = newFilePath.Replace(".s", ".");
|
||||
newFilePath = newFilePath.Replace(@"\", "/");
|
||||
|
||||
//Read the tables and set the new sizes if paths match
|
||||
TPFileSizeTable CompressedFileTbl = new TPFileSizeTable();
|
||||
CompressedFileTbl.ReadCompressedTable(new FileReader($"{Runtime.TpGamePath}/FileSizeList.txt"));
|
||||
if (CompressedFileTbl.IsInFileSizeList(newFilePath))
|
||||
{
|
||||
STConsole.WriteLine("Found matching path in File Size List table! " + newFilePath, 1);
|
||||
CompressedFileTbl.SetFileSizeEntry(newFilePath, CompressedSize);
|
||||
}
|
||||
else
|
||||
STConsole.WriteLine("Failed to find path in File Size List table! " + newFilePath, 0);
|
||||
|
||||
|
||||
TPFileSizeTable DecompressedFileTbl = new TPFileSizeTable();
|
||||
DecompressedFileTbl.ReadDecompressedTable(new FileReader($"{Runtime.TpGamePath}/DecompressedSizeList.txt"));
|
||||
|
||||
bool IsArchive = false;
|
||||
foreach (var inter in FileFormat.GetType().GetInterfaces())
|
||||
if (inter.IsGenericType && inter.GetGenericTypeDefinition() == typeof(IArchiveFile))
|
||||
IsArchive = true;
|
||||
|
||||
if (IsArchive)
|
||||
{
|
||||
IArchiveFile Archive = (IArchiveFile)FileFormat;
|
||||
foreach (var file in Archive.Files)
|
||||
{
|
||||
uint DecompressedFileSize = (uint)file.FileData.Length;
|
||||
string ArchiveFilePath = $"/DVDRoot/{file.FileName}";
|
||||
|
||||
DecompressedFileTbl.ReadCompressedTable(new FileReader($"{Runtime.TpGamePath}/FileSizeList.txt"));
|
||||
if (DecompressedFileTbl.IsInDecompressedFileSizeList(newFilePath))
|
||||
{
|
||||
STConsole.WriteLine("Found matching path in File Size List table! " + newFilePath, 1);
|
||||
DecompressedFileTbl.SetDecompressedFileSizeEntry(newFilePath, DecompressedFileSize);
|
||||
}
|
||||
else
|
||||
STConsole.WriteLine("Failed to find path in File Size List table! " + newFilePath, 0);
|
||||
}
|
||||
}
|
||||
|
||||
DecompressedFileTbl.WriteCompressedTable(new FileWriter($"{Runtime.TpGamePath}/FileSizeListTEST.txt"));
|
||||
DecompressedFileTbl.WriteDecompressedTable(new FileWriter($"{Runtime.TpGamePath}/DecompressedSizeListTEST.txt"));
|
||||
}
|
||||
|
||||
return FileLog;
|
||||
|
Loading…
Reference in New Issue
Block a user