Esempio n. 1
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
Esempio n. 2
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)
Esempio n. 3
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
Esempio n. 4
0
 def __init__(self, game):
     self.game = game
     self.covers_screen = True
     self.manager = None
     views = [
         LabelView(text="Placeholder Text for BasicDungeon",
                   layout_options=LayoutOptions(top=0.4,
                                                height=0.1,
                                                left=None,
                                                bottom=None,
                                                right=None,
                                                width=0.1)),
         ButtonView(
             text="Play",
             callback=self.finish,
             layout_options=LayoutOptions(top=0.5,
                                          height=0.2,
                                          left=0.4,
                                          right=None,
                                          bottom=None,
                                          width=0.1),
         ),
         ButtonView(text="Quit",
                    callback=lambda: self.director.quit(),
                    layout_options=LayoutOptions(top=0.5,
                                                 height=0.2,
                                                 left=0.5,
                                                 right=None,
                                                 bottom=None,
                                                 width=0.1))
     ]
     super().__init__(views)
Esempio n. 5
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)
Esempio n. 6
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 = []
Esempio n. 7
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
Esempio n. 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 = []
Esempio n. 9
0
 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
Esempio n. 10
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.info_bar_view = LabelView(' Status/Resources',
                                    align_horz='left',
                                    layout_options=LayoutOptions.row_top(1))
     self.world_view = View(layout_options=LayoutOptions(top=2))
     self.message_view = RectView(
         layout_options=LayoutOptions.row_bottom(10))
     self.add_subviews(
         [self.info_bar_view, self.world_view, self.message_view])
Esempio n. 11
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
Esempio n. 12
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
Esempio n. 13
0
    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
Esempio n. 14
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)
Esempio n. 15
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
Esempio n. 16
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)
Esempio n. 17
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)
Esempio n. 18
0
    def get_next_layout_pair(self):
        self.last_top += 0.1
        if self.last_top >= 0.8:
            self.last_top = 0.3
            self.last_left += 0.3
            if self.last_left > 0.9:
                raise Exception("Too many.")
        label = LayoutOptions(top=self.last_top,
                              left=self.last_left,
                              width=0.1,
                              height=0.1,
                              bottom=None,
                              right=None)
        value = LayoutOptions(top=self.last_top,
                              left=self.last_left + 0.1,
                              width=0.1,
                              height=0.1,
                              bottom=None,
                              right=None)

        return label, value
Esempio n. 19
0
 def __init__(self, game_state, *args, **kwargs):
     self.game_state = game_state
     self.progress_bar = ProgressBarView(
         fraction=1,
         layout_options=LayoutOptions.row_top(1).with_updates(top=3,
                                                              right=1))
     self.health_label = LabelView(
         text="  Health: ?  ",
         color_fg="#ffffff",
         color_bg='#000000',
         layout_options=LayoutOptions.row_top(1).with_updates(top=2,
                                                              right=1))
     self.inventory_count = LabelView(
         text="  Rocks: 0  ",
         color_fg="#ffffff",
         color_bg="#000000",
         layout_options=LayoutOptions.row_top(1).with_updates(top=4,
                                                              right=1))
     self.score_label = LabelView(
         text="Score: 0",
         color_fg="#ffff00",
         color_bg="#000000",
         layout_options=LayoutOptions.row_top(1).with_updates(top=6,
                                                              right=1))
     super().__init__(subviews=[
         LabelView(
             text="Stats",
             color_fg='#ffffff',
             color_bg='#660000',
             clear=True,
             layout_options=LayoutOptions.row_top(1).with_updates(right=1)),
         self.health_label,
         self.progress_bar,
         self.inventory_count,
         self.score_label,
     ],
                      *args,
                      **kwargs)
     self.update()
Esempio n. 20
0
 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.")
Esempio n. 21
0
def command_reload(game, item):
    """ Command function for player wants to reload specific ranged weapon """
    director = game_view.GameLoop.active_director
    if isinstance(
            item,
            game_logic.ItemRangedWeapon):  # check if there is ranged weapon
        if len(item.ammo) < item.ammo_max:  # check if it is loaded
            # select appropriate ammo items
            ammos = [
                a for a in game.player.inventory
                if item.ammo_type in a.categories
            ]
            if ammos:
                if len(ammos) == 1:
                    game.player.perform(actions.act_reload, game.player, item,
                                        ammos[0])
                    game.start_update_thread()
                else:
                    director.push_scene(
                        game_view.AmmoItemSelectionScene(
                            items=ammos,
                            game=game,
                            ranged_weapon=item,
                            caption=_('Load ammo:'),
                            layout_options=LayoutOptions(top=0.30,
                                                         bottom=0.30,
                                                         left=0.30,
                                                         right=0.30)))
            else:
                game_logic.Game.add_message(
                    message=_('No {ammo_type} type ammunition.').format(
                        ammo_type=_(item.ammo_type)).capitalize(),
                    level='PLAYER',
                    color=[255, 255, 255])
        else:
            game_logic.Game.add_message(
                message=_('{item} is fully loaded.').format(
                    item=str(item)).capitalize(),
                level='PLAYER',
                color=[255, 255, 255])
