+ def switch_to_pick_or_drop(target_widget):
+ self.item_pointer = 0
+ switch_widgets(map_widget, target_widget)
+ if self.examiner_mode:
+ self.examiner_mode = False
+ switch_widgets(descriptor_widget, log_widget)
+
+ def toggle_examiner_mode():
+ if self.examiner_mode:
+ self.examiner_mode = False
+ switch_widgets(descriptor_widget, log_widget)
+ else:
+ self.examiner_mode = True
+ self.examiner_position = self.game.world.player.position
+ switch_widgets(log_widget, descriptor_widget)
+ self.to_update['map'] = True
+
+ def toggle_popup():
+ if popup_widget.visible:
+ popup_widget.visible = False
+ for w in top_widgets:
+ w.ensure_freshness(True)
+ else:
+ self.to_update['popup'] = True
+ popup_widget.visible = True
+ popup_widget.reconfigure()
+ self.draw_popup_if_visible = True
+
+ def try_write_keys():
+ if len(key) == 1 and key in ASCII_printable and \
+ len(self.to_send) < len(edit_line_widget):
+ self.to_send += [key]
+ self.to_update['edit'] = True
+ elif key == 'KEY_BACKSPACE':
+ self.to_send[:] = self.to_send[:-1]
+ self.to_update['edit'] = True
+ elif key == '\n': # Return key
+ self.socket.send(''.join(self.to_send))
+ self.to_send[:] = []
+ self.to_update['edit'] = True
+
+ def try_examiner_keys():
+ if key == 'w':
+ move_examiner('UPLEFT')
+ elif key == 'e':
+ move_examiner('UPRIGHT')
+ elif key == 's':
+ move_examiner('LEFT')
+ elif key == 'd':
+ move_examiner('RIGHT')
+ elif key == 'x':
+ move_examiner('DOWNLEFT')
+ elif key == 'c':
+ move_examiner('DOWNRIGHT')
+
+ def try_player_move_keys():
+ if key == 'w':
+ self.socket.send('TASK:MOVE UPLEFT')
+ elif key == 'e':
+ self.socket.send('TASK:MOVE UPRIGHT')
+ elif key == 's':
+ self.socket.send('TASK:MOVE LEFT')
+ elif key == 'd':
+ self.socket.send('TASK:MOVE RIGHT')
+ elif key == 'x':
+ self.socket.send('TASK:MOVE DOWNLEFT')
+ elif key == 'c':
+ self.socket.send('TASK:MOVE DOWNRIGHT')
+
+ def init_colors():
+ curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_RED)
+ curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_GREEN)
+ curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_BLUE)
+ curses.init_pair(4, curses.COLOR_BLACK, curses.COLOR_YELLOW)
+