changeset 241:dd2bd7283bec

Add support for multiple-file anms to anmviewer, add feature to force acceptance of translations
author Thibaut Girka <thib@sitedethib.com>
date Sun, 01 Jan 2012 23:52:53 +0100
parents 02de1563fa18
children 1d3c8c7473a2
files anmviewer pytouhou/ui/anmrenderer.py
diffstat 2 files changed, 23 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/anmviewer
+++ b/anmviewer
@@ -30,7 +30,7 @@ def main(path, data, name, script, sprit
     resource_loader.scan_archives(os.path.join(path, name) for name in data)
 
     # Get out animation
-    anm_wrapper = resource_loader.get_anm_wrapper((name,))
+    anm_wrapper = resource_loader.get_anm_wrapper(name.split(','))
     anm = ANMRenderer(resource_loader, anm_wrapper, script, sprites)
     anm.start()
 
--- a/pytouhou/ui/anmrenderer.py
+++ b/pytouhou/ui/anmrenderer.py
@@ -44,13 +44,10 @@ class ANMRenderer(pyglet.window.Window, 
                                       caption='PyTouhou', resizable=False)
 
         self._anm_wrapper = anm_wrapper
-        self.anm = anm_wrapper.anm_files[0]
         self.sprites = sprites
         self.clear_color = (0., 0., 0., 1.)
-        if sprites:
-            self.items = self.anm.sprites
-        else:
-            self.items = self.anm.scripts
+        self.force_allow_dest_offset = False
+        self.index_items()
         self.load(index)
 
         self.x = width / 2
@@ -106,7 +103,12 @@ class ANMRenderer(pyglet.window.Window, 
         elif symbol == pyglet.window.key.W:
             self.load()
         elif symbol == pyglet.window.key.X:
-            self.x, self.y = (192, 224) if self.x == 0 else (0, 0)
+            self.x, self.y = {(192, 224): (0, 0),
+                              (0, 0): (-224, 0),
+                              (-224, 0): (192, 224)}[(self.x, self.y)]
+        elif symbol == pyglet.window.key.C:
+            self.force_allow_dest_offset = not self.force_allow_dest_offset
+            self.load()
         elif symbol == pyglet.window.key.LEFT:
             self.change(-1)
         elif symbol == pyglet.window.key.RIGHT:
@@ -144,12 +146,19 @@ class ANMRenderer(pyglet.window.Window, 
         self.load(item)
 
 
+    def index_items(self):
+        self.items = {}
+        if self.sprites:
+            for anm in self._anm_wrapper.anm_files:
+                self.items.update(anm.sprites)
+        else:
+            for anm in self._anm_wrapper.anm_files:
+                self.items.update(anm.scripts)
+
+
     def toggle_sprites(self):
         self.sprites = not(self.sprites)
-        if self.sprites:
-            self.items = self.anm.sprites
-        else:
-            self.items = self.anm.scripts
+        self.index_items()
         self.load(0)
 
 
@@ -164,6 +173,9 @@ class ANMRenderer(pyglet.window.Window, 
         if not self.sprites:
              self._anmrunner.run_frame()
 
+        if self.force_allow_dest_offset:
+            self._sprite.allow_dest_offset = True
+
         glClearColor(*self.clear_color)
         glClear(GL_COLOR_BUFFER_BIT)
         if not self._sprite._removed: