2014-05-26 06:34:49 +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
|
|
|
{
|
2015-02-07 23:55:06 +01:00
|
|
|
Menu *m = new Menu(2);
|
|
|
|
m->offset = glm::vec2( 200.f, 200.f );
|
2014-05-26 06:34:49 +02:00
|
|
|
m->addEntry(Menu::lambda("Continue", [] { StateManager::get().exit(); }));
|
|
|
|
m->addEntry(Menu::lambda("Options", [] { std::cout << "Options" << std::endl; }));
|
2014-09-16 20:22:43 +02:00
|
|
|
m->addEntry(Menu::lambda("Exit", [&] { getWindow().close(); }));
|
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);
|
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)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-02-07 23:55:06 +01:00
|
|
|
void PauseState::draw(GameRenderer* r)
|
2015-01-25 18:54:31 +01:00
|
|
|
{
|
|
|
|
MapRenderer::MapInfo map;
|
|
|
|
|
2015-02-15 02:41:24 +01:00
|
|
|
auto& vp = r->getRenderer()->getViewport();
|
2015-02-07 23:55:06 +01:00
|
|
|
|
2015-02-15 02:41:24 +01:00
|
|
|
map.scale = 0.2f;
|
|
|
|
map.mapScreenTop = glm::vec2(vp.x, vp.y);
|
|
|
|
map.mapScreenBottom = glm::vec2(0.f, 0.f);
|
2015-01-25 18:54:31 +01:00
|
|
|
|
2015-03-05 17:36:14 +01:00
|
|
|
game->getRenderer()->map.draw(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
|
|
|
}
|
|
|
|
|
2014-05-26 06:34:49 +02:00
|
|
|
void PauseState::handleEvent(const sf::Event &e)
|
|
|
|
{
|
|
|
|
switch(e.type) {
|
|
|
|
case sf::Event::KeyPressed:
|
|
|
|
switch(e.key.code) {
|
|
|
|
case sf::Keyboard::Escape:
|
|
|
|
StateManager::get().exit();
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
State::handleEvent(e);
|
|
|
|
}
|