2014-06-06 13:18:32 +02:00
|
|
|
#include "loadingstate.hpp"
|
|
|
|
#include "menustate.hpp"
|
2014-09-16 20:22:43 +02:00
|
|
|
#include "RWGame.hpp"
|
2014-06-06 13:18:32 +02:00
|
|
|
|
2014-09-16 20:22:43 +02:00
|
|
|
LoadingState::LoadingState(RWGame* game)
|
|
|
|
: State(game)
|
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) {
|
2014-12-16 00:13:33 +01:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
// Check to see if the GameWorld has run out of jobs
|
|
|
|
// (i.e. it's time to open the main menu)
|
|
|
|
if( getWorld()->_work->isEmpty() ) {
|
2014-09-16 20:22:43 +02:00
|
|
|
StateManager::get().exec(new MenuState(game));
|
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( -1.f, 0.5f );
|
|
|
|
ti.size = 0.1f;
|
|
|
|
ti.font = 2;
|
|
|
|
r->text.renderText(ti);
|
2014-06-06 13:18:32 +02:00
|
|
|
}
|