Editor: Save map on CTRL+S or CMD+S
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
5201d10e20
commit
8b9ef16929
@ -1,3 +1,4 @@
|
|||||||
|
#include "SDL2/SDL_keyboard.h"
|
||||||
#include "editor_scenes.hpp"
|
#include "editor_scenes.hpp"
|
||||||
#include "../../sdlpp/sdlpp.hpp"
|
#include "../../sdlpp/sdlpp.hpp"
|
||||||
#include "../gui/gui.hpp"
|
#include "../gui/gui.hpp"
|
||||||
@ -796,6 +797,10 @@ void placeTool(SDLPP::Scene &scene) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool controlOrCommandPressed() {
|
||||||
|
return SDL_GetModState() & KMOD_CTRL || SDL_GetModState() & KMOD_GUI;
|
||||||
|
}
|
||||||
|
|
||||||
void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
|
void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
while (SDLPP::getSDLEvent(event)) {
|
while (SDLPP::getSDLEvent(event)) {
|
||||||
@ -804,9 +809,9 @@ void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
|
|||||||
setFlag(QUIT_FLAG);
|
setFlag(QUIT_FLAG);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
if (!getFlag(TEXT_INPUT_FLAG)) {
|
if (!getFlag(TEXT_INPUT_FLAG) && !controlOrCommandPressed()) {
|
||||||
handleKeyUp(event.key.keysym.sym, *scene);
|
handleKeyUp(event.key.keysym.sym, *scene);
|
||||||
} else {
|
} else if (!controlOrCommandPressed()) {
|
||||||
if (event.key.keysym.sym == SDLK_ESCAPE ||
|
if (event.key.keysym.sym == SDLK_ESCAPE ||
|
||||||
event.key.keysym.sym == SDLK_RETURN) {
|
event.key.keysym.sym == SDLK_RETURN) {
|
||||||
setFlag(STOP_TEXT_FLAG);
|
setFlag(STOP_TEXT_FLAG);
|
||||||
@ -819,16 +824,16 @@ void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
|
|||||||
!level_name_text.empty()) {
|
!level_name_text.empty()) {
|
||||||
level_name_text.pop_back();
|
level_name_text.pop_back();
|
||||||
setFlag(TEXT_UPDATE_FLAG);
|
setFlag(TEXT_UPDATE_FLAG);
|
||||||
} else if (event.key.keysym.sym == SDLK_c &&
|
} else if (event.key.keysym.sym == SDLK_c && controlOrCommandPressed()) {
|
||||||
SDL_GetModState() & KMOD_CTRL) {
|
|
||||||
// handle copy
|
// handle copy
|
||||||
SDL_SetClipboardText(level_name_text.c_str());
|
SDL_SetClipboardText(level_name_text.c_str());
|
||||||
} else if (event.key.keysym.sym == SDLK_v &&
|
} else if (event.key.keysym.sym == SDLK_v && controlOrCommandPressed()) {
|
||||||
SDL_GetModState() & KMOD_CTRL) {
|
|
||||||
// handle paste
|
// handle paste
|
||||||
level_name_text += SDL_GetClipboardText();
|
level_name_text += SDL_GetClipboardText();
|
||||||
setFlag(TEXT_UPDATE_FLAG);
|
setFlag(TEXT_UPDATE_FLAG);
|
||||||
}
|
}
|
||||||
|
} else if (event.key.keysym.sym == SDLK_s && controlOrCommandPressed()) {
|
||||||
|
saveMapCallback(nullptr, nullptr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
|
Loading…
Reference in New Issue
Block a user