X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=rogue_chat_curses.py;h=28588928314991db4b16dcfe2ee77bc0646d908d;hb=c4a74406fd9fc0f7d91ad428a9c28b5369e5c51a;hp=5046de199ce0f7c6db4f31bd176eded30235d002;hpb=dc2747c7daca975526206bfadecc1dd0ddcc8d67;p=plomrogue2 diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 5046de1..2858892 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -200,6 +200,11 @@ def cmd_CHAT(game, msg): game.tui.do_refresh = True cmd_CHAT.argtypes = 'string' +def cmd_CHATFACE(game, thing_id): + game.tui.draw_face = thing_id + game.tui.do_refresh = True +cmd_CHATFACE.argtypes = 'int:pos' + def cmd_PLAYER_ID(game, player_id): game.player_id = player_id cmd_PLAYER_ID.argtypes = 'int:nonneg' @@ -348,6 +353,7 @@ class Game(GameBase): 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) @@ -543,6 +549,7 @@ class TUI: self.fov = '' self.flash = False self.map_lines = [] + self.draw_face = False self.offset = YX(0,0) curses.wrapper(self.loop) @@ -957,6 +964,25 @@ class TUI: 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) @@ -1005,6 +1031,8 @@ class TUI: 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: @@ -1089,6 +1117,7 @@ class TUI: 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':