Inheritance: ISettingsChange
Example #1
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));
        }
Example #2
0
 /// <summary>
 /// Indicates that a notes file has been added or removed
 /// </summary>
 /// <param name="item">GH notes item</param>
 /// <param name="addedRemoved">true=Added, false=Removed</param>
 internal GhItemMapChangedEventArgs(NotesFile fromFile, uint uniqueId, GhNotesItem toItem, bool isGenerated, bool addedRemoved)
 {
     this.ToGhNotesItem = toItem;
     this.FromFile = fromFile;
     this.UniqueId = uniqueId;
     this.IsGenerated = isGenerated;
     this.AddedRemoved = addedRemoved;
 }
Example #3
0
        public void Initialise(NotesFile baseNotesInfo, GhNotesItem[] items, float hopoMeasure, bool gh3SustainClipping, string[] wavPaths)
        {
            ne.NotesInfo = baseNotesInfo;
            ne.GhNotesInfoItems.AddRange(items);
            ne.WavFilenames.AddRange(wavPaths);
            ne.HoPoMeasure = hopoMeasure;
            ne.Gh3SustainClipping = gh3SustainClipping;
            ne.Initialise();

            loadWindowInfo(this, _windowInfo);
        }
Example #4
0
        private void setGhItemInformation(NotesFile file, uint uniqueId, GhNotesItem ghItem)
        {
            ListViewItem li = null;

            foreach (ListViewItem l in lvwGh.Items)
            {
                if (l.Text == ghItem.Name)
                {
                    li = l;
                    break;
                }
            }

            int fileNo = 0;
            for (int i = 0; i < lvwFiles.Items.Count; i++)
            {
                if (lvwFiles.Items[i].Tag == file)
                {
                    fileNo = i + 1;
                    break;
                }
            }

            if (li != null && ghItem != null)
            {
                if (ghItem.IsMapped)
                {
                    li.SubItems[1].Text = ghItem.MappedFileItem.ButtonsUsed.ToString();
                    li.SubItems[2].Text = string.Concat(ghItem.MappedFileItem.NotesCount.ToString(), ghItem.MappedFileItem.HasGeneratedNotes ? " *" : string.Empty);
                    if (_song.Notes.ForceNoStarPower)
                        li.SubItems[3].Text = "0 (Forced)";
                    else
                        li.SubItems[3].Text = string.Concat(ghItem.MappedFileItem.StarPowerCount.ToString(), ghItem.MappedFileItem.HasGeneratedStarPower ? " *" : string.Empty);
                    li.SubItems[4].Text = string.Concat(ghItem.MappedFileItem.BattlePowerCount.ToString(), ghItem.MappedFileItem.HasGeneratedBattlePower ? " *" : string.Empty);
                    li.SubItems[5].Text = string.Concat((ghItem.MappedFileItem.FaceOffP1Count + ghItem.MappedFileItem.FaceOffP2Count).ToString(), ghItem.MappedFileItem.HasGeneratedFaceOff ? " *" : string.Empty);

                    string fileName = string.Format("{0} ({1})", fileNo.ToString(), (new FileInfo(file.Filename)).Extension.Substring(1));

                    if (ghItem.MappedFileItem.HasGeneratedNotes)
                        li.SubItems[6].Text = string.Format("Generated from {0} : {1}", fileName, ghItem.MappedFileItem.SourceName);
                    else
                        li.SubItems[6].Text = string.Format("{0} : {1}", fileName, ghItem.MappedFileItem.SourceName);
                    li.Tag = ghItem;
                }
                else
                {
                    li.SubItems[1].Text = string.Empty;
                    li.SubItems[2].Text = string.Empty;
                    li.SubItems[3].Text = string.Empty;
                    li.SubItems[4].Text = string.Empty;
                    li.SubItems[5].Text = string.Empty;
                    li.SubItems[6].Text = string.Empty;
                    li.Tag = null;
                }
            }
        }
