예제 #1
0
class Menu:
    def __init__(self, file_path):

        self.file_path = Path(file_path)

        standard_palette = Palette(File(self.file_path.with_name("standard.pal")))
        self.palette = FullPalette()
        self.palette.setGlobalPalette(standard_palette)
        self.palette.setLocalPalette(standard_palette)

        self.offsets = []
        self.images = []

        self._read()

    def __getitem(self, item):
        return self.images[item]

    def __len__(self):
        """The number of images in the file"""
        return len(self.images)

    def __str__(self):
        return "Menu ({0}) {} images".format(self.file_path, len(self))

    def _read(self):
        f = File(self.file_path)

        n_entries = f.readUInt16()
        for i in range(n_entries):
            self.offsets.append(f.readUInt32())

        unknown1 = f.readUInt8()
        unknown2 = f.readUInt8()
        unknown3 = f.readUInt8()
        unknown4 = f.readUInt8()

        for i in range(n_entries):
            print(f.pos(), self.offsets[i])
            assert f.pos() == self.offsets[i]

            width = f.readUInt16()
            height = f.readUInt16()
            image = Image(width, height)

            for y in range(height):
                for x in range(width):
                    colour = self.palette[f.readUInt8()]
                    image.set(colour, x, y)

            self.images.append(image)
예제 #2
0
    def __init__(self, file_path):

        self.file_path = Path(file_path)

        standard_palette = Palette(File(self.file_path.with_name("standard.pal")))
        self.palette = FullPalette()
        self.palette.setGlobalPalette(standard_palette)
        self.palette.setLocalPalette(standard_palette)

        self.offsets = []
        self.images = []

        self._read()