Just breaking stuff
This commit is contained in:
77
archive/vnscenegen/parse/event/characterfadeevent.hpp
Normal file
77
archive/vnscenegen/parse/event/characterfadeevent.hpp
Normal 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);
|
||||
}
|
||||
};
|
||||
}
|
48
archive/vnscenegen/parse/event/pauseevent.hpp
Normal file
48
archive/vnscenegen/parse/event/pauseevent.hpp
Normal 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);
|
||||
}
|
||||
};
|
||||
}
|
101
archive/vnscenegen/parse/event/textevent.hpp
Normal file
101
archive/vnscenegen/parse/event/textevent.hpp
Normal 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);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user