diff --git a/UE4localizationsTool/Core/locres.cs b/UE4localizationsTool/Core/locres.cs index 8726a19..17c5cba 100644 --- a/UE4localizationsTool/Core/locres.cs +++ b/UE4localizationsTool/Core/locres.cs @@ -53,8 +53,17 @@ private void ReadOrEdit(bool Modify = false) if (Version >= LocresVersion.Compact) { - // Console.WriteLine("Compact"); + // Console.WriteLine("Compact"); + int localizedStringOffset = (int)locresData.GetInt64Value(); + int currentFileOffset = locresData.GetPosition(); + + + if (localizedStringOffset == -1) + { + return; + } + locresData.Seek(localizedStringOffset); int localizedStringCount = locresData.GetIntValue(); @@ -92,6 +101,7 @@ private void ReadOrEdit(bool Modify = false) } } } + locresData.Seek(currentFileOffset); } else if (Version == LocresVersion.Legacy) @@ -101,7 +111,7 @@ private void ReadOrEdit(bool Modify = false) for (int i = 0; i < HashTablesCount; i++) { - locresData.GetStringUE(); //hash namespace + locresData.GetStringUE(); //hash namespace int localizedStringCount = locresData.GetIntValue(); @@ -110,9 +120,9 @@ private void ReadOrEdit(bool Modify = false) { if (!Modify) { - locresData.GetStringUE(); //string hash + string KeyHash = locresData.GetStringUE(); //string hash locresData.Skip(4); //Unkown - Strings.Add(new List() { Strings.Count.ToString(), locresData.GetStringUE() }); + Strings.Add(new List() { KeyHash, locresData.GetStringUE() }); } else @@ -125,11 +135,67 @@ private void ReadOrEdit(bool Modify = false) } } + return; } + + if (Version >= LocresVersion.Optimized) + { + locresData.Skip(4); //FileHash + } + + + int namespaceCount = locresData.GetIntValue(); + + for(int n=0;n< namespaceCount; n++) + { + string nameSpaceStr; + uint StrHash; + ReadTextKey(locresData, Version,out StrHash,out nameSpaceStr); //no need right now + uint keyCount= locresData.GetUIntValue(); + for (int k=0;k< keyCount;k++) + { + string KeyStr; + uint KeyStrHash; + ReadTextKey(locresData, Version, out KeyStrHash, out KeyStr); + locresData.Skip(4);//SourceStringHash + + if (Version >= LocresVersion.Compact) + { + int localizedStringIndex= locresData.GetIntValue(); + if(Strings.Count> localizedStringIndex) + { + Strings[localizedStringIndex][0] = KeyStr; + } + + } + + } + + } + + + + + + + + + + } + private void ReadTextKey(MemoryList memoryList, LocresVersion locresVersion, out uint StrHash, out string Str) + { + StrHash = 0; + Str = ""; + if (locresVersion >= LocresVersion.Optimized) + { + StrHash = memoryList.GetUIntValue(); + } + Str = memoryList.GetStringUE(); + } private void ModifyStrings()