def _get_menu_data(self, player_index): """Return all menu data as a :class:`keyvalues.KeyValues` object. :param int player_index: See :meth:`menus.base._BaseMenu._get_menu_data`. """ data = KeyValues('menu') data.set_string( 'msg', _translate_text(self.description or '', player_index)) if self.title is not None: data.set_string( 'title', _translate_text(self.title, player_index)) data.set_color('color', self.title_color) page = self._player_pages[player_index] page.options = {} # Loop through all options of the current page for raw_data in self: if isinstance(raw_data, SimpleESCOption): page.options[raw_data.choice_index] = raw_data button = data.find_key(str(raw_data.choice_index), True) button.set_string('msg', raw_data._render(player_index)) button.set_string('command', '{0} {1}'.format( ESC_SELECTION_CMD, raw_data.choice_index)) close = SimpleESCOption(0, 'Close') button = data.find_key(str(close.choice_index), True) button.set_string('msg', close._render(player_index)) button.set_string('command', '{0} {1}'.format( ESC_SELECTION_CMD, close.choice_index)) # Return the menu data return data
def _get_menu_data(self, player_index): """Return all relevant menu data as a KeyValues instance. @param <player_index>: A player index. """ data = KeyValues('menu') data.set_string( 'msg', _translate_text(self.description or '', player_index)) if self.title is not None: data.set_string( 'title', _translate_text(self.title, player_index)) data.set_color('color', self.title_color) page = self._player_pages[player_index] page.options = {} # Loop through all options of the current page for raw_data in self: if isinstance(raw_data, SimpleESCOption): page.options[raw_data.choice_index] = raw_data button = data.find_key(str(raw_data.choice_index), True) button.set_string('msg', raw_data._render(player_index)) button.set_string('command', '{0} {1}'.format( ESC_SELECTION_CMD, raw_data.choice_index)) close = SimpleESCOption(0, 'Close') button = data.find_key(str(close.choice_index), True) button.set_string('msg', close._render(player_index)) button.set_string('command', '{0} {1}'.format( ESC_SELECTION_CMD, close.choice_index)) # Return the menu data return data