Ejemplo n.º 1
0
        public void FormClosing()
        {
            if (searchForm != null)
            {
                searchForm.OnControlClosing();
                searchForm.Dispose();
            }

            foreach (var control in stPanel2.Controls)
            {
                if (control is STUserControl)
                {
                    ((STUserControl)control).OnControlClosing();
                }
            }

            foreach (var node in TreeViewExtensions.Collect(treeViewCustom1.Nodes))
            {
                if (node is ArchiveRootNodeWrapper)
                {
                    var file = ((ArchiveRootNodeWrapper)node).ArchiveFile;
                    ((IFileFormat)file).Unload();
                }
                else if (node is IFileFormat)
                {
                    ((IFileFormat)node).Unload();
                }
            }
            ClearNodes();
        }
        private List <STGenericTexture> GetTextures(IFileFormat Format)
        {
            var Textures = new List <STGenericTexture>();

            if (Format is STGenericTexture)
            {
                Textures.Add((STGenericTexture)Format);
            }

            if (Format is TreeNodeFile)
            {
                foreach (var node in TreeViewExtensions.Collect(((TreeNodeFile)Format).Nodes))
                {
                    if (node is STGenericTexture)
                    {
                        Textures.Add((STGenericTexture)node);
                    }
                    else if (node is IFileFormat)
                    {
                        GetTextures((IFileFormat)node);
                    }
                }
            }

            return(Textures);
        }
Ejemplo n.º 3
0
        private void ObjectEditor_FormClosed(object sender, FormClosedEventArgs e)
        {
            Viewport viewport = LibraryGUI.Instance.GetActiveViewport();

            if (viewport != null)
            {
                viewport.FormClosing();
            }

            foreach (var control in stPanel2.Controls)
            {
                if (control is STUserControl)
                {
                    ((STUserControl)control).OnControlClosing();
                }
            }

            foreach (var node in TreeViewExtensions.Collect(treeViewCustom1.Nodes))
            {
                if (node is IFileFormat)
                {
                    ((IFileFormat)node).Unload();
                }
            }
            treeViewCustom1.Nodes.Clear();
        }
 public void FormClosing()
 {
     foreach (var node in TreeViewExtensions.Collect(treeViewCustom1.Nodes))
     {
         if (node is IFileFormat)
         {
             ((IFileFormat)node).Unload();
         }
     }
     ClearNodes();
 }
Ejemplo n.º 5
0
        public void LoadImages(TreeView treeView, TreeNode parentNode)
        {
            foreach (TreeNode nodes in TreeViewExtensions.Collect(parentNode.Nodes))
            {
                if (nodes is EditableEntry)
                {
                    if (((EditableEntry)nodes).entry.ParamType == ParamType.Color4F)
                    {
                        nodes.ImageIndex        += treeView.ImageList.Images.Count;
                        nodes.SelectedImageIndex = nodes.ImageIndex;
                    }
                }
            }

            foreach (var image in Images)
            {
                treeView.ImageList.Images.Add(image);
            }
        }
        public void FormClosing()
        {
            foreach (var control in stPanel2.Controls)
            {
                if (control is STUserControl)
                {
                    ((STUserControl)control).OnControlClosing();
                }
            }

            foreach (var node in TreeViewExtensions.Collect(treeViewCustom1.Nodes))
            {
                if (node is IFileFormat)
                {
                    ((IFileFormat)node).Unload();
                }
            }
            ClearNodes();
        }
