def __init__(self, game_state, *args, **kwargs): # All the game scenes share a GameState object. self.game_state = game_state # They also use the global player, but access it via a property just in # case I change my mind later. self.n_track_player = N_TRACK_PLAYER # Make some views. Read the clubsandwich docs for details on this stuff. # Some of them we just add as subviews and forget about, but the stats # view will need to be updated from time to time, so hang onto a reference # to it. sidebar_width = 21 # The game drawing is all done by this GameView object. It happens every # frame, so we can mostly forget about it for now. game_view = GameView(self.game_state, layout_options=LayoutOptions().with_updates( left=sidebar_width, bottom=1)) log_view = LabelView( text="", align_horz='left', color_bg='#333333', clear=True, layout_options=LayoutOptions.row_bottom(1).with_updates( left=sidebar_width)) help_view = LabelView(text=TEXT_HELP, align_horz='left', layout_options=LayoutOptions.column_left( sidebar_width).with_updates( top=None, height='intrinsic')) self.stats_view = StatsView( self.game_state, layout_options=LayoutOptions.column_left(sidebar_width)) views = [ game_view, self.stats_view, help_view, log_view, ] super().__init__(views, *args, **kwargs) # Each game scene has its own log controller. It's defined after the super() # call because it needs log_view to exist. self.logger = Logger(log_view) # This boolean signals to DirectorLoop that it doesn't need to draw any # scenes behind this one. (Compare with the pause screen, which wants the # game scene to be drawn behind it, since it's a popup window!) self.covers_screen = True
def __init__(self, host_filter, targets): self.targets = targets self.button_controls = collections.OrderedDict( (target, SelectableButtonView(target.name, functools.partial(self.select_object, value=target), align_horz='left')) for target in targets) super().__init__([ WindowView( "", subviews=[ KeyAssignedListView( self.button_controls.values(), value_column_width=max( len(value.text) + 5 for value in self.button_controls.values()), layout_options=LayoutOptions.column_left(0.9)), ], layout_options=LayoutOptions(width=0.5, left=0.3, height=0.9, right=None, bottom=None), ), ButtonView("Finish", self.finish, layout_options=LayoutOptions.row_bottom(0.2)), ]) self.host_filter = host_filter self.selections = []
def __init__(self, host_filter, hierarchy): self.hierarchy = hierarchy self.button_controls_list = [] self._recursive_create_buttons(hierarchy) self.button_controls = collections.OrderedDict( self.button_controls_list) super().__init__([ WindowView( "", subviews=[ KeyAssignedListView( self.button_controls.values(), value_column_width=max( len(value.text) + 5 for value in self.button_controls.values()), layout_options=LayoutOptions.column_left(0.9)), ], layout_options=LayoutOptions(width=0.5, left=0.3, height=0.9, right=None, bottom=None), ), ButtonView("Finish", self.finish, layout_options=LayoutOptions.row_bottom(0.2)), ]) self.host_filter = host_filter self.selections = []
def __init__(self, *args, **kwargs): self.main_display = MainDisplay(layout_options=LayoutOptions(left=0.2)) self.side_info_bar = InfoBar(layout_options=LayoutOptions.column_left( width=0.2)) views = [self.main_display, self.side_info_bar] super().__init__(views, *args, **kwargs)