added more FTexts

This commit is contained in:
iAmAsval 2020-09-04 15:12:28 +02:00
parent 5b8bfa6be6
commit 60c2d70153
10 changed files with 239 additions and 36 deletions

View File

@ -7,9 +7,7 @@ using FModel.Creator.Texts;
using FModel.ViewModels.ImageBox;
using PakReader.Parsers.Class;
using PakReader.Parsers.Objects;
using PakReader.Parsers.PropertyTagData;
using SkiaSharp;
using System.Diagnostics;
using System.IO;
namespace FModel.Creator
@ -244,20 +242,20 @@ namespace FModel.Creator
}
return true;
}
case "StreamedVideoDataAsset":
{
if (Globals.Game.ActualGame == EGame.Valorant && exports[index].GetExport<StructProperty>("Uuid") is StructProperty s && s.Value is FGuid uuid)
{
Process.Start(new ProcessStartInfo
{
FileName = string.Format(
"http://valorant.dyn.riotcdn.net/x/videos/release-01.05/{0}_default_universal.mp4",
$"{uuid.A:x8}-{uuid.B >> 16:x4}-{uuid.B & 0xFFFF:x4}-{uuid.C >> 16:x4}-{uuid.C & 0xFFFF:x4}{uuid.D:x8}"),
UseShellExecute = true
});
}
return false;
}
//case "StreamedVideoDataAsset": // must find a way to automatically gets the right version in the url
// {
// if (Globals.Game.ActualGame == EGame.Valorant && exports[index].GetExport<StructProperty>("Uuid") is StructProperty s && s.Value is FGuid uuid)
// {
// Process.Start(new ProcessStartInfo
// {
// FileName = string.Format(
// "http://valorant.dyn.riotcdn.net/x/videos/release-01.05/{0}_default_universal.mp4",
// $"{uuid.A:x8}-{uuid.B >> 16:x4}-{uuid.B & 0xFFFF:x4}-{uuid.C >> 16:x4}-{uuid.C & 0xFFFF:x4}{uuid.D:x8}"),
// UseShellExecute = true
// });
// }
// return false;
// }
}
return false;
}

View File

@ -0,0 +1,10 @@
namespace PakReader.Parsers.Objects
{
public enum ETextGender : byte
{
Masculine,
Feminine,
Neuter,
// Add new enum types at the end only! They are serialized by index.
}
}

View File

@ -2,21 +2,21 @@
{
public enum ETextHistoryType : sbyte
{
None = -1,
Base = 0,
NamedFormat,
OrderedFormat,
ArgumentFormat,
AsNumber,
AsPercent,
AsCurrency,
AsDate,
AsTime,
AsDateTime,
Transform,
StringTableEntry,
TextGenerator,
None = -1,
Base = 0,
NamedFormat,
OrderedFormat,
ArgumentFormat,
AsNumber,
AsPercent,
AsCurrency,
AsDate,
AsTime,
AsDateTime,
Transform,
StringTableEntry,
TextGenerator,
// Add new enum types at the end only! They are serialized by index.
}
// Add new enum types at the end only! They are serialized by index.
}
}

View File

@ -0,0 +1,11 @@

namespace PakReader.Parsers.Objects
{
public enum ETransformType : byte
{
ToLower = 0,
ToUpper,
// Add new enum types at the end only! They are serialized by index.
}
}

View File

@ -0,0 +1,35 @@
using System.Collections.Generic;
namespace PakReader.Parsers.Objects
{
public readonly struct FFormatArgumentData : IUStruct
{
public readonly string ArgumentName;
public readonly EFormatArgumentType ArgumentValueType;
public readonly object ArgumentValue;
public FFormatArgumentData(PackageReader reader)
{
ArgumentName = reader.ReadFString();
ArgumentValueType = (EFormatArgumentType)reader.ReadByte();
ArgumentValue = ArgumentValueType switch
{
EFormatArgumentType.Int => reader.ReadInt32(),
EFormatArgumentType.Float => reader.ReadFloat(),
EFormatArgumentType.Text => new FText(reader),
EFormatArgumentType.Gender => (ETextGender)reader.ReadByte(),
_ => null,
};
}
public Dictionary<string, object> GetValue()
{
return new Dictionary<string, object>
{
["ArgumentName"] = ArgumentName,
["ArgumentValueType"] = ArgumentValueType,
["ArgumentValue"] = ArgumentValue
};
}
}
}

View File

