Holds the song QbKey and status ProjectSong (if it's been created)
Exemple #1
0
 private void addSongToMenu(ToolStripMenuItem mi, ProjectTierSong pts)
 {
     ToolStripMenuItem m = new ToolStripMenuItem(string.Format("{2}. {0} - {1}", pts.Song.Artist, pts.Song.Title, pts.Number.ToString()));
     m.Tag = pts.Song;
     m.Click += new EventHandler(mnuMoveItemSong_Click);
     mi.DropDown.Items.Add(m);
 }
Exemple #2
0
 internal DirectoryInfo ProjectSongSettingsFolder(ProjectTierSong pts, DirectoryInfo pDir)
 {
     string badFileChars = "[\\/:<>|?*]";
     string newPath = string.Format(@"{0}\({1} {2}) {3} - {4}", pDir.FullName, pts.Tier.Number.ToString().PadLeft(2, '0'), pts.Number.ToString().PadLeft(3, '0'), Regex.Replace(pts.Song.Artist, badFileChars, string.Empty), Regex.Replace(pts.Song.Title, badFileChars, string.Empty));
     //System.Diagnostics.Debug.WriteLine(newPath);
     return new DirectoryInfo(newPath);
 }
Exemple #3
0
        internal void LoadSettings()
        {
            if (_projectFile.Length == 0 || !File.Exists(_projectFile))
                return;

            if (File.Exists(_projectFile))
            {
                try
                {
                    FileInfo pFile = new FileInfo(this.Filename);
                    DirectoryInfo pDir = new DirectoryInfo(pFile.FullName.Substring(0, pFile.FullName.Length - pFile.Extension.Length));

                    XmlReaderSettings xmlS = new XmlReaderSettings();
                    xmlS.IgnoreComments = true;
                    xmlS.IgnoreProcessingInstructions = true;
                    xmlS.IgnoreWhitespace = true;

                    using (XmlReader xml = XmlReader.Create(_projectFile, xmlS))
                    {

                        while (!xml.EOF && xml.Read())
                        {
                            if (xml.Name == "xml")
                                break;
                        }

                        while (!xml.EOF && xml.Read())
                        {
                            if (xml.Name == "TheGHOST_ProjectSettings")
                            {
                                #region TheGHOST_ProjectSettings
                                if (xml.GetAttribute("version") == "1")
                                {
                                    while (!xml.EOF && xml.Read())
                                    {
                                        switch (xml.Name)
                                        {
                                            case "Plugins":
                                                #region Plugins
                                                while (!xml.EOF && xml.Read())
                                                {
                                                    if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "Plugins")
                                                        break;
                                                }
                                                #endregion
                                                break;

                                            case "Settings":
                                                #region Settings
                                                while (!xml.EOF && xml.Read())
                                                {
                                                    if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "Settings")
                                                        break;
                                                }
                                                #endregion
                                                break;

                                            case "QbMods":
                                                #region QbMods
                                                while (!xml.EOF && xml.Read())
                                                {
                                                    if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "QbMods")
                                                        break;
                                                }
                                                #endregion
                                                break;

                                            case "BackgroundMusic":
                                                #region BackgroundMusic

                                                int bi = 0;
                                                ProjectBackgroundAudio ba = null;
                                                while (!xml.EOF && xml.Read())
                                                {
                                                    if (xml.NodeType == XmlNodeType.Element && xml.Name == "Background")
                                                    {
                                                        DateTime baLastChanged = DateTime.MinValue;
                                                        if (bi < _project.BackgroundAudio.Count)
                                                        {
                                                            ba = _project.BackgroundAudio[bi++];
                                                            if (xml.GetAttribute("start") != null)
                                                                ba.PreviewStart = int.Parse(xml.GetAttribute("start"));
                                                            if (xml.GetAttribute("length") != null)
                                                                ba.PreviewLength = int.Parse(xml.GetAttribute("length"));
                                                            if (xml.GetAttribute("fadeLength") != null)
                                                                ba.PreviewFadeLength = int.Parse(xml.GetAttribute("fadeLength"));
                                                            if (xml.GetAttribute("volume") != null)
                                                                ba.PreviewVolume = int.Parse(xml.GetAttribute("volume"));
                                                            if (xml.GetAttribute("lastChanged") != null)
                                                                baLastChanged = DateTime.Parse(xml.GetAttribute("lastChanged"), null, System.Globalization.DateTimeStyles.AssumeLocal);
                                                            if (xml.GetAttribute("lastApplied") != null)
                                                                ba.LastApplied = DateTime.Parse(xml.GetAttribute("lastApplied"), null, System.Globalization.DateTimeStyles.AssumeLocal);
                                                        }

                                                        while (!xml.IsEmptyElement && !xml.EOF && xml.Read())
                                                        {
                                                            if (xml.NodeType == XmlNodeType.Element && xml.Name == "AudioFiles")
                                                                ba.AudioLength = int.Parse(xml.GetAttribute("length"));
                                                            else if (xml.NodeType == XmlNodeType.Element && xml.Name == "AudioFile")
                                                            {
                                                                int vol = int.Parse(xml.GetAttribute("volume"));
                                                                ba.AudioFiles.Add(ba.CreateAudioFile(pathRelToAbs(xml.ReadString(), pDir), vol));
                                                            }
                                                            else // if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "Background")
                                                                break;
                                                        }

                                                        ((ISettingsChange)ba).RecordChange();
                                                        ba.LastChanged = baLastChanged;
                                                    }
                                                    else if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "BackgroundMusic")
                                                        break;
                                                }
                                                #endregion
                                                break;

                                            case "Songs":
                                                #region Songs

                                                //update to load songs in order rather than by ID.
                                                ProjectTierSong[] allSongs;

                                                try
                                                {
                                                    allSongs = new ProjectTierSong[_project.Songs.Count];
                                                }
                                                catch (Exception ex)
                                                {
                                                    throw new ApplicationException(string.Format("{0}{1}{1}Check that the correct Game is selected!", ex.Message, Environment.NewLine), ex);
                                                }

                                                _project.Songs.Values.CopyTo(allSongs, 0);
                                                int songIdx = 0;

                                                bool useIds = true; //UPGRADE COMPATABILITY: if IDs exist and the first one exists, then load with IDs (will be saved without)

                                                while (!xml.EOF && xml.Read())
                                                {
                                                    if (songIdx < allSongs.Length && xml.NodeType == XmlNodeType.Element && xml.Name == "Song")
                                                    {
                                                        ProjectSong song = null;
                                                        //get song from position

                                                        if (useIds)
                                                        {
                                                            if (xml.GetAttribute("id") != null) //load by ID
                                                            {
                                                                QbKey songQk = QbKey.Create(xml.GetAttribute("id"));
                                                                if (_project.Songs.ContainsKey(songQk.Crc))
                                                                    song = _project.CreateProjectSong(_project.Songs[songQk.Crc].SongQb, false);
                                                            }
                                                            if (song == null && songIdx == 0)
                                                                useIds = false;
                                                        }

                                                        if (!useIds)
                                                            song = _project.CreateProjectSong(allSongs[songIdx].SongQb, false);

                                                        songIdx++;

                                                        if (song != null)
                                                        {
                                                            if (xml.GetAttribute("lastApplied") != null)
                                                                song.LastApplied = DateTime.Parse(xml.GetAttribute("lastApplied"), null, System.Globalization.DateTimeStyles.AssumeLocal);

                                                            if (xml.GetAttribute("mappingDisabled") != null && bool.Parse(xml.GetAttribute("mappingDisabled")))
                                                                _project.Songs[song.SongQb.Id.Crc].IsMappingDisabled = true;
                                                            else
                                                            {
                                                                if (!xml.IsEmptyElement)
                                                                    loadSongFragment(pDir, xml, song);
                                                                else
                                                                    song = null;

                                                                //add the song settings
                                                                if (song != null)
                                                                    _project.Songs[song.SongQb.Id.Crc].Song = song;
                                                            }
                                                        }

                                                    }
                                                    else if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "Songs")
                                                        break;
                                                }
                                                #endregion
                                                break;
                                        }
                                        if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "TheGHOST_ProjectSettings")
                                            break;

                                    }
                                }
                                #endregion
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new ApplicationException(string.Format("Exception loading project: {0}", ex.Message));
                }
            }
        }
