avm1: Support strings in `MovieClip.setMask(str)`

This commit is contained in:
Toad06 2023-03-22 10:46:14 +01:00 committed by Mike Welsh
parent 8a8071e6d5
commit c81460beb0
1 changed files with 13 additions and 6 deletions

View File

@ -1045,11 +1045,18 @@ fn set_mask<'gc>(
activation: &mut Activation<'_, 'gc>, activation: &mut Activation<'_, 'gc>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> { ) -> Result<Value<'gc>, Error<'gc>> {
let mask = args let mask = match args.get(0) {
.get(0) None => return Ok(Value::Undefined),
.unwrap_or(&Value::Undefined) Some(Value::Undefined | Value::Null) => None,
.coerce_to_object(activation) Some(m) => {
.as_display_object(); let start_clip = activation.target_clip_or_root();
let mask = activation.resolve_target_display_object(start_clip, *m, false)?;
if mask.is_none() {
return Ok(Value::Bool(false));
}
mask
}
};
let mc = DisplayObject::MovieClip(movie_clip); let mc = DisplayObject::MovieClip(movie_clip);
let context = &mut activation.context; let context = &mut activation.context;
mc.set_clip_depth(context.gc_context, 0); mc.set_clip_depth(context.gc_context, 0);
@ -1057,7 +1064,7 @@ fn set_mask<'gc>(
if let Some(m) = mask { if let Some(m) = mask {
m.set_maskee(context.gc_context, Some(mc), true); m.set_maskee(context.gc_context, Some(mc), true);
} }
Ok(Value::Undefined) Ok(Value::Bool(true))
} }
fn start_drag<'gc>( fn start_drag<'gc>(