コード例 #1
0
        public override PlatformData Create(string path, Game game, ProgressIndicator progress)
        {
            PlatformData data = new PlatformData(this, game);

            data.Session["path"] = path;

            if (Directory.Exists(path))
            {
                Exceptions.Error("An RBN archive must be a file.");
            }

            if (File.Exists(path))
            {
                try {
                    RBA rba = new RBA(new EndianReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read), Endianness.LittleEndian));
                    data.Session["rba"] = rba;

                    SongData song = HarmonixMetadata.GetSongData(data, DTA.Create(rba.Data));

                    song.ID = ImportMap.GetShortName(song.Name);

                    AddSong(data, song, progress);
                } catch (Exception exception) {
                    Exceptions.Error(exception, "An error occurred while opening the RBN archive.");
                }
            }

            return(data);
        }
コード例 #2
0
        public override PlatformData Create(string path, Game game, ProgressIndicator progress)
        {
            PlatformData data = new PlatformData(this, game);

            DirectoryNode dir = data.GetDirectoryStructure(path);

            List <DirectoryNode> dirs = new List <DirectoryNode>();

            dirs.Add(dir);
            dirs.AddRange(dir.Directories);

            progress.NewTask(dirs.Count);

            foreach (DirectoryNode songdir in dirs)
            {
                data.Session["songdir"] = songdir;

                FileNode datafile    = songdir.Navigate("data", false, true) as FileNode;
                FileNode newdatafile = songdir.Navigate("songdata", false, true) as FileNode;
                if (datafile == null && newdatafile == null)
                {
                    Exceptions.Warning("Unable to find a custom in " + songdir.Filename);
                    continue;
                }

                try {
                    SongData song = null;
                    if (datafile != null)
                    {
                        song = HarmonixMetadata.GetSongData(data, DTB.Create(new EndianReader(datafile.Data, Endianness.LittleEndian)));
                        datafile.Data.Close();
                        AddSongOld(data, song, progress);
                    }
                    else
                    {
                        song = SongData.Create(newdatafile.Data);
                        newdatafile.Data.Close();
                        AddSongNew(data, song, progress);
                    }
                } catch (Exception exception) {
                    Exceptions.Error(exception, "Unable to open the custom from " + songdir.Filename);
                }

                progress.Progress();
            }
            progress.EndTask();

            return(data);
        }
コード例 #3
0
        public static SongsDTA GetSongsDTA(SongData song, AudioFormat audioformat, bool idioticdrums = true)
        {
            SongsDTA dta = HarmonixMetadata.GetSongData(song);

            dta.Downloaded = true;
            if ((dta.Decade == null || dta.Decade.Length == 0) && dta.Year.ToString().Length > 2)
            {
                dta.Decade = "the" + dta.Year.ToString()[2] + "0s";
            }
            dta.BaseName = "rwk" + dta.Version.ToString() + dta.BaseName;
            dta.Genre    = ImportMap.GetShortGenre(dta.Genre);

            dta.Song.Cores.Clear();
            dta.Song.Pans.Clear();
            dta.Song.Vols.Clear();
            foreach (SongsDTA.SongTracks track in dta.Song.Tracks)
            {
                track.Tracks.Clear();
            }
            dta.Song.TracksCount.Clear();
            var maps = audioformat.Mappings.Where(m => m.Instrument != Instrument.Preview).ToList();

            foreach (AudioFormat.Mapping map in maps)
            {
                dta.Song.Cores.Add(map.Instrument == Instrument.Guitar ? 1 : -1);
                dta.Song.Pans.Add(map.Balance);
                dta.Song.Vols.Add(map.Volume);
                SongsDTA.SongTracks track = dta.Song.Tracks.FirstOrDefault(t => t.Name == HarmonixMetadata.InstrumentToString(map.Instrument));
                if (track != null)
                {
                    track.Tracks.Add(maps.IndexOf(map));
                }
            }

            if (idioticdrums)
            {
                // For safety with customs messing with mix and not knowing what they're doing
                SongsDTA.SongTracks drumtrack = dta.Song.Tracks.FirstOrDefault(t => t.Name == "drum");
                while (drumtrack != null && drumtrack.Tracks.Count > 0 && drumtrack.Tracks.Count < 6)
                {
                    drumtrack.Tracks.Add(drumtrack.Tracks[drumtrack.Tracks.Count - 1]);
                }
            }

            return(dta);
        }
