Beispiel #1
0
        public BRRESNode NewBrres()
        {
            BRRESNode   node = ((U8FolderNode)_resource).CreateResource <BRRESNode>("NewBrres");
            BaseWrapper res  = this.FindResource(node, true);

            res = res.FindResource(node, false);
            res.EnsureVisible();
            res.TreeView.SelectedNode = res;
            return(node);
        }
Beispiel #2
0
        public void NewClr()
        {
            CLR0Node node = ((BRRESNode)_resource).CreateResource <CLR0Node>("NewCLR");

            node.Version = 3;
            BaseWrapper res = this.FindResource(node, true);

            res = res.FindResource(node, false);
            res.EnsureVisible();
            res.TreeView.SelectedNode = res;
        }
Beispiel #3
0
        public void NewMaterial()
        {
            if (_modelViewerOpen)
            {
                return;
            }

            MDL0Node model = ((MDL0Node)_resource);

            if (model._matGroup == null)
            {
                MDL0GroupNode g = model._matGroup;
                if (g == null)
                {
                    model.AddChild(g = new MDL0GroupNode(MDLResourceType.Materials), true);
                    model._matGroup  = g; model._matList = g.Children;
                }
            }

            MDL0MaterialNode mat = new MDL0MaterialNode();

            model._matGroup.AddChild(mat);
            mat.Name = "Material" + mat.Index;
            mat.New  = true;
            if (model._shadGroup == null)
            {
                MDL0GroupNode g = model._shadGroup;
                if (g == null)
                {
                    model.AddChild(g = new MDL0GroupNode(MDLResourceType.Shaders), true);
                    model._shadGroup = g; model._shadList = g.Children;
                }
            }
            if (model._shadList.Count == 0)
            {
                NewShader();
            }

            mat.ShaderNode = (MDL0ShaderNode)model._shadList[0];
            mat.AddChild(new MDL0MaterialRefNode()
            {
                Name = "MatRef0"
            });
            mat.Rebuild(true);

            BaseWrapper b = FindResource(mat, true);

            if (b != null)
            {
                b.EnsureVisible();
            }
        }
Beispiel #4
0
        private void NewCLR()
        {
            CLR0MaterialEntryNode n = ((CLR0Node)this._resource).CreateEntry();

            if (n != null)
            {
                BaseWrapper b = FindResource(n, true);
                if (b != null)
                {
                    b.EnsureVisible();
                }
            }
        }
Beispiel #5
0
        public void ImportBrres()
        {
            string path;

            if (Program.OpenFile(FileFilters.BRES, out path) > 0)
            {
                BRRESNode node = NodeFactory.FromFile(null, path) as BRRESNode;
                ((U8FolderNode)_resource).AddChild(node);

                BaseWrapper w = this.FindResource(node, true);
                w.EnsureVisible();
                w.TreeView.SelectedNode = w;
            }
        }
Beispiel #6
0
        public void ImportClr()
        {
            string path;

            if (Program.OpenFile(FileFilters.CLR0, out path) > 0)
            {
                CLR0Node node = NodeFactory.FromFile(null, path) as CLR0Node;
                ((BRRESNode)_resource).GetOrCreateFolder <CLR0Node>().AddChild(node);

                BaseWrapper w = this.FindResource(node, true);
                w.EnsureVisible();
                w.TreeView.SelectedNode = w;
            }
        }
Beispiel #7
0
        public void ImportChr()
        {
            string path;

            if (Program.OpenFile(FileFilters.CHR0Import, out path) > 0)
            {
                CHR0Node node = CHR0Node.FromFile(path);
                ((BRRESNode)_resource).GetOrCreateFolder <CHR0Node>().AddChild(node);

                BaseWrapper w = this.FindResource(node, true);
                w.EnsureVisible();
                w.TreeView.SelectedNode = w;
            }
        }
Beispiel #8
0
        public MSBinNode NewMSBin()
        {
            MSBinNode node = new MSBinNode()
            {
                FileType = ARCFileType.MiscData
            };

            _resource.AddChild(node);

            BaseWrapper w = this.FindResource(node, false);

            w.EnsureVisible();
            w.TreeView.SelectedNode = w;
            return(node);
        }
Beispiel #9
0
        public ARCNode NewARC()
        {
            ARCNode node = new ARCNode()
            {
                Name = _resource.FindName("NewARChive"), FileType = ARCFileType.MiscData
            };

            _resource.AddChild(node);

            BaseWrapper w = this.FindResource(node, false);

            w.EnsureVisible();
            w.TreeView.SelectedNode = w;
            return(node);
        }
Beispiel #10
0
        public U8FolderNode NewFolder()
        {
            U8FolderNode node = new U8FolderNode()
            {
                Name = _resource.FindName("NewFolder")
            };

            _resource.AddChild(node);

            BaseWrapper w = this.FindResource(node, false);

            w.EnsureVisible();
            w.TreeView.SelectedNode = w;
            return(node);
        }
        public void ImportTexture()
        {
            string path;
            int    index = Program.OpenFile(FileFilters.Images, out path);

            if (index > 0)
            {
                using (TextureConverterDialog dlg = new TextureConverterDialog())
                {
                    dlg.ImageSource = path;
                    if (dlg.ShowDialog(MainForm.Instance, ResourceNode as REFTNode) == DialogResult.OK)
                    {
                        BaseWrapper w = this.FindResource(dlg.REFTTextureNode, true);
                        w.EnsureVisible();
                        w.TreeView.SelectedNode = w;
                    }
                }
            }
        }
Beispiel #12
0
        public void ImportU8()
        {
            string path;

            if (Program.OpenFile("U8 Archive (*.arc)|*.arc|" +
                                 "Compressed U8 Archive (*.szs)|*.szs|" +
                                 "Archive Pair (*.pair)|*.pair", out path) > 0)
            {
                U8Node       node = NodeFactory.FromFile(null, path) as U8Node;
                U8FolderNode n    = new U8FolderNode();
                foreach (ResourceNode r in node.Children)
                {
                    n.AddChild(r);
                }
                n.Name = node.Name;
                ((U8FolderNode)_resource).AddChild(n);

                BaseWrapper w = this.FindResource(n, true);
                w.EnsureVisible();
                w.TreeView.SelectedNode = w;
            }
        }
Beispiel #13
0
        public void NewEntry()
        {
            REFFEntryNode e = new REFFEntryNode();

            REFFNode     node = _resource as REFFNode;
            ResourceNode emitter;

            if (node.VersionMinor == 9)
            {
                e.AddChild(emitter = new REFFEmitterNode9()
                {
                    _name = "Emitter"
                });
            }
            else
            {
                e.AddChild(emitter = new REFFEmitterNode7()
                {
                    _name = "Emitter"
                });
            }
            emitter.AddChild(new REFFTEVStage(0));
            emitter.AddChild(new REFFTEVStage(1));
            emitter.AddChild(new REFFTEVStage(2));
            emitter.AddChild(new REFFTEVStage(3));
            e.AddChild(new REFFParticleNode()
            {
                _name = "Particle"
            });
            e.AddChild(new REFFAnimationListNode()
            {
                _name = "Animations"
            });
            _resource.AddChild(e);
            BaseWrapper w = this.FindResource(e, true);

            w.EnsureVisible();
            w.TreeView.SelectedNode = w;
        }
Beispiel #14
0
        public void NewShader()
        {
            if (_modelViewerOpen)
            {
                return;
            }

            MDL0Node model = ((MDL0Node)_resource);

            if (model._shadGroup == null)
            {
                MDL0GroupNode g = model._shadGroup;
                if (g == null)
                {
                    model.AddChild(g = new MDL0GroupNode(MDLResourceType.Shaders), true);
                    model._shadGroup = g; model._shadList = g.Children;
                }
            }

            if (model._shadList != null && model._matList != null)
            {
                if (model._shadList.Count < model._matList.Count)
                {
                    MDL0ShaderNode shader = new MDL0ShaderNode();
                    model._shadGroup.AddChild(shader);
                    shader.Default();
                    shader.Rebuild(true);

                    BaseWrapper b = FindResource(shader, true);
                    if (b != null)
                    {
                        b.EnsureVisible();
                    }
                }
            }
        }
        public void Link(ResourceNode res)
        {
            Unlink();
            if (res != null)
            {
                this.Text = res.Name;
                TreeNodeCollection nodes = Nodes;

                //Should we continue down the tree?
                if ((IsExpanded) && (res.HasChildren))
                {
                    //Add/link each resource node
                    foreach (ResourceNode n in res.Children)
                    {
                        bool found = false;
                        foreach (BaseWrapper tn in nodes)
                        {
                            if (tn.Text == n.Name)
                            {
                                tn.Link(n);
                                found = true;
                                // Move node to bottom, to ensure that nodes are shown and saved in the same order as in the original data
                                nodes.Remove(tn);
                                nodes.Add(tn);
                                break;
                            }
                        }

                        if (!found)
                        {
                            nodes.Add(Wrap(_owner, n));
                        }
                    }

                    //Remove empty nodes
                    for (int i = 0; i < nodes.Count;)
                    {
                        BaseWrapper n = nodes[i] as BaseWrapper;
                        if (n._resource == null)
                        {
                            n.Remove();
                        }
                        else
                        {
                            i++;
                        }
                    }

                    _discovered = true;
                }
                else
                {
                    //Node will be reset and undiscovered
                    nodes.Clear();
                    //Collapse();
                    if (res.HasChildren)
                    {
                        nodes.Add(new GenericWrapper());
                        _discovered = false;
                    }
                    else
                    {
                        _discovered = true;
                    }
                }

                SelectedImageIndex = ImageIndex = (int)res.ResourceType & 0xFF;

                res.SelectChild     += OnSelectChild;
                res.ChildAdded      += OnChildAdded;
                res.ChildRemoved    += OnChildRemoved;
                res.ChildInserted   += OnChildInserted;
                res.Replaced        += OnReplaced;
                res.Restored        += OnRestored;
                res.Renamed         += OnRenamed;
                res.MovedUp         += OnMovedUp;
                res.MovedDown       += OnMovedDown;
                res.PropertyChanged += OnPropertyChanged;
                res.UpdateProps     += OnUpdateProperties;
                res.UpdateControl   += OnUpdateCurrentControl;
            }
            _resource = res;
        }