diff --git a/examples/website/project.xml b/examples/website/project.xml index 7e5550e..030deff 100644 --- a/examples/website/project.xml +++ b/examples/website/project.xml @@ -24,6 +24,7 @@ + diff --git a/haxelib.json b/haxelib.json index 5bc6815..6c83245 100644 --- a/haxelib.json +++ b/haxelib.json @@ -5,8 +5,8 @@ "description": "Glory Framework is a page-based media framework built using [Haxe 3](http://haxe.org/), [OpenFL](http://openfl.org), and [PureMVC](http://puremvc.org/). It can be used for interactive e-books, adventure games, websites, or slide presentations on any target supported by OpenFL. It uses an XML configuration file to build the layout of each page, including placement and function of different controls. Each page can have its own custom class if desired. Glory also includes two Photoshop scripts which make it easy to rapidly convert a PSD layout into something that Glory can use. It can also use SVG files saved directly from Illustrator (not all types of object are supported).", "contributors": ["ConfidantCommunications"], "classPath":"src/", - "releasenote": "Now supporting swf assets.", - "version": "1.2.0", + "releasenote": "Now compatible with Haxe 4.0 and includes app mode and website mode.", + "version": "2.0.0", "url": "https://github.com/ConfidantCommunications/Glory-Framework/", "dependencies": { "openfl" :"", @@ -14,4 +14,4 @@ "svg" :"", "puremvc-standard":"" } -} +} diff --git a/src/ca/confidant/glory/controller/ActorComponentFactory.hx b/src/ca/confidant/glory/controller/ActorComponentFactory.hx index a3a03bf..b62cdfb 100644 --- a/src/ca/confidant/glory/controller/ActorComponentFactory.hx +++ b/src/ca/confidant/glory/controller/ActorComponentFactory.hx @@ -20,7 +20,7 @@ */ package ca.confidant.glory.controller; -import haxe.xml.Fast; +import haxe.xml.Access; import ca.confidant.glory.ApplicationFacade; import ca.confidant.glory.model.ActorComponentConfigProxy; import ca.confidant.glory.view.ActorComponentMediator; @@ -50,7 +50,7 @@ class ActorComponentFactory { facade = Facade.getInstance(); } - public function create(pageId:String, actor:Fast, ?swflib:String):ActorComponent { + public function create(pageId:String, actor:Access, ?swflib:String):ActorComponent { #if !appMode var alp = cast(facade.retrieveProxy(pageId) , AssetLibraryProxy); @@ -234,7 +234,6 @@ class ActorComponentFactory { } } - // trace(Reflect.fields(LayoutCreator)); LayoutHelper.instance.layout(a,accp.layoutCommands); diff --git a/src/ca/confidant/glory/controller/AsyncLoadAssetsCommand.hx b/src/ca/confidant/glory/controller/AsyncLoadAssetsCommand.hx index b043d05..70bd374 100644 --- a/src/ca/confidant/glory/controller/AsyncLoadAssetsCommand.hx +++ b/src/ca/confidant/glory/controller/AsyncLoadAssetsCommand.hx @@ -20,7 +20,7 @@ */ package ca.confidant.glory.controller; - import haxe.xml.Fast; + import haxe.xml.Access; import openfl.utils.Assets; import openfl.utils.AssetLibrary; import openfl.utils.AssetManifest; @@ -66,7 +66,7 @@ package ca.confidant.glory.controller; var pageId:String; var oldpm:PageMediator; // var pendingLoads:Int; - var actorsList:List; + var actorsList:Array; public function new(){ super(); } diff --git a/src/ca/confidant/glory/controller/BuildControlsCommand.hx b/src/ca/confidant/glory/controller/BuildControlsCommand.hx index 5cff954..9616144 100644 --- a/src/ca/confidant/glory/controller/BuildControlsCommand.hx +++ b/src/ca/confidant/glory/controller/BuildControlsCommand.hx @@ -24,7 +24,7 @@ package ca.confidant.glory.controller; import flash.display.Bitmap; import flash.display.BitmapData; import lime.graphics.Image; - import haxe.xml.Fast; + import haxe.xml.Access; import openfl.Assets; import lime.utils.Assets in LimeAssets; import org.puremvc.haxe.patterns.command.SimpleCommand; @@ -59,7 +59,7 @@ package ca.confidant.glory.controller; #if !appMode alp=cast(facade.retrieveProxy("gloryControls") , AssetLibraryProxy); #end - var controlsList:List=pcp.getAppControls(); + var controlsList:Array=pcp.getAppControls(); for (thisControl in controlsList){ // makeControl(thisControl); var a = ActorComponentFactory.instance.create("gloryControls",thisControl); diff --git a/src/ca/confidant/glory/controller/LayoutHelper.hx b/src/ca/confidant/glory/controller/LayoutHelper.hx index 0a6ffc5..3b94da1 100644 --- a/src/ca/confidant/glory/controller/LayoutHelper.hx +++ b/src/ca/confidant/glory/controller/LayoutHelper.hx @@ -28,7 +28,8 @@ import ca.confidant.glory.model.StateProxy; import ca.confidant.glory.model.PagesConfigProxy; import ca.confidant.glory.view.components.ActorComponent; import org.puremvc.haxe.interfaces.INotification; -using layout.LayoutCreator; +// import com.player03.layout.Resizable; +using com.player03.layout.LayoutCreator.ForOpenFL; /* * @author Allan Dowdeswell @@ -41,13 +42,59 @@ using layout.LayoutCreator; private function new(){ // facade = Facade.getInstance(); }; - + + /* + * Now spoon-feed the LayoutCreator some view objects casted as Resizable. + * Necessary due to breaking changes in Haxe 4. + * + static public inline function feed(r:Resizable, ?f) { + if (f != null) f(r); + return r; + }*/ + /* + + switch(com[0]){ + case "simpleX": feed(a, t -> {t.simpleX(i);}); + case "simpleY": feed(a, t -> {t.simpleY(i);}); + case "centerX": feed(a, t -> {t.centerX();}); + case "centerY": feed(a, t -> {t.centerY();}); + case "center": feed(a, t -> {t.center();}); + case "alignLeft": feed(a, t -> {t.alignLeft(i);}); + case "alignRight": feed(a, t -> {t.alignRight(i);}); + case "alignTop": feed(a, t -> {t.alignTop(i);}); + case "alignBottom": feed(a, t -> {t.alignBottom(i);}); + case "alignTopLeft": feed(a, t -> {t.alignTopLeft(i);}); + case "alignTopRight": feed(a, t -> {t.alignTopRight(i);}); + case "alignBottomLeft": feed(a, t -> {t.alignBottomLeft(i);}); + case "alignBottomRight": feed(a, t -> {t.alignBottomRight(i);}); + case "alignLeftCenter": feed(a, t -> {t.alignLeftCenter(i);}); + case "alignRightCenter": feed(a, t -> {t.alignRightCenter(i);}); + case "alignTopCenter": feed(a, t -> {t.alignTopCenter(i);}); + case "alignBottomCenter": feed(a, t -> {t.alignBottomCenter(i);}); + case "horizontalPercent": feed(a, t -> {t.horizontalPercent(i);}); + case "verticalPercent": feed(a, t -> {t.verticalPercent(i);}); + case "simpleScale": feed(a, t -> {t.simpleScale();}); + case "simpleWidth": feed(a, t -> {t.simpleWidth(i);}); + case "simpleHeight": feed(a, t -> {t.simpleHeight(i);}); + case "rigidSimpleScale": feed(a, t -> {t.rigidSimpleScale();}); + case "rigidSimpleWidth": feed(a, t -> {t.rigidSimpleWidth(i);}); + case "rigidSimpleHeight": feed(a, t -> {t.rigidSimpleHeight(i);}); + case "fillWidth": feed(a, t -> {t.fillWidth(i);}); + case "fillHeight": feed(a, t -> {t.fillHeight(i);}); + case "fillPercentWidth": feed(a, t -> {t.fillPercentWidth(i);}); + case "fillPercentHeight": feed(a, t -> {t.fillPercentHeight(i);}); + case "rigidFillPercentWidth": feed(a, t -> {t.rigidFillPercentWidth(i);}); + case "rigidFillPercentHeight": feed(a, t -> {t.rigidFillPercentHeight(i);}); + case "maintainAspectRatio": feed(a, t -> {t.maintainAspectRatio();}); + */ public function layout(a:ActorComponent,commands:Array):Void { + for(thisCommand in commands){ var com = thisCommand.split(":"); + //todo: use an abstract here https://haxe.org/manual/types-abstract-implicit-casts.html var i = (com[1]!=null) ? Std.parseFloat(com[1]) : null; //convert parameter on right of colon to real number trace("layout command:"+com+" value:"+i); - // var pcp:PageConfigProxy = cast(facade.getProxy(PageConfigProxy.NAME),PageConfigProxy); + // switch(com[0]){ case "simpleX": a.simpleX(i); case "simpleY": a.simpleY(i); diff --git a/src/ca/confidant/glory/controller/startup/Startup3_Assets_Command.hx b/src/ca/confidant/glory/controller/startup/Startup3_Assets_Command.hx index b860ef6..530251e 100644 --- a/src/ca/confidant/glory/controller/startup/Startup3_Assets_Command.hx +++ b/src/ca/confidant/glory/controller/startup/Startup3_Assets_Command.hx @@ -24,7 +24,7 @@ package ca.confidant.glory.controller.startup; import org.puremvc.haxe.interfaces.INotification; import openfl.Assets; import openfl.utils.AssetLibrary; - import haxe.xml.Fast; + import haxe.xml.Access; import lime.utils.AssetType; import ca.confidant.glory.model.PagesConfigProxy; import openfl.net.URLLoader; @@ -56,7 +56,7 @@ package ca.confidant.glory.controller.startup; private function _onXMLLoaded(e:Event):Void { var ul:URLLoader=cast(e.target,URLLoader); - var xml=new Fast(Xml.parse(ul.data)).node.pages; + var xml=new Access(Xml.parse(ul.data)).node.pages; var pcp:PagesConfigProxy=cast(facade.retrieveProxy(PagesConfigProxy.NAME),PagesConfigProxy); pcp.processXML(xml); diff --git a/src/ca/confidant/glory/model/PagesConfigProxy.hx b/src/ca/confidant/glory/model/PagesConfigProxy.hx index acdaac6..5d549a2 100644 --- a/src/ca/confidant/glory/model/PagesConfigProxy.hx +++ b/src/ca/confidant/glory/model/PagesConfigProxy.hx @@ -22,7 +22,7 @@ package ca.confidant.glory.model; import org.puremvc.haxe.patterns.proxy.Proxy; import ca.confidant.glory.ApplicationFacade; - import haxe.xml.Fast; + import haxe.xml.Access; /* * @author Allan Dowdeswell @@ -36,7 +36,7 @@ package ca.confidant.glory.model; { public static inline var NAME:String = "pagesConfigProxy"; private var _pagesXML:Xml; - private var fast:haxe.xml.Fast; + private var fast:haxe.xml.Access; private var allPages:Array>; private var imageItems:Array; private var currentPage:Int; @@ -51,7 +51,7 @@ package ca.confidant.glory.model; currentPage=0; } - public function processXML(input:Fast){ + public function processXML(input:Access){ fast = input; parseXML(); } @@ -143,7 +143,7 @@ package ca.confidant.glory.model; return 1; } } - public function getPageActors(pageId:String):List{ + public function getPageActors(pageId:String):Array{ var p=getPage(pageId); if ((p!=null)&&(p.get("actors")!=null)){ //trace("returning actors!"); @@ -151,40 +151,40 @@ package ca.confidant.glory.model; } else { //iOS currently returning empty, why? //trace("returning empty!"); - return new List(); + return new Array(); } } - public function getPageSounds(pageId:String):List{ + public function getPageSounds(pageId:String):Array{ var p=getPage(pageId); if ((p!=null)&&(p.get("sounds")!=null)){ //trace("returning sounds!:"+Type.typeof(p.get("sounds"))); return p.get("sounds"); } else { //trace("returning no sounds!"); - return new List(); + return new Array(); } } - /*public function getPageFonts(pageId:String):List{ + /*public function getPageFonts(pageId:String):Array{ var p=getPage(pageId); if ((p!=null)&&(p.get("fonts")!=null)){ return p.get("fonts"); } else { - return new List(); + return new Array(); } } - public function getPageStyles(pageId:String):List{ + public function getPageStyles(pageId:String):Array{ var p=getPage(pageId); if ((p!=null)&&(p.get("styles")!=null)){ return p.get("styles"); } else { - return new List(); + return new Array(); } }*/ - public function getAppControls():List{ + public function getAppControls():Array{ if (fast.node.controls.hasNode.actor){ return fast.node.controls.nodes.actor; } - return new List(); + return new Array(); } public function getControlHref(controlId:String):String{ if (fast.node.controls.hasNode.actor){ diff --git a/src/ca/confidant/glory/view/components/ActorComponent.hx b/src/ca/confidant/glory/view/components/ActorComponent.hx index dedcf91..8a20cde 100644 --- a/src/ca/confidant/glory/view/components/ActorComponent.hx +++ b/src/ca/confidant/glory/view/components/ActorComponent.hx @@ -25,7 +25,7 @@ import openfl.display.DisplayObject; import openfl.display.Bitmap; import openfl.display.BitmapDataChannel; import openfl.utils.ByteArray; - +using com.player03.layout.LayoutCreator; /** * @author Allan Dowdeswell * ActorComponents appear within a page. Make them do whatever you want. diff --git a/src/pushstate/PushState.hx b/src/pushstate/PushState.hx index a46f3b6..fae80e5 100755 --- a/src/pushstate/PushState.hx +++ b/src/pushstate/PushState.hx @@ -90,9 +90,9 @@ class PushState { document.addEventListener("click",function(e:MouseEvent) { if (e.button==0 && !e.metaKey && !e.ctrlKey) { var link:AnchorElement = null, - node:Node = Std.instance(e.target,Node); + node:Node = Std.downcast(e.target,Node); while (link==null && node!=null) { - link = Std.instance(node,AnchorElement); + link = Std.downcast(node,AnchorElement); node = node.parentNode; } if (link!=null && (link.rel=="pushstate" || hasClass(link,"pushstate"))) { @@ -104,7 +104,7 @@ class PushState { // Intercept
submits. document.addEventListener("submit",function (e:Event) { - var form = Std.instance(e.target,FormElement); + var form = Std.downcast(e.target,FormElement); if (hasClass(form,"pushstate")) { e.preventDefault(); interceptFormSubmit(form); @@ -152,7 +152,7 @@ class PushState { var elm = form.elements.item(i); switch elm.nodeName.toUpperCase() { case 'INPUT': - var input = Std.instance(elm,InputElement); + var input = Std.downcast(elm,InputElement); switch input.type { case 'text','hidden','password','search','email','url','tel','number','range','date','month','week','time','datetime','datetime-local','color': addParam(input.name, input.value); case 'checkbox','radio' if (input.checked): addParam(input.name, input.value); @@ -161,10 +161,10 @@ class PushState { addUpload(input.name, input.files); } case 'TEXTAREA': - var ta = Std.instance(elm,TextAreaElement); + var ta = Std.downcast(elm,TextAreaElement); addParam(ta.name, ta.value); case 'SELECT': - var select = Std.instance(elm,SelectElement); + var select = Std.downcast(elm,SelectElement); switch select.type { case 'select-one': addParam(select.name, select.value); case 'select-multiple': @@ -178,14 +178,14 @@ class PushState { } } // Check if there was a submit button value: - var activeInput = Std.instance( document.activeElement, InputElement ); - var activeBtn = Std.instance( document.activeElement, ButtonElement ); + var activeInput = Std.downcast( document.activeElement, InputElement ); + var activeBtn = Std.downcast( document.activeElement, ButtonElement ); if ( activeInput!=null && activeInput.type=="submit" ) addParam( activeInput.name, activeInput.value ); else if ( activeBtn!=null && activeBtn.type=="submit" ) addParam( activeBtn.name, activeBtn.value ); else { var defaultSubmit = form.querySelector( "input[type=submit], button[type=submit]" ); - var defaultInput = Std.instance( defaultSubmit, InputElement ); - var defaultBtn = Std.instance( defaultSubmit, ButtonElement ); + var defaultInput = Std.downcast( defaultSubmit, InputElement ); + var defaultBtn = Std.downcast( defaultSubmit, ButtonElement ); if ( defaultInput!=null ) addParam( defaultInput.name, defaultInput.value ); else if ( defaultBtn!=null ) addParam( defaultBtn.name, defaultBtn.value ); }