Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # May 2015
- class SimpleMenu(object):
- def on_item_selected(self, player_index, option):
- """Called when an item has been selected.
- @param <player_index>:
- The index of the player who made the selection.
- @param <option>:
- The option that was selected.
- Return None to show the next menu in the menu queue. Return a menu to
- immediately show it to the player.
- """
- return None
- def on_menu_close(self, player_index, caused_by_player):
- """Called when the menu is about to be closed.
- @param <player_index>:
- The index of the player who made the selection.
- @param <caused_by_player>:
- This will be True if the player wants to close the menu. It will be
- False if it was caused by a program.
- Return False if you want to block the request to close the menu.
- """
- return True
- def on_menu_show(self, player_index):
- """Called when the menu should be shown.
- @param <player_index>:
- The index of the player who should receive the menu.
- Return False if the menu shouldn't be shown. In that case the next
- menu in the menu queue will be shown.
- """
- # If you want to set a timeout, you would probably do it here:
- # self.set_timeout(30)
- # self.get_timeout() should return None of a _Delay object
- return True
- def on_menu_time_out(self, player_index):
- """Called when the menu should time out.
- @param <player_index>:
- The index of the player whose menu should time out.
- """
- self.close(player_index)
- def on_menu_refresh(self, player_index):
- """Called when the menu should be refreshed.
- @param <player_index>:
- The index of the player whose menu should get refreshed.
- """
- # This would be the build callback. If you want to update your menu,
- # do it here.
- pass
- def on_queue_changed(self, player_index, index):
- """Called when the menu queue has been updated.
- @param <player_index>:
- The index of the player whose queue has been updated.
- @param <index>:
- The index of the menu in the queue (starting from 0).
- """
- pass
- class PagedMenu(SimpleMenu):
- def on_previous_page(self, player_index):
- """Called when the previous page should be shown.
- @param <player_index>:
- The index of the player who should get the previous page.
- Return the menu that should be shown.
- """
- return menu.show_previous_page(player_index)
- def on_next_page(self, player_index):
- """Called when the next page should be shown.
- @param <player_index>:
- The index of the player who should get the next page.
- Return the menu that should be shown.
- """
- return menu.show_next_page(player_index)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement