コード例 #1
0
ファイル: ui.py プロジェクト: nuds7/FragileTruck---pyglet
    def __init__(self, x, y, width, height, item_list, parent_group):
        self.pos = x, y
        # parent_group 	= pyglet.graphics.OrderedGroup(1)
        self.group_1 = pyglet.graphics.OrderedGroup(20, parent=parent_group)
        self.group_2 = pyglet.graphics.OrderedGroup(21, parent=parent_group)
        self.mask = GroupWithMask(x - width // 2, y - height // 2, width, height, parent=self.group_2)
        self.group_3 = pyglet.graphics.OrderedGroup(22, parent=parent_group)
        self.group_4 = pyglet.graphics.OrderedGroup(23, parent=parent_group)

        self.buttons = []
        self.y_offset = 0
        for item in item_list:
            button = State_Button(
                [x, y + self.y_offset + (height // 2) - 30], "menu/images/level_long.png", padding=(0, -4, 0, -2)
            )
            # keep a note of the space between
            # the first button and the next
            button.y_offset = self.y_offset
            self.y_offset -= button.sprite.image.height
            self.buttons.append(button)

            # check if the list is even worthy of
            # being scrollable
        if abs(self.y_offset) > height:
            self.scrollable = True
        else:
            self.scrollable = False

        self.bb = pymunk.BB(x - width // 2, y - height // 2, x + width // 2, y + height // 2)

        self.top_left = x - width // 2, y + height // 2
        self.bottom_left = x - width // 2, y - height // 2
        self.top_right = x + width // 2, y + height // 2
        self.bottom_right = x + width // 2, y - height // 2

        self.red = (255, 0, 0, 255)
        self.green = (0, 255, 0, 255)

        self.weighted = 0
        self.scroll_y = 0
        self.contains_mouse = False

        self.top_limit = y + height // 2 - self.buttons[0].sprite.image.height // 2 - 3
        self.bottom_stopper = y - height // 2 + abs(self.y_offset) - self.buttons[0].sprite.image.height // 2 + 2

        self.scroll_amount = 0
        self.rate = 10

        self.close_button = State_Button([x + 120, y + 194], "menu/images/x.png", padding=(-1, -1, -1, -1))