Inheritance: ISettingsChange
Esempio n. 1
0
        public void SetSong(ProjectSong song)
        {
            _song = song;

            if (_song != null)
            {
                setTitle();

                _song.Title = _song.Title;
                _song.Artist = _song.Artist;
                _song.Year = _song.Year;

                //proxy class for the GUI, the core doesn't know about the interface objects
                _trackProperties = new TrackProperties(_song);

                pgdSong.SelectedObject = _trackProperties;

                _song.Audio.AudioFileChanged += new AudioFileChangedEventHandler(Audio_AudioFileChanged);
                _song.Audio.PreviewSettingsChanged += new PreviewSettingsChangedEventHandler(Audio_PreviewSettingsChanged);

                //Change track details and preview
                foreach (AudioFile af in _song.Audio.SongFiles)
                    audioFileChanged("song", af.Name, true);
                if (_song.Audio.GuitarFile != null && _song.Audio.GuitarFile.Name.Length != 0)
                    audioFileChanged("guitar", _song.Audio.GuitarFile.Name, true);
                if (_song.Audio.RhythmFile != null && _song.Audio.RhythmFile.Name.Length != 0)
                    audioFileChanged("rhythm", _song.Audio.RhythmFile.Name, true);

                setPreviewSettings();

            }
        }
Esempio n. 2
0
        public void SetSong(ProjectSong song)
        {
            _song = song;

            if (_song != null)
            {
                _song.Notes.GhItemMapChanged += new GhItemMapChangedEventHandler(Notes_GhItemMapChanged);
                _song.Notes.NotesFileChanged += new NotesFileChangedEventHandler(Notes_NotesFileChanged);

                setTitle();

                _notesDragUniqueId = 0;

                foreach (GhNotesItem gii in _song.Notes.GhItems)
                    addGhItem(gii);

                _ghItems = _song.Notes.GhItems; //hold a local copy

                //populate any already configured notes files
                foreach (NotesFile nf in _song.Notes.Files)
                    notesFileChanged(NotesFileChangeType.Added, nf);

                refreshMappedItemInformation();

                udDelaySeconds.Value = (decimal)(_song.MinMsBeforeNotesStart / 1000F);
            }
        }
Esempio n. 3
0
        private bool _updateAffectsAudio; //set to true when a change required the audio to be updated (to be safe)

        #endregion Fields

        #region Constructors

        internal ProjectSongNotes(Project project, ProjectSong song)
        {
            _lastChanged = DateTime.MinValue;
            _recordChange = false;

            _project = project;
            _song = song;
            _baseFile = null;
            _updateAffectsAudio = false;

            string songName = _song.SongQb.Id.Text;

            _ghItems = new List<GhNotesItem>();
            _files = new List<NotesFile>();

            _ghItems.Add(new GhNotesItem("Easy", NotesType.Guitar, NotesDifficulty.Easy, songName));
            _ghItems.Add(new GhNotesItem("Medium", NotesType.Guitar, NotesDifficulty.Medium, songName));
            _ghItems.Add(new GhNotesItem("Hard", NotesType.Guitar, NotesDifficulty.Hard, songName));
            _ghItems.Add(new GhNotesItem("Expert", NotesType.Guitar, NotesDifficulty.Expert, songName));
            _ghItems.Add(new GhNotesItem("Easy Rhythm", NotesType.Rhythm, NotesDifficulty.Easy, songName));
            _ghItems.Add(new GhNotesItem("Medium Rhythm", NotesType.Rhythm, NotesDifficulty.Medium, songName));
            _ghItems.Add(new GhNotesItem("Hard Rhythm", NotesType.Rhythm, NotesDifficulty.Hard, songName));
            _ghItems.Add(new GhNotesItem("Expert Rhythm", NotesType.Rhythm, NotesDifficulty.Expert, songName));
            //_ghItems.Add(new GhNotesItem("Easy Co Op", NotesType.GuitarCoop, NotesDifficulty.Easy, songName));
            //_ghItems.Add(new GhNotesItem("Medium Co Op", NotesType.GuitarCoop, NotesDifficulty.Medium, songName));
            //_ghItems.Add(new GhNotesItem("Hard Co Op", NotesType.GuitarCoop, NotesDifficulty.Hard, songName));
            //_ghItems.Add(new GhNotesItem("Expert Co Op", NotesType.GuitarCoop, NotesDifficulty.Expert, songName));
            //_ghItems.Add(new GhNotesItem("Easy Rhythm Co Op", NotesType.RhythmCoop, NotesDifficulty.Easy, songName));
            //_ghItems.Add(new GhNotesItem("Medium Rhythm Co Op", NotesType.RhythmCoop, NotesDifficulty.Medium, songName));
            //_ghItems.Add(new GhNotesItem("Hard Rhythm Co Op", NotesType.RhythmCoop, NotesDifficulty.Hard, songName));
            //_ghItems.Add(new GhNotesItem("Expert Rhythm Co Op", NotesType.RhythmCoop, NotesDifficulty.Expert, songName));
        }
