2020-01-06 00:02:32 -08:00
|
|
|
//
|
|
|
|
// Created by aurailus on 2019-12-28.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "LuaErrorScene.h"
|
2020-07-06 14:00:46 -07:00
|
|
|
|
2020-11-03 23:29:30 -08:00
|
|
|
#include "client/Client.h"
|
2020-08-13 00:55:18 -07:00
|
|
|
#include "client/graph/Font.h"
|
|
|
|
#include "client/graph/Renderer.h"
|
|
|
|
#include "client/gui/basic/GuiRect.h"
|
|
|
|
#include "client/gui/basic/GuiText.h"
|
2020-01-06 00:02:32 -08:00
|
|
|
|
2020-11-03 23:29:30 -08:00
|
|
|
LuaErrorScene::LuaErrorScene(Client& client, const std::string &err) : Scene(client), err(err) {
|
|
|
|
client.renderer.setClearColor(0, 0, 0);
|
|
|
|
client.renderer.window.input.lockMouse(false);
|
2020-01-06 00:02:32 -08:00
|
|
|
|
2020-11-03 23:29:30 -08:00
|
|
|
Font f(client.game->textures, client.game->textures["font"]);
|
|
|
|
glm::ivec2 win = client.renderer.window.getSize();
|
2020-01-06 00:02:32 -08:00
|
|
|
|
2020-02-20 16:58:36 -08:00
|
|
|
auto container = std::make_shared<GuiRect>("container");
|
2020-01-06 00:02:32 -08:00
|
|
|
container->create({800, 500}, {}, {0.05, 0.05, 0.05, 1});
|
|
|
|
container->setPos({win.x / 2 - 800 / 2, win.y / 2 - 500 / 2});
|
|
|
|
components.add(container);
|
|
|
|
|
2020-02-20 16:58:36 -08:00
|
|
|
auto titleText = std::make_shared<GuiText>("titleText");
|
2020-01-06 00:02:32 -08:00
|
|
|
titleText->create({3, 3}, {}, {}, {1, 0.4, 0.5, 1}, f);
|
|
|
|
titleText->setText("The Zepha sandbox has encountered an error.");
|
|
|
|
titleText->setPos({16, 12});
|
|
|
|
container->add(titleText);
|
|
|
|
|
2020-02-20 16:58:36 -08:00
|
|
|
auto errorText = std::make_shared<GuiText>("errorText");
|
2020-01-06 00:02:32 -08:00
|
|
|
errorText->create({2, 2}, {}, {}, {0.85, 0.85, 0.85, 1}, f);
|
|
|
|
errorText->setText(err);
|
|
|
|
errorText->setPos({16, 48});
|
|
|
|
container->add(errorText);
|
|
|
|
|
2020-11-03 23:29:30 -08:00
|
|
|
client.renderer.window.addResizeCallback("scene", [&](glm::ivec2 win) {
|
2020-02-20 16:58:36 -08:00
|
|
|
components.get<GuiRect>("container")->setPos({win.x / 2 - 800 / 2, win.y / 2 - 500 / 2});
|
2020-01-06 00:02:32 -08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void LuaErrorScene::update() {
|
2020-11-03 23:29:30 -08:00
|
|
|
client.game->textures.update();
|
2020-01-06 00:02:32 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void LuaErrorScene::draw() {
|
2020-11-03 23:29:30 -08:00
|
|
|
Renderer& renderer = client.renderer;
|
2020-01-06 00:02:32 -08:00
|
|
|
|
|
|
|
renderer.beginChunkDeferredCalls();
|
|
|
|
renderer.endDeferredCalls();
|
|
|
|
renderer.beginGUIDrawCalls();
|
2020-11-03 23:29:30 -08:00
|
|
|
renderer.enableTexture(&client.game->textures.atlasTexture);
|
2020-01-06 00:02:32 -08:00
|
|
|
|
|
|
|
components.draw(renderer);
|
|
|
|
|
|
|
|
renderer.swapBuffers();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LuaErrorScene::cleanup() {
|
2020-11-03 23:29:30 -08:00
|
|
|
client.renderer.window.removeResizeCallback("scene");
|
2020-01-06 00:02:32 -08:00
|
|
|
}
|