MCPcopy Create free account
hub / github.com/MrDrElliot/LuminaEngine / RebuildTree

Method RebuildTree

Engine/Editor/Source/UI/Properties/PropertyTable.cpp:1184–1241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1182 SkipSpace();
1183 const int32 LiteralStart = Pos;
1184 while (Pos < Text.Len() && Text[Pos] != ' ' && Text[Pos] != ')' && Text[Pos] != '&' && Text[Pos] != '|')
1185 {
1186 ++Pos;
1187 }
1188 FStringView Literal = Text.Mid(LiteralStart, Pos - LiteralStart);
1189 if (Literal.Len() >= 2 && Literal[0] == '"' && Literal.Last() == '"')
1190 {
1191 Literal = Literal.Mid(1, Literal.Len() - 2);
1192 }
1193 Term.bLiteralResolved = TryResolveConditionLiteral(Property, Literal, Term.Expected);
1194 }
1195
1196 const int32 Index = Add(ENodeKind::Term, -1, -1);
1197 Nodes[Index].Term = Term;
1198 return Index;
1199 }
1200 };
1201
1202 void FPropertyEditCondition::Parse(FProperty* Source)
1203 {
1204 Nodes.Reset();
1205 Root = -1;
1206 bHides = false;
1207
1208 const FCStringView Expression = Source->GetMetadata("EditCondition");
1209 if (Expression.IsEmpty())
1210 {
1211 return;
1212 }
1213
1214 const FStringView ExpressionView = Expression;
1215 FParser Parser{ ExpressionView, 0, Source, Nodes };
1216 const int32 Parsed = Parser.ParseOr();
1217 Parser.SkipSpace();
1218 if (Parser.bFailed || Parsed < 0 || Parser.Pos != Parser.Text.Len())
1219 {
1220 Nodes.Reset();
1221 return;
1222 }
1223 Root = Parsed;
1224 bHides = Source->HasEditorFlag(EPropertyEditorFlags::EditConditionHides);
1225 }
1226
1227 bool FPropertyEditCondition::EvaluateNode(int32 Index, void* ContainerPtr) const
1228 {
1229 const FNode& Node = Nodes[Index];
1230 switch (Node.Kind)
1231 {
1232 case ENodeKind::Not: return !EvaluateNode(Node.Left, ContainerPtr);
1233 case ENodeKind::And: return EvaluateNode(Node.Left, ContainerPtr) && EvaluateNode(Node.Right, ContainerPtr);
1234 case ENodeKind::Or: return EvaluateNode(Node.Left, ContainerPtr) || EvaluateNode(Node.Right, ContainerPtr);
1235 default: return EvaluateConditionTerm(Node.Term, ContainerPtr);
1236 }
1237 }
1238
1239 bool FPropertyEditCondition::Evaluate(void* ContainerPtr) const
1240 {
1241 return Root < 0 || ContainerPtr == nullptr || EvaluateNode(Root, ContainerPtr);

Callers 1

RebuildChildrenMethod · 0.45

Calls 9

FNameFunction · 0.50
clearMethod · 0.45
IsVisibleMethod · 0.45
HasMetadataMethod · 0.45
lengthMethod · 0.45
findMethod · 0.45
dataMethod · 0.45
AddPropertyMethod · 0.45

Tested by

no test coverage detected