/* * Copyright (c) 2008, HippoHX Contributors * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE HIPPOHX PROJECT CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE HIPPOHX PROJECT CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ package com.hippohx.gui{ import com.hippohx.System; public class Project{ public var label:String; // this is for the List component public var fullPath:String = ""; public var title:String = ""; public var appname:String = ""; public var appxml:String = ""; public var customappxml:String = ""; public var appbackend:String = ""; public var appswf:String = ""; public var macicon:String = ""; public var winicon:String = ""; public var formac:Boolean = true; public var forwin:Boolean = true; public var exportfolder:String = ""; public var windowWidth:uint = 800; public var windowHeight:uint = 600; public var windowTitle:String = ""; public var windowCloseButton:Boolean = true; public var windowMinimizeButton:Boolean = true; public var windowMaximizeButton:Boolean = true; public var resizable:Boolean = false; public var fullscreen:Boolean = false; public var allowRightClick:Boolean = true; public var transparent:Boolean = false; public var flashvars:String = ""; // TODO: Might be worth url-encoding FlashVars public var backgroundcolor:String = "0xffffff"; private var initialXML:String; public function Project(){ resetInitialXML(); } public function setXML(projectXML:XML):void{ label = title = projectXML.projectname; appname = projectXML.appname; appbackend = projectXML.appbackend; appswf = projectXML.appswf; macicon = projectXML.appicons.mac; winicon = projectXML.appicons.win; formac = (projectXML.versions.@mac == "true"); forwin = (projectXML.versions.@win == "true"); exportfolder = projectXML.exportfolder; windowWidth = projectXML.window.@width; windowHeight = projectXML.window.@height; windowTitle = projectXML.window.title; windowCloseButton = (projectXML.window.@close == "true"); windowMinimizeButton = (projectXML.window.@minimize == "true"); windowMaximizeButton = (projectXML.window.@maximize == "true"); resizable = (projectXML.window.@resizable == "true"); fullscreen = (projectXML.window.@fullscreen == "true"); allowRightClick = (projectXML.window.@allowRightClick == "true"); transparent = (projectXML.window.@transparent == "true"); // Added after initial release. Lets keep backwards compatibility customappxml = (projectXML.hasNode.customappxml)? projectXML.customappxml : ""; flashvars = (projectXML.hasNode.options)? projectXML.options.flashvars : ""; backgroundcolor = (projectXML.hasNode.options)? projectXML.options.backgroundcolor : "0xffffff"; resetInitialXML(); } public function resetChanges():void{ setXML(new XML(initialXML)); } public function resetInitialXML():void{ initialXML = getProjectXMLRaw(); } public function hasChanged():Boolean{ return !(initialXML == getProjectXMLRaw()); } public function getProjectXMLRaw():String{ var xml:XML = new XML( {title} {appname} {appbackend} {customappxml} {appswf} {macicon} {winicon} {exportfolder} {windowTitle} {flashvars} {backgroundcolor} ); return xml.toXMLString(); } public function getAppXMLRaw(custom:Boolean=false):String{ var separator:String = com.hippohx.System.getInstance().getSystemSeparator(); // when packaged, the swf will be at the same level as the executable var swfName:String = appswf.substr(appswf.lastIndexOf(separator)+1); var hippoNode:XML = new XML( {windowTitle} {swfName} {flashvars} {backgroundcolor} ); var raw:String = hippoNode.toXMLString(); raw = raw.split("&").join("&"); // If FlashVars are added we need to replace the & with an actual & if(!custom){ raw = "" + raw + ""; } return raw; } public function getHHXRaw():String{ var xml:XML = new XML( {appname} {appxml} {appbackend} {appswf} {macicon} {winicon} {exportfolder} ); return xml.toXMLString(); } public function readyToBuild():Boolean{ // MANDATORY to build: SWF, executable name, export folder, window width, window height and window title return (appswf != "" && appname != "" && exportfolder != "" && windowWidth > 0 && windowHeight > 0 && windowTitle != ""); } } }