Exemple #1
0
    def addEntry(self, title="No title", action=None, top=False):
        h = self.but_h
        w = self.but_w
        x = self.w.width / 2
        y = (
            self.w.height / 2 - (h * len(self.entries)) +
            self.spacing
        )
        if title == "New Game":
            btn_texture = self.w.textures["button_green_jagged"]
        elif title == "Exit":
            btn_texture = self.w.textures["button_red"]
        else:
            btn_texture = self.w.textures["button_brown"]
        b_sprite = Sprite(
                        btn_texture,
                        x=x,
                        y=y,
                        batch=self.w.batches["mm_buttons"],
                        group=self.w.ui_group,
                    )
        b_sprite.opacity = 150
        # b_sprite.width, b_sprite.height = 3, 1
        b_sprite.rectangle = create_rectangle(x, y, w, h)
        b_sprite.action = action
        b_sprite.label = text.Label(
            title, font_name='Visitor TT1 BRK',
            font_size=self.font_size,
            color=self.font_clr,
            x=x, y=y,
            batch=self.w.batches["mm_labels"],
            anchor_x="center", anchor_y="center"
        )
        b_sprite.label.oldfontsize = b_sprite.label.font_size
        b_sprite.orig_size = self.but_w, self.but_h
        b_sprite.bw, b_sprite.bh = b_sprite.orig_size

        if top:
            self.entries.insert(0, b_sprite)
            self.updateOffset()
        else:
            self.entries.append(b_sprite)
            self.updateOffset()