示例#1
0
 public static object LoadObject(GameArchives.IFile i)
 {
     if (i.Name.Contains(".bmp_") || i.Name.Contains(".png_"))
     {
         using (var s = i.GetStream())
         {
             try
             {
                 return(TextureReader.ReadStream(s));
             }
             catch (Exception ex)
             {
                 System.Windows.Forms.MessageBox.Show("Couldn't load texture: " + ex.Message);
                 return(null);
             }
         }
     }
     else if (i.Name.Contains("_dta_") || i.Name.EndsWith(".dtb"))
     {
         using (var s = i.GetStream())
         {
             var data = DtxCS.DTX.FromDtb(s);
             var sb   = new StringBuilder();
             foreach (var x in data.Children)
             {
                 sb.AppendLine(x.ToString(0));
             }
             return(sb.ToString());
         }
     }
     else if (i.Name.EndsWith(".dta") || i.Name.EndsWith(".moggsong"))
     {
         using (var s = i.GetStream())
             using (var r = new System.IO.StreamReader(s))
             {
                 return(r.ReadToEnd());
             }
     }
     else if (i.Name.Contains(".songdta"))
     {
         using (var s = i.GetStream())
         {
             var songData = SongDataReader.ReadStream(s);
             return(songData);
         }
     }
     else if (i.Name.Contains(".fbx"))
     {
         using (var s = i.GetStream())
         {
             return(HxMeshReader.ReadStream(s));
         }
     }
     else if (i.Name.Contains(".rbmid_"))
     {
         using (var s = i.GetStream())
         {
             return(RBMidReader.ReadStream(s));
         }
     }
     else if (i.Name.Contains(".lipsync"))
     {
         using (var s = i.GetStream())
         {
             return(new LipsyncReader(s).Read());
         }
     }
     else if (i.Name.Contains(".rbsong"))
     {
         using (var s = i.GetStream())
         {
             return(new RBSongReader(s).Read());
         }
     }
     else if (i.Name.Contains(".gp4"))
     {
         using (var s = i.GetStream())
         {
             return(LibOrbisPkg.GP4.Gp4Project.ReadFrom(s));
         }
     }
     else if (i.Name.Contains(".pkg"))
     {
         using (var s = i.GetStream())
         {
             return(new LibOrbisPkg.PKG.PkgReader(s).ReadHeader());
         }
     }
     else
     {
         return(null);
     }
 }
示例#2
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            switch (e.Node.Tag)
            {
            case null:
                break;

            case GameArchives.IFile i:
                if (i.Name.Contains(".bmp_") || i.Name.Contains(".png_"))
                {
                    using (var s = i.GetStream())
                    {
                        var tex = TextureReader.ReadStream(s);
                        pictureBox1.Width  = tex.Mipmaps[0].Width;
                        pictureBox1.Height = tex.Mipmaps[0].Height;
                        tabControl1.SelectTab(0);
                        fileTreeView.Select();
                        try
                        {
                            pictureBox1.Image = TextureConverter.ToBitmap(tex, 0);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Couldn't load texture: " + ex.Message);
                        }
                    }
                }
                else if (i.Name.Contains("_dta_") || i.Name.EndsWith(".dtb"))
                {
                    using (var s = i.GetStream())
                    {
                        var data = DtxCS.DTX.FromDtb(s);
                        tabControl1.SelectTab(1);
                        fileTreeView.Select();
                        var sb = new StringBuilder();
                        foreach (var x in data.Children)
                        {
                            sb.AppendLine(x.ToString(0));
                        }
                        dataTextBox.Text = sb.ToString();
                    }
                }
                else if (i.Name.EndsWith(".dta") || i.Name.EndsWith(".moggsong"))
                {
                    using (var s = i.GetStream())
                        using (var r = new System.IO.StreamReader(s))
                        {
                            tabControl1.SelectTab(1);
                            fileTreeView.Select();
                            dataTextBox.Text = r.ReadToEnd();
                        }
                }
                else if (i.Name.Contains(".songdta"))
                {
                    using (var s = i.GetStream())
                    {
                        var songData = SongDataReader.ReadStream(s);
                        songDataInspector1.UpdateValues(songData);
                        tabControl1.SelectTab(2);
                        fileTreeView.Select();
                    }
                }
                else if (i.Name.Contains(".fbx"))
                {
                    using (var s = i.GetStream())
                    {
                        var mesh = HxMeshReader.ReadStream(s);
                        meshTextBox.Text = HxMeshConverter.ToObj(mesh);
                        tabControl1.SelectTab(3);
                        fileTreeView.Select();
                    }
                }
                else if (i.Name.Contains(".rbmid_"))
                {
                    using (var s = i.GetStream())
                    {
                        var rbmid = RBMidReader.ReadStream(s);
                        ObjectPreview(rbmid);
                    }
                }
                else if (i.Name.Contains(".lipsync"))
                {
                    using (var s = i.GetStream())
                    {
                        var lipsync = new LibForge.Lipsync.LipsyncReader(s).Read();
                        ObjectPreview(lipsync);
                    }
                }
                else if (i.Name.Contains(".rbsong"))
                {
                    using (var s = i.GetStream())
                    {
                        var rbsong = new LibForge.RBSong.RBSongReader(s).Read();
                        ObjectPreview(rbsong);
                    }
                }
                break;
            }
        }