home · contact · privacy
Don't lose input values by /help input.
[plomrogue2] / rogue_chat_nocanvas_monochrome.html
index 60418718fb57b9fb8a2535b85f6a46ce70c1cf8b..863495981002fd43669d341845b66111da9585de 100644 (file)
@@ -355,13 +355,8 @@ let tui = {
     }
     this.mode = mode;
     this.empty_input();
-    if (mode == mode_annotate && explorer.position in explorer.info_db) {
-        let info = explorer.info_db[explorer.position];
-        if (info != "(none)") {
-           this.inputEl.value = info;
-           this.recalc_input_lines();
-        }
-    } else if (mode == mode_login) {
+    this.restore_input_values();
+    if (mode == mode_login) {
         if (this.login_name) {
             server.send(['LOGIN', this.login_name]);
         } else {
@@ -369,19 +364,28 @@ let tui = {
         }
     } else if (mode == mode_edit) {
         this.show_help = true;
-    } else 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_password) {
-        this.inputEl.value = this.password;
-        this.recalc_input_lines();
     } else if (mode == mode_teleport) {
         tui.log_msg("@ May teleport to: " + tui.teleport_target);
         tui.log_msg("@ Enter 'YES!' to entusiastically affirm.");
     }
     this.full_refresh();
   },
+  restore_input_values: function() {
+      if (this.mode == mode_annotate && explorer.position in explorer.info_db) {
+          let info = explorer.info_db[explorer.position];
+          if (info != "(none)") {
+              this.inputEl.value = info;
+              this.recalc_input_lines();
+          }
+      } else if (this.mode == mode_portal && explorer.position in game.portals) {
+          let portal = game.portals[explorer.position]
+          this.inputEl.value = portal;
+          this.recalc_input_lines();
+      } else if (this.mode == mode_password) {
+          this.inputEl.value = this.password;
+          this.recalc_input_lines();
+      }
+  },
   empty_input: function(str) {
       this.inputEl.value = "";
       if (this.mode.has_input_prompt) {
@@ -743,6 +747,7 @@ tui.inputEl.addEventListener('keydown', (event) => {
     if (tui.mode.has_input_prompt && event.key == 'Enter' && tui.inputEl.value == '/help') {
         tui.show_help = true;
         tui.empty_input();
+        tui.restore_input_values();
         tui.full_refresh();
     } else if (!tui.mode.has_input_prompt && event.key == tui.keys.help) {
         tui.show_help = true;