diff --git a/UE4localizationsTool/Core/ConsoleMode.cs b/UE4localizationsTool/Core/ConsoleMode.cs new file mode 100644 index 0000000..90b1fa1 --- /dev/null +++ b/UE4localizationsTool/Core/ConsoleMode.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AssetParser +{ + public static class ConsoleMode + { + + public static void Print(string Str,ConsoleColor color=ConsoleColor.White) + { + bool Show = false; + if (Show) + { + Console.ForegroundColor = color; + Console.WriteLine(Str); + Console.ForegroundColor = ConsoleColor.White; + } + } + } +} diff --git a/UE4localizationsTool/Core/DataTable.cs b/UE4localizationsTool/Core/DataTable.cs index 2f54601..887ac3c 100644 --- a/UE4localizationsTool/Core/DataTable.cs +++ b/UE4localizationsTool/Core/DataTable.cs @@ -12,7 +12,7 @@ public DataTable(MemoryList memoryList, Uexp uexp, bool Modify = false) for (int TableIndex = 0; TableIndex < TableCount; TableIndex++) { memoryList.Skip(8); //no neeed - _ = new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct, Modify); + _ = new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct,false, Modify); } } } diff --git a/UE4localizationsTool/Core/Spreadsheet.cs b/UE4localizationsTool/Core/Spreadsheet.cs index 6785b3a..b961d85 100644 --- a/UE4localizationsTool/Core/Spreadsheet.cs +++ b/UE4localizationsTool/Core/Spreadsheet.cs @@ -11,7 +11,7 @@ public Spreadsheet(MemoryList memoryList, Uexp uexp, bool Modify = false) for (int TableIndex = 0; TableIndex < TableCount; TableIndex++) { - _ = new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct, Modify); + _ = new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct,false, Modify); } } } diff --git a/UE4localizationsTool/Core/StructProperty.cs b/UE4localizationsTool/Core/StructProperty.cs index 2c7e40f..eabb977 100644 --- a/UE4localizationsTool/Core/StructProperty.cs +++ b/UE4localizationsTool/Core/StructProperty.cs @@ -7,21 +7,29 @@ namespace AssetParser public class StructProperty { - public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, bool Modify = false) + public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true,bool FromProperty = false, bool Modify = false) { while (memoryList.GetPosition() < memoryList.GetSize()) { - - long PropertyNameC = memoryList.GetInt64Value(); - //Console.WriteLine($"PropertyNameC- {PropertyNameC} > "+ memoryList.GetPosition()); - if (PropertyNameC > uexp.UassetData.Number_of_Names) + long GetPropertyName; + if (FromProperty) { - memoryList.Skip(-4); - continue; + GetPropertyName = memoryList.GetInt64Value(); + + ConsoleMode.Print($"PropertyNameMoving- {GetPropertyName} > " + memoryList.GetPosition(),ConsoleColor.DarkBlue); + if (GetPropertyName > uexp.UassetData.Number_of_Names) + { + memoryList.Skip(-4); + continue; + } + } + else + { + GetPropertyName = memoryList.GetIntValue(); + memoryList.Skip(4); } - - string PropertyName = uexp.UassetData.GetPropertyName((int)PropertyNameC); + string PropertyName = uexp.UassetData.GetPropertyName((int)GetPropertyName); if (PropertyName == "None") { break; @@ -33,11 +41,10 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, int PropertyLength = memoryList.GetIntValue(); memoryList.Skip(4);//null - //Console.ForegroundColor = //ConsoleColor.Green; - //Console.WriteLine($"PropertyName-> " + PropertyName); - //Console.WriteLine("Property-> " + Property); - //Console.WriteLine("PropertyLength-> " + PropertyLength); - //Console.ForegroundColor = //ConsoleColor.White; + ConsoleMode.Print("PropertyName-> " + PropertyName,ConsoleColor.Green); + ConsoleMode.Print("Property-> " + Property, ConsoleColor.Green); + ConsoleMode.Print("PropertyLength-> " + PropertyLength, ConsoleColor.Green); + if (Property == "MapProperty") { @@ -54,10 +61,10 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, MemoryList MapData = new MemoryList(memoryList.GetBytes(PropertyLength)); MapData.Skip(4);//null or something int MapCount = MapData.GetIntValue(); - //Console.WriteLine("MapCount-> " + MapCount); - //Console.ForegroundColor = //ConsoleColor.Blue; - //Console.WriteLine("MapProperty"); - //Console.ForegroundColor = //ConsoleColor.White; + + ConsoleMode.Print("MapCount-> " + MapCount,ConsoleColor.Blue); + ConsoleMode.Print("MapProperty " + MapCount,ConsoleColor.Blue); + try { for (int Mapindex = 0; Mapindex < MapCount; Mapindex++) @@ -66,9 +73,10 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, { MapData.Skip(4);//null or something } - //Console.WriteLine("Mapindex-> " + Mapindex); - //Console.WriteLine("MapKey-> " + MapKey); - //Console.WriteLine("MapValue-> " + MapValue); + + ConsoleMode.Print("Mapindex-> " + Mapindex, ConsoleColor.Blue); + ConsoleMode.Print("MapKey-> " + MapKey,ConsoleColor.Blue); + ConsoleMode.Print("MapValue-> " + MapValue, ConsoleColor.Blue); PropertyParser(PropertyName, MapKey, -1, MapData, uexp, Modify); PropertyParser(PropertyName, MapValue, -1, MapData, uexp, Modify); } @@ -77,9 +85,9 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, { uexp.IsGood = false; } - //Console.ForegroundColor = //ConsoleColor.Blue; - //Console.WriteLine("EndMapProperty"); - //Console.ForegroundColor = //ConsoleColor.White; + + ConsoleMode.Print("EndMapProperty",ConsoleColor.Blue); + if (Modify) { memoryList.ReplaceBytes(PropertyLength, MapData.ToArray(), false, MapDataPosition); @@ -89,12 +97,11 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, } else if (Property == "ArrayProperty") { - //Console.ForegroundColor = //ConsoleColor.Yellow; - //Console.WriteLine("ArrayProperty"); - //Console.ForegroundColor = //ConsoleColor.White; + + ConsoleMode.Print("ArrayProperty", ConsoleColor.Yellow); string ArrayType = uexp.UassetData.GetPropertyName(memoryList.GetIntValue()); memoryList.Skip(4);//null or something - //Console.WriteLine("ArrayType-> " + ArrayType); + ConsoleMode.Print("ArrayType-> " + ArrayType,ConsoleColor.Yellow); if (FromStruct) { memoryList.Skip(1); //null For "Struct" @@ -111,13 +118,13 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, if (ArrayType == "StructProperty") { string ArrayName /*?*/ = uexp.UassetData.GetPropertyName(ArrayData.GetIntValue()); - //Console.WriteLine("ArrayName-> " + ArrayName); + ConsoleMode.Print("ArrayName-> " + ArrayName, ConsoleColor.DarkYellow); ArrayData.Skip(12); //null bytes int StructpositionEdit = ArrayData.GetPosition(); int StructLength = ArrayData.GetIntValue(); ArrayData.Skip(4); //null or something string StructType = uexp.UassetData.GetPropertyName(ArrayData.GetIntValue()); - //Console.WriteLine("ArrayStructType-> " + StructType); + ConsoleMode.Print("ArrayStructType-> " + StructType, ConsoleColor.DarkYellow); ArrayData.Skip(20); //Unkown bytes if (FromStruct) { @@ -155,14 +162,13 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, memoryList.Seek(ArrayPosition + ArrayData.GetSize()); memoryList.SetIntValue(ArrayData.GetSize(), false, ThisPosition); } - //Console.ForegroundColor = //ConsoleColor.Yellow; - //Console.WriteLine("EndArrayProperty"); - //Console.ForegroundColor = //ConsoleColor.White; + + ConsoleMode.Print("EndArrayProperty" , ConsoleColor.Yellow); } else if (Property == "StructProperty") { string StructType = uexp.UassetData.GetPropertyName(memoryList.GetIntValue()); - //Console.WriteLine("StructType-> " + StructType); + ConsoleMode.Print("StructType-> " + StructType, ConsoleColor.Gray); memoryList.Skip(4); //null or something memoryList.Skip(16); //null bytes if (FromStruct) @@ -260,7 +266,7 @@ public StructProperty(MemoryList memoryList, Uexp uexp, bool FromStruct = true, { try { - new StructProperty(StructData, uexp, true, Modify); + new StructProperty(StructData, uexp, true,false, Modify); } catch { @@ -540,10 +546,10 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe memoryList.Skip(4);//null or something memoryList.Skip(4);//null or something int MapCount = memoryList.GetIntValue(); - //Console.WriteLine("MapCount-> " + MapCount); - //Console.ForegroundColor = //ConsoleColor.Blue; - //Console.WriteLine("MapProperty2"); - //Console.ForegroundColor = //ConsoleColor.White; + + ConsoleMode.Print("MapCount-> " + MapCount, ConsoleColor.DarkBlue); + ConsoleMode.Print("StartMap", ConsoleColor.DarkBlue); + try { for (int Mapindex = 0; Mapindex < MapCount; Mapindex++) @@ -552,9 +558,9 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe { memoryList.Skip(4);//null or something } - //Console.WriteLine("Mapindex2-> " + Mapindex); - //Console.WriteLine("MapKey2-> " + MapKey); - //Console.WriteLine("MapValue2-> " + MapValue); + ConsoleMode.Print("Mapindex2-> " + Mapindex, ConsoleColor.DarkBlue); + ConsoleMode.Print("MapKey2-> " + MapKey, ConsoleColor.DarkBlue); + ConsoleMode.Print("MapValue2-> " + MapValue, ConsoleColor.DarkBlue); PropertyParser(PropertyName, MapKey, -1, memoryList, uexp, Modify); PropertyParser(PropertyName, MapValue, -1, memoryList, uexp, Modify); @@ -564,9 +570,7 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe { uexp.IsGood = false; } - //Console.ForegroundColor = //ConsoleColor.Blue; - //Console.WriteLine("EndMapProperty2"); - //Console.ForegroundColor = //ConsoleColor.White; + ConsoleMode.Print("EndMap", ConsoleColor.DarkBlue); } else if (Property == "FieldPathProperty") { @@ -654,7 +658,7 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe if (!Modify) { uexp.Strings.Add(new List() { PropertyName, memoryList.GetStringUE() }); - // Console.WriteLine(uexp.Strings[uexp.Strings.Count - 1][1]); + ConsoleMode.Print(uexp.Strings[uexp.Strings.Count - 1][1], ConsoleColor.Magenta); } else { @@ -704,15 +708,9 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe } else if (Property == "StructProperty") { - //Console.ForegroundColor = //ConsoleColor.Yellow; - //Console.WriteLine("StructProperty->" + memoryList.GetPosition()); - //Console.ForegroundColor = //ConsoleColor.White; - - new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct, Modify); - - //Console.ForegroundColor = //ConsoleColor.Yellow; - //Console.WriteLine("EndStructProperty->" + memoryList.GetPosition()); - //Console.ForegroundColor = //ConsoleColor.White; + ConsoleMode.Print("Struct->" + memoryList.GetPosition(), ConsoleColor.DarkCyan); + new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct,true, Modify); + ConsoleMode.Print("EndStruct->" + memoryList.GetPosition(), ConsoleColor.DarkCyan); } else if (Property == "SetProperty") { @@ -742,9 +740,9 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe try { - //Console.WriteLine("MovieSceneEvalTemplatePtr--> StructProperty"); - new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct, Modify); - //Console.WriteLine("MovieSceneEvalTemplatePtr--> EndStructProperty"); + ConsoleMode.Print("MovieSceneEvalTemplatePtr--> StructProperty", ConsoleColor.Red); + new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct,true, Modify); + ConsoleMode.Print("MovieSceneEvalTemplatePtr--> EndStructProperty", ConsoleColor.Red); } catch { @@ -753,35 +751,31 @@ private void PropertyParser(string PropertyName, string Property, int PropertyLe } } else if (Property == "MovieSceneTrackImplementationPtr") - { - //Console.ReadLine(); - //Console.WriteLine("StartMovieSceneEvalTemplatePtrLength->"+PropertyLength); + { + ConsoleMode.Print("StartMovieSceneEvalTemplatePtrLength->" + PropertyLength); if (memoryList.GetStringUE().Length > 0|| PropertyLength>0) { - //Console.WriteLine("StartMovieSceneEvalTemplatePtr"); + ConsoleMode.Print("StartMovieSceneEvalTemplatePtr", ConsoleColor.Yellow); try { - //Console.ForegroundColor = //ConsoleColor.DarkYellow; - //Console.WriteLine("MovieSceneEvalTemplatePtr--> StructProperty"); - new StructProperty(memoryList, uexp, true, Modify); - //Console.WriteLine("MovieSceneEvalTemplatePtr--> EndStructProperty"); - //Console.ForegroundColor = //ConsoleColor.White; + + ConsoleMode.Print("MovieSceneTrackImplementationPtr--> StructProperty", ConsoleColor.DarkYellow); + new StructProperty(memoryList, uexp, true,true, Modify); + ConsoleMode.Print("MovieSceneTrackImplementationPtr--> EndStructProperty", ConsoleColor.DarkYellow); } catch { uexp.IsGood = false; } memoryList.Skip(4); //ImplementationPtr Index - //Console.ForegroundColor = //ConsoleColor.DarkYellow; - //Console.WriteLine("EndStartMovieSceneEvalTemplatePtr"); - //Console.ForegroundColor = //ConsoleColor.White; + ConsoleMode.Print("EndMovieSceneEvalTemplatePtr", ConsoleColor.Yellow); } } else { - new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct, Modify); + new StructProperty(memoryList, uexp, uexp.UassetData.UseFromStruct,true, Modify); } } diff --git a/UE4localizationsTool/Core/Uexp.cs b/UE4localizationsTool/Core/Uexp.cs index a980daf..2f84d3d 100644 --- a/UE4localizationsTool/Core/Uexp.cs +++ b/UE4localizationsTool/Core/Uexp.cs @@ -50,14 +50,9 @@ private void ReadOrEdit(bool Modify = false) memoryList.Seek(0); //Seek to beginning of Block - //no need for now - Console.ForegroundColor = ConsoleColor.Red; - // Console.WriteLine($"-----------{n}------------"); - Console.ForegroundColor = ConsoleColor.White; - _ = new StructProperty(memoryList, this, UassetData.UseFromStruct, Modify); - Console.ForegroundColor = ConsoleColor.Red; - // Console.WriteLine($"-----------End------------"); - Console.ForegroundColor = ConsoleColor.White; + ConsoleMode.Print($"-----------{n}------------", ConsoleColor.Red); + _ = new StructProperty(memoryList, this, UassetData.UseFromStruct,false, Modify); + ConsoleMode.Print($"-----------End------------", ConsoleColor.Red); switch (UassetData.GetExportPropertyName(UassetData.Exports_Directory[n].ExportClass)) { diff --git a/UE4localizationsTool/FrmMain.Designer.cs b/UE4localizationsTool/FrmMain.Designer.cs index 7d5f9dc..8d6d6f6 100644 --- a/UE4localizationsTool/FrmMain.Designer.cs +++ b/UE4localizationsTool/FrmMain.Designer.cs @@ -41,7 +41,7 @@ private void InitializeComponent() this.exportAllTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.importAllTextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.search = new System.Windows.Forms.ToolStripMenuItem(); + this.find = new System.Windows.Forms.ToolStripMenuItem(); this.filterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.byNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.byValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -132,7 +132,7 @@ private void InitializeComponent() this.exportAllTextToolStripMenuItem, this.importAllTextToolStripMenuItem, this.toolStripSeparator1, - this.search, + this.find, this.filterToolStripMenuItem, this.toolStripSeparator2, this.undoToolStripMenuItem, @@ -167,13 +167,13 @@ private void InitializeComponent() this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(210, 6); // - // search + // find // - this.search.Name = "search"; - this.search.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F))); - this.search.Size = new System.Drawing.Size(213, 22); - this.search.Text = "Search"; - this.search.Click += new System.EventHandler(this.search_Click); + this.find.Name = "find"; + this.find.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F))); + this.find.Size = new System.Drawing.Size(213, 22); + this.find.Text = "Find"; + this.find.Click += new System.EventHandler(this.search_Click); // // filterToolStripMenuItem // @@ -189,7 +189,7 @@ private void InitializeComponent() // this.byNameToolStripMenuItem.Name = "byNameToolStripMenuItem"; this.byNameToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Q))); - this.byNameToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.byNameToolStripMenuItem.Size = new System.Drawing.Size(170, 22); this.byNameToolStripMenuItem.Text = "By Name"; this.byNameToolStripMenuItem.Click += new System.EventHandler(this.byNameToolStripMenuItem_Click); // @@ -197,7 +197,7 @@ private void InitializeComponent() // this.byValueToolStripMenuItem.Name = "byValueToolStripMenuItem"; this.byValueToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.W))); - this.byValueToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.byValueToolStripMenuItem.Size = new System.Drawing.Size(170, 22); this.byValueToolStripMenuItem.Text = "By Value"; this.byValueToolStripMenuItem.Click += new System.EventHandler(this.byValueToolStripMenuItem_Click); // @@ -205,7 +205,7 @@ private void InitializeComponent() // this.clearFilterToolStripMenuItem.Name = "clearFilterToolStripMenuItem"; this.clearFilterToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.D))); - this.clearFilterToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.clearFilterToolStripMenuItem.Size = new System.Drawing.Size(170, 22); this.clearFilterToolStripMenuItem.Text = "Clear filter"; this.clearFilterToolStripMenuItem.Click += new System.EventHandler(this.clearFilterToolStripMenuItem_Click); // @@ -280,14 +280,14 @@ private void InitializeComponent() // commandLinesToolStripMenuItem // this.commandLinesToolStripMenuItem.Name = "commandLinesToolStripMenuItem"; - this.commandLinesToolStripMenuItem.Size = new System.Drawing.Size(161, 22); + this.commandLinesToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.commandLinesToolStripMenuItem.Text = "Command Lines"; this.commandLinesToolStripMenuItem.Click += new System.EventHandler(this.commandLinesToolStripMenuItem_Click); // // aboutToolStripMenuItem1 // this.aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1"; - this.aboutToolStripMenuItem1.Size = new System.Drawing.Size(161, 22); + this.aboutToolStripMenuItem1.Size = new System.Drawing.Size(180, 22); this.aboutToolStripMenuItem1.Text = "About"; this.aboutToolStripMenuItem1.Click += new System.EventHandler(this.aboutToolStripMenuItem1_Click); // @@ -319,12 +319,11 @@ private void InitializeComponent() this.dataGridView1.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellValueChanged); this.dataGridView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.dataGridView1_KeyDown); this.dataGridView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dataGridView1_MouseDown); - // // TextName // this.TextName.HeaderText = "Name"; - this.TextName.MaxInputLength =int.MaxValue; + this.TextName.MaxInputLength = 2147483647; this.TextName.Name = "TextName"; this.TextName.ReadOnly = true; this.TextName.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; @@ -333,9 +332,9 @@ private void InitializeComponent() // this.TextValue.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.TextValue.HeaderText = "Text Value"; + this.TextValue.MaxInputLength = 2147483647; this.TextValue.Name = "TextValue"; this.TextValue.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.TextValue.MaxInputLength = int.MaxValue; // // Index // @@ -407,9 +406,9 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(7, 9); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(70, 13); + this.label1.Size = new System.Drawing.Size(56, 13); this.label1.TabIndex = 1; - this.label1.Text = "Search what:"; + this.label1.Text = "Find what:"; // // InputSearch // @@ -457,9 +456,9 @@ private void InitializeComponent() // this.DataCount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.DataCount.BackColor = System.Drawing.SystemColors.Window; - this.DataCount.Location = new System.Drawing.Point(460, 9); + this.DataCount.Location = new System.Drawing.Point(487, 9); this.DataCount.Name = "DataCount"; - this.DataCount.Size = new System.Drawing.Size(226, 15); + this.DataCount.Size = new System.Drawing.Size(200, 15); this.DataCount.TabIndex = 5; this.DataCount.Text = "------"; this.DataCount.TextAlign = System.Drawing.ContentAlignment.TopRight; @@ -480,6 +479,7 @@ private void InitializeComponent() this.MinimumSize = new System.Drawing.Size(705, 489); this.Name = "FrmMain"; this.Text = "UE4 localizations Tool"; + this.Load += new System.EventHandler(this.FrmMain_Load); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); @@ -503,7 +503,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem search; + private System.Windows.Forms.ToolStripMenuItem find; private System.Windows.Forms.Panel SearchPanal; private System.Windows.Forms.Label SearchHide; private System.Windows.Forms.Button FindPrevious; diff --git a/UE4localizationsTool/FrmMain.cs b/UE4localizationsTool/FrmMain.cs index b6e0f54..111a1b6 100644 --- a/UE4localizationsTool/FrmMain.cs +++ b/UE4localizationsTool/FrmMain.cs @@ -1,8 +1,12 @@ using AssetParser; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Drawing; +using System.Globalization; using System.IO; +using System.Linq; +using System.Net; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; @@ -25,8 +29,8 @@ struct DataRow FrmState state; Stack BackupDataUndo; Stack BackupDataRedo; - int BackupDataIndex = 0; List> ListrefValues; + bool Filter; public FrmMain() { @@ -44,6 +48,8 @@ public FrmMain() this.dataGridView1.RowsAdded += (x, y) => this.UpdateCounter(); this.dataGridView1.RowsRemoved += (x, y) => this.UpdateCounter(); this.DataCount.Text = ""; + this.Filter= false; + this.clearFilterToolStripMenuItem.Enabled = false; } private void AddToDataView() @@ -90,6 +96,8 @@ private async void LoadFile(string filePath) this.Text = ToolName; this.BackupDataUndo = new Stack(); this.BackupDataRedo = new Stack(); + this.Filter = false; + this.clearFilterToolStripMenuItem.Enabled = false; try { state = new FrmState(this, "loading File", "loading File please wait..."); @@ -138,7 +146,7 @@ private void exportAllTextToolStripMenuItem_Click(object sender, EventArgs e) string[] DataGridStrings = new string[dataGridView1.Rows.Count]; for (int i = 0; i < dataGridView1.Rows.Count; i++) { - DataGridStrings[i] = dataGridView1.Rows[i].Cells[1].Value.ToString(); + DataGridStrings[i] = ObjectToString(dataGridView1.Rows[i].Cells[1].Value); } SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Text File|*.txt"; @@ -241,6 +249,7 @@ private async void SaveFile(object sender, EventArgs e) private void SearchHide_Click(object sender, EventArgs e) { SearchPanal.Visible = false; + dataGridView1.Height += SearchPanal.Height; } private void search_Click(object sender, EventArgs e) @@ -248,9 +257,16 @@ private void search_Click(object sender, EventArgs e) SearchPanal.Visible = !SearchPanal.Visible; if (SearchPanal.Visible) { + dataGridView1.Height -= SearchPanal.Height; InputSearch.Focus(); InputSearch.SelectAll(); } + else + { + dataGridView1.Height += SearchPanal.Height; + } + + } List FindArray = new List(); @@ -262,7 +278,7 @@ private void Find_Click(object sender, EventArgs e) OldFind = InputSearch.Text; for (int i = 0; i < dataGridView1.Rows.Count; i++) { - if (dataGridView1.Rows[i].Cells[1].Value.ToString().ToLower().Contains(InputSearch.Text.ToLower())) + if (ObjectToString(dataGridView1.Rows[i].Cells[1].Value).ToLower().Contains(InputSearch.Text.ToLower())) { FindArray.Add(i); } @@ -351,7 +367,7 @@ private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { BackupDataRedo.Clear(); } - BackupDataUndo.Push(new DataRow() { Index = dataGridView1.SelectedCells[0].RowIndex, StringValue = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[1].Value != null ? dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[1].Value.ToString() : "" }); + BackupDataUndo.Push(new DataRow() { Index = dataGridView1.SelectedCells[0].RowIndex, StringValue = ObjectToString(dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[1].Value)}); dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells[1].Value = Clipboard.GetText(); } } @@ -391,7 +407,7 @@ private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEvent { if (dataGridView1.Created) { - ListrefValues[int.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString())][1] = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); + ListrefValues[int.Parse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString())][1] = ObjectToString(dataGridView1.Rows[e.RowIndex].Cells[1].Value); dataGridView1.Rows[e.RowIndex].Cells[1].Style.BackColor = System.Drawing.Color.FromArgb(255, 204, 153); } } @@ -453,7 +469,7 @@ private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEv { BackupDataRedo.Clear(); } - BackupDataUndo.Push(new DataRow() { Index = e.RowIndex, StringValue = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString()}); + BackupDataUndo.Push(new DataRow() { Index = e.RowIndex, StringValue = ObjectToString(dataGridView1.Rows[e.RowIndex].Cells[1].Value)}); } private void undoToolStripMenuItem_Click(object sender, EventArgs e) @@ -463,7 +479,7 @@ private void undoToolStripMenuItem_Click(object sender, EventArgs e) { DataRow dataRow = BackupDataUndo.Pop(); - BackupDataRedo.Push(new DataRow() { Index = dataRow.Index, StringValue = dataGridView1.Rows[dataRow.Index].Cells[1].Value != null ? dataGridView1.Rows[dataRow.Index].Cells[1].Value.ToString() : "" }); + BackupDataRedo.Push(new DataRow() { Index = dataRow.Index, StringValue = ObjectToString(dataGridView1.Rows[dataRow.Index].Cells[1].Value)}); //MessageBox.Show(dataRow.StringValue); dataGridView1.Rows[dataRow.Index].Cells[1].Value = dataRow.StringValue; @@ -487,7 +503,7 @@ private void redoToolStripMenuItem_Click(object sender, EventArgs e) //MessageBox.Show(BackupDataRedo.Peek().StringValue); DataRow dataRow = BackupDataRedo.Pop(); - BackupDataUndo.Push(new DataRow() { Index = dataRow.Index, StringValue = dataGridView1.Rows[dataRow.Index].Cells[1].Value != null ? dataGridView1.Rows[dataRow.Index].Cells[1].Value.ToString() : "" }); + BackupDataUndo.Push(new DataRow() { Index = dataRow.Index, StringValue = ObjectToString(dataGridView1.Rows[dataRow.Index].Cells[1].Value) }); dataGridView1.Rows[dataRow.Index].Cells[1].Value = dataRow.StringValue; if (dataRow.StringValue == ListrefValues[dataRow.Index][1]) dataGridView1.Rows[dataRow.Index].Cells[1].Style.BackColor = System.Drawing.Color.FromArgb(255, 255, 255); @@ -512,7 +528,7 @@ private void aboutToolStripMenuItem1_Click(object sender, EventArgs e) } - + private void byNameToolStripMenuItem_Click(object sender, EventArgs e) { @@ -526,8 +542,9 @@ private void byNameToolStripMenuItem_Click(object sender, EventArgs e) if (frmFilter.ShowDialog() == DialogResult.OK) - { - + { + Filter = true; + clearFilterToolStripMenuItem.Enabled = true; dataGridView1.Rows.Clear(); for (int x = 0; x < ListrefValues.Count; x++) { @@ -584,11 +601,7 @@ private void byNameToolStripMenuItem_Click(object sender, EventArgs e) } } - private void clearFilterToolStripMenuItem_Click(object sender, EventArgs e) - { - dataGridView1.Rows.Clear(); - AddToDataView(); - } + private void byValueToolStripMenuItem_Click(object sender, EventArgs e) { @@ -600,6 +613,8 @@ private void byValueToolStripMenuItem_Click(object sender, EventArgs e) frmFilter.Text = "Filter by value"; if (frmFilter.ShowDialog() == DialogResult.OK) { + Filter = true; + clearFilterToolStripMenuItem.Enabled = true; dataGridView1.Rows.Clear(); for (int x = 0; x < ListrefValues.Count; x++) @@ -657,6 +672,17 @@ private void byValueToolStripMenuItem_Click(object sender, EventArgs e) } } + private void clearFilterToolStripMenuItem_Click(object sender, EventArgs e) + { + if (Filter) + { + dataGridView1.Rows.Clear(); + AddToDataView(); + Filter = false; + clearFilterToolStripMenuItem.Enabled = false; + } + } + private void UpdateCounter() { DataCount.Text = "Text count: " + dataGridView1.Rows.Count; @@ -666,5 +692,67 @@ private void label2_Click(object sender, EventArgs e) { } + + private string ObjectToString(object Value) + { + if(!(Value is null)) + { + return Value.ToString(); + } + return ""; + } + + private void FrmMain_Load(object sender, EventArgs e) + { + + float ToolVer = 0; + string ToolSite = ""; + + using (WebClient client = new WebClient()) + { + try + { + string UpdateScript = client.DownloadString("https://raw.githubusercontent.com/amrshaheen61/UE4LocalizationsTool/UpdateInfo.txt"); + + if (UpdateScript.StartsWith("UpdateFile",false,CultureInfo.InvariantCulture)) + { + var lines = Regex.Split(UpdateScript, "\r\n|\r|\n"); + foreach (string Line in lines) + { + + if (Line.StartsWith("Tool_UpdateVer", false, CultureInfo.InvariantCulture)) + { + ToolVer = float.Parse(Line.Split(new char[] { '=' }, 2)[1].Trim()); + } + if (Line.StartsWith("Tool_UpdateSite", false, CultureInfo.InvariantCulture)) + { + ToolSite = Line.Split(new char[] { '=' }, 2)[1].Trim(); + } + } + + if (ToolVer > float.Parse(Application.ProductVersion)) + { + + DialogResult message = MessageBox.Show("There is an update available\nDo you want to download it?", "Update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + + if (message == DialogResult.Yes) + { + Process.Start(new ProcessStartInfo { FileName = ToolSite, UseShellExecute = true }); + Application.Exit(); + } + + + } + } + + } + catch + { + //n + } + + + } + } } } diff --git a/UE4localizationsTool/Properties/AssemblyInfo.cs b/UE4localizationsTool/Properties/AssemblyInfo.cs index 9bcfe5e..3cf115a 100644 --- a/UE4localizationsTool/Properties/AssemblyInfo.cs +++ b/UE4localizationsTool/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ [assembly: AssemblyDescription("Simple to to edit engine texts")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Arabic Subtitles")] -[assembly: AssemblyProduct("UE4 localizations Tool")] +[assembly: AssemblyProduct("UE4 localizations Tool Beta")] [assembly: AssemblyCopyright("Copyright © 2022 - By Amr Shaheen")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,4 +32,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0")] -[assembly: AssemblyFileVersion("1.2")] +[assembly: AssemblyFileVersion("1.3")] diff --git a/UE4localizationsTool/UE4localizationsTool.csproj b/UE4localizationsTool/UE4localizationsTool.csproj index 4402895..7efcdf3 100644 --- a/UE4localizationsTool/UE4localizationsTool.csproj +++ b/UE4localizationsTool/UE4localizationsTool.csproj @@ -5,7 +5,7 @@ Debug AnyCPU {C8AA2127-04A4-400B-9CA3-1951639BB0A3} - Exe + WinExe UE4localizationsTool UE4localizationsTool v4.7.2 @@ -24,7 +24,7 @@ false false true - 4 + 5 1.0.0.%2a false true @@ -89,6 +89,7 @@ + @@ -172,6 +173,7 @@ + diff --git a/UE4localizationsTool/UpdateInfo.txt b/UE4localizationsTool/UpdateInfo.txt new file mode 100644 index 0000000..141f83a --- /dev/null +++ b/UE4localizationsTool/UpdateInfo.txt @@ -0,0 +1,3 @@ +UpdateFile +Tool_UpdateVer = 1.3 +Tool_UpdateSite = https://github.com/amrshaheen61/UE4LocalizationsTool \ No newline at end of file