avm2: Port `flash.display.Scene` to ActionScript
This commit is contained in:
parent
5817c1761b
commit
790880a508
|
@ -758,12 +758,6 @@ pub fn load_player_globals<'gc>(
|
||||||
flash::display::framelabel::create_class(mc),
|
flash::display::framelabel::create_class(mc),
|
||||||
script
|
script
|
||||||
);
|
);
|
||||||
avm2_system_class!(
|
|
||||||
scene,
|
|
||||||
activation,
|
|
||||||
flash::display::scene::create_class(mc),
|
|
||||||
script
|
|
||||||
);
|
|
||||||
avm2_system_class!(
|
avm2_system_class!(
|
||||||
graphics,
|
graphics,
|
||||||
activation,
|
activation,
|
||||||
|
@ -998,7 +992,7 @@ fn load_playerglobal<'gc>(
|
||||||
// This acts the same way as 'avm2_system_class', but for classes
|
// This acts the same way as 'avm2_system_class', but for classes
|
||||||
// declared in 'playerglobal'. Classes are declared as ("package", "class", field_name),
|
// declared in 'playerglobal'. Classes are declared as ("package", "class", field_name),
|
||||||
// and are stored in 'avm2().system_classes' and 'avm2().system_prototypes'
|
// and are stored in 'avm2().system_classes' and 'avm2().system_prototypes'
|
||||||
avm2_system_classes_playerglobal!(activation, script, []);
|
avm2_system_classes_playerglobal!(activation, script, [("flash.display", "Scene", scene)]);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ pub mod loaderinfo;
|
||||||
pub mod movieclip;
|
pub mod movieclip;
|
||||||
pub mod nativemenu;
|
pub mod nativemenu;
|
||||||
pub mod nativemenuitem;
|
pub mod nativemenuitem;
|
||||||
pub mod scene;
|
|
||||||
pub mod shape;
|
pub mod shape;
|
||||||
pub mod simplebutton;
|
pub mod simplebutton;
|
||||||
pub mod spreadmethod;
|
pub mod spreadmethod;
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package flash.display {
|
||||||
|
public final class Scene {
|
||||||
|
private var _name: String;
|
||||||
|
private var _labels: Array;
|
||||||
|
private var _numFrames: int;
|
||||||
|
|
||||||
|
public function Scene(name: String, labels: Array, numFrames: int) {
|
||||||
|
this._name = name;
|
||||||
|
this._labels = labels;
|
||||||
|
this._numFrames = numFrames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get name(): String {
|
||||||
|
return this._name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get labels(): Array {
|
||||||
|
return this._labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get numFrames(): int {
|
||||||
|
return this._numFrames;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,86 +0,0 @@
|
||||||
//! `flash.display.Scene` builtin/prototype
|
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
|
||||||
use crate::avm2::class::{define_indirect_properties, Class};
|
|
||||||
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
|
|
||||||
use crate::avm2::method::Method;
|
|
||||||
use crate::avm2::names::{Namespace, QName};
|
|
||||||
use crate::avm2::object::{Object, TObject};
|
|
||||||
use crate::avm2::value::Value;
|
|
||||||
use crate::avm2::Error;
|
|
||||||
use gc_arena::{GcCell, MutationContext};
|
|
||||||
|
|
||||||
/// Implements `flash.display.Scene`'s instance constructor.
|
|
||||||
pub fn instance_init<'gc>(
|
|
||||||
activation: &mut Activation<'_, 'gc, '_>,
|
|
||||||
this: Option<Object<'gc>>,
|
|
||||||
args: &[Value<'gc>],
|
|
||||||
) -> Result<Value<'gc>, Error> {
|
|
||||||
if let Some(mut this) = this {
|
|
||||||
activation.super_init(this, &[])?;
|
|
||||||
|
|
||||||
let name = args
|
|
||||||
.get(0)
|
|
||||||
.cloned()
|
|
||||||
.unwrap_or(Value::Undefined)
|
|
||||||
.coerce_to_string(activation)?;
|
|
||||||
let labels = args.get(1).cloned().unwrap_or(Value::Undefined);
|
|
||||||
let num_frames = args
|
|
||||||
.get(2)
|
|
||||||
.cloned()
|
|
||||||
.unwrap_or(Value::Undefined)
|
|
||||||
.coerce_to_i32(activation)?;
|
|
||||||
|
|
||||||
this.set_property(
|
|
||||||
&QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "name").into(),
|
|
||||||
name.into(),
|
|
||||||
activation,
|
|
||||||
)?;
|
|
||||||
this.set_property(
|
|
||||||
&QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "labels").into(),
|
|
||||||
labels,
|
|
||||||
activation,
|
|
||||||
)?;
|
|
||||||
this.set_property(
|
|
||||||
&QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "numFrames").into(),
|
|
||||||
num_frames.into(),
|
|
||||||
activation,
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Value::Undefined)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Implements `flash.display.Scene`'s class constructor.
|
|
||||||
pub fn class_init<'gc>(
|
|
||||||
_activation: &mut Activation<'_, 'gc, '_>,
|
|
||||||
_this: Option<Object<'gc>>,
|
|
||||||
_args: &[Value<'gc>],
|
|
||||||
) -> Result<Value<'gc>, Error> {
|
|
||||||
Ok(Value::Undefined)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Construct `Scene`'s class.
|
|
||||||
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
|
|
||||||
let class = Class::new(
|
|
||||||
QName::new(Namespace::package("flash.display"), "Scene"),
|
|
||||||
Some(QName::new(Namespace::public(), "Object").into()),
|
|
||||||
Method::from_builtin(instance_init, "<Scene instance initializer>", mc),
|
|
||||||
Method::from_builtin(class_init, "<Scene class initializer>", mc),
|
|
||||||
mc,
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut write = class.write(mc);
|
|
||||||
|
|
||||||
define_indirect_properties!(
|
|
||||||
write,
|
|
||||||
mc,
|
|
||||||
[
|
|
||||||
("name", "", "String"),
|
|
||||||
("labels", "", "Array"),
|
|
||||||
("numFrames", "", "int"),
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
class
|
|
||||||
}
|
|
|
@ -18,6 +18,7 @@ include "flash/display/JPEGXREncoderOptions.as"
|
||||||
include "flash/display/LineScaleMode.as"
|
include "flash/display/LineScaleMode.as"
|
||||||
include "flash/display/PixelSnapping.as"
|
include "flash/display/PixelSnapping.as"
|
||||||
include "flash/display/PNGEncoderOptions.as"
|
include "flash/display/PNGEncoderOptions.as"
|
||||||
|
include "flash/display/Scene.as"
|
||||||
include "flash/display/SWFVersion.as"
|
include "flash/display/SWFVersion.as"
|
||||||
include "flash/geom/ColorTransform.as"
|
include "flash/geom/ColorTransform.as"
|
||||||
include "flash/geom/Orientation3D.as"
|
include "flash/geom/Orientation3D.as"
|
||||||
|
|
Loading…
Reference in New Issue