diff --git a/assets/games/liminal/prefabs/EthPrefab.xml b/assets/games/liminal/prefabs/EthPrefab.xml index 408fd914..e9ed3012 100644 --- a/assets/games/liminal/prefabs/EthPrefab.xml +++ b/assets/games/liminal/prefabs/EthPrefab.xml @@ -5,4 +5,18 @@ + + + TilesetGrid grid; + + + + this->grid = TilesetGrid( + 1, 13, + 741, 10270, + 0, 0, + 0, 0 + ); + tiledSprite->tileset = &grid; + \ No newline at end of file diff --git a/assets/games/liminal/scenes/SceneBase.xml b/assets/games/liminal/scenes/SceneBase.xml index 35345bdc..ec05af31 100644 --- a/assets/games/liminal/scenes/SceneBase.xml +++ b/assets/games/liminal/scenes/SceneBase.xml @@ -4,13 +4,13 @@ - + - - - + + + @@ -24,7 +24,16 @@ alignUnitRight="UI_COMPONENT_ALIGN_UNIT_PERCENT" alignY="UI_COMPONENT_ALIGN_STRETCH" ref="image" + texture="camTexture->renderTarget.getTexture()" /> + + + useEvent([&]{ + assertNotNull(camTexture); + assertNotNull(image); + camTexture->renderTarget.setSize(image->getWidth(), image->getHeight()); + }, image->eventAlignmentUpdated); + \ No newline at end of file diff --git a/assets/games/liminal/scenes/VNSceneTest.xml b/assets/games/liminal/scenes/VNSceneTest.xml index 2e0b5b65..3432205a 100644 --- a/assets/games/liminal/scenes/VNSceneTest.xml +++ b/assets/games/liminal/scenes/VNSceneTest.xml @@ -1,6 +1,6 @@ - + Hi, I'm Ethereality. diff --git a/src/dawntools/util/generator/CMakeLists.txt b/src/dawntools/util/generator/CMakeLists.txt index 7872a4c8..19378cec 100644 --- a/src/dawntools/util/generator/CMakeLists.txt +++ b/src/dawntools/util/generator/CMakeLists.txt @@ -10,6 +10,7 @@ set( ${DAWN_TOOL_SOURCES} ${D}/SceneItemGenerator.cpp ${D}/SceneAssetGenerator.cpp + ${D}/SceneCodeGenerator.cpp ${D}/SceneGenerator.cpp ${D}/SceneItemComponentGenerator.cpp diff --git a/src/dawntools/util/generator/SceneCodeGenerator.cpp b/src/dawntools/util/generator/SceneCodeGenerator.cpp new file mode 100644 index 00000000..daa441d3 --- /dev/null +++ b/src/dawntools/util/generator/SceneCodeGenerator.cpp @@ -0,0 +1,28 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "SceneCodeGenerator.hpp" + +using namespace Dawn; + +void SceneCodeGenerator::generate( + std::vector *publicProperties, + std::vector *initBody, + struct SceneCode *code, + std::string tabs +) { + switch(code->codeType) { + case SCENE_CODE_TYPE_PROPERTIES: + line(publicProperties, code->code, ""); + break; + + case SCENE_CODE_TYPE_INIT: + line(initBody, code->code, ""); + break; + + default: + break; + } +} \ No newline at end of file diff --git a/src/dawntools/util/generator/SceneCodeGenerator.hpp b/src/dawntools/util/generator/SceneCodeGenerator.hpp new file mode 100644 index 00000000..62d46df0 --- /dev/null +++ b/src/dawntools/util/generator/SceneCodeGenerator.hpp @@ -0,0 +1,20 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "util/parser/SceneCodeParser.hpp" +#include "util/CodeGen.hpp" + +namespace Dawn { + class SceneCodeGenerator : public CodeGen { + public: + static void generate( + std::vector *publicProperties, + std::vector *initBody, + struct SceneCode *code, + std::string tabs + ); + }; +} \ No newline at end of file diff --git a/src/dawntools/util/generator/SceneGenerator.cpp b/src/dawntools/util/generator/SceneGenerator.cpp index cca882dc..d1ac1bc7 100644 --- a/src/dawntools/util/generator/SceneGenerator.cpp +++ b/src/dawntools/util/generator/SceneGenerator.cpp @@ -76,4 +76,16 @@ void SceneGenerator::generate( // Seal methods line(&methodAssets.body, "return assets;", ""); + + // Code + auto itCode = scene->code.begin(); + while(itCode != scene->code.end()) { + SceneCodeGenerator::generate( + &classInfo.publicProperties, + &methodInit.body, + &(*itCode), + "" + ); + ++itCode; + } } \ No newline at end of file diff --git a/src/dawntools/util/generator/SceneItemGenerator.cpp b/src/dawntools/util/generator/SceneItemGenerator.cpp index fee19857..6b81addd 100644 --- a/src/dawntools/util/generator/SceneItemGenerator.cpp +++ b/src/dawntools/util/generator/SceneItemGenerator.cpp @@ -122,4 +122,16 @@ void SceneItemGenerator::generate( if(!parentRef.empty()) { line(initBody, name + "->transform.setParent(&"+parentRef+"->transform);", ""); } + + // Code + auto itCode = item->code.begin(); + while(itCode != item->code.end()) { + SceneCodeGenerator::generate( + publicProperties, + initBody, + &(*itCode), + "" + ); + ++itCode; + } } \ No newline at end of file diff --git a/src/dawntools/util/generator/SceneItemGenerator.hpp b/src/dawntools/util/generator/SceneItemGenerator.hpp index 71848417..35fdb66c 100644 --- a/src/dawntools/util/generator/SceneItemGenerator.hpp +++ b/src/dawntools/util/generator/SceneItemGenerator.hpp @@ -7,6 +7,7 @@ #include "SceneItemComponentGenerator.hpp" #include "SceneAssetGenerator.hpp" #include "util/parser/SceneItemParser.hpp" +#include "util/generator/SceneCodeGenerator.hpp" namespace Dawn { class SceneItemGenerator : public CodeGen { diff --git a/src/dawntools/util/parser/CMakeLists.txt b/src/dawntools/util/parser/CMakeLists.txt index 359b300f..584fb9a9 100644 --- a/src/dawntools/util/parser/CMakeLists.txt +++ b/src/dawntools/util/parser/CMakeLists.txt @@ -11,6 +11,7 @@ set( ${D}/SceneParser.cpp ${D}/SceneItemParser.cpp ${D}/SceneAssetParser.cpp + ${D}/SceneCodeParser.cpp ${D}/SceneItemComponentParser.cpp ${D}/SceneItemComponentRegistry.cpp diff --git a/src/dawntools/util/parser/SceneCodeParser.cpp b/src/dawntools/util/parser/SceneCodeParser.cpp new file mode 100644 index 00000000..0c839221 --- /dev/null +++ b/src/dawntools/util/parser/SceneCodeParser.cpp @@ -0,0 +1,39 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#include "SceneCodeParser.hpp" + +using namespace Dawn; + +std::vector SceneCodeParser::getRequiredAttributes() { + return { "type" }; +} + +std::map SceneCodeParser::getOptionalAttributes() { + return {}; +} + +int32_t SceneCodeParser::onParse( + Xml *node, + std::map values, + struct SceneCode *out, + std::string *error +) { + // Get the type + std::string type = values["type"]; + if(type == "properties") { + out->codeType = SCENE_CODE_TYPE_PROPERTIES; + } else if(type == "init") { + out->codeType = SCENE_CODE_TYPE_INIT; + } else { + *error = "Invalid type '" + type + "' for SceneCode."; + return -1; + } + + // Get the code + out->code = node->value; + + return 0; +} \ No newline at end of file diff --git a/src/dawntools/util/parser/SceneCodeParser.hpp b/src/dawntools/util/parser/SceneCodeParser.hpp new file mode 100644 index 00000000..67f7f11c --- /dev/null +++ b/src/dawntools/util/parser/SceneCodeParser.hpp @@ -0,0 +1,32 @@ +// Copyright (c) 2023 Dominic Masters +// +// This software is released under the MIT License. +// https://opensource.org/licenses/MIT + +#pragma once +#include "util/XmlParser.hpp" + +namespace Dawn { + enum SceneCodeType { + SCENE_CODE_TYPE_PROPERTIES, + SCENE_CODE_TYPE_INIT + }; + + struct SceneCode { + enum SceneCodeType codeType; + std::string code; + }; + + class SceneCodeParser : public XmlParser { + public: + virtual std::vector getRequiredAttributes(); + virtual std::map getOptionalAttributes(); + + virtual int32_t onParse( + Xml *node, + std::map values, + struct SceneCode *out, + std::string *error + ); + }; +} \ No newline at end of file diff --git a/src/dawntools/util/parser/SceneItemParser.cpp b/src/dawntools/util/parser/SceneItemParser.cpp index 17342b4e..26773d73 100644 --- a/src/dawntools/util/parser/SceneItemParser.cpp +++ b/src/dawntools/util/parser/SceneItemParser.cpp @@ -71,6 +71,12 @@ int32_t SceneItemParser::onParse( auto ret = (SceneAssetParser()).parse(c, &asset, error); if(ret != 0) return ret; out->assets.push_back(asset); + + } else if(c->node == "code") { + struct SceneCode code; + auto ret = (SceneCodeParser()).parse(c, &code, error); + if(ret != 0) return ret; + out->code.push_back(code); } else { struct SceneItemComponent component; diff --git a/src/dawntools/util/parser/SceneItemParser.hpp b/src/dawntools/util/parser/SceneItemParser.hpp index e029628f..f65a970b 100644 --- a/src/dawntools/util/parser/SceneItemParser.hpp +++ b/src/dawntools/util/parser/SceneItemParser.hpp @@ -6,6 +6,7 @@ #pragma once #include "util/parser/SceneItemComponentParser.hpp" #include "util/parser/SceneAssetParser.hpp" +#include "util/parser/SceneCodeParser.hpp" namespace Dawn { struct SceneItem { @@ -19,6 +20,7 @@ namespace Dawn { std::vector components; std::vector children; std::vector assets; + std::vector code; }; class SceneItemParser : public XmlParser { diff --git a/src/dawntools/util/parser/SceneParser.cpp b/src/dawntools/util/parser/SceneParser.cpp index bb24769a..3dbe86ec 100644 --- a/src/dawntools/util/parser/SceneParser.cpp +++ b/src/dawntools/util/parser/SceneParser.cpp @@ -40,6 +40,12 @@ int32_t SceneParser::onParse( ret = (SceneItemParser()).parse(child, &item, error); if(ret != 0) return 1; out->items.push_back(item); + + } else if(child->node == "code") { + struct SceneCode code; + ret = (SceneCodeParser()).parse(child, &code, error); + if(ret != 0) return ret; + out->code.push_back(code); } ++itChildren; diff --git a/src/dawntools/util/parser/SceneParser.hpp b/src/dawntools/util/parser/SceneParser.hpp index 141388dd..c9aef74f 100644 --- a/src/dawntools/util/parser/SceneParser.hpp +++ b/src/dawntools/util/parser/SceneParser.hpp @@ -5,12 +5,14 @@ #pragma once #include "util/parser/SceneItemParser.hpp" +#include "util/parser/SceneCodeParser.hpp" namespace Dawn { struct Scene { std::string name; std::string extend; std::vector items; + std::vector code; struct SceneItemComponentRegistry *registry; };