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

Commit

Permalink
Changes for v1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
amrshaheen61 committed Jun 27, 2022
1 parent 21e4395 commit 1290385
Show file tree
Hide file tree
Showing 14 changed files with 1,560 additions and 174 deletions.
49 changes: 41 additions & 8 deletions UE4localizationsTool/Commads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ public class Commads
{
private List<List<string>> Strings;
private bool usefilter = false;
private bool nonames = false;
private bool UseMatching = false;
private bool RegularExpression = false;
private bool ReverseMode = false;
private List<string> ArrayValues;
public Commads(string Options, string SourcePath, bool UseFilter = false)
public Commads(string Options, string SourcePath, bool UseFilter = false, bool NoNames = false)
{
usefilter = UseFilter;

nonames = NoNames;
if (usefilter)
{
GetFilterValues();
Expand Down Expand Up @@ -116,7 +117,14 @@ private void SaveTextFile(string FilePath)
}
else
{
stringsArray[i] = item[0] + "=" + item[1];
if (!nonames)
{
stringsArray[i] = item[0] + "=" + item[1];
}
else
{
stringsArray[i] = item[1];
}
}
i++;
}
Expand Down Expand Up @@ -238,12 +246,20 @@ void EditList(List<List<string>> Strings, string[] StringValues)
{
try
{
Strings[i][1] = StringValues[i].Split(new char[] { '=' }, 2)[1];
if (!nonames)
{
Strings[i][1] = StringValues[i].Split(new char[] { '=' }, 2)[1];
}
else
{
Strings[i][1] = StringValues[i];
}
}
catch
{
throw new Exception("Can't parse this line from text file: " + StringValues[i]);
}

}
}

