Dawn/src/dawnhelloworld/scenes/HelloWorldScene.hpp

54 lines
1.7 KiB
C++

// 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 "prefabs/SimpleSpinningCubePrefab.hpp"
#include "scene/components/ui/UILabel.hpp"
#include "scene/components/ui/UIImage.hpp"
#include "display/font/BitmapFont.hpp"
namespace Dawn {
class HelloWorldScene : public Scene {
protected:
Camera *camera;
SimpleSpinningCubePrefab *cube;
UICanvas *canvas;
UILabel *label;
UIImage *image;
BitmapFont font;
void stage() override {
camera = Camera::create(this);
camera->transform->lookAt(glm::vec3(3, 3, 3), glm::vec3(0, 0, 0));
cube = SimpleSpinningCubePrefab::create(this);
canvas = UICanvas::create(this);
auto imageItem = this->createSceneItem();
image = imageItem->addComponent<UIImage>();
image->color = COLOR_BLACK;
imageItem->transform.setParent(canvas->transform);
auto labelItem = this->createSceneItem();
label = labelItem->addComponent<UILabel>();
labelItem->transform.setParent(canvas->transform);
label->text = "Hello World, how are you today? I hope you are doing well. I really like the fact I can ramble in my text for once.";
label->maxWidth = 220;
image->alignment = glm::vec4(0, 0, label->getContentWidth(), label->getContentHeight());
}
std::vector<Asset*> getRequiredAssets() override {
auto assMan = &this->game->assetManager;
std::vector<Asset*> assets;
vectorAppend(&assets, SimpleSpinningCubePrefab::getRequiredAssets(assMan));
return assets;
}
public:
HelloWorldScene(DawnGame *game) : Scene(game) {}
};
}