add ctrl+q shortcut to exit the game from anywhere
This commit is contained in:
parent
ab4cdf2aa1
commit
f2ac8a951c
@ -646,7 +646,10 @@ void EventProcess(SDL_Event event)
|
|||||||
engine->Exit();
|
engine->Exit();
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
engine->onKeyPress(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT);
|
if (event.key.keysym.sym == 'q' && (event.key.keysym.mod&KMOD_CTRL))
|
||||||
|
engine->ConfirmExit();
|
||||||
|
else
|
||||||
|
engine->onKeyPress(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
engine->onKeyRelease(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT);
|
engine->onKeyRelease(event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod&KMOD_SHIFT, event.key.keysym.mod&KMOD_CTRL, event.key.keysym.mod&KMOD_ALT);
|
||||||
|
@ -1327,22 +1327,6 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
|
|||||||
UpdateDrawMode();
|
UpdateDrawMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
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::Point senderPosition, std::string toolTip)
|
void GameView::ToolTip(ui::Point senderPosition, std::string toolTip)
|
||||||
{
|
{
|
||||||
// buttom button tooltips
|
// buttom button tooltips
|
||||||
@ -1579,7 +1563,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
|||||||
break;
|
break;
|
||||||
case SDLK_ESCAPE:
|
case SDLK_ESCAPE:
|
||||||
case 'q':
|
case 'q':
|
||||||
ExitPrompt();
|
ui::Engine::Ref().ConfirmExit();
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
c->ToggleAHeat();
|
c->ToggleAHeat();
|
||||||
|
@ -146,7 +146,6 @@ public:
|
|||||||
bool CtrlBehaviour(){ return ctrlBehaviour; }
|
bool CtrlBehaviour(){ return ctrlBehaviour; }
|
||||||
bool ShiftBehaviour(){ return shiftBehaviour; }
|
bool ShiftBehaviour(){ return shiftBehaviour; }
|
||||||
bool AltBehaviour(){ return altBehaviour; }
|
bool AltBehaviour(){ return altBehaviour; }
|
||||||
void ExitPrompt();
|
|
||||||
SelectMode GetSelectMode() { return selectMode; }
|
SelectMode GetSelectMode() { return selectMode; }
|
||||||
void BeginStampSelection();
|
void BeginStampSelection();
|
||||||
ui::Point GetPlaceSaveOffset() { return placeSaveOffset; }
|
ui::Point GetPlaceSaveOffset() { return placeSaveOffset; }
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "gui/interface/Window.h"
|
#include "gui/interface/Window.h"
|
||||||
#include "gui/interface/Engine.h"
|
#include "gui/interface/Engine.h"
|
||||||
|
#include "gui/dialogues/ConfirmPrompt.h"
|
||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
|
|
||||||
using namespace ui;
|
using namespace ui;
|
||||||
@ -73,6 +74,22 @@ void Engine::Exit()
|
|||||||
running_ = false;
|
running_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::ConfirmExit()
|
||||||
|
{
|
||||||
|
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 Engine::ShowWindow(Window * window)
|
void Engine::ShowWindow(Window * window)
|
||||||
{
|
{
|
||||||
windowOpenState = 0;
|
windowOpenState = 0;
|
||||||
|
@ -39,6 +39,7 @@ namespace ui
|
|||||||
inline long unsigned int LastTick() { return lastTick; }
|
inline long unsigned int LastTick() { return lastTick; }
|
||||||
inline void LastTick(long unsigned int tick) { lastTick = tick; }
|
inline void LastTick(long unsigned int tick) { lastTick = tick; }
|
||||||
void Exit();
|
void Exit();
|
||||||
|
void ConfirmExit();
|
||||||
void Break();
|
void Break();
|
||||||
void UnBreak();
|
void UnBreak();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user