Ejemplo n.º 1
0
    def __init__(self, inventory, party, width, height, x=0, y=0, theme=None,
                 bg=None, mouse_control=Menu.MOUSE_LOOSE):
        self.inventory = inventory
        self.party = party
        Menu.__init__(self, width, height, x, y, theme, bg, mouse_control)

        self.close_label = CloseLabel()
        self.add_widget(self.close_label, (20, 12))

        self.inventory_panel = Panel(self.width * 0.55, self.height - 50)
        self.add_widget(self.inventory_panel,
                        (16, self.height - 16, LEFT, DOWN))
        
        self.inventory_scroll = ItemScrollArea(self.inventory,
                                               self.inventory_panel.width - 10,
                                               self.inventory_panel.height - 10,
                                               graphics_config.item_icon_height
                                               + 12,
                                               (20, 10))
        self.inventory_panel.add_widget(self.inventory_scroll, (5, 5))
        
        self.info_panel = ItemInfoPanel(self.width * 0.35, self.height * 0.55)
        info_x = self.width - 16
        info_y = self.height - 16
        self.add_widget(self.info_panel, (info_x, info_y, RIGHT, DOWN))
        
        cursor = Cursor()
        cursor.bind(self)

        self.config_action_dialog(100, 60, TRANSPARENT)
Ejemplo n.º 2
0
    def __init__(self):
        Menu.__init__(self, 400, 300)
        self.panel = Panel(200, 150)
        self.add_widget(self.panel, (40, 80))

        self.add_widget(MenuLabel(), (90, 20))
        self.add_widget(Label('NonFocusable', focusable=False), (150, 20))

        first_panel_label = Label('Panel0')
        self.panel.add_widget(first_panel_label, (40, 20))
        self.panel.add_widget(Label('Panel1'), (120, 20))
        self.panel.add_widget(Label('Panel2'), (40, 60))
        self.panel.add_widget(Label('Panel3'), (120, 60))
        self.panel.add_widget(AdjustableBar(100, 14, filled=0.9), (50, 100))

        side_panel = Panel(110, 220)
        self.add_widget(side_panel, (260, 40))

        grid = AdjustableVerticalGrid(110, 72, 2, 6)
        side_panel.add_widget(grid, AlignTopLeft())

        img = pygame.image.load(data_path('icon.png'))
        #img = pygame.image.load(data_path('test.png'))
        self.add_widget(ImageWidget(img), (8, 8))

        group = WidgetGroup(148, 20)
        group.add_widget(Label('Group0'), (10, 0))
        group.add_widget(Label('Group1'), (90, 0))
        self.add_widget(group, (60, 240))

        #self.crystallize()

        # Add cursor
        cursor = Cursor()
        cursor.bind(self, first_panel_label)
Ejemplo n.º 3
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement

        Menu.__init__(self,
                      g_cfg.screen_width - 2 * cfg.border_width,
                      g_cfg.screen_height / 2 - 2 * cfg.border_width,
                      cfg.border_width,
                      g_cfg.screen_height / 2 + cfg.border_width,
                      bg=TRANSPARENT,
                      blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        font = self.theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text, box_width, font)

        # Draw message
        y_acc = 0
        for line in lines:
            label = Label(line[2])
            panel.add_widget(label,
                             (cfg.border_width, cfg.border_width + y_acc))
            y_acc += line[1] + cfg.line_spacing
Ejemplo n.º 4
0
    def __init__(self, item_menu, item, quantity, item_entry, width, height,
                 x=0, y=0, theme=None, bg=TRANSPARENT,
                 mouse_control=Menu.MOUSE_LOOSE):
        Menu.__init__(self, width, height, x, y, theme, bg, mouse_control)
        self.item_menu = item_menu

        self.item = item
        self.quantity = quantity

        self.panel = Panel(width, height)
        self.add_widget(self.panel, (0, 0))
        
        if hasattr(item, 'use'):
            self.use_label = UseLabel(self.item, self.item_menu.inventory,
                                      self.item_menu.party, item_entry)
        else:
            self.use_label = TrashLabel(self.item, self.item_menu.inventory, 
                                        item_entry)
        self.panel.add_widget(self.use_label, (20, 12))

        self.close_label = CloseLabel()
        self.panel.add_widget(self.close_label, (20, 36))

        cursor = Cursor()
        cursor.bind(self)
