diff --git a/NResLib/NResArchive.cs b/NResLib/NResArchive.cs
index 92202ab..1f94348 100644
--- a/NResLib/NResArchive.cs
+++ b/NResLib/NResArchive.cs
@@ -19,10 +19,11 @@ public record NResArchiveHeader(string NRes, int Version, int FileCount, int Tot
/// каждый элемент это 64 байта,
/// найти начало можно как (Header.TotalFileLengthBytes - Header.FileCount * 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] Неизвестное число
@@ -32,9 +33,10 @@ public record NResArchiveHeader(string NRes, int Version, int FileCount, int Tot
/// [60..64] Индекс в файле (от 0, не больше чем кол-во файлов)
public record ListMetadataItem(
string FileType,
+ uint ElementCount,
int Magic1,
int FileLength,
- int Magic2,
+ int ElementSize,
string FileName,
int Magic3,
int Magic4,
diff --git a/NResLib/NResExporter.cs b/NResLib/NResExporter.cs
index 4cc08b7..7396049 100644
--- a/NResLib/NResExporter.cs
+++ b/NResLib/NResExporter.cs
@@ -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);
}
diff --git a/NResLib/NResParser.cs b/NResLib/NResParser.cs
index cb079ab..7c04557 100644
--- a/NResLib/NResParser.cs
+++ b/NResLib/NResParser.cs
@@ -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]),
diff --git a/NResLib/README.md b/NResLib/README.md
index bf60c91..3226dd5 100644
--- a/NResLib/README.md
+++ b/NResLib/README.md
@@ -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] Неизвестное число
diff --git a/NResUI/ImGuiUI/NResExplorerPanel.cs b/NResUI/ImGuiUI/NResExplorerPanel.cs
index d3902aa..173d0e7 100644
--- a/NResUI/ImGuiUI/NResExplorerPanel.cs
+++ b/NResUI/ImGuiUI/NResExplorerPanel.cs
@@ -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);