Dawn/archive/dawnpokergame/prefabs/ui/VisualNovelTextboxPrefab.hpp
2023-03-14 22:27:46 -07:00

43 lines
1.4 KiB
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "prefabs/ui/UIBorderPrefab.hpp"
#include "visualnovel/ui/VisualNovelTextbox.hpp"
namespace Dawn {
class VisualNovelTextboxPrefab :
public UIPrefab<VisualNovelTextbox, VisualNovelTextboxPrefab>
{
public:
static std::vector<Asset*> prefabAssets(AssetManager *man) {
std::vector<Asset*> assets;
assets.push_back(man->get<TrueTypeAsset>("truetype_bizudp"));
vectorAppend(&assets, UIBorderPrefab::getRequiredAssets(man));
return assets;
}
static void prefabApply(AssetManager *man, VisualNovelTextbox *textbox) {
auto assetFont = man->get<TrueTypeAsset>("truetype_bizudp");
UIBorderPrefab::apply(&textbox->border);
textbox->setFont(&assetFont->font);
textbox->setFontSize(36.0f);
textbox->setLabelPadding(glm::vec2(2, 2));
textbox->label.textColor = COLOR_WHITE;
textbox->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_END,
glm::vec4(
0,
(assetFont->font.getLineHeight(textbox->getFontSize()) * 4) +
(textbox->border.getBorderSize().y * 2.0f) +
(textbox->getLabelPadding().y * 2.0f),
0, 0
),
0.0f
);
}
};
}