About to break VN Scene Parser
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
<Camera ref="camera" />
|
||||
</item>
|
||||
|
||||
<item lookAt="0, 0, 5, 0, 0, 0" >
|
||||
<!-- <item lookAt="0, 0, 5, 0, 0, 0" >
|
||||
<Camera fov="0.436332" ref="cameraNew" />
|
||||
<CameraTexture />
|
||||
</item>
|
||||
@ -21,5 +21,5 @@
|
||||
ref="image"
|
||||
/>
|
||||
</item>
|
||||
</item>
|
||||
</item> -->
|
||||
</scene>
|
@ -1,4 +1,4 @@
|
||||
<vnscene name="ExampleScene">
|
||||
<vnscene name="ExampleScene" extend="scene/ExtendedScene">
|
||||
<item ref="eth" prefab="prefabs/SimpleSpinningCubePrefab" />
|
||||
<item ref="craig" prefab="prefabs/SimpleSpinningCubePrefab" />
|
||||
<item ref="bg" prefab="prefabs/SimpleSpinningCubePrefab" />
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
@ -15,7 +15,6 @@ target_sources(scenetool
|
||||
${DAWN_SHARED_SOURCES}
|
||||
${DAWN_TOOL_SOURCES}
|
||||
SceneTool.cpp
|
||||
SceneParser.cpp
|
||||
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<Asset*>";
|
||||
line(&methodAssets.body, "auto assMan = &this->game->assetManager;", "");
|
||||
line(&methodAssets.body, "std::vector<Asset*> 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<Asset*> assets;", "");
|
||||
} else {
|
||||
line(&methodAssets.body, "std::vector<Asset*> assets = " + baseClassName + "::getRequiredAssets();", "");
|
||||
line(&methodInit.body, baseClassName + "::stage();", "");
|
||||
}
|
||||
|
||||
// Generate
|
||||
int32_t assetNumber = 0;
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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;
|
@ -6,10 +6,11 @@
|
||||
#pragma once
|
||||
#include "VNSceneItemParser.hpp"
|
||||
#include "events/VNSceneEventsParser.hpp"
|
||||
#include "util/parser/SceneItemParser.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
struct VNScene {
|
||||
std::vector<struct VNSceneItem> items;
|
||||
struct Scene scene;
|
||||
struct VNSceneEventList events;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user