Skip to content

Commit

Permalink
Now compatible with Haxe 4, OpenFL 8.9.5 and SVG 1.3.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ConfidantCommunications committed Oct 9, 2019
1 parent 65d202e commit fe902d9
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 39 deletions.
1 change: 1 addition & 0 deletions examples/website/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<haxelib name="puremvc-standard" />
<haxelib name="puremvc-asynccommand-standard" />
<haxelib name="advanced-layout" />
<haxeflag name="-dce" value="no" />
<!--haxelib name="pushstate" if="html5" / now forked locally-->

<assets path="assets/fonts" rename="fonts" />
Expand Down
6 changes: 3 additions & 3 deletions haxelib.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"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" :"",
"actuate" :"",
"svg" :"",
"puremvc-standard":""
}
}
}
5 changes: 2 additions & 3 deletions src/ca/confidant/glory/controller/ActorComponentFactory.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -234,7 +234,6 @@ class ActorComponentFactory {
}
}

// trace(Reflect.fields(LayoutCreator));
LayoutHelper.instance.layout(a,accp.layoutCommands);


Expand Down
4 changes: 2 additions & 2 deletions src/ca/confidant/glory/controller/AsyncLoadAssetsCommand.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -66,7 +66,7 @@ package ca.confidant.glory.controller;
var pageId:String;
var oldpm:PageMediator;
// var pendingLoads:Int;
var actorsList:List<Fast>;
var actorsList:Array<Access>;
public function new(){
super();
}
Expand Down
4 changes: 2 additions & 2 deletions src/ca/confidant/glory/controller/BuildControlsCommand.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,7 +59,7 @@ package ca.confidant.glory.controller;
#if !appMode
alp=cast(facade.retrieveProxy("gloryControls") , AssetLibraryProxy);
#end
var controlsList:List<Fast>=pcp.getAppControls();
var controlsList:Array<Access>=pcp.getAppControls();
for (thisControl in controlsList){
// makeControl(thisControl);
var a = ActorComponentFactory.instance.create("gloryControls",thisControl);
Expand Down
53 changes: 50 additions & 3 deletions src/ca/confidant/glory/controller/LayoutHelper.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<String>):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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
26 changes: 13 additions & 13 deletions src/ca/confidant/glory/model/PagesConfigProxy.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Map<String,Dynamic>>;
private var imageItems:Array<Dynamic>;
private var currentPage:Int;
Expand All @@ -51,7 +51,7 @@ package ca.confidant.glory.model;
currentPage=0;
}

public function processXML(input:Fast){
public function processXML(input:Access){
fast = input;
parseXML();
}
Expand Down Expand Up @@ -143,48 +143,48 @@ package ca.confidant.glory.model;
return 1;
}
}
public function getPageActors(pageId:String):List<Fast>{
public function getPageActors(pageId:String):Array<Access>{
var p=getPage(pageId);
if ((p!=null)&&(p.get("actors")!=null)){
//trace("returning actors!");
return p.get("actors");
} else {
//iOS currently returning empty, why?
//trace("returning empty!");
return new List<Fast>();
return new Array<Access>();
}
}
public function getPageSounds(pageId:String):List<Fast>{
public function getPageSounds(pageId:String):Array<Access>{
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<Fast>();
return new Array<Access>();
}
}
/*public function getPageFonts(pageId:String):List<Fast>{
/*public function getPageFonts(pageId:String):Array<Access>{
var p=getPage(pageId);
if ((p!=null)&&(p.get("fonts")!=null)){
return p.get("fonts");
} else {
return new List<Fast>();
return new Array<Access>();
}
}
public function getPageStyles(pageId:String):List<Fast>{
public function getPageStyles(pageId:String):Array<Access>{
var p=getPage(pageId);
if ((p!=null)&&(p.get("styles")!=null)){
return p.get("styles");
} else {
return new List<Fast>();
return new Array<Access>();
}
}*/
public function getAppControls():List<Fast>{
public function getAppControls():Array<Access>{
if (fast.node.controls.hasNode.actor){
return fast.node.controls.nodes.actor;
}
return new List<Fast>();
return new Array<Access>();
}
public function getControlHref(controlId:String):String{
if (fast.node.controls.hasNode.actor){
Expand Down
2 changes: 1 addition & 1 deletion src/ca/confidant/glory/view/components/ActorComponent.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 10 additions & 10 deletions src/pushstate/PushState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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"))) {
Expand All @@ -104,7 +104,7 @@ class PushState {

// Intercept <form rel="pushstate"> 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);
Expand Down Expand Up @@ -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);
Expand All @@ -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':
Expand All @@ -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 );
}
Expand Down

0 comments on commit fe902d9

Please sign in to comment.