예제 #1
0
def format_machine(machine: Machine) -> Dict[str, Any]:
    if machine.game is None:
        game = 'any game'
    elif machine.version is None:
        game = {
            GameConstants.BISHI_BASHI: 'BishiBashi',
            GameConstants.DDR: 'DDR',
            GameConstants.IIDX: 'IIDX',
            GameConstants.JUBEAT: 'Jubeat',
            GameConstants.MUSECA: 'MÚSECA',
            GameConstants.POPN_MUSIC: 'Pop\'n Music',
            GameConstants.REFLEC_BEAT: 'Reflec Beat',
            GameConstants.SDVX: 'SDVX',
        }.get(machine.game)
    elif machine.version > 0:
        game = [
            name for (game, version, name) in Base.all_games()
            if game == machine.game and version == machine.version
        ][0]
    elif machine.version < 0:
        game = [
            name for (game, version, name) in Base.all_games()
            if game == machine.game and version == -machine.version
        ][0] + ' or older'

    return {
        'pcbid': machine.pcbid,
        'name': machine.name,
        'description': machine.description,
        'port': machine.port,
        'game': game,
    }
예제 #2
0
def viewmachines() -> Response:
    games: Dict[str, Dict[int, str]] = {}
    for (game, version, name) in Base.all_games():
        if game not in games:
            games[game] = {}
        games[game][version] = name

    return render_react(
        'Machines',
        'admin/machines.react.js',
        {
            'machines': [format_machine(machine) for machine in g.data.local.machine.get_all_machines()],
            'arcades': {arcade.id: arcade.name for arcade in g.data.local.machine.get_all_arcades()},
            'series': {
                GameConstants.BISHI_BASHI: 'BishiBashi',
                GameConstants.DDR: 'DDR',
                GameConstants.IIDX: 'IIDX',
                GameConstants.JUBEAT: 'Jubeat',
                GameConstants.MUSECA: 'MÚSECA',
                GameConstants.POPN_MUSIC: 'Pop\'n Music',
                GameConstants.REFLEC_BEAT: 'Reflec Beat',
                GameConstants.SDVX: 'SDVX',
            },
            'games': games,
            'enforcing': g.config['server']['enforce_pcbid'],
        },
        {
            'generatepcbid': url_for('admin_pages.generatepcbid'),
            'addpcbid': url_for('admin_pages.addpcbid'),
            'updatepcbid': url_for('admin_pages.updatepcbid'),
            'removepcbid': url_for('admin_pages.removepcbid'),
        },
    )
예제 #3
0
def get_game_settings(arcade: Arcade) -> List[Dict[str, Any]]:
    game_lut: Dict[str, Dict[int, str]] = {}
    settings_lut: Dict[str, Dict[int, Dict[str, Any]]] = {}
    all_settings = []

    for (game, version, name) in Base.all_games():
        if game not in game_lut:
            game_lut[game] = {}
            settings_lut[game] = {}
        game_lut[game][version] = name
        settings_lut[game][version] = {}

    for (game, version, settings) in Base.all_settings():
        if not settings:
            continue

        # First, set up the basics
        game_settings: Dict[str, Any] = {
            'game': game,
            'version': version,
            'name': game_lut[game][version],
            'bools': [],
            'ints': [],
            'strs': [],
            'longstrs': [],
        }

        # Now, look up the current setting for each returned setting
        for setting_type, setting_unpacker in [
            ('bools', "get_bool"),
            ('ints', "get_int"),
            ('strs', "get_str"),
            ('longstrs', "get_str"),
        ]:
            for setting in settings.get(setting_type, []):
                if setting['category'] not in settings_lut[game][version]:
                    cached_setting = g.data.local.machine.get_settings(
                        arcade.id, game, version, setting['category'])
                    if cached_setting is None:
                        cached_setting = ValidatedDict()
                    settings_lut[game][version][
                        setting['category']] = cached_setting

                current_settings = settings_lut[game][version][
                    setting['category']]
                setting['value'] = getattr(current_settings, setting_unpacker)(
                    setting['setting'])
                game_settings[setting_type].append(setting)

        # Now, include it!
        all_settings.append(game_settings)

    return sorted(
        all_settings,
        key=lambda setting: (setting['game'], setting['version']),
    )
예제 #4
0
def get_game_settings(arcade: Arcade) -> List[Dict[str, Any]]:
    game_lut: Dict[str, Dict[int, str]] = {}
    settings_lut: Dict[str, Dict[int, Dict[str, Any]]] = {}
    all_settings = []

    for (game, version, name) in Base.all_games():
        if game not in game_lut:
            game_lut[game] = {}
            settings_lut[game] = {}
        game_lut[game][version] = name
        settings_lut[game][version] = {}

    for (game, version, settings) in Base.all_settings():
        if not settings:
            continue

        # First, set up the basics
        game_settings: Dict[str, Any] = {
            'game': game,
            'version': version,
            'name': game_lut[game][version],
            'bools': [],
            'ints': [],
        }

        # Now, look up the current setting for each returned setting
        for bool_setting in settings.get('bools', []):
            if bool_setting['category'] not in settings_lut[game][version]:
                cached_setting = g.data.local.machine.get_settings(
                    arcade.id, game, version, bool_setting['category'])
                if cached_setting is None:
                    cached_setting = ValidatedDict()
                settings_lut[game][version][
                    bool_setting['category']] = cached_setting

            current_settings = settings_lut[game][version][
                bool_setting['category']]
            bool_setting['value'] = current_settings.get_bool(
                bool_setting['setting'])
            game_settings['bools'].append(bool_setting)

        # Now, look up the current setting for each returned setting
        for int_setting in settings.get('ints', []):
            if int_setting['category'] not in settings_lut[game][version]:
                cached_setting = g.data.local.machine.get_settings(
                    arcade.id, game, version, int_setting['category'])
                if cached_setting is None:
                    cached_setting = ValidatedDict()
                settings_lut[game][version][
                    int_setting['category']] = cached_setting

            current_settings = settings_lut[game][version][
                int_setting['category']]
            int_setting['value'] = current_settings.get_int(
                int_setting['setting'])
            game_settings['ints'].append(int_setting)

        # Now, include it!
        all_settings.append(game_settings)

    return all_settings