Marker progress
This commit is contained in:
@ -71,6 +71,12 @@ void VNSceneGen::test(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case VN_SCENE_EVENT_TYPE_MARKER:
|
||||||
|
initType = "VNDummyEvent";
|
||||||
|
toInclude = "games/vn/events/VNDummyEvent.hpp";
|
||||||
|
line(&afterLines, "auto marker_" + event->marker.name + " = " + eventName + ";", "");
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
std::cout << "Unknown event type: " << event->type << std::endl;
|
std::cout << "Unknown event type: " << event->type << std::endl;
|
||||||
assertUnreachable();
|
assertUnreachable();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
# Sources
|
# Sources
|
||||||
target_sources(vnscenetool
|
target_sources(vnscenetool
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
VNMarkerParser.cpp
|
||||||
VNSceneEventsParser.cpp
|
VNSceneEventsParser.cpp
|
||||||
VNPositionEventParser.cpp
|
VNPositionEventParser.cpp
|
||||||
VNTextEventParser.cpp
|
VNTextEventParser.cpp
|
||||||
|
26
src/dawntools/vnscenetool/events/VNGoToMarkerEventParser.cpp
Normal file
26
src/dawntools/vnscenetool/events/VNGoToMarkerEventParser.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (c) 2023 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#include "VNGoToMarkerEventParser.hpp"
|
||||||
|
|
||||||
|
using namespace Dawn;
|
||||||
|
|
||||||
|
std::vector<std::string> VNGoToMarkerEventParser::getRequiredAttributes() {
|
||||||
|
return { "name" };
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, std::string> VNGoToMarkerEventParser::getOptionalAttributes() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t VNGoToMarkerEventParser::onParse(
|
||||||
|
Xml *node,
|
||||||
|
std::map<std::string, std::string> values,
|
||||||
|
struct VNGoToMarkerEvent *out,
|
||||||
|
std::string *error
|
||||||
|
) {
|
||||||
|
out->name = values["name"];
|
||||||
|
return 0;
|
||||||
|
}
|
25
src/dawntools/vnscenetool/events/VNGoToMarkerEventParser.hpp
Normal file
25
src/dawntools/vnscenetool/events/VNGoToMarkerEventParser.hpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// 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 VNGoToMarkerEvent {
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
class VNGoToMarkerEventParser : public XmlParser<struct VNGoToMarkerEvent> {
|
||||||
|
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 VNGoToMarkerEvent *out,
|
||||||
|
std::string *error
|
||||||
|
) override;
|
||||||
|
};
|
||||||
|
}
|
32
src/dawntools/vnscenetool/events/VNMarkerParser.cpp
Normal file
32
src/dawntools/vnscenetool/events/VNMarkerParser.cpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) 2023 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#include "VNMarkerParser.hpp"
|
||||||
|
|
||||||
|
using namespace Dawn;
|
||||||
|
|
||||||
|
std::vector<std::string> VNMarkerParser::getRequiredAttributes() {
|
||||||
|
return { "name" };
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<std::string, std::string> VNMarkerParser::getOptionalAttributes() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t VNMarkerParser::onParse(
|
||||||
|
Xml *node,
|
||||||
|
std::map<std::string, std::string> values,
|
||||||
|
struct VNMarker *out,
|
||||||
|
std::string *error
|
||||||
|
) {
|
||||||
|
// Ensure name only contains letters, and numbers, no spaces or symbols
|
||||||
|
if(!std::regex_match(values["name"], std::regex("^[a-zA-Z0-9]+$"))) {
|
||||||
|
*error = "Marker name " + values["name"] + " must only contain letters and numbers.";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
out->name = values["name"];
|
||||||
|
return 0;
|
||||||
|
}
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "util/XmlParser.hpp"
|
#include "util/XmlParser.hpp"
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
struct VNMarker {
|
struct VNMarker {
|
||||||
|
@ -55,6 +55,11 @@ int32_t VNSceneEventsParser::onParse(
|
|||||||
ret = (VNParallelEventParser()).parse(child, &event.parallel, error);
|
ret = (VNParallelEventParser()).parse(child, &event.parallel, error);
|
||||||
if(ret != 0) return ret;
|
if(ret != 0) return ret;
|
||||||
|
|
||||||
|
} else if(child->node == "marker") {
|
||||||
|
event.type = VN_SCENE_EVENT_TYPE_MARKER;
|
||||||
|
ret = (VNMarkerParser()).parse(child, &event.marker, error);
|
||||||
|
if(ret != 0) return ret;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
*error = "Unknown child node '" + child->node + "'";
|
*error = "Unknown child node '" + child->node + "'";
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "VNSetEventParser.hpp"
|
#include "VNSetEventParser.hpp"
|
||||||
#include "VNWaitEventParser.hpp"
|
#include "VNWaitEventParser.hpp"
|
||||||
#include "VNParallelEventParser.hpp"
|
#include "VNParallelEventParser.hpp"
|
||||||
|
#include "VNMarkerParser.hpp"
|
||||||
|
|
||||||
namespace Dawn {
|
namespace Dawn {
|
||||||
struct VNSceneEvent;
|
struct VNSceneEvent;
|
||||||
@ -22,7 +23,8 @@ namespace Dawn {
|
|||||||
VN_SCENE_EVENT_TYPE_POSITION,
|
VN_SCENE_EVENT_TYPE_POSITION,
|
||||||
VN_SCENE_EVENT_TYPE_SET,
|
VN_SCENE_EVENT_TYPE_SET,
|
||||||
VN_SCENE_EVENT_TYPE_WAIT,
|
VN_SCENE_EVENT_TYPE_WAIT,
|
||||||
VN_SCENE_EVENT_TYPE_PARALLEL
|
VN_SCENE_EVENT_TYPE_PARALLEL,
|
||||||
|
VN_SCENE_EVENT_TYPE_MARKER
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VNParallelEvent {
|
struct VNParallelEvent {
|
||||||
@ -37,6 +39,7 @@ namespace Dawn {
|
|||||||
struct VNSetEvent set;
|
struct VNSetEvent set;
|
||||||
struct VNWaitEvent wait;
|
struct VNWaitEvent wait;
|
||||||
struct VNParallelEvent parallel;
|
struct VNParallelEvent parallel;
|
||||||
|
struct VNMarker marker;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VNSceneEventsParser : public XmlParser<struct VNSceneEventList> {
|
class VNSceneEventsParser : public XmlParser<struct VNSceneEventList> {
|
||||||
|
Reference in New Issue
Block a user