// 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 TestUIScene::getRequiredAssets() { std::vector assets; AssetManager *man = &this->game->assetManager; assets.push_back(man->get("truetype_alice")); assets.push_back(man->get("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("texture_test"); // auto border = this->canvas->addElement(); // 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("truetype_alice"); auto grid = this->canvas->addElement(); grid->setTransform(UI_COMPONENT_ALIGN_STRETCH, UI_COMPONENT_ALIGN_STRETCH, glm::vec4(0, 0, 0, 0), 0); grid->setGridSize(4, 4, 8, 8); auto menu = new UIMenu(this->canvas, grid->getColumns(), grid->getRows()); for(int32_t x = 0; x < grid->getColumns(); x++) { for(int32_t y = 0; y < grid->getRows(); y++) { auto label = this->canvas->addElement(); label->setFont(&assetFont->font); label->setText("test.1"); label->setFontSize(24); grid->addToGrid(label, x, y, UI_COMPONENT_ALIGN_END, UI_COMPONENT_ALIGN_END); auto menuItem = new TestMenuItem; menuItem->label = label; menu->setItem(x, y, menuItem); } menu->setPosition(0, 0); this->canvas->setCurrentMenu(menu); } this->canvas->setCurrentMenu(menu); }