2016-07-02 20:49:31 +02:00
|
|
|
#include "LoadingState.hpp"
|
2016-09-09 22:13:20 +02:00
|
|
|
#include "RWGame.hpp"
|
2014-06-06 13:18:32 +02:00
|
|
|
|
2018-05-08 16:10:29 +02:00
|
|
|
LoadingState::LoadingState(RWGame* game, const std::function<void(void)>& callback)
|
2016-10-17 00:56:51 +02:00
|
|
|
: State(game), complete(callback) {
|
2014-06-06 13:18:32 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void LoadingState::enter() {
|
|
|
|
game->newGame();
|
2014-06-06 13:18:32 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void LoadingState::exit() {
|
2014-06-06 13:18:32 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void LoadingState::tick(float dt) {
|
|
|
|
RW_UNUSED(dt);
|
2016-08-02 13:00:05 +02:00
|
|
|
|
2016-12-02 01:56:38 +01:00
|
|
|
done();
|
|
|
|
complete();
|
2014-06-06 13:18:32 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
bool LoadingState::shouldWorldUpdate() {
|
|
|
|
return false;
|
2015-04-03 16:38:24 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void LoadingState::handleEvent(const SDL_Event& e) {
|
|
|
|
State::handleEvent(e);
|
2014-06-06 13:18:32 +02:00
|
|
|
}
|
|
|
|
|
2018-12-01 18:57:06 +01:00
|
|
|
void LoadingState::draw(GameRenderer& r) {
|
2016-09-09 22:13:20 +02:00
|
|
|
// Display some manner of loading screen.
|
|
|
|
TextRenderer::TextInfo ti;
|
2018-12-24 15:48:01 +01:00
|
|
|
ti.text = GameStringUtil::fromString("Loading...", FONT_ARIAL);
|
2018-12-01 18:57:06 +01:00
|
|
|
auto size = r.getRenderer().getViewport();
|
2016-09-09 22:13:20 +02:00
|
|
|
ti.size = 25.f;
|
|
|
|
ti.screenPosition = glm::vec2(50.f, size.y - ti.size - 50.f);
|
2018-12-24 15:48:01 +01:00
|
|
|
ti.font = FONT_ARIAL;
|
2016-09-09 22:13:20 +02:00
|
|
|
ti.baseColour = glm::u8vec3(255);
|
2018-12-01 18:57:06 +01:00
|
|
|
r.text.renderText(ti);
|
2014-06-06 13:18:32 +02:00
|
|
|
}
|