<button id="flatten">flatten surroundings</button>
<button id="switch_to_annotate">annotate tile</button>
<button id="switch_to_portal">edit portal</button>
+ <button id="switch_to_name_thing">name thing</button>
<button id="switch_to_password">enter map edit password</button>
</td>
</tr>
<li><input id="key_switch_to_study" type="text" value="?" />
<li><input id="key_switch_to_edit" type="text" value="E" />
<li><input id="key_switch_to_write" type="text" value="m" />
+<li><input id="key_switch_to_name_thing" type="text" value="N" />
<li><input id="key_switch_to_password" type="text" value="P" />
<li><input id="key_switch_to_admin_enter" type="text" value="A" />
<li><input id="key_switch_to_control_pw_type" type="text" value="C" />
'short': 'study',
'long': 'This mode allows you to study the map and its tiles in detail. Move the question mark over a tile, and the right half of the screen will show detailed information on it. Toggle the map view to show or hide different information layers.'},
'edit': {
- 'short': 'map edit',
- 'long': 'This mode allows you to change the map in various ways. Individual map tiles can be protected by "protection characters", which you can see by toggling into the protections map view. You can edit a tile if you set the map edit password that matches its protection character. The character "." marks the absence of protection: Such tiles can always be edited.'
+ 'short': 'world edit',
+ 'long': 'This mode allows you to change the game world in various ways. Individual map tiles can be protected by "protection characters", which you can see by toggling into the protections map view. You can edit a tile if you set the map edit password that matches its protection character. The character "." marks the absence of protection: Such tiles can always be edited.'
+ },
+ 'name_thing': {
+ 'short': 'name thing',
+ 'long': 'Give name to/change name of thing here.'
},
'write': {
'short': 'change terrain',
mode_control_pw_type: new Mode('control_pw_type', true),
mode_portal: new Mode('portal', true, true),
mode_password: new Mode('password', true),
+ mode_name_thing: new Mode('name_thing', true, true),
mode_admin_enter: new Mode('admin_enter', true),
mode_admin: new Mode('admin'),
mode_control_pw_pw: new Mode('control_pw_pw', true),
"control_tile_type", "chat",
"study", "play", "edit"]
this.mode_control_tile_draw.available_modes = ["admin_enter"]
- this.mode_edit.available_modes = ["write", "annotate", "portal",
+ this.mode_edit.available_modes = ["write", "annotate", "portal", "name_thing",
"password", "chat", "study", "play",
"admin_enter"]
this.mode = this.mode_waiting_for_server;
this.tile_draw = false;
if (mode_name == 'admin_enter' && this.is_admin) {
mode_name = 'admin';
+ } else if (mode_name == 'name_thing') {
+ let player_position = game.things[game.player_id].position;
+ let thing_id = null;
+ for (let t_id in game.things) {
+ if (t_id == game.player_id) {
+ continue;
+ }
+ let t = game.things[t_id];
+ if (player_position[0] == t.position[0] && player_position[1] == t.position[1]) {
+ thing_id = t_id;
+ break;
+ }
+ }
+ if (!thing_id) {
+ terminal.blink_screen();
+ this.log_msg('? not standing over thing');
+ return;
+ } else {
+ this.selected_thing_id = thing_id;
+ }
};
this.mode = this['mode_' + mode_name];
if (["control_tile_draw", "control_tile_type", "control_pw_type"].includes(this.mode.name)) {
explorer.query_info();
}
}
- this.empty_input();
+ this.inputEl.value = "";
this.restore_input_values();
for (let el of document.getElementsByTagName("button")) {
el.disabled = true;
document.getElementById("switch_to_write").disabled = false;
document.getElementById("switch_to_portal").disabled = false;
document.getElementById("switch_to_password").disabled = false;
+ document.getElementById("switch_to_name_thing").disabled = false;
document.getElementById("toggle_map_mode").disabled = false;
} else if (this.mode.name == 'admin') {
document.getElementById("switch_to_control_pw_type").disabled = false;
let info = explorer.info_db[explorer.position];
if (info != "(none)") {
this.inputEl.value = info;
- this.recalc_input_lines();
}
} else if (this.mode.name == 'portal' && explorer.position in game.portals) {
let portal = game.portals[explorer.position]
this.inputEl.value = portal;
- this.recalc_input_lines();
} else if (this.mode.name == 'password') {
this.inputEl.value = this.password;
- this.recalc_input_lines();
+ } else if (this.mode.name == 'name_thing') {
+ let t = game.get_thing(this.selected_thing_id);
+ if (t && t.name_) {
+ this.inputEl.value = t.name_;
+ }
}
},
- empty_input: function(str) {
- this.inputEl.value = "";
+ recalc_input_lines: function() {
if (this.mode.has_input_prompt) {
- this.recalc_input_lines();
+ let _ = null;
+ [this.input_lines, _] = this.msg_into_lines_of_width(this.input_prompt + this.inputEl.value, this.window_width);
} else {
- this.height_input = 0;
+ this.input_lines = [];
}
- },
- recalc_input_lines: function() {
- let _ = null;
- [this.input_lines, _] = this.msg_into_lines_of_width(this.input_prompt + this.inputEl.value, this.window_width);
this.height_input = this.input_lines.length;
},
msg_into_lines_of_width: function(msg, width) {
full_refresh: function() {
this.links = {};
terminal.drawBox(0, 0, terminal.rows, terminal.cols);
+ this.recalc_input_lines();
if (this.mode.is_intro) {
this.draw_history();
this.draw_input();
if (tui.inputEl.value.length > max_length) {
tui.inputEl.value = tui.inputEl.value.slice(0, max_length);
};
- tui.recalc_input_lines();
} else if (tui.mode.name == 'write' && tui.inputEl.value.length > 0) {
server.send(["TASK:WRITE", tui.inputEl.value[0], tui.password]);
tui.switch_mode('edit');
}
if (tui.mode.has_input_prompt && event.key == 'Enter' && tui.inputEl.value == '/help') {
tui.show_help = true;
- tui.empty_input();
+ tui.inputEl.value = "";
tui.restore_input_values();
} else if (!tui.mode.has_input_prompt && event.key == tui.keys.help
&& !tui.mode.is_single_char_entry) {
} else if (tui.mode.name == 'login' && event.key == 'Enter') {
tui.login_name = tui.inputEl.value;
server.send(['LOGIN', tui.inputEl.value]);
- tui.empty_input();
+ tui.inputEl.value = "";
} else if (tui.mode.name == 'control_pw_pw' && event.key == 'Enter') {
if (tui.inputEl.value.length == 0) {
tui.log_msg('@ aborted');
} else if (tui.mode.name == 'portal' && event.key == 'Enter') {
explorer.set_portal(tui.inputEl.value);
tui.switch_mode('edit');
+ } else if (tui.mode.name == 'name_thing' && event.key == 'Enter') {
+ if (tui.inputEl.value.length == 0) {
+ tui.inputEl.value = " ";
+ }
+ server.send(["THING_NAME", tui.selected_thing_id, tui.inputEl.value]);
+ tui.switch_mode('edit');
} else if (tui.mode.name == 'annotate' && event.key == 'Enter') {
explorer.annotate(tui.inputEl.value);
tui.switch_mode('edit');
} else if (tui.inputEl.valuelength > 0) {
server.send(['ALL', tui.inputEl.value]);
}
- tui.empty_input();
+ tui.inputEl.value = "";
} else if (tui.mode.name == 'play') {
if (tui.mode.mode_switch_on_key(event)) {
null;