-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrenderable_factory.py
More file actions
29 lines (22 loc) · 1.08 KB
/
renderable_factory.py
File metadata and controls
29 lines (22 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from xcoder.objects import Shape
from xcoder.objects.movie_clip.movie_clip import MovieClip
from xcoder.objects.plain_object import PlainObject
from xcoder.objects.renderable.display_object import DisplayObject
from xcoder.objects.renderable.renderable_movie_clip import RenderableMovieClip
from xcoder.objects.renderable.renderable_shape import RenderableShape
from xcoder.swf import SupercellSWF
def create_renderable_from_plain(
swf: SupercellSWF, plain_object: PlainObject
) -> DisplayObject:
if isinstance(plain_object, Shape):
return RenderableShape(plain_object)
if isinstance(plain_object, MovieClip):
children = []
for bind_id in plain_object.binds:
bind_object = swf.get_display_object(bind_id)
display_object = None
if bind_object is not None:
display_object = create_renderable_from_plain(swf, bind_object)
children.append(display_object)
return RenderableMovieClip.create_from_plain(swf, plain_object, children)
raise Exception(f"Unsupported object type: {plain_object}")