-
-
Notifications
You must be signed in to change notification settings - Fork 817
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package flash.display | ||
{ | ||
import __ruffle__.stub_getter; | ||
import flash.geom.Rectangle; | ||
|
||
[API("661")] | ||
public final class Screen | ||
{ | ||
private static var _screens:Array; | ||
private var _width:int; | ||
private var _height:int; | ||
|
||
[API(661)] | ||
public var mode:ScreenMode; | ||
|
||
public function Screen(width:int, height:int) | ||
{ | ||
_width = width; | ||
_height = height; | ||
mode = new ScreenMode(width, height); | ||
} | ||
|
||
public static function get mainScreen():Screen | ||
{ | ||
return screens[0]; | ||
} | ||
|
||
public static native function getScreensInternal():Array; | ||
|
||
public static function get screens():Array | ||
{ | ||
if (!_screens) | ||
{ | ||
_screens = getScreensInternal().map(function(screen:Array, _idx:int, _arr:Array):Screen | ||
{ | ||
return new Screen(screen[0], screen[1]); | ||
}); | ||
} | ||
return _screens; | ||
} | ||
|
||
public function get colorDepth():Number | ||
{ | ||
stub_getter("flash.display.Screen", "colorDepth"); | ||
return 24; | ||
} | ||
|
||
public function get bounds():Rectangle | ||
{ | ||
return new Rectangle(0, 0, _width, _height); | ||
} | ||
|
||
public function get visibleBounds():Rectangle | ||
{ | ||
stub_getter("flash.display.Screen", "visibleBounds"); | ||
return bounds; | ||
} | ||
|
||
[API(661)] | ||
public function get modes():Array | ||
{ | ||
stub_getter("flash.display.Screen", "modes"); | ||
return []; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package flash.display | ||
{ | ||
import __ruffle__.stub_getter; | ||
import flash.geom.Rectangle; | ||
|
||
[API(661)] | ||
public class ScreenMode | ||
{ | ||
private var _width:int; | ||
private var _height:int; | ||
|
||
public function ScreenMode(width:int, height:int) | ||
{ | ||
_width = width; | ||
_height = height; | ||
} | ||
|
||
public function get colorDepth():Number | ||
{ | ||
stub_getter("flash.display.ScreenMode", "colorDepth"); | ||
return 24; | ||
} | ||
|
||
public function get refreshRate():Number | ||
{ | ||
stub_getter("flash.display.ScreenMode", "refreshRate"); | ||
return 0; | ||
} | ||
|
||
public function get height():int | ||
{ | ||
return _height; | ||
} | ||
|
||
public function get width():int | ||
{ | ||
return _width; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::avm2::{Activation, ArrayObject, ArrayStorage, Error, Object, Value}; | ||
|
||
pub fn get_screens_internal<'gc>( | ||
activation: &mut Activation<'_, 'gc>, | ||
_this: Object<'gc>, | ||
_args: &[Value<'gc>], | ||
) -> Result<Value<'gc>, Error<'gc>> { | ||
let screens = activation | ||
.context | ||
.ui | ||
.get_screens_sizes() | ||
.into_iter() | ||
.map(|screen| { | ||
let storage = | ||
ArrayStorage::from_storage(vec![Some(screen.0.into()), Some(screen.1.into())]); | ||
Ok(Some(ArrayObject::from_storage(activation, storage)?.into())) | ||
}) | ||
.collect::<Result<Vec<Option<Value<'gc>>>, Error<'gc>>>()?; | ||
let storage = ArrayStorage::from_storage(screens); | ||
Ok(ArrayObject::from_storage(activation, storage)?.into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters