Use the depth to indicate which layer a particular root clip is, and then use that to calculate it's `_leveln` path.

This commit is contained in:
David Wendt 2020-02-01 18:29:21 -05:00
parent 8ef759d377
commit 00f88f9e87
5 changed files with 5 additions and 2 deletions

View File

@ -951,6 +951,7 @@ impl<'gc> Avm1<'gc> {
MovieClip::new(NEWEST_PLAYER_VERSION, context.gc_context).into();
layer.post_instantiation(context.gc_context, layer, self.prototypes.movie_clip);
layer.set_depth(context.gc_context, level_id as i32);
context.layers.insert(level_id, layer);
layer

View File

@ -588,6 +588,7 @@ mod tests {
let swf = Arc::new(SwfMovie::empty(swf_version));
let mut root: DisplayObject<'_> = MovieClip::new(swf_version, gc_context).into();
root.post_instantiation(gc_context, root, avm.prototypes().movie_clip);
root.set_depth(gc_context, 0);
let mut layers = BTreeMap::new();
layers.insert(0, root);

View File

@ -27,6 +27,7 @@ where
let swf = Arc::new(SwfMovie::empty(swf_version));
let mut root: DisplayObject<'_> = MovieClip::new(swf_version, gc_context).into();
root.post_instantiation(gc_context, root, avm.prototypes().movie_clip);
root.set_depth(gc_context, 0);
let mut layers = BTreeMap::new();
layers.insert(0, root);

View File

@ -581,8 +581,7 @@ pub trait TDisplayObject<'gc>: 'gc + Collect + Debug + Into<DisplayObject<'gc>>
path.push_str(&*self.name());
path
} else {
// TODO: Get the actual level # from somewhere.
"_level0".to_string()
format!("_level{}", self.depth())
}
}

View File

@ -235,6 +235,7 @@ impl Player {
for (_i, layer) in root_data.layers.iter_mut() {
layer.post_instantiation(gc_context, *layer, mc_proto);
layer.set_depth(gc_context, 0);
}
});