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

57 lines
1.2 KiB
C++
Raw Normal View History

2014-06-06 13:18:32 +02:00
#include "loadingstate.hpp"
#include "menustate.hpp"
#include "RWGame.hpp"
2014-06-06 13:18:32 +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) {
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() ) {
StateManager::get().exec(new MenuState(game));
2014-06-06 13:18:32 +02:00
}
}
void LoadingState::handleEvent(const sf::Event &e)
{
State::handleEvent(e);
}
void LoadingState::draw(sf::RenderWindow &w)
{
// Display some manner of loading screen.
sf::Text loadingText("Loading...", game->getFont(), 28);
2014-06-06 13:18:32 +02:00
loadingText.setPosition({30.f, 20.f});
w.draw(loadingText);
}