X-Git-Url: https://plomlompom.com/repos/todo?a=blobdiff_plain;f=rogue_chat_curses.py;h=7d2a3b163b0d3a05f4c0a24ffe1f2e3b2b67d95a;hb=01b6b1da2a94fe26d1ad44348afb133edcd2a273;hp=8eb70d65e7ced5f998e2f681c550e4e3ca07df41;hpb=87b8e08add4c032f4f0aa7f07f4964719bbc4236;p=plomrogue2 diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 8eb70d6..7d2a3b1 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -200,6 +200,10 @@ 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 +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 +352,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) @@ -475,10 +480,11 @@ class TUI: self.mode_control_tile_draw.available_modes = ["admin_enter"] self.mode_control_tile_draw.available_actions = ["move_explorer", "toggle_tile_draw"] - self.mode_edit.available_modes = ["write", "annotate", "portal", "name_thing", - "password", "chat", "study", "play", - "admin_enter", "enter_face"] - self.mode_edit.available_actions = ["move", "flatten", "toggle_map_mode"] + self.mode_edit.available_modes = ["write", "annotate", "portal", + "name_thing", "enter_face", "password", + "chat", "study", "play", "admin_enter"] + self.mode_edit.available_actions = ["move", "flatten", "install", + "toggle_map_mode"] self.mode = None self.host = host self.game = Game() @@ -542,6 +548,7 @@ class TUI: self.fov = '' self.flash = False self.map_lines = [] + self.draw_face = False self.offset = YX(0,0) curses.wrapper(self.loop) @@ -956,6 +963,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) @@ -1004,6 +1030,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: @@ -1088,6 +1116,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': @@ -1215,8 +1244,6 @@ class TUI: self.send('TASK:DOOR') elif key == self.keys['consume'] and task_action_on('consume'): self.send('TASK:INTOXICATE') - elif key == self.keys['install'] and task_action_on('install'): - self.send('TASK:INSTALL') elif key == self.keys['wear'] and task_action_on('wear'): self.send('TASK:WEAR') elif key == self.keys['spin'] and task_action_on('spin'): @@ -1250,6 +1277,8 @@ class TUI: continue elif key == self.keys['flatten'] and task_action_on('flatten'): self.send('TASK:FLATTEN_SURROUNDINGS ' + quote(self.password)) + elif key == self.keys['install'] and task_action_on('install'): + self.send('TASK:INSTALL %s' % quote(self.password)) elif key == self.keys['toggle_map_mode']: self.toggle_map_mode() elif key in self.movement_keys and task_action_on('move'):