Just breaking stuff

This commit is contained in:
2023-03-14 22:27:46 -07:00
parent 795e69237c
commit 09cb20271b
156 changed files with 4218 additions and 4389 deletions

View File

@ -0,0 +1,77 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
// 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 "util/CodeGen.hpp"
namespace Dawn {
struct CharacterFadeEventInfo {
std::string character;
std::string duration;
std::string ease;
std::string fade;
std::string include;
};
class CharacterFadeParser : public XmlParser<struct CharacterFadeEventInfo> {
protected:
std::vector<std::string> getRequiredAttributes() {
return std::vector<std::string>{
"character"
};
}
std::map<std::string, std::string> getOptionalAttributes() {
return std::map<std::string, std::string>{
{ "fade", "in" },
{ "ease", "linear" },
{ "duration", "1" }
};
}
int32_t onParse(
Xml *node,
std::map<std::string, std::string> values,
struct CharacterFadeEventInfo *out,
std::string *error
) {
out->character = values["character"];
out->duration = parseDuration(values["duration"]);
out->ease = parseEase(values["ease"]);
out->fade = values["fade"] == "in" ? "true" : "false";
out->include = "visualnovel/events/characters/VisualNovelFadeCharacterEvent.hpp";
if(out->ease.size() == 0) {
*error = "Invalid ease";
return 1;
}
return 0;
}
};
class CharacterFadeGen : public CodeGen {
public:
static void generate(
std::vector<std::string> *out,
struct CharacterFadeEventInfo *info,
std::string tabs = ""
) {
line(out, "new VisualNovelFadeCharacterEvent(vnManager,", tabs + " ");
line(out, "this->" + info->character + "->vnCharacter,", tabs + " ");
line(out, info->fade + ",", tabs + " ");
line(out, info->ease + ",", tabs + " ");
line(out, info->duration, tabs + " ");
line(out, ")", tabs);
}
};
}

View File

@ -0,0 +1,48 @@
// 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 "util/CodeGen.hpp"
namespace Dawn {
struct PauseEventInfo {
std::string duration;
std::string include;
};
class PauseEventParser : public XmlParser<struct PauseEventInfo> {
protected:
std::vector<std::string> getRequiredAttributes() {
return std::vector<std::string>{ "duration" };
}
std::map<std::string, std::string> getOptionalAttributes() {
return std::map<std::string, std::string>();
}
int32_t onParse(
Xml *node,
std::map<std::string, std::string> values,
struct PauseEventInfo *out,
std::string *error
) {
out->duration = parseDuration(values["duration"]);
out->include = "visualnovel/events/timing/VisualNovelPauseEvent.hpp";
return 0;
}
};
class PauseEventGen : public CodeGen {
public:
static void generate(
std::vector<std::string> *out,
struct PauseEventInfo *info,
std::string tabs = ""
) {
line(out, "new VisualNovelPauseEvent(vnManager, " + info->duration + ")", tabs);
}
};
}

View File

@ -0,0 +1,101 @@
// 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 "util/CodeGen.hpp"
#include "util/Language.hpp"
namespace Dawn {
struct TextEventInfo {
std::string character;
std::string emotion;
std::vector<struct LanguageString> strings;
std::string key;
};
class TextStringParser : public XmlParser<struct LanguageString> {
protected:
std::vector<std::string> getRequiredAttributes() {
return std::vector<std::string>{ "lang" };
}
std::map<std::string, std::string> getOptionalAttributes() {
return std::map<std::string, std::string>();
}
int32_t onParse(
Xml *node,
std::map<std::string, std::string> values,
struct LanguageString *out,
std::string *error
) {
out->lang = values["lang"];
out->text = node->value;
return 0;
}
};
class TextEventParser : public XmlParser<struct TextEventInfo> {
protected:
std::vector<std::string> getRequiredAttributes() {
return std::vector<std::string>{
"character",
"emotion"
};
}
std::map<std::string, std::string> getOptionalAttributes() {
return std::map<std::string, std::string>();
}
int32_t onParse(
Xml *node,
std::map<std::string, std::string> values,
struct TextEventInfo *out,
std::string *error
) {
int32_t ret = 0;
out->character = values["character"];
out->emotion = values["emotion"];
if(out->key.size() <= 0) {
*error = "Text Event requries a language key to be defined.";
return 1;
}
auto itChildren = node->children.begin();
while(itChildren != node->children.end()) {
auto c = *itChildren;
if(c->node == "string") {
struct LanguageString str;
ret = (TextStringParser()).parse(c, &str, error);
str.key = out->key;
out->strings.push_back(str);
}
++itChildren;
}
return ret;
}
};
class TextEventGen : public CodeGen {
public:
static void generate(
std::vector<std::string> *out,
struct TextEventInfo *info,
std::string tabs = ""
) {
std::string emo = info->emotion;
emo[0] = toupper(emo[0]);
line(out, "new VisualNovelTextboxEvent(vnManager,", tabs);
line(out, "this->" + info->character + "->vnCharacter, ", tabs + " ");
line(out, "this->" + info->character + "->emotion" + emo + ", ", tabs + " ");
line(out, "\"" + info->key + "\"", tabs + " ");
line(out, ")", tabs);
}
};
}