diff --git a/UE4localizationsTool/App.config b/UE4localizationsTool/App.config index 74a2987..136e35f 100644 --- a/UE4localizationsTool/App.config +++ b/UE4localizationsTool/App.config @@ -1,12 +1,12 @@ - -
+ +
- + diff --git a/UE4localizationsTool/Core/AssetHelper.cs b/UE4localizationsTool/Core/AssetHelper.cs index 4f794ab..a0d3684 100644 --- a/UE4localizationsTool/Core/AssetHelper.cs +++ b/UE4localizationsTool/Core/AssetHelper.cs @@ -123,22 +123,22 @@ public static string GetStringUES(this MemoryList memoryList, short namedata) return ReplaceBreaklines(Stringvalue).TrimEnd('\0'); } - public static string GetStringUE(this MemoryList memoryList, Encoding encoding) + public static string GetStringUE(this MemoryList memoryList, Encoding encoding, bool SavePosition = true, int SeekAndRead = -1) { - string Stringvalue = ReplaceBreaklines(memoryList.GetStringValueN(true, -1, encoding)); + string Stringvalue = ReplaceBreaklines(memoryList.GetStringValueN(SavePosition, SeekAndRead, encoding)); return Stringvalue.TrimEnd('\0'); } - public static void SetStringUE(this MemoryList memoryList, string str, Encoding encoding) + public static void SetStringUE(this MemoryList memoryList, string str, Encoding encoding, bool SavePosition = true, int SeekAndRead = -1) { - memoryList.SetStringValueN(ReplaceBreaklines(str, true), true, -1, encoding); + memoryList.SetStringValueN(ReplaceBreaklines(str, true), SavePosition, SeekAndRead, encoding); } - public static void SetStringUE(this MemoryList memoryList, string StringValue, bool UseUnicode = false) + public static void SetStringUE(this MemoryList memoryList, string StringValue, bool UseUnicode = false,bool IgnoreNull=true) { StringValue = ReplaceBreaklines(StringValue, true); - if (string.IsNullOrEmpty(StringValue)) + if (string.IsNullOrEmpty(StringValue)&&IgnoreNull) { memoryList.InsertIntValue(0); return; diff --git a/UE4localizationsTool/Core/Games/J5BinderAsset.cs b/UE4localizationsTool/Core/Games/J5BinderAsset.cs new file mode 100644 index 0000000..4f55cb5 --- /dev/null +++ b/UE4localizationsTool/Core/Games/J5BinderAsset.cs @@ -0,0 +1,271 @@ +using AssetParser; +using Helper.MemoryList; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace UE4localizationsTool.Core.Games +{ + + + /* + * Game:Jump Force + * File:systemtext_EN.uasset + */ + + public class J5BinderAsset + { + //public MemoryList MemoryList { get; } + public Uexp Uexp { get; } + public bool Modify { get; } + + MemoryList StreamMemory; + + public J5BinderAsset(MemoryList memoryList, Uexp uexp, bool Modify = false) + { + // MemoryList = memoryList; + Uexp = uexp; + this.Modify = Modify; + + memoryList.GetIntValue();//Null + var Baseposition = memoryList.GetPosition(); + var BufferSize = (int)memoryList.GetInt64Value(); + StreamMemory=new MemoryList(memoryList.GetBytes(BufferSize)); + load(); + + + if (Modify) + { + Build(); + memoryList.SetSize(Baseposition); + + memoryList.SetInt64Value(StreamMemory.MemoryListSize); + memoryList.SetBytes(StreamMemory.ToArray()); + } + + } + + + [StructLayout(LayoutKind.Sequential, Pack = 1)] + private class Header + { + public ulong Magic; + public int Type;//?? + public int TablesCount; + public int unk;//=48 + public int TableBlockSize; + public long unk2;//=0 + public long Baseoffset; + public long unk3;//=48 + } + + private class TableInfo + { + public int TableIndex; + public int Type;//=16 ?? + public long TableSize; + public long TableUSize; + public ulong TableHash; + public long TableNameoffset; + public long NextTableOffset; + public long TableOffset;//from +=Baseoffset + + public string TableName; + public STXTENLL Stxt; + + + public static TableInfo Read(MemoryList memoryList) + { + var tableInfo = new TableInfo(); + tableInfo.TableIndex = memoryList.GetIntValue(); + tableInfo.Type = memoryList.GetIntValue(); + tableInfo.TableSize= memoryList.GetInt64Value(); + tableInfo.TableUSize = memoryList.GetInt64Value(); + tableInfo.TableHash = memoryList.GetUInt64Value(); + tableInfo.TableNameoffset = memoryList.GetInt64Value(); + tableInfo.NextTableOffset = memoryList.GetInt64Value(); + tableInfo.TableOffset = memoryList.GetInt64Value(); + + tableInfo.TableName= memoryList.GetStringValueN(false,(int)tableInfo.TableNameoffset); + + return tableInfo; + } + + public void Write(MemoryList memoryList) + { + memoryList.SetIntValue(TableIndex); + memoryList.SetIntValue(Type); + memoryList.SetInt64Value(TableSize); + memoryList.SetInt64Value(TableUSize); + memoryList.SetUInt64Value(TableHash); + memoryList.SetInt64Value(TableNameoffset); + memoryList.SetInt64Value(NextTableOffset); + memoryList.SetInt64Value(TableOffset); + } + + } + + + public class STXTENLL + { + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public class Header + { + public ulong Magic; + public int Type;//?? + public int HeaderSize; + public int TableBufferSize; + public int TablesCount; + public ulong unko;//??=1200 + } + + public class TableInfo + { + public int Index; + public int StringOffset; + public string Value; + public static TableInfo Read(MemoryList memoryList) + { + var tableInfo = new TableInfo(); + tableInfo.Index = memoryList.GetIntValue(); + tableInfo.StringOffset = memoryList.GetIntValue(); + tableInfo.Value = memoryList.GetStringUE(SavePosition: false,SeekAndRead: tableInfo.StringOffset, encoding: Encoding.Unicode); + return tableInfo; + } + public void Write(MemoryList memoryList) + { + memoryList.SetIntValue(Index); + memoryList.SetIntValue(StringOffset); + } + } + + + public Header header; + public TableInfo[] tableInfos; + + public static STXTENLL Read(MemoryList memoryList) + { + var stxt = new STXTENLL(); + stxt.header = memoryList.GetStructureValues
(); + + if(stxt.header.Magic!= 0x4C4C4E4554585453) + { + throw new Exception("stxt.header.Magic!=0x4C4C4E4554585453"); + } + + stxt.tableInfos = new TableInfo[stxt.header.TablesCount]; + for (int i = 0; i < stxt.header.TablesCount; i++) + { + stxt.tableInfos[i] = TableInfo.Read(memoryList); + } + return stxt; + } + + public byte[] Build() + { + var memoryList = new MemoryList(); + memoryList.SetStructureValus(header); + + var Position = memoryList.GetPosition(); + memoryList.SetBytes(new byte[header.TableBufferSize*header.TablesCount]); + + foreach (var tableInfo in tableInfos) + { + tableInfo.StringOffset = memoryList.GetPosition(); + memoryList.SetStringUE(tableInfo.Value,encoding:Encoding.Unicode); + } + memoryList.Seek(Position); + + + foreach (var tableInfo in tableInfos) + { + tableInfo.Write(memoryList); + } + + return memoryList.ToArray(); + } + + + } + + + + Header header; + TableInfo[] tableInfos; + private void load() + { + header = StreamMemory.GetStructureValues
(); + + if(header.Magic != 0x4C4C46444E42) + { + throw new Exception("J5BinderAssetMagic!=0x4C4C46444E42"); + } + + tableInfos=new TableInfo[header.TablesCount]; + for (int i = 0; i < header.TablesCount; i++) + { + tableInfos[i] = TableInfo.Read(StreamMemory); + } + + for (int i = 0; i < header.TablesCount; i++) + { + StreamMemory.Seek((int)(header.Baseoffset + tableInfos[i].TableOffset)); + tableInfos[i].Stxt = STXTENLL.Read(new MemoryList(StreamMemory.GetBytes((int)tableInfos[i].TableSize))); + } + + + foreach(var tableInfo in tableInfos) + { + foreach(var stxt in tableInfo.Stxt.tableInfos) + { + Uexp.Strings.Add(new List() { tableInfo.TableName, stxt.Value }); + } + } + + + } + + + private void Build() + { + StreamMemory.Seek((int)(header.Baseoffset)); + StreamMemory.SetSize((int)(header.Baseoffset)); + + foreach (var tableInfo in tableInfos) + { + foreach (var stxt in tableInfo.Stxt.tableInfos) + { + stxt.Value = Uexp.Strings[Uexp.CurrentIndex++][1]; + } + } + + + foreach (var tableInfo in tableInfos) + { + var buffer= tableInfo.Stxt.Build(); + tableInfo.TableOffset = StreamMemory.GetPosition() - header.Baseoffset; + tableInfo.TableSize= buffer.Length; + tableInfo.TableUSize = buffer.Length; + StreamMemory.SetBytes(buffer); + } + + StreamMemory.Seek(0); + + StreamMemory.SetStructureValus(header); + + foreach (var tableInfo in tableInfos) + { + tableInfo.Write(StreamMemory); + } + + } + + + + + } +} diff --git a/UE4localizationsTool/Core/Uexp.cs b/UE4localizationsTool/Core/Uexp.cs index d4c9c74..391fb21 100644 --- a/UE4localizationsTool/Core/Uexp.cs +++ b/UE4localizationsTool/Core/Uexp.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.IO; using System.Windows.Forms; +using UE4localizationsTool.Core.Games; namespace AssetParser { @@ -166,8 +167,8 @@ private void ReadOrEdit(bool Modify = false) case "MuseStringTable": new MuseStringTable(memoryList, this, Modify); break; - case "SubtitlesText": - new MuseStringTable(memoryList, this, Modify); + case "J5BinderAsset": + new J5BinderAsset(memoryList, this, Modify); break; } ConsoleMode.Print($"-----------End------------", ConsoleColor.DarkRed); diff --git a/UE4localizationsTool/Core/locres/LocresNamespace.cs b/UE4localizationsTool/Core/locres/LocresNamespace.cs index cf63fbe..3a6c59e 100644 --- a/UE4localizationsTool/Core/locres/LocresNamespace.cs +++ b/UE4localizationsTool/Core/locres/LocresNamespace.cs @@ -10,9 +10,34 @@ namespace UE4localizationsTool.Core.locres { - public class NameSpaceTable : List + + public class HashTable { public uint NameHash { get; set; } + public uint KeyHash { get; set; } + public uint ValueHash { get; set; } + + public HashTable() + { + + } + public HashTable(uint NameHash, uint KeyHash=0, uint ValueHash=0) + { + this.NameHash = NameHash; + this.KeyHash = KeyHash; + this.ValueHash = ValueHash; + } + + public override string ToString() + { + return $"NameHash: {NameHash} KeyHash: {KeyHash} ValueHash: {ValueHash}"; + } + } + + + public class NameSpaceTable : List + { + public uint NameHash { get; set; } = 0; public string Name { get; set; } public NameSpaceTable(string TableName, uint NameHash = 0) { @@ -297,18 +322,40 @@ private void Save() foreach (var NameSpace in this) { - locresData.SetUIntValue(CalcHash(NameSpace.Name)); - - locresData.SetStringUE(NameSpace.Name); + + if (NameSpace.NameHash==0) + { + locresData.SetUIntValue(CalcHash(NameSpace.Name)); + } + else + { + locresData.SetUIntValue(NameSpace.NameHash); + } + + locresData.SetStringUE(NameSpace.Name,IgnoreNull: false); locresData.SetIntValue(NameSpace.Count); foreach (var Table in NameSpace) { - - locresData.SetUIntValue(CalcHash(Table.key)); + if(Table.keyHash==0) + { + locresData.SetUIntValue(CalcHash(Table.key)); + } + else + { + locresData.SetUIntValue(Table.keyHash); + } - locresData.SetStringUE(Table.key); - locresData.SetUIntValue(Table.Value.StrCrc32()); + locresData.SetStringUE(Table.key, IgnoreNull: false); + + if(Table.ValueHash == 0) + { + locresData.SetUIntValue(Table.Value.StrCrc32()); + } + else + { + locresData.SetUIntValue(Table.ValueHash); + } int stringTableIndex = stringTable.FindIndex(x => x.Text == Table.Value); @@ -339,7 +386,7 @@ private void Save() { foreach (var entry in stringTable) { - locresData.SetStringUE(entry.Text); + locresData.SetStringUE(entry.Text, IgnoreNull: false); locresData.SetIntValue(entry.refCount); } } @@ -347,7 +394,7 @@ private void Save() { foreach (var entry in stringTable) { - locresData.SetStringUE(entry.Text); + locresData.SetStringUE(entry.Text, IgnoreNull: false); } } @@ -370,13 +417,22 @@ private void buildLegacyFile() foreach (var names in this) { - locresData.SetStringUE(names.Name, true); + locresData.SetStringUE(names.Name, true, IgnoreNull: false); locresData.SetIntValue(names.Count); foreach (var table in names) { - locresData.SetStringUE(table.key, true); - locresData.SetUIntValue(table.Value.StrCrc32()); - locresData.SetStringUE(table.Value, true); + locresData.SetStringUE(table.key, true, IgnoreNull: false); + + if (table.ValueHash == 0) + { + locresData.SetUIntValue(table.Value.StrCrc32()); + } + else + { + locresData.SetUIntValue(table.ValueHash); + } + + locresData.SetStringUE(table.Value, true, IgnoreNull: false); } } @@ -425,6 +481,7 @@ public void AddItemsToDataGridView(DataGridView dataGrid) var dataTable = new System.Data.DataTable(); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Text value", typeof(string)); + dataTable.Columns.Add("Hash Table", typeof(HashTable)); foreach (var names in this) { @@ -432,12 +489,13 @@ public void AddItemsToDataGridView(DataGridView dataGrid) { string name = string.IsNullOrEmpty(names.Name) ? table.key : names.Name + "::" + table.key; string textValue = table.Value; - dataTable.Rows.Add(name, textValue); + dataTable.Rows.Add(name, textValue,new HashTable(names.NameHash,table.keyHash,table.ValueHash)); } } dataGrid.DataSource = dataTable; dataGrid.Columns["Text value"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + // dataGrid.Columns["Hash Table"].Visible = false; } public void LoadFromDataGridView(DataGridView dataGrid) @@ -463,8 +521,11 @@ public void LoadFromDataGridView(DataGridView dataGrid) KeyStr = items[0]; } - - AddString(NameSpaceStr, KeyStr, row.Cells["Text value"].Value.ToString()); + var HashTable= row.Cells["Hash Table"].Value as HashTable; + + + + AddString(NameSpaceStr, KeyStr, row.Cells["Text value"].Value.ToString(), HashTable.NameHash, HashTable.KeyHash, HashTable.ValueHash); } } diff --git a/UE4localizationsTool/Forms/FrmLocresEntryEditor.Designer.cs b/UE4localizationsTool/Forms/FrmLocresEntryEditor.Designer.cs index b4c22c6..1df74b1 100644 --- a/UE4localizationsTool/Forms/FrmLocresEntryEditor.Designer.cs +++ b/UE4localizationsTool/Forms/FrmLocresEntryEditor.Designer.cs @@ -38,14 +38,23 @@ private void InitializeComponent() this.txtKey = new UE4localizationsTool.Controls.NTextBox(); this.txtNameSpace = new UE4localizationsTool.Controls.NTextBox(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.txtNameSapceHash = new UE4localizationsTool.Controls.NTextBox(); + this.txtKeyHash = new UE4localizationsTool.Controls.NTextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.KeyHash = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.txtValueHash = new UE4localizationsTool.Controls.NTextBox(); + this.BtnNameSpace = new System.Windows.Forms.Button(); + this.BtnKey = new System.Windows.Forms.Button(); + this.BtnValue = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(12, 155); + this.label3.Location = new System.Drawing.Point(12, 148); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(34, 13); + this.label3.Size = new System.Drawing.Size(33, 13); this.label3.TabIndex = 8; this.label3.Text = "Value"; // @@ -63,7 +72,7 @@ private void InitializeComponent() this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(12, 17); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(66, 13); + this.label1.Size = new System.Drawing.Size(63, 13); this.label1.TabIndex = 6; this.label1.Text = "NameSpace"; // @@ -71,7 +80,7 @@ private void InitializeComponent() // this.button2.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button2.Location = new System.Drawing.Point(315, 297); + this.button2.Location = new System.Drawing.Point(315, 328); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 5; @@ -82,18 +91,19 @@ private void InitializeComponent() // this.Apply.Anchor = System.Windows.Forms.AnchorStyles.Bottom; this.Apply.DialogResult = System.Windows.Forms.DialogResult.OK; - this.Apply.Location = new System.Drawing.Point(210, 297); + this.Apply.Location = new System.Drawing.Point(210, 328); this.Apply.Name = "Apply"; this.Apply.Size = new System.Drawing.Size(75, 23); this.Apply.TabIndex = 4; this.Apply.Text = "Apply"; this.Apply.UseVisualStyleBackColor = true; + this.Apply.Click += new System.EventHandler(this.Apply_Click); // // txtValue // this.txtValue.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.txtValue.Location = new System.Drawing.Point(12, 171); + this.txtValue.Location = new System.Drawing.Point(12, 164); this.txtValue.Multiline = true; this.txtValue.Name = "txtValue"; this.txtValue.PlaceholderText = ""; @@ -110,7 +120,7 @@ private void InitializeComponent() this.txtKey.Multiline = true; this.txtKey.Name = "txtKey"; this.txtKey.PlaceholderText = ""; - this.txtKey.Size = new System.Drawing.Size(588, 36); + this.txtKey.Size = new System.Drawing.Size(409, 36); this.txtKey.StopEnterKey = true; this.txtKey.TabIndex = 1; this.txtKey.TextChanged += new System.EventHandler(this.txtKey_TextChanged); @@ -123,16 +133,121 @@ private void InitializeComponent() this.txtNameSpace.Multiline = true; this.txtNameSpace.Name = "txtNameSpace"; this.txtNameSpace.PlaceholderText = ""; - this.txtNameSpace.Size = new System.Drawing.Size(588, 34); + this.txtNameSpace.Size = new System.Drawing.Size(409, 34); this.txtNameSpace.StopEnterKey = true; this.txtNameSpace.TabIndex = 0; this.txtNameSpace.TextChanged += new System.EventHandler(this.txtNameSpace_TextChanged); // + // txtNameSapceHash + // + this.txtNameSapceHash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.txtNameSapceHash.Location = new System.Drawing.Point(427, 33); + this.txtNameSapceHash.Multiline = true; + this.txtNameSapceHash.Name = "txtNameSapceHash"; + this.txtNameSapceHash.PlaceholderText = ""; + this.txtNameSapceHash.Size = new System.Drawing.Size(145, 34); + this.txtNameSapceHash.StopEnterKey = true; + this.txtNameSapceHash.TabIndex = 9; + // + // txtKeyHash + // + this.txtKeyHash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.txtKeyHash.Location = new System.Drawing.Point(427, 95); + this.txtKeyHash.Multiline = true; + this.txtKeyHash.Name = "txtKeyHash"; + this.txtKeyHash.PlaceholderText = ""; + this.txtKeyHash.Size = new System.Drawing.Size(146, 36); + this.txtKeyHash.StopEnterKey = true; + this.txtKeyHash.TabIndex = 10; + // + // label4 + // + this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(427, 14); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(89, 13); + this.label4.TabIndex = 11; + this.label4.Text = "NameSapce hash"; + // + // KeyHash + // + this.KeyHash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.KeyHash.AutoSize = true; + this.KeyHash.Location = new System.Drawing.Point(427, 79); + this.KeyHash.Name = "KeyHash"; + this.KeyHash.Size = new System.Drawing.Size(51, 13); + this.KeyHash.TabIndex = 12; + this.KeyHash.Text = "Key hash"; + // + // label6 + // + this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(366, 277); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(59, 13); + this.label6.TabIndex = 14; + this.label6.Text = "Value hash"; + // + // txtValueHash + // + this.txtValueHash.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.txtValueHash.Location = new System.Drawing.Point(430, 267); + this.txtValueHash.Multiline = true; + this.txtValueHash.Name = "txtValueHash"; + this.txtValueHash.PlaceholderText = ""; + this.txtValueHash.Size = new System.Drawing.Size(143, 30); + this.txtValueHash.StopEnterKey = true; + this.txtValueHash.TabIndex = 13; + // + // BtnNameSpace + // + this.BtnNameSpace.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.BtnNameSpace.Location = new System.Drawing.Point(578, 33); + this.BtnNameSpace.Name = "BtnNameSpace"; + this.BtnNameSpace.Size = new System.Drawing.Size(24, 33); + this.BtnNameSpace.TabIndex = 15; + this.BtnNameSpace.Text = "C"; + this.BtnNameSpace.UseVisualStyleBackColor = true; + this.BtnNameSpace.Click += new System.EventHandler(this.BtnNameSpace_Click); + // + // BtnKey + // + this.BtnKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.BtnKey.Location = new System.Drawing.Point(579, 95); + this.BtnKey.Name = "BtnKey"; + this.BtnKey.Size = new System.Drawing.Size(24, 36); + this.BtnKey.TabIndex = 16; + this.BtnKey.Text = "C"; + this.BtnKey.UseVisualStyleBackColor = true; + this.BtnKey.Click += new System.EventHandler(this.BtnKey_Click); + // + // BtnValue + // + this.BtnValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.BtnValue.Location = new System.Drawing.Point(579, 267); + this.BtnValue.Name = "BtnValue"; + this.BtnValue.Size = new System.Drawing.Size(24, 30); + this.BtnValue.TabIndex = 17; + this.BtnValue.Text = "C"; + this.BtnValue.UseVisualStyleBackColor = true; + this.BtnValue.Click += new System.EventHandler(this.BtnValue_Click); + // // FrmLocresEntryEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(612, 339); + this.ClientSize = new System.Drawing.Size(612, 370); + this.Controls.Add(this.BtnValue); + this.Controls.Add(this.BtnKey); + this.Controls.Add(this.BtnNameSpace); + this.Controls.Add(this.label6); + this.Controls.Add(this.txtValueHash); + this.Controls.Add(this.KeyHash); + this.Controls.Add(this.label4); + this.Controls.Add(this.txtKeyHash); + this.Controls.Add(this.txtNameSapceHash); this.Controls.Add(this.label3); this.Controls.Add(this.label2); this.Controls.Add(this.label1); @@ -141,7 +256,6 @@ private void InitializeComponent() this.Controls.Add(this.txtValue); this.Controls.Add(this.txtKey); this.Controls.Add(this.txtNameSpace); - this.MaximumSize = new System.Drawing.Size(778, 378); this.MinimumSize = new System.Drawing.Size(519, 378); this.Name = "FrmLocresEntryEditor"; this.ShowIcon = false; @@ -163,5 +277,14 @@ private void InitializeComponent() private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.ToolTip toolTip1; + private Controls.NTextBox txtNameSapceHash; + private Controls.NTextBox txtKeyHash; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label KeyHash; + private System.Windows.Forms.Label label6; + private Controls.NTextBox txtValueHash; + private System.Windows.Forms.Button BtnNameSpace; + private System.Windows.Forms.Button BtnKey; + private System.Windows.Forms.Button BtnValue; } } \ No newline at end of file diff --git a/UE4localizationsTool/Forms/FrmLocresEntryEditor.cs b/UE4localizationsTool/Forms/FrmLocresEntryEditor.cs index 10f7d45..ffd761a 100644 --- a/UE4localizationsTool/Forms/FrmLocresEntryEditor.cs +++ b/UE4localizationsTool/Forms/FrmLocresEntryEditor.cs @@ -14,6 +14,20 @@ public partial class FrmLocresEntryEditor : NForm public string NameSpace { get; set; } public string Key { get; set; } public string Value { get; set; } + + public HashTable HashTable + { + get + { + return new HashTable() + { + NameHash = uint.Parse(txtNameSapceHash.Text), + KeyHash = uint.Parse(txtKeyHash.Text), + ValueHash = uint.Parse(txtValueHash.Text), + }; + } + } + public LocresFile asset { get; set; } public FrmLocresEntryEditor() @@ -44,6 +58,12 @@ public FrmLocresEntryEditor(NDataGridView gridView, LocresFile asset) Key = items[0]; Value = gridView.CurrentCell.OwningRow.Cells["Text value"].Value.ToString(); } + + var Hashs= gridView.CurrentCell.OwningRow.Cells["Hash Table"].Value as HashTable; + + txtNameSapceHash.Text = Hashs.NameHash.ToString(); + txtKeyHash.Text = Hashs.KeyHash.ToString(); + txtValueHash.Text = Hashs.ValueHash.ToString(); Print(); } @@ -82,7 +102,7 @@ public void AddRow(NDataGridView gridView) // throw new Exception("this NameSpace and Key already exists in the table."); //} - dt.Rows.Add(RowName, Value); + dt.Rows.Add(RowName, Value,HashTable); } @@ -100,6 +120,7 @@ public void EditRow(NDataGridView DGV) { DGV.SetValue(DGV.CurrentCell.OwningRow.Cells["Name"], GetName()); DGV.SetValue(DGV.CurrentCell.OwningRow.Cells["Text value"], txtValue.Text); + DGV.SetValue(DGV.CurrentCell.OwningRow.Cells["Hash Table"], HashTable); } private void txtNameSpace_TextChanged(object sender, EventArgs e) @@ -117,5 +138,34 @@ private void txtValue_TextChanged(object sender, EventArgs e) Value = AssetParser.AssetHelper.ReplaceBreaklines(txtValue.Text); } + private void BtnNameSpace_Click(object sender, EventArgs e) + { + txtNameSapceHash.Text = asset.CalcHash(txtNameSpace.Text).ToString(); + } + + private void BtnKey_Click(object sender, EventArgs e) + { + txtKeyHash.Text = asset.CalcHash(txtKey.Text).ToString(); + } + + private void BtnValue_Click(object sender, EventArgs e) + { + txtValueHash.Text=txtValue.Text.StrCrc32().ToString(); + } + + private void Apply_Click(object sender, EventArgs e) + { + if(string.IsNullOrEmpty(txtNameSapceHash.Text)|| string.IsNullOrEmpty(txtKeyHash.Text)|| string.IsNullOrEmpty(txtValueHash.Text)) + { + MessageBox.Show("NameSpace or Key or Value is empty"); + return; + } + + if(!uint.TryParse(txtNameSapceHash.Text,out uint temp)|| !uint.TryParse(txtKeyHash.Text, out uint temp1) || !uint.TryParse(txtValueHash.Text, out uint temp2)) + { + MessageBox.Show("NameSpace or Key or Value is not a number"); + return; + } + } } } diff --git a/UE4localizationsTool/Forms/FrmMain.cs b/UE4localizationsTool/Forms/FrmMain.cs index a52e401..33201d0 100644 --- a/UE4localizationsTool/Forms/FrmMain.cs +++ b/UE4localizationsTool/Forms/FrmMain.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using UE4localizationsTool.Controls; +using UE4localizationsTool.Core.Hash; using UE4localizationsTool.Core.locres; using UE4localizationsTool.Forms; using UE4localizationsTool.Helper; @@ -124,7 +125,7 @@ enum ExportType private void ExportAll(ExportType exportType) { - if (this.SortApply) SortDataGrid(2, true); + if (this.SortApply && !(Asset is LocresFile)) SortDataGrid(2, true); SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Text File|*.txt"; @@ -180,7 +181,7 @@ private void importAllTextToolStripMenuItem_Click(object sender, EventArgs e) if (ofd.ShowDialog() == DialogResult.OK) { - if (this.SortApply) SortDataGrid(2, true); + if (this.SortApply && !(Asset is LocresFile)) SortDataGrid(2, true); if (ofd.FileName.EndsWith(".csv", StringComparison.InvariantCulture)) { @@ -551,7 +552,7 @@ private void csvFileToolStripMenuItem_Click(object sender, EventArgs e) private void find_Click(object sender, EventArgs e) { searchBox.Show(); - + } private void filterToolStripMenuItem_Click(object sender, EventArgs e) @@ -674,7 +675,7 @@ private void mergeLocresFileToolStripMenuItem_Click(object sender, EventArgs e) { string name = string.IsNullOrEmpty(names.Name) ? table.key : names.Name + "::" + table.key; string textValue = table.Value; - dataTable.Rows.Add(name, textValue); + dataTable.Rows.Add(name, textValue, new HashTable(names.NameHash, table.keyHash, table.ValueHash)); } } } @@ -731,7 +732,10 @@ private void mergeUassetFileToolStripMenuItem_Click(object sender, EventArgs e) { foreach (var Strings in new Uexp(Uexp.GetUasset(fileName), true).StringNodes) { - dataTable.Rows.Add(Strings.GetName(), Strings.Value); + var locresasset = Asset as LocresFile; + var HashTable = new HashTable(locresasset.CalcHash(Strings.NameSpace), locresasset.CalcHash(Strings.Key), Strings.Value.StrCrc32()); + + dataTable.Rows.Add(Strings.GetName(), Strings.Value, HashTable); } } @@ -766,7 +770,7 @@ private void dataGridView1_CellValidated(object sender, DataGridViewCellEventArg private void dataGridView1_CellValuePushed(object sender, DataGridViewCellValueEventArgs e) { - + } private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) diff --git a/UE4localizationsTool/Helper/MemoryList.cs b/UE4localizationsTool/Helper/MemoryList.cs index eccc09a..50f2ed1 100644 --- a/UE4localizationsTool/Helper/MemoryList.cs +++ b/UE4localizationsTool/Helper/MemoryList.cs @@ -158,7 +158,15 @@ public void SetPosition(int Value) public void SetSize(int Value) { + if (MemoryListPosition> Value) + { + MemoryListPosition = Value; + } + + MemoryListSize = Value; + + } public void WriteFile(string FilePath) diff --git a/UE4localizationsTool/Properties/Settings.Designer.cs b/UE4localizationsTool/Properties/Settings.Designer.cs index 7098ea0..c26a767 100644 --- a/UE4localizationsTool/Properties/Settings.Designer.cs +++ b/UE4localizationsTool/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace UE4localizationsTool.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.7.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/UE4localizationsTool/Properties/app.manifest b/UE4localizationsTool/Properties/app.manifest index ef6918c..ef267b2 100644 --- a/UE4localizationsTool/Properties/app.manifest +++ b/UE4localizationsTool/Properties/app.manifest @@ -20,7 +20,7 @@ - + diff --git a/UE4localizationsTool/UE4localizationsTool.csproj b/UE4localizationsTool/UE4localizationsTool.csproj index 8601ae4..89b6776 100644 --- a/UE4localizationsTool/UE4localizationsTool.csproj +++ b/UE4localizationsTool/UE4localizationsTool.csproj @@ -5,10 +5,10 @@ Debug AnyCPU {C8AA2127-04A4-400B-9CA3-1951639BB0A3} - Exe + WinExe UE4localizationsTool UE4localizationsTool - v4.7.2 + v4.8 512 true @@ -69,7 +69,7 @@ UE4localizationsTool_TemporaryKey.pfx - true + false false @@ -108,6 +108,7 @@ + diff --git a/UE4localizationsTool/UE4localizationsTool.csproj.DotSettings b/UE4localizationsTool/UE4localizationsTool.csproj.DotSettings new file mode 100644 index 0000000..632c268 --- /dev/null +++ b/UE4localizationsTool/UE4localizationsTool.csproj.DotSettings @@ -0,0 +1,2 @@ + + CSharp120 \ No newline at end of file diff --git a/UE4localizationsTool/UpdateInfo.txt b/UE4localizationsTool/UpdateInfo.txt index fecdb8e..ccaa592 100644 --- a/UE4localizationsTool/UpdateInfo.txt +++ b/UE4localizationsTool/UpdateInfo.txt @@ -1,3 +1,3 @@ UpdateFile -Tool_UpdateVer = 2.3 -Tool_UpdateSite = https://github.com/amrshaheen61/UE4LocalizationsTool/releases/tag/v2.3 \ No newline at end of file +Tool_UpdateVer = 2.4 +Tool_UpdateSite = https://github.com/amrshaheen61/UE4LocalizationsTool/releases/tag/v2.4 \ No newline at end of file diff --git a/cso.dat b/cso.dat deleted file mode 100644 index 5ab5db0..0000000 --- a/cso.dat +++ /dev/null @@ -1,75 +0,0 @@ -V1 -2:Hash32Len13to24,q -2:s,R -2:len,o -2:a,qN -2:b,oJ -2:c,E -2:d,s -2:e,X -2:f,A -2:h,H -2:LocresNamespace,c -2:AddItemsToDataTable,l -2:dataGrid,lN -2:dataTable,b -2:names,p -2:table,a -2:locres,HK -2:LocresVersion,g -2:Legacy,gK -2:Compact,S -2:Optimized,e -2:Optimized_CityHash64_UTF16,D -2:MagicGUID,bJ -2:IsGood,u -2:get_u_,k -2:set_k_,P -2:Uexp,N -2:UassetData,sY -2:AssetParser,qX -2:s143077981,aW -2:t143077981,z -1:1,UE4localizationsTool,qX_,aW_,z_ -2:InitializeContextMenu,r -2:copyMenuItem,rH -2:pasteMenuItem,SJ -2:Redo,zK -2:data,A6 -2:temp,I -2:tempstyle,B -2:OnCellEndEdit,Q -2:PasteMenuItem_Click,P8 -2:sender,zU -2:str,rA -2:Filter,qL -2:filterForm,y -2:filteredData,PL -2:row,z9 -2:shouldShow,EW -2:OnRowPrePaint,cO -2:ShouldShowRow,w -2:filterValue,b6 -2:cellValue,T -2:AddItemsToDataGridView,h -2:i,cV -2:item,AU -2:rowIndex,XU -2:FindPrevious_Click,t -2:found,L -2:startColumn,h1 -2:colIndex,wW -2:cell,kI -2:InitializeComponent,sI -2:resources,P7 -2:OnRowsAdded,O -2:AddRow,t8 -2:gridView,zO -2:dt,f -2:RowName,IG -2:rowExists,v -2:.ctor,z4 -2:items,pM -2:OpenFile_Click,Q7 -2:ofd,m -2:mergeLocresFileToolStripMenuItem_Click,G