mirror of
https://github.com/4sval/FModel.git
synced 2026-03-31 14:15:47 -05:00
Improvements
This commit is contained in:
parent
89c8cbaccc
commit
a8a5207dec
|
|
@ -17,7 +17,7 @@ namespace FModel.Extensions;
|
|||
|
||||
public static class KismetExtensions
|
||||
{
|
||||
public static string GetPrefix(string type, string extra = "")
|
||||
public static string GetPrefix(string type, string extra = "") // todo: implement better handling
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
|
|
@ -79,14 +79,18 @@ public static class KismetExtensions
|
|||
}
|
||||
public static string GetPropertyType(FProperty? property)
|
||||
{
|
||||
if (property is null)
|
||||
return "None";
|
||||
if (property is null) return "None";
|
||||
|
||||
bool isPointer(FProperty p) =>
|
||||
p.PropertyFlags.HasFlag(EPropertyFlags.InstancedReference) ||
|
||||
property.PropertyFlags.HasFlag(EPropertyFlags.ReferenceParm) ||
|
||||
p.PropertyFlags.HasFlag(EPropertyFlags.ContainsInstancedReference);
|
||||
|
||||
return property switch
|
||||
{
|
||||
FSetProperty set => $"TSet<{GetPrefix(set.ElementProp.GetType().Name)}{GetPropertyType(set.ElementProp)}{(set.PropertyFlags.HasFlag(EPropertyFlags.InstancedReference) || property.PropertyFlags.HasFlag(EPropertyFlags.ReferenceParm) || set.PropertyFlags.HasFlag(EPropertyFlags.ContainsInstancedReference) ? "*" : string.Empty)}>",
|
||||
FMapProperty map => $"TMap<{GetPrefix(map.ValueProp.GetType().Name)}{GetPropertyType(map.KeyProp)}, {GetPrefix(map.ValueProp.GetType().Name)}{GetPropertyType(map.ValueProp)}{(map.PropertyFlags.HasFlag(EPropertyFlags.InstancedReference) || property.PropertyFlags.HasFlag(EPropertyFlags.ReferenceParm) || map.PropertyFlags.HasFlag(EPropertyFlags.ContainsInstancedReference) ? "*" : string.Empty)}>",
|
||||
FArrayProperty array => $"TArray<{GetPrefix(array.Inner.GetType().Name)}{GetPropertyType(array.Inner)}{(array.PropertyFlags.HasFlag(EPropertyFlags.InstancedReference) || property.PropertyFlags.HasFlag(EPropertyFlags.ReferenceParm) || array.PropertyFlags.HasFlag(EPropertyFlags.ContainsInstancedReference) || GetPropertyProperty(array.Inner.GetType().Name) ? "*" : string.Empty)}>",
|
||||
FSetProperty s => $"TSet<{GetPrefix(s.ElementProp.GetType().Name)}{GetPropertyType(s.ElementProp)}{(isPointer(s) ? "*" : "")}>",
|
||||
FMapProperty m => $"TMap<{GetPrefix(m.KeyProp.GetType().Name)}{GetPropertyType(m.KeyProp)}, {GetPrefix(m.ValueProp.GetType().Name)}{GetPropertyType(m.ValueProp)}{(isPointer(m) ? "*" : "")}>",
|
||||
FArrayProperty a => $"TArray<{GetPrefix(a.Inner.GetType().Name)}{GetPropertyType(a.Inner)}{(isPointer(a) || GetPropertyProperty(a.Inner.GetType().Name) ? "*" : "")}>",
|
||||
_ => GetPropertyType((object)property)
|
||||
};
|
||||
}
|
||||
|
|
@ -224,14 +228,7 @@ public static class KismetExtensions
|
|||
var destination = ProcessTextProperty(op.DestinationProperty, false);
|
||||
var variable = ProcessTextProperty(opp.Variable, false);
|
||||
|
||||
if (!isParameter)
|
||||
{
|
||||
outputBuilder.Append($"\t\t{(destination.Contains("K2Node_") ? $"UberGraphFrame->{destination}" : destination)} = {variable};\n\n"); // hardcoded but works
|
||||
}
|
||||
else
|
||||
{
|
||||
outputBuilder.Append($"\t\t{(destination.Contains("K2Node_") ? $"UberGraphFrame->{destination}" : destination)} = {variable}");
|
||||
}
|
||||
outputBuilder.Append($"\t\t{(destination.Contains("K2Node_") ? "UberGraphFrame->" + destination : destination)} = {variable}{(!isParameter ? ";\n\n" : "")}"); // Hardcoded but works
|
||||
break;
|
||||
}
|
||||
case EExprToken.EX_LocalFinalFunction:
|
||||
|
|
@ -366,7 +363,7 @@ public static class KismetExtensions
|
|||
}
|
||||
case EExprToken.EX_Cast:
|
||||
{
|
||||
EX_Cast op = (EX_Cast) expression;// support CST_ObjectToInterface when I have an example of how it works
|
||||
EX_Cast op = (EX_Cast) expression; // support CST_ObjectToInterface when I have an example of how it works
|
||||
|
||||
if (op.ConversionType is ECastToken.CST_ObjectToBool or ECastToken.CST_InterfaceToBool)
|
||||
{
|
||||
|
|
@ -474,7 +471,7 @@ public static class KismetExtensions
|
|||
{
|
||||
var element = op.Elements[i];
|
||||
outputBuilder.Append(' ');
|
||||
ProcessExpression(element.Token, element, outputBuilder, jumpCodeOffsets);// sometimes the start of an array is a byte not a variable
|
||||
ProcessExpression(element.Token, element, outputBuilder, jumpCodeOffsets); // sometimes the start of an array is a byte not a variable
|
||||
|
||||
if (i < op.Elements.Length - 1)
|
||||
{
|
||||
|
|
@ -499,7 +496,7 @@ public static class KismetExtensions
|
|||
{
|
||||
var element = op.Elements[i];
|
||||
outputBuilder.Append(' ');
|
||||
ProcessExpression(element.Token, element, outputBuilder, jumpCodeOffsets, true);// sometimes the start of an array is a byte not a variable
|
||||
ProcessExpression(element.Token, element, outputBuilder, jumpCodeOffsets, true); // sometimes the start of an array is a byte not a variable
|
||||
|
||||
if (i < op.Elements.Length - 1)
|
||||
{
|
||||
|
|
@ -624,7 +621,7 @@ public static class KismetExtensions
|
|||
case EExprToken.EX_ObjectConst:
|
||||
{
|
||||
EX_ObjectConst op = (EX_ObjectConst) expression;
|
||||
outputBuilder.Append(!isParameter ? "\t\tFindObject<" : outputBuilder.ToString().EndsWith('\n') ? "\t\tFindObject<" : "FindObject<"); // please don't complain, i know this is bad but i MUST do it.
|
||||
outputBuilder.Append(!isParameter ? "\t\tFindObject<" : outputBuilder.ToString().EndsWith('\n') ? "\t\tFindObject<" : "FindObject<"); // please don't complain, I know this is bad but I MUST do it.
|
||||
string classString = op.Value.ResolvedObject?.Class?.ToString().Replace("'", "");
|
||||
|
||||
if (classString?.Contains('.') == true)
|
||||
|
|
@ -638,8 +635,8 @@ public static class KismetExtensions
|
|||
}
|
||||
outputBuilder.Append(">(\"");
|
||||
var resolvedObject = op?.Value?.ResolvedObject;
|
||||
var outerString = resolvedObject?.Outer?.ToString()?.Replace("'", "") ?? "UNKNOWN";
|
||||
var outerClassString = resolvedObject?.Class?.ToString()?.Replace("'", "") ?? "UNKNOWN";
|
||||
var outerString = resolvedObject?.Outer?.ToString()?.Replace("'", "") ?? "outerUnknown";
|
||||
var outerClassString = resolvedObject?.Class?.ToString()?.Replace("'", "") ?? "outerClassUnknown";
|
||||
var name = op?.Value?.Name ?? string.Empty;
|
||||
|
||||
outputBuilder.Append(outerString.Replace(outerClassString, "") + "." + name);
|
||||
|
|
@ -866,7 +863,7 @@ public static class KismetExtensions
|
|||
}
|
||||
else
|
||||
{
|
||||
outputBuilder.Append(op.Value);
|
||||
outputBuilder.Append(op.Value); // impossible to reach?
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -1024,6 +1021,7 @@ public static class KismetExtensions
|
|||
// some here are "useful" and unsupported
|
||||
break;
|
||||
/*
|
||||
Todo: check what uses these, fortnite has none instances
|
||||
EExprToken.EX_Assert
|
||||
EExprToken.EX_Skip
|
||||
EExprToken.EX_InstrumentationEvent
|
||||
|
|
|
|||
|
|
@ -1,240 +1,147 @@
|
|||
<SyntaxDefinition name="C++" extensions=".c;.h;.cc;.cpp;.hpp" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
|
||||
<Color name="String" foreground="#FFCB6B" />
|
||||
<Color name="Punctuation" foreground="#FF89DDFF" />
|
||||
<Color name="MethodName" foreground="#FFDCDCAA" fontWeight="bold" />
|
||||
<SyntaxDefinition name="C++" extensions=".cpp;.h;.hpp;.c" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
|
||||
<Color name="Comment" foreground="#84c36b" />
|
||||
<Color name="Keyword" foreground="#82AAFF" fontWeight="bold" />
|
||||
<Color name="Type" foreground="#4cc9b0" />
|
||||
<Color name="String" foreground="#ECC48D" />
|
||||
<Color name="Preprocessor" foreground="#82AAFF" fontWeight="bold" />
|
||||
<Color name="Number" foreground="#F78C6C" />
|
||||
<Color name="Function" foreground="#C3E88D" />
|
||||
<Color name="AccessModifier" foreground="#f20f5c" fontWeight="bold" />
|
||||
<Color name="UEMacro" foreground="#82AAFF" fontWeight="bold" />
|
||||
<Color name="LabelColor" foreground="#808080" />
|
||||
<Color name="JumpKeywords" foreground="#dda0dd" />
|
||||
<Color name="CompoundKeywords" foreground="#FF569CD6" fontWeight="bold" />
|
||||
<Color name="This" foreground="#FF569CD6" fontWeight="bold" />
|
||||
<Color name="Operators" foreground="#FFB467CA" fontWeight="bold" />
|
||||
<Color name="Namespace" foreground="#FF9CDCFE" fontWeight="bold" />
|
||||
<Color name="Friend" foreground="#FFD16969" />
|
||||
<Color name="Modifiers" foreground="#f20f5c" fontWeight="bold" />
|
||||
<Color name="TypeKeywords" foreground="#FF4EC9B0" />
|
||||
<Color name="BooleanConstants" foreground="#FF569CD6" fontWeight="bold" />
|
||||
<Color name="Keywords" foreground="#FF569CD6" fontWeight="bold" />
|
||||
<Color name="LoopKeywords" foreground="#FF569CD6" fontWeight="bold" />
|
||||
<Color name="JumpKeywords" foreground="#FFF47C3C" />
|
||||
<Color name="ExceptionHandling" foreground="#FFB467CA" fontWeight="bold" />
|
||||
<Color name="ControlFlow" foreground="#FF569CD6" fontWeight="bold" />
|
||||
<Color name="ClassName" foreground="#FFFFCC66" fontWeight="bold" />
|
||||
<Color name="Type" foreground="#4ec9b0" />
|
||||
<Color name="Function" foreground="#FF99FF99" fontWeight="bold" />
|
||||
<Color name="Variable" foreground="#FFCC99FF" />
|
||||
<Color name="Label" foreground="#FFAAAAAA" fontStyle="italic" />
|
||||
<Color name="Keyword" foreground="#FFFF8888" fontWeight="bold" />
|
||||
<Color name="Pointer" foreground="#ff8888" fontWeight="bold"/>
|
||||
<Color name="StaticClass" foreground="#c2a8ff" />
|
||||
<Color name="Brace" foreground="#89DDFF" />
|
||||
<Color name="Number" foreground="#FFFFAA66" />
|
||||
<Color name="Identifier" foreground="#FF61AFEF" />
|
||||
<Color name="This" foreground="#FF569CD6" fontWeight="bold" />
|
||||
<Color name="BooleanConstants" foreground="#569cd6" fontWeight="bold" />
|
||||
|
||||
<RuleSet ignoreCase="false">
|
||||
<Keywords color="Type">
|
||||
<Word>BlueprintGeneratedClass</Word>
|
||||
<Word>Class</Word>
|
||||
<Word>FSoftObjectPath</Word>
|
||||
<Word>UScriptArray</Word>
|
||||
<Word>NavmeshGeneratorComponent</Word>
|
||||
<Word>EndGameComponent</Word>
|
||||
<Word>USceneComponent</Word>
|
||||
<Span color="String" begin=""" end=""" />
|
||||
<!-- UE Macros -->
|
||||
<Keywords color="UEMacro">
|
||||
<Word>UCLASS</Word>
|
||||
<Word>USTRUCT</Word>
|
||||
<Word>UPROPERTY</Word>
|
||||
<Word>UFUNCTION</Word>
|
||||
<Word>GENERATED_BODY</Word>
|
||||
<Word>GENERATED_USTRUCT_BODY</Word>
|
||||
<Word>GENERATED_UCLASS_BODY</Word>
|
||||
</Keywords>
|
||||
|
||||
<Keywords color="TypeKeywords">
|
||||
<Word>bool</Word>
|
||||
<Word>char</Word>
|
||||
<Word>unsigned</Word>
|
||||
<Word>union</Word>
|
||||
<Word>virtual</Word>
|
||||
<Word>double</Word>
|
||||
<Word>float</Word>
|
||||
<Word>short</Word>
|
||||
<Word>signed</Word>
|
||||
<Word>void</Word>
|
||||
<Word>class</Word>
|
||||
<Word>enum</Word>
|
||||
<Word>struct</Word>
|
||||
</Keywords>
|
||||
|
||||
<Rule color="Type">\b(BlueprintGeneratedClass|Class|FSoftObjectPath|UScriptArray|NavmeshGeneratorComponent|EndGameComponent|USceneComponent)\b</Rule>
|
||||
|
||||
<Rule color="ClassName">ABP_[A-Za-z0-9_]+_C</Rule>
|
||||
|
||||
<Rule color="Type">\bF[A-Z][A-Za-z0-9_]*\b</Rule>
|
||||
<Rule color="Type">\bU[A-Z][A-Za-z0-9_]*\b</Rule>
|
||||
<Rule color="Type">\bA[A-Z][A-Za-z0-9_]*\b</Rule>
|
||||
<Rule color="Type">\bE[A-Z][A-Za-z0-9_]*\b</Rule>
|
||||
|
||||
<Rule color="Label">Label_[0-9]+</Rule>
|
||||
|
||||
<Rule color="Variable">CallFunc_[A-Za-z0-9_]+</Rule>
|
||||
<Rule color="Identifier">K2Node_[A-Za-z0-9_]+</Rule>
|
||||
<Rule color="Identifier">Temp_delegate_Variable(_[0-9]+)?</Rule>
|
||||
|
||||
<Rule color="MethodName">ExecuteUbergraph_[A-Za-z0-9_]+</Rule>
|
||||
<Rule color="MethodName">UserConstructionScript</Rule>
|
||||
<Rule color="MethodName">ReceiveBeginPlay</Rule>
|
||||
<Rule color="MethodName">OnBeginFadeOut</Rule>
|
||||
<Rule color="MethodName">.*__UpdateFunc</Rule>
|
||||
<Rule color="MethodName">.*__FinishedFunc</Rule>
|
||||
|
||||
<Rule color="Keyword">goto</Rule>
|
||||
<Rule color="Keyword">nullptr</Rule>
|
||||
|
||||
<Rule color="Keyword">FindObject<[A-Za-z0-9_]+></Rule>
|
||||
|
||||
<Rule color="String">"[^"]*"</Rule>
|
||||
<Rule color="Number">\b[0-9]+(\.[0-9]+)?\b</Rule>
|
||||
<Rule color="Brace">[\[\]\{\}]</Rule>
|
||||
|
||||
<Rule color="Type">UKismetMathLibrary</Rule>
|
||||
<Rule color="Type">UKismetSystemLibrary</Rule>
|
||||
|
||||
<Rule color="Punctuation">[?,.;()\[\]{}+\-/%*<>^=~!&]+</Rule>
|
||||
|
||||
<Keywords color="CompoundKeywords">
|
||||
<Word>__abstract</Word>
|
||||
<Word>__box</Word>
|
||||
<Word>__delegate</Word>
|
||||
<Word>__gc</Word>
|
||||
<Word>__identifier</Word>
|
||||
<Word>__nogc</Word>
|
||||
<Word>__pin</Word>
|
||||
<Word>__property</Word>
|
||||
<Word>__sealed</Word>
|
||||
<Word>__try_cast</Word>
|
||||
<Word>__typeof</Word>
|
||||
<Word>__value</Word>
|
||||
<Word>__event</Word>
|
||||
<Word>__hook</Word>
|
||||
<Word>__raise</Word>
|
||||
<Word>__unhook</Word>
|
||||
<Word>__interface</Word>
|
||||
<Word>ref class</Word>
|
||||
<Word>ref struct</Word>
|
||||
<Word>value class</Word>
|
||||
<Word>value struct</Word>
|
||||
<Word>interface class</Word>
|
||||
<Word>interface struct</Word>
|
||||
<Word>enum class</Word>
|
||||
<Word>enum struct</Word>
|
||||
<Word>delegate</Word>
|
||||
<Word>event</Word>
|
||||
<Word>property</Word>
|
||||
<Word>abstract</Word>
|
||||
<Word>override</Word>
|
||||
<Word>sealed</Word>
|
||||
<Word>generic</Word>
|
||||
<Word>where</Word>
|
||||
<Word>finally</Word>
|
||||
<Word>for each</Word>
|
||||
<Word>gcnew</Word>
|
||||
<Word>in</Word>
|
||||
<Word>initonly</Word>
|
||||
<Word>literal</Word>
|
||||
<Word>nullptr</Word>
|
||||
</Keywords>
|
||||
|
||||
<Keywords color="This">
|
||||
<Word>this</Word>
|
||||
</Keywords>
|
||||
<Keywords color="Operators">
|
||||
<Word>and</Word>
|
||||
<Word>and_eq</Word>
|
||||
<Word>bitand</Word>
|
||||
<Word>bitor</Word>
|
||||
<Word>new</Word>
|
||||
<Word>not</Word>
|
||||
<Word>not_eq</Word>
|
||||
<Word>or</Word>
|
||||
<Word>or_eq</Word>
|
||||
<Word>xor</Word>
|
||||
<Word>xor_eq</Word>
|
||||
</Keywords>
|
||||
<Keywords color="Namespace">
|
||||
<Word>using</Word>
|
||||
<Word>namespace</Word>
|
||||
</Keywords>
|
||||
<Keywords color="Friend">
|
||||
<Word>friend</Word>
|
||||
</Keywords>
|
||||
<Keywords color="Modifiers">
|
||||
<Word>private</Word>
|
||||
<Word>protected</Word>
|
||||
<Word>public</Word>
|
||||
<Word>const</Word>
|
||||
<Word>volatile</Word>
|
||||
<Word>static</Word>
|
||||
</Keywords>
|
||||
<Keywords color="BooleanConstants">
|
||||
<Word>true</Word>
|
||||
<Word>false</Word>
|
||||
<Word>NULL</Word>
|
||||
</Keywords>
|
||||
<Keywords color="Keywords">
|
||||
<Word>break</Word>
|
||||
<Word>case</Word>
|
||||
<Word>catch</Word>
|
||||
<Word>const_cast</Word>
|
||||
<Word>continue</Word>
|
||||
<Word>default</Word>
|
||||
<Word>delete</Word>
|
||||
<Word>dynamic_cast</Word>
|
||||
<Word>else</Word>
|
||||
<Word>explicit</Word>
|
||||
<Word>export</Word>
|
||||
<Word>extern</Word>
|
||||
<Word>false</Word>
|
||||
<Word>for</Word>
|
||||
<Word>friend</Word>
|
||||
<Word>goto</Word>
|
||||
<Word>if</Word>
|
||||
<Word>mutable</Word>
|
||||
<Word>namespace</Word>
|
||||
<Word>new</Word>
|
||||
<Word>operator</Word>
|
||||
<Word>private</Word>
|
||||
<Word>protected</Word>
|
||||
<Word>public</Word>
|
||||
<Word>register</Word>
|
||||
<Word>reinterpret_cast</Word>
|
||||
<Word>return</Word>
|
||||
<Word>sizeof</Word>
|
||||
<Word>static_cast</Word>
|
||||
<Word>template</Word>
|
||||
<Word>throw</Word>
|
||||
<Word>try</Word>
|
||||
<Word>typedef</Word>
|
||||
<Word>typeid</Word>
|
||||
<Word>typename</Word>
|
||||
<Word>using</Word>
|
||||
<Word>virtual</Word>
|
||||
<Word>volatile</Word>
|
||||
<Word>while</Word>
|
||||
</Keywords>
|
||||
<Keywords color="LoopKeywords">
|
||||
<Word>do</Word>
|
||||
<Word>for</Word>
|
||||
<Word>while</Word>
|
||||
<Word>break</Word>
|
||||
<Word>continue</Word>
|
||||
</Keywords>
|
||||
<Keywords color="JumpKeywords">
|
||||
<Word>goto</Word>
|
||||
<Word>return</Word>
|
||||
<Word>throw</Word>
|
||||
</Keywords>
|
||||
<Keywords color="ExceptionHandling">
|
||||
<Word>try</Word>
|
||||
<Word>catch</Word>
|
||||
<Word>throw</Word>
|
||||
<Word>finally</Word>
|
||||
</Keywords>
|
||||
<Keywords color="ControlFlow">
|
||||
|
||||
<!-- C++ Keywords -->
|
||||
<Keywords color="Keyword">
|
||||
<Word>void</Word>
|
||||
<Word>int</Word>
|
||||
<Word>Int8</Word>
|
||||
<Word>Int16</Word>
|
||||
<Word>Int32</Word>
|
||||
<Word>Int64</Word>
|
||||
<Word>uint</Word>
|
||||
<Word>UInt16</Word>
|
||||
<Word>UInt32</Word>
|
||||
<Word>UInt64</Word>
|
||||
<Word>float</Word>
|
||||
<Word>double</Word>
|
||||
<Word>bool</Word>
|
||||
<Word>return</Word>
|
||||
<Word>if</Word>
|
||||
<Word>else</Word>
|
||||
<Word>for</Word>
|
||||
<Word>while</Word>
|
||||
<Word>do</Word>
|
||||
<Word>switch</Word>
|
||||
<Word>case</Word>
|
||||
<Word>default</Word>
|
||||
<Word>break</Word>
|
||||
<Word>continue</Word>
|
||||
<Word>return</Word>
|
||||
<Word>namespace</Word>
|
||||
<Word>using</Word>
|
||||
<Word>typedef</Word>
|
||||
<Word>sizeof</Word>
|
||||
<Word>new</Word>
|
||||
<Word>delete</Word>
|
||||
<Word>class</Word>
|
||||
<Word>struct</Word>
|
||||
<Word>enum</Word>
|
||||
<Word>template</Word>
|
||||
<Word>typename</Word>
|
||||
<Word>const</Word>
|
||||
<Word>static</Word>
|
||||
<Word>mutable</Word>
|
||||
<Word>volatile</Word>
|
||||
<Word>override</Word>
|
||||
<Word>virtual</Word>
|
||||
<Word>explicit</Word>
|
||||
<Word>friend</Word>
|
||||
<Word>inline</Word>
|
||||
<Word>constexpr</Word>
|
||||
</Keywords>
|
||||
|
||||
<Keywords color="Pointer">
|
||||
<Word>nullptr</Word>
|
||||
</Keywords>
|
||||
|
||||
<Keywords color="BooleanConstants">
|
||||
<Word>true</Word>
|
||||
<Word>True</Word>
|
||||
<Word>false</Word>
|
||||
<Word>False</Word>
|
||||
<Word>NULL</Word>
|
||||
</Keywords>
|
||||
|
||||
<Keywords color="AccessModifier">
|
||||
<Word>public</Word>
|
||||
<Word>protected</Word>
|
||||
<Word>private</Word>
|
||||
</Keywords>
|
||||
|
||||
<Keywords color="This">
|
||||
<Word>this</Word>
|
||||
</Keywords>
|
||||
|
||||
<!-- Reference symbols -->
|
||||
<Rule color="Pointer">(?<=[A-Za-z0-9_>&\]])&(?=\s*[A-Za-z_<])</Rule>
|
||||
|
||||
<Rule color="LabelColor">\bLabel_\d+:</Rule>
|
||||
|
||||
<!-- Numbers (hex too) -->
|
||||
<Rule color="Number">\b(0x[0-9a-fA-F]+|[0-9]+(\.[0-9]+)?)\b</Rule>
|
||||
|
||||
<Rule color="StaticClass">\bU[A-Z][A-Za-z0-9_]*\b(?=::)</Rule>
|
||||
<Rule color="Function">[A-Za-z_][A-Za-z0-9_]*\s*(?=\()</Rule>
|
||||
|
||||
<Rule color="Brace">[\[\]\{\}]</Rule>
|
||||
|
||||
<!-- Template Functions -->
|
||||
<Rule color="Function">\b[A-Za-z_][A-Za-z0-9_]*\b(?=<)</Rule>
|
||||
|
||||
<!-- Types -->
|
||||
<Rule color="Type">\b[A-Z][A-Za-z0-9_]*(?:<[^>]+>)?[*&]?(?=\s+[*&]?[A-Za-z_][A-Za-z0-9_]*\s*(=|;|\)|,))</Rule>
|
||||
|
||||
<!-- Types inside <> -->
|
||||
<Rule color="Type">(?<=<)\s*[A-Z][A-Za-z0-9_]*(?:<[^>]+>)?[*&]?\s*(?=[>,])</Rule>
|
||||
|
||||
<!-- Match class name after the 'class' keyword -->
|
||||
<Rule color="Type">\b(?<=class\s)[A-Za-z_][A-Za-z0-9_]*</Rule>
|
||||
|
||||
<!-- Match name after 'public' keyword -->
|
||||
<Rule color="Type">\b(?<=public\s)[A-Za-z_][A-Za-z0-9_]*</Rule>
|
||||
|
||||
<!-- Types in function parameters -->
|
||||
<Rule color="Type">\b(?:T|F|U|E)[A-Z][A-Za-z0-9_]*(?:<[^>]+>)?[*&]?(?=\s+[*&]?[A-Za-z_][A-Za-z0-9_]*\s*(?:=|,|\)))</Rule>
|
||||
<Rule color="Type">\b(?<=[,(]\s*const\s)(?:T|F|U)[A-Z][A-Za-z0-9_]*[*&]?(?=\s)</Rule>
|
||||
|
||||
<!-- First parameter type in function -->
|
||||
<Rule color="Type">\b(?<=\()\s*[TUF][A-Z][A-Za-z0-9_]*(?=\s*<)</Rule>
|
||||
<Rule color="Type">\b(?<=\()\s*[TUF][A-Z][A-Za-z0-9_]*[*&]?(?=\s)</Rule>
|
||||
<Rule color="Type">\b(?<=\(\s*const\s)[TUF][A-Z][A-Za-z0-9_]*[*&]?(?=\s)</Rule>
|
||||
|
||||
</RuleSet>
|
||||
</SyntaxDefinition>
|
||||
|
|
|
|||
|
|
@ -976,7 +976,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
continue;
|
||||
|
||||
var dummy = ((AbstractUePackage) pkg).ConstructObject(pointer.Class?.Object?.Value as UStruct, pkg);
|
||||
if (dummy is not UBlueprintGeneratedClass || pointer.Object.Value is not UBlueprintGeneratedClass blueprint)
|
||||
if (dummy is not UClass || pointer.Object.Value is not UClass blueprint)
|
||||
continue;
|
||||
|
||||
var typePrefix = KismetExtensions.GetPrefix(blueprint.GetType().Name);
|
||||
|
|
@ -991,7 +991,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
var propertyName = property.Name.ToString();
|
||||
var propertyValue = property.Tag?.GenericValue;
|
||||
strings.Add(propertyName);
|
||||
string placeholder = $"{propertyName}placeholder";
|
||||
string placeholder = $"{propertyName}fmodelholder"; // spelling mistake is intended
|
||||
|
||||
void ShouldAppend(string value)
|
||||
{
|
||||
|
|
@ -1092,19 +1092,19 @@ public class CUE4ParseViewModel : ViewModel
|
|||
var type = KismetExtensions.GetPropertyType(property);
|
||||
var prefix = KismetExtensions.GetPrefix(property.GetType().Name);
|
||||
|
||||
string whatever;
|
||||
string pointerIdentifier;
|
||||
if (property.PropertyFlags.HasFlag(EPropertyFlags.InstancedReference) ||
|
||||
property.PropertyFlags.HasFlag(EPropertyFlags.ReferenceParm) ||
|
||||
KismetExtensions.GetPropertyProperty(property))
|
||||
{
|
||||
whatever = "*";
|
||||
pointerIdentifier = "*";
|
||||
}
|
||||
else
|
||||
{
|
||||
whatever = string.Empty;
|
||||
pointerIdentifier = string.Empty;
|
||||
}
|
||||
|
||||
outputBuilder.AppendLine($"\t{prefix}{type}{whatever} {propertyName} = {propertyName}placeholder;");
|
||||
outputBuilder.AppendLine($"\t{prefix}{type}{pointerIdentifier} {propertyName} = {propertyName}fmodelholder;");
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -1117,8 +1117,8 @@ public class CUE4ParseViewModel : ViewModel
|
|||
if (funcMapOrder != null)
|
||||
{
|
||||
var functionName = f.Name.ToString();
|
||||
int indexx = funcMapOrder.IndexOf(functionName);
|
||||
return indexx >= 0 ? indexx : int.MaxValue;
|
||||
int index = funcMapOrder.IndexOf(functionName);
|
||||
return index >= 0 ? index : int.MaxValue;
|
||||
}
|
||||
|
||||
return int.MaxValue;
|
||||
|
|
@ -1171,8 +1171,6 @@ public class CUE4ParseViewModel : ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach (var function in functions)
|
||||
{
|
||||
string argsList = "";
|
||||
|
|
@ -1181,21 +1179,28 @@ public class CUE4ParseViewModel : ViewModel
|
|||
{
|
||||
foreach (FProperty property in function.ChildProperties)
|
||||
{
|
||||
if (property.Name.PlainText == "ReturnValue")
|
||||
var name = property.Name.ToString();
|
||||
var plainName = property.Name.PlainText;
|
||||
var prefix = KismetExtensions.GetPrefix(property.GetType().Name);
|
||||
var type = KismetExtensions.GetPropertyType(property);
|
||||
var isConst = property.PropertyFlags.HasFlag(EPropertyFlags.ConstParm);
|
||||
var isOut = property.PropertyFlags.HasFlag(EPropertyFlags.OutParm);
|
||||
var isInstanced = property.PropertyFlags.HasFlag(EPropertyFlags.InstancedReference);
|
||||
var isEdit = property.PropertyFlags.HasFlag(EPropertyFlags.Edit);
|
||||
|
||||
if (plainName == "ReturnValue")
|
||||
{
|
||||
returnFunc =
|
||||
$"{(property.PropertyFlags.HasFlag(EPropertyFlags.ConstParm) ? "const " : string.Empty)}{KismetExtensions.GetPrefix(property.GetType().Name)}{KismetExtensions.GetPropertyType(property)}{(property.PropertyFlags.HasFlag(EPropertyFlags.InstancedReference) || KismetExtensions.GetPrefix(property.GetType().Name) == "U" ? "*" : string.Empty)}";
|
||||
}
|
||||
else if (!(property.Name.ToString().EndsWith("_ReturnValue") ||
|
||||
property.Name.ToString().StartsWith("CallFunc_") ||
|
||||
property.Name.ToString().StartsWith("K2Node_") ||
|
||||
property.Name.ToString()
|
||||
.StartsWith("Temp_")) || // removes useless args
|
||||
property.PropertyFlags.HasFlag(EPropertyFlags.Edit))
|
||||
{
|
||||
argsList +=
|
||||
$"{(property.PropertyFlags.HasFlag(EPropertyFlags.ConstParm) ? "const " : string.Empty)}{KismetExtensions.GetPrefix(property.GetType().Name)}{KismetExtensions.GetPropertyType(property)}{(property.PropertyFlags.HasFlag(EPropertyFlags.InstancedReference) || KismetExtensions.GetPrefix(property.GetType().Name) == "U" ? "*" : string.Empty)}{(property.PropertyFlags.HasFlag(EPropertyFlags.OutParm) ? "&" : string.Empty)} {Regex.Replace(property.Name.ToString(), @"^__verse_0x[0-9A-Fa-f]+_", "")}, ";
|
||||
returnFunc = $"{(isConst ? "const " : "")}{prefix}{type}{(isInstanced || prefix == "U" ? "*" : "")}";
|
||||
continue;
|
||||
}
|
||||
|
||||
bool uselessIgnore = name.EndsWith("_ReturnValue") || name.StartsWith("CallFunc_") || name.StartsWith("K2Node_") || name.StartsWith("Temp_"); // read variable name
|
||||
|
||||
if (uselessIgnore && !isEdit)
|
||||
continue;
|
||||
|
||||
var strippedVerseName = Regex.Replace(name, @"^__verse_0x[0-9A-Fa-f]+_", "");
|
||||
argsList += $"{(isConst ? "const " : "")}{prefix}{type}{(isInstanced || prefix == "U" ? "*" : "")}{(isOut ? "&" : "")} {strippedVerseName}, ";
|
||||
}
|
||||
}
|
||||
argsList = argsList.TrimEnd(',', ' ');
|
||||
|
|
@ -1211,7 +1216,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
}
|
||||
else
|
||||
{
|
||||
outputBuilder.Append("\n\t // This function does not have Bytecode \n\n");
|
||||
outputBuilder.Append("\n\t // No Bytecode (Make sure \"Serialize Script Bytecode\" is enabled \n\n");
|
||||
outputBuilder.Append("\t}\n");
|
||||
}
|
||||
}
|
||||
|
|
@ -1220,7 +1225,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
var cpp = Regex.Replace(outputBuilder.ToString(), @"\w+placeholder", "nullptr");
|
||||
var cpp = Regex.Replace(outputBuilder.ToString(), @"\w+fmodelholder", "nullptr");
|
||||
TabControl.SelectedTab.SetDocumentText(cpp, false, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user