diff --git a/assets/games/liminal/scenes/scene-base.xml b/assets/games/liminal/scenes/scene-base.xml index 8f16ac6a..a633b508 100644 --- a/assets/games/liminal/scenes/scene-base.xml +++ b/assets/games/liminal/scenes/scene-base.xml @@ -3,7 +3,7 @@ - + \ No newline at end of file diff --git a/assets/games/liminal/test.xml b/assets/games/liminal/test.xml index cb2df250..f6b4e749 100644 --- a/assets/games/liminal/test.xml +++ b/assets/games/liminal/test.xml @@ -1,4 +1,4 @@ - + diff --git a/src/dawnliminal/CMakeLists.txt b/src/dawnliminal/CMakeLists.txt index 4bd79eb1..8647f1d9 100644 --- a/src/dawnliminal/CMakeLists.txt +++ b/src/dawnliminal/CMakeLists.txt @@ -20,7 +20,7 @@ add_subdirectory(save) set(LIMINAL_ASSETS_DIR ${DAWN_ASSETS_DIR}/games/liminal) tool_scene(${LIMINAL_ASSETS_DIR}/scenes/scene-base.xml) tool_scene(${LIMINAL_ASSETS_DIR}/scenes/scene-extend.xml) -# tool_vnscene(${LIMINAL_ASSETS_DIR}/test.xml) +tool_vnscene(${LIMINAL_ASSETS_DIR}/test.xml) tool_prefab(${LIMINAL_ASSETS_DIR}/VNTextbox.xml) tool_truetype(font_main ${DAWN_ASSETS_DIR}/ark-pixel.ttf) diff --git a/src/dawnliminal/game/LiminalGame.cpp b/src/dawnliminal/game/LiminalGame.cpp index ee74955f..baee4bb4 100644 --- a/src/dawnliminal/game/LiminalGame.cpp +++ b/src/dawnliminal/game/LiminalGame.cpp @@ -5,11 +5,11 @@ #include "game/DawnGame.hpp" #include "scenes/HelloWorldScene.hpp" -#include "scenes/TestScene.hpp" +#include "scenes/ExtendedScene.hpp" using namespace Dawn; Scene * Dawn::dawnGameGetInitialScene(DawnGame *game) { // return new HelloWorldScene(game); - return new TestScene(game); + return new ExtendedScene(game); } \ No newline at end of file diff --git a/src/dawntools/scenetool/CMakeLists.txt b/src/dawntools/scenetool/CMakeLists.txt index 73e7ea43..8a6c47b3 100644 --- a/src/dawntools/scenetool/CMakeLists.txt +++ b/src/dawntools/scenetool/CMakeLists.txt @@ -15,7 +15,6 @@ target_sources(scenetool ${DAWN_SHARED_SOURCES} ${DAWN_TOOL_SOURCES} SceneTool.cpp - SceneParser.cpp SceneGen.cpp ) diff --git a/src/dawntools/scenetool/SceneGen.cpp b/src/dawntools/scenetool/SceneGen.cpp index 64b5954d..a47b4880 100644 --- a/src/dawntools/scenetool/SceneGen.cpp +++ b/src/dawntools/scenetool/SceneGen.cpp @@ -14,23 +14,44 @@ void SceneGen::generate( ) { struct ClassGenInfo classInfo; classInfo.clazz = scene->name; - classInfo.extend = "Scene"; classInfo.constructorArgs = "DawnGame *game"; classInfo.extendArgs = "game"; + std::string baseClassName = "Scene"; + + // Determine extends + if(scene->extend.empty()) { + classInfo.includes.push_back("scene/Scene.hpp"); + } else { + classInfo.includes.push_back(scene->extend + ".hpp"); + + // Get last slash of scene->extend + auto lastSlash = scene->extend.find_last_of('/'); + if(lastSlash != std::string::npos) { + baseClassName = scene->extend.substr(lastSlash + 1); + } else { + baseClassName = scene->extend; + } + } + classInfo.extend = baseClassName; + // classInfo.extend = "Scene"; + struct MethodGenInfo methodAssets; methodAssets.name = "getRequiredAssets"; methodAssets.isOverride = true; methodAssets.type = "std::vector"; line(&methodAssets.body, "auto assMan = &this->game->assetManager;", ""); - line(&methodAssets.body, "std::vector assets;", ""); struct MethodGenInfo methodInit; methodInit.name = "stage"; methodInit.isOverride = true; - classInfo.includes.push_back("scene/Scene.hpp"); - + if(scene->extend.empty()) { + line(&methodAssets.body, "std::vector assets;", ""); + } else { + line(&methodAssets.body, "std::vector assets = " + baseClassName + "::getRequiredAssets();", ""); + line(&methodInit.body, baseClassName + "::stage();", ""); + } // Generate int32_t assetNumber = 0; diff --git a/src/dawntools/scenetool/SceneGen.hpp b/src/dawntools/scenetool/SceneGen.hpp index 8037faba..1cb5f1d5 100644 --- a/src/dawntools/scenetool/SceneGen.hpp +++ b/src/dawntools/scenetool/SceneGen.hpp @@ -4,7 +4,7 @@ // https://opensource.org/licenses/MIT #pragma once -#include "SceneParser.hpp" +#include "util/parser/SceneParser.hpp" #include "util/generator/SceneItemGenerator.hpp" namespace Dawn { diff --git a/src/dawntools/scenetool/SceneTool.cpp b/src/dawntools/scenetool/SceneTool.cpp index 5d852a4d..b780bb41 100644 --- a/src/dawntools/scenetool/SceneTool.cpp +++ b/src/dawntools/scenetool/SceneTool.cpp @@ -47,7 +47,7 @@ int32_t SceneTool::start() { SceneGen::generate(&outputData, &scene, ""); // Load output file from name and type - File outputFile = File(flags["output"] + "/scenes/TestScene.hpp"); + File outputFile = File(flags["output"] + "/scenes/" + scene.name + ".hpp"); if(!outputFile.mkdirp()) { std::cout << "Failed to create output directory!" << std::endl; return 1; diff --git a/src/dawntools/scenetool/SceneTool.hpp b/src/dawntools/scenetool/SceneTool.hpp index 9ad02c01..bb4f0a31 100644 --- a/src/dawntools/scenetool/SceneTool.hpp +++ b/src/dawntools/scenetool/SceneTool.hpp @@ -7,7 +7,7 @@ #include "util/DawnTool.hpp" #include "util/File.hpp" #include "util/Xml.hpp" -#include "SceneParser.hpp" +#include "util/parser/SceneParser.hpp" #include "SceneGen.hpp" namespace Dawn { diff --git a/src/dawntools/util/parser/CMakeLists.txt b/src/dawntools/util/parser/CMakeLists.txt index 1eb1ea68..359b300f 100644 --- a/src/dawntools/util/parser/CMakeLists.txt +++ b/src/dawntools/util/parser/CMakeLists.txt @@ -8,6 +8,7 @@ set(D ${CMAKE_CURRENT_LIST_DIR}) set( DAWN_TOOL_SOURCES ${DAWN_TOOL_SOURCES} + ${D}/SceneParser.cpp ${D}/SceneItemParser.cpp ${D}/SceneAssetParser.cpp ${D}/SceneItemComponentParser.cpp diff --git a/src/dawntools/scenetool/SceneParser.cpp b/src/dawntools/util/parser/SceneParser.cpp similarity index 92% rename from src/dawntools/scenetool/SceneParser.cpp rename to src/dawntools/util/parser/SceneParser.cpp index db94a195..bb24769a 100644 --- a/src/dawntools/scenetool/SceneParser.cpp +++ b/src/dawntools/util/parser/SceneParser.cpp @@ -40,9 +40,6 @@ int32_t SceneParser::onParse( ret = (SceneItemParser()).parse(child, &item, error); if(ret != 0) return 1; out->items.push_back(item); - } else { - *error = "Unknown node type " + child->node; - return 1; } ++itChildren; diff --git a/src/dawntools/scenetool/SceneParser.hpp b/src/dawntools/util/parser/SceneParser.hpp similarity index 100% rename from src/dawntools/scenetool/SceneParser.hpp rename to src/dawntools/util/parser/SceneParser.hpp diff --git a/src/dawntools/vnscenetool/VNSceneParser.hpp b/src/dawntools/vnscenetool/VNSceneParser.hpp index 17f661c4..4072cd64 100644 --- a/src/dawntools/vnscenetool/VNSceneParser.hpp +++ b/src/dawntools/vnscenetool/VNSceneParser.hpp @@ -6,10 +6,11 @@ #pragma once #include "VNSceneItemParser.hpp" #include "events/VNSceneEventsParser.hpp" +#include "util/parser/SceneItemParser.hpp" namespace Dawn { struct VNScene { - std::vector items; + struct Scene scene; struct VNSceneEventList events; };