- def switch_widgets(self, widget_1, widget_2):
- widget_1.visible = False
- widget_2.visible = True
- x = widget_2.check_updates[0]
- self.to_update[x] = True
+ def setup_screen(stdscr):
+ self.stdscr = stdscr
+ self.stdscr.refresh() # will be called by getkey else, clearing screen
+ self.stdscr.timeout(10)
+
+ def switch_widgets(widget_1, widget_2):
+ widget_1.visible = False
+ widget_2.visible = True
+ trigger = widget_2.check_updates[0]
+ self.to_update[trigger] = True
+
+ def pick_or_drop_menu(action_key, widget, selectables, task,
+ bonus_command=None):
+ if len(selectables) < self.item_pointer + 1 and\
+ self.item_pointer > 0:
+ self.item_pointer = len(selectables) - 1
+ if key == 'c':
+ switch_widgets(widget, map_widget)
+ elif key == 'j':
+ self.item_pointer += 1
+ elif key == 'k' and self.item_pointer > 0:
+ self.item_pointer -= 1
+ elif key == action_key and len(selectables) > 0:
+ id_ = selectables[self.item_pointer]
+ self.socket.send('TASK:%s %s' % (task, id_))
+ if bonus_command:
+ self.socket.send(bonus_command)
+ if self.item_pointer > 0:
+ self.item_pointer -= 1
+ else:
+ return
+ trigger = widget.check_updates[0]
+ self.to_update[trigger] = True