/// <summary> /// 新規作成 /// </summary> public static void New() { if (OnBeforeNew != null) { OnBeforeNew(null, null); } StartFrame = 0; EndFrame = 120; IsLoop = true; SelectedNode = null; Command.CommandManager.Clear(); Root = new Data.NodeRoot(); // 初期ノードの追加 Root.AddChild(); Command.CommandManager.Clear(); FullPath = string.Empty; IsChanged = false; if (OnAfterNew != null) { OnAfterNew(null, null); } }
/// <summary> /// New /// </summary> public static void New() { if (OnBeforeNew != null) { OnBeforeNew(null, null); } StartFrame = 0; EndFrame = 120; IsLoop = true; SelectedNode = null; Command.CommandManager.Clear(); Root = new Data.NodeRoot(); effectBehavior = new Data.EffectBehaviorValues(); culling = new Data.EffectCullingValues(); globalValues = new Data.GlobalValues(); // Add a root node Root.AddChild(); Command.CommandManager.Clear(); FullPath = string.Empty; IsChanged = false; if (OnAfterNew != null) { OnAfterNew(null, null); } }
/// <summary> /// New /// </summary> public static void New() { if (OnBeforeNew != null) { OnBeforeNew(null, null); } StartFrame = 0; EndFrame = 120; IsLoop = true; SelectedNode = null; Command.CommandManager.Clear(); Root = new Data.NodeRoot(); // Adhoc code effectBehavior.Reset(); culling = new Data.EffectCullingValues(); globalValues = new Data.GlobalValues(); if (recording.RecordingStorageTarget.Value == Data.RecordingStorageTargetTyoe.Local) { recording = new Data.RecordingValues(); } dynamic_ = new Data.DynamicValues(); // Add a root node Root.AddChild(); Command.CommandManager.Clear(); FullPath = string.Empty; IsChanged = false; // Select child //SelectedNode = Root.Children[0]; if (OnAfterNew != null) { OnAfterNew(null, null); } }
public static bool LoadFrom(string path) { path = System.IO.Path.GetFullPath(path); if (!System.IO.File.Exists(path)) { return(false); } SelectedNode = null; FullPath = path; var doc = new System.Xml.XmlDocument(); doc.Load(path); if (doc.ChildNodes.Count != 2) { return(false); } if (doc.ChildNodes[1].Name != "EffekseerProject") { return(false); } if (OnBeforeLoad != null) { OnBeforeLoad(null, null); } uint toolVersion = 0; if (doc["EffekseerProject"]["ToolVersion"] != null) { var fileVersion = doc["EffekseerProject"]["ToolVersion"].GetText(); var currentVersion = Core.Version; toolVersion = ParseVersion(fileVersion); if (toolVersion > ParseVersion(currentVersion)) { throw new Exception("Version Error : \nファイルがより新しいバージョンのツールで作成されています。\n最新バージョンのツールを使用してください。"); } } // 互換性のための変換 { // Stripe→Ribbon var innerText = doc.InnerXml; innerText = innerText.Replace("<Stripe>", "<Ribbon>").Replace("</Stripe>", "</Ribbon>"); doc = new System.Xml.XmlDocument(); doc.LoadXml(innerText); } // 互換性のための変換 { // GenerationTime // GenerationTimeOffset Action <System.Xml.XmlNode> replace = null; replace = (node) => { if ((node.Name == "GenerationTime" || node.Name == "GenerationTimeOffset") && node.ChildNodes.Count > 0 && node.ChildNodes[0] is System.Xml.XmlText) { var name = node.Name; var value = node.ChildNodes[0].Value; node.RemoveAll(); var center = doc.CreateElement("Center"); var max = doc.CreateElement("Max"); var min = doc.CreateElement("Min"); center.AppendChild(doc.CreateTextNode(value)); max.AppendChild(doc.CreateTextNode(value)); min.AppendChild(doc.CreateTextNode(value)); node.AppendChild(center); node.AppendChild(max); node.AppendChild(min); } else { for (int i = 0; i < node.ChildNodes.Count; i++) { replace(node.ChildNodes[i]); } } }; replace(doc); } var root = doc["EffekseerProject"]["Root"]; if (root == null) { return(false); } var behaviorElement = doc["EffekseerProject"]["Behavior"]; if (behaviorElement != null) { var o = effectBehavior as object; Data.IO.LoadObjectFromElement(behaviorElement as System.Xml.XmlElement, ref o, false); } var cullingElement = doc["EffekseerProject"]["Culling"]; if (cullingElement != null) { var o = culling as object; Data.IO.LoadObjectFromElement(cullingElement as System.Xml.XmlElement, ref o, false); } StartFrame = 0; EndFrame = doc["EffekseerProject"]["EndFrame"].GetTextAsInt(); StartFrame = doc["EffekseerProject"]["StartFrame"].GetTextAsInt(); IsLoop = bool.Parse(doc["EffekseerProject"]["IsLoop"].GetText()); IsLoop = true; int version = 0; if (doc["EffekseerProject"]["Version"] != null) { version = doc["EffekseerProject"]["Version"].GetTextAsInt(); } var root_node = new Data.NodeRoot() as object; Data.IO.LoadObjectFromElement(root as System.Xml.XmlElement, ref root_node, false); // 互換性のための変換(テクスチャ周り) if (version < 3) { Action <Data.NodeBase> convert = null; convert = (n) => { var n_ = n as Data.Node; if (n_ != null) { if (n_.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Sprite) { n_.RendererCommonValues.ColorTexture.SetAbsolutePathDirectly(n_.DrawingValues.Sprite.ColorTexture.AbsolutePath); n_.RendererCommonValues.AlphaBlend.SetValueDirectly(n_.DrawingValues.Sprite.AlphaBlend.Value); } else if (n_.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Ring) { n_.RendererCommonValues.ColorTexture.SetAbsolutePathDirectly(n_.DrawingValues.Ring.ColorTexture.AbsolutePath); n_.RendererCommonValues.AlphaBlend.SetValueDirectly(n_.DrawingValues.Ring.AlphaBlend.Value); } else if (n_.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Ribbon) { n_.RendererCommonValues.ColorTexture.SetAbsolutePathDirectly(n_.DrawingValues.Ribbon.ColorTexture.AbsolutePath); n_.RendererCommonValues.AlphaBlend.SetValueDirectly(n_.DrawingValues.Ribbon.AlphaBlend.Value); } } for (int i = 0; i < n.Children.Count; i++) { convert(n.Children[i]); } }; convert(root_node as Data.NodeBase); } Root = root_node as Data.NodeRoot; Command.CommandManager.Clear(); IsChanged = false; if (OnAfterLoad != null) { OnAfterLoad(null, null); } return(true); }
public static bool LoadFromXml(System.Xml.XmlDocument doc, string basePath) { basePath = System.IO.Path.GetFullPath(basePath); SelectedNode = null; FullPath = basePath; if (doc.ChildNodes.Count != 2) { return(false); } if (doc.ChildNodes[1].Name != "EffekseerProject") { return(false); } if (OnBeforeLoad != null) { OnBeforeLoad(null, null); } uint toolVersion = 0; if (doc["EffekseerProject"]["ToolVersion"] != null) { var fileVersion = doc["EffekseerProject"]["ToolVersion"].GetText(); var currentVersion = Core.Version; toolVersion = ParseVersion(fileVersion); if (toolVersion > ParseVersion(currentVersion)) { switch (Language) { case Language.English: throw new Exception("Version Error : \nThe file is created with a newer version of the tool.\nPlease use the latest version of the tool."); break; case Language.Japanese: throw new Exception("Version Error : \nファイルがより新しいバージョンのツールで作成されています。\n最新バージョンのツールを使用してください。"); break; } } } // For compatibility { // Stripe→Ribbon var innerText = doc.InnerXml; innerText = innerText.Replace("<Stripe>", "<Ribbon>").Replace("</Stripe>", "</Ribbon>"); doc = new System.Xml.XmlDocument(); doc.LoadXml(innerText); } // For compatibility { // GenerationTime // GenerationTimeOffset Action <System.Xml.XmlNode> replace = null; replace = (node) => { if ((node.Name == "GenerationTime" || node.Name == "GenerationTimeOffset") && node.ChildNodes.Count > 0 && node.ChildNodes[0] is System.Xml.XmlText) { var name = node.Name; var value = node.ChildNodes[0].Value; node.RemoveAll(); var center = doc.CreateElement("Center"); var max = doc.CreateElement("Max"); var min = doc.CreateElement("Min"); center.AppendChild(doc.CreateTextNode(value)); max.AppendChild(doc.CreateTextNode(value)); min.AppendChild(doc.CreateTextNode(value)); node.AppendChild(center); node.AppendChild(max); node.AppendChild(min); } else { for (int i = 0; i < node.ChildNodes.Count; i++) { replace(node.ChildNodes[i]); } } }; replace(doc); } var root = doc["EffekseerProject"]["Root"]; if (root == null) { return(false); } culling = new Data.EffectCullingValues(); globalValues = new Data.GlobalValues(); // Adhoc code effectBehavior.Reset(); var behaviorElement = doc["EffekseerProject"]["Behavior"]; if (behaviorElement != null) { var o = effectBehavior as object; Data.IO.LoadObjectFromElement(behaviorElement as System.Xml.XmlElement, ref o, false); } var cullingElement = doc["EffekseerProject"]["Culling"]; if (cullingElement != null) { var o = culling as object; Data.IO.LoadObjectFromElement(cullingElement as System.Xml.XmlElement, ref o, false); } var globalElement = doc["EffekseerProject"]["Global"]; if (globalElement != null) { var o = globalValues as object; Data.IO.LoadObjectFromElement(globalElement as System.Xml.XmlElement, ref o, false); } var dynamicElement = doc["EffekseerProject"]["Dynamic"]; if (dynamicElement != null) { var o = dynamic_ as object; Data.IO.LoadObjectFromElement(dynamicElement as System.Xml.XmlElement, ref o, false); } // recording option (this option is stored in local or global) if (doc["EffekseerProject"]["Recording"] != null) { var o = recording as object; Data.IO.LoadObjectFromElement(doc["EffekseerProject"]["Recording"] as System.Xml.XmlElement, ref o, false); } StartFrame = 0; EndFrame = doc["EffekseerProject"]["EndFrame"].GetTextAsInt(); StartFrame = doc["EffekseerProject"]["StartFrame"].GetTextAsInt(); IsLoop = bool.Parse(doc["EffekseerProject"]["IsLoop"].GetText()); IsLoop = true; int version = 0; if (doc["EffekseerProject"]["Version"] != null) { version = doc["EffekseerProject"]["Version"].GetTextAsInt(); } var root_node = new Data.NodeRoot() as object; Data.IO.LoadObjectFromElement(root as System.Xml.XmlElement, ref root_node, false); // For compatibility if (version < 3) { Action <Data.NodeBase> convert = null; convert = (n) => { var n_ = n as Data.Node; if (n_ != null) { if (n_.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Sprite) { n_.RendererCommonValues.ColorTexture.SetAbsolutePathDirectly(n_.DrawingValues.Sprite.ColorTexture.AbsolutePath); n_.RendererCommonValues.AlphaBlend.SetValueDirectly(n_.DrawingValues.Sprite.AlphaBlend.Value); } else if (n_.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Ring) { n_.RendererCommonValues.ColorTexture.SetAbsolutePathDirectly(n_.DrawingValues.Ring.ColorTexture.AbsolutePath); n_.RendererCommonValues.AlphaBlend.SetValueDirectly(n_.DrawingValues.Ring.AlphaBlend.Value); } else if (n_.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Ribbon) { n_.RendererCommonValues.ColorTexture.SetAbsolutePathDirectly(n_.DrawingValues.Ribbon.ColorTexture.AbsolutePath); n_.RendererCommonValues.AlphaBlend.SetValueDirectly(n_.DrawingValues.Ribbon.AlphaBlend.Value); } } for (int i = 0; i < n.Children.Count; i++) { convert(n.Children[i]); } }; convert(root_node as Data.NodeBase); } Root = root_node as Data.NodeRoot; Command.CommandManager.Clear(); IsChanged = false; if (OnAfterLoad != null) { OnAfterLoad(null, null); } return(true); }
public static bool LoadFrom(string path) { path = System.IO.Path.GetFullPath(path); if (!System.IO.File.Exists(path)) return false; SelectedNode = null; FullPath = path; var doc = new System.Xml.XmlDocument(); doc.Load(path); if (doc.ChildNodes.Count != 2) return false; if (doc.ChildNodes[1].Name != "EffekseerProject") return false; if (OnBeforeLoad != null) { OnBeforeLoad(null, null); } uint toolVersion = 0; if (doc["EffekseerProject"]["ToolVersion"] != null) { var fileVersion = doc["EffekseerProject"]["ToolVersion"].GetText(); var currentVersion = Core.Version; toolVersion = ParseVersion(fileVersion); if (toolVersion > ParseVersion(currentVersion)) { throw new Exception("Version Error : \nファイルがより新しいバージョンのツールで作成されています。\n最新バージョンのツールを使用してください。"); } } // 互換性のための変換 { // Stripe→Ribbon var innerText = doc.InnerXml; innerText = innerText.Replace("<Stripe>", "<Ribbon>").Replace("</Stripe>", "</Ribbon>"); doc = new System.Xml.XmlDocument(); doc.LoadXml(innerText); } // 互換性のための変換 { // GenerationTime // GenerationTimeOffset Action<System.Xml.XmlNode> replace = null; replace = (node) => { if ((node.Name == "GenerationTime" || node.Name == "GenerationTimeOffset") && node.ChildNodes.Count > 0 && node.ChildNodes[0] is System.Xml.XmlText) { var name = node.Name; var value = node.ChildNodes[0].Value; node.RemoveAll(); var center = doc.CreateElement("Center"); var max = doc.CreateElement("Max"); var min = doc.CreateElement("Min"); center.AppendChild(doc.CreateTextNode(value)); max.AppendChild(doc.CreateTextNode(value)); min.AppendChild(doc.CreateTextNode(value)); node.AppendChild(center); node.AppendChild(max); node.AppendChild(min); } else { for(int i = 0; i < node.ChildNodes.Count; i++) { replace(node.ChildNodes[i]); } } }; replace(doc); } var root = doc["EffekseerProject"]["Root"]; if (root == null) return false; var behaviorElement = doc["EffekseerProject"]["Behavior"]; if (behaviorElement != null) { var o = effectBehavior as object; Data.IO.LoadObjectFromElement(behaviorElement as System.Xml.XmlElement, ref o, false); } var cullingElement = doc["EffekseerProject"]["Culling"]; if (cullingElement != null) { var o = culling as object; Data.IO.LoadObjectFromElement(cullingElement as System.Xml.XmlElement, ref o, false); } StartFrame = 0; EndFrame = doc["EffekseerProject"]["EndFrame"].GetTextAsInt(); StartFrame = doc["EffekseerProject"]["StartFrame"].GetTextAsInt(); IsLoop = bool.Parse(doc["EffekseerProject"]["IsLoop"].GetText()); IsLoop = true; int version = 0; if (doc["EffekseerProject"]["Version"] != null) { version = doc["EffekseerProject"]["Version"].GetTextAsInt(); } var root_node = new Data.NodeRoot() as object; Data.IO.LoadObjectFromElement(root as System.Xml.XmlElement, ref root_node, false); // 互換性のための変換(テクスチャ周り) if (version < 3) { Action<Data.NodeBase> convert = null; convert = (n) => { var n_ = n as Data.Node; if (n_ != null) { if (n_.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Sprite) { n_.RendererCommonValues.ColorTexture.SetAbsolutePathDirectly(n_.DrawingValues.Sprite.ColorTexture.AbsolutePath); n_.RendererCommonValues.AlphaBlend.SetValueDirectly(n_.DrawingValues.Sprite.AlphaBlend.Value); } else if (n_.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Ring) { n_.RendererCommonValues.ColorTexture.SetAbsolutePathDirectly(n_.DrawingValues.Ring.ColorTexture.AbsolutePath); n_.RendererCommonValues.AlphaBlend.SetValueDirectly(n_.DrawingValues.Ring.AlphaBlend.Value); } else if (n_.DrawingValues.Type.Value == Data.RendererValues.ParamaterType.Ribbon) { n_.RendererCommonValues.ColorTexture.SetAbsolutePathDirectly(n_.DrawingValues.Ribbon.ColorTexture.AbsolutePath); n_.RendererCommonValues.AlphaBlend.SetValueDirectly(n_.DrawingValues.Ribbon.AlphaBlend.Value); } } for (int i = 0; i < n.Children.Count; i++) { convert(n.Children[i]); } }; convert(root_node as Data.NodeBase); } Root = root_node as Data.NodeRoot; Command.CommandManager.Clear(); IsChanged = false; if (OnAfterLoad != null) { OnAfterLoad(null, null); } return true; }