Skip to content

Commit

Permalink
rework object viewer to have a tab for each section of ILocoObject
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminSutas committed Nov 8, 2023
1 parent 2580f6b commit 92942b1
Show file tree
Hide file tree
Showing 9 changed files with 622 additions and 163 deletions.
9 changes: 6 additions & 3 deletions OpenLocoTool/DatFileParsing/SawyerStreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public ILocoObject LoadFull(string filename, bool loadExtra = true)

for (var i = 0; i < stringTableAttr.Count; ++i)
{
var stringName = stringTableAttr.Names[i];
stringTable.Add(stringName, new());
var languageDict = stringTable[stringName];

for (; ptr < data.Length && data[ptr] != 0xFF;)
{
var lang = (LanguageId)data[ptr++];
Expand All @@ -129,15 +133,14 @@ public ILocoObject LoadFull(string filename, bool loadExtra = true)
while (data[ptr++] != '\0') ;

var str = Encoding.ASCII.GetString(data[ini..(ptr - 1)]); // do -1 to exclude the \0
var stringName = stringTableAttr.Names[i];
if (stringTable.ContainsKey((stringName, lang)))
if (languageDict.ContainsKey(lang))
{
//Logger.Error($"Key {(i, lang)} already exists (this shouldn't happen)");
break;
}
else
{
stringTable.Add((stringName, lang), str);
languageDict.Add(lang, str);
}
}

Expand Down
2 changes: 1 addition & 1 deletion OpenLocoTool/DatFileParsing/Typedefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
global using Speed32 = System.Int32;
global using MicroZ = System.Byte;
global using SoundObjectId = System.Byte;
global using StringTable = System.Collections.Generic.Dictionary<(string, OpenLocoTool.LanguageId), string>;
global using StringTable = System.Collections.Generic.Dictionary<string, System.Collections.Generic.Dictionary<OpenLocoTool.LanguageId, string>>;
using System.ComponentModel;

namespace OpenLocoTool.DatFileParsing
Expand Down
Loading

0 comments on commit 92942b1

Please sign in to comment.