Пример #1
0
 public void SetScenarioHasChanged(YmtFile scenario, bool changed)
 {
     if (ProjectTreeView.Nodes.Count > 0)
     {
         var pnode  = ProjectTreeView.Nodes[0];
         var scnode = GetChildTreeNode(pnode, "Scenarios");
         if (scnode == null)
         {
             return;
         }
         string changestr = changed ? "*" : "";
         for (int i = 0; i < scnode.Nodes.Count; i++)
         {
             var snode = scnode.Nodes[i];
             if (snode.Tag == scenario)
             {
                 string name = scenario.Name;
                 if (scenario.RpfFileEntry != null)
                 {
                     name = scenario.RpfFileEntry.Name;
                 }
                 snode.Text = changestr + name;
                 break;
             }
         }
     }
 }
Пример #2
0
        public void LoadMeta(YmtFile ymt)
        {
            string fn;

            Xml      = MetaXml.GetXml(ymt, out fn);
            FileName = fn;
            RawPropertyGrid.SelectedObject = ymt;
            rpfFileEntry = ymt?.RpfFileEntry;
            modified     = false;
            metaFormat   = MetaFormat.XML;
            if (ymt != null)
            {
                if (ymt.Meta != null)
                {
                    metaFormat = MetaFormat.RSC;
                }
                if (ymt.Pso != null)
                {
                    metaFormat = MetaFormat.PSO;
                }
                if (ymt.Rbf != null)
                {
                    metaFormat = MetaFormat.RBF;
                }
            }
        }
Пример #3
0
 public void SetScenarioYmt(YmtFile scenario)
 {
     CurrentScenario = scenario;
     Tag             = scenario;
     UpdateFormTitle();
     UpdateScenarioUI();
     waschanged = scenario?.HasChanged ?? false;
 }
Пример #4
0
        public void TrySelectScenarioTreeNode(YmtFile scenario)
        {
            TreeNode tnode = FindScenarioTreeNode(scenario);

            if (tnode != null)
            {
                ProjectTreeView.SelectedNode = tnode;
            }
        }
Пример #5
0
        public void LoadMeta(YmtFile ymt)
        {
            string fn;

            Xml      = MetaXml.GetXml(ymt, out fn);
            FileName = fn;
            RawPropertyGrid.SelectedObject = ymt;
            modified = false;
        }
