public static void ExportHaXeClasses(String file, String toFolder) { XmlDocument xml = new XmlDocument(); try { xml.Load(file); } catch { MessageBox.Show(LocaleHelper.GetErrorString( LocaleHelper.INVALID_FILE_ERROR)); return; } XmlNode root = xml.FirstChild; SamSchema sch = new SamSchema(); XmlAttribute p = root.Attributes["package"]; if (p != null) { sch.Package = p.InnerText; } p = root.Attributes["version"]; if (p != null) { sch.Version = p.InnerText; } XmlNodeList nodeList = root.ChildNodes; Int32 nodeCount = nodeList.Count; XmlNode currentNode; SamFrame fr; List <SamResource> resources = new List <SamResource>(); for (Int32 i = 0; i < nodeCount; i++) { currentNode = nodeList[i]; if (currentNode.LocalName == "frame") { fr = new SamFrame(); if (currentNode.ChildNodes.Count > 0) { AddResources(fr, currentNode.ChildNodes, resources); } sch.Frames.Add(fr); } } ProcessTemplates(sch.Package, resources, toFolder); }
public void RunTarget(String file, SamSettings settings) { String command = this.settingObject.SamHome; // TODO: Put this into resources if (String.IsNullOrEmpty(command) || !File.Exists(command)) { MessageBox.Show( LocaleHelper.GetErrorString(LocaleHelper.NO_SAM_HOME)); return; } if (settings == null || String.IsNullOrEmpty(settings.Output)) { MessageBox.Show( LocaleHelper.GetErrorString(LocaleHelper.NO_OUTPUT_FILE)); return; } String arguments = ""; //Usage: SamHaXe [options] <resources.xml> <assets.swf> //options: //-c <config file name>, --config <config file name> // If given, config is read from the specified file. //-d <file name>, --depfile <file name> // If given, resource dependecies will be written into the specified file. //-h, --help // Display this help message. //-l, --module-list // List all import modules with a short description. //-m module:key=value[:key=value:...], --module-options module:key=value[:key=value:...] // The specified options are passed to the specified import module. (Exaple: Binary:myopt=somevalue) //--module-help module[=interface_version[;flash_version]][:module[=interface_version[;flash_version]]...] // Prints help message of listed modules. if (!String.IsNullOrEmpty(settings.Config)) { arguments += "-c \"" + settings.Config + "\" "; } if (!String.IsNullOrEmpty(settings.Depfile)) { arguments += "-d \"" + settings.Depfile + "\" "; } arguments += "\"" + settings.Input + "\" \"" + settings.Output + "\""; Globals.MainForm.CallCommand("RunProcessCaptured", command + ";" + arguments); }
private static void AddResources(ISamResources toContainer, XmlNodeList fromNodes, List <SamResource> storeIn) { Int32 count = fromNodes.Count; XmlNode node; SamResource res = null; XmlAttribute a; Boolean failed = false; for (Int32 i = 0; i < count; i++) { node = fromNodes[i]; switch (node.LocalName) { case "library": case "swf": res = new SamResource(); res.ResourceType = ResourceNodeType.Swf; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["class"]; if (!failed && a != null) { res.Class = a.InnerText; } else if (node.LocalName == "swf") { failed = true; } break; case "ttf": res = new SamFont(); res.ResourceType = ResourceNodeType.Font; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["name"]; if (!failed && a == null) { failed = true; } AddFontRange((SamFont)res, node.ChildNodes); a = node.Attributes["class"]; if (a != null) { res.Class = a.InnerText; } break; case "sound": res = new SamResource(); res.ResourceType = ResourceNodeType.Sound; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["class"]; if (!failed && a != null) { res.Class = a.InnerText; } else { failed = true; } break; case "image": res = new SamResource(); res.ResourceType = ResourceNodeType.Image; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["class"]; if (!failed && a != null) { res.Class = a.InnerText; } else { failed = true; } break; case "binary": res = new SamResource(); res.ResourceType = ResourceNodeType.Binary; a = node.Attributes["import"]; if (a != null) { res.File = a.InnerText; } else { failed = true; } if (!failed) { res.File = a.InnerText; } a = node.Attributes["class"]; if (!failed && a != null) { res.Class = a.InnerText; } else { failed = true; } break; case "composite": res = new SamComposite(); res.ResourceType = ResourceNodeType.Compose; AddResources(res as ISamResources, node.ChildNodes, storeIn); break; } if (failed) { MessageBox.Show(LocaleHelper.GetErrorString( LocaleHelper.INVALID_FILE_ERROR)); return; } toContainer.Resources.Add(res); if (res.ResourceType != ResourceNodeType.Compose) { if (res.Class != null) { storeIn.Add(res); } } } }