Example #5
0
        private void notesFileChanged(NotesFileChangeType changeType, NotesFile notesFile)
        {
            if (changeType != NotesFileChangeType.Removed)
            {
                FileInfo fi = new FileInfo(notesFile.Filename);

                ListViewItem li = null;
                if (changeType == NotesFileChangeType.Added)
                    li = lvwFiles.Items.Add(string.Format("{0} ({1})", (lvwFiles.Items.Count + 1).ToString(), fi.Extension.Substring(1)));
                else //reloaded
                {
                    foreach (ListViewItem lvi in lvwFiles.Items)
                    {
                        if (((NotesFile)lvi.Tag).Filename.ToLower() == notesFile.Filename.ToLower())
                        {
                            li = lvi;
                            break;
                        }
                    }
                }

                if (li != null)
                {
                    li.ImageIndex = notesFile == _song.Notes.BaseFile ? 1 : 0;
                    li.ToolTipText = fi.FullName;
                    li.Tag = notesFile;  //must be set before selecting.
                    li.Selected = true;
                }
                Application.DoEvents();

                _song.Notes.SmartMap(notesFile, true);
            }
            else
            {
                int idx = -1;
                foreach (ListViewItem li in lvwFiles.Items)
                {
                    if (li.Tag == notesFile)
                    {
                        idx = li.Index;
                        break;
                    }
                }

                if (idx != -1)
                    lvwFiles.Items.RemoveAt(idx);
            }
        }
Example #6
0
 private bool findMatch(NotesFile nf, GhNotesItem ghi, NotesType type, NotesDifficulty difficulty)
 {
     string match;
     if (nf.Parser != null)
     {
         match = nf.Parser.MatchType(type, difficulty);
         if (match.Length != 0)
         {
             int j = 0;
             foreach (NotesFileItem nfi in nf.Items)
             {
                 if (!ghi.IsMapped && nfi.SourceName == match && nfi.Notes.Length > 1 * 3)
                 {
                     this.MapToGhItem(nf, nfi.UniqueId, ghi, false);
                     return true;
                 }
                 j++;
             }
         }
     }
     return false;
 }
Example #7
0
 protected void OnNotesFileChanged(NotesFile nf, NotesFileChangeType type)
 {
     if (NotesFileChanged != null)
         NotesFileChanged(this, new NotesFileChangedEventArgs(nf, type));
 }
Example #8
0
        protected void OnGhItemMapChanged(NotesFile fromFile, uint uniqueId, GhNotesItem toItem, bool isGenerated, bool addedRemoved)
        {
            if (GhItemMapChanged != null)
                GhItemMapChanged(this, new GhItemMapChangedEventArgs(fromFile, uniqueId, toItem, isGenerated, addedRemoved));

            this.LastChanged = DateTime.Now;
            this.UpdateAffectsAudio = true;
        }
Example #9
0
        public void RemoveFile(NotesFile file)
        {
            foreach(GhNotesItem gi in this.GhItems)
            {
                if (gi.IsMapped && gi.MappedFile == file)
                    this.UnMapGhItem(gi);
            }
            _files.Remove(file);

            if (file == _song.Notes.BaseFile)
            {
                if (_song.Notes.Files.Length == 0)
                    _song.Notes.BaseFile = null;
                else
                    _song.Notes.BaseFile = _song.Notes.Files[0];
            }

            OnNotesFileChanged(file, NotesFileChangeType.Removed);
        }
Example #10
0
        public void ReloadFile(NotesFile file)
        {
            foreach (GhNotesItem gi in this.GhItems)
            {
                if (gi.IsMapped && gi.MappedFile == file)
                    this.UnMapGhItem(gi);
            }

            for (int i = 0; i < _files.Count; i++)
            {
                if (_files[i] == file)
                {
                    file = this.ParseFile(file.Filename);
                    _files[i] = file;
                    break;
                }
            }
        }
Example #11
0
        public NotesFile ParseFile(string filename)
        {
            bool alreadyAdded = false;

            if (_files.Exists(delegate(NotesFile nfl)
            {
                return (nfl.Filename.ToLower() == filename.ToLower());
            }))
            {
                alreadyAdded = true;
            }

            FileInfo fi = new FileInfo(filename);

            INotesParser np = null;
            NotesFile nf = null;

            if (fi.Extension.ToLower() == ".chart")
                np = new Chart();
            else if (fi.Extension.ToLower() == ".mid")
                np = new Mid();

            if (np != null)
            {
                nf = new NotesFile(np, fi.FullName, _song.Length, _project.Defaults.Gh3SustainClipping);
                if (!alreadyAdded)
                    this.AddFile(nf);

                //set the base file
                if (_baseFile == null)
                    _baseFile = nf;

                this.LastChanged = DateTime.Now;

                OnNotesFileChanged(nf, alreadyAdded ? NotesFileChangeType.Reloaded : NotesFileChangeType.Added);

                return nf;
            }
            else
                throw new ApplicationException("Unrecognised notes format");
        }
