From: Christian Heller Date: Sun, 1 Nov 2020 01:47:06 +0000 (+0100) Subject: Add ability to edit portals to client. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/do_tasks?a=commitdiff_plain;h=56ca11424088772ce277fa439125b48a13049d0e;p=plomrogue2-experiments Add ability to edit portals to client. --- diff --git a/new2/rogue_chat_nocanvas_monochrome.html b/new2/rogue_chat_nocanvas_monochrome.html index 3e25304..c2c978e 100644 --- a/new2/rogue_chat_nocanvas_monochrome.html +++ b/new2/rogue_chat_nocanvas_monochrome.html @@ -258,6 +258,7 @@ let mode_play = new Mode('play / move around', false, false); let mode_study = new Mode('check map tiles for messages', false, true); let mode_edit = new Mode('write ASCII char to map tile', false, false); let mode_teleport = new Mode('teleport away?'); +let mode_portal = new Mode('add portal to map tile', true, true); let tui = { mode: mode_waiting_for_server, @@ -303,9 +304,14 @@ let tui = { if (mode == mode_annotate && explorer.position in explorer.info_db) { let info = explorer.info_db[explorer.position]; if (info != "(none)") { - this.inputEl.value = explorer.info_db[explorer.position]; + this.inputEl.value = info; this.recalc_input_lines(); } + } + if (mode == mode_portal && explorer.position in game.portals) { + let portal = game.portals[explorer.position] + this.inputEl.value = portal; + this.recalc_input_lines(); } else if (mode == mode_teleport) { tui.log_msg("Type Y or y to affirm teleportation, any other key to abort."); tui.log_msg("target: " + tui.teleport_target); @@ -526,6 +532,12 @@ let explorer = { msg = " "; // triggers annotation deletion } server.send(["ANNOTATE", unparser.to_yx(explorer.position), msg]); + }, + set_portal: function(msg) { + if (msg.length == 0) { + msg = " "; // triggers portal deletion + } + server.send(["PORTAL", unparser.to_yx(explorer.position), msg]); } } @@ -555,6 +567,9 @@ tui.inputEl.addEventListener('keydown', (event) => { if (tui.mode == mode_login && event.key == 'Enter') { server.send(['LOGIN', tui.inputEl.value]); tui.switch_mode(mode_login); + } else if (tui.mode == mode_portal && event.key == 'Enter') { + explorer.set_portal(tui.inputEl.value); + tui.switch_mode(mode_study, true); } else if (tui.mode == mode_annotate && event.key == 'Enter') { explorer.annotate(tui.inputEl.value); tui.switch_mode(mode_study, true); @@ -625,6 +640,9 @@ tui.inputEl.addEventListener('keydown', (event) => { tui.switch_mode(mode_chat); } else if (event.key == 'p') { tui.switch_mode(mode_play); + } else if (event.key === 'P') { + event.preventDefault(); + tui.switch_mode(mode_portal); } else if (event.key === tui.key_left) { explorer.move('left'); } else if (event.key === tui.key_right) {