private static IList <SongsDTA> GetInstalledCustoms(string path, string sdpath)
        {
            if (!Directory.Exists(path))
            {
                return(new List <SongsDTA>());
            }

            List <SongsDTA> list = new List <SongsDTA>();

            string[] dirs = Directory.GetDirectories(path, "*", SearchOption.TopDirectoryOnly);
            foreach (string file in dirs)
            {
                if (File.Exists(Path.Combine(file, "data")))
                {
                    FileStream fstream = null;
                    try {
                        fstream = new FileStream(Path.Combine(file, "data"), FileMode.Open);
                        list.Add(SongsDTA.Create(DTB.Create(new EndianReader(fstream, Endianness.LittleEndian))));
                    } catch { }
                    if (fstream != null)
                    {
                        fstream.Close();
                    }
                }
            }
            return(list);
        }
示例#2
0
        public static SongsDTA GetSongsDTA(SongData song)
        {
            DataArray tree = song.Data.GetSubtree("HmxSongsDtb");

            if (tree != null)
            {
                return(SongsDTA.Create(tree.GetSubtree()));
            }
            return(null);
        }
示例#3
0
        public static SongData GetSongData(PlatformData platformdata, DTB.NodeTree dtb)
        {
            SongData data = new SongData(platformdata);

            data.Data.SetSubtree("HmxSongsDtb", dtb);

            SongsDTA dta = SongsDTA.Create(dtb);

            data.Album = dta.Album;
            if (dta.Track.HasValue)
            {
                data.AlbumTrack = dta.Track.Value;
            }
            data.Artist = dta.Artist;
            data.ID     = dta.BaseName;
            for (Instrument instrument = Instrument.Ambient; instrument <= Instrument.Vocals; instrument++)
            {
                SongsDTA.Rankings rank = dta.Rank.SingleOrDefault(r => r.Name == InstrumentToString(instrument));
                if (rank != null)
                {
                    data.Difficulty[instrument] = rank.Rank;
                }
            }
            data.Genre        = dta.Genre;
            data.Master       = dta.Master;
            data.Name         = dta.Name;
            data.Pack         = dta.Pack;
            data.Vocalist     = dta.Vocalist;
            data.Year         = dta.Year;
            data.Version      = dta.Version;
            data.PreviewTimes = dta.Preview;
            if (dta.Song.HopoThreshold.HasValue)
            {
                data.HopoThreshold = dta.Song.HopoThreshold.Value;
            }

            return(data);
        }
        public override void DeleteSong(PlatformData data, FormatData formatdata, ProgressIndicator progress)
        {
            string path    = data.Session["maindirpath"] as string;
            string dtapath = "rawk/rb2/customs/" + formatdata.Song.ID;

            FileStream dtafile = new FileStream(Path.Combine(path, dtapath + "/data"), FileMode.Open, FileAccess.Read, FileShare.Read);

            EndianReader reader = new EndianReader(dtafile, Endianness.LittleEndian);

            DTB.NodeTree dtb = DTB.Create(reader);
            dtafile.Close();

            SongsDTA dta   = SongsDTA.Create(dtb);
            string   title = dta.Song.Name.Substring(4, 4);
            int      index = int.Parse(dta.Song.Name.Substring(9, 3));

            Util.Delete(Path.Combine(path, "private/wii/data/" + title + "/" + Util.Pad((index).ToString(), 3) + ".bin"));
            Util.Delete(Path.Combine(path, "private/wii/data/" + title + "/" + Util.Pad((index + 1).ToString(), 3) + ".bin"));
            Directory.Delete(Path.Combine(path, dtapath), true);

            base.DeleteSong(data, formatdata, progress);

            SaveDTBCache(data);
        }
示例#5
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);
        }
示例#6
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);
        }
示例#7
0
		public override PlatformData Create(string path, Game game, ProgressIndicator progress)
		{
			PlatformData data = new PlatformData(this, game);

			DirectoryNode maindir = DirectoryNode.FromPath(path, data.Cache, FileAccess.Read);

			char[] regions = new char[] { 'E', 'P' };

			DirectoryNode dir = maindir.Navigate("private/wii/data", false, true) as DirectoryNode;
			if (dir == null)
				dir = maindir;

			for (char letter = 'A'; letter <= 'Z'; letter++) {
				foreach (char region in regions) {
					DirectoryNode subdir = dir.Find("SZ" + letter + region, true) as DirectoryNode;
					if (subdir == null)
						continue;

					foreach (FileNode file in subdir.Files) {
						if (String.Compare(Path.GetExtension(file.Name), ".bin", true) != 0)
							continue;

						try {
							file.Data.Position = 0;
							DlcBin bin = new DlcBin(file.Data);
							U8 u8;
							try {
								u8 = new U8(bin.Data);
							} catch (FormatException) {
								file.Data.Close();
								continue;
							}
							FileNode songsdta = u8.Root.Find("songs.dta", SearchOption.AllDirectories) as FileNode;
							if (songsdta == null) {
								file.Data.Close();
								continue;
							}

							DTB.NodeTree dtb = DTA.Create(songsdta.Data);
							SongsDTA dta = SongsDTA.Create(dtb);
							file.Data.Close();
							
							SongData song = HarmonixMetadata.GetSongData(data, dtb);

							string contentbin = dta.Song.Name.Substring(9, 3); // Example, "dlc/sZAE/023/content/songs/simpleman/simpleman"

							FileNode contentfile = subdir.Find(contentbin + ".bin", true) as FileNode;
							if (contentfile == null)
								continue;

							FormatData formatdata = new TemporaryFormatData(song, data);

							Create(formatdata, file.Data, contentfile.Data);
							
							data.AddSong(formatdata);

							contentfile.Data.Close();
						} catch (FormatException) { } // Not a DLC bin we care about
					}
				}
			}

			return data;
		}