Starting new VN Structure

This commit is contained in:
2023-04-18 09:55:11 -07:00
parent 60a5a98ec5
commit 6d86fc10bc
72 changed files with 803 additions and 1761 deletions

View File

@ -20,4 +20,5 @@ include(util/CMakeLists.txt)
# Tools
add_subdirectory(prefabtool)
add_subdirectory(texturetool)
add_subdirectory(texturetool)
# add_subdirectory(vnscenetool)

View File

@ -0,0 +1,63 @@
# Copyright (c) 2023 Dominic Msters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Texture Build Tool
project(vnscenetool VERSION 1.0)
add_executable(vnscenetool)
# Subdirs
add_subdirectory(events)
# Sources
target_sources(vnscenetool
PRIVATE
${DAWN_SHARED_SOURCES}
${DAWN_TOOL_SOURCES}
VNSceneTool.cpp
VNSceneParser.cpp
VNSceneEventsParser.cpp
)
# Includes
target_include_directories(vnscenetool
PUBLIC
${DAWN_SHARED_INCLUDES}
${DAWN_TOOL_INCLUDES}
${CMAKE_CURRENT_LIST_DIR}
)
# Definitions
target_compile_definitions(vnscenetool
PUBLIC
${DAWN_SHARED_DEFINITIONS}
DAWN_TOOL_INSTANCE=VNSceneTool
DAWN_TOOL_HEADER="VNSceneTool.hpp"
)
# Libraries
target_link_libraries(vnscenetool
PUBLIC
${DAWN_BUILD_HOST_LIBS}
)
# Tool Function
function(tool_vnscene in)
set(DEPS "")
if(DAWN_BUILD_TOOLS)
set(DEPS vnscenetool)
endif()
STRING(REGEX REPLACE "[\.|\\|\/]" "-" prefab_name ${in})
add_custom_target(prefab_${prefab_name}
COMMAND vnscenetool --input="${DAWN_ASSETS_SOURCE_DIR}/${in}"
COMMENT "Generating prefab from ${in}"
DEPENDS ${DEPS}
)
target_include_directories(${DAWN_TARGET_NAME}
PUBLIC
${DAWN_GENERATED_DIR}/generatedprefabs
)
add_dependencies(${DAWN_TARGET_NAME} prefab_${prefab_name})
endfunction()

View File

@ -0,0 +1,42 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VNSceneEventsParser.hpp"
using namespace Dawn;
std::vector<std::string> VNSceneEventsParser::getRequiredAttributes() {
return { };
}
std::map<std::string, std::string> VNSceneEventsParser::getOptionalAttributes() {
return { };
}
int32_t VNSceneEventsParser::onParse(
Xml *node,
std::map<std::string, std::string> values,
struct VNSceneEvent *out,
std::string *error
) {
int32_t ret;
auto itChildren = node->children.begin();
while(itChildren != node->children.end()) {
Xml *child = *itChildren;
// Parse event(s)
if(child->node == "position") {
struct VNPosition position;
ret = (VNPositionParser()).parse(child, &position, error);
if(ret != 0) return ret;
out->position = position;
}
itChildren++;
}
return 0;
}

View File

@ -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"
#include "events/VNPositionParser.hpp"
namespace Dawn {
struct VNSceneEvent {
int32_t bruh;
};
class VNSceneEventsParser : public XmlParser<struct VNSceneEvent> {
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 VNSceneEvent *out,
std::string *error
) override;
};
}

View File

@ -0,0 +1,44 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VNSceneParser.hpp"
using namespace Dawn;
std::vector<std::string> VNSceneParser::getRequiredAttributes() {
return { };
}
std::map<std::string, std::string> VNSceneParser::getOptionalAttributes() {
return { };
}
int32_t VNSceneParser::onParse(
Xml *node,
std::map<std::string, std::string> values,
struct VNScene *out,
std::string *error
) {
//
int32_t ret;
auto itChildren = node->children.begin();
while(itChildren != node->children.end()) {
Xml *child = *itChildren;
// Parse event(s)
if(child->node == "events") {
struct VNSceneEvent scene;
ret = (VNSceneEventsParser()).parse(child, &scene, error);
if(ret != 0) return ret;
out->events.push_back(scene);
}
itChildren++;
}
return 0;
}

View 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 "VNSceneEventsParser.hpp"
namespace Dawn {
struct VNScene {
std::vector<struct VNSceneEvent> events;
};
class VNSceneParser : public XmlParser<struct VNScene> {
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 VNScene *out,
std::string *error
) override;
};
}

View File

@ -0,0 +1,43 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VNSceneTool.hpp"
using namespace Dawn;
std::vector<std::string> VNSceneTool::getRequiredFlags() {
return { "input" };
}
std::map<std::string, std::string> VNSceneTool::getOptionalFlags() {
return std::map<std::string, std::string>();
}
int32_t VNSceneTool::start() {
File input = File(flags["input"]);
if(!input.exists()) {
std::cout << "Input file does not exist!" << std::endl;
return 1;
}
std::string data;
if(!input.readString(&data)) {
std::cout << "Failed to read input file!" << std::endl;
return 1;
}
auto xml = Xml::load(data);
std::string error;
struct VNScene scene;
auto result = ((VNSceneParser()).parse(&xml, &scene, &error));
if(result != 0) {
std::cout << "Failed to parse scene: " << error << std::endl;
return result;
}
// Generate output
return 0;
}

View File

@ -0,0 +1,20 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "util/DawnTool.hpp"
#include "VNSceneParser.hpp"
#include "util/File.hpp"
namespace Dawn {
class VNSceneTool : public DawnTool {
protected:
std::vector<std::string> getRequiredFlags() override;
std::map<std::string, std::string> getOptionalFlags() override;
public:
int32_t start();
};
}

View File

@ -0,0 +1,10 @@
# Copyright (c) 2023 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(vnscenetool
PRIVATE
VNPositionParser.cpp
)

View File

@ -0,0 +1,25 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "VNPositionParser.hpp"
using namespace Dawn;
std::vector<std::string> VNPositionParser::getRequiredAttributes() {
return { };
}
std::map<std::string, std::string> VNPositionParser::getOptionalAttributes() {
return { };
}
int32_t VNPositionParser::onParse(
Xml *node,
std::map<std::string, std::string> values,
struct VNPosition *out,
std::string *error
) {
return 0;
}

View File

@ -0,0 +1,6 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once