// 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;

  // First, pass as a standard scene
  ret = (SceneParser()).parse(node, &out->scene, error);
  if(ret != 0) return ret;

  // Now pass the VN Events
  auto itChildren = node->childNodes.begin();
  while(itChildren != node->childNodes.end()) {
    if(itChildren->nodeType != XML_NODE_TYPE_ELEMENT) {
      ++itChildren;
      continue;
    }

    Xml *child = itChildren->child;
    if(child->node != "events") {
      ++itChildren;
      continue;
    }
    ret = (VNSceneEventsParser()).parse(child, &out->events, error);
    if(ret != 0) return ret;
    break;
  }

  return 0;
}