1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 18:32:44 +01:00
openrw/rwgame/loadingstate.cpp

60 lines
1.1 KiB
C++
Raw Normal View History

2014-06-06 13:18:32 +02:00
#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)
{
// 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;
}
2014-06-06 13:18:32 +02:00
void LoadingState::handleEvent(const sf::Event &e)
{
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;
r->text.renderText(ti);
2014-06-06 13:18:32 +02:00
}