diff --git a/src/dawn/games/vn/events/VNSetEvent.hpp b/src/dawn/games/vn/events/VNSetEvent.hpp index 9f82c272..ea0d5a33 100644 --- a/src/dawn/games/vn/events/VNSetEvent.hpp +++ b/src/dawn/games/vn/events/VNSetEvent.hpp @@ -4,24 +4,20 @@ // https://opensource.org/licenses/MIT #pragma once -#include "VNAnimateEvent.hpp" +#include "VNEvent.hpp" namespace Dawn { - template - class VNSetEvent : public VNAnimateEvent { + template + class VNSetEvent : public VNEvent { public: - StateProperty *modifies = nullptr; + T *modifies = nullptr; + T value; protected: void onStart() override { assertNotNull(this->modifies); - this->from = modifies->getValue(); - - VNAnimateEvent::onStart(); - } - - void setValue(T value) override { - modifies->setValue(value); + *modifies = value; + this->next(); } }; } \ No newline at end of file diff --git a/src/dawntools/util/generator/SceneGenerator.cpp b/src/dawntools/util/generator/SceneGenerator.cpp index 88b516f3..2bbcf3d9 100644 --- a/src/dawntools/util/generator/SceneGenerator.cpp +++ b/src/dawntools/util/generator/SceneGenerator.cpp @@ -14,13 +14,15 @@ void SceneGenerator::generate( struct MethodGenInfo &methodInit ) { assertNotNull(scene); + + std::map assetMap; + int32_t assetNumber = 0; + std::string baseClassName = "Scene"; classInfo.clazz = scene->name; classInfo.constructorArgs = "DawnGame *game"; classInfo.extendArgs = "game"; - std::string baseClassName = "Scene"; - // Determine extends if(scene->extend.empty()) { classInfo.includes.push_back("scene/Scene.hpp"); @@ -39,7 +41,7 @@ void SceneGenerator::generate( methodAssets.name = "getRequiredAssets"; methodAssets.isOverride = true; methodAssets.type = "std::vector"; - line(&methodAssets.body, "auto assMan = &this->game->assetManager;", ""); + line(&methodAssets.body, "auto man = &this->game->assetManager;", ""); methodInit.name = "stage"; methodInit.isOverride = true; @@ -51,11 +53,26 @@ void SceneGenerator::generate( line(&methodInit.body, baseClassName + "::stage();", ""); } + // Scene assets + line(&methodInit.body, "auto man = &this->game->assetManager;", ""); + + auto itAssets = scene->assets.begin(); + while(itAssets != scene->assets.end()) { + SceneAssetGenerator::generate( + assetMap, + assetNumber, + &classInfo.publicProperties, + &methodInit.body, + &methodAssets.body, + &(*itAssets), + "" + ); + ++itAssets; + } + // Generate - int32_t assetNumber = 0; int32_t childNumber = 0; int32_t componentNumber = 0; - std::map assetMap; std::vector componentsUnused; auto itDeps = scene->dependencies.begin(); diff --git a/src/dawntools/util/generator/SceneItemGenerator.cpp b/src/dawntools/util/generator/SceneItemGenerator.cpp index 54dce3fb..a8d6fddd 100644 --- a/src/dawntools/util/generator/SceneItemGenerator.cpp +++ b/src/dawntools/util/generator/SceneItemGenerator.cpp @@ -118,7 +118,7 @@ void SceneItemGenerator::generate( // Create prefab includes.push_back(item->prefab + ".hpp"); line(initBody, (item->ref.empty() ? "auto " : "") + name + " = " + prefabName + "::create(" + sceneRef + ");", ""); - line(assetBody, "vectorAppend(&assets, " + prefabName + "::getRequiredAssets(assMan));", ""); + line(assetBody, "vectorAppend(&assets, " + prefabName + "::getRequiredAssets(man));", ""); } else { // Not a prefab, init empty child. line(initBody, (item->ref.empty() ? "auto " : "") + name + " = " + sceneRef + "->createSceneItem();", ""); diff --git a/src/dawntools/util/parser/SceneParser.cpp b/src/dawntools/util/parser/SceneParser.cpp index 4499a862..b7ad347b 100644 --- a/src/dawntools/util/parser/SceneParser.cpp +++ b/src/dawntools/util/parser/SceneParser.cpp @@ -35,8 +35,14 @@ int32_t SceneParser::onParse( auto itChildren = node->children.begin(); while(itChildren != node->children.end()) { Xml *child = *itChildren; - - if(child->node == "item") { + + if(child->node == "asset") { + struct SceneAsset asset; + auto ret = (SceneAssetParser()).parse(child, &asset, error); + if(ret != 0) return ret; + out->assets.push_back(asset); + + } else if(child->node == "item") { struct SceneItem item; item.registry = out->registry; ret = (SceneItemParser()).parse(child, &item, error); diff --git a/src/dawntools/util/parser/SceneParser.hpp b/src/dawntools/util/parser/SceneParser.hpp index e94ea214..1eaceccf 100644 --- a/src/dawntools/util/parser/SceneParser.hpp +++ b/src/dawntools/util/parser/SceneParser.hpp @@ -13,6 +13,7 @@ namespace Dawn { std::string extend; std::vector items; std::vector code; + std::vector assets; struct SceneItemComponentRegistry *registry; std::vector dependencies; }; diff --git a/src/dawntools/vnscenetool/VNSceneGen.cpp b/src/dawntools/vnscenetool/VNSceneGen.cpp index 82aedc86..29a13af8 100644 --- a/src/dawntools/vnscenetool/VNSceneGen.cpp +++ b/src/dawntools/vnscenetool/VNSceneGen.cpp @@ -39,9 +39,7 @@ void VNSceneGen::test( initType = "VNSetEvent<" + event->set.type + ">"; toInclude = "games/vn/events/VNSetEvent.hpp"; line(&afterLines, eventName + "->modifies = &" + event->set.property + ";", ""); - line(&afterLines, eventName + "->to = " + event->set.to + ";", ""); - if(event->set.from != "") line(&afterLines, eventName + "->from = " + event->set.from + ";", ""); - if(event->set.duration != "") line(&afterLines, eventName + "->duration = " + event->set.duration + ";", ""); + line(&afterLines, eventName + "->value = " + event->set.to + ";", ""); break; case VN_SCENE_EVENT_TYPE_WAIT: diff --git a/src/dawntools/vnscenetool/events/VNSetEventParser.cpp b/src/dawntools/vnscenetool/events/VNSetEventParser.cpp index 878dcd7b..cba32b0c 100644 --- a/src/dawntools/vnscenetool/events/VNSetEventParser.cpp +++ b/src/dawntools/vnscenetool/events/VNSetEventParser.cpp @@ -14,10 +14,7 @@ std::vector VNSetEventParser::getRequiredAttributes() { std::map VNSetEventParser::getOptionalAttributes() { return { { "to", "" }, - { "value", "" }, - { "from", "" }, - { "duration", "" }, - { "curve", "" } + { "value", "" } }; } @@ -38,8 +35,5 @@ int32_t VNSetEventParser::onParse( out->type = values["type"]; out->property = values["property"]; - out->from = values["from"]; - out->duration = values["duration"]; - out->curve = values["curve"]; return 0; } \ No newline at end of file diff --git a/src/dawntools/vnscenetool/events/VNSetEventParser.hpp b/src/dawntools/vnscenetool/events/VNSetEventParser.hpp index d085fa54..4a2be102 100644 --- a/src/dawntools/vnscenetool/events/VNSetEventParser.hpp +++ b/src/dawntools/vnscenetool/events/VNSetEventParser.hpp @@ -10,9 +10,6 @@ namespace Dawn { struct VNSetEvent { std::string property = ""; std::string to = ""; - std::string from = ""; - std::string duration = ""; - std::string curve = ""; std::string type = ""; };