Ejemplo n.º 5
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement

        # Split into lines
        theme = menu_config.theme
        font = theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text, box_width, font)

        # Calculate box size
        self.box_height = (sum([line[1] for line in lines]) +
                           (len(lines) - 1) * cfg.line_spacing +
                           4 * cfg.border_width)
        assert self.box_height < g_cfg.screen_height,\
               'Too much text for one box.'

        Menu.__init__(self, g_cfg.screen_width - 2 * cfg.border_width,
                            self.box_height - 2 * cfg.border_width,
                            cfg.border_width,
                            g_cfg.screen_height - self.box_height\
                            + cfg.border_width,
                            bg=TRANSPARENT,
                            blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        # Draw message
        y_acc = 0
        for line in lines:
            label = Label(line[2])
            panel.add_widget(label,
                             (cfg.border_width, cfg.border_width + y_acc))
            y_acc += line[0] + cfg.line_spacing
Ejemplo n.º 6
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement
        self.current_panel = None

        Menu.__init__(self,
                      g_cfg.screen_width - 2 * cfg.border_width,
                      g_cfg.screen_height / 2 - 2 * cfg.border_width,
                      cfg.border_width,
                      g_cfg.screen_height / 2 + cfg.border_width,
                      bg=TRANSPARENT,
                      blocking=block_movement)

        # Split into lines
        font = self.theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text, box_width, font)

        # Split into boxes
        box_height = g_cfg.screen_height / 2 - 4 * cfg.border_width
        self.boxes = split_boxes(lines, box_height, cfg.line_spacing)
        self.panels = []

        # Draw panels
        for box in self.boxes:
            panel = Panel(self.width, self.height)
            y_acc = 0
            for line in box:
                label = Label(line[2])
                panel.add_widget(label,
                                 (cfg.border_width, cfg.border_width + y_acc))
                y_acc += line[1] + cfg.line_spacing
            self.panels.append(panel)

        self.advance_panel()
Ejemplo n.º 7
0
    def __init__(self,
                 item_menu,
                 item,
                 quantity,
                 item_entry,
                 width,
                 height,
                 x=0,
                 y=0,
                 theme=None,
                 bg=TRANSPARENT,
                 mouse_control=Menu.MOUSE_LOOSE):
        Menu.__init__(self, width, height, x, y, theme, bg, mouse_control)
        self.item_menu = item_menu

        self.item = item
        self.quantity = quantity

        self.panel = Panel(width, height)
        self.add_widget(self.panel, (0, 0))

        if hasattr(item, 'use'):
            self.use_label = UseLabel(self.item, self.item_menu.inventory,
                                      self.item_menu.party, item_entry)
        else:
            self.use_label = TrashLabel(self.item, self.item_menu.inventory,
                                        item_entry)
        self.panel.add_widget(self.use_label, (20, 12))

        self.close_label = CloseLabel()
        self.panel.add_widget(self.close_label, (20, 36))

        cursor = Cursor()
        cursor.bind(self)
Ejemplo n.º 8
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement

        Menu.__init__(self, g_cfg.screen_width - 2 * cfg.border_width,
                            g_cfg.screen_height / 2 - 2 * cfg.border_width,
                            cfg.border_width,
                            g_cfg.screen_height / 2 + cfg.border_width,
                            bg=TRANSPARENT,
                            blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        font = self.theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text,
                            box_width,
                            font)

        # Draw message
        y_acc = 0
        for line in lines:
            label = Label(line[2])
            panel.add_widget(label,
                             (cfg.border_width,
                              cfg.border_width + y_acc))
            y_acc += line[1] + cfg.line_spacing