コード例 #4
0
        private void AddSongFromDTB(string path, PlatformData data, DTB.NodeTree dtb, ProgressIndicator progress)
        {
            SongData song = HarmonixMetadata.GetSongData(data, dtb);
            SongsDTA dta  = HarmonixMetadata.GetSongsDTA(song);

            if (song.ID.StartsWith("rwk"))
            {
                song.ID = dta.Song.Name.Split('/').Last();
            }

            string title       = dta.Song.Name.Substring(4, 4);
            int    index       = int.Parse(dta.Song.Name.Substring(9, 3));
            string indexpath   = Util.Pad((index + 1).ToString(), 3);
            string contentpath = Path.Combine(path, "private/wii/data/" + title + "/" + indexpath + ".bin");
            string dtapath     = Path.Combine(path, "private/wii/data/" + title + "/" + Util.Pad(index.ToString(), 3) + ".bin");

            AddSongFromBins(data, song, dtapath, contentpath, progress);
        }
コード例 #5
0
        public override bool AddSong(PlatformData data, SongData song, ProgressIndicator progress)
        {
            DirectoryNode songdir = data.Session["songdir"] as DirectoryNode;

            SongsDTA dta = HarmonixMetadata.GetSongsDTA(song);

            if (dta == null)               // GH1's <addsong />
            {
                dta            = HarmonixMetadata.GetSongData(song);
                dta.Song.Cores = new List <int>()
                {
                    -1, -1, 1, 1
                };
                dta.Song.Vols = new List <float>()
                {
                    0, 0, 0, 0
                };
                dta.Song.Pans = new List <float>()
                {
                    -1, 1, -1, 1
                };
                dta.Song.Tracks.Find(t => t.Name == "guitar").Tracks.AddRange(new int[] { 2, 3 });
                HarmonixMetadata.SetSongsDTA(song, dta.ToDTB());
            }

            dta.Bank = "sfx/tambourine_bank.milo";

            DirectoryNode songnode = songdir.Navigate(song.ID) as DirectoryNode;

            FileNode chartfile = songnode.Find(song.ID + ".mid") as FileNode;

            if (chartfile == null)
            {
                return(false);
            }

            for (int coop = 0; coop < 2; coop++)
            {
                if (coop == 1)
                {
                    song       = new SongData(song);
                    song.ID   += "_coop";
                    song.Name += " [coop]";
                    if (dta.SongCoop != null)
                    {
                        dta.Song     = dta.SongCoop;
                        dta.SongCoop = null;
                    }
                    else
                    {
                        return(false);
                    }
                }
                HarmonixMetadata.SetSongsDTA(song, dta.ToDTB());
                FormatData formatdata = new TemporaryFormatData(song, data);

                FileNode songaudiofile = songnode.Find(song.ID + ".vgs") as FileNode;
                if (songaudiofile == null)
                {
                    songaudiofile = songnode.Find(song.ID + "_sp.vgs") as FileNode;
                }
                if (songaudiofile == null)
                {
                    return(false);
                }

                if (data.Game == Game.GuitarHero1)
                {
                    ChartFormatGH1.Instance.Create(formatdata, chartfile == null ? null : chartfile.Data);
                }
                else
                {
                    ChartFormatGH2.Instance.Create(formatdata, chartfile == null ? null : chartfile.Data, coop == 1);
                }

                AudioFormatVGS.Instance.Create(formatdata, songaudiofile.Data, null);

                data.AddSong(formatdata);
            }

            return(true);
        }
コード例 #6
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);
        }