Esempio n. 22
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)
Esempio n. 23
0
def command_throw_choose(game, main_scene):
    """ Command function for player wants to throw an item in hands - choose target """
    right = game.player.equipment['RIGHT_HAND']
    left = game.player.equipment['LEFT_HAND']
    items = [i for i in [right, left]
             if i is not None]  # pick equipment in hands
    if items:  # check if there are any
        if len(items) == 1:  # if one
            if game.player.get_throw_range(items[0]) > 0:
                main_scene.start_targeting(
                    range=game.player.get_throw_range(items[0]),
                    t_object=items[0],
                    eligible_types=(game_logic.BattleEntity, 'point'),
                    callback=command_throw,
                    player=game.player,
                    item=items[0])
            else:
                game_logic.Game.add_message(message=_(
                    '{item} is too heavy!'.format(
                        item=str(items[0])).capitalize()),
                                            level='PLAYER',
                                            color=[255, 255, 255])
        else:  # if multiple items in hands
            main_scene.director.push_scene(
                game_view.ThrowItemSelectionScene(items=items,
                                                  game=game,
                                                  caption=_('Throw item:'),
                                                  layout_options=LayoutOptions(
                                                      top=0.30,
                                                      bottom=0.30,
                                                      left=0.30,
                                                      right=0.30)))
    else:
        game_logic.Game.add_message(
            message=_('Take something in hand to throw it.'),
            level='PLAYER',
            color=[255, 255, 255])
Esempio n. 24
0
def command_fire_choose(game):
    """ Command function for player wants to fire ranged weapon - choose target """
    director = game_view.GameLoop.active_director
    ranged_weapons = [
        w for w in list(game.player.equipment.values())
        if isinstance(w, game_logic.ItemRangedWeapon)
    ]  # pick ranged weapons in equipment
    if ranged_weapons:  # check if there are any
        if len(ranged_weapons) == 1:  # if one
            if len(ranged_weapons[0].ammo) > 0:  # if it has ammo loaded
                director.main_game_scene.start_targeting(
                    range=ranged_weapons[0].range,
                    t_object=ranged_weapons[0],
                    eligible_types=(game_logic.BattleEntity, 'point'),
                    callback=command_fire,
                    player=game.player,
                    weapon=ranged_weapons[0])
            else:
                game_logic.Game.add_message(
                    message=_("{weapon} isn't loaded!").format(
                        weapon=str(ranged_weapons[0]).capitalize()),
                    level='PLAYER',
                    color=[255, 255, 255])
        else:  # if multiple ranged equipped
            director.push_scene(
                game_view.FireItemSelectionScene(items=ranged_weapons,
                                                 game=game,
                                                 caption=_('Fire weapon:'),
                                                 layout_options=LayoutOptions(
                                                     top=0.30,
                                                     bottom=0.30,
                                                     left=0.30,
                                                     right=0.30)))
    else:
        game_logic.Game.add_message(message=_('Equip ranged weapon to fire.'),
                                    level='PLAYER',
                                    color=[255, 255, 255])
Esempio n. 25
0
def command_pick_up(game, dx, dy):
    """ Command function for player wants to pick up some items  """
    director = game_view.GameLoop.active_director
    player = game.player
    loc = game.current_loc
    x = player.position[0] + dx
    y = player.position[1] + dy
    if loc.is_in_boundaries(
            x, y):  # check if position of selected cell is in boundaries
        items = [
            i for i in loc.cells[x][y].entities
            if isinstance(i, game_logic.Item)
        ]  # select items in cell
        if items:  # check if there is an item
            if len(items) == 1:
                if isinstance(items[0], game_logic.ItemCharges) and\
                        'stackable' in items[0].categories and items[0].charges > 1:
                    director.push_scene(
                        game_view.NumberInputScene(
                            num_range=(1, items[0].charges),
                            num_start=items[0].charges,
                            title=str(items[0]),
                            callback=lambda text, item=items[0], game=game:
                            _split_stack_and_pick(text, item, game)))
                else:
                    player.perform(actions.act_pick_up_item, player, items[0])
            else:  # if there are multiple Items - ask which to pick up?
                director.push_scene(
                    game_view.PickUpItemSelectionScene(
                        items=items,
                        game=game,
                        caption=_('Pick up item:'),
                        layout_options=LayoutOptions(top=0.25,
                                                     bottom=0.25,
                                                     left=0.2,
                                                     right=0.2)))
Esempio n. 26
0
 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)
Esempio n. 27
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 = {}