diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-04 15:39:24 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-08-04 15:39:24 (GMT) |
| commit | f2f4278932e0752c22d15185ce70198077d0b5fd (patch) | |
| tree | d53cc28ba9a9020fc851fb3d89803a52a7d06436 /src/game | |
| parent | 055832270979cdb027c0c30a74cf82c23df13689 (diff) | |
| download | powder-f2f4278932e0752c22d15185ce70198077d0b5fd.zip powder-f2f4278932e0752c22d15185ce70198077d0b5fd.tar.gz | |
Better exiting from windows (Escape and Enter) and 'q' for exit, fixes #35 and #60
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/GameView.cpp | 21 | ||||
| -rw-r--r-- | src/game/GameView.h | 2 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index f58b145..5773be2 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -12,6 +12,7 @@ #include "interface/Slider.h" #include "search/Thumbnail.h" #include "simulation/SaveRenderer.h" +#include "dialogues/ConfirmPrompt.h" #include "Format.h" #include "QuickOption.h" @@ -888,6 +889,22 @@ void GameView::OnMouseUp(int x, int y, unsigned button) } } +void GameView::ExitPrompt() +{ + class ExitConfirmation: public ConfirmDialogueCallback { + public: + ExitConfirmation() {} + virtual void ConfirmCallback(ConfirmPrompt::DialogueResult result) { + if (result == ConfirmPrompt::ResultOkay) + { + ui::Engine::Ref().Exit(); + } + } + virtual ~ExitConfirmation() { } + }; + new ConfirmPrompt("You are about to quit", "Are you sure you want to exit the game?", new ExitConfirmation()); +} + void GameView::ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip) { this->toolTip = toolTip; @@ -1024,6 +1041,10 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool case 'y': c->SwitchAir(); break; + case KEY_ESCAPE: + case 'q': + ExitPrompt(); + break; case 'u': c->ToggleAHeat(); break; diff --git a/src/game/GameView.h b/src/game/GameView.h index 15bf0dc..7cb8d6b 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -142,6 +142,8 @@ public: void NotifyInfoTipChanged(GameModel * sender); void NotifyQuickOptionsChanged(GameModel * sender); + void ExitPrompt(); + virtual void ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip); virtual void OnMouseMove(int x, int y, int dx, int dy); |
