Improved the standardization of UI

This commit is contained in:
2022-12-08 23:00:33 -08:00
parent eb6c4c8076
commit a2ee1e139d
8 changed files with 85 additions and 36 deletions

View File

@ -4,31 +4,37 @@
// https://opensource.org/licenses/MIT
#pragma once
#include "ui/PokerGameBorder.hpp"
#include "visualnovel/ui/VisualNovelTextbox.hpp"
#include "asset/assets/TextureAsset.hpp"
#include "asset/assets/TrueTypeAsset.hpp"
namespace Dawn {
class PokerGameTextbox {
public:
static std::vector<Asset*> getAssets(AssetManager *man) {
return std::vector<Asset*>{
man->get<TrueTypeAsset>("truetype_ark"),
man->get<TextureAsset>("texture_test")
};
assertNotNull(man);
std::vector<Asset*> assets;
vectorAppend(&assets, &PokerGameBorder::getAssets(man));
assets.push_back(man->get<TrueTypeAsset>("truetype_ark"));
return assets;
}
static VisualNovelTextbox * create(UICanvas *canvas) {
auto assMan = &canvas->getGame()->assetManager;
static void apply(VisualNovelTextbox *textbox) {
assertNotNull(textbox);
auto assetFont = assMan->get<TrueTypeAsset>("truetype_ark");
auto assetTexture = assMan->get<TextureAsset>("texture_test");
auto textbox = canvas->addElement<VisualNovelTextbox>();
textbox->setBorder(&assetTexture->texture, glm::vec2(16, 16));
auto assetFont = textbox->getGame()->assetManager.get<TrueTypeAsset>("truetype_ark");
PokerGameBorder::apply(&textbox->border);
textbox->setFont(&assetFont->font);
textbox->setFontSize(40);
textbox->setLabelPadding(glm::vec2(10, 8));
}
static VisualNovelTextbox * create(UICanvas *canvas) {
assertNotNull(canvas);
auto textbox = canvas->addElement<VisualNovelTextbox>();
PokerGameTextbox::apply(textbox);
textbox->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_END,
glm::vec4(0, 238, 0, 0),