예제 #1
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (openFileDialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
         openFileDialog2.FileName.Length > 0)
     {
         Dictionary <string, byte[]> files = new Dictionary <string, byte[]>();
         if (Directory.Exists(Path.GetDirectoryName(openFileDialog1.FileName).Replace("blyt", "timg")))
         {
             foreach (FileInfo f in new DirectoryInfo(Path.GetDirectoryName(openFileDialog1.FileName).Replace("blyt", "timg")).GetFiles())
             {
                 files.Add(f.Name, File.ReadAllBytes(f.FullName));
             }
         }
         Animation = new IO.BRLAN(File.ReadAllBytes(openFileDialog2.FileName), files);
         treeView1.BeginUpdate();
         if (treeView1.Nodes.Count == 1)
         {
             treeView1.Nodes.Add("Brlan");
             treeView1.Nodes[1].ImageIndex         = 8;
             treeView1.Nodes[1].SelectedImageIndex = 8;
         }
         treeView1.Nodes[1].Nodes.Clear();
         treeView1.Nodes[1].Nodes.Add("Pai1");
         treeView1.Nodes[1].Nodes[0].ImageIndex         = 9;
         treeView1.Nodes[1].Nodes[0].SelectedImageIndex = 9;
         treeView1.EndUpdate();
         FrameNr = 0;
         toolStripButton2.Enabled = true;
         Render();
     }
 }