@ -23,6 +23,8 @@ namespace PakReader.Parsers.Objects
var HistoryType = (ETextHistoryType)reader.ReadSByte();
// Create the history class based on the serialized type
// https://github.com/EpicGames/UnrealEngine/blob/283e412aa843210f2d6e9ed0236861cf749b3429/Engine/Source/Runtime/Core/Private/Internationalization/TextHistory.h
// https://github.com/EpicGames/UnrealEngine/blob/bf95c2cbc703123e08ab54e3ceccdd47e48d224a/Engine/Source/Runtime/Core/Private/Internationalization/TextHistory.cpp
switch (HistoryType)
{
case ETextHistoryType.Base:
@ -31,8 +33,6 @@ namespace PakReader.Parsers.Objects
case ETextHistoryType.AsDateTime:
Text = new FTextHistory.DateTime(reader);
break;
// https://github.com/EpicGames/UnrealEngine/blob/bf95c2cbc703123e08ab54e3ceccdd47e48d224a/Engine/Source/Runtime/Core/Private/Internationalization/TextHistory.cpp
// https://github.com/EpicGames/UnrealEngine/blob/bf95c2cbc703123e08ab54e3ceccdd47e48d224a/Engine/Source/Runtime/Core/Private/Internationalization/TextData.h
case ETextHistoryType.NamedFormat:
case ETextHistoryType.OrderedFormat:
Text = new FTextHistory.OrderedFormat(reader);
@ -45,10 +45,18 @@ namespace PakReader.Parsers.Objects
case ETextHistoryType.StringTableEntry:
Text = new FTextHistory.StringTableEntry(reader);
break;
case ETextHistoryType.ArgumentFormat:
case ETextHistoryType.AsDate:
case ETextHistoryType.AsTime:
Text = new FTextHistory.AsTime(reader);
break;
case ETextHistoryType.AsDate:
Text = new FTextHistory.AsDate(reader);
break;
case ETextHistoryType.ArgumentFormat:
Text = new FTextHistory.ArgumentDataFormat(reader);
break;
case ETextHistoryType.Transform:
Text = new FTextHistory.Transform(reader);
break;
case ETextHistoryType.TextGenerator:
throw new NotImplementedException(string.Format(FModel.Properties.Resources.ParsingNotSupported, HistoryType));
default:
@ -65,6 +73,10 @@ namespace PakReader.Parsers.Objects
FTextHistory.OrderedFormat orderedFormat => orderedFormat.GetValue(),
FTextHistory.FormatNumber formatNumber => formatNumber.GetValue(),
FTextHistory.StringTableEntry stringTableEntry => stringTableEntry.GetValue(),
FTextHistory.AsTime asTime => asTime.GetValue(),
FTextHistory.AsDate asDate => asDate.GetValue(),
FTextHistory.ArgumentDataFormat argumentDataFormat => argumentDataFormat.GetValue(),
FTextHistory.Transform transform => transform.GetValue(),
FTextHistory.None none => none.CultureInvariantString,
_ => Text
};

View File

@ -0,0 +1,36 @@
using System.Collections.Generic;
namespace PakReader.Parsers.Objects
{
public partial class FTextHistory
{
public sealed class ArgumentDataFormat : FTextHistory
{
public readonly FText FormatText;
public readonly FFormatArgumentData[] Arguments;
internal ArgumentDataFormat(PackageReader reader)
{
FormatText = new FText(reader);
Arguments = reader.ReadTArray(() => new FFormatArgumentData(reader));
}
public Dictionary<string, object> GetValue()
{
var ret = new object[Arguments.Length];
for (int i = 0; i < ret.Length; i++)
{
ret[i] = Arguments[i] switch
{
_ => Arguments[i].GetValue(),
};
}
return new Dictionary<string, object>
{
["FormatText"] = FormatText.GetValue(),
["Arguments"] = ret
};
}
}
}
}

View File

@ -0,0 +1,37 @@
using System.Collections.Generic;
namespace PakReader.Parsers.Objects
{
public partial class FTextHistory
{
public sealed class AsDate : FTextHistory
{
public readonly FDateTime SourceDateTime;
public readonly EDateTimeStyle DateStyle;
public readonly EDateTimeStyle TimeStyle;
public readonly string TimeZone;
public readonly string CultureName;
internal AsDate(PackageReader reader)
{
SourceDateTime = new FDateTime(reader);
DateStyle = (EDateTimeStyle)reader.ReadByte();
TimeStyle = (EDateTimeStyle)reader.ReadByte();
TimeZone = reader.ReadFString();
CultureName = reader.ReadFString();
}
public Dictionary<string, object> GetValue()
{
return new Dictionary<string, object>
{
["SourceDateTime"] = SourceDateTime.Ticks,
["DateStyle"] = DateStyle,
["TimeStyle"] = TimeStyle,
["TimeZone"] = TimeZone,
["CultureName"] = CultureName,
};
}
}
}
}

View File

@ -0,0 +1,34 @@
using System.Collections.Generic;
namespace PakReader.Parsers.Objects
{
public partial class FTextHistory
{
public sealed class AsTime : FTextHistory
{
public readonly FDateTime SourceDateTime;
public readonly EDateTimeStyle TimeStyle;
public readonly string TimeZone;
public readonly string CultureName;
internal AsTime(PackageReader reader)
{
SourceDateTime = new FDateTime(reader);
TimeStyle = (EDateTimeStyle)reader.ReadByte();
TimeZone = reader.ReadFString();
CultureName = reader.ReadFString();
}
public Dictionary<string, object> GetValue()
{
return new Dictionary<string, object>
{
["SourceDateTime"] = SourceDateTime.Ticks,
["TimeStyle"] = TimeStyle,
["TimeZone"] = TimeZone,
["CultureName"] = CultureName,
};
}
}
}
}

View File

@ -0,0 +1,30 @@
using System.Collections.Generic;
namespace PakReader.Parsers.Objects
{
public partial class FTextHistory
{
public sealed class Transform : FTextHistory
{
/** The source text instance that was transformed */
public readonly FText SourceText;
/** How the source text was transformed */
public readonly ETransformType TransformType;
internal Transform(PackageReader reader)
{
SourceText = new FText(reader);
TransformType = (ETransformType)reader.ReadByte();
}
public Dictionary<string, object> GetValue()
{
return new Dictionary<string, object>
{
["SourceText"] = SourceText.GetValue(),
["TransformType"] = TransformType
};
}
}
}
}