Exemplo n.º 1
0
        public static bool MoveNode(Data.Node movedNode, Data.NodeBase targetParent, int targetIndex)
        {
            // Check
            if (movedNode.Parent == targetParent && targetIndex != int.MaxValue)
            {
                var index = targetParent.Children.Internal.Select((i, n) => Tuple35.Create(i, n)).FirstOrDefault(_ => _.Item1 == movedNode).Item2;

                // Not changed.
                if (index == targetIndex || index + 1 == targetIndex)
                {
                    return(false);
                }
            }

            if (movedNode == targetParent)
            {
                return(false);
            }

            Func <Data.Node, bool> isFound = null;

            isFound = (Data.Node n) =>
            {
                if (n.Children.Internal.Any(_ => _ == targetParent))
                {
                    return(true);
                }

                foreach (var n_ in n.Children.Internal)
                {
                    if (isFound(n_))
                    {
                        return(true);
                    }
                }

                return(false);
            };

            if (isFound(movedNode))
            {
                return(false);
            }

            //
            if (targetParent == movedNode.Parent && targetIndex != int.MaxValue)
            {
                var index = targetParent.Children.Internal.Select((i, n) => Tuple35.Create(i, n)).FirstOrDefault(_ => _.Item1 == movedNode).Item2;
                if (index < targetIndex)
                {
                    targetIndex -= 1;
                }
            }

            Command.CommandManager.StartCollection();
            movedNode.Parent.RemoveChild(movedNode);
            targetParent.AddChild(movedNode, targetIndex);
            Command.CommandManager.EndCollection();
            return(true);
        }
Exemplo n.º 2
0
        /// <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);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 internal NodeBase(NodeBase parent)
 {
     Parent = parent;
     Name = new Value.String();
     IsRendered = new Value.Boolean(true);
     Children = new ChildrenCollection(this);
 }
Exemplo n.º 4
0
        /// <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);
            }
        }
Exemplo n.º 5
0
 public static bool MoveNode(Data.Node movedNode, Data.NodeBase targetParent, int targetIndex)
 {
     Command.CommandManager.StartCollection();
     movedNode.Parent.RemoveChild(movedNode);
     targetParent.AddChild(movedNode, targetIndex);
     Command.CommandManager.EndCollection();
     return(true);
 }
Exemplo n.º 6
0
        public static void LoadFromElement(XmlElement e, NodeBase.ChildrenCollection children, bool isClip)
        {
            children.Node.ClearChildren();

            for (var i = 0; i < e.ChildNodes.Count; i++)
            {
                var e_child = e.ChildNodes[i] as XmlElement;
                if (e_child.LocalName != "Node") continue;

                var node = children.Node.AddChild();
                LoadFromElement(e_child, node, isClip);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 internal Node(NodeBase parent)
     : base(parent)
 {
     Name.SetValueDirectly("Node");
     CommonValues = new Data.CommonValues();
     LocationValues = new Data.LocationValues();
     RotationValues = new Data.RotationValues();
     ScalingValues = new Data.ScaleValues();
     LocationAbsValues = new Data.LocationAbsValues();
     GenerationLocationValues = new Data.GenerationLocationValues();
     RendererCommonValues = new Data.RendererCommonValues();
     DrawingValues = new RendererValues();
     SoundValues = new SoundValues();
 }
Exemplo n.º 8
0
        public static string Copy(Data.NodeBase node)
        {
            if (node == null)
            {
                return(string.Empty);
            }

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var element = Data.IO.SaveObjectToElement(doc, "CopiedNode", node, true);

            doc.AppendChild(element);

            return(doc.InnerXml);
        }
Exemplo n.º 9
0
        public static void Paste(Data.NodeBase node, string data)
        {
            if (node == null)
            {
                return;
            }

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            doc.LoadXml(data);

            if (doc.ChildNodes.Count == 0 || doc.ChildNodes[0].Name != "CopiedNode")
            {
                return;
            }

            Command.CommandManager.StartCollection();
            Data.IO.LoadFromElement(doc.ChildNodes[0] as System.Xml.XmlElement, node, true);
            Command.CommandManager.EndCollection();
        }
Exemplo n.º 10
0
        /// <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);
            }
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
 public static XmlElement SaveToElement(XmlDocument doc, string element_name, NodeBase node, bool isClip)
 {
     return SaveObjectToElement(doc, element_name, node, isClip);
 }
Exemplo n.º 13
0
        public static XmlElement SaveToElement(XmlDocument doc, string element_name, NodeBase.ChildrenCollection children, bool isClip)
        {
            var e = doc.CreateElement(element_name);
            for (int i = 0; i < children.Count; i++)
            {
                var e_node = SaveToElement(doc, children[i].GetType().Name, children[i], isClip);
                e.AppendChild(e_node);
            }

            return e;
        }
Exemplo n.º 14
0
 internal ChildrenCollection(NodeBase node)
 {
     _node = node;
 }
Exemplo n.º 15
0
 internal ChildrenCollection(NodeBase node)
 {
     _node = node;
 }
Exemplo n.º 16
0
        /// <summary>
        /// ノードを子として保有しているか取得
        /// </summary>
        /// <param name="node">ノード</param>
        /// <param name="recursion">再帰的に検索するか</param>
        /// <returns></returns>
        public bool HasNode(NodeBase node, bool recursion)
        {
            for (int i = 0; i < Children.Count; i++)
            {
                if (Children[i] == node) return true;

                if (recursion)
                {
                    if (Children[i].HasNode(node, true)) return true;
                }
            }

            return false;
        }
Exemplo n.º 17
0
 public static XmlElement SaveToElement(XmlDocument doc, string element_name, NodeBase node, bool isClip)
 {
     return(SaveObjectToElement(doc, element_name, node, isClip));
 }
Exemplo n.º 18
0
        public static void LoadFromElement(XmlElement e, NodeBase node, bool isClip)
        {
            var o = node as object;

            LoadObjectFromElement(e, ref o, isClip);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
 public static void LoadFromElement(XmlElement e, NodeBase node, bool isClip)
 {
     var o = node as object;
     LoadObjectFromElement(e, ref o, isClip);
 }