def get_settings_display_string(cls, config: Dict[str, Any]) -> ba.Lstr:
        """Given a game config dict, return a short description for it.

        This is used when viewing game-lists or showing what game
        is up next in a series.
        """
        name = cls.get_display_string(config['settings'])

        # In newer configs, map is in settings; it used to be in the
        # config root.
        if 'map' in config['settings']:
            sval = Lstr(value='${NAME} @ ${MAP}',
                        subs=[('${NAME}', name),
                              ('${MAP}',
                               _map.get_map_display_string(
                                   _map.get_filtered_map_name(
                                       config['settings']['map'])))])
        elif 'map' in config:
            sval = Lstr(value='${NAME} @ ${MAP}',
                        subs=[('${NAME}', name),
                              ('${MAP}',
                               _map.get_map_display_string(
                                   _map.get_filtered_map_name(config['map'])))
                              ])
        else:
            print('invalid game config - expected map entry under settings')
            sval = Lstr(value='???')
        return sval
Esempio n. 2
0
def get_store_item_name_translated(item_name: str) -> ba.Lstr:
    """Return a ba.Lstr for a store item name."""
    # pylint: disable=cyclic-import
    from ba import _lang
    from ba import _map
    item_info = get_store_item(item_name)
    if item_name.startswith('characters.'):
        return _lang.Lstr(translate=('characterNames', item_info['character']))
    if item_name in ['upgrades.pro', 'pro']:
        return _lang.Lstr(resource='store.bombSquadProNameText',
                          subs=[('${APP_NAME}',
                                 _lang.Lstr(resource='titleText'))])
    if item_name.startswith('maps.'):
        map_type: Type[ba.Map] = item_info['map_type']
        return _map.get_map_display_string(map_type.name)
    if item_name.startswith('games.'):
        gametype: Type[ba.GameActivity] = item_info['gametype']
        return gametype.get_display_string()
    if item_name.startswith('icons.'):
        return _lang.Lstr(resource='editProfileWindow.iconText')
    raise ValueError('unrecognized item: ' + item_name)