Mercurial > touhou
annotate pytouhou/resource/anmwrapper.py @ 282:dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sat, 11 Feb 2012 16:43:54 +0100 |
parents | ac2e5e1c2c3c |
children | 2100276c289d |
rev | line source |
---|---|
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
1 from itertools import izip, chain, repeat |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
2 |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
3 |
97 | 4 class AnmWrapper(object): |
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
5 def __init__(self, anm_files, offsets=()): |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
6 self.scripts = {} |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
7 self.sprites = {} |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
8 |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
9 for anm, offset in izip(anm_files, chain(offsets, repeat(0))): |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
10 for script_id, script in anm.scripts.iteritems(): |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
11 self.scripts[script_id + offset] = (anm, script) #TODO: check |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
12 for sprite_id, sprite in anm.sprites.iteritems(): |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
13 self.sprites[sprite_id + offset] = (anm, sprite) |
97 | 14 |
15 | |
16 def get_sprite(self, sprite_index): | |
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
17 return self.sprites[sprite_index] |
97 | 18 |
19 | |
20 def get_script(self, script_index): | |
282
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
21 return self.scripts[script_index] |
dbb1a86c0235
Rename Animations to ANM0 and prepare AnmWrapper for dialogs and interface.
Thibaut Girka <thib@sitedethib.com>
parents:
97
diff
changeset
|
22 |