1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 11:22:45 +01:00
openrw/rwgame/states/LoadingState.cpp

58 lines
1.0 KiB
C++
Raw Normal View History

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