public void CopyTo(CopyPatternPreset item)
 {
     item.Name = Name;
     item.ForwardOnly = ForwardOnly;
     item.MatchLengths5 = MatchLengths5;
     item.MatchLengths6 = MatchLengths6;
     item.MatchSpacing = MatchSpacing;
     item.MatchBeat = MatchBeat;
     item.KeepLengths = KeepLengths;
     item.FirstMatchOnly = FirstMatchOnly;
     item.RemoveExisting = RemoveExisting;
 }
示例#2
0
 public void CopyTo(CopyPatternPreset item)
 {
     item.Name           = Name;
     item.ForwardOnly    = ForwardOnly;
     item.MatchLengths5  = MatchLengths5;
     item.MatchLengths6  = MatchLengths6;
     item.MatchSpacing   = MatchSpacing;
     item.MatchBeat      = MatchBeat;
     item.KeepLengths    = KeepLengths;
     item.FirstMatchOnly = FirstMatchOnly;
     item.RemoveExisting = RemoveExisting;
 }
        private void LoadSettingConfiguration()
        {
            if (settings == null)
            {
                settings = new SettingMgr();
            }
            settings.LoadSettings();

            checkBoxAutoSelectNext.Checked = settings.GetValueBool("checkBoxAutoSelectNext", true);
            checkBatchOpenWhenCompleted.Checked = settings.GetValueBool("checkBatchOpenWhenCompleted", true);
            checkBoxBatchCopyUSB.Checked = settings.GetValueBool("checkBoxBatchCopyUSB", false);
            checkBatchCopyTextEvents.Checked = settings.GetValueBool("checkBatchCopyTextEvents", true);
            checkBatchGenerateTrainersIfNone.Checked = settings.GetValueBool("checkBatchGenerateTrainersIfNone", true);

            textBoxUSBFolder.Text = settings.GetValue("textBoxUSBFolder");

            DefaultConFileLocation = settings.GetValue("textBoxDefaultCONFileLocation");
            DefaultMidiFileLocationG5 = settings.GetValue("textBoxDefaultMidi5FileLocation");
            DefaultMidiFileLocationPro = settings.GetValue("textBoxDefaultMidiProFileLocation");
            checkBoxShow108.Checked = settings.GetValueBool("checkBoxShow108", false);

            textBoxZoom.Text = settings.GetValue("textBoxZoom", textBoxZoom.Text);
            Utility.timeScalarZoomSpeed = settings.GetValue("timeScalarZoomSpeed", Utility.timeScalarZoomSpeed.ToStringEx()).ToDouble(10);

            checkUseDefaultFolders.Checked = settings.GetValueBool("useDefaultFolders", true);
            checkBoxInitSelectedTrackOnly.Checked = settings.GetValueBool("checkBoxInitSelectedTrackOnly", false);
            checkBoxInitSelectedDifficultyOnly.Checked = settings.GetValueBool("checkBoxInitSelectedDifficultyOnly", false);

            checkKeepSelection.Checked = settings.GetValueBool("checkKeepSelection", true);
            checkBoxClearAfterNote.Checked = settings.GetValueBool("checkBoxClearAfterNote", false);
            checkRealtimeNotes.Checked = settings.GetValueBool("checkRealtimeNotes", false);
            checkTwoNotePowerChord.Checked = settings.GetValueBool("checkTwoNotePowerChord", false);
            checkThreeNotePowerChord.Checked = settings.GetValueBool("checkThreeNotePowerChord", false);
            checkChordMode.Checked = settings.GetValueBool("checkChordMode", false);
            checkScrollToSelection.Checked = settings.GetValueBool("checkScrollToSelection", true);
            checkKBQuickEdit.Checked = settings.GetValueBool("checkKBQuickEdit", true);
            checkIndentBString.Checked = settings.GetValueBool("checkIndentBString", false);
            checkBoxSearchByNoteType.Checked = settings.GetValueBool("checkBoxSearchByNoteType", true);
            checkBoxSearchByNoteStrum.Checked = settings.GetValueBool("checkBoxSearchByNoteStrum", true);
            checkBoxSearchByNoteFret.Checked = settings.GetValueBool("checkBoxSearchByNoteFret", true);
            checkBoxKeepLengths.Checked = settings.GetValueBool("checkBoxSetLengths5", true);
            checkMatchBeat.Checked = settings.GetValueBool("checkMatchBeat", true);
            checkBoxMatchLengths.Checked = settings.GetValueBool("checkBoxMatchLengths", true);
            checkBoxMatchLength6.Checked = settings.GetValueBool("checkBoxMatchLength6", true);
            checkBoxMatchSpacing.Checked = settings.GetValueBool("checkBoxMatchSpacing", true);
            checkBoxMatchForwardOnly.Checked = settings.GetValueBool("checkBoxMatchForwardOnly", false);
            checkBoxFirstMatchOnly.Checked = settings.GetValueBool("checkBoxFirstMatchOnly", false);
            checkBoxShowMidiChannelEdit.Checked = settings.GetValueBool("checkBoxShowMidiChannelEdit", true);

            textBoxTempoNumerator.Text = settings.GetValue("textBoxTempoNumerator", "4");
            textBoxTempoDenominator.Text = settings.GetValue("textBoxTempoDenominator", "4");

            checkBoxUseCurrentChord.Checked = settings.GetValueBool("checkUseCurrentChord", true);
            checkBoxAllowOverwriteChord.Checked = settings.GetValueBool("checkAllowOverwriteChord", true);
            textBoxPlaceNoteFret.Text = settings.GetValue("textBoxPlaceNoteFret", "0");

            checkBoxGridSnap.Checked = settings.GetValueBool("checkBoxGridSnap", true);
            checkSnapToCloseG5.Checked = settings.GetValueBool("checkSnapToCloseG5", true);

            checkBoxCreateArpeggioHelperNotes.Checked = settings.GetValueBool("checkBoxCreateArpeggioHelperNotes", true);

            checkViewNotesGridPro.Checked = settings.GetValueBool("checkViewNotesGrid", true);
            checkViewNotesGrid5Button.Checked = settings.GetValueBool("checkViewNotesGrid5", true);
            textBoxCopyAllCONFolder.Text = settings.GetValue("textBoxCopyAllCONFolder");
            textBoxMinimumNoteWidth.Text = settings.GetValue("textBoxMinimumNoteWidth", "0");
            textBoxCopyAllProFolder.Text = settings.GetValue("textBoxCopyAllProFolder");
            textBoxCopyAllG5MidiFolder.Text = settings.GetValue("textBoxCopyAllG5MidiFolder");
            checkBoxMidiPlaybackScroll.Checked = settings.GetValueBool("checkBoxMidiPlaybackScroll", true);
            CheckMinimumNoteWidth();
            SetGridScalar(settings.GetValue("gridScalar", "0.25"));
            textBoxScrollToSelectionOffset.Text = settings.GetValue("textBoxScrollToSelectionOffset", Utility.ScollToSelectionOffset.ToString());
            checkBoxMultiSelectionSongList.Checked = settings.GetValueBool("checkBoxMultiSelectionSongList", false);
            checkBoxSkipGenIfEasyNotes.Checked = settings.GetValueBool("checkBoxSkipGenIfEasyNotes", false);
            checkGenDiffCopyGuitarToBass.Checked = settings.GetValueBool("checkGenDiffCopyGuitarToBass", true);
            checkBoxLoadLastSongStartup.Checked = settings.GetValueBool("checkBoxLoadLastSongStartup", true);
            resetTime = settings.GetValueInt("textClearHoldBox", 1);
            textClearHoldBox.Text = resetTime.ToString();
            checkBoxEnableMidiInput.Checked = settings.GetValueBool("checkBoxEnableMidiInput", false);
            checkBoxEnableClearTimer.Checked = settings.GetValueBool("checkBoxEnableClearTimer", true);
            checkBoxPlayMidiStrum.Checked = settings.GetValueBool("checkBoxPlayMidiStrum", false);
            checkBoxClearIfNoFrets.Checked = settings.GetValueBool("checkBoxClearIfNoFrets", true);
            checkBoxChordStrum.Checked = settings.GetValueBool("checkBoxChordStrum", false);
            checkBoxMidiInputStartup.Checked = settings.GetValueBool("checkBoxMidiInputStartup", true);
            checkView5Button.Checked = settings.GetValueBool("checkView5Button", true);

            Utility.NoteCloseWidth = settings.GetValueInt("textBoxNoteCloseDist", 8);
            textBoxNoteCloseDist.Text = Utility.NoteCloseWidth.ToString();
            checkBoxBatchCheckCON.Checked = settings.GetValueBool("checkBoxBatchCheckCON", true);
            checkBoxBatchGenerateDifficulties.Checked = settings.GetValueBool("checkBoxBatchGenerateDifficulties", true);
            checkBoxBatchGuitarBassCopy.Checked = settings.GetValueBool("checkBoxBatchGuitarBassCopy", true);
            checkBoxBatchRebuildCON.Checked = settings.GetValueBool("checkBoxBatchRebuildCON", true);

            checkBoxMatchAllFrets.Checked = settings.GetValueBool("checkBoxMatchAllFrets", true);
            checkBoxCompressAllInDefaultCONFolder.Checked = settings.GetValueBool("checkBoxCompressAllInDefaultCONFolder", true);

            textBoxCompressAllZipFile.Text = settings.GetValue("textBoxCompressAllZipFile");
            checkBoxRenderMouseSnap.Checked = settings.GetValueBool("checkBoxRenderMouseSnap", false);

            checkBoxSnapToCloseNotes.Checked = settings.GetValueBool("checkBoxSnapToCloseNotes", true);

            Utility.NoteSnapDistance = settings.GetValueInt("textBoxNoteSnapDistance", 4);
            Utility.GridSnapDistance = settings.GetValueInt("textBoxGridSnapDistance", 4);
            textBoxNoteSnapDistance.Text = Utility.NoteSnapDistance.ToString();
            textBoxGridSnapDistance.Text = Utility.GridSnapDistance.ToString();

            RefreshMidiInputList();
            CheckMidiInputVisibility();
            UpdateProperties(true);

            comboNoteEditorCopyPatternPreset.Items.Clear();
            comboNoteEditorCopyPatternPreset.SelectedIndex = -1;
            foreach (XmlNode node in XMLUtil.GetNodeList(settings.XMLRoot, "searchPatterns/searchPattern"))
            {
                var preset = new CopyPatternPreset()
                {
                    ID = XMLUtil.GetNodeValueInt(node, "@ID"),
                    Name = XMLUtil.GetNodeValue(node, "@Name") ?? "",
                    ForwardOnly = XMLUtil.GetNodeValueBool(node, "@ForwardOnly"),
                    MatchLengths5 = XMLUtil.GetNodeValueBool(node, "@MatchLengths5"),
                    MatchLengths6 = XMLUtil.GetNodeValueBool(node, "@MatchLengths6"),
                    MatchSpacing = XMLUtil.GetNodeValueBool(node, "@MatchSpacing"),
                    MatchBeat = XMLUtil.GetNodeValueBool(node, "@MatchBeat"),
                    KeepLengths = XMLUtil.GetNodeValueBool(node, "@KeepLengths"),
                    FirstMatchOnly = XMLUtil.GetNodeValueBool(node, "@FirstMatchOnly"),
                    RemoveExisting = XMLUtil.GetNodeValueBool(node, "@RemoveExisting", true),

                };

                comboNoteEditorCopyPatternPreset.Items.Add(preset);
            }

            if (comboNoteEditorCopyPatternPreset.Items.Count > 0)
            {
                comboNoteEditorCopyPatternPreset.SelectedIndex = 0;
            }

            SongList = new SongCacheList(listBoxSongLibrary);

            var snglist = XMLUtil.GetNodeList(settings.XMLRoot, "docLib/song");
            if (snglist != null)
            {
                var lst = new List<SongCacheItem>();

                foreach (XmlNode song in snglist)
                {

                    var sc = new SongCacheItem();
                    sc.SongName = XMLUtil.GetNodeValue(song, "@name");
                    sc.G5FileName = XMLUtil.GetNodeValue(song, "@G5FileName");
                    sc.G6FileName = XMLUtil.GetNodeValue(song, "@G6FileName");
                    sc.G6ConFile = XMLUtil.GetNodeValue(song, "@G6ConFile");
                    sc.Description = XMLUtil.GetNodeValue(song, "@Description");

                    sc.HasBass = XMLUtil.GetNodeValueBool(song, "@HasBass");
                    sc.HasGuitar = XMLUtil.GetNodeValueBool(song, "@HasGuitar");
                    sc.CopyGuitarToBass = XMLUtil.GetNodeValueBool(song, "@CopyGuitarToBass");
                    sc.IsComplete = XMLUtil.GetNodeValueBool(song, "@IsComplete");
                    sc.IsFinalized = XMLUtil.GetNodeValueBool(song, "@IsFinalized");

                    sc.GuitarTuning[0] = XMLUtil.GetNodeValue(song, "@GuitarLowE", "0");
                    sc.GuitarTuning[1] = XMLUtil.GetNodeValue(song, "@GuitarA", "0");
                    sc.GuitarTuning[2] = XMLUtil.GetNodeValue(song, "@GuitarD", "0");
                    sc.GuitarTuning[3] = XMLUtil.GetNodeValue(song, "@GuitarG", "0");
                    sc.GuitarTuning[4] = XMLUtil.GetNodeValue(song, "@GuitarB", "0");
                    sc.GuitarTuning[5] = XMLUtil.GetNodeValue(song, "@GuitarHighE", "0");

                    sc.BassTuning[0] = XMLUtil.GetNodeValue(song, "@BassLowE", "0");
                    sc.BassTuning[1] = XMLUtil.GetNodeValue(song, "@BassA", "0");
                    sc.BassTuning[2] = XMLUtil.GetNodeValue(song, "@BassD", "0");
                    sc.BassTuning[3] = XMLUtil.GetNodeValue(song, "@BassG", "0");
                    sc.BassTuning[4] = XMLUtil.GetNodeValue(song, "@BassB", "0");
                    sc.BassTuning[5] = XMLUtil.GetNodeValue(song, "@BassHighE", "0");

                    sc.DTABassDifficulty = XMLUtil.GetNodeValueInt(song, "@DTABassDifficulty", 0);
                    sc.DTAGuitarDifficulty = XMLUtil.GetNodeValueInt(song, "@DTAGuitarDifficulty", 0);
                    sc.DTASongID = XMLUtil.GetNodeValue(song, "@DTASongID");
                    sc.DTASongShortName = XMLUtil.GetNodeValue(song, "@DTASongShortName");

                    sc.SongMP3Location = XMLUtil.GetNodeValue(song, "@SongMP3Location", "");
                    sc.SongMP3PlaybackOffset = XMLUtil.GetNodeValue(song, "@SongMP3PlaybackOffset", "").ToInt();
                    sc.EnableSongMP3Playback = XMLUtil.GetNodeValueBool(song, "@EnableSongMP3Playback", false);

                    sc.EnableSongMidiPlayback = XMLUtil.GetNodeValueBool(song, "@EnableSongMidiPlayback", true);
                    sc.SongMP3PlaybackVolume = XMLUtil.GetNodeValueInt(song, "@SongMP3PlaybackVolume", 100);
                    sc.SongMidiPlaybackVolume = XMLUtil.GetNodeValueInt(song, "@SongMidiPlaybackVolume", 100);

                    sc.AutoGenGuitarHard = XMLUtil.GetNodeValueBool(song, "@AutoGenGuitarHard", true);
                    sc.AutoGenGuitarMedium = XMLUtil.GetNodeValueBool(song, "@AutoGenGuitarMedium", true);
                    sc.AutoGenGuitarEasy = XMLUtil.GetNodeValueBool(song, "@AutoGenGuitarEasy", true);

                    sc.AutoGenBassHard = XMLUtil.GetNodeValueBool(song, "@AutoGenBassHard", true);
                    sc.AutoGenBassMedium = XMLUtil.GetNodeValueBool(song, "@AutoGenBassMedium", true);
                    sc.AutoGenBassEasy = XMLUtil.GetNodeValueBool(song, "@AutoGenBassEasy", true);

                    var sid = XMLUtil.GetNodeValue(song, "@CacheSongID");
                    if (!string.IsNullOrEmpty(sid))
                    {
                        int songid = sid.ToInt();
                        if (!songid.IsNull())
                        {
                            sc.CacheSongID = songid;
                        }
                        else
                        {
                            sc.CacheSongID = GetNextSongID();
                        }
                    }

                    sc.IsDirty = false;

                    try
                    {
                        if (string.IsNullOrEmpty(sc.DTASongID) && !string.IsNullOrEmpty(sc.G5FileName))
                        {
                            FindDTAInformation(sc);
                        }
                    }
                    catch { }

                    lst.Add(sc);

                }
                lst.Sort();
                SongList.AddRange(lst);
                SongList.PopulateList();
            }
            CheckNotesGridSelection();
            CheckNoteChannelVisibility();

            PostLoadSettings();
        }
        MatchingCopyPattern internalFindMatchingCopyPattern(
            FindMatchingPatternConfig findConfig,
            CopyPatternPreset replaceConfig)
        {
            var ret = new MatchingCopyPattern();

            bool matchG5Lengths = replaceConfig.MatchLengths5;
            bool matchG6Lengths = replaceConfig.MatchLengths6;
            bool matchSpacing = replaceConfig.MatchSpacing;
            bool matchBeat = replaceConfig.MatchBeat;

            TickPair ticks;
            if (!getPatternMatchTicks(out ticks))
                return ret;

            var track5 = EditorG5.GuitarTrack;
            var track6 = EditorPro.GuitarTrack;

            var chords5 = track5.Messages.Chords.ToArray();
            var nchords6 = track6.Messages.Chords.ToArray();

            var matchChords5 = track5.Messages.Chords.GetBetweenTick(ticks).ToArray();
            if (matchChords5.Length == 0)
                return ret;

            var oChords6 = track6.Messages.Chords.GetBetweenTick(ticks).ToArray();

            if (oChords6.Length == 0)
                return ret;

            if (replaceConfig.ForwardOnly && !findConfig.FindPrevious)
            {
                chords5 = chords5.Where(x => x.DownTick >= ticks.Up).ToArray();
                nchords6 = nchords6.Where(x => x.DownTick >= ticks.Up).ToArray();
            }

            int minMatchTick5 = matchChords5.GetMinTick();

            int minMatchTick6 = oChords6.GetMinTick();
            int maxMatchTick6 = oChords6.GetMaxTick();

            ret.DeltaTimeStart = track6.TickToTime(minMatchTick6) -
                track5.TickToTime(minMatchTick5);

            if (matchChords5.Any() == false)
                return ret;

            int numMatchChords5 = matchChords5.Count();
            int numMatchChords6 = oChords6.Count();

            ret.OriginalChords6 = oChords6.ToArray();
            ret.StartTick = ticks.Down;
            ret.EndTick = ticks.Up;

            var checkStrings = new cmpNoteFunc(
                (n1, n2) =>
                {
                    return n1.NoteString != n2.NoteString;
                });
            var checkData1 = new cmpNoteFunc(
                (n1, n2) =>
                {
                    return n1.NoteFretDown != n2.NoteFretDown;
                });
            var checkLength = new cmpNoteFunc(
                (n1, n2) =>
                {
                    return Utility.IsCloseTick(n1.TickLength, n2.TickLength) == false;
                });

            var checkNull = new cmpNoteFunc((a, b) =>
            {
                return ((a == null) || (b == null));
            });

            var testBeat = new cmpChordFunc((co, cn) =>
            {
                var ob32 = ProGuitarTrack.GetTempo(co.DownTick).SecondsPerThirtySecondNote;
                var ob = ProGuitarTrack.GetTempo(co.DownTick).SecondsPerQuarterNote;
                var nb = ProGuitarTrack.GetTempo(cn.DownTick).SecondsPerQuarterNote;

                var diff = Math.Abs(ob - nb);
                if (diff > ob32)
                {
                    return false;
                }

                return true;
            });
            var chordsEqual = new cmpChordFunc(
                (a, b) =>
                {
                    if (matchBeat && testBeat(a, b) == false)
                        return false;

                    for (int x = 0; x < 6; x++)
                    {
                        var an = a.Notes[x];
                        var bn = b.Notes[x];

                        if (an == null && bn == null)
                            continue;

                        if (checkNull(an, bn) ||
                            checkData1(an, bn) ||
                            checkStrings(an, bn) ||
                            (matchG5Lengths && checkLength(an, bn)))
                        {
                            return false;
                        }
                    }
                    return true;
                });

            var testSpacing = new matchFunc((mfmatch, mfmca) =>
            {
                for (int y = 0; y < mfmca.Length - 1; y++)
                {
                    var nc = mfmatch[y];
                    var oc = mfmca[y];

                    var timeTillNext5 =
                        track5.TickToTime(mfmca[y + 1].DownTick) -
                        track5.TickToTime(oc.UpTick);

                    var timeTillNext52 =
                        track5.TickToTime(mfmatch[y + 1].DownTick) -
                        track5.TickToTime(nc.UpTick);

                    var diff = Math.Abs(timeTillNext52 - timeTillNext5);
                    double spb = ProGuitarTrack.GetTempo(oc.DownTick).SecondsPerThirtySecondNote;
                    if (diff > spb)
                    {
                        return false;
                    }
                }
                return true;
            });

            var mca = matchChords5.ToArray();
            var match = new GuitarChord[mca.Length];
            var matches = new List<GuitarChord[]>();
            for (int ci = 0; ci < chords5.Length - mca.Length; ci++)
            {
                for (int mc = 0; mc < mca.Length; mc++)
                {
                    var cc = chords5[ci + mc];

                    if (cc.DownTick < mca[mca.Length - 1].UpTick &&
                        cc.UpTick > mca[0].DownTick)
                    {
                        break;
                    }

                    if (chordsEqual(cc, mca[mc]))
                    {
                        match[mc] = cc;
                        if (mc == mca.Length - 1)
                        {
                            if (matchSpacing)
                            {
                                if (testSpacing(match, mca) == true)
                                {
                                    matches.Add(match.ToArray());
                                    ci += mca.Length - 1;
                                }
                            }
                            else
                            {
                                matches.Add(match.ToArray());
                                ci += mca.Length - 1;
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            var goodMatches = new List<GuitarChord[]>();
            foreach (var m in matches)
            {
                var c6 = track6.Messages.Chords.GetBetweenTick(m.GetTickPair()).ToArray();
                bool matching = true;
                if (replaceConfig.MatchLengths6)
                {

                    if (c6.Length == oChords6.Length)
                    {
                        for (int x = 0; x < c6.Length; x++)
                        {
                            if (!Utility.IsCloseTick(c6[x].TickPair.TickLength, oChords6[x].TickPair.TickLength))
                            {
                                matching = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        matching = false;
                    }
                }

                if (matching)
                {
                    goodMatches.Add(c6);
                }
            }
            foreach (var m in goodMatches)
            {
                ret.Matches.Add(m);
            }
            return ret;
        }
        MatchingCopyPattern FindMatchingCopyPattern(FindMatchingPatternConfig config, CopyPatternPreset replaceConfig = null)
        {
            MatchingCopyPattern ret = null;

            try
            {
                if (replaceConfig == null)
                {
                    replaceConfig = GetNewCopyPatternPresetFromScreen();
                }

                ret = internalFindMatchingCopyPattern(config, replaceConfig);
                if (ret == null)
                    return ret;

                var matches = ret.Matches.ToArray();

                ret.Matches.Clear();

                matches.ToList().For((x, i) => matches[i] = x.SortTicks().ToArray());

                if (config.FindNext && config.FindPrevious)
                {
                    if (config.FirstMatchOnly)
                    {
                        ret.Matches.Add(matches.FirstOrDefault());
                    }
                    else
                    {
                        foreach (var itm in matches)
                        {
                            ret.Matches.Add(itm);
                        }
                    }
                }
                else if (config.FindNext)
                {
                    var next = matches.Where(n => n.GetMinTick() > SelectedChord.DownTick);
                    if (next != null && next.Any())
                    {
                        if (config.FirstMatchOnly)
                        {
                            ret.Matches.Add(next.FirstOrDefault());
                        }
                        else
                        {
                            foreach (var itm in next)
                            {
                                ret.Matches.Add(itm);
                            }
                        }
                    }
                }
                else if (config.FindPrevious)
                {
                    var next = matches.Where(n => n.GetMinTick() < SelectedChord.DownTick);
                    if (next != null && next.Any())
                    {
                        if (config.FirstMatchOnly)
                        {
                            ret.Matches.Add(next.LastOrDefault());
                        }
                        else
                        {
                            ret.Matches.AddRange(next);
                        }
                    }
                }
            }
            catch { }

            return ret;
        }