Exemple #1
0
 def __init__(self, *args, **kwargs):
     views = [
         LabelView(
             LOGO[1:].rstrip(),
             layout_options=LayoutOptions.row_top(0.5)),
         LabelView(
             "Try resizing the window!",
             layout_options=LayoutOptions.centered('intrinsic', 'intrinsic')),
         ButtonView(
             text="Play", callback=self.play,
             color_bg='#000000', color_fg='#00ff00',
             layout_options=LayoutOptions.row_bottom(4).with_updates(
                 left=0.2, width=0.2, right=None)),
         ButtonView(
             text="Settings", callback=self.show_settings,
             layout_options=LayoutOptions.row_bottom(4).with_updates(
                 left=0.4, width=0.2, right=None)),
         ButtonView(
             text="[color=red]Quit",
             callback=lambda: self.director.pop_scene(),
             # [color=red] messes up auto size calculations
             size=Size(4, 1),
             layout_options=LayoutOptions.row_bottom(4).with_updates(
                 left=0.6, width=0.2, right=None)),
     ]
     super().__init__(views, *args, **kwargs)
Exemple #2
0
    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
Exemple #3
0
    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
Exemple #4
0
 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
Exemple #5
0
    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
Exemple #6
0
    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)
Exemple #7
0
    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)
Exemple #8
0
 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 = []
Exemple #9
0
 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):
     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]))
Exemple #11
0
 def __init__(self, *args, **kwargs):
     views = [
         LabelView(
             FONT_LOGO.renderText('BeepBoop'),
             layout_options=LayoutOptions.row_top(0.3)),
         LabelView(
             get_image('robot'),
             layout_options=LayoutOptions(top=0.3, bottom=4)),
         ButtonView(
             text="Play", callback=self.play,
             layout_options=LayoutOptions.row_bottom(4).with_updates(left=0.2, width=0.2, right=None)),
         ButtonView(
             text="Settings", callback=self.show_settings,
             layout_options=LayoutOptions.row_bottom(4).with_updates(left=0.4, width=0.2, right=None)),
         ButtonView(
             text="Quit", callback=lambda: self.director().pop_scene(),
             layout_options=LayoutOptions.row_bottom(4).with_updates(left=0.6, width=0.2, right=None)),
     ]
     super().__init__(views, *args, **kwargs)
Exemple #12
0
 def __init__(self, *args, **kwargs):
     views = [
         LabelView(TITLE[1:].rstrip(),
                   layout_options=LayoutOptions.row_top(0.5)),
         LabelView(ABOUT,
                   color_fg='#ffcb00',
                   layout_options=LayoutOptions.centered(
                       'intrinsic', 'intrinsic').with_updates(top=28)),
         ButtonView(
             text="Descend the stairs",
             callback=self.play,
             layout_options=LayoutOptions.row_bottom(10).with_updates(
                 left=0.2, width=0.2, right=None)),
         ButtonView(
             text="Quit",
             callback=lambda: self.director.pop_scene(),
             layout_options=LayoutOptions.row_bottom(10).with_updates(
                 left=0.6, width=0.2, right=None)),
     ]
     super().__init__(views, *args, **kwargs)
Exemple #13
0
    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
Exemple #14
0
 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
Exemple #15
0
    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)
Exemple #16
0
 def __init__(self, *args, **kwargs):
     views = [ButtonView(text="Quit", callback=self.quit)]
     super().__init__(views, *args, **kwargs)
Exemple #17
0
    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 = {}