CLI command -keys

This commit is contained in:
Zeno Rogue 2022-04-26 13:27:09 +02:00
parent 64ece33a97
commit a788b9e540
2 changed files with 26 additions and 1 deletions

View File

@ -940,8 +940,9 @@ EX void mainloopiter() {
for(auto d: dialog::key_queue) {
println(hlog, "handling key ", d);
handlekey(d, d);
dialog::key_queue.erase(dialog::key_queue.begin());
break;
}
dialog::key_queue.clear();
while(SDL_PollEvent(&ev)) handle_event(ev);
fix_mouseh();

View File

@ -915,6 +915,30 @@ int read_cheat_args() {
for(int i=0; i<caflEND; i++) if(appears(mapeditor::canvasFloorName(i), args()))
canvasfloor = i;
}
else if(argis("-keys")) {
shift(); string s = args();
bool quote = false;
for(char c: s)
if(quote) {
quote = false;
if(c == '\\') dialog::queue_key(c), quote = false;
else if(c >= '1' && c <= '9') dialog::queue_key(SDLK_F1 + c - '1');
else if(c == 'e') dialog::queue_key(SDLK_ESCAPE);
else if(c == 'r') dialog::queue_key(SDLK_RETURN);
else if(c == 't') dialog::queue_key(SDLK_TAB);
else if(c == 'b') dialog::queue_key(SDLK_BACKSPACE);
else if(c == 'R') dialog::queue_key(SDLK_RIGHT);
else if(c == 'L') dialog::queue_key(SDLK_LEFT);
else if(c == 'U') dialog::queue_key(SDLK_UP);
else if(c == 'D') dialog::queue_key(SDLK_DOWN);
else if(c == 'H') dialog::queue_key(SDLK_HOME);
else if(c == 'E') dialog::queue_key(SDLK_END);
else if(c == 'P') dialog::queue_key(SDLK_PAGEUP);
else if(c == 'Q') dialog::queue_key(SDLK_PAGEDOWN);
}
else if(c == '\\') quote = true;
else dialog::queue_key(c);
}
else if(argis("-hroll")) {
shift();
int i = argi();