Restored UI Label support

This commit is contained in:
2024-09-10 17:36:04 -05:00
parent ca240bc180
commit e5f3f69120
17 changed files with 420 additions and 10 deletions

View File

@ -0,0 +1,22 @@
# Copyright (c) 2023 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Includes
target_include_directories(${DAWN_TARGET_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
dawnrpg.cpp
)
# Subdirs
add_subdirectory(scenes)
# Assets
include("${DAWN_ASSETS_SOURCE_DIR}/dawnrpg/CMakeLists.txt")

12
src/dawnrpg/dawnrpg.cpp Normal file
View File

@ -0,0 +1,12 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "scenes/SceneList.hpp"
using namespace Dawn;
const std::function<void(Scene&)> Scene::getInitialScene() {
return Dawn::testScene;
}

View File

@ -0,0 +1,9 @@
# Copyright (c) 2024 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DAWN_TARGET_NAME}
PRIVATE
TestScene.cpp
)

View File

@ -0,0 +1,11 @@
// Copyright (c) 2024 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/Scene.hpp"
namespace Dawn {
void testScene(Scene &scene);
}

View File

@ -0,0 +1,105 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "scenes/SceneList.hpp"
#include "component/display/Camera.hpp"
#include "prefab/SimpleSpinningCube.hpp"
#include "component/display/material/SimpleTexturedMaterial.hpp"
#include "display/mesh/CubeMesh.hpp"
#include "component/ui/UICanvas.hpp"
#include "ui/elements/UIRectangle.hpp"
#include "ui/elements/UILabel.hpp"
#include "ui/UIMenu.hpp"
#include "ui/container/UIRowContainer.hpp"
#include "ui/container/UIPaddingContainer.hpp"
#include "poker/PokerGame.hpp"
using namespace Dawn;
void Dawn::testScene(Scene &s) {
auto cameraItem = s.createSceneItem();
auto camera = cameraItem->addComponent<Camera>();
cameraItem->lookAt({ 3, 3, 3 }, { 0, 0, 0 }, { 0, 1, 0 });
camera->clipFar = 99999.99f;
auto cube = s.createSceneItem();
auto cubeMesh = std::make_shared<Mesh>();
auto cubeRenderer = cube->addComponent<MeshRenderer>();
auto cubeMaterial = cube->addComponent<SimpleTexturedMaterial>();
cubeRenderer->mesh = cubeMesh;
cubeMesh->createBuffers(CUBE_VERTICE_COUNT, CUBE_INDICE_COUNT);
CubeMesh::buffer(cubeMesh, glm::vec3(0,0,0), glm::vec3(1, 1, 1), 0, 0);
auto canvasItem = s.createSceneItem();
auto canvas = canvasItem->addComponent<UICanvas>();
auto container = std::make_shared<UIContainer>();
container->align = { 32, 32, UI_ALIGN_SIZE_AUTO, UI_ALIGN_SIZE_AUTO };
container->alignX = UIAlignmentType::START;
container->alignY = UIAlignmentType::START;
canvas->addElement(container);
auto rect = std::make_shared<UIRectangle>();
rect->align = { 0, 0, 32, 32 };
rect->alignX = UIAlignmentType::START;
rect->alignY = UIAlignmentType::START;
rect->color = COLOR_MAGENTA;
container->appendChild(rect);
auto texture = s.getGame()->assetManager.get<TrueTypeTexture>("font_silver", 128);
while(!s.getGame()->assetManager.isEverythingLoaded()) {
s.getGame()->assetManager.update();
}
auto label = std::make_shared<UILabel>();
label->align = { 0, 0, UI_ALIGN_SIZE_AUTO, UI_ALIGN_SIZE_AUTO };
label->alignX = UIAlignmentType::START;
label->alignY = UIAlignmentType::START;
label->setFont(texture);
label->setText(L"Hello World!");
container->appendChild(label);
// auto game = std::make_shared<PokerGame>();
// auto player0 = game->addNewPlayer();
// auto player1 = game->addNewPlayer();
// auto player2 = game->addNewPlayer();
// auto player3 = game->addNewPlayer();
// game->newGame();
// game->takeBlinds();
// game->dealToEveryone(2);
// std::shared_ptr<PokerPlayer> player;
// while((player = game->getCurrentBetter()) != nullptr) {
// auto turn = player->getAITurn();
// std::cout << "Player " << (int)player->playerIndex << " is taking turn: " << (int)turn.type << std::endl;
// turn.action();
// }
// std::cout << "Reveal flop" << std::endl;
// game->burnCard();
// game->turn();
// game->newBettingRound();
// while((player = game->getCurrentBetter()) != nullptr) {
// auto turn = player->getAITurn();
// std::cout << "Player " << (int)player->playerIndex << " is taking turn: " << (int)turn.type << std::endl;
// turn.action();
// }
// std::cout << "Reveal turn" << std::endl;
// game->burnCard();
// game->turn();
// game->newBettingRound();
// while((player = game->getCurrentBetter()) != nullptr) {
// auto turn = player->getAITurn();
// std::cout << "Player " << (int)player->playerIndex << " is taking turn: " << (int)turn.type << std::endl;
// turn.action();
// }
}