Example #1
0
        public static void ReplaceNode(TreeNode node, TreeView treeview, ArchiveFileWrapper replaceNode, TreeNode NewNode, ArchiveRootNodeWrapper rootNode)
        {
            if (NewNode == null)
            {
                return;
            }

            var fileInfo = replaceNode.ArchiveFileInfo;

            int index = 0;

            if (node == null)
            {
                index = treeview.Nodes.IndexOf(replaceNode);
                treeview.Nodes.RemoveAt(index);
                treeview.Nodes.Insert(index, NewNode);
            }
            else
            {
                index = node.Nodes.IndexOf(replaceNode);
                node.Nodes.RemoveAt(index);
                node.Nodes.Insert(index, NewNode);
            }

            NewNode.ImageKey         = replaceNode.ImageKey;
            NewNode.SelectedImageKey = replaceNode.SelectedImageKey;
            NewNode.Text             = replaceNode.Text;
            NewNode.Tag = fileInfo;

            rootNode.FileNodes.RemoveAt(index);
            rootNode.FileNodes.Insert(index, Tuple.Create(fileInfo, NewNode));

            if (NewNode is ISingleTextureIconLoader)
            {
                ObjectEditor editor = LibraryGUI.GetObjectEditor();
                if (editor != null) //The editor isn't always in object editor so check
                {
                    editor.UpdateTextureIcon((ISingleTextureIconLoader)NewNode);
                }
            }
        }
Example #2
0
        public void ResetModels()
        {
            var viewport = LibraryGUI.GetActiveViewport();

            if (viewport == null)
            {
                return;
            }
            if (viewport.scene == null)
            {
                return;
            }

            foreach (var drawable in viewport.scene.objects)
            {
                if (drawable is STSkeleton)
                {
                    ((STSkeleton)drawable).reset();
                }
            }
        }
Example #3
0
        private void SetAnimationsToFrame(float frameNum)
        {
            if (currentAnimation == null && stCurrentAnimation == null)
            {
                return;
            }

            var viewport = LibraryGUI.GetActiveViewport();

            if (viewport == null || viewport.scene == null)
            {
                return;
            }

            if (stCurrentAnimation != null)
            {
                Console.WriteLine("SetAnimationsToFrame");

                if (frameNum > stCurrentAnimation.FrameCount)
                {
                    return;
                }

                float animFrameNum = frameNum;

                stCurrentAnimation.SetFrame(animFrameNum);
                stCurrentAnimation.NextFrame();

                //Add frames to the playing animation
                stCurrentAnimation.Frame += frameNum;

                //Reset it when it reaches the total frame count
                if (stCurrentAnimation.Frame >= stCurrentAnimation.FrameCount && stCurrentAnimation.Loop)
                {
                    stCurrentAnimation.Frame = 0;
                }
            }
            else
            {
                var anim = currentAnimation.Tag;

                float animFrameNum = frameNum;

                if (anim is MaterialAnimation)
                {
                    ((MaterialAnimation)anim).SetFrame(animFrameNum);
                    ((MaterialAnimation)anim).NextFrame(viewport);
                }
                else if (anim is VisibilityAnimation)
                {
                    ((VisibilityAnimation)anim).SetFrame(animFrameNum);
                    ((VisibilityAnimation)anim).NextFrame(viewport);
                }
                else if (anim is CameraAnimation)
                {
                    ((CameraAnimation)anim).SetFrame(animFrameNum);
                    ((CameraAnimation)anim).NextFrame(viewport);
                }
                else if (anim is LightAnimation)
                {
                    ((LightAnimation)anim).SetFrame(animFrameNum);
                    ((LightAnimation)anim).NextFrame(viewport);
                }
                else if (anim is FogAnimation)
                {
                    ((FogAnimation)anim).SetFrame(animFrameNum);
                    ((FogAnimation)anim).NextFrame(viewport);
                }
                else //Play a skeletal animation if it's not the other types
                {
                    foreach (var drawable in viewport.scene.objects)
                    {
                        if (drawable is STSkeleton)
                        {
                            currentAnimation.SetFrame(animFrameNum);
                            currentAnimation.NextFrame((STSkeleton)drawable);
                        }
                    }
                }


                //Add frames to the playing animation
                currentAnimation.Frame += frameNum;

                //Reset it when it reaches the total frame count
                if (currentAnimation.Frame >= currentAnimation.FrameCount)
                {
                    currentAnimation.Frame = 0;
                }
            }
        }
Example #4
0
        private void selectItem(object sender, TreeNodeMouseClickEventArgs e)
        {
            Viewport viewport = LibraryGUI.GetActiveViewport();

            if (viewport == null)
            {
                return;
            }

            if (e.Node is Animation)
            {
                string AnimName = e.Node.Text;
                AnimName = Regex.Match(AnimName, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString();
                if (AnimName.Length > 3)
                {
                    AnimName = AnimName.Substring(3);
                }

                Console.WriteLine("AnimName " + AnimName);

                Animation running = new Animation(AnimName);
                running.ReplaceMe((Animation)e.Node);
                running.Tag = e.Node;

                Queue <TreeNode> NodeQueue = new Queue <TreeNode>();
                foreach (TreeNode n in treeView1.Nodes)
                {
                    NodeQueue.Enqueue(n);
                }
                while (NodeQueue.Count > 0)
                {
                    try
                    {
                        TreeNode n        = NodeQueue.Dequeue();
                        string   NodeName = Regex.Match(n.Text, @"([A-Z][0-9][0-9])(.*)").Groups[0].ToString();
                        if (NodeName.Length <= 3)
                        {
                            Console.WriteLine(NodeName);
                        }
                        else
                        {
                            NodeName = NodeName.Substring(3);
                        }
                        if (n is Animation)
                        {
                            if (n == e.Node)
                            {
                                continue;
                            }
                            if (NodeName.Equals(AnimName))
                            {
                                running.Children.Add(n);
                            }
                        }
                        if (n is AnimationGroupNode)
                        {
                            foreach (TreeNode tn in n.Nodes)
                            {
                                NodeQueue.Enqueue(tn);
                            }
                        }
                    }
                    catch
                    {
                    }
                }

                if (LibraryGUI.GetAnimationPanel() != null)
                {
                    Console.WriteLine("running" + running.Text);
                    LibraryGUI.GetAnimationPanel().CurrentAnimation = running;
                }
            }
        }