Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Changes for v2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
amrshaheen61 committed Oct 16, 2023
1 parent b33e2be commit 5fa142f
Show file tree
Hide file tree
Showing 15 changed files with 573 additions and 127 deletions.
6 changes: 3 additions & 3 deletions UE4localizationsTool/App.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="UE4localizationsTool.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="UE4localizationsTool.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<userSettings>
<UE4localizationsTool.Properties.Settings>
Expand Down
12 changes: 6 additions & 6 deletions UE4localizationsTool/Core/AssetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
271 changes: 271 additions & 0 deletions UE4localizationsTool/Core/Games/J5BinderAsset.cs
Original file line number Diff line number Diff line change
@@ -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<Header>();

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<Header>();

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<string>() { 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);
}

}




}
}
5 changes: 3 additions & 2 deletions UE4localizationsTool/Core/Uexp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using UE4localizationsTool.Core.Games;

namespace AssetParser
{
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 5fa142f

Please sign in to comment.