Starting new VN Structure
This commit is contained in:
		
							
								
								
									
										63
									
								
								src/dawntools/vnscenetool/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/dawntools/vnscenetool/CMakeLists.txt
									
									
									
									
									
										Normal 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()
 | 
			
		||||
							
								
								
									
										42
									
								
								src/dawntools/vnscenetool/VNSceneEventsParser.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/dawntools/vnscenetool/VNSceneEventsParser.cpp
									
									
									
									
									
										Normal 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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								src/dawntools/vnscenetool/VNSceneEventsParser.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/dawntools/vnscenetool/VNSceneEventsParser.hpp
									
									
									
									
									
										Normal 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;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										44
									
								
								src/dawntools/vnscenetool/VNSceneParser.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								src/dawntools/vnscenetool/VNSceneParser.cpp
									
									
									
									
									
										Normal 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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										25
									
								
								src/dawntools/vnscenetool/VNSceneParser.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/dawntools/vnscenetool/VNSceneParser.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 "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;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										43
									
								
								src/dawntools/vnscenetool/VNSceneTool.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/dawntools/vnscenetool/VNSceneTool.cpp
									
									
									
									
									
										Normal 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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										20
									
								
								src/dawntools/vnscenetool/VNSceneTool.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/dawntools/vnscenetool/VNSceneTool.hpp
									
									
									
									
									
										Normal 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();
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										10
									
								
								src/dawntools/vnscenetool/events/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src/dawntools/vnscenetool/events/CMakeLists.txt
									
									
									
									
									
										Normal 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
 | 
			
		||||
)
 | 
			
		||||
							
								
								
									
										25
									
								
								src/dawntools/vnscenetool/events/VNPositionParser.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/dawntools/vnscenetool/events/VNPositionParser.cpp
									
									
									
									
									
										Normal 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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										6
									
								
								src/dawntools/vnscenetool/events/VNPositionParser.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/dawntools/vnscenetool/events/VNPositionParser.hpp
									
									
									
									
									
										Normal 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
 | 
			
		||||
		Reference in New Issue
	
	Block a user