From 450663594fc353647dd474694cb73eb3fb63778f Mon Sep 17 00:00:00 2001 From: Misa Date: Tue, 30 Jun 2020 23:35:59 -0700 Subject: [PATCH] Add G keybind to go to room Ved has this useful feature where instead of having to manually travel to a room whose coordinates you know, you can just press G and type in coordinates to go there. VCE added this, but I changed the text to be "x,y" instead of "(x,y)" because otherwise it could confuse someone into thinking they need to type parentheses when in reality they don't need to and typing them will just make it not work. Also I made sure to add an error message if the user types in an invalid format. Failing silently would just confuse people, and maybe they'll start thinking the feature doesn't work or something like that. VCE doesn't have this helpful error message. Lastly, VCE has a bug where if you use the shortcut to go from one horizontally/vertically warping room to another, the background of the previous room will still be there and scroll off with the background of the room you went to, instead of just having the new background only. This is because they forgot a 'graphics.backgrounddrawn = false;'. But don't worry, *I* didn't forget about it. --- desktop_version/src/editor.cpp | 20 ++++++++++++++++++++ desktop_version/src/editor.h | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 2c95d3eb..301b4668 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -4295,6 +4295,20 @@ void editorinput() key.disabletextentry(); switch (ed.textmod) { + case TEXT_GOTOROOM: + { + std::vector coords = split(key.keybuffer, ','); + if (coords.size() != 2) + { + ed.note = "[ ERROR: Invalid format ]"; + ed.notedelay = 45; + break; + } + ed.levx = clamp(atoi(coords[0].c_str()) - 1, 0, ed.mapwidth - 1); + ed.levy = clamp(atoi(coords[1].c_str()) - 1, 0, ed.mapheight - 1); + graphics.backgrounddrawn = false; + break; + } case TEXT_LOAD: { std::string loadstring = ed.filename + ".vvvvvv"; @@ -4692,6 +4706,12 @@ void editorinput() ed.getlin(TEXT_ROOMNAME, "Enter new room name:", &(ed.level[ed.levx+(ed.levy*ed.maxwidth)].roomname)); game.mapheld=true; } + if (key.keymap[SDLK_g]) + { + ed.keydelay = 6; + ed.getlin(TEXT_GOTOROOM, "Enter room coordinates x,y:", NULL); + game.mapheld=true; + } //Save and load if(key.keymap[SDLK_s]) diff --git a/desktop_version/src/editor.h b/desktop_version/src/editor.h index 34c94fa2..7072a801 100644 --- a/desktop_version/src/editor.h +++ b/desktop_version/src/editor.h @@ -18,7 +18,8 @@ enum textmode { TEXT_ROOMNAME, TEXT_SCRIPT, TEXT_ROOMTEXT, - LAST_EDTEXT = TEXT_ROOMTEXT, + TEXT_GOTOROOM, + LAST_EDTEXT = TEXT_GOTOROOM, // Settings-mode text fields TEXT_TITLE,