From 21e4395e6a562300dc3474177a728b0a4cd26d1e Mon Sep 17 00:00:00 2001 From: Amr Shaheen Date: Tue, 14 Jun 2022 21:05:35 +0200 Subject: [PATCH] Changes for v1.6 (bug) --- UE4localizationsTool/Core/AssetHelper.cs | 23 ++++++---- UE4localizationsTool/Core/StructProperty.cs | 43 ++++++++++--------- UE4localizationsTool/Core/Uexp.cs | 3 ++ UE4localizationsTool/Forms/FrmMain.cs | 2 +- .../Properties/AssemblyInfo.cs | 2 +- .../UE4localizationsTool.csproj | 2 +- UE4localizationsTool/UpdateInfo.txt | 4 +- 7 files changed, 46 insertions(+), 33 deletions(-) diff --git a/UE4localizationsTool/Core/AssetHelper.cs b/UE4localizationsTool/Core/AssetHelper.cs index 12cf7be..0db3b65 100644 --- a/UE4localizationsTool/Core/AssetHelper.cs +++ b/UE4localizationsTool/Core/AssetHelper.cs @@ -88,7 +88,6 @@ public static void DeleteStringUE(this MemoryList memoryList) public static void ReplaceStringUE(this MemoryList memoryList, string StringValue) { - // memoryList.DeleteStringUE(); StringValue = StringValue.Replace("", "\r\n"); StringValue = StringValue.Replace("", "\r"); @@ -99,12 +98,20 @@ public static void ReplaceStringUE(this MemoryList memoryList, string StringValu string TempString = memoryList.GetStringUE(); if (StringValue == TempString) { - return; + return; } memoryList.Seek(ThisPosition); memoryList.DeleteStringUE(); + + if (string.IsNullOrEmpty(StringValue)) + { + memoryList.InsertIntValue(0); + return; + } + + StringValue += '\0'; Encoding encoding = Encoding.Unicode; @@ -113,17 +120,17 @@ public static void ReplaceStringUE(this MemoryList memoryList, string StringValu encoding = Encoding.ASCII; } + byte[] TextBytes= encoding.GetBytes(StringValue); + if (encoding == Encoding.ASCII) { - - memoryList.InsertIntValue(StringValue.Length); - memoryList.InsertStringValue(StringValue, true, -1, encoding); + memoryList.InsertIntValue(TextBytes.Length); + memoryList.InsertBytes(TextBytes); } else { - - memoryList.InsertIntValue(memoryList.GetStringLenght(StringValue, encoding) / -2); - memoryList.InsertStringValue(StringValue, true, -1, encoding); + memoryList.InsertIntValue(TextBytes.Length/-2); + memoryList.InsertBytes(TextBytes); } } diff --git a/UE4localizationsTool/Core/StructProperty.cs b/UE4localizationsTool/Core/StructProperty.cs index fbf750f..a903487 100644 --- a/UE4localizationsTool/Core/StructProperty.cs +++ b/UE4localizationsTool/Core/StructProperty.cs @@ -84,6 +84,7 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, catch { uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); } ConsoleMode.Print("EndMapProperty", ConsoleColor.Blue); @@ -155,6 +156,7 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, catch { uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); } if (Modify) { @@ -271,6 +273,7 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, catch { uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); } } @@ -314,6 +317,7 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, int TextDataPosition = memoryList.GetPosition(); if (ContainText == 0xff) { + try { TextData = new MemoryList(memoryList.GetBytes(PropertyLength - 5)); @@ -326,7 +330,7 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, { if (!Modify) { - uexp.Strings.Add(new List() { PropertyName, TextData.GetStringUE() }); + uexp.Strings.Add(new List() { PropertyName+"_"+i, TextData.GetStringUE() }); } else @@ -341,7 +345,8 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, } catch { - + uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); } continue; } @@ -369,7 +374,8 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, } catch { - + uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); } } else if (Property == "ByteProperty") @@ -437,7 +443,8 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, } catch { - + uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); } } @@ -579,6 +586,7 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe catch { uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); } ConsoleMode.Print("EndMap", ConsoleColor.DarkBlue); } @@ -645,7 +653,11 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe PropertyParser(PropertyName, StructType, -1, StructData, uexp, Modify); } } - catch { uexp.IsGood = false; } + catch + { + uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); + } if (Modify) { @@ -682,21 +694,7 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe byte ContainText = memoryList.GetByteValue(); if (ContainText == 0xff) { - int TextLinesCount = memoryList.GetIntValue(); - for (int i = 0; i < TextLinesCount; i++) - { - if (!Modify) - { - uexp.Strings.Add(new List() { PropertyName, memoryList.GetStringUE() }); - - } - else - { - memoryList.ReplaceStringUE(uexp.Strings[uexp.CurrentIndex][1]); - uexp.CurrentIndex++; - } - } - return; + return; } if (!Modify) @@ -704,6 +702,9 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe uexp.Strings.Add(new List() { PropertyName + "_1", memoryList.GetStringUE() }); uexp.Strings.Add(new List() { PropertyName + "_2", memoryList.GetStringUE() }); uexp.Strings.Add(new List() { PropertyName + "_3", memoryList.GetStringUE() }); + ConsoleMode.Print(uexp.Strings[uexp.Strings.Count - 3][1], ConsoleColor.Magenta); + ConsoleMode.Print(uexp.Strings[uexp.Strings.Count - 2][1], ConsoleColor.Magenta); + ConsoleMode.Print(uexp.Strings[uexp.Strings.Count - 1][1], ConsoleColor.Magenta); } else { @@ -757,6 +758,7 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe catch { uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); } } } @@ -776,6 +778,7 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe catch { uexp.IsGood = false; + ConsoleMode.Print("Bug here.", ConsoleColor.Red); } memoryList.Skip(4); //ImplementationPtr Index ConsoleMode.Print("EndMovieSceneEvalTemplatePtr", ConsoleColor.Yellow); diff --git a/UE4localizationsTool/Core/Uexp.cs b/UE4localizationsTool/Core/Uexp.cs index 2e51b05..a504104 100644 --- a/UE4localizationsTool/Core/Uexp.cs +++ b/UE4localizationsTool/Core/Uexp.cs @@ -66,6 +66,9 @@ private void ReadOrEdit(bool Modify = false) _ = new Spreadsheet(memoryList, this, Modify); break; + case "Function": + // _ = new Function(memoryList, this, Modify); + break; } } catch diff --git a/UE4localizationsTool/Forms/FrmMain.cs b/UE4localizationsTool/Forms/FrmMain.cs index 7f157c5..ea1cc26 100644 --- a/UE4localizationsTool/Forms/FrmMain.cs +++ b/UE4localizationsTool/Forms/FrmMain.cs @@ -746,7 +746,7 @@ private void FrmMain_Load(object sender, EventArgs e) { try { - string UpdateScript = client.DownloadString("https://raw.githubusercontent.com/amrshaheen61/UE4LocalizationsTool/blob/master/UE4localizationsTool/UpdateInfo.txt"); + string UpdateScript = client.DownloadString("https://raw.githubusercontent.com/amrshaheen61/UE4LocalizationsTool/master/UE4localizationsTool/UpdateInfo.txt"); if (UpdateScript.StartsWith("UpdateFile", false, CultureInfo.InvariantCulture)) { diff --git a/UE4localizationsTool/Properties/AssemblyInfo.cs b/UE4localizationsTool/Properties/AssemblyInfo.cs index f05b610..cc4c9fb 100644 --- a/UE4localizationsTool/Properties/AssemblyInfo.cs +++ b/UE4localizationsTool/Properties/AssemblyInfo.cs @@ -32,4 +32,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0")] -[assembly: AssemblyFileVersion("1.5")] +[assembly: AssemblyFileVersion("1.6")] diff --git a/UE4localizationsTool/UE4localizationsTool.csproj b/UE4localizationsTool/UE4localizationsTool.csproj index 15a1e46..b8b2687 100644 --- a/UE4localizationsTool/UE4localizationsTool.csproj +++ b/UE4localizationsTool/UE4localizationsTool.csproj @@ -24,7 +24,7 @@ false false true - 5 + 7 1.0.0.%2a false true diff --git a/UE4localizationsTool/UpdateInfo.txt b/UE4localizationsTool/UpdateInfo.txt index cb7ab42..fbc60a1 100644 --- a/UE4localizationsTool/UpdateInfo.txt +++ b/UE4localizationsTool/UpdateInfo.txt @@ -1,3 +1,3 @@ UpdateFile -Tool_UpdateVer = 1.5 -Tool_UpdateSite = https://github.com/amrshaheen61/UE4LocalizationsTool/releases/tag/v1.5 \ No newline at end of file +Tool_UpdateVer = 1.6 +Tool_UpdateSite = https://github.com/amrshaheen61/UE4LocalizationsTool/releases/tag/v1.6 \ No newline at end of file