}
} else if (tokens[0] === 'CHAT') {
tui.log_msg('# ' + tokens[1], 1);
+ } else if (tokens[0] === 'CHATFACE') {
+ tui.draw_face = tokens[1];
} else if (tokens[0] === 'REPLY') {
tui.log_msg('#MUSICPLAYER: ' + tokens[1], 1);
} else if (tokens[0] === 'PLAYER_ID') {
offset: [0,0],
map_lines: [],
selectables: [],
+ draw_face: false,
init: function() {
this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter",
"command_thing", "take_thing", "drop_thing"]
terminal.write(term_y, term_x, to_draw);
}
},
+ draw_face_popup: function() {
+ const t = game.things[this.draw_face];
+ if (!t) {
+ this.draw_face = false;
+ return;
+ }
+ function draw_body_part(body_part, end_y) {
+ const start_x = tui.window_width - 10;
+ terminal.write(end_y - 4, start_x, '+--------+');
+ 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 - 1);
+ }
+ if (t.hat) {
+ draw_body_part(t.hat, terminal.rows - 4);
+ }
+ },
draw_mode_line: function() {
let help = 'hit [' + this.keys.help + '] for help';
if (this.mode.has_input_prompt) {
if (this.show_help) {
this.draw_help();
}
+ if (this.draw_face && ['chat', 'play'].includes(this.mode.name)) {
+ this.draw_face_popup();
+ }
if (!this.draw_links) {
this.links = {};
}
};
tui.inputEl.addEventListener('keydown', (event) => {
tui.show_help = false;
+ tui.draw_face = false;
if (event.key == 'Enter') {
event.preventDefault();
}
game.tui.do_refresh = True
cmd_CHAT.argtypes = 'string'
+def cmd_CHATFACE(game, thing_id):
+ game.tui.draw_face = thing_id
+cmd_CHATFACE.argtypes = 'int:pos'
+
def cmd_PLAYER_ID(game, player_id):
game.player_id = player_id
cmd_PLAYER_ID.argtypes = 'int:nonneg'
self.register_command(cmd_ADMIN_OK)
self.register_command(cmd_PONG)
self.register_command(cmd_CHAT)
+ self.register_command(cmd_CHATFACE)
self.register_command(cmd_REPLY)
self.register_command(cmd_PLAYER_ID)
self.register_command(cmd_TURN)
self.fov = ''
self.flash = False
self.map_lines = []
+ self.draw_face = False
self.offset = YX(0,0)
curses.wrapper(self.loop)
term_y += 1
map_y += 1
+ def draw_face_popup():
+ t = self.game.get_thing(self.draw_face)
+ if not t:
+ self.draw_face = False
+ return
+
+ def draw_body_part(body_part, end_y):
+ start_x = self.window_width - 10
+ safe_addstr(end_y - 4, start_x, '+--------+')
+ safe_addstr(end_y - 3, start_x, '| |')
+ safe_addstr(end_y - 2, start_x, '| ' + body_part[0:6] + ' |')
+ safe_addstr(end_y - 1, start_x, '| ' + body_part[6:12] + ' |')
+ safe_addstr(end_y, start_x, '| ' + body_part[12:18] + ' |')
+
+ if hasattr(t, 'face'):
+ draw_body_part(t.face, self.size.y - 1)
+ if hasattr(t, 'hat'):
+ draw_body_part(t.hat, self.size.y - 4)
+
def draw_help():
content = "%s help\n\n%s\n\n" % (self.mode.short_desc,
self.mode.help_intro)
draw_map()
if self.show_help:
draw_help()
+ if self.draw_face and self.mode.name in {'chat', 'play'}:
+ draw_face_popup()
def pick_selectable(task_name):
try:
if len(key) == 1:
keycode = ord(key)
self.show_help = False
+ self.draw_face = False
if key == 'KEY_RESIZE':
reset_screen_size()
elif self.mode.has_input_prompt and key == 'KEY_BACKSPACE':