Mercurial > touhou
comparison pytouhou/ui/texture.pyx @ 504:69c73023f7a0
Make ANM garbage collectable.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 23 Oct 2013 18:24:17 +0200 |
parents | 1c891c71cf22 |
children | bfea9e9a6845 |
comparison
equal
deleted
inserted
replaced
503:c622eaf64428 | 504:69c73023f7a0 |
---|---|
37 def __init__(self, loader=None, renderer=None): | 37 def __init__(self, loader=None, renderer=None): |
38 self.loader = loader | 38 self.loader = loader |
39 self.renderer = renderer | 39 self.renderer = renderer |
40 | 40 |
41 | 41 |
42 def load(self, anm_list): | 42 def load(self, anms): |
43 for anm in sorted(anm_list, key=lambda x: x[0].first_name.endswith('ascii.png')): | 43 for anm in sorted(anms.values(), key=lambda x: x[0].first_name.endswith('ascii.png')): |
44 for entry in anm: | 44 for entry in anm: |
45 if not hasattr(entry, 'texture'): | 45 if not hasattr(entry, 'texture'): |
46 texture = decode_png(self.loader, entry.first_name, entry.secondary_name) | 46 texture = decode_png(self.loader, entry.first_name, entry.secondary_name) |
47 entry.texture = load_texture(texture) | 47 entry.texture = load_texture(texture) |
48 elif not isinstance(entry.texture, TextureId): | 48 elif not isinstance(entry.texture, TextureId): |
49 entry.texture = load_texture(entry.texture) | 49 entry.texture = load_texture(entry.texture) |
50 self.renderer.add_texture(entry.texture) | 50 self.renderer.add_texture(entry.texture) |
51 entry.texture.renderer = self.renderer | 51 entry.texture.renderer = self.renderer |
52 anms.clear() | |
52 | 53 |
53 | 54 |
54 cdef class FontManager: | 55 cdef class FontManager: |
55 cdef Font font | 56 cdef Font font |
56 cdef object renderer | 57 cdef object renderer |