0% found this document useful (0 votes)
26 views

Desktop Native Application

This document contains the code for a DesktopNativeApplication class that implements functions for a native desktop application. It includes imports for various libraries and defines functions for initializing the application, navigating URLs, opening files, taking screenshots, getting device info, and rebooting the application by starting the executable again. It also includes functions for interacting with Steamworks functionality.

Uploaded by

nightmaremtgame
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Desktop Native Application

This document contains the code for a DesktopNativeApplication class that implements functions for a native desktop application. It includes imports for various libraries and defines functions for initializing the application, navigating URLs, opening files, taking screenshots, getting device info, and rebooting the application by starting the executable again. It also includes functions for interacting with Steamworks functionality.

Uploaded by

nightmaremtgame
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

package MNativeApplication

{
import by.blooddy.crypto.Base64;
import by.blooddy.crypto.image.JPEGEncoder;
import com.amanitadesign.steam.FRESteamWorks;
import feathers.controls.TextInput;
import fkengine.database.Tables.LocaleTbl;
import fkengine.gui.Alert.Alert;
import fkengine.main.INativeApplication;
import fkengine.message.MessageHandler;
import fkengine.utils.Defines;
import flash.desktop.NativeApplication;
import flash.desktop.NativeProcess;
import flash.desktop.NativeProcessStartupInfo;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display.Screen;
import flash.display.Stage;
import flash.events.Event;
import flash.external.ExternalInterface;
import flash.filesystem.File;
import flash.filters.BlurFilter;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.net.FileFilter;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.system.Capabilities;
import flash.utils.ByteArray;

public class DesktopNativeApplication implements INativeApplication


{

private static var _steamworks:FRESteamWorks;

private var _stage:Stage;

private var _device:String = "desktop";

private var _params:Object;

private var _steamUserId:String;

private var _loader:Loader;

private var _imageLoadCallback:Function;

public function DesktopNativeApplication(param1:Stage)


{
super();
_stage = param1;
_steamworks = new FRESteamWorks();
var _loc2_:Boolean = Boolean(_steamworks.init());
if(_loc2_ == false)
{
_steamworks = null;
}
}

public static function get steamworks() : FRESteamWorks


{
return _steamworks;
}

public function initialize(param1:Function) : void


{

NativeApplication.nativeApplication.addEventListener("deactivate",onDeactivate);
}

protected function onDeactivate(param1:Event) : void


{
MessageHandler.sendMessage(Defines.MESSAGE_GameDeactivate,null,this);
}

public function navigateToUrl(param1:String) : void


{
try
{
if(ExternalInterface.available)
{
ExternalInterface.call("open",param1,"_blank");
}
else
{
navigateToURL(new URLRequest(param1));
}
}
catch(error:Error)
{
}
}

public function canOpenUrl(param1:String) : Boolean


{
var _loc2_:String = File.applicationStorageDirectory.nativePath;
_loc2_ =
_loc2_.replace("com.freakinware.mitosis","com.freakinware.package");
_loc2_ =
_loc2_.replace("com.freakinware.wormis","com.freakinware.package");
_loc2_ =
_loc2_.replace("com.freakinware.strikeis","com.freakinware.package");
if(param1 == "wormis://play")
{
_loc2_ =
_loc2_.replace("com.freakinware.package","com.freakinware.wormis");
}
if(param1 == "mitosis://play")
{
_loc2_ =
_loc2_.replace("com.freakinware.package","com.freakinware.mitosis");
}
if(param1 == "strikeis://play")
{
_loc2_ =
_loc2_.replace("com.freakinware.package","com.freakinware.strikeis");
}
var _loc3_:File = new File(_loc2_);
return _loc3_.exists;
}

public function exec(param1:String, param2:Object) : void


{
var _loc4_:FileFilter = null;
var _loc3_:File = null;
if(param1 == "fallback")
{
ExternalInterface.call("main.fallback");
return;
}
if(param1 == "update")
{
navigateToUrl(LocaleTbl.localizationFor("update_url_" + _device));
}
if(param1 == "exit")
{
NativeApplication.nativeApplication.exit();
}
if(param1 == "rate" && _steamworks != null)
{

_steamworks.activateGameOverlayToStore(LocaleTbl.intValueFor("steam_app_id"),0);
return;
}
if(param1 == "load_image")
{
_loc4_ = new FileFilter("Images (*.png,
*.jpg)","*.png;*.jpg;*.jpeg","JPEG;jp2_;PNGf");
_loc3_ = File.documentsDirectory;
_imageLoadCallback = param2 as Function;
_loc3_.addEventListener("select",fileSelected);
_loc3_.browseForOpen("Open",[_loc4_]);
}
if(param1 == "share" || param1 == "rate")
{
navigateToUrl(LocaleTbl.localizationFor("sw_" + param1 + "_" +
_device));
return;
}
if(param1 == "part1")
{
_params = param2;
_params[2](_params[0],_params[0],_params[1]);
return;
}
if(param1 == "restart")
{
reboot();
return;
}
}

protected function fileSelected(param1:Event) : void


{
var _loc2_:File = File(param1.target);
_loc2_.removeEventListener("select",fileSelected);
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener("complete",completeHandler);
var _loc3_:URLRequest = new URLRequest(_loc2_.nativePath);
_loader.load(_loc3_);
}

protected function completeHandler(param1:Event) : void


{
if(_loader.content is Bitmap)
{
_imageLoadCallback(Bitmap(_loader.content).bitmapData);
}
}

public function modTextInput(param1:TextInput, param2:String) : void


{
}

public function screenshotReceived(param1:BitmapData) : void


{
var _loc8_:String = null;
var _loc4_:Number = 0.25;
var _loc3_:* = null;
var _loc7_:BlurFilter = new BlurFilter(3,3,3);
var _loc5_:BitmapData = new BitmapData(param1.width * _loc4_,param1.height
* _loc4_,false,0);
var _loc6_:Matrix;
(_loc6_ = new Matrix()).scale(_loc4_,_loc4_);
_loc5_.drawWithQuality(param1,_loc6_,null,null,null,true,"best");
_loc5_.applyFilter(_loc5_,_loc5_.rect,new Point(0,0),_loc7_);
var _loc2_:ByteArray = JPEGEncoder.encode(_loc5_,80);
if(_loc2_)
{
if(_loc8_ = Base64.encode(_loc2_))
{
_loc3_ = _loc8_;
}
}
_loc5_.dispose();
param1.dispose();
ExternalInterface.call("main.screenshot",_loc3_);
}

public function getDeviceInfo() : String


{
var _loc1_:String = Capabilities.os;
return "0:" + _loc1_;
}

public function vibrate(param1:Number = 500) : void


{
}

public function getOptionalData(param1:String) : *


{
var _loc3_:XML = null;
var _loc2_:Namespace = null;
var _loc4_:String = null;
if(param1 == "last_version")
{
return LocaleTbl.localizationFor("current_app_version_" + _device);
}
if(param1 == "device")
{
return _device;
}
if(param1 == "version")
{
_loc3_ = NativeApplication.nativeApplication.applicationDescriptor;
_loc2_ = _loc3_.namespace();
return (_loc4_ = _loc3_._loc2_::versionNumber).split(".").join(".");
}
if(param1 == "usertoken")
{
if(_steamworks &&
_steamworks.userHasLicenseForApp(_steamworks.getUserID(),LocaleTbl.intValueFor("ste
am_app_id")))
{
return "steam::" + _steamworks.getUserID();
}
return null;
}
if(param1 == "token" || param1 == "https")
{
return _stage.root.loaderInfo.parameters[param1];
}
if(param1 == "keyboardSize")
{
return 0;
}
if(param1 == "can_leave_game")
{
return _stage.displayState == "fullScreenInteractive";
}
if(param1 == "can_change_res")
{
return true;
}
if(param1 == "ScreenWidth")
{
return Screen.mainScreen.bounds.width;
}
if(param1 == "ScreenHeight")
{
return Screen.mainScreen.bounds.height;
}
return null;
}

public function initializePushNotifications(param1:String, param2:Function) :


void
{
}

public function reboot() : void


{
var _loc3_:File = null;
var _loc4_:Array = null;
var _loc5_:NativeProcessStartupInfo = null;
var _loc1_:NativeProcess = null;
var _loc2_:Alert = null;
if(NativeProcess.isSupported)
{
if(Capabilities.os.toLowerCase().indexOf("windows") != -1)
{
_loc3_ = File.applicationDirectory.resolvePath("Mitosis.exe");
}
else
{
(_loc4_ = File.applicationDirectory.nativePath.split("/")).pop();
_loc3_ = new File(_loc4_.join("/") + "/MacOS/Mitosis");
}
(_loc5_ = new NativeProcessStartupInfo()).executable = _loc3_;
_loc1_ = new NativeProcess();
_loc1_.start(_loc5_);
NativeApplication.nativeApplication.exit();
}
else
{
_loc2_ = new
Alert(LocaleTbl.localizationFor("reboot_app"),LocaleTbl.localizationFor("reboot_app
_desc"));
_loc2_.show();
}
}
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy