Esempio n. 1
0
 def load(self):
     for image in file_list('images', '*.png'):
         debug('Loading: ',image)
         key = os.path.basename(image)
         self[key] = pygame.image.load(image).convert_alpha()
     for image in file_list('portraits', '*.png'):
         key = 'portrait_%s' % os.path.basename(image)
         debug ('Loading: ', key)
         self[key] = pygame.image.load(image).convert_alpha()
     gui_map = load_yaml('images', 'gui_rects.yaml')
     for key in gui_map:
         rect = pygame.Rect(gui_map[key]['x'], gui_map[key]['y'], gui_map[key]['w'], gui_map[key]['h'])
         try:
             self.assign(key, 'RPG_GUI_v1.png', rect)
         except:
             debug(key, rect)
             raise
     self.gui_map = gui_map
Esempio n. 2
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)
Esempio n. 3
0
 def listmanager(self,keyname, items):
     self._rmtemp()
     itemlist = []
     for itemfile in file_list('items'):
         itemfile = os.path.basename(itemfile)
         itemlist.append(Item(load_yaml('items',itemfile)))
     c = ContainerDialog(self.rect,
         self.frontend,
         keyname,
         7,
         items=[Item(i) for i in items],
         onclose=self.updatelist,
         onclose_parms=[keyname],
         animation='view',
         can_add=True,
         can_remove=True,
         addfrom=itemlist)
     self._addtemp('%s_listmanager' %keyname, c)
Esempio n. 4
0
 def selectlist(self, dirname,action, x, y):
     self._rmtemp()
     itemlist = []
     for itemfile in file_list(dirname):
         itemfile = os.path.basename(itemfile)
         itemlist.append(Item(load_yaml(dirname,itemfile)))
     c = ContainerDialog(self.rect,
         self.frontend,
         'Add %s' % dirname,
         self._layer + 1,
         items=itemlist,
         onclose=action,
         onclose_parms=[x,y],
         onselect=action,
         onselect_parms=[x,y],
         animation='view',
         can_add=False,
         can_remove=False)
     self._addtemp('te_listmanager' , c)
Esempio n. 5
0
 def _package(self):
     ensure_dir(self.j('{release_dir}'))
     pkg_root = self.j('{prefix_dir}')
     # Create the package listing file.
     files = list(file_list(self.j('{prefix_dir}')))
     pkg_list_fn = self.j('{prefix_dir}', 'share', 'xyz', '{variant_name}')
     self.ensure_dir(os.path.dirname(pkg_list_fn))
     with open(pkg_list_fn, 'w') as pkg_list_f:
         pkg_list_f.write('{variant_name}\n'.format(**self.config))
         if not self.group_only:
             pkg_list_f.write("Source Version: {}\n".format(git_ver('{source_dir}'.format(**self.config))))
         pkg_list_f.write("XYZ Version: {}\n".format(git_ver('.')))
         pkg_list_f.write('\n')
         for fn in files:
             pkg_list_f.write('{} {}\n'.format(
                              sha256_file(self.j('{prefix_dir}', fn)),
                              fn))
     logger.info("Creating tar.gz %s/%s -> %s", os.getcwd(), pkg_root, self.config['release_file'])
     tar_gz('{release_file}'.format(**self.config), pkg_root)
Esempio n. 6
0
 def load(self):
     self._rmtemp()
     itemlist = []
     for itemfile in file_list(self.dirname):
         itemfile = os.path.basename(itemfile)
         if self.dirname == 'items':
             itemlist.append(Item(load_yaml(self.dirname,itemfile)))
         else:
             itemlist.append(NPC(load_yaml(self.dirname,itemfile)))
     c = ContainerDialog(self.rect,
         self.frontend,
         'Load %s' %self.dirname,
         7,
         items=itemlist,
         onselect=self.loaditem,
         onselect_parms=[],
         animation='view',
         can_add=False,
         can_remove=False
         )
     self._addtemp(make_hash(), c)
Esempio n. 7
0
 def __init__(self, rect, frontend, onselect):
     self.onselect = onselect
     self.frontend = frontend
     self.rect = rect
     self._layer=5
     FloatDialog.__init__(self, rect, self.frontend)
     prevbtn = Button('Prev', self.prev, [], self.frontend.eventstack, self.frontend.imagecache, (rect.x+10,rect.y+rect.h-50), layer=6)
     nextbtn = Button('Next', self.next, [], self.frontend.eventstack, self.frontend.imagecache, (rect.x+rect.w-100,rect.y+rect.h-50), layer=6)
     self.clickhash = self.frontend.eventstack.register_event("button1", self, self.click)
     self._addtemp('ts_prevbtn', prevbtn)
     self._addtemp('ts_nextbtn', nextbtn)
     counter = 0
     self.page = 0
     self.pages = [[]]
     pagecounter=0
     for mapfile in file_list('maps'):
         if counter >= 9:
             self.pages.append([])
             pagecounter += 1
         counter += 1
         self.pages[pagecounter].append(self.minimap(mapfile))
     self.update()