mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-05-18 11:21:18 +03:00
update NRES file with element count and element size, seen in ResTree .trf
This commit is contained in:
parent
8c4fc8f096
commit
a419be1fce
@ -19,10 +19,11 @@ public record NResArchiveHeader(string NRes, int Version, int FileCount, int Tot
|
||||
/// каждый элемент это 64 байта,
|
||||
/// найти начало можно как (Header.TotalFileLengthBytes - Header.FileCount * 64)
|
||||
/// </summary>
|
||||
/// <param name="FileType">[0..8] ASCII описание типа файла, например TEXM или MAT0</param>
|
||||
/// <param name="FileType">[0..4] ASCII описание типа файла, например TEXM или MAT0</param>
|
||||
/// <param name="ElementCount">[4..8] Количество элементов в файле (если файл составной, например .trf) </param>
|
||||
/// <param name="Magic1">[8..12] Неизвестное число</param>
|
||||
/// <param name="FileLength">[12..16] Длина файла в байтах</param>
|
||||
/// <param name="Magic2">[16..20] Неизвестное число</param>
|
||||
/// <param name="ElementSize">[16..20] Размер элемента в файле (если файл составной, например .trf) </param>
|
||||
/// <param name="FileName">[20..40] ASCII имя файла</param>
|
||||
/// <param name="Magic3">[40..44] Неизвестное число</param>
|
||||
/// <param name="Magic4">[44..48] Неизвестное число</param>
|
||||
@ -32,9 +33,10 @@ public record NResArchiveHeader(string NRes, int Version, int FileCount, int Tot
|
||||
/// <param name="Index">[60..64] Индекс в файле (от 0, не больше чем кол-во файлов)</param>
|
||||
public record ListMetadataItem(
|
||||
string FileType,
|
||||
uint ElementCount,
|
||||
int Magic1,
|
||||
int FileLength,
|
||||
int Magic2,
|
||||
int ElementSize,
|
||||
string FileName,
|
||||
int Magic3,
|
||||
int Magic4,
|
||||
|
@ -30,7 +30,7 @@ public class NResExporter
|
||||
extension = ".bin";
|
||||
}
|
||||
|
||||
var targetFilePath = Path.Combine(targetDirectoryPath, $"{archiveFile.Index}_{fileName}{extension}");
|
||||
var targetFilePath = Path.Combine(targetDirectoryPath, $"{archiveFile.Index}_{archiveFile.FileType}_{fileName}{extension}");
|
||||
|
||||
File.WriteAllBytes(targetFilePath, buffer);
|
||||
}
|
||||
|
@ -48,13 +48,32 @@ public static class NResParser
|
||||
for (int i = 0; i < header.FileCount; i++)
|
||||
{
|
||||
nResFs.ReadExactly(metaDataBuffer);
|
||||
var type = "";
|
||||
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (!char.IsLetterOrDigit((char)metaDataBuffer[j]))
|
||||
{
|
||||
type += metaDataBuffer[j]
|
||||
.ToString("X2") + " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
type += (char)metaDataBuffer[j];
|
||||
}
|
||||
}
|
||||
|
||||
var type2 = BinaryPrimitives.ReadUInt32LittleEndian(metaDataBuffer.Slice(4));
|
||||
|
||||
type = type.Trim();
|
||||
|
||||
elements.Add(
|
||||
new ListMetadataItem(
|
||||
FileType: Encoding.ASCII.GetString(metaDataBuffer[..8]).TrimEnd('\0'),
|
||||
FileType: type,
|
||||
ElementCount: type2,
|
||||
Magic1: BinaryPrimitives.ReadInt32LittleEndian(metaDataBuffer[8..12]),
|
||||
FileLength: BinaryPrimitives.ReadInt32LittleEndian(metaDataBuffer[12..16]),
|
||||
Magic2: BinaryPrimitives.ReadInt32LittleEndian(metaDataBuffer[16..20]),
|
||||
ElementSize: BinaryPrimitives.ReadInt32LittleEndian(metaDataBuffer[16..20]),
|
||||
FileName: Encoding.ASCII.GetString(metaDataBuffer[20..40]).TrimEnd('\0'),
|
||||
Magic3: BinaryPrimitives.ReadInt32LittleEndian(metaDataBuffer[40..44]),
|
||||
Magic4: BinaryPrimitives.ReadInt32LittleEndian(metaDataBuffer[44..48]),
|
||||
|
@ -32,10 +32,11 @@
|
||||
3. В конце файла есть метаданные.
|
||||
Поскольку NRes это по сути архив, длина метаданных у каждого файла разная и считается как `Количество файлов * 64`, каждый элемент метаданных - 64 байта.
|
||||
|
||||
+ [0..8] ASCII описание типа файла, например TEXM или MAT0
|
||||
+ [0..4] ASCII описание типа файла, например TEXM или MAT0
|
||||
+ [4..8] Количество элементов в файле (если файл составной, например .trf)
|
||||
+ [8..12] Неизвестное число
|
||||
+ [12..16] Длина файла в байтах
|
||||
+ [16..20] Неизвестное число
|
||||
+ [16..20] Размер элемента в файле (если файл составной, например .trf)
|
||||
+ [20..40] ASCII имя файла
|
||||
+ [40..44] Неизвестное число
|
||||
+ [44..48] Неизвестное число
|
||||
|
@ -46,12 +46,13 @@ public class NResExplorerPanel : IImGuiPanel
|
||||
ImGui.Text(_viewModel.Archive.Header.TotalFileLengthBytes.ToString());
|
||||
|
||||
|
||||
if (ImGui.BeginTable("content", 11))
|
||||
if (ImGui.BeginTable("content", 12, ImGuiTableFlags.Borders | ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.NoHostExtendX))
|
||||
{
|
||||
ImGui.TableSetupColumn("Тип файла");
|
||||
ImGui.TableSetupColumn("Кол-во элементов");
|
||||
ImGui.TableSetupColumn("Magic1");
|
||||
ImGui.TableSetupColumn("Длина файла в байтах");
|
||||
ImGui.TableSetupColumn("Magic2");
|
||||
ImGui.TableSetupColumn("Размер элемента");
|
||||
ImGui.TableSetupColumn("Имя файла");
|
||||
ImGui.TableSetupColumn("Magic3");
|
||||
ImGui.TableSetupColumn("Magic4");
|
||||
@ -68,6 +69,8 @@ public class NResExplorerPanel : IImGuiPanel
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(_viewModel.Archive.Files[i].FileType);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(_viewModel.Archive.Files[i].ElementCount.ToString());
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(
|
||||
_viewModel.Archive.Files[i]
|
||||
.Magic1.ToString()
|
||||
@ -80,7 +83,7 @@ public class NResExplorerPanel : IImGuiPanel
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(
|
||||
_viewModel.Archive.Files[i]
|
||||
.Magic2.ToString()
|
||||
.ElementSize.ToString()
|
||||
);
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(_viewModel.Archive.Files[i].FileName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user