2016-07-02 20:49:31 +02:00
|
|
|
#include "PauseState.hpp"
|
2016-09-09 22:13:20 +02:00
|
|
|
#include "RWGame.hpp"
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
PauseState::PauseState(RWGame* game) : State(game) {
|
2016-10-16 21:37:07 +02:00
|
|
|
auto& t = game->getGameData().texts;
|
2016-08-16 01:28:35 +02:00
|
|
|
|
2016-10-18 23:00:53 +02:00
|
|
|
auto menu = Menu::create(
|
|
|
|
{{t.text(MenuDefaults::kResumeGameId), [&] { done(); }},
|
|
|
|
{t.text(MenuDefaults::kOptionsId),
|
|
|
|
[] { std::cout << "Options" << std::endl; }},
|
|
|
|
{t.text(MenuDefaults::kQuitGameId),
|
|
|
|
[] { StateManager::get().clear(); }}});
|
|
|
|
menu->offset = glm::vec2(200.f, 200.f);
|
|
|
|
enterMenu(menu);
|
2014-05-26 06:34:49 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void PauseState::enter() {
|
|
|
|
getWorld()->setPaused(true);
|
2016-05-23 18:44:38 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
getWindow().showCursor();
|
2014-05-26 06:34:49 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void PauseState::exit() {
|
|
|
|
getWorld()->setPaused(false);
|
2014-05-26 06:34:49 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void PauseState::tick(float dt) {
|
|
|
|
RW_UNUSED(dt);
|
2014-05-26 06:34:49 +02:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void PauseState::draw(GameRenderer* r) {
|
|
|
|
MapRenderer::MapInfo map;
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
auto& vp = r->getRenderer()->getViewport();
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
map.worldSize = 4000.f;
|
|
|
|
map.clipToSize = false;
|
|
|
|
map.screenPosition = glm::vec2(vp.x / 2, vp.y / 2);
|
|
|
|
map.screenSize = std::max(vp.x, vp.y);
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-10-16 21:37:07 +02:00
|
|
|
game->getRenderer().map.draw(getWorld(), map);
|
2015-01-25 18:54:31 +01:00
|
|
|
|
2015-02-07 23:55:06 +01:00
|
|
|
State::draw(r);
|
2015-01-25 18:54:31 +01:00
|
|
|
}
|
|
|
|
|
2016-09-09 22:13:20 +02:00
|
|
|
void PauseState::handleEvent(const SDL_Event& e) {
|
|
|
|
switch (e.type) {
|
|
|
|
case SDL_KEYDOWN:
|
|
|
|
switch (e.key.keysym.sym) {
|
|
|
|
case SDLK_ESCAPE:
|
2016-10-17 00:56:51 +02:00
|
|
|
done();
|
2016-09-09 22:13:20 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
State::handleEvent(e);
|
2014-05-26 06:34:49 +02:00
|
|
|
}
|