Added default font editing to VN
This commit is contained in:
@ -9,7 +9,8 @@
|
||||
using namespace Dawn;
|
||||
|
||||
VNManager::VNManager(SceneItem *item) :
|
||||
SceneItemComponent(item)
|
||||
SceneItemComponent(item),
|
||||
defaultFont("<font font=\"font_main\">{{ text }}</font>")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
|
20
src/dawn/games/vn/events/VNSetDefaultFontEvent.hpp
Normal file
20
src/dawn/games/vn/events/VNSetDefaultFontEvent.hpp
Normal 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();
|
||||
}
|
||||
};
|
||||
}
|
@ -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;
|
||||
|
@ -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)();
|
||||
|
Reference in New Issue
Block a user