Ejemplo n.º 1
0
    def load_from_folder(self, path):

        self.directory_u1 = list(
            bytes_to_int_array(read_file(os.path.join(path, "directory_u1"))))
        self.directory_u7 = list(
            bytes_to_int_array(read_file(os.path.join(path,
                                                      "directory_u7"))))[0]

        self.section_uncompressed_lengths = [0] * self._MAX_SECTIONS_COUNT()
        self.section_lengths = [0] * self._MAX_SECTIONS_COUNT()
        self.section_indices = [0] * self._MAX_SECTIONS_COUNT()
        self.section_compressed = [0] * self._MAX_SECTIONS_COUNT()
        self.section_offsets = [0] * self._MAX_SECTIONS_COUNT()

        self._load_spec((pathlib.Path(path) / "spec").read_text('ascii'))

        self.sections = []
        for i in range(self.sections_count):
            sp = os.path.join(path, str(self.section_indices[i]))

            cls = get_section_for_index(self.section_indices[i],
                                        self.section_compressed[i] == 1)

            obj = cls()
            obj.set_data(read_file(sp))

            self.sections.append(obj)

        assert len(self.sections) == self.sections_count

        self.pack()

        return self
Ejemplo n.º 2
0
    def load_from_folder(self, path):
        self.preview = Preview()
        self.preview.set_data(read_file(os.path.join(path, "preview")))

        self.description = Description()
        self.description.set_data(read_file(os.path.join(path, "description")))

        self.u1 = U1()
        self.u1.set_data([v for v in read_file(os.path.join(path, "u1"))])

        self.u2 = U2()
        self.u2.set_data([v for v in read_file(os.path.join(path, "u2"))])

        self.u3 = U3()
        self.u3.set_data([v for v in read_file(os.path.join(path, "u3"))])

        self.u4 = U4()
        self.u4.set_data([v for v in read_file(os.path.join(path, "u4"))])

        self.ud = [v for v in read_file(os.path.join(path, "ud"))]

        self.directory = Directory()
        self.directory.load_from_folder(os.path.join(path, "sections"))

        return self
Ejemplo n.º 3
0
def export_images(unpacked_map_folder, destination):
    if not os.path.exists(destination):
        os.makedirs(destination)

    for section, size in imageable_sections.items():
        if size == 80400 * 9:  # skip 1105
            continue
        print("Imaging section {}".format(section))
        s = size_mapping[size]
        #d = cut_strict(read_file("{}/sections/{}".format(unpacked_map_folder, section)), s, 198)
        #d = TileSystem().from_bytes(read_file("{}/sections/{}".format(unpacked_map_folder, section), fmt=s)).get_tiles()
        #im = make_image_of_data(d, system=TiledDiamondSystem(rows=len(d), tilewidth=32, tileheight=16))
        im = TileSystem().from_bytes(
            read_file("{}/sections/{}".format(unpacked_map_folder, section),
                      fmt=s)).create_image()
        im.save("{}/{}.png".format(destination, section))