view scripts/anmviewer @ 772:7492d384d122 default tip

Rust: Add a Glide renderer (2D only for now) This is an experiment for a Rust renderer, iterating over the Python data using pyo3. It requires --feature=glide to be passed to cargo build, doesn’t support NPOT textures, text rendering, the background, or even msg faces, some of that may come in a future changeset.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 05 Sep 2022 17:53:36 +0200
parents e15672733c93
children
line wrap: on
line source

#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
##
## Copyright (C) 2011 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 3 only.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##

import argparse
import os

from pytouhou.ui.window import Window
from pytouhou.resource.loader import Loader
from pytouhou.ui.anmrenderer import ANMRenderer


def main(path, data, name, script, entry, sprites, fixed_pipeline):
    resource_loader = Loader()
    resource_loader.scan_archives(os.path.join(path, name) for name in data)

    window = Window((384, 448), fixed_pipeline=fixed_pipeline, sound=False)

    # Get out animation
    anm = resource_loader.get_anm(name)
    renderer = ANMRenderer(window, resource_loader, anm[entry], script, sprites)
    window.set_runner(renderer)
    window.run()


parser = argparse.ArgumentParser(description='Viewer of ANM files, archives containing animations used in Touhou games.')

parser.add_argument('data', metavar='DAT', default=('CM.DAT', 'ST.DAT'), nargs='*', help='Game’s .DAT data files')
parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.')
parser.add_argument('--anm', metavar='ANM', required=True, help='Select an ANM')
parser.add_argument('--script', metavar='SCRIPT', type=int, default=0, help='First script to play')
parser.add_argument('--entry', metavar='ENTRY', type=int, default=0, help='Entry to display, in multi-entries ANMs.')
parser.add_argument('--sprites', action='store_true', default=False, help='Display sprites instead of scripts.')
parser.add_argument('--fixed-pipeline', action='store_true', help='Use the fixed pipeline instead of the new programmable one.')

args = parser.parse_args()

main(args.path, tuple(args.data), args.anm, args.script, args.entry, args.sprites,
     args.fixed_pipeline)