+ draw_names: function() {
+ let players = [];
+ for (const thing_id in game.things) {
+ let t = game.things[thing_id];
+ if (t.type_ == 'Player') {
+ players.push(t);
+ }
+ };
+ function compare(a, b) {
+ if (a.name_.length > b.name_.length) {
+ return -1;
+ } else if (a.name_.length < b.name_.length) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ players.sort(compare);
+ const shrink_offset = Math.max(0, (terminal.rows - tui.left_window_width / 2) / 2);
+ let y = 0;
+ for (const player of players) {
+ let name = player.name_;
+ const offset_y = y - shrink_offset;
+ const max_len = Math.max(5, (tui.left_window_width / 2) - (offset_y * 2) - 8);
+ if (name.length > max_len) {
+ name = name.slice(0, max_len - 1) + '…';
+ }
+ terminal.write(y, 0, '@' + player.thing_char + ':' + name);
+ y += 1;
+ if (y >= terminal.rows) {
+ break;
+ }
+ }
+ },
+ draw_face_popup: function() {
+ const t = game.things[this.draw_face];
+ if (!t || !t.face) {
+ this.draw_face = false;
+ return;
+ }
+ const start_x = tui.left_window_width - 10;
+ function draw_body_part(body_part, end_y) {
+ terminal.write(end_y - 3, start_x, '----------');
+ terminal.write(end_y - 2, start_x, '| ' + body_part.slice(0, 6) + ' |');
+ terminal.write(end_y - 1, start_x, '| ' + body_part.slice(6, 12) + ' |');
+ terminal.write(end_y, start_x, '| ' + body_part.slice(12, 18) + ' |');
+ }
+ if (t.face) {
+ draw_body_part(t.face, terminal.rows - 3);
+ }
+ if (t.hat) {
+ draw_body_part(t.hat, terminal.rows - 6);
+ }
+ terminal.write(terminal.rows - 2, start_x, '----------');
+ let name = t.name_;
+ if (name.length > 7) {
+ name = name.slice(0, 6) + '…';
+ }
+ terminal.write(terminal.rows - 1, start_x, '@' + t.thing_char + ':' + name);
+ },