2016-07-02 20:49:31 +02:00
|
|
|
#include "PauseState.hpp"
|
2014-09-16 20:22:43 +02:00
|
|
|
#include "RWGame.hpp"
|
2015-01-25 18:54:31 +01:00
|
|
|
#include <ai/PlayerController.hpp>
|
|
|
|
#include <objects/CharacterObject.hpp>
|
2014-05-26 06:34:49 +02:00
|
|
|
|
2014-09-16 20:22:43 +02:00
|
|
|
PauseState::PauseState(RWGame* game)
|
|
|
|
: State(game)
|
2014-05-26 06:34:49 +02:00
|
|
|
{
|
2016-08-16 01:28:35 +02:00
|
|
|
auto data = game->getGameData();
|
|
|
|
auto& t = data->texts;
|
|
|
|
|
|
|
|
Menu *m = new Menu;
|
2015-02-07 23:55:06 +01:00
|
|
|
m->offset = glm::vec2( 200.f, 200.f );
|
2016-08-16 01:28:35 +02:00
|
|
|
m->addEntry(Menu::lambda(t.text(MenuDefaults::kResumeGameId), [] { StateManager::get().exit(); }));
|
|
|
|
m->addEntry(Menu::lambda(t.text(MenuDefaults::kOptionsId), [] { std::cout << "Options" << std::endl; }));
|
|
|
|
m->addEntry(Menu::lambda(t.text(MenuDefaults::kQuitGameId), [] { StateManager::get().clear(); }));
|
2014-05-26 06:34:49 +02:00
|
|
|
this->enterMenu(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PauseState::enter()
|
|
|
|
{
|
2015-02-04 18:16:46 +01:00
|
|
|
getWorld()->setPaused(true);
|
2016-05-23 18:44:38 +02:00
|
|
|
|
2016-06-22 12:29:39 +02:00
|
|
|
getWindow().showCursor();
|
2014-05-26 06:34:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PauseState::exit()
|
|
|
|
{
|
2015-02-04 18:16:46 +01:00
|
|
|
getWorld()->setPaused(false);
|
2014-05-26 06:34:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PauseState::tick(float dt)
|
|
|
|
{
|
2016-08-02 13:00:05 +02:00
|
|
|
RW_UNUSED(dt);
|
2014-05-26 06:34:49 +02:00
|
|
|
}
|
|
|
|
|
2015-02-07 23:55:06 +01:00
|
|
|
void PauseState::draw(GameRenderer* r)
|
2015-01-25 18:54:31 +01:00
|
|
|
{
|
|
|
|
MapRenderer::MapInfo map;
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2015-02-15 02:41:24 +01:00
|
|
|
auto& vp = r->getRenderer()->getViewport();
|
2016-06-22 12:29:39 +02:00
|
|
|
|
2016-04-12 02:02:09 +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
|
|
|
|
2015-04-27 04:55:18 +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-06-22 12:29:39 +02:00
|
|
|
void PauseState::handleEvent(const SDL_Event& e)
|
2014-05-26 06:34:49 +02:00
|
|
|
{
|
|
|
|
switch(e.type) {
|
2016-06-22 12:29:39 +02:00
|
|
|
case SDL_KEYDOWN:
|
|
|
|
switch(e.key.keysym.sym) {
|
|
|
|
case SDLK_ESCAPE:
|
2014-05-26 06:34:49 +02:00
|
|
|
StateManager::get().exit();
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
State::handleEvent(e);
|
|
|
|
}
|