示例#1
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()
示例#2
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
示例#3
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
示例#4
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)
示例#5
0
    def __init__(self, width, height):
        Panel.__init__(self, width, height, focusable=False)

        self.item_icon = ImageWidget(None, focusable=False)
        x = 10
        y = 10
        self.add_widget(self.item_icon, (x, y))

        self.item_name = Label("", focusable=False)
        x = 10 + graphics_config.item_icon_width + 5
        y = 10 + (graphics_config.item_icon_height - self.item_name.height) / 2
        self.add_widget(self.item_name, (x, y))

        self.item_description = Label("",
                                      self.width - 20,
                                      size=10,
                                      focusable=False)
        x = 10
        y = (10 +
             max(self.item_name.height, graphics_config.item_icon_height) + 10)
        self.add_widget(self.item_description, (x, y))
示例#6
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)
示例#7
0
    def __init__(self, width, height, item, inventory):
        WidgetGroup.__init__(self, width, height)
        self.item = item
        self.quantity = inventory.get_amount(item)
        self.inventory = inventory

        self.icon = ImageWidget()
        i = item.get_icon()
        if i is not None:
            self.icon.surf = i.get_surface()
        else:
            self.icon.surf = None
        self.add_widget(self.icon, (0, 0))

        s = self.create_string()
        self.label = Label(s)
        label_y = height / 2 - self.label.height / 2
        self.add_widget(self.label,
                        (5 + graphics_config.item_icon_width, label_y))
示例#8
0
 def __init__(self):
     Label.__init__(self, 'Exit', size=20)
示例#9
0
 def __init__(self, text, speed):
     Label.__init__(self, text, size=20)
     self.speed = speed
示例#10
0
 def __init__(self, width, height, height_in_cells, max_height):
     VerticalGrid.__init__(self, width, height, height_in_cells)
     self.max_height = max_height
     for i in range(height_in_cells):
         label = Label('SidePanel%d' % i)
         self[i].add_widget(label, AlignCenter())
示例#11
0
 def __init__(self, item, inv, party, item_entry):
     Label.__init__(self, 'Use')
     self.item = item
     self.inv = inv
     self.party = party
     self.item_entry = item_entry
示例#12
0
 def __init__(self):
     Label.__init__(self, 'Menu')
示例#13
0
 def __init__(self, text='Close'):
     Label.__init__(self, text)
示例#14
0
 def __init__(self, item, inv, item_entry):
     Label.__init__(self, 'Trash')
     self.item = item
     self.inv = inv
     self.item_entry = item_entry
示例#15
0
 def __init__(self, item, inv, party, item_entry):
     Label.__init__(self, 'Use')
     self.item = item
     self.inv = inv
     self.party = party
     self.item_entry = item_entry
示例#16
0
 def add_line(self):
     if self.height_in_cells < self.max_height:
         i = self.height_in_cells
         self.add_lines()
         label = Label('SidePanel%d' % i)
         self[i].add_widget(label, AlignCenter())
示例#17
0
 def __init__(self, text, index):
     Label.__init__(self, text, focusable=True)
     self.index = index
示例#18
0
 def __init__(self):
     Label.__init__(self, 'Advance')
示例#19
0
 def __init__(self):
     Label.__init__(self, 'Exit')
示例#20
0
文件: tab.py 项目: xjzpguob/libRPG
 def __init__(self, tab_group, id, theme=None):
     Label.__init__(self, id, focusable=True, theme=theme)
     self.tab_group = tab_group
     self.id = id
示例#21
0
 def __init__(self, text='Close'):
     Label.__init__(self, text)
示例#22
0
文件: dialog.py 项目: Eronarn/libRPG
 def __init__(self, text, index):
     Label.__init__(self, text, focusable=True)
     self.index = index
示例#23
0
 def __init__(self, item, inv, item_entry):
     Label.__init__(self, 'Trash')
     self.item = item
     self.inv = inv
     self.item_entry = item_entry
示例#24
0
 def __init__(self):
     Label.__init__(self, 'Menu')