Ejemplo n.º 9
0
    def __init__(self,
                 text,
                 choices,
                 user_data=None,
                 completion_callback=None,
                 block_movement=True):
        self.block_movement = block_movement
        self.text = text
        self.choices = choices
        self.completion_callback = completion_callback
        self.user_data = user_data

        Menu.__init__(self,
                      g_cfg.screen_width - 2 * cfg.border_width,
                      g_cfg.screen_height / 2 - 2 * cfg.border_width,
                      cfg.border_width,
                      g_cfg.screen_height / 2 + cfg.border_width,
                      bg=TRANSPARENT,
                      blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        # Build lines and choice lines
        font = self.theme.get_font(cfg.font_size)
        self.__build_lines(font)

        # Draw message
        y_acc = 0
        for line in self.lines:
            label = Label(line[2], focusable=False)
            panel.add_widget(label,
                             (cfg.border_width, cfg.border_width + y_acc))
            y_acc += line[1] + cfg.line_spacing

        self.starting_option = None
        for index, line in enumerate(self.choice_lines):
            label = ChoiceLabel(line[2], index)
            panel.add_widget(label,
                             (2 * cfg.border_width, cfg.border_width + y_acc))
            y_acc += line[1] + cfg.choice_line_spacing
            if self.starting_option is None:
                self.starting_option = label

        Cursor(ArrowCursorTheme()).bind(self, self.starting_option)
Ejemplo n.º 10
0
    def __init__(self, match):
        self.match = match
        
        w, h = g_cfg.screen_dimensions
        Menu.__init__(self, w, h)

        self.ingame = Ingame(match.match_team1, match.match_team2)
        self.ingame.register(self)
        
        self.team_panels = []
        
        SPACING = 10
        TEAM_PANELS_H = 230
        
        COMMAND_PANEL_H = 50
        
        team_panel = TeamPanel(match.match_team1, (w - 3 * SPACING) / 2,
                               TEAM_PANELS_H) 
        self.add_widget(team_panel, (SPACING, SPACING))
        self.team_panels.append(team_panel)
        
        team_panel = TeamPanel(match.match_team2, (w - 3 * SPACING) / 2,
                               TEAM_PANELS_H) 
        self.add_widget(team_panel, (SPACING, self.team_panels[0].bottom + SPACING))
        self.team_panels.append(team_panel)
        
        self.match_panel = MatchPanel(self.ingame, w - 2 * SPACING,
                                      h - 2 * TEAM_PANELS_H - 5 * SPACING - COMMAND_PANEL_H)
        self.add_widget(self.match_panel, (SPACING, 2 * TEAM_PANELS_H + 3 * SPACING))
        
        self.command_panel = CommandPanel(w - 2 * SPACING, COMMAND_PANEL_H)
        self.add_widget(self.command_panel, (SPACING, h - SPACING, LEFT, DOWN))
        
        self.chalkboard_panel = ChalkboardPanel(self.ingame,
                                                (w - 3 * SPACING) / 2,
                                                2 * TEAM_PANELS_H + SPACING)
        self.add_widget(self.chalkboard_panel, (w - SPACING, SPACING, RIGHT, UP))
        
        cursor = Cursor(DefaultCursorTheme(border=1, horizontal_offset=0,
                                           vertical_offset=0))
        cursor.bind(self)
        
        self.speed = None
        self.command_panel.speed_labels[2].activate()
Ejemplo n.º 11
0
 def __init__(self, simulation):
     Menu.__init__(self, graphics_config.screen_width,
                   graphics_config.screen_height)
     self.simulation = simulation
     
     y = 20
     Y_SEPARATION = 40
     
     x = 20
     l = ExitLabel()
     self.add_widget(l, (x, y))
     
     y += Y_SEPARATION
     l = AdvanceLabel()
     self.add_widget(l, (x, y))
     
     y += Y_SEPARATION
     txt = 'My team is %s' % self.simulation.player_team_name
     self.my_team_label = Label(txt, focusable=False)
     self.add_widget(self.my_team_label, (x, y))
     
     y += Y_SEPARATION
     self.opponent_label = Label(text='', focusable=False)
     self.add_widget(self.opponent_label, (x, y))
     
     y += Y_SEPARATION
     self.last_game_label = Label(text='', focusable=False)
     self.add_widget(self.last_game_label, (x, y))
     
     y += Y_SEPARATION
     self.records_label = Label(text='', focusable=False)
     self.add_widget(self.records_label, (x, y))
     
     y += Y_SEPARATION
     self.date_label = Label(text='', focusable=False)
     self.add_widget(self.date_label, (x, y))
     
     c = Cursor()
     c.bind(self)
     
     self.update_next_game()
     self.update_standings()
     self.update_date()
Ejemplo n.º 12
0
    def __init__(self, text, choices, user_data=None, completion_callback=None,
                 block_movement=True):
        self.block_movement = block_movement
        self.text = text
        self.choices = choices
        self.completion_callback = completion_callback
        self.user_data = user_data

        Menu.__init__(self, g_cfg.screen_width - 2 * cfg.border_width,
                            g_cfg.screen_height / 2 - 2 * cfg.border_width,
                            cfg.border_width,
                            g_cfg.screen_height / 2 + cfg.border_width,
                            bg=TRANSPARENT,
                            blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        # Build lines and choice lines
        font = self.theme.get_font(cfg.font_size)
        self.__build_lines(font)

        # Draw message
        y_acc = 0
        for line in self.lines:
            label = Label(line[2], focusable=False)
            panel.add_widget(label,
                             (cfg.border_width,
                              cfg.border_width + y_acc))
            y_acc += line[1] + cfg.line_spacing

        self.starting_option = None
        for index, line in enumerate(self.choice_lines):
            label = ChoiceLabel(line[2], index)
            panel.add_widget(label,
                             (2 * cfg.border_width,
                              cfg.border_width + y_acc))
            y_acc += line[1] + cfg.choice_line_spacing
            if self.starting_option is None:
                self.starting_option = label

        Cursor(ArrowCursorTheme()).bind(self, self.starting_option)
Ejemplo n.º 13
0
    def __init__(self):
        Menu.__init__(self, 480, 320)
        tab_group = TabGroup(['Bars%d' % (i + 1) for i in xrange(self.TABS)],
                             480,
                             320,
                             tab_height=30)
        self.add_widget(tab_group, AlignCenter())

        # Bar tabs
        for k in xrange(4):
            grid = Grid(480, 290, 4, 10)
            for i in xrange(4):
                for j in xrange(10):
                    grid[i, j].add_widget(Panel(120, 29), AlignCenter())
                    width = 10 + 10 * (i + 1)
                    height = 1 + j
                    bar = CrazyBar(width, height)
                    grid[i, j].add_widget(bar, AlignCenter())
            tab_group[k].add_widget(grid, AlignCenter())

        # Animated image tab
        surfaces = []
        for k in xrange(25):
            s = pygame.Surface((100, 100))
            s.fill(((25 - k) * 10, 0, k * 10))
            surfaces.append(s)
        for k in xrange(25):
            s = pygame.Surface((100, 100))
            s.fill((0, k * 10, (25 - k) * 10))
            surfaces.append(s)
        for k in xrange(25):
            s = pygame.Surface((100, 100))
            s.fill((k * 10, (25 - k) * 10, 0))
            surfaces.append(s)
        animation = AnimatedImage(surfaces, 1)
        a = AnimatedImageWidget(animation, False)
        tab_group[4].add_widget(a, AlignTop())

        # Add cursor
        cursor = Cursor()
        cursor.bind(self)
Ejemplo n.º 14
0
    def __init__(self):
        Menu.__init__(self, 480, 320)
        tab_group = TabGroup(['Bars%d' % (i + 1) for i in xrange(self.TABS)],
                             480, 320, tab_height=30)
        self.add_widget(tab_group, AlignCenter())

        # Bar tabs
        for k in xrange(4):
            grid = Grid(480, 290, 4, 10)
            for i in xrange(4):
                for j in xrange(10):
                    grid[i, j].add_widget(Panel(120, 29), AlignCenter())
                    width = 10 + 10 * (i + 1)
                    height = 1 + j
                    bar = CrazyBar(width, height)
                    grid[i, j].add_widget(bar, AlignCenter())
            tab_group[k].add_widget(grid, AlignCenter())

        # Animated image tab
        surfaces = []
        for k in xrange(25):
            s = pygame.Surface((100, 100))
            s.fill(((25 - k) * 10, 0, k * 10))
            surfaces.append(s)
        for k in xrange(25):
            s = pygame.Surface((100, 100))
            s.fill((0, k * 10, (25 - k) * 10))
            surfaces.append(s)
        for k in xrange(25):
            s = pygame.Surface((100, 100))
            s.fill((k * 10, (25 - k) * 10, 0))
            surfaces.append(s)
        animation = AnimatedImage(surfaces, 1)
        a = AnimatedImageWidget(animation, False)
        tab_group[4].add_widget(a, AlignTop())

        # Add cursor
        cursor = Cursor()
        cursor.bind(self)
Ejemplo n.º 15
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement

        # Split into lines
        theme = menu_config.theme
        font = theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text,
                            box_width,
                            font)

        # Calculate box size
        self.box_height = (sum([line[1] for line in lines])
                           + (len(lines) - 1) * cfg.line_spacing
                           + 4 * cfg.border_width)
        assert self.box_height < g_cfg.screen_height,\
               'Too much text for one box.'

        Menu.__init__(self, g_cfg.screen_width - 2 * cfg.border_width,
                            self.box_height - 2 * cfg.border_width,
                            cfg.border_width,
                            g_cfg.screen_height - self.box_height\
                            + cfg.border_width,
                            bg=TRANSPARENT,
                            blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        # Draw message
        y_acc = 0
        for line in lines:
            label = Label(line[2])
            panel.add_widget(label,
                             (cfg.border_width,
                              cfg.border_width + y_acc))
            y_acc += line[0] + cfg.line_spacing
Ejemplo n.º 16
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement
        self.current_panel = None

        Menu.__init__(self, g_cfg.screen_width - 2 * cfg.border_width,
                            g_cfg.screen_height / 2 - 2 * cfg.border_width,
                            cfg.border_width,
                            g_cfg.screen_height / 2 + cfg.border_width,
                            bg=TRANSPARENT,
                            blocking=block_movement)

        # Split into lines
        font = self.theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text,
                            box_width,
                            font)

        # Split into boxes
        box_height = g_cfg.screen_height / 2 - 4 * cfg.border_width
        self.boxes = split_boxes(lines, box_height, cfg.line_spacing)
        self.panels = []

        # Draw panels
        for box in self.boxes:
            panel = Panel(self.width, self.height)
            y_acc = 0
            for line in box:
                label = Label(line[2])
                panel.add_widget(label,
                                 (cfg.border_width,
                                  cfg.border_width + y_acc))
                y_acc += line[1] + cfg.line_spacing
            self.panels.append(panel)

        self.advance_panel()
Ejemplo n.º 17
0
    def __init__(self):
        Menu.__init__(self, 400, 300)
        self.panel = Panel(200, 150)
        self.add_widget(self.panel, (40, 80))

        self.add_widget(MenuLabel(), (90, 20))
        self.add_widget(Label('NonFocusable', focusable=False), (150, 20))

        first_panel_label = Label('Panel0')
        self.panel.add_widget(first_panel_label, (40, 20))
        self.panel.add_widget(Label('Panel1'), (120, 20))
        self.panel.add_widget(Label('Panel2'), (40, 60))
        self.panel.add_widget(Label('Panel3'), (120, 60))
        self.panel.add_widget(AdjustableBar(100, 14, filled=0.9),
                              (50, 100))

        side_panel = Panel(110, 220)
        self.add_widget(side_panel, (260, 40))

        grid = AdjustableVerticalGrid(110, 72, 2, 6)
        side_panel.add_widget(grid, AlignTopLeft())

        img = pygame.image.load(data_path('icon.png'))
        #img = pygame.image.load(data_path('test.png'))
        self.add_widget(ImageWidget(img), (8, 8))

        group = WidgetGroup(148, 20)
        group.add_widget(Label('Group0'), (10, 0))
        group.add_widget(Label('Group1'), (90, 0))
        self.add_widget(group, (60, 240))

        #self.crystallize()

        # Add cursor
        cursor = Cursor()
        cursor.bind(self, first_panel_label)
Ejemplo n.º 18
0
    def __init__(self,
                 inventory,
                 party,
                 width,
                 height,
                 x=0,
                 y=0,
                 theme=None,
                 bg=None,
                 mouse_control=Menu.MOUSE_LOOSE):
        self.inventory = inventory
        self.party = party
        Menu.__init__(self, width, height, x, y, theme, bg, mouse_control)

        self.close_label = CloseLabel()
        self.add_widget(self.close_label, (20, 12))

        self.inventory_panel = Panel(self.width * 0.55, self.height - 50)
        self.add_widget(self.inventory_panel,
                        (16, self.height - 16, LEFT, DOWN))

        self.inventory_scroll = ItemScrollArea(
            self.inventory, self.inventory_panel.width - 10,
            self.inventory_panel.height - 10,
            graphics_config.item_icon_height + 12, (20, 10))
        self.inventory_panel.add_widget(self.inventory_scroll, (5, 5))

        self.info_panel = ItemInfoPanel(self.width * 0.35, self.height * 0.55)
        info_x = self.width - 16
        info_y = self.height - 16
        self.add_widget(self.info_panel, (info_x, info_y, RIGHT, DOWN))

        cursor = Cursor()
        cursor.bind(self)

        self.config_action_dialog(100, 60, TRANSPARENT)