Esempio n. 4
0
 public TrackEditScreen()
 {
     InitializeComponent();
     _song = null;
     _lastAudioLen = 0;
     tmrPreview.Enabled = false;
     tmrPreview.Interval = 500;
     _importingAudio = false;
     _settingVolume = false;
     _startVolumes = null;
 }
Esempio n. 5
0
 internal TrackProperties(ProjectSong song)
 {
     _song = song;
 }
Esempio n. 6
0
        private void saveSongFragment(DirectoryInfo pDir, XmlWriter xml, ProjectSong ps, string version, string filename)
        {
            bool b = (filename != null && filename.Length != 0);
            if (b)
            {
                try
                {
                    FileHelper.Delete(filename);
                    xml = XmlWriter.Create(filename, xml.Settings);
                    xml.WriteComment("This is a copy of the settings from the project file.  This file can be imported with TheGHOST using Smart Mode");
                }
                catch
                {
                    return; //skip this
                }
            }

            xml.WriteStartElement("Song");
            if (!b)
            {
                //xml.WriteAttributeString("id", ps.SongQb.Id.Text);
                xml.WriteAttributeString("lastApplied", ps.LastApplied.ToString("s"));
            }
            else
                xml.WriteAttributeString("version", version);

            #region QbSettings
            xml.WriteStartElement("QbSettings");
            xml.WriteAttributeString("artist", ps.Artist);
            xml.WriteAttributeString("title", ps.Title);
            xml.WriteAttributeString("year", ps.Year);
            xml.WriteAttributeString("singer", ps.Singer.ToString());
            xml.WriteAttributeString("guitarVolume", ps.GuitarVolume.ToString());
            xml.WriteAttributeString("songVolume", ps.SongVolume.ToString());
            xml.WriteAttributeString("lastChanged", ps.QbLastChanged.ToString("s"));
            xml.WriteEndElement(); //QbSettings
            #endregion

            #region Notes
            xml.WriteStartElement("Notes");
            xml.WriteAttributeString("minMsBeforeStart", ps.MinMsBeforeNotesStart.ToString());
            xml.WriteAttributeString("hoPoMeasure", ps.Notes.HoPoMeasure.ToString());
            xml.WriteAttributeString("gh3SustainClipping", ps.Notes.Gh3SustainClipping.ToString());
            xml.WriteAttributeString("forceNoStarPower", ps.Notes.ForceNoStarPower.ToString());
            xml.WriteAttributeString("lastChanged", ps.Notes.LastChanged.ToString("s"));

            xml.WriteStartElement("NotesFiles");
            foreach (NotesFile nf in ps.Notes.Files)
            {
                xml.WriteStartElement("NotesFile");
                if (ps.Notes.BaseFile == nf)
                    xml.WriteAttributeString("baseFile", true.ToString());
                xml.WriteAttributeString("nonNoteSyncOffset", nf.NonNoteSyncOffset.ToString());
                xml.WriteStartElement("Filename");
                xml.WriteString(pathAbsToRel(nf.Filename, pDir, b));
                xml.WriteEndElement(); //Filename
                xml.WriteStartElement("Items");
                foreach (NotesFileItem nfi in nf.Items)
                {
                    xml.WriteStartElement("Item");
                    xml.WriteAttributeString("id", nfi.UniqueId.ToString());
                    xml.WriteAttributeString("name", nfi.SourceName);
                    xml.WriteAttributeString("syncOffset", nfi.SyncOffset.ToString());
                    xml.WriteEndElement(); //Item
                }
                xml.WriteEndElement(); //Items
                xml.WriteEndElement(); //NotesFile
            }
            xml.WriteEndElement(); //NotesFiles

            xml.WriteStartElement("MappedItems");
            foreach (GhNotesItem ghi in ps.Notes.GhItems)
            {
                xml.WriteStartElement("MappedItem");
                xml.WriteAttributeString("name", ghi.Name);
                if (ghi.IsMapped)
                {
                    if (ghi.MappedFileItem != null)
                        xml.WriteAttributeString("mapToItemId", ghi.MappedFileItem.UniqueId.ToString());
                    xml.WriteAttributeString("syncOffset", ghi.MappedFileItem.SyncOffset.ToString());
                    xml.WriteAttributeString("hasGeneratedBattlePower", ghi.MappedFileItem.HasGeneratedBattlePower.ToString());
                    xml.WriteAttributeString("hasGeneratedFaceOff", ghi.MappedFileItem.HasGeneratedFaceOff.ToString());
                    xml.WriteAttributeString("hasGeneratedStarPower", ghi.MappedFileItem.HasGeneratedStarPower.ToString());
                    xml.WriteAttributeString("hasGeneratedNotes", ghi.MappedFileItem.HasGeneratedNotes.ToString());
                }
                xml.WriteEndElement(); //MappedItem
            }
            xml.WriteEndElement(); //MappedItems

            xml.WriteEndElement(); //Notes
            #endregion

            #region Audio
            xml.WriteStartElement("Audio");
            xml.WriteAttributeString("lastChanged", ps.Audio.LastChanged.ToString("s"));

            xml.WriteStartElement("Preview");
            xml.WriteAttributeString("start", ps.Audio.PreviewStart.ToString());
            xml.WriteAttributeString("length", ps.Audio.PreviewLength.ToString());
            xml.WriteAttributeString("fadeLength", ps.Audio.PreviewFadeLength.ToString());
            xml.WriteAttributeString("volume", ps.Audio.PreviewVolume.ToString());
            xml.WriteAttributeString("includeGuitar", ps.Audio.PreviewIncludeGuitar.ToString());
            xml.WriteAttributeString("includeRhythm", ps.Audio.PreviewIncludeRhythm.ToString());
            xml.WriteEndElement(); //Preview

            xml.WriteStartElement("AudioFiles");
            xml.WriteAttributeString("length", ps.Audio.AudioLength.ToString());

            if (ps.Audio.SongFiles.Count != 0)
            {
                foreach (AudioFile af in ps.Audio.SongFiles)
                {
                    xml.WriteStartElement("AudioFile");
                    xml.WriteAttributeString("type", "song");
                    xml.WriteAttributeString("volume", af.Volume.ToString());
                    xml.WriteString(pathAbsToRel(af.Name, pDir, b));
                    xml.WriteEndElement(); //AudioFile
                }
            }
            else
            {
                xml.WriteStartElement("AudioFile");
                xml.WriteAttributeString("type", "song");
                xml.WriteAttributeString("volume", "100");
                xml.WriteString(string.Empty);
                xml.WriteEndElement(); //AudioFile
            }

            xml.WriteStartElement("AudioFile");
            xml.WriteAttributeString("type", "guitar");
            xml.WriteAttributeString("volume", (ps.Audio.GuitarFile == null || ps.Audio.GuitarFile.Name.Length == 0) ? "100" : ps.Audio.GuitarFile.Volume.ToString());
            xml.WriteString(ps.Audio.GuitarFile == null ? string.Empty : pathAbsToRel(ps.Audio.GuitarFile.Name, pDir, b));
            xml.WriteEndElement(); //AudioFile

            xml.WriteStartElement("AudioFile");
            xml.WriteAttributeString("type", "rhythm");
            xml.WriteAttributeString("volume", (ps.Audio.RhythmFile == null || ps.Audio.RhythmFile.Name.Length == 0) ? "100" : ps.Audio.RhythmFile.Volume.ToString());
            xml.WriteString(ps.Audio.RhythmFile == null ? string.Empty : pathAbsToRel(ps.Audio.RhythmFile.Name, pDir, b));
            xml.WriteEndElement(); //AudioFile
            xml.WriteEndElement(); //AudioFiles

            xml.WriteEndElement(); //Audio
            #endregion

            xml.WriteEndElement(); //Song

            if (b)
                xml.Close();
        }
