Added default font editing to VN

This commit is contained in:
2023-07-12 22:17:11 -07:00
parent 4649469fee
commit 54932cd348
12 changed files with 129 additions and 8 deletions

View File

@ -9,7 +9,8 @@
using namespace Dawn;
VNManager::VNManager(SceneItem *item) :
SceneItemComponent(item)
SceneItemComponent(item),
defaultFont("<font font=\"font_main\">{{ text }}</font>")
{
}

View File

@ -23,6 +23,9 @@ namespace Dawn {
std::map<std::string, std::string> flags;
public:
// @optional
std::string defaultFont;
/**
* Constructs a visual novel manager, scene item component.
*

View 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 "VNEvent.hpp"
namespace Dawn {
class VNSetDefaultFontEvent : public VNEvent {
public:
std::string font;
protected:
void onStart() override {
this->manager->defaultFont = this->font;
this->next();
}
};
}

View File

@ -20,7 +20,8 @@ namespace Dawn {
scroller = this->getScene()->findComponent<VNTextboxScroller>();
assertNotNull(scroller);
scroller->label->richText = "<font font=\"font_main\" size=\"32\">" + text + "</font>";
auto richText = stringReplaceAll(this->manager->defaultFont, "{{ text }}", this->text);
scroller->label->richText = richText;
useEvent([&](inputbind_t bind){
if(bind != INPUT_BIND_ACCEPT) return;

View File

@ -79,7 +79,7 @@ void UIRichTextLabel::onStart() {
}
};
auto root = Xml::load("<root><font font=\"font_main\">" + ((std::string)this->richText) + "</font></root>");
auto root = Xml::load("<root>" + ((std::string)this->richText) + "</root>");
parseChildren(&root);
this->rebufferQuads(bufferTexts);
}, this->richText)();