avm1: Implement updateAfterEvent
This commit is contained in:
parent
8715589f50
commit
3322c2d916
|
@ -206,6 +206,17 @@ pub fn clear_interval<'a, 'gc>(
|
||||||
Ok(Value::Undefined)
|
Ok(Value::Undefined)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_after_event<'a, 'gc>(
|
||||||
|
_activation: &mut Activation<'_, 'gc>,
|
||||||
|
context: &mut UpdateContext<'a, 'gc, '_>,
|
||||||
|
_this: Object<'gc>,
|
||||||
|
_args: &[Value<'gc>],
|
||||||
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
|
*context.needs_render = true;
|
||||||
|
|
||||||
|
Ok(Value::Undefined)
|
||||||
|
}
|
||||||
|
|
||||||
/// This structure represents all system builtins that are used regardless of
|
/// This structure represents all system builtins that are used regardless of
|
||||||
/// whatever the hell happens to `_global`. These are, of course,
|
/// whatever the hell happens to `_global`. These are, of course,
|
||||||
/// user-modifiable.
|
/// user-modifiable.
|
||||||
|
@ -556,6 +567,13 @@ pub fn create_globals<'gc>(
|
||||||
EnumSet::empty(),
|
EnumSet::empty(),
|
||||||
Some(function_proto),
|
Some(function_proto),
|
||||||
);
|
);
|
||||||
|
globals.force_set_function(
|
||||||
|
"updateAfterEvent",
|
||||||
|
update_after_event,
|
||||||
|
gc_context,
|
||||||
|
EnumSet::empty(),
|
||||||
|
Some(function_proto),
|
||||||
|
);
|
||||||
|
|
||||||
globals.add_property(
|
globals.add_property(
|
||||||
gc_context,
|
gc_context,
|
||||||
|
|
|
@ -917,6 +917,7 @@ mod tests {
|
||||||
shared_objects: &mut HashMap::new(),
|
shared_objects: &mut HashMap::new(),
|
||||||
unbound_text_fields: &mut Vec::new(),
|
unbound_text_fields: &mut Vec::new(),
|
||||||
timers: &mut Timers::new(),
|
timers: &mut Timers::new(),
|
||||||
|
needs_render: &mut false,
|
||||||
};
|
};
|
||||||
|
|
||||||
root.post_instantiation(&mut avm, &mut context, root, None, false);
|
root.post_instantiation(&mut avm, &mut context, root, None, false);
|
||||||
|
|
|
@ -73,6 +73,7 @@ where
|
||||||
shared_objects: &mut HashMap::new(),
|
shared_objects: &mut HashMap::new(),
|
||||||
unbound_text_fields: &mut Vec::new(),
|
unbound_text_fields: &mut Vec::new(),
|
||||||
timers: &mut Timers::new(),
|
timers: &mut Timers::new(),
|
||||||
|
needs_render: &mut false,
|
||||||
};
|
};
|
||||||
root.post_instantiation(&mut avm, &mut context, root, None, false);
|
root.post_instantiation(&mut avm, &mut context, root, None, false);
|
||||||
root.set_name(context.gc_context, "");
|
root.set_name(context.gc_context, "");
|
||||||
|
|
|
@ -46,6 +46,9 @@ pub struct UpdateContext<'a, 'gc, 'gc_context> {
|
||||||
/// variables.
|
/// variables.
|
||||||
pub player_version: u8,
|
pub player_version: u8,
|
||||||
|
|
||||||
|
/// Requests a that the player re-renders after this execution (e.g. due to `updateAfterEvent`).
|
||||||
|
pub needs_render: &'a mut bool,
|
||||||
|
|
||||||
/// The root SWF file.
|
/// The root SWF file.
|
||||||
pub swf: &'a Arc<SwfMovie>,
|
pub swf: &'a Arc<SwfMovie>,
|
||||||
|
|
||||||
|
|
|
@ -551,7 +551,9 @@ impl Player {
|
||||||
Self::run_actions(avm, context);
|
Self::run_actions(avm, context);
|
||||||
});
|
});
|
||||||
self.is_mouse_down = is_mouse_down;
|
self.is_mouse_down = is_mouse_down;
|
||||||
self.needs_render = needs_render;
|
if needs_render {
|
||||||
|
self.needs_render = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update dragged object, if any.
|
/// Update dragged object, if any.
|
||||||
|
@ -912,6 +914,7 @@ impl Player {
|
||||||
system_properties,
|
system_properties,
|
||||||
instance_counter,
|
instance_counter,
|
||||||
storage,
|
storage,
|
||||||
|
needs_render,
|
||||||
) = (
|
) = (
|
||||||
self.player_version,
|
self.player_version,
|
||||||
&self.swf,
|
&self.swf,
|
||||||
|
@ -928,6 +931,7 @@ impl Player {
|
||||||
&mut self.system,
|
&mut self.system,
|
||||||
&mut self.instance_counter,
|
&mut self.instance_counter,
|
||||||
self.storage.deref_mut(),
|
self.storage.deref_mut(),
|
||||||
|
&mut self.needs_render,
|
||||||
);
|
);
|
||||||
|
|
||||||
self.gc_arena.mutate(|gc_context, gc_root| {
|
self.gc_arena.mutate(|gc_context, gc_root| {
|
||||||
|
@ -971,6 +975,7 @@ impl Player {
|
||||||
shared_objects,
|
shared_objects,
|
||||||
unbound_text_fields,
|
unbound_text_fields,
|
||||||
timers,
|
timers,
|
||||||
|
needs_render,
|
||||||
};
|
};
|
||||||
|
|
||||||
let ret = f(avm, &mut update_context);
|
let ret = f(avm, &mut update_context);
|
||||||
|
|
Loading…
Reference in New Issue