154 lines
4.1 KiB
Haxe
154 lines
4.1 KiB
Haxe
package com.amanitadesign.steam;
|
|
|
|
import flash.events.Event;
|
|
import flash.events.EventDispatcher;
|
|
import flash.events.IEventDispatcher;
|
|
import flash.events.StatusEvent;
|
|
import flash.external.ExtensionContext;
|
|
import flash.utils.ByteArray<Dynamic>;
|
|
import flash.utils.clearInterval;
|
|
import flash.utils.setInterval;
|
|
|
|
class FRESteamWorks extends EventDispatcher
|
|
{
|
|
//[Event(name="steam_response", type="com.amanitadesign.steam.SteamEvent")]
|
|
|
|
private var _ExtensionContext:ExtensionContext;
|
|
private var _tm:Int;
|
|
|
|
public var isReady:Bool=false;
|
|
|
|
public function new(target:IEventDispatcher=null)
|
|
{
|
|
_ExtensionContext=ExtensionContext.createExtensionContext("com.amanitadesign.steam.FRESteamWorks", null);
|
|
_ExtensionContext.addEventListener(StatusEvent.STATUS, handleStatusEvent);
|
|
super(target);
|
|
}
|
|
|
|
private function handleStatusEvent(event:StatusEvent):Void{
|
|
//_ExtensionContext.removeEventListener(StatusEvent.STATUS, handleStatusEvent);
|
|
var req_type:Int=new Std.int(event.code);
|
|
var response:Int=new Std.int(event.level);
|
|
var sEvent:SteamEvent=new SteamEvent(SteamEvent.STEAM_RESPONSE, req_type, response);
|
|
trace("handleStatusEvent:"+req_type+" "+response);
|
|
switch(req_type)
|
|
{
|
|
case SteamConstants.RESPONSE_OnUserStatsReceived:
|
|
trace("RESPONSE_OnUserStatsReceived");
|
|
break;
|
|
case SteamConstants.RESPONSE_OnAchievementStored:
|
|
trace("RESPONSE_OnAchievementStored");
|
|
break;
|
|
}
|
|
dispatchEvent(sEvent);
|
|
}
|
|
|
|
public function dispose():Void
|
|
{
|
|
clearInterval(_tm);
|
|
_ExtensionContext.removeEventListener(StatusEvent.STATUS, handleStatusEvent);
|
|
_ExtensionContext.dispose();
|
|
}
|
|
|
|
public function init():Bool
|
|
{
|
|
isReady=_ExtensionContext.call("AIRSteam_Init")as Bool;
|
|
if(isReady) _tm=setInterval(runCallbacks, 100);
|
|
return isReady;
|
|
}
|
|
public function requestStats():Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_RequestStats")as Bool;
|
|
}
|
|
|
|
public function runCallbacks():Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_RunCallbacks")as Bool;
|
|
}
|
|
|
|
public function setAchievement(id:String):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_SetAchievement", id)as Bool;
|
|
}
|
|
|
|
public function clearAchievement(id:String):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_ClearAchievement", id)as Bool;
|
|
}
|
|
|
|
public function isAchievement(id:String):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_IsAchievement", id)as Bool;
|
|
}
|
|
|
|
public function getStatInt(id:String):Int
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_GetStatInt", id)as Int;
|
|
}
|
|
|
|
public function getStatFloat(id:String):Float
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_GetStatFloat", id)as Float;
|
|
}
|
|
|
|
public function setStatInt(id:String, value:Int):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_SetStatInt", id, value)as Bool;
|
|
}
|
|
|
|
public function setStatFloat(id:String, value:Float):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_SetStatFloat", id, value)as Bool;
|
|
}
|
|
|
|
public function storeStats():Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_StoreStats")as Bool;
|
|
}
|
|
|
|
public function resetAllStats(bAchievementsToo:Bool):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_ResetAllStats", bAchievementsToo)as Bool;
|
|
}
|
|
|
|
|
|
public function getFileCount():Int
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_GetFileCount")as Int;
|
|
}
|
|
|
|
public function getFileSize(fileName:String):Int
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_GetFileSize", fileName)as Int;
|
|
}
|
|
|
|
public function fileExists(fileName:String):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_FileExists", fileName)as Bool;
|
|
}
|
|
|
|
public function fileWrite(fileName:String, data:ByteArray):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_FileWrite", fileName, data)as Bool;
|
|
}
|
|
|
|
public function fileRead(fileName:String, data:ByteArray):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_FileRead", fileName, data)as Bool;
|
|
}
|
|
|
|
public function fileDelete(fileName:String):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_FileDelete", fileName)as Bool;
|
|
}
|
|
|
|
public function isCloudEnabledForApp():Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_IsCloudEnabledForApp")as Bool;
|
|
}
|
|
|
|
public function setCloudEnabledForApp(enabled:Bool):Bool
|
|
{
|
|
return _ExtensionContext.call("AIRSteam_SetCloudEnabledForApp", enabled)as Bool;
|
|
}
|
|
} |