Ejemplo n.º 7
0
            private void MapTextureIDs(PTCL ptcl)
            {
                List <TextureDescriptor> texDescp = new List <TextureDescriptor>();
                List <Emitter>           emitters = new List <Emitter>();
                BNTX        bntx    = null;
                List <TEXR> botwTex = new List <TEXR>(); //Used for BOTW

                foreach (var node in TreeViewExtensions.Collect(ptcl.Nodes))
                {
                    if (node is TextureDescriptor)
                    {
                        texDescp.Add((TextureDescriptor)node);
                    }
                    if (node is SectionBase && ((SectionBase)node).BinaryData is Emitter)
                    {
                        emitters.Add((Emitter)((SectionBase)node).BinaryData);
                    }
                    if (node is BNTX)
                    {
                        bntx = (BNTX)node;
                    }
                    if (node is SectionBase && ((SectionBase)node).BinaryData is TEXR)
                    {
                        botwTex.Add((TEXR)((SectionBase)node).BinaryData);
                    }
                }

                int index = 0;

                if (botwTex.Count > 0)
                {
                    TreeNode textureFolder = new TreeNode("Textures");
                    ptcl.Nodes.Add(textureFolder);

                    List <TEXR> TextureList = new List <TEXR>();

                    foreach (var emitter in emitters)
                    {
                        foreach (TEXR tex in botwTex)
                        {
                            bool HasImage = TextureList.Any(item => item.data == tex.data);
                            if (!HasImage)
                            {
                                tex.Text = "Texture " + index++;
                                textureFolder.Nodes.Add(tex);
                            }
                            TextureList.Add(tex);

                            foreach (var sampler in emitter.Samplers)
                            {
                                if (sampler.TextureID == tex.TextureID)
                                {
                                    emitter.DrawableTex.Add(tex);
                                }
                            }
                        }
                    }
                    TextureList.Clear();
                }


                if (bntx == null)
                {
                    return;
                }

                foreach (var emitter in emitters)
                {
                    foreach (var tex in texDescp)
                    {
                        foreach (var sampler in emitter.Samplers)
                        {
                            if (sampler.TextureID == tex.TextureID)
                            {
                                if (bntx.Textures.ContainsKey(tex.TexName))
                                {
                                    emitter.DrawableTex.Add(bntx.Textures[tex.TexName]);
                                }
                            }
                        }
                    }
                }
            }
Ejemplo n.º 8
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!DisplayKeys)
            {
                base.OnPaint(e);
                return;
            }

            e.Graphics.FillRectangle(brush3, new Rectangle(0, 0, margin, Height));

            e.Graphics.SetClip(new Rectangle(0, barHeight, Width, Height - barHeight));

            bool v = false;
            int  y = -scrollY - 10;

            trackCount = 0;

            if (ActiveAnimation != null)
            {
                foreach (var node in TreeViewExtensions.Collect(NodeTree.Nodes))
                {
                    if (node.Parent != null && node.Tag is STAnimationTrack && node.Parent.IsVisible && node.Parent.IsExpanded)
                    {
                        var track = node.Tag as STAnimationTrack;
                        if (!track.HasKeys)
                        {
                            continue;
                        }

                        for (int i = 1; i < track.KeyFrames.Count; i++)
                        {
                            int l = Math.Max(-20, (int)((
                                                            track.KeyFrames[i - 1].Frame
                                                            - frameLeft) * (Width - 40 - margin) / (frameRight - frameLeft)));
                            int r = (int)((
                                              track.KeyFrames[i].Frame
                                              - frameLeft) * (Width - 40 - margin) / (frameRight - frameLeft));

                            if (v = !v)
                            {
                                var keyColor = new SolidBrush(Color.Yellow);
                                switch (node.ImageKey)
                                {
                                case "AnimationTrackR":
                                case "AnimationTrackX":
                                    keyColor = new SolidBrush(Color.Red);
                                    break;

                                case "AnimationTrackG":
                                case "AnimationTrackY":
                                    keyColor = new SolidBrush(Color.Green);
                                    break;

                                case "AnimationTrackB":
                                case "AnimationTrackZ":
                                    keyColor = new SolidBrush(Color.Blue);
                                    break;

                                case "AnimationTrackA":
                                case "AnimationTrackW":
                                    keyColor = new SolidBrush(Color.Gray);
                                    break;
                                }

                                if (node.IsSelected)
                                {
                                    keyColor = new SolidBrush(Color.White);
                                }

                                e.Graphics.FillEllipse(keyColor, new Rectangle(l + margin + 20, barHeight + y, 5, lineHeight));
                            }
                        }
                    }

                    if (node.IsVisible)
                    {
                        y += NodeTree.ItemHeight;
                    }
                }
            }

            base.OnPaint(e);
        }