Almost done with new language tools
This commit is contained in:
@ -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);
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user