Skip to content

Commit 92942b1

Browse files
committed
rework object viewer to have a tab for each section of ILocoObject
1 parent 2580f6b commit 92942b1

File tree

9 files changed

+622
-163
lines changed

9 files changed

+622
-163
lines changed

OpenLocoTool/DatFileParsing/SawyerStreamReader.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ public ILocoObject LoadFull(string filename, bool loadExtra = true)
121121

122122
for (var i = 0; i < stringTableAttr.Count; ++i)
123123
{
124+
var stringName = stringTableAttr.Names[i];
125+
stringTable.Add(stringName, new());
126+
var languageDict = stringTable[stringName];
127+
124128
for (; ptr < data.Length && data[ptr] != 0xFF;)
125129
{
126130
var lang = (LanguageId)data[ptr++];
@@ -129,15 +133,14 @@ public ILocoObject LoadFull(string filename, bool loadExtra = true)
129133
while (data[ptr++] != '\0') ;
130134

131135
var str = Encoding.ASCII.GetString(data[ini..(ptr - 1)]); // do -1 to exclude the \0
132-
var stringName = stringTableAttr.Names[i];
133-
if (stringTable.ContainsKey((stringName, lang)))
136+
if (languageDict.ContainsKey(lang))
134137
{
135138
//Logger.Error($"Key {(i, lang)} already exists (this shouldn't happen)");
136139
break;
137140
}
138141
else
139142
{
140-
stringTable.Add((stringName, lang), str);
143+
languageDict.Add(lang, str);
141144
}
142145
}
143146

OpenLocoTool/DatFileParsing/Typedefs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
global using Speed32 = System.Int32;
1010
global using MicroZ = System.Byte;
1111
global using SoundObjectId = System.Byte;
12-
global using StringTable = System.Collections.Generic.Dictionary<(string, OpenLocoTool.LanguageId), string>;
12+
global using StringTable = System.Collections.Generic.Dictionary<string, System.Collections.Generic.Dictionary<OpenLocoTool.LanguageId, string>>;
1313
using System.ComponentModel;
1414

1515
namespace OpenLocoTool.DatFileParsing

0 commit comments

Comments
 (0)