コード例 #1
0
ファイル: Menu.py プロジェクト: discully/afinalunity
    def __init__(self, file_path):

        self.file_path = Path(file_path)

        if self.file_path.suffix != ".mrg":
            raise ValueError("Menu only supports .mrg files")

        global_palette_path = Palette.getGlobalPalettePath(file_path)
        self.palette = Palette.fullPalette(
            global_palette_path, global_palette_path
        )  # todo: This is certainly the wrong local pallette.

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

        self._read()
コード例 #2
0
ファイル: Cursor.py プロジェクト: discully/afinalunity
def cursor(file_path, palette_path=None):
    f = File.File(file_path)

    palette_path = Palette.getGlobalPalettePath(file_path, palette_path)
    palette = Palette.fullPalette(palette_path, palette_path)

    cursors = []
    try:
        while True:
            width = f.readUInt16()
            height = f.readUInt16()
            cursor_image = Image.Image(width, height)
            cursor_image.name = "{}.{}".format(file_path.name, len(cursors))
            for y in range(height):
                for x in range(width):
                    cursor_image.set(palette[f.readUInt8()], x, y)
            cursors.append(cursor_image)
    except EOFError:
        pass

    return cursors