Example #12
0
        /// <summary>
        /// Map the missing GH3 items to other difficulties
        /// </summary>
        //public void AutoMapMissing()
        //{
        //    foreach (GhNotesItem ghi in this.GhItems)
        //    {
        //        if (!ghi.IsMapped)
        //        {
        //            foreach (NotesFile nf in this.Files)
        //            {
        //                //loop up to expert
        //                for (int i = (int)ghi.Difficulty; i <= (int)NotesDifficulty.Expert; i++)
        //                    findMatch(nf, ghi, (NotesDifficulty)i);
        //                if (ghi.IsMapped)
        //                    break;
        //                //loop down to easy
        //                for (int i = ((int)ghi.Difficulty) - 1; i >= (int)NotesDifficulty.Easy; i--)
        //                    findMatch(nf, ghi, (NotesDifficulty)i);
        //                if (ghi.IsMapped)
        //                    break;
        //            }
        //            if (ghi.IsMapped)
        //                continue;
        //        }
        //    }
        //}
        public void MapToGhItem(NotesFile fromFile, uint uniqueId, GhNotesItem toItem, bool isGenerated)
        {
            toItem.IsMapped = true;
            toItem.MappedFile = fromFile;
            toItem.MappedFileItem = fromFile.FindItem(uniqueId);

            this.LastChanged = DateTime.Now;
            this.UpdateAffectsAudio = true;

            //Raise an event
            this.OnGhItemMapChanged(fromFile, uniqueId, toItem, isGenerated, false);
        }
Example #13
0
 public void AddFile(NotesFile file)
 {
     _files.Add(file);
 }
Example #14
0
 internal NotesFileItem(string sourceName, NotesFile baseFile, NotesFileItem sourceItem, NotesDifficulty sourceDifficulty, NotesDifficulty difficulty)
 {
     this.construct(sourceName, new int[0], new int[0], new int[0], new int[0], new int[0], sourceItem.SustainTrigger);
     this.GenerateNotes(baseFile.Frets, difficulty, sourceItem.Notes, sourceItem.StarPower, sourceItem.BattlePower, sourceDifficulty);
 }
Example #15
0
        public void SmartMap(NotesFile nf, bool exactMatch)
        {
            int idx = 0;

            foreach (GhNotesItem ghi in _ghItems)
            {
                if (!findMatch(nf, ghi, ghi.Type, ghi.Difficulty) && !exactMatch)
                {
                    if (ghi.Type == NotesType.RhythmCoop)
                        findMatch(nf, ghi, NotesType.Rhythm, ghi.Difficulty);

                    if (!ghi.IsMapped)
                        findMatch(nf, ghi, NotesType.Guitar, ghi.Difficulty);

                    if (!ghi.IsMapped)
                        findMatch(nf, ghi, NotesType.Rhythm, ghi.Difficulty);
                }
                idx++;
            }
        }
 /// <summary>
 /// Indicates that a notes file has been added or removed
 /// </summary>
 /// <param name="notesFile">Notes File</param>
 /// <param name="addedRemoved">true=Added, false=Removed</param>
 internal NotesFileChangedEventArgs(NotesFile notesFile, NotesFileChangeType changeType)
 {
     this.NotesFile = notesFile;
     this.ChangeType = changeType;
 }
Example #17
0
 public void GenerateNotes(NotesFile baseFile, GhNotesItem sourceItem)
 {
     this.IsMapped = true;
     this.MappedFile = sourceItem.MappedFile;
     this.MappedFileItem = new NotesFileItem(sourceItem.MappedFileItem.SourceName, baseFile, sourceItem.MappedFileItem, sourceItem.Difficulty, this.Difficulty);
     this.MappedFileItem.NotesGeneratedFrom = string.Format("{0} : {1}", sourceItem.Type.ToString(), sourceItem.Difficulty.ToString());
     this.MappedFileItem.UniqueId = sourceItem.MappedFileItem.UniqueId;
     this.MappedFileItem.SyncOffset = sourceItem.MappedFileItem.SyncOffset;
     this.MappedFileItem.LastChanged = DateTime.Now;
 }