Пример #6
0
 public bool ContainsScenario(YmtFile ymt)
 {
     foreach (var f in ScenarioFiles)
     {
         if (f == ymt)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #7
0
        public void RemoveScenarioFile(YmtFile ymt)
        {
            if (ymt == null)
            {
                return;
            }
            var relpath = GetRelativePath(ymt.FilePath);

            if (string.IsNullOrEmpty(relpath))
            {
                relpath = ymt.Name;
            }
            ScenarioFiles.Remove(ymt);
            ScenarioFilenames.Remove(relpath);
            HasChanged = true;
        }
Пример #8
0
        public bool AddScenarioFile(YmtFile ymt)
        {
            string relpath = GetRelativePath(ymt.FilePath);

            if (string.IsNullOrEmpty(relpath))
            {
                relpath = ymt.Name;
            }
            if (ScenarioFilenames.Contains(relpath))
            {
                return(false);
            }
            ScenarioFilenames.Add(relpath);
            ScenarioFiles.Add(ymt);
            return(true);
        }
Пример #9
0
        public YmtFile AddScenarioFile(string filename)
        {
            YmtFile scenario = new YmtFile();

            scenario.RpfFileEntry      = new RpfResourceFileEntry();
            scenario.RpfFileEntry.Name = new FileInfo(filename).Name;
            scenario.FilePath          = GetFullFilePath(filename);
            scenario.Name        = scenario.RpfFileEntry.Name;
            scenario.ContentType = YmtFileContentType.ScenarioPointRegion;
            scenario.FileFormat  = YmtFileFormat.RSC;
            if (!AddScenarioFile(scenario))
            {
                return(null);
            }
            return(scenario);
        }
Пример #10
0
        public void LoadMeta(YmtFile ymt)
        {
            var fn = (ymt?.RpfFileEntry?.Name) ?? "";

            if (ymt.Meta != null)
            {
                LoadMeta(ymt.Meta); fn += ".xml";
            }
            else if (ymt.Pso != null)
            {
                LoadMeta(ymt.Pso); fn += ".pso.xml";
            }
            else if (ymt.Rbf != null)
            {
                LoadMeta(ymt.Rbf); fn += ".rbf.xml";
            }
            FileName = fn;
            RawPropertyGrid.SelectedObject = ymt;
        }
Пример #11
0
        public TreeNode FindScenarioTreeNode(YmtFile ymt)
        {
            if (ProjectTreeView.Nodes.Count <= 0)
            {
                return(null);
            }
            var projnode      = ProjectTreeView.Nodes[0];
            var scenariosnode = GetChildTreeNode(projnode, "Scenarios");

            if (scenariosnode == null)
            {
                return(null);
            }
            for (int i = 0; i < scenariosnode.Nodes.Count; i++)
            {
                var ymtnode = scenariosnode.Nodes[i];
                if (ymtnode.Tag == ymt)
                {
                    return(ymtnode);
                }
            }
            return(null);
        }
Пример #12
0
        private void SelectFile(RpfEntry entry, int offset, int length)
        {
            SelectedEntry  = entry;
            SelectedOffset = offset;
            SelectedLength = length;

            RpfFileEntry rfe = entry as RpfFileEntry;

            if (rfe == null)
            {
                RpfDirectoryEntry rde = entry as RpfDirectoryEntry;
                if (rde != null)
                {
                    FileInfoLabel.Text = rde.Path + " (Directory)";
                    DataTextBox.Text   = "[Please select a data file]";
                }
                else
                {
                    FileInfoLabel.Text = "[Nothing selected]";
                    DataTextBox.Text   = "[Please select a data file]";
                }
                ShowTextures(null);
                return;
            }


            Cursor = Cursors.WaitCursor;

            string typestr = "Resource";

            if (rfe is RpfBinaryFileEntry)
            {
                typestr = "Binary";
            }

            byte[] data = rfe.File.ExtractFile(rfe);

            int datalen = (data != null) ? data.Length : 0;

            FileInfoLabel.Text = rfe.Path + " (" + typestr + " file)  -  " + TextUtil.GetBytesReadable(datalen);


            if (ShowLargeFileContentsCheckBox.Checked || (datalen < 524287)) //512K
            {
                DisplayFileContentsText(rfe, data, length, offset);
            }
            else
            {
                DataTextBox.Text = "[Filesize >512KB. Select the Show large files option to view its contents]";
            }



            bool istexdict = false;


            if (rfe.NameLower.EndsWith(".ymap"))
            {
                YmapFile ymap = new YmapFile(rfe);
                ymap.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ymap;
            }
            else if (rfe.NameLower.EndsWith(".ytyp"))
            {
                YtypFile ytyp = new YtypFile();
                ytyp.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ytyp;
            }
            else if (rfe.NameLower.EndsWith(".ymf"))
            {
                YmfFile ymf = new YmfFile();
                ymf.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ymf;
            }
            else if (rfe.NameLower.EndsWith(".ymt"))
            {
                YmtFile ymt = new YmtFile();
                ymt.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ymt;
            }
            else if (rfe.NameLower.EndsWith(".ybn"))
            {
                YbnFile ybn = new YbnFile();
                ybn.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ybn;
            }
            else if (rfe.NameLower.EndsWith(".fxc"))
            {
                FxcFile fxc = new FxcFile();
                fxc.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = fxc;
            }
            else if (rfe.NameLower.EndsWith(".yft"))
            {
                YftFile yft = new YftFile();
                yft.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = yft;

                if ((yft.Fragment != null) && (yft.Fragment.Drawable != null) && (yft.Fragment.Drawable.ShaderGroup != null) && (yft.Fragment.Drawable.ShaderGroup.TextureDictionary != null))
                {
                    ShowTextures(yft.Fragment.Drawable.ShaderGroup.TextureDictionary);
                    istexdict = true;
                }
            }
            else if (rfe.NameLower.EndsWith(".ydr"))
            {
                YdrFile ydr = new YdrFile();
                ydr.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ydr;

                if ((ydr.Drawable != null) && (ydr.Drawable.ShaderGroup != null) && (ydr.Drawable.ShaderGroup.TextureDictionary != null))
                {
                    ShowTextures(ydr.Drawable.ShaderGroup.TextureDictionary);
                    istexdict = true;
                }
            }
            else if (rfe.NameLower.EndsWith(".ydd"))
            {
                YddFile ydd = new YddFile();
                ydd.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ydd;
                //todo: show embedded texdicts in ydd's? is this possible?
            }
            else if (rfe.NameLower.EndsWith(".ytd"))
            {
                YtdFile ytd = new YtdFile();
                ytd.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ytd;
                ShowTextures(ytd.TextureDict);
                istexdict = true;
            }
            else if (rfe.NameLower.EndsWith(".ycd"))
            {
                YcdFile ycd = new YcdFile();
                ycd.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ycd;
            }
            else if (rfe.NameLower.EndsWith(".ynd"))
            {
                YndFile ynd = new YndFile();
                ynd.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ynd;
            }
            else if (rfe.NameLower.EndsWith(".ynv"))
            {
                YnvFile ynv = new YnvFile();
                ynv.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = ynv;
            }
            else if (rfe.NameLower.EndsWith("_cache_y.dat"))
            {
                CacheDatFile cdf = new CacheDatFile();
                cdf.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = cdf;
            }
            else if (rfe.NameLower.EndsWith(".rel"))
            {
                RelFile rel = new RelFile(rfe);
                rel.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = rel;
            }
            else if (rfe.NameLower.EndsWith(".gxt2"))
            {
                Gxt2File gxt2 = new Gxt2File();
                gxt2.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = gxt2;
            }
            else if (rfe.NameLower.EndsWith(".pso"))
            {
                JPsoFile pso = new JPsoFile();
                pso.Load(data, rfe);
                DetailsPropertyGrid.SelectedObject = pso;
            }
            else
            {
                DetailsPropertyGrid.SelectedObject = null;
            }


            if (!istexdict)
            {
                ShowTextures(null);
            }


            Cursor = Cursors.Default;
        }
Пример #13
0
        private void LoadScenarioTreeNodes(YmtFile ymt, TreeNode node)
        {
            if (!string.IsNullOrEmpty(node.Name))
            {
                return;                                   //named nodes are eg Points
            }
            node.Nodes.Clear();

            var region = ymt?.ScenarioRegion;

            if (region == null)
            {
                return;
            }

            var nodes = region.Nodes;

            if ((nodes == null) || (nodes.Count == 0))
            {
                return;
            }

            var pointsnode = node.Nodes.Add("Points (" + nodes.Count.ToString() + ")");

            pointsnode.Name = "Points";
            pointsnode.Tag  = ymt;
            for (int i = 0; i < nodes.Count; i++)
            {
                var snode = nodes[i];
                var tnode = pointsnode.Nodes.Add(snode.MedTypeName + ": " + snode.StringText);
                tnode.Tag = snode;
            }

            //var sr = region.Region;
            //if (sr == null) return;
            //int pointCount = (sr.Points?.LoadSavePoints?.Length ?? 0) + (sr.Points?.MyPoints?.Length ?? 0);
            //int entityOverrideCount = (sr.EntityOverrides?.Length ?? 0);
            //int chainCount = (sr.Paths?.Chains?.Length ?? 0);
            //int clusterCount = (sr.Clusters?.Length ?? 0);
            //TreeNode pointsNode = null;
            //TreeNode entityOverridesNode = null;
            //TreeNode chainsNode = null;
            //TreeNode clustersNode = null;
            //if (pointCount > 0)
            //{
            //    pointsNode = node.Nodes.Add("Points (" + pointCount.ToString() + ")");
            //}
            //if (entityOverrideCount > 0)
            //{
            //    entityOverridesNode = node.Nodes.Add("Entity Overrides (" + entityOverrideCount.ToString() + ")");
            //}
            //if (chainCount > 0)
            //{
            //    chainsNode = node.Nodes.Add("Chains (" + chainsNode.ToString() + ")");
            //}
            //if (clusterCount > 0)
            //{
            //    clustersNode = node.Nodes.Add("Clusters (" + clusterCount.ToString() + ")");
            //}
            //for (int i = 0; i < nodes.Count; i++)
            //{
            //    var snode = nodes[i];
            //    if (snode == null) continue;
            //    if ((pointsNode != null) && ((snode.LoadSavePoint != null) || (snode.MyPoint != null)))
            //    {
            //        pointsNode.Nodes.Add(snode.ToString()).Tag = snode;
            //    }
            //    if ((entityOverridesNode != null) && ((snode.EntityOverride != null) || (snode.EntityPoint != null)))
            //    {
            //        entityOverridesNode.Nodes.Add(snode.ToString()).Tag = snode;
            //    }
            //    if ((chainsNode != null) && (snode.ChainingNode != null))
            //    {
            //        chainsNode.Nodes.Add(snode.ToString()).Tag = snode;
            //    }
            //    if ((clustersNode != null) && ((snode.Cluster != null) || (snode.ClusterLoadSavePoint != null) || (snode.ClusterMyPoint != null)))
            //    {
            //        clustersNode.Nodes.Add(snode.ToString()).Tag = snode;
            //    }
            //}
        }