def _close(self, player_index): """See :meth:`menus.base._BaseMenu._close`.""" queue = self.get_user_queue(player_index) queue.priority -= 1 # Unfortunately, this doesn't hide the menu :( data = KeyValues('menu') data.set_string('title', '') data.set_int('level', queue.priority) data.set_int('time', 10) data.set_string('msg', '') create_message(edict_from_index(player_index), DialogType.MENU, data)
def _close(self, player_index): """Close a menu by overriding it with an empty menu. @param <player_index>: A player index. """ queue = self.get_user_queue(player_index) queue.priority -= 1 # Unfortunately, this doesn't hide the menu :( data = KeyValues('menu') data.set_string('title', '') data.set_int('level', queue.priority) data.set_int('time', 10) data.set_string('msg', '') create_message(edict_from_index(player_index), DialogType.MENU, data)
def _send(self, player_index): """Build and send the menu to the given player via create_message(). :param int player_index: See :meth:`menus.base._BaseMenu._send`. """ queue = self.get_user_queue(player_index) queue.priority -= 1 # Build the menu data = self._build(player_index) # Set priority and display time data.set_int('level', queue.priority) data.set_int('time', 10) # Send the menu create_message(edict_from_index(player_index), DialogType.MENU, data)
def send(self, *player_indexes, **tokens): """Send the Dialog message to the appropriate recipients. :param player_indexes: Values can be a player index, multiple player indexes (star args), a :class:`filters.players.PlayerIter` instance, or a :class:`filters.recipients.RecipientFilter` instance. :param tokens: Keyword arguments used to replace values in messages. """ # Get a recipient filter of the given users recipients = RecipientFilter(*player_indexes) # Get the KeyValues instance keyvalues = KeyValues(self.message_type.name.lower()) # Set the time for the message to display keyvalues.set_int('time', self.time) # Loop through all recipients for index in recipients: # Get a Player instance for the current player player = Player(index) # Is the player not human? if player.is_fake_client(): continue # Get the level for the message level = self._get_player_level(player.userid) # Set the level for the player keyvalues.set_int('level', level) # Set the title (value should be server IP address) keyvalues.set_string( 'title', self._get_text(self.title, player, **tokens)) # Set any remaining keyvalues self._set_keyvalues(keyvalues, player, **tokens) # Send the message create_message(player.edict, self.message_type, keyvalues)
def _send(self, player_index): """Build and send the menu to the given player via create_message(). @param <player_index>: A player index. """ queue = self.get_user_queue(player_index) queue.priority -= 1 # Build the menu data = self._build(player_index) # Set priority and display time data.set_int('level', queue.priority) data.set_int('time', 10) # Send the menu create_message( edict_from_index(player_index), DialogType.MENU, data )