About to break VN Scene Parser
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
<Camera ref="camera" />
|
<Camera ref="camera" />
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item lookAt="0, 0, 5, 0, 0, 0" >
|
<!-- <item lookAt="0, 0, 5, 0, 0, 0" >
|
||||||
<Camera fov="0.436332" ref="cameraNew" />
|
<Camera fov="0.436332" ref="cameraNew" />
|
||||||
<CameraTexture />
|
<CameraTexture />
|
||||||
</item>
|
</item>
|
||||||
@ -21,5 +21,5 @@
|
|||||||
ref="image"
|
ref="image"
|
||||||
/>
|
/>
|
||||||
</item>
|
</item>
|
||||||
</item>
|
</item> -->
|
||||||
</scene>
|
</scene>
|
@ -1,4 +1,4 @@
|
|||||||
<vnscene name="ExampleScene">
|
<vnscene name="ExampleScene" extend="scene/ExtendedScene">
|
||||||
<item ref="eth" prefab="prefabs/SimpleSpinningCubePrefab" />
|
<item ref="eth" prefab="prefabs/SimpleSpinningCubePrefab" />
|
||||||
<item ref="craig" prefab="prefabs/SimpleSpinningCubePrefab" />
|
<item ref="craig" prefab="prefabs/SimpleSpinningCubePrefab" />
|
||||||
<item ref="bg" 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)
|
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-base.xml)
|
||||||
tool_scene(${LIMINAL_ASSETS_DIR}/scenes/scene-extend.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_prefab(${LIMINAL_ASSETS_DIR}/VNTextbox.xml)
|
||||||
tool_truetype(font_main ${DAWN_ASSETS_DIR}/ark-pixel.ttf)
|
tool_truetype(font_main ${DAWN_ASSETS_DIR}/ark-pixel.ttf)
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
|
|
||||||
#include "game/DawnGame.hpp"
|
#include "game/DawnGame.hpp"
|
||||||
#include "scenes/HelloWorldScene.hpp"
|
#include "scenes/HelloWorldScene.hpp"
|
||||||
#include "scenes/TestScene.hpp"
|
#include "scenes/ExtendedScene.hpp"
|
||||||
|
|
||||||
using namespace Dawn;
|
using namespace Dawn;
|
||||||
|
|
||||||
Scene * Dawn::dawnGameGetInitialScene(DawnGame *game) {
|
Scene * Dawn::dawnGameGetInitialScene(DawnGame *game) {
|
||||||
// return new HelloWorldScene(game);
|
// return new HelloWorldScene(game);
|
||||||
return new TestScene(game);
|
return new ExtendedScene(game);
|
||||||
}
|
}
|
@ -15,7 +15,6 @@ target_sources(scenetool
|
|||||||
${DAWN_SHARED_SOURCES}
|
${DAWN_SHARED_SOURCES}
|
||||||
${DAWN_TOOL_SOURCES}
|
${DAWN_TOOL_SOURCES}
|
||||||
SceneTool.cpp
|
SceneTool.cpp
|
||||||
SceneParser.cpp
|
|
||||||
SceneGen.cpp
|
SceneGen.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,23 +14,44 @@ void SceneGen::generate(
|
|||||||
) {
|
) {
|
||||||
struct ClassGenInfo classInfo;
|
struct ClassGenInfo classInfo;
|
||||||
classInfo.clazz = scene->name;
|
classInfo.clazz = scene->name;
|
||||||
classInfo.extend = "Scene";
|
|
||||||
classInfo.constructorArgs = "DawnGame *game";
|
classInfo.constructorArgs = "DawnGame *game";
|
||||||
classInfo.extendArgs = "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;
|
struct MethodGenInfo methodAssets;
|
||||||
methodAssets.name = "getRequiredAssets";
|
methodAssets.name = "getRequiredAssets";
|
||||||
methodAssets.isOverride = true;
|
methodAssets.isOverride = true;
|
||||||
methodAssets.type = "std::vector<Asset*>";
|
methodAssets.type = "std::vector<Asset*>";
|
||||||
line(&methodAssets.body, "auto assMan = &this->game->assetManager;", "");
|
line(&methodAssets.body, "auto assMan = &this->game->assetManager;", "");
|
||||||
line(&methodAssets.body, "std::vector<Asset*> assets;", "");
|
|
||||||
|
|
||||||
struct MethodGenInfo methodInit;
|
struct MethodGenInfo methodInit;
|
||||||
methodInit.name = "stage";
|
methodInit.name = "stage";
|
||||||
methodInit.isOverride = true;
|
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
|
// Generate
|
||||||
int32_t assetNumber = 0;
|
int32_t assetNumber = 0;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// https://opensource.org/licenses/MIT
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "SceneParser.hpp"
|
#include "util/parser/SceneParser.hpp"
|
||||||
#include "util/generator/SceneItemGenerator.hpp"
|
#include "util/generator/SceneItemGenerator.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
|
@ -47,7 +47,7 @@ int32_t SceneTool::start() {
|
|||||||
SceneGen::generate(&outputData, &scene, "");
|
SceneGen::generate(&outputData, &scene, "");
|
||||||
|
|
||||||
// Load output file from name and type
|
// 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()) {
|
if(!outputFile.mkdirp()) {
|
||||||
std::cout << "Failed to create output directory!" << std::endl;
|
std::cout << "Failed to create output directory!" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "util/DawnTool.hpp"
|
#include "util/DawnTool.hpp"
|
||||||
#include "util/File.hpp"
|
#include "util/File.hpp"
|
||||||
#include "util/Xml.hpp"
|
#include "util/Xml.hpp"
|
||||||
#include "SceneParser.hpp"
|
#include "util/parser/SceneParser.hpp"
|
||||||
#include "SceneGen.hpp"
|
#include "SceneGen.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
|
@ -8,6 +8,7 @@ set(D ${CMAKE_CURRENT_LIST_DIR})
|
|||||||
set(
|
set(
|
||||||
DAWN_TOOL_SOURCES
|
DAWN_TOOL_SOURCES
|
||||||
${DAWN_TOOL_SOURCES}
|
${DAWN_TOOL_SOURCES}
|
||||||
|
${D}/SceneParser.cpp
|
||||||
${D}/SceneItemParser.cpp
|
${D}/SceneItemParser.cpp
|
||||||
${D}/SceneAssetParser.cpp
|
${D}/SceneAssetParser.cpp
|
||||||
${D}/SceneItemComponentParser.cpp
|
${D}/SceneItemComponentParser.cpp
|
||||||
|
@ -40,9 +40,6 @@ int32_t SceneParser::onParse(
|
|||||||
ret = (SceneItemParser()).parse(child, &item, error);
|
ret = (SceneItemParser()).parse(child, &item, error);
|
||||||
if(ret != 0) return 1;
|
if(ret != 0) return 1;
|
||||||
out->items.push_back(item);
|
out->items.push_back(item);
|
||||||
} else {
|
|
||||||
*error = "Unknown node type " + child->node;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
++itChildren;
|
++itChildren;
|
@ -6,10 +6,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "VNSceneItemParser.hpp"
|
#include "VNSceneItemParser.hpp"
|
||||||
#include "events/VNSceneEventsParser.hpp"
|
#include "events/VNSceneEventsParser.hpp"
|
||||||
|
#include "util/parser/SceneItemParser.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
struct VNScene {
|
struct VNScene {
|
||||||
std::vector<struct VNSceneItem> items;
|
struct Scene scene;
|
||||||
struct VNSceneEventList events;
|
struct VNSceneEventList events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user