1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-09 20:32:43 +01:00
openrw/rwgame/states/LoadingState.cpp

63 lines
1.1 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()
{
// Load Item definitions
for( auto& def : game->getGameData()->ideLocations )
{
game->getGameData()->loadObjects(def.second);
2014-06-06 13:18:32 +02:00
}
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
{
// Display some manner of loading screen.
2015-02-07 23:55:06 +01:00
TextRenderer::TextInfo ti;
ti.text = "Loading...";
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
}