Scene change support
This commit is contained in:
@@ -135,6 +135,12 @@ void VNSceneGen::test(
|
||||
break;
|
||||
}
|
||||
|
||||
case VN_SCENE_EVENT_TYPE_SCENE_CHANGE:
|
||||
initType = "VNSceneChangeEvent<" + event->sceneChange.scene + ">";
|
||||
toInclude = "games/vn/events/VNSceneChangeEvent.hpp";
|
||||
includes->push_back(event->sceneChange.include);
|
||||
break;
|
||||
|
||||
default:
|
||||
std::cout << "Unknown event type: " << event->type << std::endl;
|
||||
assertUnreachable();
|
||||
|
@@ -17,4 +17,5 @@ target_sources(vnscenetool
|
||||
VNChoiceEventParser.cpp
|
||||
VNChoiceSetEventParser.cpp
|
||||
VNIfEventParser.cpp
|
||||
VNSceneChangeEventParser.cpp
|
||||
)
|
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "VNSceneChangeEventParser.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
std::vector<std::string> VNSceneChangeEventParser::getRequiredAttributes() {
|
||||
return { "scene" };
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> VNSceneChangeEventParser::getOptionalAttributes() {
|
||||
return {};
|
||||
}
|
||||
|
||||
int32_t VNSceneChangeEventParser::onParse(
|
||||
Xml *node,
|
||||
std::map<std::string, std::string> values,
|
||||
struct VNSceneChangeEvent *out,
|
||||
std::string *error
|
||||
) {
|
||||
out->include = values["scene"] + ".hpp";
|
||||
|
||||
// Find last slash and take all string after that
|
||||
size_t lastSlash = values["scene"].find_last_of('/');
|
||||
if(lastSlash != std::string::npos) {
|
||||
out->scene = values["scene"].substr(lastSlash+1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
// 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 {
|
||||
struct VNSceneChangeEvent {
|
||||
std::string scene;
|
||||
std::string include;
|
||||
};
|
||||
|
||||
class VNSceneChangeEventParser : public XmlParser<struct VNSceneChangeEvent> {
|
||||
protected:
|
||||
std::vector<std::string> getRequiredAttributes() override;
|
||||
std::map<std::string, std::string> getOptionalAttributes() override;
|
||||
int32_t onParse(
|
||||
Xml *node,
|
||||
std::map<std::string, std::string> values,
|
||||
struct VNSceneChangeEvent *out,
|
||||
std::string *error
|
||||
) override;
|
||||
};
|
||||
}
|
@@ -80,6 +80,11 @@ int32_t VNSceneEventsParser::onParse(
|
||||
ret = (VNIfEventParser()).parse(child, &event.ifEvent, error);
|
||||
if(ret != 0) return ret;
|
||||
|
||||
} else if(child->node == "scene-change") {
|
||||
event.type = VN_SCENE_EVENT_TYPE_SCENE_CHANGE;
|
||||
ret = (VNSceneChangeEventParser()).parse(child, &event.sceneChange, error);
|
||||
if(ret != 0) return ret;
|
||||
|
||||
} else {
|
||||
*error = "Unknown child node '" + child->node + "'";
|
||||
return -1;
|
||||
|
@@ -14,6 +14,7 @@
|
||||
#include "VNChoiceEventParser.hpp"
|
||||
#include "VNChoiceSetEventParser.hpp"
|
||||
#include "VNIfEventParser.hpp"
|
||||
#include "VNSceneChangeEventParser.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
struct VNSceneEvent;
|
||||
@@ -32,7 +33,8 @@ namespace Dawn {
|
||||
VN_SCENE_EVENT_TYPE_GOTO_MARKER,
|
||||
VN_SCENE_EVENT_TYPE_CHOICES,
|
||||
VN_SCENE_EVENT_TYPE_CHOICE_SET,
|
||||
VN_SCENE_EVENT_TYPE_IF
|
||||
VN_SCENE_EVENT_TYPE_IF,
|
||||
VN_SCENE_EVENT_TYPE_SCENE_CHANGE
|
||||
};
|
||||
|
||||
struct VNParallelEvent {
|
||||
@@ -58,6 +60,7 @@ namespace Dawn {
|
||||
struct VNChoiceEvent choices;
|
||||
struct VNChoiceSetEvent choiceSet;
|
||||
struct VNIfEvent ifEvent;
|
||||
struct VNSceneChangeEvent sceneChange;
|
||||
};
|
||||
|
||||
class VNSceneEventsParser : public XmlParser<struct VNSceneEventList> {
|
||||
|
Reference in New Issue
Block a user