// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #pragma once #include "parse/elements/children.hpp" namespace Dawn { struct RootInformation { std::vector includes; struct ChildrenInfo children; }; class RootParser : public XmlParser { protected: std::vector getRequiredAttributes() { return std::vector(); } std::map getOptionalAttributes() { return std::map(); } int32_t onParse( Xml *node, std::map values, struct RootInformation *out, std::string *error ) { int32_t ret; if(node->node != "root") { *error = "Root node is of an invalid type"; return 1; } ret = (ChildrenParser()).parse(node, &out->children, error); if(ret != 0) return ret; return ret; } }; class RootGen : public CodeGen { public: static void generate( std::vector *out, struct RootInformation *info, std::string tabs = "" ) { struct ClassGenInfo clazz; clazz.clazz = "SimpleTestUI"; clazz.extend = "SceneItemPrefab<" + clazz.clazz + ">"; clazz.constructorArgs = "Scene *s, sceneitemid_t i"; clazz.extendArgs = "s, i"; clazz.includes.push_back("#include \"prefab/SceneItemPrefab.hpp\""); // Assets struct MethodGenInfo assetsInfo; assetsInfo.name = "prefabAssets"; assetsInfo.isStatic = true; assetsInfo.type = "std::vector"; assetsInfo.args = "AssetManager *ass"; line(&assetsInfo.body, "return {", ""); line(&assetsInfo.body, "};", ""); methodGen(&clazz.publicCode, assetsInfo); line(&clazz.publicCode, "", ""); // Init struct MethodGenInfo prefabInfo; prefabInfo.name = "prefabInit"; prefabInfo.args = "AssetManager *ass"; prefabInfo.isOverride = true; methodGen(&clazz.publicCode, prefabInfo); classGen(out, clazz); } }; }