mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-03-21 23:00:03 +01:00
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();
|
||||
break;
|
||||
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;
|
||||
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);
|
||||
|
@ -1327,22 +1327,6 @@ void GameView::OnMouseUp(int x, int y, unsigned button)
|
||||
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)
|
||||
{
|
||||
// buttom button tooltips
|
||||
@ -1579,7 +1563,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
break;
|
||||
case SDLK_ESCAPE:
|
||||
case 'q':
|
||||
ExitPrompt();
|
||||
ui::Engine::Ref().ConfirmExit();
|
||||
break;
|
||||
case 'u':
|
||||
c->ToggleAHeat();
|
||||
|
@ -146,7 +146,6 @@ public:
|
||||
bool CtrlBehaviour(){ return ctrlBehaviour; }
|
||||
bool ShiftBehaviour(){ return shiftBehaviour; }
|
||||
bool AltBehaviour(){ return altBehaviour; }
|
||||
void ExitPrompt();
|
||||
SelectMode GetSelectMode() { return selectMode; }
|
||||
void BeginStampSelection();
|
||||
ui::Point GetPlaceSaveOffset() { return placeSaveOffset; }
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "Platform.h"
|
||||
#include "gui/interface/Window.h"
|
||||
#include "gui/interface/Engine.h"
|
||||
#include "gui/dialogues/ConfirmPrompt.h"
|
||||
#include "graphics/Graphics.h"
|
||||
|
||||
using namespace ui;
|
||||
@ -73,6 +74,22 @@ void Engine::Exit()
|
||||
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)
|
||||
{
|
||||
windowOpenState = 0;
|
||||
|
@ -39,6 +39,7 @@ namespace ui
|
||||
inline long unsigned int LastTick() { return lastTick; }
|
||||
inline void LastTick(long unsigned int tick) { lastTick = tick; }
|
||||
void Exit();
|
||||
void ConfirmExit();
|
||||
void Break();
|
||||
void UnBreak();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user