diff --git a/addons/source-python/packages/source-python/menus/base.py b/addons/source-python/packages/source-python/menus/base.py index 16fc37169..7831f944b 100644 --- a/addons/source-python/packages/source-python/menus/base.py +++ b/addons/source-python/packages/source-python/menus/base.py @@ -201,6 +201,37 @@ def _close(self, player_index): """ raise NotImplementedError + def register_select_callback(self, callback): + """Register a select callback for the menu. + + Can and should be used as a decorator. + + :param callable callback: A function that gets called + whenever a selection was made. + + The callback will recieve 3 parameters: + 1. The instance of this menu. + 2. The player's index who made the selection. + 3. The player's choice. + """ + self.select_callback = callback + return callback + + def register_build_callback(self, callback): + """Register a build callback for the menu. + + Can and should be used as a decorator. + + :param callable callback: A function that gets called + before a menu is displayed. + + The callback will recieve 2 parameters: + 1. The instance of this menu. + 2. The index of the player who will recieve this menu. + """ + self.build_callback = callback + return callback + class _MenuData(object): """Base class for menu data.