1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 18:32:44 +01:00
openrw/rwgame/states/PauseState.cpp
Daniel Evans 398e184cd6 Use GameString in RWGame, using localised strings.
This adds:
- Localised GameStrings in the menus, replacing hard-coded strings
- Changes the default menu font to match the game
2016-08-23 00:05:25 +01:00

68 lines
1.4 KiB
C++

#include "PauseState.hpp"
#include "RWGame.hpp"
#include <ai/PlayerController.hpp>
#include <objects/CharacterObject.hpp>
PauseState::PauseState(RWGame* game)
: State(game)
{
auto data = game->getGameData();
auto& t = data->texts;
Menu *m = new Menu;
m->offset = glm::vec2( 200.f, 200.f );
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(); }));
this->enterMenu(m);
}
void PauseState::enter()
{
getWorld()->setPaused(true);
getWindow().showCursor();
}
void PauseState::exit()
{
getWorld()->setPaused(false);
}
void PauseState::tick(float dt)
{
RW_UNUSED(dt);
}
void PauseState::draw(GameRenderer* r)
{
MapRenderer::MapInfo map;
auto& vp = r->getRenderer()->getViewport();
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);
game->getRenderer()->map.draw(getWorld(), map);
State::draw(r);
}
void PauseState::handleEvent(const SDL_Event& e)
{
switch(e.type) {
case SDL_KEYDOWN:
switch(e.key.keysym.sym) {
case SDLK_ESCAPE:
StateManager::get().exit();
break;
default: break;
}
break;
default: break;
}
State::handleEvent(e);
}