Esempio n. 7
0
        private void loadSongFragment(DirectoryInfo pDir, XmlReader xml, ProjectSong song)
        {
            DateTime qbLastChanged = DateTime.MinValue;
            while (!xml.EOF && xml.Read())
            {
                switch (xml.Name)
                {
                    case "QbSettings":
                        #region QbSettings
                        song.Artist = xml.GetAttribute("artist");
                        song.Title = xml.GetAttribute("title");
                        song.Year = xml.GetAttribute("year");
                        song.Singer = (Singer)Enum.Parse(typeof(Singer), xml.GetAttribute("singer"));
                        song.GuitarVolume = float.Parse(xml.GetAttribute("guitarVolume"));
                        song.SongVolume = float.Parse(xml.GetAttribute("songVolume"));
                        qbLastChanged = DateTime.Parse(xml.GetAttribute("lastChanged"), null, System.Globalization.DateTimeStyles.AssumeLocal);
                        #endregion
                        break;
                    case "Notes":
                        #region Notes
                        List<MapSetting> genItems = new List<MapSetting>();

                        song.MinMsBeforeNotesStart = int.Parse(xml.GetAttribute("minMsBeforeStart"));
                        song.Notes.HoPoMeasure = float.Parse(xml.GetAttribute("hoPoMeasure"));
                        song.Notes.Gh3SustainClipping = bool.Parse(xml.GetAttribute("gh3SustainClipping"));
                        song.Notes.ForceNoStarPower = xml.GetAttribute("forceNoStarPower") == null ? false : bool.Parse(xml.GetAttribute("forceNoStarPower"));
                        DateTime notesLastChanged = DateTime.Parse(xml.GetAttribute("lastChanged"), null, System.Globalization.DateTimeStyles.AssumeLocal);

                        while (!xml.EOF && xml.Read())
                        {
                            //skip NotesFiles and MappedItems elements and process the children
                            switch (xml.Name)
                            {
                                case "NotesFile":
                                    #region NotesFile
                                    bool baseFile = xml.GetAttribute("baseFile") == null ? false : bool.Parse(xml.GetAttribute("baseFile"));
                                    int nonNoteSyncOffset = int.Parse(xml.GetAttribute("nonNoteSyncOffset"));
                                    NotesFile nf = null;
                                    while (!xml.EOF && xml.Read())
                                    {
                                        switch (xml.Name)
                                        {
                                            case "Filename":
                                                nf = song.Notes.ParseFile(pathRelToAbs(xml.ReadString(), pDir));
                                                if (baseFile)
                                                    song.Notes.BaseFile = nf;
                                                nf.NonNoteSyncOffset = nonNoteSyncOffset;
                                                break;
                                            case "Item": //ignore the Items tag

                                                string sourceName = xml.GetAttribute("name");
                                                foreach (NotesFileItem nfi in nf.Items)
                                                {
                                                    if (nfi.SourceName == sourceName)
                                                    {
                                                        nfi.UniqueId = uint.Parse(xml.GetAttribute("id"));
                                                        nfi.SyncOffset = int.Parse(xml.GetAttribute("syncOffset"));
                                                        break;
                                                    }
                                                }
                                                break;
                                        }
                                        if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "NotesFile")
                                            break;

                                    }
                                    #endregion
                                    break;
                                case "MappedItem": //ignore mapped items
                                    #region MappedItem
                                    string mapName = xml.GetAttribute("name");

                                    foreach (GhNotesItem ghi in song.Notes.GhItems)
                                    {
                                        if (ghi.Name == mapName)
                                        {
                                            uint mapId;
                                            //item is mapped
                                            if (xml.GetAttribute("mapToItemId") != null)
                                            {
                                                mapId = uint.Parse(xml.GetAttribute("mapToItemId"));

                                                int syncOffset = xml.GetAttribute("syncOffset") == null ? 0 : int.Parse(xml.GetAttribute("syncOffset"));
                                                bool genNotes = bool.Parse(xml.GetAttribute("hasGeneratedNotes"));
                                                bool genSP = bool.Parse(xml.GetAttribute("hasGeneratedStarPower"));
                                                bool genBP = bool.Parse(xml.GetAttribute("hasGeneratedBattlePower"));
                                                bool genFO = bool.Parse(xml.GetAttribute("hasGeneratedFaceOff"));
                                                if (!genNotes)
                                                {
                                                    foreach (NotesFile nfl in song.Notes.Files)
                                                    {
                                                        if (nfl.FindItem(mapId) != null)
                                                        {
                                                            song.Notes.MapToGhItem(nfl, mapId, ghi, false);

                                                            if (genSP || genBP || genFO)
                                                                song.Notes.GenerateNotes(ghi, false, genSP, genBP, genFO, true);
                                                            break;
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    genItems.Add(new MapSetting(syncOffset, genSP, genFO, genBP, genNotes, mapId, ghi));
                                                }
                                            }
                                            break;
                                        }
                                    }
                                    #endregion
                                    break;
                            }
                            if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "Notes")
                                break;
                        }
                        //must map the generated notes after all the direct mapping have been made
                        foreach (MapSetting mi in genItems)
                        {
                            foreach (GhNotesItem ghi in song.Notes.GhItems)
                            {
                                if (ghi.IsMapped && !ghi.MappedFileItem.HasGeneratedNotes && ghi.MappedFileItem.UniqueId == mi.UniqueId)
                                {
                                    mi.GhItem.GenerateNotes(song.Notes.BaseFile, ghi);
                                    mi.GhItem.MappedFileItem.SyncOffset = mi.SyncOffset;
                                    if (mi.GenSP || mi.GenBP || mi.GenFO)
                                        song.Notes.GenerateNotes(mi.GhItem, false, mi.GenSP, mi.GenBP, mi.GenFO, true);
                                    break;
                                }
                            }
                        }
                        ((ISettingsChange)song.Notes).RecordChange();
                        song.Notes.LastChanged = notesLastChanged;
                        #endregion
                        break;
                    case "Audio":
                        #region Audio
                        DateTime audioLastChanged = DateTime.Parse(xml.GetAttribute("lastChanged"), null, System.Globalization.DateTimeStyles.AssumeLocal);

                        while (!xml.EOF && xml.Read())
                        {
                            if (xml.NodeType == XmlNodeType.Element && xml.Name == "Preview")
                            {
                                song.Audio.PreviewStart = int.Parse(xml.GetAttribute("start"));
                                song.Audio.PreviewLength = int.Parse(xml.GetAttribute("length"));
                                song.Audio.PreviewFadeLength = int.Parse(xml.GetAttribute("fadeLength"));
                                song.Audio.PreviewVolume = int.Parse(xml.GetAttribute("volume"));
                                song.Audio.PreviewIncludeGuitar = bool.Parse(xml.GetAttribute("includeGuitar"));
                                song.Audio.PreviewIncludeRhythm = bool.Parse(xml.GetAttribute("includeRhythm"));
                            }
                            else if (xml.NodeType == XmlNodeType.Element && xml.Name == "AudioFiles")
                            {
                                if (xml.GetAttribute("length") != null)
                                    song.Audio.AudioLength = int.Parse(xml.GetAttribute("length"));
                            }
                            else if (xml.NodeType == XmlNodeType.Element && xml.Name == "AudioFile")
                            {
                                string t = xml.GetAttribute("type");
                                int vol = 100;
                                if (xml.GetAttribute("volume") != null)
                                    vol = int.Parse(xml.GetAttribute("volume"));
                                string fn = pathRelToAbs(xml.ReadString(), pDir);
                                switch (t)
                                {
                                    case "song":
                                        if (fn.Trim().Length != 0)
                                            song.Audio.SongFiles.Add(song.Audio.CreateAudioFile(fn, vol));
                                        break;
                                    case "guitar":
                                        song.Audio.GuitarFile = fn == null || fn.Trim().Length == 0 ? null : song.Audio.CreateAudioFile(fn, vol);
                                        break;
                                    case "rhythm":
                                        song.Audio.RhythmFile = fn == null || fn.Trim().Length == 0 ? null : song.Audio.CreateAudioFile(fn, vol);
                                        break;
                                }
                            }
                            else if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "Audio")
                                break;
                        }

                        ((ISettingsChange)song.Audio).RecordChange();
                        song.Audio.LastChanged = audioLastChanged;
                        #endregion
                        break;
                }
                if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "Song")
                {
                    ((ISettingsChange)song).RecordChange();
                    song.QbLastChanged = qbLastChanged;
                    break;
                }
            }
        }
Esempio n. 8
0
        internal void LoadSongXmlSettings(string filename, ProjectSong song)
        {
            DirectoryInfo sDir = (new FileInfo(filename)).Directory;

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

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

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

                while (!xml.EOF && xml.Read())
                {
                    if (xml.Name == "Song")
                        loadSongFragment(sDir, xml, song);
                }
            }
        }
Esempio n. 9
0
 public NotesEditScreen()
 {
     InitializeComponent();
     _song = null;
 }
Esempio n. 10
0
 public ProjectSong CreateProjectSong(SongQb songQb, bool recordChange)
 {
     ProjectSong ps = new ProjectSong(this, songQb);
     if (recordChange)
         ((ISettingsChange)ps).RecordChange();
     return ps;
 }