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 "../../sdlpp/sdlpp.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) {
|
||||
SDL_Event event;
|
||||
while (SDLPP::getSDLEvent(event)) {
|
||||
@ -804,9 +809,9 @@ void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
|
||||
setFlag(QUIT_FLAG);
|
||||
break;
|
||||
case SDL_KEYUP:
|
||||
if (!getFlag(TEXT_INPUT_FLAG)) {
|
||||
if (!getFlag(TEXT_INPUT_FLAG) && !controlOrCommandPressed()) {
|
||||
handleKeyUp(event.key.keysym.sym, *scene);
|
||||
} else {
|
||||
} else if (!controlOrCommandPressed()) {
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE ||
|
||||
event.key.keysym.sym == SDLK_RETURN) {
|
||||
setFlag(STOP_TEXT_FLAG);
|
||||
@ -819,16 +824,16 @@ void pollEvents(std::shared_ptr<SDLPP::Scene> &scene) {
|
||||
!level_name_text.empty()) {
|
||||
level_name_text.pop_back();
|
||||
setFlag(TEXT_UPDATE_FLAG);
|
||||
} else if (event.key.keysym.sym == SDLK_c &&
|
||||
SDL_GetModState() & KMOD_CTRL) {
|
||||
} else if (event.key.keysym.sym == SDLK_c && controlOrCommandPressed()) {
|
||||
// handle copy
|
||||
SDL_SetClipboardText(level_name_text.c_str());
|
||||
} else if (event.key.keysym.sym == SDLK_v &&
|
||||
SDL_GetModState() & KMOD_CTRL) {
|
||||
} else if (event.key.keysym.sym == SDLK_v && controlOrCommandPressed()) {
|
||||
// handle paste
|
||||
level_name_text += SDL_GetClipboardText();
|
||||
setFlag(TEXT_UPDATE_FLAG);
|
||||
}
|
||||
} else if (event.key.keysym.sym == SDLK_s && controlOrCommandPressed()) {
|
||||
saveMapCallback(nullptr, nullptr);
|
||||
}
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
|
Loading…
Reference in New Issue
Block a user