avm1: Support loading into _level in GetURL2

Calling loadMovieNum with a variable parameter compiles into a
GetURL2 call with a `_level` window target parameter. Previously
this triggered Ruffle to try to navigate to the SWF. Now it
properly loads the SWF inside the current movie.
This commit is contained in:
Mike Welsh 2020-07-23 00:38:57 -07:00
parent ec638e40a9
commit 74cb8609c1
4 changed files with 25 additions and 2 deletions

View File

@ -1340,6 +1340,29 @@ impl<'a, 'gc: 'a> Activation<'a, 'gc> {
context.navigator.spawn_future(process); context.navigator.spawn_future(process);
} }
return Ok(FrameControl::Continue);
} else if window_target.starts_with("_level") && url.len() > 6 {
// target of `_level#` indicates a `loadMovieNum` call.
match window_target[6..].parse::<u32>() {
Ok(level_id) => {
let fetch = context.navigator.fetch(&url, RequestOptions::get());
let level = self.resolve_level(level_id, context);
let process = context.load_manager.load_movie_into_clip(
context.player.clone().unwrap(),
level,
fetch,
None,
);
context.navigator.spawn_future(process);
}
Err(e) => log::warn!(
"Couldn't parse level id {} for action_get_url_2: {}",
url,
e
),
}
return Ok(FrameControl::Continue); return Ok(FrameControl::Continue);
} else { } else {
let vars = match NavigationMethod::from_send_vars_method(swf_method) { let vars = match NavigationMethod::from_send_vars_method(swf_method) {
@ -1353,7 +1376,6 @@ impl<'a, 'gc: 'a> Activation<'a, 'gc> {
vars, vars,
); );
} }
Ok(FrameControl::Continue) Ok(FrameControl::Continue)
} }

View File

@ -1,2 +1,3 @@
Loading movie Loading movies
Child movie loaded!
Child movie loaded! Child movie loaded!