Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
        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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
        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)
Exemplo n.º 6
0
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)