diff --git a/core/src/avm2/globals.rs b/core/src/avm2/globals.rs index f310a3406..5845216e4 100644 --- a/core/src/avm2/globals.rs +++ b/core/src/avm2/globals.rs @@ -772,6 +772,13 @@ pub fn load_player_globals<'gc>( domain, script, )?; + class( + activation, + flash::display::stagedisplaystate::create_class(mc), + implicit_deriver, + domain, + script, + )?; // package `flash.geom` activation diff --git a/core/src/avm2/globals/flash/display.rs b/core/src/avm2/globals/flash/display.rs index 16b425f69..731970906 100644 --- a/core/src/avm2/globals/flash/display.rs +++ b/core/src/avm2/globals/flash/display.rs @@ -16,4 +16,5 @@ pub mod shape; pub mod sprite; pub mod stage; pub mod stagealign; +pub mod stagedisplaystate; pub mod swfversion; diff --git a/core/src/avm2/globals/flash/display/stagedisplaystate.rs b/core/src/avm2/globals/flash/display/stagedisplaystate.rs new file mode 100644 index 000000000..5175c6815 --- /dev/null +++ b/core/src/avm2/globals/flash/display/stagedisplaystate.rs @@ -0,0 +1,66 @@ +//! `flash.display.StageDisplayState` builtin/prototype + +use crate::avm2::activation::Activation; +use crate::avm2::class::{Class, ClassAttributes}; +use crate::avm2::method::Method; +use crate::avm2::names::{Namespace, QName}; +use crate::avm2::object::Object; +use crate::avm2::traits::Trait; +use crate::avm2::value::Value; +use crate::avm2::Error; +use gc_arena::{GcCell, MutationContext}; + +/// Implements `flash.display.StageDisplayState`'s instance constructor. +pub fn instance_init<'gc>( + activation: &mut Activation<'_, 'gc, '_>, + this: Option>, + _args: &[Value<'gc>], +) -> Result, Error> { + if let Some(this) = this { + activation.super_init(this, &[])?; + } + + Ok(Value::Undefined) +} + +/// Implements `flash.display.StageDisplayState`'s class constructor. +pub fn class_init<'gc>( + _activation: &mut Activation<'_, 'gc, '_>, + _this: Option>, + _args: &[Value<'gc>], +) -> Result, Error> { + Ok(Value::Undefined) +} + +/// Construct `StageDisplayState`'s class. +pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> { + let class = Class::new( + QName::new(Namespace::package("flash.display"), "StageDisplayState"), + Some(QName::new(Namespace::package(""), "Object").into()), + Method::from_builtin(instance_init), + Method::from_builtin(class_init), + mc, + ); + + let mut write = class.write(mc); + + write.set_attributes(ClassAttributes::SEALED | ClassAttributes::FINAL); + + write.define_class_trait(Trait::from_const( + QName::new(Namespace::public(), "FULL_SCREEN"), + QName::new(Namespace::public(), "String").into(), + Some("fullScreen".into()), + )); + write.define_class_trait(Trait::from_const( + QName::new(Namespace::public(), "FULL_SCREEN_INTERACTIVE"), + QName::new(Namespace::public(), "String").into(), + Some("fullScreenInteractive".into()), + )); + write.define_class_trait(Trait::from_const( + QName::new(Namespace::public(), "NORMAL"), + QName::new(Namespace::public(), "String").into(), + Some("normal".into()), + )); + + class +}