Dawn/src/dawnpokergame/scenes/TestUIScene.cpp

54 lines
1.5 KiB
C++

// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "TestUIScene.hpp"
using namespace Dawn;
TestUIScene::TestUIScene(DawnGame *game) : Scene(game) {
}
std::vector<Asset*> TestUIScene::getRequiredAssets() {
std::vector<Asset*> assets;
AssetManager *man = &this->game->assetManager;
assets.push_back(man->get<TrueTypeAsset>("truetype_alice"));
assets.push_back(man->get<TextureAsset>("texture_test"));
return assets;
}
void TestUIScene::stage() {
AssetManager *man = &this->game->assetManager;
// Camera
this->camera = Camera::create(this);
this->camera->transform->lookAt(glm::vec3(3, 3, 3), glm::vec3(0, 0, 0));
auto testCube = SimpleSpinningCubePrefab::create(this);
// UI
this->canvas = UICanvas::create(this);
// auto text = man->get<TextureAsset>("texture_test");
// auto border = this->canvas->addElement<UIBorder>();
// border->texture = &text->texture;
// border->setBorderSize(glm::vec2(4, 4));
// border->setTransform(
// UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH,
// glm::vec4(0, 0, 0, 0),
// 0.0f
// );
auto assetFont = man->get<TrueTypeAsset>("truetype_alice");
auto label = this->canvas->addElement<UILabel>();
label->setFont(&assetFont->font);
label->setText("test.1");
label->setFontSize(24);
label->setTransform(
UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH,
glm::vec4(0, 0, 0, 0),
0.0f
);
}