1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-18 16:32:32 +02:00
openrw/rwgame/loadingstate.cpp
Daniel Evans 91065b6af4 Initial Save + Load implementation
* Fix VM Global Addressing
* Modify VM structures to simplify storage
* Add explicit GameWorld::createPlayer() method
* Move gameTime to GameState for storage
* Add SaveGame class for reading + writing
* New Dependancy: cereal
2015-05-03 05:23:44 +01:00

60 lines
1.1 KiB
C++

#include "loadingstate.hpp"
#include "RWGame.hpp"
#include <render/OpenGLRenderer.hpp>
LoadingState::LoadingState(RWGame* game)
: State(game), next(nullptr)
{
}
void LoadingState::enter()
{
// Load Item definitions
for( auto& def : game->getGameData()->ideLocations )
{
game->getGameData()->loadObjects(def.second);
}
game->newGame();
}
void LoadingState::exit()
{
}
void LoadingState::tick(float dt)
{
// If background work is completed, switch to the next state
if( getWorld()->_work->isEmpty() ) {
StateManager::get().exec(next);
}
}
bool LoadingState::shouldWorldUpdate()
{
return false;
}
void LoadingState::setNextState(State* nextState)
{
next = nextState;
}
void LoadingState::handleEvent(const sf::Event &e)
{
State::handleEvent(e);
}
void LoadingState::draw(GameRenderer* r)
{
// Display some manner of loading screen.
TextRenderer::TextInfo ti;
ti.text = "Loading...";
auto size = r->getRenderer()->getViewport();
ti.size = 25.f;
ti.screenPosition = glm::vec2( 50.f, size.y - ti.size - 50.f );
ti.font = 2;
r->text.renderText(ti);
}