Keep on improving fonts.

This commit is contained in:
2023-01-24 14:49:31 -08:00
parent 6f75e8b7a4
commit dd83f2cefa
9 changed files with 133 additions and 8 deletions

View File

@ -8,4 +8,5 @@ target_sources(${DAWN_TARGET_NAME}
PRIVATE
PixelVNScene.cpp
PokerVNScene.cpp
TestUIScene.cpp
)

View File

@ -0,0 +1,54 @@
// 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
);
}

View File

@ -0,0 +1,25 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/Scene.hpp"
#include "game/DawnGame.hpp"
#include "scene/components/ui/UICanvas.hpp"
#include "ui/UILabel.hpp"
#include "ui/UIBorder.hpp"
#include "prefabs/SimpleSpinningCubePrefab.hpp"
namespace Dawn {
class TestUIScene : public Scene {
private:
Camera *camera = nullptr;
UICanvas *canvas = nullptr;
public:
TestUIScene(DawnGame *game);
std::vector<Asset*> getRequiredAssets() override;
void stage() override;
};
}