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

63 lines
1.3 KiB
C++
Raw Normal View History

2014-06-06 13:18:32 +02:00
#include "loadingstate.hpp"
#include "RWGame.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 all of the files waiting to be loaded.
auto world = getWorld();
// Loade all of the IDEs.
for(std::map<std::string, std::string>::iterator it = world->gameData.ideLocations.begin();
it != world->gameData.ideLocations.end();
++it) {
world->defineItems(it->second);
}
// Load IPLs
for(std::map<std::string, std::string>::iterator it = world->gameData.iplLocations.begin();
it != world->gameData.iplLocations.end();
++it) {
world->gameData.loadZone(it->second);
2014-06-06 13:18:32 +02:00
world->placeItems(it->second);
}
}
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
}
}
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...";
ti.screenPosition = glm::vec2( 50.f, 50.f );
ti.size = 10.f;
2015-02-07 23:55:06 +01:00
ti.font = 2;
r->text.renderText(ti);
2014-06-06 13:18:32 +02:00
}