bascenev1lib.activity.multiteamjoin
Functionality related to the join screen for multi-team sessions.
1# Released under the MIT License. See LICENSE for details. 2# 3"""Functionality related to the join screen for multi-team sessions.""" 4 5from __future__ import annotations 6 7import bascenev1 as bs 8from bascenev1lib.actor.text import Text 9 10 11class MultiTeamJoinActivity(bs.JoinActivity): 12 """Join screen for teams sessions.""" 13 14 def __init__(self, settings: dict): 15 super().__init__(settings) 16 self._next_up_text: Text | None = None 17 18 def on_transition_in(self) -> None: 19 from bascenev1lib.actor.controlsguide import ControlsGuide 20 21 super().on_transition_in() 22 ControlsGuide(delay=1.0).autoretain() 23 24 session = self.session 25 assert isinstance(session, bs.MultiTeamSession) 26 27 # Show info about the next up game. 28 self._next_up_text = Text( 29 bs.Lstr( 30 value='${1} ${2}', 31 subs=[ 32 ('${1}', bs.Lstr(resource='upFirstText')), 33 ('${2}', session.get_next_game_description()), 34 ], 35 ), 36 h_attach=Text.HAttach.CENTER, 37 scale=0.7, 38 v_attach=Text.VAttach.TOP, 39 h_align=Text.HAlign.CENTER, 40 position=(0, -70), 41 flash=False, 42 color=(0.5, 0.5, 0.5, 1.0), 43 transition=Text.Transition.FADE_IN, 44 transition_delay=5.0, 45 ) 46 47 # In teams mode, show our two team names. 48 # FIXME: Lobby should handle this. 49 if isinstance(bs.getsession(), bs.DualTeamSession): 50 team_names = [team.name for team in bs.getsession().sessionteams] 51 team_colors = [ 52 tuple(team.color) + (0.5,) 53 for team in bs.getsession().sessionteams 54 ] 55 if len(team_names) == 2: 56 for i in range(2): 57 Text( 58 team_names[i], 59 scale=0.7, 60 h_attach=Text.HAttach.CENTER, 61 v_attach=Text.VAttach.TOP, 62 h_align=Text.HAlign.CENTER, 63 position=(-200 + 350 * i, -100), 64 color=team_colors[i], 65 transition=Text.Transition.FADE_IN, 66 ).autoretain() 67 68 Text( 69 bs.Lstr( 70 resource='mustInviteFriendsText', 71 subs=[ 72 ( 73 '${GATHER}', 74 bs.Lstr(resource='gatherWindow.titleText'), 75 ) 76 ], 77 ), 78 h_attach=Text.HAttach.CENTER, 79 scale=0.8, 80 host_only=True, 81 v_attach=Text.VAttach.CENTER, 82 h_align=Text.HAlign.CENTER, 83 position=(0, 0), 84 flash=False, 85 color=(0, 1, 0, 1.0), 86 transition=Text.Transition.FADE_IN, 87 transition_delay=2.0, 88 transition_out_delay=7.0, 89 ).autoretain()
class
MultiTeamJoinActivity(bascenev1._activity.Activity[bascenev1._player.EmptyPlayer, bascenev1._team.EmptyTeam]):
12class MultiTeamJoinActivity(bs.JoinActivity): 13 """Join screen for teams sessions.""" 14 15 def __init__(self, settings: dict): 16 super().__init__(settings) 17 self._next_up_text: Text | None = None 18 19 def on_transition_in(self) -> None: 20 from bascenev1lib.actor.controlsguide import ControlsGuide 21 22 super().on_transition_in() 23 ControlsGuide(delay=1.0).autoretain() 24 25 session = self.session 26 assert isinstance(session, bs.MultiTeamSession) 27 28 # Show info about the next up game. 29 self._next_up_text = Text( 30 bs.Lstr( 31 value='${1} ${2}', 32 subs=[ 33 ('${1}', bs.Lstr(resource='upFirstText')), 34 ('${2}', session.get_next_game_description()), 35 ], 36 ), 37 h_attach=Text.HAttach.CENTER, 38 scale=0.7, 39 v_attach=Text.VAttach.TOP, 40 h_align=Text.HAlign.CENTER, 41 position=(0, -70), 42 flash=False, 43 color=(0.5, 0.5, 0.5, 1.0), 44 transition=Text.Transition.FADE_IN, 45 transition_delay=5.0, 46 ) 47 48 # In teams mode, show our two team names. 49 # FIXME: Lobby should handle this. 50 if isinstance(bs.getsession(), bs.DualTeamSession): 51 team_names = [team.name for team in bs.getsession().sessionteams] 52 team_colors = [ 53 tuple(team.color) + (0.5,) 54 for team in bs.getsession().sessionteams 55 ] 56 if len(team_names) == 2: 57 for i in range(2): 58 Text( 59 team_names[i], 60 scale=0.7, 61 h_attach=Text.HAttach.CENTER, 62 v_attach=Text.VAttach.TOP, 63 h_align=Text.HAlign.CENTER, 64 position=(-200 + 350 * i, -100), 65 color=team_colors[i], 66 transition=Text.Transition.FADE_IN, 67 ).autoretain() 68 69 Text( 70 bs.Lstr( 71 resource='mustInviteFriendsText', 72 subs=[ 73 ( 74 '${GATHER}', 75 bs.Lstr(resource='gatherWindow.titleText'), 76 ) 77 ], 78 ), 79 h_attach=Text.HAttach.CENTER, 80 scale=0.8, 81 host_only=True, 82 v_attach=Text.VAttach.CENTER, 83 h_align=Text.HAlign.CENTER, 84 position=(0, 0), 85 flash=False, 86 color=(0, 1, 0, 1.0), 87 transition=Text.Transition.FADE_IN, 88 transition_delay=2.0, 89 transition_out_delay=7.0, 90 ).autoretain()
Join screen for teams sessions.
MultiTeamJoinActivity(settings: dict)
15 def __init__(self, settings: dict): 16 super().__init__(settings) 17 self._next_up_text: Text | None = None
Creates an Activity in the current bascenev1.Session.
The activity will not be actually run until bascenev1.Session.setactivity is called. 'settings' should be a dict of key/value pairs specific to the activity.
Activities should preload as much of their media/etc as possible in their constructor, but none of it should actually be used until they are transitioned in.
def
on_transition_in(self) -> None:
19 def on_transition_in(self) -> None: 20 from bascenev1lib.actor.controlsguide import ControlsGuide 21 22 super().on_transition_in() 23 ControlsGuide(delay=1.0).autoretain() 24 25 session = self.session 26 assert isinstance(session, bs.MultiTeamSession) 27 28 # Show info about the next up game. 29 self._next_up_text = Text( 30 bs.Lstr( 31 value='${1} ${2}', 32 subs=[ 33 ('${1}', bs.Lstr(resource='upFirstText')), 34 ('${2}', session.get_next_game_description()), 35 ], 36 ), 37 h_attach=Text.HAttach.CENTER, 38 scale=0.7, 39 v_attach=Text.VAttach.TOP, 40 h_align=Text.HAlign.CENTER, 41 position=(0, -70), 42 flash=False, 43 color=(0.5, 0.5, 0.5, 1.0), 44 transition=Text.Transition.FADE_IN, 45 transition_delay=5.0, 46 ) 47 48 # In teams mode, show our two team names. 49 # FIXME: Lobby should handle this. 50 if isinstance(bs.getsession(), bs.DualTeamSession): 51 team_names = [team.name for team in bs.getsession().sessionteams] 52 team_colors = [ 53 tuple(team.color) + (0.5,) 54 for team in bs.getsession().sessionteams 55 ] 56 if len(team_names) == 2: 57 for i in range(2): 58 Text( 59 team_names[i], 60 scale=0.7, 61 h_attach=Text.HAttach.CENTER, 62 v_attach=Text.VAttach.TOP, 63 h_align=Text.HAlign.CENTER, 64 position=(-200 + 350 * i, -100), 65 color=team_colors[i], 66 transition=Text.Transition.FADE_IN, 67 ).autoretain() 68 69 Text( 70 bs.Lstr( 71 resource='mustInviteFriendsText', 72 subs=[ 73 ( 74 '${GATHER}', 75 bs.Lstr(resource='gatherWindow.titleText'), 76 ) 77 ], 78 ), 79 h_attach=Text.HAttach.CENTER, 80 scale=0.8, 81 host_only=True, 82 v_attach=Text.VAttach.CENTER, 83 h_align=Text.HAlign.CENTER, 84 position=(0, 0), 85 flash=False, 86 color=(0, 1, 0, 1.0), 87 transition=Text.Transition.FADE_IN, 88 transition_delay=2.0, 89 transition_out_delay=7.0, 90 ).autoretain()
Called when the Activity is first becoming visible.
Upon this call, the Activity should fade in backgrounds, start playing music, etc. It does not yet have access to players or teams, however. They remain owned by the previous Activity up until bascenev1.Activity.on_begin() is called.
Inherited Members
- bascenev1._activitytypes.JoinActivity
- is_joining_activity
- allow_kick_idle_players
- use_fixed_vr_overlay
- bascenev1._activity.Activity
- settings_raw
- teams
- players
- announce_player_deaths
- allow_pausing
- slow_motion
- inherits_slow_motion
- inherits_music
- inherits_vr_camera_offset
- inherits_vr_overlay_center
- inherits_tint
- allow_mid_activity_joins
- transition_time
- can_show_ad_on_death
- paused_text
- preloads
- lobby
- context
- globalsnode
- stats
- on_expire
- customdata
- expired
- playertype
- teamtype
- retain_actor
- add_actor_weak_ref
- session
- on_player_join
- on_player_leave
- on_team_join
- on_team_leave
- on_transition_out
- on_begin
- handlemessage
- has_transitioned_in
- has_begun
- has_ended
- is_transitioning_out
- transition_out
- end
- create_player
- create_team
- bascenev1._dependency.DependencyComponent
- dep_is_present
- get_dynamic_deps