예제 #2
0
        private void openToolStripButton_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
                openFileDialog1.FileName.Length > 0)
            {
                timer1.Enabled = false;
                simpleOpenGlControl1.DestroyContexts();
                simpleOpenGlControl1.InitializeContexts();
                InitOpenGl();
                Animation = null;
                FrameNr   = 0;
                toolStripButton1.Enabled = true;
                toolStripButton2.Enabled = false;
                toolStripButton2.Checked = false;
                if (openFileDialog1.FileName.ToLower().EndsWith(".brlyt"))
                {
                    Dictionary <string, byte[]> files = new Dictionary <string, byte[]>();
                    if (Directory.Exists(Path.GetDirectoryName(openFileDialog1.FileName).Replace("blyt", "timg")))
                    {
                        foreach (FileInfo f in new DirectoryInfo(Path.GetDirectoryName(openFileDialog1.FileName).Replace("blyt", "timg")).GetFiles())
                        {
                            files.Add(f.Name, File.ReadAllBytes(f.FullName));
                        }
                    }
                    foreach (FileInfo f in new DirectoryInfo(Path.GetDirectoryName(openFileDialog1.FileName)).GetFiles())
                    {
                        if (f.Extension == ".brfnt")
                        {
                            files.Add(f.Name, File.ReadAllBytes(f.FullName));
                        }
                    }
                    Layout = new IO.BRLYT(File.ReadAllBytes(openFileDialog1.FileName), files);
                }
                else if (openFileDialog1.FileName.ToLower().EndsWith("banner.bin"))
                {
                    byte[] file = File.ReadAllBytes(openFileDialog1.FileName);
                    if (libWiiSharp.Lz77.IsLz77Compressed(file))
                    {
                        file = new libWiiSharp.Lz77().Decompress(file);
                    }
                    libWiiSharp.U8 u = libWiiSharp.U8.Load(file);
                    Dictionary <string, byte[]> files = new Dictionary <string, byte[]>();
                    int i = 0;
                    foreach (libWiiSharp.U8_Node n in u.Nodes)
                    {
                        if (u.StringTable[i].ToLower().EndsWith(".brfnt") || u.StringTable[i].ToLower().EndsWith(".tpl"))
                        {
                            files.Add(u.StringTable[i], u.Data[i]);
                        }
                        i++;
                    }
                    i = 0;
                    foreach (libWiiSharp.U8_Node n in u.Nodes)
                    {
                        if (u.StringTable[i].ToLower().EndsWith(".brlyt"))
                        {
                            Layout = new IO.BRLYT(u.Data[i], files);
                            break;
                        }
                        i++;
                    }
                }
                else if (openFileDialog1.FileName.ToLower().EndsWith(".wad"))
                {
                    byte[] file = File.ReadAllBytes(openFileDialog1.FileName);
                    if (libWiiSharp.Lz77.IsLz77Compressed(file))
                    {
                        file = new libWiiSharp.Lz77().Decompress(file);
                    }
                    libWiiSharp.WAD w = libWiiSharp.WAD.Load(file);
                    libWiiSharp.U8  u = null;
                    int             i = 0;
                    foreach (libWiiSharp.U8_Node n in w.BannerApp.Nodes)
                    {
                        if (w.BannerApp.StringTable[i].ToLower().EndsWith("banner.bin"))
                        {
                            u = libWiiSharp.U8.Load(w.BannerApp.Data[i]);
                            break;
                        }
                        i++;
                    }

                    Dictionary <string, byte[]> files = new Dictionary <string, byte[]>();
                    i = 0;
                    foreach (libWiiSharp.U8_Node n in u.Nodes)
                    {
                        if (u.StringTable[i].ToLower().EndsWith(".brfnt") || u.StringTable[i].ToLower().EndsWith(".tpl"))
                        {
                            files.Add(u.StringTable[i], u.Data[i]);
                        }
                        i++;
                    }
                    i = 0;
                    bool layout = false;
                    foreach (libWiiSharp.U8_Node n in u.Nodes)
                    {
                        if (u.StringTable[i].ToLower().EndsWith(".brlyt") && !layout)
                        {
                            Layout = new IO.BRLYT(u.Data[i], files);
                            layout = true;
                        }
                        else if (u.StringTable[i].ToLower().EndsWith("banner_start.brlan"))
                        {
                            Animation = new IO.BRLAN(u.Data[i], files);
                            FrameNr   = 0;
                            toolStripButton2.Enabled = true;
                        }
                        else if (u.StringTable[i].ToLower().EndsWith("banner.brlan"))
                        {
                            Animation = new IO.BRLAN(u.Data[i], files);
                            FrameNr   = 0;
                            toolStripButton2.Enabled = true;
                        }
                        i++;
                    }
                }
                else if (openFileDialog1.FileName.ToLower().EndsWith(".bnr"))
                {
                    byte[] file = File.ReadAllBytes(openFileDialog1.FileName);
                    if (libWiiSharp.Lz77.IsLz77Compressed(file))
                    {
                        file = new libWiiSharp.Lz77().Decompress(file);
                    }
                    libWiiSharp.U8 w = libWiiSharp.U8.Load(file);
                    libWiiSharp.U8 u = null;
                    int            i = 0;
                    foreach (libWiiSharp.U8_Node n in w.Nodes)
                    {
                        if (w.StringTable[i].ToLower().EndsWith("banner.bin"))
                        {
                            u = libWiiSharp.U8.Load(w.Data[i]);
                            break;
                        }
                        i++;
                    }

                    Dictionary <string, byte[]> files = new Dictionary <string, byte[]>();
                    i = 0;
                    foreach (libWiiSharp.U8_Node n in u.Nodes)
                    {
                        if (u.StringTable[i].ToLower().EndsWith(".brfnt") || u.StringTable[i].ToLower().EndsWith(".tpl"))
                        {
                            files.Add(u.StringTable[i], u.Data[i]);
                        }
                        i++;
                    }
                    i = 0;
                    bool layout = false;
                    foreach (libWiiSharp.U8_Node n in u.Nodes)
                    {
                        if (u.StringTable[i].ToLower().EndsWith(".brlyt") && !layout)
                        {
                            Layout = new IO.BRLYT(u.Data[i], files);
                            layout = true;
                        }
                        else if (u.StringTable[i].ToLower().EndsWith("banner_start.brlan"))
                        {
                            Animation = new IO.BRLAN(u.Data[i], files);
                            FrameNr   = 0;
                            toolStripButton2.Enabled = true;
                        }
                        i++;
                    }
                }
                propertyGrid1.SelectedObject = null;
                treeView1.BeginUpdate();
                treeView1.Nodes.Clear();
                treeView1.Nodes.Add("Brlyt");
                treeView1.Nodes[0].ImageIndex         = 5;
                treeView1.Nodes[0].SelectedImageIndex = 5;
                TreeNode c = treeView1.Nodes[0].Nodes.Add("Txl1");
                c.ImageIndex         = 6;
                c.SelectedImageIndex = 6;
                if (Layout.FNL1 != null)
                {
                    c                    = treeView1.Nodes[0].Nodes.Add("Fnl1");
                    c.ImageIndex         = 7;
                    c.SelectedImageIndex = 7;
                }
                c                    = treeView1.Nodes[0].Nodes.Add("Mat1");
                c.ImageIndex         = 4;
                c.SelectedImageIndex = 4;
                foreach (IO.BRLYT.mat1.MAT1Entry m in Layout.MAT1.Entries)
                {
                    m.GetTreeNode(c.Nodes);
                }
                Layout.PAN1.GetTreeNodes(treeView1.Nodes[0].Nodes);
                treeView1.EndUpdate();
                Layout.BindTextures();
                simpleOpenGlControl1.Width  = (int)Layout.LYT1.Width;
                simpleOpenGlControl1.Height = (int)Layout.LYT1.Height;
                Render();
            }
        }