Esempio n. 1
0
 private void HandleSubentryNode(EntryTreeNode node)
 {
     if (node.ResourceType == ResourceType.MESH) // meshes/models
     {
         if (node.Game == Game.ODYSSEY)
         {
             // to be implemented
         }
         else if (node.Game == Game.ORIGINS)
         {
             /*Origins.Submesh[] submeshes = Origins.ExtractModel(Helpers.GetTempPath(node.Path), node, () =>
              * {
              *  Console.WriteLine("EXTRACTED MODEL");
              * });
              * foreach (Origins.Submesh submesh in submeshes)
              * {
              *  gl.Meshes.Add(new DynamicMesh(submesh));
              * }*/
         }
         else if (node.Game == Game.STEEP)
         {
             // to be implemented
         }
     }
     else if (node.ResourceType == ResourceType.TEXTURE_MAP) // texture maps
     {
         if (node.Game == Game.ODYSSEY || node.Game == Game.ORIGINS)
         {
             Odyssey.ExtractTextureMap(Helpers.GetTempPath(node.Path), node, (string path) =>
             {
                 HandleTextureMap(path);
             });
         }
         else if (node.Game == Game.STEEP) // Needs string path too
         {
             Steep.ExtractTextureMap(Helpers.GetTempPath(node.Path), node, (string path) =>
             {
                 HandleTextureMap(path);
             });
         }
     }
 }
Esempio n. 2
0
        private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node == null || e.Node.Tag == null)
            {
                return;
            }

            EntryTreeNode node   = (EntryTreeNode)e.Node;
            TreeNode      parent = (EntryTreeNode)node.Parent;
            string        text   = node.Text;
            string        tag    = (string)node.Tag;
            long          size   = node.Size;
            ResourceType  type   = node.ResourceType;

            Console.WriteLine(tag);

            // reset the picture box and rich text box
            // ToDo: empty 3D viewer
            pictureBox.ImageLocation = "";
            richTextBox.Text         = "";

            // retrieve the file names the forge
            if (tag.Contains(".forge"))
            {
                if (text.EndsWith(".forge")) // forge file
                {
                    // dump resources used by currentForge
                    if (currentForge != null)
                    {
                        currentForge.Dump();
                    }

                    currentForge = new Forge(tag);
                }
                else // forge entry/subentry
                {
                    // forge subentry
                    if (tag.Contains(FORGE_ENTRY_IDENTIFIER) && tag.Contains(FORGE_SUBENTRY_IDENTIFIER))
                    {
                        /*if (type == ResourceType.MIPMAP)
                         * {
                         *  string parentText = Helpers.GetTempPath(parent.Text);
                         *  string dds = Odyssey.ExtractMipMap(parentText);
                         *  tabControl.SelectedIndex = 1;
                         *
                         *  //scene.DisplayTexture(dds);
                         * }
                         * else*/if (type == ResourceType.TEXTURE_MAP)
                        {
                            string parentText = Helpers.GetTempPath(parent.Text);
                            Odyssey.ExtractTextureMap(parentText, currentForge);
                        }
                        tabControl.SelectedIndex = 1;
                    }
                }
            }
            else if (node.Text.EndsWith(".png"))
            {
                pictureBox.ImageLocation = tag;
                tabControl.SelectedIndex = 1;
            }
            else if (node.Text.EndsWith(".ini") || node.Text.EndsWith(".txt"))
            {
                richTextBox.Text         = string.Join("\n", File.ReadAllLines(tag));
                tabControl.SelectedIndex = 2;
            }

            // update path status label
            pathStatusLabel.Text = tag;

            // update size status label
            if (size > -1)
            {
                sizeStatusLabel.Text = "Size: " + Helpers.BytesToString(size);
            }

            // update the status labels for the picture box
            if (pictureBox.Image != null)
            {
                imageDimensStatusLabel.Text = string.Format("Dimensions: {0}x{1}", pictureBox.Image.Width, pictureBox.Image.Height);
            }
        }
