1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-19 17:01:44 +02:00
openrw/rwgame/states/LoadingState.cpp

48 lines
1.1 KiB
C++
Raw Normal View History

#include "LoadingState.hpp"
2015-04-05 03:12:54 +02:00
#include <render/OpenGLRenderer.hpp>
2016-09-09 22:13:20 +02:00
#include "RWGame.hpp"
2014-06-06 13:18:32 +02:00
2016-09-09 22:13:20 +02:00
LoadingState::LoadingState(RWGame* game) : State(game), next(nullptr) {
2014-06-06 13:18:32 +02:00
}
2016-09-09 22:13:20 +02:00
void LoadingState::enter() {
game->newGame();
2014-06-06 13:18:32 +02:00
}
2016-09-09 22:13:20 +02:00
void LoadingState::exit() {
2014-06-06 13:18:32 +02:00
}
2016-09-09 22:13:20 +02:00
void LoadingState::tick(float dt) {
RW_UNUSED(dt);
2016-08-02 13:00:05 +02:00
2016-09-09 22:13:20 +02:00
// If background work is completed, switch to the next state
if (getWorld()->_work->isEmpty()) {
StateManager::get().exec(next);
}
2014-06-06 13:18:32 +02:00
}
2016-09-09 22:13:20 +02:00
bool LoadingState::shouldWorldUpdate() {
return false;
}
2016-09-09 22:13:20 +02:00
void LoadingState::setNextState(State* nextState) {
next = nextState;
}
2016-09-09 22:13:20 +02:00
void LoadingState::handleEvent(const SDL_Event& e) {
State::handleEvent(e);
2014-06-06 13:18:32 +02:00
}
2016-09-09 22:13:20 +02:00
void LoadingState::draw(GameRenderer* r) {
static auto kLoadingString = GameStringUtil::fromString("Loading...");
// Display some manner of loading screen.
TextRenderer::TextInfo ti;
ti.text = kLoadingString;
auto size = r->getRenderer()->getViewport();
ti.size = 25.f;
ti.screenPosition = glm::vec2(50.f, size.y - ti.size - 50.f);
ti.font = 2;
ti.baseColour = glm::u8vec3(255);
r->text.renderText(ti);
2014-06-06 13:18:32 +02:00
}