コード例 #7
0
        public override bool AddSong(PlatformData data, SongData song, ProgressIndicator progress)
        {
            FormatData formatdata = new TemporaryFormatData(song, data);

            DirectoryNode songdir = data.Session["songdir"] as DirectoryNode;

            SongsDTA dta = HarmonixMetadata.GetSongsDTA(song);

            if (dta == null)               // LRB's <addsong />
            {
                dta            = HarmonixMetadata.GetSongData(song);
                dta.Song.Cores = new List <int>()
                {
                    -1, -1, -1, -1, -1, 1, 1, -1, -1
                };
                dta.Song.Vols = new List <float>()
                {
                    0, 0, 0, 0, 0, 0, 0, 0, 0
                };
                dta.Song.Pans = new List <float>()
                {
                    0, 0, -1, 1, 0, -1, 1, 0, 0
                };
                dta.Song.Tracks.Find(t => t.Name == "drum").Tracks.AddRange(new int[] { 0, 1, 2, 3 });
                dta.Song.Tracks.Find(t => t.Name == "bass").Tracks.AddRange(new int[] { 4 });
                dta.Song.Tracks.Find(t => t.Name == "guitar").Tracks.AddRange(new int[] { 5, 6 });
                dta.Song.Tracks.Find(t => t.Name == "vocals").Tracks.AddRange(new int[] { 7 });
                dta.Song.Name = "songs/" + song.ID + "/" + song.ID;
                HarmonixMetadata.SetSongsDTA(song, dta.ToDTB());
            }

            string dtaname = dta.Song.Name;

            if (dtaname.StartsWith("dlc"))
            {
                dtaname = dtaname.Split(new char[] { '/' }, 4)[3];
            }

            int    lastslash = dtaname.LastIndexOf('/');
            string basename  = dtaname.Substring(lastslash + 1);

            dtaname = dtaname.Substring(0, lastslash);
            DirectoryNode songnode = songdir.Navigate(dtaname) as DirectoryNode;

            if (songnode == null)
            {
                return(false);
            }

            FileNode    songaudiofile = songnode.Navigate(basename + ".bik", false, true) as FileNode;
            AudioFormat audio         = null;

            if (songaudiofile == null)
            {
                songaudiofile = songnode.Navigate(basename + ".mogg", false, true) as FileNode;
                if (songaudiofile == null)
                {
                    return(false);
                }
                if (HarmonixMetadata.IsRockBand1(data.Game))
                {
                    audio = HarmonixMetadata.GetAudioFormat(song);
                    audio.InitialOffset = 3000;
                }
                AudioFormatMogg.Instance.Create(formatdata, songaudiofile.Data, audio);
            }
            else
            {
                AudioFormatRB2Bink.Instance.Create(formatdata, songaudiofile.Data, null);
            }

            // TODO:	SongInfo
            // TODO:	Preview

            FileNode chartfile   = songnode.Find(basename + ".mid") as FileNode;
            FileNode panfile     = songnode.Find(basename + ".pan") as FileNode;
            FileNode weightsfile = songnode.Navigate("gen/" + basename + "_weights.bin") as FileNode;
            FileNode milofile    = songnode.Navigate("gen/" + basename + ".milo_wii") as FileNode;
            FileNode albumfile   = songnode.Navigate("gen/" + basename + "_keep.png_wii") as FileNode;

            if (chartfile == null)
            {
                return(false);
            }

            if (albumfile == null)
            {
                albumfile = songnode.Navigate("gen/" + basename + "_nomip_keep.bmp_wii") as FileNode;
            }

            if (albumfile != null)
            {
                song.AlbumArt = WiiImage.Create(new EndianReader(albumfile.Data, Endianness.LittleEndian)).Bitmap;
                albumfile.Data.Close();
            }

            ChartFormatRB.Instance.Create(formatdata, chartfile == null ? null : chartfile.Data, panfile == null ? null : panfile.Data, weightsfile == null ? null : weightsfile.Data, milofile == null ? null : milofile.Data, false, false, data.Game);

            data.AddSong(formatdata);

            return(true);
        }
コード例 #8
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);
        }
コード例 #9
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;
		}