VN Textbox can now be any size

This commit is contained in:
2022-11-06 11:45:10 -08:00
parent db90bd1476
commit 6f4ab49caa
23 changed files with 1493 additions and 1317 deletions

View File

@ -1,14 +1,14 @@
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
DawnPokerGame.cpp
)
tool_texture(texture_test texture_test.png texture_test)
# Copyright (c) 2022 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DAWN_TARGET_NAME}
PRIVATE
DawnGame.cpp
)
tool_texture(texture_test texture_test.png texture_test)
add_dependencies(${DAWN_TARGET_NAME} texture_test)

View File

@ -1,72 +1,64 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnPokerGame.hpp"
#include "asset/assets/TextureAsset.hpp"
#include "asset/assets/TrueTypeAsset.hpp"
#include "visualnovel/ui/VisualNovelTextbox.hpp"
using namespace Dawn;
std::shared_ptr<TrueTypeAsset> assetFont;
std::shared_ptr<TextureAsset> assetTexture;
DawnGame::DawnGame(DawnHost &host) :
host(host),
renderManager(*this),
inputManager(*this)
{
}
int32_t DawnGame::init() {
this->assetManager.init();
this->renderManager.init();
this->scene = std::make_shared<Scene>(*this);
auto cameraObject = this->scene->createSceneItem();
auto camera = cameraObject->addComponent<Camera>();
camera->transform.lookAt(glm::vec3(50, 50, 50), glm::vec3(0, 0, 0));
auto canvas = UICanvas::createCanvas(this->scene);
assetFont = this->assetManager.load<TrueTypeAsset>("truetype_ark");
assetTexture = this->assetManager.load<TextureAsset>("texture_test");
while(!assetFont->loaded || !assetTexture->loaded) {
this->assetManager.update();
}
auto textbox = canvas->addElement<VisualNovelTextbox>();
textbox->setBorder(assetTexture->texture.get(), glm::vec2(16, 16));
textbox->setFont(&assetFont->font);
textbox->setText("1\n2\n3\n4\n5\n6\n7\n8\n9\n10", 40);
// auto sprite = canvas->addElement<UISprite>();
// sprite->setTransform(
// UI_COMPONENT_ALIGN_START,
// UI_COMPONENT_ALIGN_START,
// glm::vec4(0, 0, 200, 200),
// 0
// );
// sprite->texture = &asset->font.getTexture();
return DAWN_GAME_INIT_RESULT_SUCCESS;
}
int32_t DawnGame::update(float_t delta) {
this->assetManager.update();
this->inputManager.update();
this->timeManager.update(delta);
if(this->scene != nullptr) this->scene->update();
this->renderManager.update();
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
}
DawnGame::~DawnGame() {
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#include "DawnGame.hpp"
#include "asset/assets/TextureAsset.hpp"
#include "asset/assets/TrueTypeAsset.hpp"
#include "visualnovel/ui/VisualNovelTextbox.hpp"
using namespace Dawn;
std::shared_ptr<TrueTypeAsset> assetFont;
std::shared_ptr<TextureAsset> assetTexture;
DawnGame::DawnGame(DawnHost &host) :
host(host),
renderManager(*this),
inputManager(*this)
{
}
int32_t DawnGame::init() {
this->assetManager.init();
this->renderManager.init();
this->scene = std::make_shared<Scene>(*this);
auto cameraObject = this->scene->createSceneItem();
auto camera = cameraObject->addComponent<Camera>();
camera->transform.lookAt(glm::vec3(50, 50, 50), glm::vec3(0, 0, 0));
auto canvas = UICanvas::createCanvas(this->scene);
assetFont = this->assetManager.load<TrueTypeAsset>("truetype_ark");
assetTexture = this->assetManager.load<TextureAsset>("texture_test");
while(!assetFont->loaded || !assetTexture->loaded) {
this->assetManager.update();
}
auto textbox = canvas->addElement<VisualNovelTextbox>();
textbox->setBorder(assetTexture->texture.get(), glm::vec2(16, 16));
textbox->setFont(&assetFont->font);
textbox->setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus leo odio, egestas nec imperdiet ac, placerat eget quam. Nam tellus justo, aliquam sed porta quis, ullamcorper in libero. Proin auctor eget elit nec rutrum. Vestibulum tincidunt sem vel nisi sagittis, sed imperdiet eros aliquet. Fusce a ultrices augue, at auctor lacus. Sed lobortis, ante vitae vehicula egestas, lorem turpis cursus dui, sit amet egestas mauris ligula non ipsum. Pellentesque scelerisque posuere lorem sit amet tempor. Praesent ac hendrerit mi. Nulla mollis diam vitae vestibulum aliquam. Nullam metus justo, viverra sed risus eu, tincidunt sodales lacus. Quisque efficitur accumsan posuere. Aliquam posuere volutpat diam quis lacinia. Nullam blandit nulla vestibulum mi placerat varius. Proin egestas lacus nec pellentesque iaculis. Vestibulum ex metus, congue in eleifend et, scelerisque a nulla. Pellentesque cursus lectus sed arcu efficitur tincidunt. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla a felis non velit fermentum ullamcorper.", 40);
textbox->setTransform(
UI_COMPONENT_ALIGN_START, UI_COMPONENT_ALIGN_START,
glm::vec4(100, 100, 300, 300),
0.0f
);
return DAWN_GAME_INIT_RESULT_SUCCESS;
}
int32_t DawnGame::update(float_t delta) {
this->assetManager.update();
this->inputManager.update();
this->timeManager.update(delta);
if(this->scene != nullptr) this->scene->update();
this->renderManager.update();
return DAWN_GAME_UPDATE_RESULT_SUCCESS;
}

View File

@ -0,0 +1,23 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "game/_DawnGame.hpp"
#include "scene/components/Components.hpp"
namespace Dawn {
class DawnGame : public IDawnGame {
public:
DawnHost &host;
RenderManager renderManager;
AssetManager assetManager;
InputManager inputManager;
TimeManager timeManager;
DawnGame(DawnHost &host);
int32_t init() override;
int32_t update(float_t delta) override;
};
}

View File

@ -1,8 +0,0 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "game/DawnGame.hpp"
#include "scene/components/Components.hpp"