Expand Down Expand Up @@ -518,10 +534,19 @@ private void ApplyFilter(List<List<string>> Strings, string[] Array)
{
if (!ReverseMode)
{

try
{
Strings[x][1] = Array[i].Split(new char[] { '=' }, 2)[1];
i++;
if (!nonames)
{
Strings[x][1] = Array[i].Split(new char[] { '=' }, 2)[1];
i++;
}
else
{
Strings[x][1] = Array[i];
i++;
}
}
catch
{
Expand All @@ -533,8 +558,16 @@ private void ApplyFilter(List<List<string>> Strings, string[] Array)
{
try
{
Strings[x][1] = Array[i].Split(new char[] { '=' }, 2)[1];
i++;
if (!nonames)
{
Strings[x][1] = Array[i].Split(new char[] { '=' }, 2)[1];
i++;
}
else
{
Strings[x][1] = Array[i];
i++;
}
}
catch
{
Expand Down
93 changes: 92 additions & 1 deletion UE4localizationsTool/Core/AssetHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Helper.MemoryList;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace AssetParser
Expand Down Expand Up @@ -59,7 +62,75 @@ public static string GetStringUE(this MemoryList memoryList)
return Stringvalue.TrimEnd('\0');
}

public static bool IsASCII(string StringValue)

public static string GetStringUE(this MemoryList memoryList,Encoding encoding)
{
string Stringvalue = memoryList.GetStringValueN(true,-1, encoding);
Stringvalue = Stringvalue.Replace("\r\n", "<cf>");
Stringvalue = Stringvalue.Replace("\r", "<cr>");
Stringvalue = Stringvalue.Replace("\n", "<lf>");
return Stringvalue.TrimEnd('\0');
}

public static string GetStringUE(this MemoryList memoryList,int Lenght, bool SavePosition = true, int SeekAndRead = -1, Encoding encoding = null)
{
string Stringvalue = memoryList.GetStringValue(Lenght, SavePosition, SeekAndRead, encoding);
Stringvalue = Stringvalue.Replace("\r\n", "<cf>");
Stringvalue = Stringvalue.Replace("\r", "<cr>");
Stringvalue = Stringvalue.Replace("\n", "<lf>");
return Stringvalue.TrimEnd('\0');
}


public static string ReplaceString(string Str)
{
Str = Str.Replace("<cf>", "\r\n");
Str = Str.Replace("<cr>", "\r");
return Str.Replace("<lf>", "\n");
}


public static void ReplaceStringUE_Func(this MemoryList memoryList, string StringValue)
{

StringValue = StringValue.Replace("<cf>", "\r\n");
StringValue = StringValue.Replace("<cr>", "\r");
StringValue = StringValue.Replace("<lf>", "\n");

memoryList.Skip(-1);
ExprToken eExpr = (ExprToken)memoryList.GetByteValue();
if (eExpr == ExprToken.EX_StringConst)
{
memoryList.DeleteStringN(-1, Encoding.ASCII);
}
else if (eExpr == ExprToken.EX_UnicodeStringConst)
{
memoryList.DeleteStringN(-1, Encoding.Unicode);
}
memoryList.Skip(-1);


Encoding encoding = Encoding.Unicode;
if (IsASCII(StringValue))
{
encoding = Encoding.ASCII;
}

if (encoding == Encoding.ASCII)
{
memoryList.SetByteValue((byte)ExprToken.EX_StringConst);
memoryList.InsertStringValueN(StringValue,true,-1, encoding);
}
else
{
memoryList.SetByteValue((byte)ExprToken.EX_UnicodeStringConst);
memoryList.InsertStringValueN(StringValue, true, -1, encoding);
}
}



public static bool IsASCII(string StringValue)
{
for (int n = 0; n < StringValue.Length; n++)
{
Expand Down Expand Up @@ -135,4 +206,24 @@ public static void ReplaceStringUE(this MemoryList memoryList, string StringValu
}

}


public class ReadStringProperty
{
public ReadStringProperty(MemoryList memoryList, Uexp uexp, string PropertyName, bool Modify = false)
{
if (!Modify)
{
uexp.Strings.Add(new List<string>() { PropertyName, memoryList.GetStringUE() });
ConsoleMode.Print(uexp.Strings[uexp.Strings.Count - 1][1], ConsoleColor.Magenta);
}
else
{
memoryList.ReplaceStringUE(uexp.Strings[uexp.CurrentIndex][1]);
uexp.CurrentIndex++;
}
}
}


}
116 changes: 116 additions & 0 deletions UE4localizationsTool/Core/Enum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,120 @@ public enum UE4Version
VER_UE4_26 = 519,
VER_UE4_27 = 522,
};

public enum ExprToken
{
EX_LocalVariable = 0x00,
EX_InstanceVariable = 0x01,
EX_DefaultVariable = 0x02,
EX_Return = 0x04,
EX_Jump = 0x06,
EX_JumpIfNot = 0x07,
EX_Assert = 0x09,
EX_Nothing = 0x0B,
EX_Let = 0x0F,
EX_ClassContext = 0x12,
EX_MetaCast = 0x13,
EX_LetBool = 0x14,
EX_EndParmValue = 0x15,
EX_EndFunctionParms = 0x16,
EX_Self = 0x17,
EX_Skip = 0x18,
EX_Context = 0x19,
EX_Context_FailSilent = 0x1A,
EX_VirtualFunction = 0x1B,
EX_FinalFunction = 0x1C,
EX_IntConst = 0x1D,
EX_FloatConst = 0x1E,
EX_StringConst = 0x1F,
EX_ObjectConst = 0x20,
EX_NameConst = 0x21,
EX_RotationConst = 0x22,
EX_VectorConst = 0x23,
EX_ByteConst = 0x24,
EX_IntZero = 0x25,
EX_IntOne = 0x26,
EX_True = 0x27,
EX_False = 0x28,
EX_TextConst = 0x29,
EX_NoObject = 0x2A,
EX_TransformConst = 0x2B,
EX_IntConstByte = 0x2C,
EX_NoInterface = 0x2D,
EX_DynamicCast = 0x2E,
EX_StructConst = 0x2F,
EX_EndStructConst = 0x30,
EX_SetArray = 0x31,
EX_EndArray = 0x32,
EX_PropertyConst = 0x33,
EX_UnicodeStringConst = 0x34,
EX_Int64Const = 0x35,
EX_UInt64Const = 0x36,
EX_PrimitiveCast = 0x38,
EX_SetSet = 0x39,
EX_EndSet = 0x3A,
EX_SetMap = 0x3B,
EX_EndMap = 0x3C,
EX_SetConst = 0x3D,
EX_EndSetConst = 0x3E,
EX_MapConst = 0x3F,
EX_EndMapConst = 0x40,
EX_StructMemberContext = 0x42,
EX_LetMulticastDelegate = 0x43,
EX_LetDelegate = 0x44,
EX_LocalVirtualFunction = 0x45,
EX_LocalFinalFunction = 0x46,
EX_LocalOutVariable = 0x48,
EX_DeprecatedOp4A = 0x4A,
EX_InstanceDelegate = 0x4B,
EX_PushExecutionFlow = 0x4C,
EX_PopExecutionFlow = 0x4D,
EX_ComputedJump = 0x4E,
EX_PopExecutionFlowIfNot = 0x4F,
EX_Breakpoint = 0x50,
EX_InterfaceContext = 0x51,
EX_ObjToInterfaceCast = 0x52,
EX_EndOfScript = 0x53,
EX_CrossInterfaceCast = 0x54,
EX_InterfaceToObjCast = 0x55,
EX_WireTracepoint = 0x5A,
EX_SkipOffsetConst = 0x5B,
EX_AddMulticastDelegate = 0x5C,
EX_ClearMulticastDelegate = 0x5D,
EX_Tracepoint = 0x5E,
EX_LetObj = 0x5F,
EX_LetWeakObjPtr = 0x60,
EX_BindDelegate = 0x61,
EX_RemoveMulticastDelegate = 0x62,
EX_CallMulticastDelegate = 0x63,
EX_LetValueOnPersistentFrame = 0x64,
EX_ArrayConst = 0x65,
EX_EndArrayConst = 0x66,
EX_SoftObjectConst = 0x67,
EX_CallMath = 0x68,
EX_SwitchValue = 0x69,
EX_InstrumentationEvent = 0x6A,
EX_ArrayGetByRef = 0x6B,
EX_ClassSparseDataVariable = 0x6C,
EX_FieldPathConst = 0x6D,
EX_Max = 0x100,
};
public enum TextHistoryType
{
None = -1,
Base = 0,
NamedFormat,
OrderedFormat,
ArgumentFormat,
AsNumber,
AsPercent,
AsCurrency,
AsDate,
AsTime,
AsDateTime,
Transform,
StringTableEntry,
TextGenerator
}

}
Loading

0 comments on commit 1290385

Please sign in to comment.