Пример #1
0
        public override PlatformData Create(string path, Game game, ProgressIndicator progress)
        {
            if (File.Exists(path))
            {
                if (String.Compare(Path.GetExtension(path), ".ark", true) == 0 || String.Compare(Path.GetExtension(path), ".hdr", true) == 0)
                {
                    path = Path.GetDirectoryName(path);
                }
            }

            PlatformData data = new PlatformData(this, game);

            data.Game = Platform.DetermineGame(data);

            Ark ark = data.GetHarmonixArk(path);

            DirectoryNode songdir = ark.Root.Find("songs", true) as DirectoryNode;

            if (songdir == null)
            {
                Exceptions.Error("This is not a Guitar Hero PS2 disc; the songs dir is missing from the ark.");
            }

            FileNode songsdtbfile = ark.Root.Navigate("config/gen/songs.dtb", false, true) as FileNode;

            if (songsdtbfile == null)
            {
                Exceptions.Error("Couldn't find songs.dtb; this is not a Guitar Hero PS2 disc.");
            }

            data.Session["songdir"] = songdir;

            try {
                List <SongsDTA> dtas      = new List <SongsDTA>();
                Stream          dtbstream = new MemoryStream((int)songsdtbfile.Size);
                CryptedDtbStream.DecryptOld(dtbstream, new EndianReader(songsdtbfile.Data, Endianness.LittleEndian), (int)songsdtbfile.Size);
                dtbstream.Position = 0;
                DTB.NodeTree dtb = DTB.Create(new EndianReader(dtbstream, Endianness.LittleEndian));
                progress.NewTask(dtb.Nodes.Count);
                foreach (DTB.Node node in dtb.Nodes)
                {
                    DTB.NodeTree tree = node as DTB.NodeTree;
                    if (tree == null || tree.Nodes[0].Type != 0x00000005 || songdir.Find((tree.Nodes[0] as DTB.NodeString).Text) == null)
                    {
                        progress.Progress();
                        continue;
                    }

                    SongsDTA dta = SongsDTA.Create(tree);
                    if (dtas.FirstOrDefault(d => d.BaseName == dta.BaseName) != null)
                    {
                        progress.Progress();
                        continue;                         // Don't import songs twice
                    }
                    dtas.Add(dta);

                    SongData song = HarmonixMetadata.GetSongData(data, tree);
                    try {
                        AddSong(data, song, progress);
                    } catch (Exception exception) {
                        Exceptions.Warning(exception, "Unable to properly parse " + song.Name);
                    }
                    progress.Progress();
                }
                progress.EndTask();
            } catch (Exception exception) {
                Exceptions.Error(exception, "An error occurred while parsing the Guitar Hero PS2 disc.");
            }

            return(data);
        }
Пример #2
0
        public override PlatformData Create(string path, Game game, ProgressIndicator progress)
        {
            PlatformData data = new PlatformData(this, game);

            Ark ark = data.GetHarmonixArk(path);

            data.Game = Platform.DetermineGame(data);

            if (data.Game == Game.RockBand2 || data.Game == Game.RockBandBeatles)
            {
                Exceptions.Error("Unable to parse song list from Rock Band Wii disc.");
            }

            data.Session["songdir"] = ark.Root;

            string[] songdirs = new string[] { "songs", "songs_regional/na", "songs_regional/eu" };
            progress.NewTask(songdirs.Length);
            foreach (string songdirname in songdirs)
            {
                DirectoryNode songdir = ark.Root.Navigate(songdirname) as DirectoryNode;
                if (songdir == null)
                {
                    continue;
                }

                FileNode songsdtbfile = songdir.Navigate("gen/songs.dtb") as FileNode;
                if (songsdtbfile == null)
                {
                    continue;
                }

                try {
                    List <SongsDTA> dtas = new List <SongsDTA>();
                    DTB.NodeTree    dtb  = DTB.Create(new EndianReader(new CryptedDtbStream(new EndianReader(songsdtbfile.Data, Endianness.LittleEndian)), Endianness.LittleEndian));
                    progress.NewTask(dtb.Nodes.Count);
                    foreach (DTB.Node node in dtb.Nodes)
                    {
                        DTB.NodeTree tree = node as DTB.NodeTree;
                        if (tree == null || tree.Nodes[0].Type != 0x00000005 || songdir.Find((tree.Nodes[0] as DTB.NodeString).Text) == null)
                        {
                            progress.Progress();
                            continue;
                        }

                        SongsDTA dta = SongsDTA.Create(tree);
                        if (dtas.Find(d => d.BaseName == dta.BaseName) != null)
                        {
                            progress.Progress();
                            continue;                             // Don't import songs twice
                        }

                        dtas.Add(dta);

                        try {
                            SongData song = HarmonixMetadata.GetSongData(data, tree);

                            AddSong(data, song, progress);
                        } catch (Exception exception) {
                            Exceptions.Warning(exception, "Could not import " + dta.Name + " from the Rock Band Wii disc.");
                        }

                        progress.Progress();
                    }
                } catch (Exception exception) {
                    Exceptions.Warning(exception, "Unable to parse song list from Rock Band Wii disc: " + songdirname);
                }
                progress.EndTask();
                progress.Progress();
            }

            progress.EndTask();

            return(data);
        }