bastd.ui.playlist

Playlist ui functionality.

 1# Released under the MIT License. See LICENSE for details.
 2#
 3"""Playlist ui functionality."""
 4
 5from __future__ import annotations
 6
 7from typing import TYPE_CHECKING
 8
 9import ba
10
11if TYPE_CHECKING:
12    pass
13
14
15# FIXME: Could change this to be a classmethod of session types?
16class PlaylistTypeVars:
17    """Defines values for a playlist type (config names to use, etc)."""
18
19    def __init__(self, sessiontype: type[ba.Session]):
20        from ba.internal import (get_default_teams_playlist,
21                                 get_default_free_for_all_playlist)
22        self.sessiontype: type[ba.Session]
23
24        if issubclass(sessiontype, ba.DualTeamSession):
25            play_mode_name = ba.Lstr(resource='playModes.teamsText',
26                                     fallback_resource='teamsText')
27            self.get_default_list_call = get_default_teams_playlist
28            self.session_type_name = 'ba.DualTeamSession'
29            self.config_name = 'Team Tournament'
30            self.window_title_name = ba.Lstr(resource='playModes.teamsText',
31                                             fallback_resource='teamsText')
32            self.sessiontype = ba.DualTeamSession
33
34        elif issubclass(sessiontype, ba.FreeForAllSession):
35            play_mode_name = ba.Lstr(resource='playModes.freeForAllText',
36                                     fallback_resource='freeForAllText')
37            self.get_default_list_call = get_default_free_for_all_playlist
38            self.session_type_name = 'ba.FreeForAllSession'
39            self.config_name = 'Free-for-All'
40            self.window_title_name = ba.Lstr(
41                resource='playModes.freeForAllText',
42                fallback_resource='freeForAllText')
43            self.sessiontype = ba.FreeForAllSession
44
45        else:
46            raise RuntimeError(
47                f'Playlist type vars undefined for sessiontype: {sessiontype}')
48        self.default_list_name = ba.Lstr(resource='defaultGameListNameText',
49                                         subs=[('${PLAYMODE}', play_mode_name)
50                                               ])
51        self.default_new_list_name = ba.Lstr(
52            resource='defaultNewGameListNameText',
53            subs=[('${PLAYMODE}', play_mode_name)])
class PlaylistTypeVars:
17class PlaylistTypeVars:
18    """Defines values for a playlist type (config names to use, etc)."""
19
20    def __init__(self, sessiontype: type[ba.Session]):
21        from ba.internal import (get_default_teams_playlist,
22                                 get_default_free_for_all_playlist)
23        self.sessiontype: type[ba.Session]
24
25        if issubclass(sessiontype, ba.DualTeamSession):
26            play_mode_name = ba.Lstr(resource='playModes.teamsText',
27                                     fallback_resource='teamsText')
28            self.get_default_list_call = get_default_teams_playlist
29            self.session_type_name = 'ba.DualTeamSession'
30            self.config_name = 'Team Tournament'
31            self.window_title_name = ba.Lstr(resource='playModes.teamsText',
32                                             fallback_resource='teamsText')
33            self.sessiontype = ba.DualTeamSession
34
35        elif issubclass(sessiontype, ba.FreeForAllSession):
36            play_mode_name = ba.Lstr(resource='playModes.freeForAllText',
37                                     fallback_resource='freeForAllText')
38            self.get_default_list_call = get_default_free_for_all_playlist
39            self.session_type_name = 'ba.FreeForAllSession'
40            self.config_name = 'Free-for-All'
41            self.window_title_name = ba.Lstr(
42                resource='playModes.freeForAllText',
43                fallback_resource='freeForAllText')
44            self.sessiontype = ba.FreeForAllSession
45
46        else:
47            raise RuntimeError(
48                f'Playlist type vars undefined for sessiontype: {sessiontype}')
49        self.default_list_name = ba.Lstr(resource='defaultGameListNameText',
50                                         subs=[('${PLAYMODE}', play_mode_name)
51                                               ])
52        self.default_new_list_name = ba.Lstr(
53            resource='defaultNewGameListNameText',
54            subs=[('${PLAYMODE}', play_mode_name)])

Defines values for a playlist type (config names to use, etc).

PlaylistTypeVars(sessiontype: type[ba._session.Session])
20    def __init__(self, sessiontype: type[ba.Session]):
21        from ba.internal import (get_default_teams_playlist,
22                                 get_default_free_for_all_playlist)
23        self.sessiontype: type[ba.Session]
24
25        if issubclass(sessiontype, ba.DualTeamSession):
26            play_mode_name = ba.Lstr(resource='playModes.teamsText',
27                                     fallback_resource='teamsText')
28            self.get_default_list_call = get_default_teams_playlist
29            self.session_type_name = 'ba.DualTeamSession'
30            self.config_name = 'Team Tournament'
31            self.window_title_name = ba.Lstr(resource='playModes.teamsText',
32                                             fallback_resource='teamsText')
33            self.sessiontype = ba.DualTeamSession
34
35        elif issubclass(sessiontype, ba.FreeForAllSession):
36            play_mode_name = ba.Lstr(resource='playModes.freeForAllText',
37                                     fallback_resource='freeForAllText')
38            self.get_default_list_call = get_default_free_for_all_playlist
39            self.session_type_name = 'ba.FreeForAllSession'
40            self.config_name = 'Free-for-All'
41            self.window_title_name = ba.Lstr(
42                resource='playModes.freeForAllText',
43                fallback_resource='freeForAllText')
44            self.sessiontype = ba.FreeForAllSession
45
46        else:
47            raise RuntimeError(
48                f'Playlist type vars undefined for sessiontype: {sessiontype}')
49        self.default_list_name = ba.Lstr(resource='defaultGameListNameText',
50                                         subs=[('${PLAYMODE}', play_mode_name)
51                                               ])
52        self.default_new_list_name = ba.Lstr(
53            resource='defaultNewGameListNameText',
54            subs=[('${PLAYMODE}', play_mode_name)])