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 ( 21 get_default_teams_playlist, 22 get_default_free_for_all_playlist, 23 ) 24 25 self.sessiontype: type[ba.Session] 26 27 if issubclass(sessiontype, ba.DualTeamSession): 28 play_mode_name = ba.Lstr( 29 resource='playModes.teamsText', fallback_resource='teamsText' 30 ) 31 self.get_default_list_call = get_default_teams_playlist 32 self.session_type_name = 'ba.DualTeamSession' 33 self.config_name = 'Team Tournament' 34 self.window_title_name = ba.Lstr( 35 resource='playModes.teamsText', fallback_resource='teamsText' 36 ) 37 self.sessiontype = ba.DualTeamSession 38 39 elif issubclass(sessiontype, ba.FreeForAllSession): 40 play_mode_name = ba.Lstr( 41 resource='playModes.freeForAllText', 42 fallback_resource='freeForAllText', 43 ) 44 self.get_default_list_call = get_default_free_for_all_playlist 45 self.session_type_name = 'ba.FreeForAllSession' 46 self.config_name = 'Free-for-All' 47 self.window_title_name = ba.Lstr( 48 resource='playModes.freeForAllText', 49 fallback_resource='freeForAllText', 50 ) 51 self.sessiontype = ba.FreeForAllSession 52 53 else: 54 raise RuntimeError( 55 f'Playlist type vars undefined for sessiontype: {sessiontype}' 56 ) 57 self.default_list_name = ba.Lstr( 58 resource='defaultGameListNameText', 59 subs=[('${PLAYMODE}', play_mode_name)], 60 ) 61 self.default_new_list_name = ba.Lstr( 62 resource='defaultNewGameListNameText', 63 subs=[('${PLAYMODE}', play_mode_name)], 64 )
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 ( 22 get_default_teams_playlist, 23 get_default_free_for_all_playlist, 24 ) 25 26 self.sessiontype: type[ba.Session] 27 28 if issubclass(sessiontype, ba.DualTeamSession): 29 play_mode_name = ba.Lstr( 30 resource='playModes.teamsText', fallback_resource='teamsText' 31 ) 32 self.get_default_list_call = get_default_teams_playlist 33 self.session_type_name = 'ba.DualTeamSession' 34 self.config_name = 'Team Tournament' 35 self.window_title_name = ba.Lstr( 36 resource='playModes.teamsText', fallback_resource='teamsText' 37 ) 38 self.sessiontype = ba.DualTeamSession 39 40 elif issubclass(sessiontype, ba.FreeForAllSession): 41 play_mode_name = ba.Lstr( 42 resource='playModes.freeForAllText', 43 fallback_resource='freeForAllText', 44 ) 45 self.get_default_list_call = get_default_free_for_all_playlist 46 self.session_type_name = 'ba.FreeForAllSession' 47 self.config_name = 'Free-for-All' 48 self.window_title_name = ba.Lstr( 49 resource='playModes.freeForAllText', 50 fallback_resource='freeForAllText', 51 ) 52 self.sessiontype = ba.FreeForAllSession 53 54 else: 55 raise RuntimeError( 56 f'Playlist type vars undefined for sessiontype: {sessiontype}' 57 ) 58 self.default_list_name = ba.Lstr( 59 resource='defaultGameListNameText', 60 subs=[('${PLAYMODE}', play_mode_name)], 61 ) 62 self.default_new_list_name = ba.Lstr( 63 resource='defaultNewGameListNameText', 64 subs=[('${PLAYMODE}', play_mode_name)], 65 )
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 ( 22 get_default_teams_playlist, 23 get_default_free_for_all_playlist, 24 ) 25 26 self.sessiontype: type[ba.Session] 27 28 if issubclass(sessiontype, ba.DualTeamSession): 29 play_mode_name = ba.Lstr( 30 resource='playModes.teamsText', fallback_resource='teamsText' 31 ) 32 self.get_default_list_call = get_default_teams_playlist 33 self.session_type_name = 'ba.DualTeamSession' 34 self.config_name = 'Team Tournament' 35 self.window_title_name = ba.Lstr( 36 resource='playModes.teamsText', fallback_resource='teamsText' 37 ) 38 self.sessiontype = ba.DualTeamSession 39 40 elif issubclass(sessiontype, ba.FreeForAllSession): 41 play_mode_name = ba.Lstr( 42 resource='playModes.freeForAllText', 43 fallback_resource='freeForAllText', 44 ) 45 self.get_default_list_call = get_default_free_for_all_playlist 46 self.session_type_name = 'ba.FreeForAllSession' 47 self.config_name = 'Free-for-All' 48 self.window_title_name = ba.Lstr( 49 resource='playModes.freeForAllText', 50 fallback_resource='freeForAllText', 51 ) 52 self.sessiontype = ba.FreeForAllSession 53 54 else: 55 raise RuntimeError( 56 f'Playlist type vars undefined for sessiontype: {sessiontype}' 57 ) 58 self.default_list_name = ba.Lstr( 59 resource='defaultGameListNameText', 60 subs=[('${PLAYMODE}', play_mode_name)], 61 ) 62 self.default_new_list_name = ba.Lstr( 63 resource='defaultNewGameListNameText', 64 subs=[('${PLAYMODE}', play_mode_name)], 65 )