Exemple #4
0
        private ListViewItem addSongToListView(ListViewGroup lg, ProjectTierSong song)
        {
            //for GH3 only get songs that are s.Key.Crc == s.Checksum.Crc - this fixes an issue with cult of personality (talk talk)
            //uint id = _project.GameInfo.Game == Game.GH3_Wii ? song.Checksum.Crc : song.Key.Crc;

            TrackMap map = new TrackMap(song.SongQb, song);
            SongQb sqb = song.SongQb;

            ListViewItem li = new ListViewItem(string.Format("{0}   -   {1}{2}{3}{4}", sqb.Artist, sqb.Title, sqb.Year.Length == 0 ? string.Empty : "   (", sqb.Year, sqb.Year.Length == 0 ? string.Empty : ")"));
            _trackList.AppendLine(string.Format("{0} - {1}{2}{3}{4}", sqb.Artist, sqb.Title, sqb.Year.Length == 0 ? string.Empty : " (", sqb.Year, sqb.Year.Length == 0 ? string.Empty : ")"));
            li.SubItems.Add(string.Empty);
            li.SubItems.Add(sqb.Id.Text);
            li.Tag = map;

            setSavedSong(li, sqb, true);

            li.Group = lg;
            lvwTracks.Items.Add(li);

            if (song.IsMappingDisabled)
                disableSongItem(li);

            return li;
        }
