Skip to content

Commit

Permalink
avm2: stub desktop AIR APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mesteery committed Aug 22, 2024
1 parent a10b31b commit ef314a8
Show file tree
Hide file tree
Showing 18 changed files with 1,038 additions and 26 deletions.
21 changes: 21 additions & 0 deletions core/src/avm2/globals/flash/desktop/Icon.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// The initial version of this file was autogenerated from the official AS3 reference at
// https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/Icon.html
// by https://github.com/golfinq/ActionScript_Event_Builder
// It won't be regenerated in the future, so feel free to edit and/or fix

package flash.desktop
{
import flash.events.EventDispatcher;
[API("661")]
public class Icon extends EventDispatcher
{

// The icon image as an array of BitmapData objects of different sizes.
public var bitmaps:Array;

function Icon(bitmaps:Array)
{
this.bitmaps = bitmaps;
}
}
}
27 changes: 27 additions & 0 deletions core/src/avm2/globals/flash/desktop/InteractiveIcon.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// The initial version of this file was autogenerated from the official AS3 reference at
// https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/InteractiveIcon.html
// by https://github.com/golfinq/ActionScript_Event_Builder
// It won't be regenerated in the future, so feel free to edit and/or fix

package flash.desktop
{
[API("661")]
public class InteractiveIcon extends Icon
{
// The current display height of the icon in pixels.
private var _height:int;

// The current display width of the icon in pixels.
private var _width:int;

public function get height():int
{
return this._height;
}

public function get width():int
{
return this._width;
}
}
}
259 changes: 259 additions & 0 deletions core/src/avm2/globals/flash/desktop/NativeApplication.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
package flash.desktop
{
import flash.display.NativeWindow;
import flash.events.InvokeEvent;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.events.EventDispatcher;
import flash.system.Security;
import flash.utils.Timer;
import flash.utils.setTimeout;
import __ruffle__.stub_method;
import __ruffle__.stub_getter;
import __ruffle__.stub_setter;

[API("661")]
public final class NativeApplication extends EventDispatcher
{
private static var _instance:NativeApplication;

public var _openedWindows:Array = [];

private var _idleThreshold:int = 300;

public function NativeApplication()
{
super();
setTimeout(function():void
{
dispatchEvent(new InvokeEvent(InvokeEvent.INVOKE, false, false, null, []));
}, 500);
}

public static function get nativeApplication():NativeApplication
{
if (!_instance)
_instance = new NativeApplication();
return _instance;
}

public static function get supportsMenu():Boolean
{
stub_getter("flash.desktop.NativeApplication", "supportsMenu");
return false;
}

public static function get supportsDockIcon():Boolean
{
stub_getter("flash.desktop.NativeApplication", "supportsDockIcon");
return false;
}

public static function get supportsSystemTrayIcon():Boolean
{
stub_getter("flash.desktop.NativeApplication", "supportsSystemTrayIcon");
return false;
}

[API("668")]
public static function get supportsDefaultApplication():Boolean
{
stub_getter("flash.desktop.NativeApplication", "supportsDefaultApplication");
return false;
}

[API("668")]
public static function get supportsStartAtLogin():Boolean
{
stub_getter("flash.desktop.NativeApplication", "supportsStartAtLogin");
return false;
}

public function exit(exitCode:int = 0):void
{
stub_method("flash.desktop.NativeApplication", "exit");
}

public function get runtimeVersion():String
{
stub_method("flash.desktop.NativeApplication", "runtimeVersion");
return "5.0.0";
}

public function get runtimePatchLevel():uint
{
stub_method("flash.desktop.NativeApplication", "runtimePatchLevel");
return 0;
}

public function get applicationID():String
{
stub_method("flash.desktop.NativeApplication", "applicationID");
return "";
}

public function get publisherID():String
{
stub_method("flash.desktop.NativeApplication", "publisherID");
return "";
}

public function get applicationDescriptor():XML
{
stub_method("flash.desktop.NativeApplication", "applicationDescriptor");
return null;
}

public function get autoExit():Boolean
{
stub_getter("flash.desktop.NativeApplication", "autoExit");
return false;
}

public function set autoExit(param1:Boolean):void
{
stub_getter("flash.desktop.NativeApplication", "autoExit");
}

public function get icon():InteractiveIcon
{
stub_getter("flash.desktop.NativeApplication", "icon");
return null;
}

[API("668")]
public function get systemIdleMode():String
{
stub_getter("flash.desktop.NativeApplication", "systemIdleMode");
return "normal";
}

[API("668")]
public function set systemIdleMode(param1:String):void
{
stub_setter("flash.desktop.NativeApplication", "systemIdleMode");
}

public function get startAtLogin():Boolean
{
stub_getter("flash.desktop.NativeApplication", "startAtLogin");
return false;
}

public function set startAtLogin(param1:Boolean):void
{
stub_setter("flash.desktop.NativeApplication", "startAtLogin");
}

public function activate(window:NativeWindow = null):void
{
stub_method("flash.desktop.NativeApplication", "activate");
}

public function get activeWindow():NativeWindow
{
stub_getter("flash.desktop.NativeApplication", "activeWindow");
return _openedWindows[0];
}

public function get openedWindows():Array
{
stub_getter("flash.desktop.NativeApplication", "openedWindows");
return _openedWindows;
}

public function get timeSinceLastUserInput():int
{
stub_getter("flash.desktop.NativeApplication", "timeSinceLastUserInput");
return 100;
}

public function get idleThreshold():int
{
return this._idleThreshold;
}

public function set idleThreshold(value:int):void
{
this._idleThreshold = value;
}

public function copy():Boolean
{
stub_getter("flash.desktop.NativeApplication", "copy");
return false;
}

public function cut():Boolean
{
stub_getter("flash.desktop.NativeApplication", "cut");
return false;
}

public function paste():Boolean
{
stub_getter("flash.desktop.NativeApplication", "paste");
return false;
}

public function clear():Boolean
{
stub_getter("flash.desktop.NativeApplication", "clear");
return false;
}

public function selectAll():Boolean
{
stub_method("flash.desktop.NativeApplication", "selectAll");
return false;
}

public function getDefaultApplication(extension:String):String
{
stub_method("flash.desktop.NativeApplication", "getDefaultApplication");
return null;
}

public function isSetAsDefaultApplication(extension:String):Boolean
{
stub_method("flash.desktop.NativeApplication", "isSetAsDefaultApplication");
return true;
}

public function setAsDefaultApplication(extension:String):void
{
stub_method("flash.desktop.NativeApplication", "setAsDefaultApplication");
}

public function removeAsDefaultApplication(extension:String):void
{
stub_method("flash.desktop.NativeApplication", "removeAsDefaultApplication");
}

[API("681")]
public function get executeInBackground():Boolean
{
stub_getter("flash.desktop.NativeApplication", "executeInBackground");
return false;
}

[API("681")]
public function set executeInBackground(param1:Boolean):void
{
stub_setter("flash.desktop.NativeApplication", "executeInBackground");
}

// [API("721")] Ruffle doesn't support this API Version
public function get isCompiledAOT():Boolean
{
stub_getter("flash.desktop.NativeApplication", "isCompiledAOT");
return false;
}

public function get isActive():Boolean
{
stub_getter("flash.desktop.NativeApplication", "isActive");
return true;
}
}
}
Loading

0 comments on commit ef314a8

Please sign in to comment.