Created
October 10, 2012 16:12
-
-
Save jgranick/3866623 to your computer and use it in GitHub Desktop.
Draft Project File Spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package; | |
class Project extends ProjectBase { | |
public function new (target:String) { | |
super (target); | |
meta.title = "TestNME"; | |
meta.packageName = "com.testing.myapplication"; | |
meta.version = "1.0.0"; | |
meta.company = ""; | |
app.main = "TestNME"; | |
app.file = "TestNME"; | |
app.path = "Export"; | |
if (!isMobile) { | |
window.width = 800; | |
window.height = 600; | |
window.shaders = true; | |
} | |
window.fps = 30; | |
window.orientation = "portrait"; | |
source.push ("Source"); | |
haxelib.push ("nme"); | |
haxelib.push ("actuate"); | |
haxelib.push ("svg"); | |
haxelib.push ("webview"); | |
library.push ("Assets/library.swf"); | |
includeAssets ("Assets", "assets", [ "*" ], [ "nme.svg" ]); | |
icon.push (new Icon ("Assets/nme.svg")); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ; | |
class ProjectBase { | |
public var meta:MetaData; | |
public var app:App; | |
public var window:Window; | |
public var isMobile:Bool; | |
public var isDesktop:Bool; | |
public var isWeb:Bool; | |
public var assets:Array <Asset>; | |
public var certificate:Keystore; | |
public var dependency:Array <String>; | |
public var haxedef:Array <String>; | |
public var haxeflag:Array <String>; | |
public var haxelib:Array <String>; | |
public var icon:Array <Icon>; | |
public var java:Array <String>; | |
public var library:Array <String>; | |
public var ndll:Array <NDLL>; | |
public var path:Array <String>; | |
public var setenv:Hash <String>; | |
public var source:Array <String>; | |
public var target:Target; | |
// add pre-build, post-build hooks | |
public static function main () { | |
new Project ("html5"); | |
} | |
public function new (targetName:String) { | |
target = Reflect.field (Target, targetName.toUpperCase ()); | |
switch (target) { | |
case Target.FLASH, Target.HTML5: isWeb = true; | |
case Target.ANDROID, Target.BLACKBERRY, Target.IOS, Target.WEBOS: isMobile = true; | |
case Target.WINDOWS, Target.MAC, Target.LINUX: isDesktop = true; | |
} | |
meta = { title: "MyApplication", description: "", packageName: "com.example.myapp", version: "1.0.0", company: "Example, Inc." } | |
app = { main: "Main", file: "MyApplication", path: "bin", preloader: "NMEPreloader", swfVersion: "11" } | |
window = { width: 800, height: 600, background: 0xFFFFFF, fps: 30, resizable: true, borderless: false, orientation: "auto", vsync: false, fullscreen: false, antialiasing: 0, shaders: false } | |
assets = new Array <Asset> (); | |
dependency = new Array <String> (); | |
haxedef = new Array <String> (); | |
haxeflag = new Array <String> (); | |
haxelib = new Array <String> (); | |
icon = new Array <Icon> (); | |
java = new Array <String> (); | |
library = new Array <String> (); | |
ndll = new Array <NDLL> (); | |
path = new Array <String> (); | |
setenv = new Hash <String> (); | |
source = new Array <String> (); | |
} | |
public function include (path:String):Void { | |
// extend project file somehow? | |
} | |
public function includeAssets (path:String, rename:String = null, include:Array <String> = null, exclude:Array <String> = null):Void { | |
if (path == null) { | |
path = [ "*" ]; | |
} | |
if (exclude == null) { | |
exclude = []; | |
} | |
// populate assets array with files in the directory | |
} | |
} | |
typedef App = { | |
var file:String; | |
var main:String; | |
var path:String; | |
var minSWFVersion:String; | |
var preloader:String; | |
var swfVersion:String; | |
var url:String; | |
} | |
class Asset { | |
public var data:Dynamic; | |
public var embed:Bool; | |
public var glyphs:String; | |
public var id:String; | |
public var path:String; | |
public var rename:String; | |
public var type:AssetType; | |
public function new (path:String, rename:String = "", type:AssetType = null, embed:Bool = true) { | |
this.path = path; | |
if (rename == "") { | |
this.rename = path; | |
} else { | |
this.rename = rename; | |
} | |
if (type == null) { | |
var extension = Path.extension (path); | |
switch (extension.toLowerCase ()) { | |
case "jpg", "jpeg", "png", "gif": | |
this.type = AssetType.IMAGE; | |
case "otf", "ttf": | |
this.type = AssetType.FONT; | |
case "wav", "ogg": | |
this.type = AssetType.SOUND; | |
case "mp3", "mp2": | |
this.type = AssetType.MUSIC; | |
case "text", "txt", "json", "xml", "svg": | |
this.type = AssetType.TEXT; | |
default: | |
this.type = AssetType.BINARY; | |
} | |
} | |
} | |
} | |
enum AssetType { | |
BINARY; | |
FONT; | |
IMAGE; | |
MUSIC; | |
SOUND; | |
TEMPLATE; | |
TEXT; | |
} | |
class Icon { | |
public var height:Int; | |
public var path:String; | |
public var size:Int; | |
public var width:Int; | |
public function new (path:String, size:Int = -1) { | |
this.path = path; | |
this.size = height = width = size; | |
} | |
} | |
class Keystore { | |
public var alias:String; | |
public var aliasPassword:String; | |
public var password:String; | |
public var path:String; | |
public var type:String; | |
public function new (path:String, password:String = null, alias:String = "", aliasPassword:String = null) { | |
this.path = path; | |
this.password = password; | |
this.alias = alias; | |
this.aliasPassword = aliasPassword; | |
} | |
} | |
typedef MetaData = { | |
var title:String; | |
var description:String; | |
var packageName:String; | |
var version:String; | |
var company:String; | |
} | |
class NDLL { | |
public var haxelib:String; | |
public var name:String; | |
public function new (name:String, haxelib:String = "") { | |
this.name = name; | |
this.haxelib = haxelib; | |
} | |
} | |
enum Target { | |
ANDROID; | |
BLACKBERRY; | |
FLASH; | |
HTML5; | |
IOS; | |
LINUX; | |
MAC; | |
WINDOWS; | |
WEBOS; | |
} | |
typedef Window = { | |
var width:Int; | |
var height:Int; | |
var background:Int; | |
var fps:Int; | |
var resizable:Bool; | |
var borderless:Bool; | |
var vsync:Bool; | |
var fullscreen:Bool; | |
var antialiasing:Int; | |
var orientation:String; | |
var shaders:Bool; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks nice! What about seperate the concept of platform/technology instead of a single target?
It can be hieratical.
eg.
"iphone" implies "ios" and "mobile".