Exemple #5
0
 private void setEditSong(ProjectTierSong pts)
 {
     //add the song to the songs being edited.  TheGHOST does this after leaving the Track Select screen for all songs
     ProjectSong song = _project.CreateProjectSong(pts.SongQb, true);
     pts.Song = song;
     pts.IsEditSong = true;
 }
Exemple #6
0
 public TrackMap(SongQb songQb, ProjectTierSong tierSong)
 {
     this.SongQb = songQb;
     this.TierSong = tierSong;
     this.MappedDir = null;
 }
Exemple #7
0
        private void buildCompleteList()
        {
            try
            {
                QbKey qkKqCredits = QbKey.Create("kingsandqueenscredits");

                Dictionary<uint, SongQb> songListComplete = new Dictionary<uint, SongQb>();

                _songs = new Dictionary<uint, ProjectTierSong>();
                _tiers = new List<ProjectTier>();

                QbFile slQb = this.FileManager.SongListQbFile;
                QbItemBase permSongsQi = slQb.FindItem(QbKey.Create("permanent_songlist_props"), false);

                if (permSongsQi != null)
                {
                    permSongsQi.FindItem(false, delegate(QbItemBase item)
                    {
                        if (item.QbItemType == QbItemType.StructItemStruct)
                        {
                            SongQb s = new SongQb(this, (QbItemStruct)item);
                            if ((s.IsSetList || s.Id.Crc == qkKqCredits.Crc) && !songListComplete.ContainsKey(s.Id.Crc))
                                songListComplete.Add(s.Id.Crc, s);
                        }
                        return false; //if we return false then the search continues
                    });
                }

                int tierNo = 1;
                //career
                foreach (TierQb t in BuildTierList(this.FileManager.GuitarProgressionQbFile, QbKey.Create("GH3_Career_Songs")))
                    _tiers.Add(new ProjectTier(t, TierType.Career, tierNo++));
                //bonus
                foreach (TierQb t in BuildTierList(this.FileManager.StoreDataQbFile, QbKey.Create("GH3_Bonus_Songs")))
                    _tiers.Add(new ProjectTier(t, TierType.Bonus, tierNo++));

                int si;
                foreach (ProjectTier pt in _tiers)
                {
                    si = 1;
                    pt.Save(songListComplete);
                    foreach (ProjectTierSong pts in pt.Songs)
                    {
                        _songs.Add(pts.SongQb.Id.Crc, pts);
                        if (pt.Type == TierType.Bonus)
                            pts.IsBonusSong = true;
                        pts.Number = si++;
                    }
                }

                int gs = this.AddedGhostSongCount;
                //build a list of keys
                List<QbKey> theGhostSongs = new List<QbKey>(gs);
                for (int i = 1; i <= gs; i++)
                {
                    QbKey qk = QbKey.Create(string.Format("theghost{0}", i.ToString().PadLeft(3, '0')));

                    if (_songs.ContainsKey(qk.Crc))
                        _songs[qk.Crc].IsAddedWithTheGhost = true;
                }

                List<TierQb> quickList = BuildTierList(this.FileManager.GuitarProgressionQbFile, QbKey.Create("GH3_General_Songs")); //quickplay

                //find the non career songs or bonus
                ProjectTier ncTier = new ProjectTier(null);
                foreach (TierQb tier in quickList)
                {
                    foreach (QbKey song in tier.Songs)
                    {
                        if (!_songs.ContainsKey(song.Crc))
                        {
                            if (songListComplete.ContainsKey(song.Crc))
                            {
                                ProjectTierSong pts = new ProjectTierSong(songListComplete[song.Crc]);
                                _songs.Add(song.Crc, pts);
                                pts.Tier = ncTier;
                                ncTier.InsertSong(pts, ncTier.Songs.Count);
                            }
                            else
                            {
                            }
                        }
                    }
                }

                if (this.GameInfo.Game == Game.GHA_Wii)
                {
                    QbKey song = qkKqCredits;
                    if (!_songs.ContainsKey(song.Crc) && songListComplete.ContainsKey(song.Crc))
                    {
                        ProjectTierSong pts = new ProjectTierSong(songListComplete[song.Crc]);
                        _songs.Add(song.Crc, pts);
                        pts.Tier = ncTier;
                        ncTier.InsertSong(pts, ncTier.Songs.Count);
                    }
                }

                if (ncTier.Songs.Count != 0)
                {
                    ncTier.Type = TierType.NonCareer;
                    _tiers.Add(ncTier);
                }

                //foreach (ProjectTierSong pts in _songs.Values)
                //    System.Diagnostics.Debug.WriteLine(pts.SongQb.Id.Text);

            }
            catch
            {
                throw;
            }
        }