core: Add DisplayObject::path
This commit is contained in:
parent
73604a891e
commit
783ede6f79
|
@ -106,7 +106,7 @@ pub fn create_proto<'gc>(
|
||||||
1.0.into()
|
1.0.into()
|
||||||
},
|
},
|
||||||
"toString" => |movie_clip: MovieClip<'gc>, _context: &mut UpdateContext<'_, 'gc, '_>, _cell: DisplayObject<'gc>, _args| -> ReturnValue<'gc> {
|
"toString" => |movie_clip: MovieClip<'gc>, _context: &mut UpdateContext<'_, 'gc, '_>, _cell: DisplayObject<'gc>, _args| -> ReturnValue<'gc> {
|
||||||
movie_clip.name().to_string().into()
|
movie_clip.path().into()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -206,6 +206,17 @@ pub trait TDisplayObject<'gc>: 'gc + Collect + Debug {
|
||||||
);
|
);
|
||||||
fn name(&self) -> Ref<str>;
|
fn name(&self) -> Ref<str>;
|
||||||
fn set_name(&mut self, context: MutationContext<'gc, '_>, name: &str);
|
fn set_name(&mut self, context: MutationContext<'gc, '_>, name: &str);
|
||||||
|
/// Returns the dot-syntax path to this display object, e.g. `_level0.foo.clip`
|
||||||
|
fn path(&self) -> String {
|
||||||
|
if let Some(parent) = self.parent() {
|
||||||
|
let mut path = parent.path();
|
||||||
|
path.push_str(".");
|
||||||
|
path.push_str(&*self.name());
|
||||||
|
path
|
||||||
|
} else {
|
||||||
|
self.name().to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
fn clip_depth(&self) -> Depth;
|
fn clip_depth(&self) -> Depth;
|
||||||
fn set_clip_depth(&mut self, context: MutationContext<'gc, '_>, depth: Depth);
|
fn set_clip_depth(&mut self, context: MutationContext<'gc, '_>, depth: Depth);
|
||||||
fn parent(&self) -> Option<DisplayObject<'gc>>;
|
fn parent(&self) -> Option<DisplayObject<'gc>>;
|
||||||
|
|
|
@ -214,7 +214,8 @@ impl<Audio: AudioBackend, Renderer: RenderBackend, Navigator: NavigatorBackend>
|
||||||
player.gc_arena.mutate(|gc_context, gc_root| {
|
player.gc_arena.mutate(|gc_context, gc_root| {
|
||||||
let root_data = gc_root.0.write(gc_context);
|
let root_data = gc_root.0.write(gc_context);
|
||||||
let mut root = root_data.root;
|
let mut root = root_data.root;
|
||||||
root.post_instantiation(gc_context, root, root_data.avm.prototypes().movie_clip)
|
root.post_instantiation(gc_context, root, root_data.avm.prototypes().movie_clip);
|
||||||
|
root.set_name(gc_context, "_level0");
|
||||||
});
|
});
|
||||||
|
|
||||||
player.build_matrices();
|
player.build_matrices();
|
||||||
|
|
Loading…
Reference in New Issue