Ejemplo n.º 1
0
    def layout(self):
        self._rmtemp()

        itemlist = []
        for itemfile in file_list('items'):
            itemfile = os.path.basename(itemfile)
            itemlist.append(Item(load_yaml('items',itemfile)))
        inventory_rect = pygame.Rect(self.rect.x,self.rect.y, self.rect.w - 523, self.rect.h)
        pack = ContainerDialog(
            inventory_rect,
            self.frontend,
            'Pack:',
            layer=self._layer +1,
            items=[Item(i) for i in self.char.get('inventory/pack',[])],
            onclose=self.update_inventory,
            onselect=self.equip_item,
            onselect_parms=[],
            can_add=False,
            can_remove=False,
            addfrom=itemlist
            )
        self._addtemp('Inventory_pack_dialog', pack)
        image_x = self.rect.w - 522
        image_y = 10
        self.image.blit(self.frontend.imagecache['inventory_background.png'], (image_x, image_y))
        rects = load_yaml('images','gui_rects.yaml')
        debug(self.char())
        portrait = self.frontend.imagecache[self.char.get('personal/portrait')]
        portrait = pygame.transform.smoothscale(portrait, (256,256))
        prect = rects['inventory_portrait']
        self.image.blit(portrait,(image_x + prect['x'],image_y + prect['y']))
        image_x += self.rect.x
        image_y += self.rect.y
        for itemtuple in self.char.inventory_generator(['equiped']):
            debug(itemtuple)
            item, slot = itemtuple[1], itemtuple[2]
            irect = rects[slot]
            irect = pygame.Rect(image_x + irect['x'], image_y + irect['y'], irect['w'], irect['h'])
            debug(slot, irect)
            sprite = ButtonSprite(
                self.frontend.tilemaps,
                irect,
                self.frontend.eventstack,
                onclick=self.unequip_item,
                onclick_params=[slot],
                animations=item.getsubtree('animations'),
                layer=self._layer + 2,
                fps=5,
                mouseover=item.displayname(),
                frontend=self.frontend,
                sendself=True
                )
            sprite.setanimation('view')
            self._addtemp(make_hash(), sprite)
Ejemplo n.º 2
0
 def zoomicons(self, x, y, scn_x, scn_y):
     objlist = list(self.gamemap.tile_objects(x,y))
     n = len(objlist)
     if not n:
         return
     col, row = 0, 0
     if n%2 != 0:
         n += 1
     colcount = n/2
     if n < 4:
         scale = int(128/n)
     else:
         scale = int(128/colcount)
     for objtype,item in objlist:
         s_x = scn_x + col*scale
         s_y = scn_y + row*scale
         rect = pygame.Rect(s_x, s_y, scale, scale)
         if objtype != 'money':
             animations = item.getsubtree('animations')
             name=item.displayname()
         else:
             animations = item
             name='Money'
         itemsprite = ButtonSprite(
         self.frontend.tilemaps,
         rect,
         self.frontend.eventstack,
         onclick = self.targetclick,
         onclick_params = [x,y,objtype, item],
         animations = animations,
         layer=self._layer+2,
         mouseover=name,
         fps=5,
         frontend=self.frontend)
         if objtype == 'npc':
             itemsprite.setanimation('stand')
         else:
             itemsprite.setanimation('view')
         self._addtemp(make_hash(), itemsprite)
         col += 1
         if col == colcount:
             col = 0
             row += 1