Exemplo n.º 1
0
    def onSelectElement(self, element=None):
        self.focus_element = element

        if self.element_icon:
            self.frame.removeElement(self.element_icon)
            self.element_icon = None

        if element:
            w, h = self.frame.rect.size
            icon = GraphicIcon(element.frame, element.avatar.faceImage, None)
            icon.rect = pygame.Rect(w - 32, 0, 32, 32)
            icon.load()
            element.frame.addElement(icon)
            self.element_icon = icon
Exemplo n.º 2
0
    def onSelectElement(self, element=None):
        self.focus_element = element

        if self.element_icon:
            self.frame.removeElement(self.element_icon)
            self.element_icon = None

        if element:
            w, h = self.frame.rect.size
            icon = GraphicIcon(element.frame, element.avatar.faceImage, None)
            icon.rect = pygame.Rect(w-32,0,32,32)
            icon.load()
            element.frame.addElement(icon)
            self.element_icon = icon
Exemplo n.º 3
0
def movementMenu(element, target):
    def closer(icon):
        icon.frame.removeElement(icon)
        icon.unload()

    def func(menu):
        import lib.blacksmith as b
        menu.close()

        camera = menu.element.camera
        body = camera.area.getBody(target.avatar)
        endpoint = camera.surfaceToWorld(menu.anchor)
        path = camera.area.pathfind(body.bbox.bottomcenter, endpoint)

        #s = area.MovementSentinal(body, path)
        #camera.area.add(s)

        image = Image("path.png")

        for node in path:
            y, x = node
            icon = GraphicIcon(element.frame, image, closer)
            icon.load()
            icon.rect = pygame.Rect(x * 16, y * 16, 16, 16)
            menu.frame.addElement(icon)

    image = ImageTile("spellicons.png", tile=(20, 3), tilesize=(32, 32))

    m = RoundMenu(element.frame, element)
    a = GraphicIcon(element.frame, image, func, [m])
    m.setIcons([a])
    return m
Exemplo n.º 4
0
def buildActionMenu(element):
    actions = element.avatar.queryActions(None)
    if actions:
        icons = [GraphicIcon(element.frame, a.icon, None) for a in actions]
        menu = RoundMenu(element.frame, element)
        menu.setIcons(icons)
        return menu
    else:
        return None
Exemplo n.º 5
0
    def func(menu):
        import lib.blacksmith as b
        menu.close()

        camera = menu.element.camera
        body = camera.area.getBody(target.avatar)
        endpoint = camera.surfaceToWorld(menu.anchor)
        path = camera.area.pathfind(body.bbox.bottomcenter, endpoint)

        #s = area.MovementSentinal(body, path)
        #camera.area.add(s)

        image = Image("path.png")

        for node in path:
            y, x = node
            icon = GraphicIcon(element.frame, image, closer)
            icon.load()
            icon.rect = pygame.Rect(x * 16, y * 16, 16, 16)
            menu.frame.addElement(icon)
Exemplo n.º 6
0
def testMenu(element):
    def func(menu):
        import lib.blacksmith as b
        menu.close()

        anvil = b.Anvil()
        anvil.loadAll()
        pos = menu.element.camera.surfaceToWorld(menu.anchor) - (16, 16, 0)
        menu.element.camera.area.add(anvil)
        menu.element.camera.area.setPosition(anvil, pos)

    image = Image("grasp.png")

    m = RoundMenu(element.frame, element)
    a = GraphicIcon(element.frame, image, func, [m])
    b = GraphicIcon(element.frame, image, func, [m])
    c = GraphicIcon(element.frame, image, func, [m])
    d = GraphicIcon(element.frame, image, func, [m])
    m.setIcons([a, b, c, d])
    return m
Exemplo n.º 7
0
    def func(menu):
        import lib.blacksmith as b
        menu.close()

        camera = menu.element.camera
        body = camera.area.getBody(target.avatar)
        endpoint = camera.surfaceToWorld(menu.anchor)
        path = camera.area.pathfind(body.bbox.bottomcenter, endpoint)

        #s = area.MovementSentinal(body, path)
        #camera.area.add(s)

        image = Image("path.png")

        for node in path:
            y, x = node
            icon = GraphicIcon(element.frame, image, closer)
            icon.load()
            icon.rect = pygame.Rect(x*16, y*16, 16, 16)
            menu.frame.addElement(icon)