Esempio n. 3
0
        private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node == null || e.Node.Tag == null)
            {
                return;
            }

            EntryTreeNode node   = (EntryTreeNode)e.Node;
            Forge         forge  = node.Forge;
            TreeNode      parent = (EntryTreeNode)node.Parent;
            string        text   = node.Text;
            string        tag    = (string)node.Tag;
            long          size   = node.Size;
            ResourceType  type   = node.ResourceType;

            // reset the picture box and rich text box
            // ToDo: empty 3D viewer
            pictureBox.ImageLocation = "";
            richTextBox.Text         = "";

            if (tag.Contains(".forge"))
            {
                if (text.EndsWith(".forge")) // forge file
                {
                    // dump resources used by currentForge
                    if (currentForge != null)
                    {
                        currentForge.Dump();
                    }

                    currentForge = new Forge(tag);
                    node.Forge   = currentForge;
                }
                else // forge entry/subentry
                {
                    // forge subentry
                    if (tag.Contains(FORGE_ENTRY_IDENTIFIER) && tag.Contains(FORGE_SUBENTRY_IDENTIFIER))
                    {
                        if (type == ResourceType.TEXTURE_MAP)
                        {
                            string parentText = Helpers.GetTempPath(parent.Text);
                            if (node.Game == Game.ODYSSEY || node.Game == Game.ORIGINS)
                            {
                                Odyssey.ExtractTextureMap(parentText, forge, () =>
                                {
                                    if (File.Exists($"{Helpers.GetTempPath(parent.Text)}.png"))
                                    {
                                        currentImgPath = $"{Helpers.GetTempPath(parent.Text)}.png";
                                    }
                                    else if (File.Exists($"{Helpers.GetTempPath(parent.Text)}_TopMip_0.png"))
                                    {
                                        currentImgPath = $"{Helpers.GetTempPath(parent.Text)}_TopMip_0.png";
                                    }

                                    Invoke(new Action(() =>
                                    {
                                        if (!string.IsNullOrEmpty(currentImgPath))
                                        {
                                            UpdatePictureBox(Image.FromFile(currentImgPath));
                                        }

                                        zoomDropDownButton.Text  = "Zoom Level: 100%";
                                        tabControl.SelectedIndex = 1;
                                    }));
                                });
                            }
                            else
                            {
                                Steep.ExtractTextureMap(parentText, forge, () =>
                                {
                                    if (File.Exists($"{Helpers.GetTempPath(parent.Text)}.png"))
                                    {
                                        currentImgPath = $"{Helpers.GetTempPath(parent.Text)}.png";
                                    }
                                    else if (File.Exists($"{Helpers.GetTempPath(parent.Text)}_Mip0.png"))
                                    {
                                        currentImgPath = $"{Helpers.GetTempPath(parent.Text)}_Mip0.png";
                                    }

                                    Invoke(new Action(() =>
                                    {
                                        if (!string.IsNullOrEmpty(currentImgPath))
                                        {
                                            UpdatePictureBox(Image.FromFile(currentImgPath));
                                        }

                                        zoomDropDownButton.Text  = "Zoom Level: 100%";
                                        tabControl.SelectedIndex = 1;
                                    }));
                                });
                            }
                        }
                    }
                }
            }
            else if (text.EndsWith(".png"))
            {
                pictureBox.Image = Image.FromFile(tag);
                pictureBox.Refresh();

                if (pictureBox.Image != null)
                {
                    imageDimensStatusLabel.Text = $"Dimensions: {pictureBox.Image.Width}x{pictureBox.Image.Height}";
                }

                tabControl.SelectedIndex = 1;
            }
            else if (text.EndsWith(".ini") || text.EndsWith(".txt") || text.EndsWith(".log"))
            {
                richTextBox.Text         = string.Join("\n", File.ReadAllLines(tag));
                tabControl.SelectedIndex = 2;
            }
            else if (text.EndsWith(".pck"))
            {
                SoundpackBrowser browser = new SoundpackBrowser();
                browser.LoadPack(tag);
                browser.Show();
            }

            // update path status label
            if (!tag.Contains(FORGE_ENTRY_IDENTIFIER))
            {
                pathStatusLabel.Text = tag;
            }

            // update size status label
            if (size > -1)
            {
                sizeStatusLabel.Text = $"Size: {Helpers.BytesToString(size)}";
            }
        }