def __init__(self, game): self.covers_screen = True self.game = game self.player = self.game.player self.ability_score_set = self.player.stats.base_ability_score_set self.manager = None self.sorted_races = sorted(races.listing, key=lambda race: race.name) self.enabled_races, self.disabled_races = self.filter_race_choices() self.buttons = { race: SelectableButtonView(race.name, partial(self.set_race, race), color_fg=self._inactive_fg if race in self.enabled_races else self._disabled_fg, align_horz='left') for race in self.sorted_races } self.race_choice = None views = [ WindowView(title='Race Selection', subviews=[ KeyAssignedListView(self.buttons.values()), ButtonView('Finish', self.finish, layout_options=LayoutOptions( **get_left_layout(13, left=0.45))) ]) ] super().__init__(views)
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, 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, game): console_layout_options = LayoutOptions(top=None, height=12, bottom=0, left=1, right=None, width=0.99) game_view_layout_options = LayoutOptions(top=10, height=30, bottom=None, left=0, right=None, width=0.99) hud_view_layout_options = LayoutOptions(top=0, height=0.2, bottom=None, left=0, right=None, width=0.99) self.console = ScrollingTextView(12, 110, layout_options=console_layout_options) self.game_view = GameView(game, layout_options=game_view_layout_options) self.game = game game.action_stack = ActionStack(game, game.player, self.update_turn) self.hud_view = HudView(game, layout_options=hud_view_layout_options) super().__init__( WindowView("", subviews=[self.hud_view, self.game_view, self.console])) self.game.game_scene = self
def __init__(self, *args, **kwargs): self.tile_size = get_game_config()['cellsize'] self.font_size = get_game_config()['fontsize'] self.button_tile_size = ButtonView( text=self.tile_size, callback=self.rotate_tile_size) view = WindowView( 'Settings', layout_options=LayoutOptions.centered(50, 20), subviews=[ ListView( [ ('Tile size', self.button_tile_size), ] + [ ('Filler ' + str(i), ButtonView(text='Hi', callback=lambda: None)) for i in range(50) ], layout_options=LayoutOptions(bottom=3)), ButtonView( text='Apply', callback=self.apply, layout_options=LayoutOptions.row_bottom(3).with_updates(right=0.5)), ButtonView( text='Cancel', callback=lambda: self.director().pop_scene(), layout_options=LayoutOptions.row_bottom(3).with_updates(left=0.5)), ]) super().__init__(view, *args, **kwargs) self.covers_screen = False
def __init__(self, *args, **kwargs): view = WindowView( 'Character', layout_options=LayoutOptions(top=7, right=10, bottom=7, left=10), subviews=[ LabelView('Name:', layout_options=LayoutOptions( height=1, top=1, bottom=None)), SingleLineTextInputView( callback=self.print_name, layout_options=LayoutOptions .centered('intrinsic', 'intrinsic') .with_updates(top=2, bottom=None)), LabelView('Strength:', layout_options=LayoutOptions( height=1, top=4, bottom=None)), IntStepperView( value=10, min_value=1, max_value=20, callback=lambda x: print(x), layout_options=LayoutOptions .centered('intrinsic', 'intrinsic') .with_updates(top=5)), ButtonView( text='Cancel', callback=lambda: self.director.pop_scene(), layout_options=LayoutOptions.row_bottom(3)), ] ) super().__init__(view, *args, **kwargs) self.covers_screen = True
def __init__(self, *args, **kwargs): view = WindowView( 'Settings', layout_options=LayoutOptions.centered(60, 20), subviews=[ SettingsListView( [(k, CyclingButtonView( v, v[0], callback=lambda _: None, align_horz='left')) for k, v in sorted(SettingsScene.OPTIONS.items())], value_column_width=20, layout_options=LayoutOptions(bottom=5)), ButtonView( text='Apply', callback=self.apply, layout_options=LayoutOptions.row_bottom(5).with_updates( right=0.5)), ButtonView( text='Cancel', callback=lambda: self.director.pop_scene(), layout_options=LayoutOptions.row_bottom(5).with_updates( left=0.5)), ]) super().__init__(view, *args, **kwargs) # this lets the main screen show underneath self.covers_screen = False
def __init__(self, game): self.covers_screen = True self.game = game self.skills = {} self.points_left = 3 self.player = self.game.player self.player_skills = self.player.skills self.game.player = self.player self.manager = None sorted_skills = sorted(list(skill_listing), key=lambda skill: skill.name) sub_views = [] for i, skill in enumerate(sorted_skills): partial_validation = partial(self.validate_points, skill=skill) sub_views.append( LabelView("%s:" % skill.name, layout_options=LayoutOptions(**get_left_layout(i)))) sub_views.append(ValidatedIntStepperView( validation_callback=partial_validation, value=0, callback=partial(self.set_skill, skill=skill), layout_options=LayoutOptions(**get_right_layout(i+1, width=5)))) sub_views.append( ButtonView( 'Finish', self.finish, layout_options=LayoutOptions(**get_left_layout(0.9, left=0.45)) )) views = [WindowView(title='Skill Selection', subviews=sub_views)] super().__init__(views)
def __init__(self): button_generator = (ButtonView( text="Item {}".format(i), callback=lambda x=i: print("Called Item {}".format(x))) for i in range(0, 100)) self.key_assign = KeyAssignedListView(value_controls=button_generator) super().__init__( WindowView("Scrolling Text", subviews=[self.key_assign]))
def __init__(self, *args, **kwargs): view = WindowView( 'Pause', layout_options=LayoutOptions.centered(40, 10), subviews=[ ButtonView(text='Resume', callback=self.resume, layout_options=LayoutOptions.row_top(5)), ButtonView(text='Quit', callback=self.quit, layout_options=LayoutOptions.row_bottom(5)), ]) super().__init__(view, *args, **kwargs) self.covers_screen = False
def __init__(self, *args, **kwargs): view = WindowView( 'Character', layout_options=LayoutOptions(top=7, right=10, bottom=7, left=10), subviews=[ LabelView('There is no game yet.', layout_options=LayoutOptions.row_top(0.5)), ButtonView( text='Darn', callback=lambda: self.director().pop_scene(), layout_options=LayoutOptions.row_bottom(0.5)), ] ) super().__init__(view, *args, **kwargs) self.covers_screen = False
def __init__(self): self.lets_scroll = ScrollingTextView( lines_to_display=4, chars_per_line=60, layout_options=LayoutOptions(left=0.05, width=0.85, height=0.3, right=None, bottom=0.1, top=None)) super().__init__(WindowView("Scrolling Text", subviews=[self.lets_scroll])) self.lets_scroll.add_lines("Sometimes this scrolling view can come quite handy right?\n" "I mean often we need to scroll through logs of action\n" "to make sure we get everything visible and nice to read things.\n" "\n" "Maybe you should stop reading all this and\n" "Use the scrolling text view into your own game?\n" "Just making sure this is nicely wrapped.\n" "This, however\n" "Needs to break up\n" "as expected.")
def __init__(self, score, *args, **kwargs): view = WindowView( 'Game Over', layout_options=LayoutOptions.centered(80, 30), subviews=[ LabelView(TEXT_GAME_OVER, layout_options=LayoutOptions.centered( 'intrinsic', 'intrinsic')), LabelView( "Your score: {}".format(score), layout_options=LayoutOptions.row_bottom(1).with_updates( bottom=6)), ButtonView(text='Aaauuuuggghhhhhh...', callback=self.done, layout_options=LayoutOptions.row_bottom(3)), ]) super().__init__(view, *args, **kwargs) self.covers_screen = False
def __init__(self, game): self.covers_screen = True self.game = game self.manager = None self.player = self.game.player self.ability_score_set = self.player.stats.base_ability_score_set self.race = self.player.race.base_race if self.race.racial_class is None: self.sorted_classes = sorted(classes.listing, key=lambda c_class: c_class.name) self.enabled_classes, self.disabled_classes = self.filter_class_choices( ) else: self.sorted_classes = [self.race.racial_class] self.enabled_classes = self.sorted_classes self.disabled_classes = [] self.buttons = { character_class: SelectableButtonView( character_class.name, partial(self.set_character_class, character_class), color_fg=self._inactive_fg if character_class in self.enabled_classes else self._disabled_fg, align_horz='left') for character_class in self.sorted_classes } self.class_choices = [] views = [ WindowView(title='Class Selection', subviews=[ KeyAssignedListView(self.buttons.values()), ButtonView('Finish', self.finish, layout_options=LayoutOptions( **get_left_layout(13, left=0.45))) ]) ] super().__init__(views)
def __init__(self, game): self.covers_screen = True self.game = game self.manager = None stat_initial = 7 stat_minimum = 3 stat_maximum = 18 views = [ WindowView( title='Ability Score Selection', subviews=[ LabelView( "Name:", layout_options=LayoutOptions(**get_left_layout(2))), SingleLineTextInputView( callback=self.set_name, layout_options=LayoutOptions( **get_right_layout(3, width=0.2, right=0.4))), LabelView( "Strength:", layout_options=LayoutOptions(**get_left_layout(6))), ValidatedIntStepperView( validation_callback=self.validate_points, value=stat_initial, callback=lambda value: self.set_stat( "Strength", value), min_value=stat_minimum, max_value=stat_maximum, layout_options=LayoutOptions( **get_right_layout(7, width=5)), ), LabelView( "Dexterity:", layout_options=LayoutOptions(**get_left_layout(7))), ValidatedIntStepperView( validation_callback=self.validate_points, value=stat_initial, callback=lambda value: self.set_stat( "Dexterity", value), min_value=stat_minimum, max_value=stat_maximum, layout_options=LayoutOptions( **get_right_layout(8, width=5)), ), LabelView( "Constitution:", layout_options=LayoutOptions(**get_left_layout(8))), ValidatedIntStepperView( validation_callback=self.validate_points, value=stat_initial, callback=lambda value: self.set_stat( "Constitution", value), min_value=stat_minimum, max_value=stat_maximum, layout_options=LayoutOptions( **get_right_layout(9, width=5)), ), LabelView( "Intelligence:", layout_options=LayoutOptions(**get_left_layout(9))), ValidatedIntStepperView( validation_callback=self.validate_points, value=stat_initial, callback=lambda value: self.set_stat( "Intelligence", value), min_value=stat_minimum, max_value=stat_maximum, layout_options=LayoutOptions( **get_right_layout(10, width=5)), ), LabelView( "Charisma:", layout_options=LayoutOptions(**get_left_layout(10))), ValidatedIntStepperView( validation_callback=self.validate_points, value=stat_initial, callback=lambda value: self.set_stat( "Charisma", value), min_value=stat_minimum, max_value=stat_maximum, layout_options=LayoutOptions( **get_right_layout(11, width=5)), ), LabelView( "Wisdom:", layout_options=LayoutOptions(**get_left_layout(11))), ValidatedIntStepperView( validation_callback=self.validate_points, value=stat_initial, callback=lambda value: self.set_stat("Wisdom", value), min_value=stat_minimum, max_value=stat_maximum, layout_options=LayoutOptions( **get_right_layout(12, width=5))), ButtonView('Finish', self.finish, layout_options=LayoutOptions( **get_left_layout(13, left=0.45))) ]) ] super().__init__(views) self.name = "" self.stats = { "strength": stat_initial, "dexterity": stat_initial, "constitution": stat_initial, "intelligence": stat_initial, "charisma": stat_initial, "wisdom": stat_initial } self.points_left = 18 self.choices = {}