示例#1
0
 def _update_for_keyboard(self, keyboard: ba.InputDevice) -> None:
     from ba import _input
     punch_key = keyboard.get_button_name(
         _input.get_device_value(keyboard, 'buttonPunch'))
     self._press_to_punch = Lstr(resource='orText',
                                 subs=[('${A}',
                                        Lstr(value='\'${K}\'',
                                             subs=[('${K}', punch_key)])),
                                       ('${B}', self._press_to_punch)])
     bomb_key = keyboard.get_button_name(
         _input.get_device_value(keyboard, 'buttonBomb'))
     self._press_to_bomb = Lstr(resource='orText',
                                subs=[('${A}',
                                       Lstr(value='\'${K}\'',
                                            subs=[('${K}', bomb_key)])),
                                      ('${B}', self._press_to_bomb)])
     self._joinmsg = Lstr(value='${A} < ${B} >',
                          subs=[('${A}',
                                 Lstr(resource='pressPunchToJoinText')),
                                ('${B}', self._press_to_punch)])
示例#2
0
def get_last_player_name_from_input_device(device: ba.InputDevice) -> str:
    """Return a reasonable player name associated with a device.

    (generally the last one used there)
    """
    appconfig = _ba.app.config

    # Look for a default player profile name for them;
    # otherwise default to their current random name.
    profilename = '_random'
    key_name = device.name + ' ' + device.unique_identifier
    if ('Default Player Profiles' in appconfig
            and key_name in appconfig['Default Player Profiles']):
        profilename = appconfig['Default Player Profiles'][key_name]
    if profilename == '_random':
        profilename = device.get_default_player_name()
    if profilename == '__account__':
        profilename = _ba.get_account_display_string()
    return profilename
示例#3
0
 def _meaningful_button_name(device: ba.InputDevice, button: int) -> str:
     """Return a flattened string button name; empty for non-meaningful."""
     if not device.has_meaningful_button_names:
         return ''
     return device.get_button_name(button).evaluate()