def query_info(self):
self.send('GET_ANNOTATION ' + str(self.explorer))
+ def restore_input_values(self):
+ if self.mode.name == 'annotate' and self.explorer in self.game.info_db:
+ info = self.game.info_db[self.explorer]
+ if info != '(none)':
+ self.input_ = info
+ elif self.mode.name == 'portal' and self.explorer in self.game.portals:
+ self.input_ = self.game.portals[self.explorer]
+ elif self.mode.name == 'password':
+ self.input_ = self.password
+
def switch_mode(self, mode_name, keep_position = False):
self.map_mode = 'terrain'
self.mode = getattr(self, 'mode_' + mode_name)
elif self.mode.name == 'teleport':
self.log_msg("@ May teleport to %s" % (self.teleport_target_host)),
self.log_msg("@ Enter 'YES!' to enthusiastically affirm.");
- elif self.mode.name == 'annotate' and self.explorer in self.game.info_db:
- info = self.game.info_db[self.explorer]
- if info != '(none)':
- self.input_ = info
- elif self.mode.name == 'portal' and self.explorer in self.game.portals:
- self.input_ = self.game.portals[self.explorer]
- elif self.mode.name == 'password':
- self.input_ = self.password
+ self.restore_input_values()
def loop(self, stdscr):
import time
elif self.mode.has_input_prompt and key == '\n' and self.input_ == '/help':
self.show_help = True
self.input_ = ""
+ self.restore_input_values()
elif self.mode.has_input_prompt and key != '\n': # Return key
self.input_ += key
max_length = self.window_width * self.size.y - len(input_prompt) - 1
}
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 {
}
} 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) {
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;