7#include "../third_party/imgui/imgui.h"
22 std::vector<ValidationError> errors;
31 auto nodes =
graph->GetAllNodes();
40 if (
graph->rootNodeId < 0)
51 std::vector<ValidationError> errors;
79 for (
const auto&
error : errors)
93 for (
const auto&
error : errors)
95 if (
error.severity == severity)
109 default:
return "Unknown";
121 default:
return ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
126 std::vector<ValidationError>& errors)
131 if (
node->actionType.empty())
141 "Invalid or deprecated ActionType: " +
node->actionType,
148 if (
node->conditionType.empty())
158 "Invalid or deprecated ConditionType: " +
node->conditionType,
165 if (
node->decoratorType.empty())
175 "Invalid or deprecated DecoratorType: " +
node->decoratorType,
182 std::vector<ValidationError>& errors)
196 if (
it ==
node->parameters.end() ||
it->second.empty())
199 "Missing required parameter: " +
paramDef.name,
217 if (
it ==
node->parameters.end() ||
it->second.empty())
220 "Missing required parameter: " +
paramDef.name,
238 if (
it ==
node->parameters.end() ||
it->second.empty())
241 "Missing required parameter: " +
paramDef.name,
251 std::vector<ValidationError>& errors)
256 if (
node->childIds.empty())
266 if (
node->decoratorChildId < 0)
274 for (
int childId :
node->childIds)
276 if (!
graph->GetNode(childId))
279 "Child node " + std::to_string(childId) +
" does not exist",
284 if (
node->decoratorChildId >= 0 && !
graph->GetNode(
node->decoratorChildId))
287 "Decorator child node " + std::to_string(
node->decoratorChildId) +
" does not exist",
299 return blueprint[
"type"].get<std::string>();
306 return "BehaviorTree";
318 return "EntityBlueprint";
325 if (data.contains(
"prefabName") || data.contains(
"components"))
327 return "EntityPrefab";
334 return "UIBlueprint";
364 if (!
blueprint.contains(
"schema_version"))
379 if (!
blueprint.contains(
"blueprintType"))
381 std::string type =
blueprint.contains(
"type") ?
390 blueprint[
"metadata"] = nlohmann::json::object();
391 blueprint[
"metadata"][
"author"] =
"Unknown";
393 blueprint[
"metadata"][
"lastModified"] =
"";
394 blueprint[
"metadata"][
"tags"] = nlohmann::json::array();
401 blueprint[
"editorState"] = nlohmann::json::object();
403 blueprint[
"editorState"][
"scrollOffset"] = nlohmann::json::object();
404 blueprint[
"editorState"][
"scrollOffset"][
"x"] = 0.0f;
405 blueprint[
"editorState"][
"scrollOffset"][
"y"] = 0.0f;
419 errors =
"Missing 'type' field";
423 std::string type =
blueprint[
"type"].get<std::string>();
426 if (type ==
"BehaviorTree")
430 else if (type ==
"HFSM")
434 else if (type ==
"EntityPrefab" || type ==
"EntityBlueprint")
438 else if (type ==
"UIBlueprint")
442 else if (type ==
"Level")
461 if (!data->contains(
"nodes") || !(*data)[
"nodes"].is_array())
463 errors =
"BehaviorTree missing 'nodes' array";
467 if (!data->contains(
"rootNodeId"))
469 errors =
"BehaviorTree missing 'rootNodeId'";
486 if (!data->contains(
"states") || !(*data)[
"states"].is_array())
488 errors =
"HFSM missing 'states' array";
492 if (!data->contains(
"initialState"))
494 errors =
"HFSM missing 'initialState'";
511 if (!data->contains(
"components") || !(*data)[
"components"].is_array())
513 errors =
"EntityPrefab missing 'components' array";
525 errors =
"UIBlueprint missing 'elements' array";
537 errors =
"Level missing 'worldSize' or 'entities'";
ComponentTypeID GetComponentTypeID_Static()
int GetErrorCount(const std::vector< ValidationError > &errors, ErrorSeverity severity) const
static ImVec4 SeverityToColor(ErrorSeverity severity)
std::vector< ValidationError > ValidateNode(const NodeGraph *graph, int nodeId)
bool ValidateUIBlueprint(const nlohmann::json &blueprint, std::string &errors)
std::string DetectType(const nlohmann::json &blueprint)
bool Normalize(nlohmann::json &blueprint)
void ValidateNodeType(const NodeGraph *graph, const GraphNode *node, std::vector< ValidationError > &errors)
bool ValidateHFSM(const nlohmann::json &blueprint, std::string &errors)
bool ValidateEntityPrefab(const nlohmann::json &blueprint, std::string &errors)
bool IsGraphValid(const NodeGraph *graph)
void ValidateNodeLinks(const NodeGraph *graph, const GraphNode *node, std::vector< ValidationError > &errors)
bool ValidateJSON(const nlohmann::json &blueprint, std::string &errors)
void ValidateNodeParameters(const NodeGraph *graph, const GraphNode *node, std::vector< ValidationError > &errors)
bool ValidateLevel(const nlohmann::json &blueprint, std::string &errors)
static const char * SeverityToString(ErrorSeverity severity)
bool ValidateBehaviorTree(const nlohmann::json &blueprint, std::string &errors)
std::vector< ValidationError > ValidateGraph(const NodeGraph *graph)
const CatalogType * FindActionType(const std::string &id) const
static EnumCatalogManager & Get()
const CatalogType * FindDecoratorType(const std::string &id) const
const CatalogType * FindConditionType(const std::string &id) const
std::vector< CatalogParameter > parameters