def packer(map_name='wmap', save_to=None): import texture import packer utils.pg_init() textures = texture.TextureGroup.get_group(map_name) with utils.timeit_context('Packing'): pack = packer.ImagePack(img.image for _, img in textures.iter_all()) if save_to: pg.image.save(pack.image, save_to) else: utils.show_surface(pack.image)
if cls._data is None: with open(config.dataFile, 'rb') as infile: data = pickle.load(infile) cls._data = {meta['name']: meta for meta in data} if name not in cls._groups: cls._groups[name] = TextureGroup(cls._data[name]) return cls._groups[name] def load_all(self): pass def iter_all(self): yield from self.textures.items() def __len__(self): return len(self.textures) def get(self, id, fail=0): id //= 2 if id not in self.textures: utils.debug('{}: id: {} not in range {}'.format( self.name, id, (0, len(textures) - 1))) return None return self.textures[id] if __name__ == '__main__': utils.pg_init() image = TextureGroup.get_group('smap').image utils.show_surface(image)
def load_mmap(id=0): import texture utils.pg_init() tg = texture.TextureGroup.get_group('mmap') t1 = tg.get(int(id)).image utils.show_surface(t1)