Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # May 2015
  2.  
  3. class SimpleMenu(object):
  4.     def on_item_selected(self, player_index, option):
  5.         """Called when an item has been selected.
  6.        
  7.        @param <player_index>:
  8.        The index of the player who made the selection.
  9.        
  10.        @param <option>:
  11.        The option that was selected.
  12.        
  13.        Return None to show the next menu in the menu queue. Return a menu to
  14.        immediately show it to the player.
  15.        """
  16.         return None
  17.        
  18.     def on_menu_close(self, player_index, caused_by_player):
  19.         """Called when the menu is about to be closed.
  20.        
  21.        @param <player_index>:
  22.        The index of the player who made the selection.
  23.        
  24.        @param <caused_by_player>:
  25.        This will be True if the player wants to close the menu. It will be
  26.        False if it was caused by a program.
  27.        
  28.        Return False if you want to block the request to close the menu.
  29.        """
  30.         return True
  31.        
  32.     def on_menu_show(self, player_index):
  33.         """Called when the menu should be shown.
  34.        
  35.        @param <player_index>:
  36.        The index of the player who should receive the menu.
  37.        
  38.        Return False if the menu shouldn't be shown. In that case the next
  39.        menu in the menu queue will be shown.
  40.        """
  41.         # If you want to set a timeout, you would probably do it here:
  42.         # self.set_timeout(30)
  43.         # self.get_timeout() should return None of a _Delay object
  44.         return True
  45.        
  46.     def on_menu_time_out(self, player_index):
  47.         """Called when the menu should time out.
  48.        
  49.        @param <player_index>:
  50.        The index of the player whose menu should time out.
  51.        """
  52.         self.close(player_index)
  53.        
  54.     def on_menu_refresh(self, player_index):
  55.         """Called when the menu should be refreshed.
  56.        
  57.        @param <player_index>:
  58.        The index of the player whose menu should get refreshed.
  59.        """
  60.         # This would be the build callback. If you want to update your menu,
  61.         # do it here.
  62.         pass
  63.        
  64.     def on_queue_changed(self, player_index, index):
  65.         """Called when the menu queue has been updated.
  66.        
  67.        @param <player_index>:
  68.        The index of the player whose queue has been updated.
  69.        
  70.        @param <index>:
  71.        The index of the menu in the queue (starting from 0).
  72.        """
  73.         pass
  74.        
  75. class PagedMenu(SimpleMenu):
  76.     def on_previous_page(self, player_index):
  77.         """Called when the previous page should be shown.
  78.        
  79.        @param <player_index>:
  80.        The index of the player who should get the previous page.
  81.        
  82.        Return the menu that should be shown.
  83.        """
  84.         return menu.show_previous_page(player_index)
  85.        
  86.     def on_next_page(self, player_index):
  87.         """Called when the next page should be shown.
  88.        
  89.        @param <player_index>:
  90.        The index of the player who should get the next page.
  91.        
  92.        Return the menu that should be shown.
  93.        """
  94.         return menu.show_next_page(player_index)