public void NameFromStringsTest()
        {
            string tName = string.Empty; 
            var t = new TuningDefinition();
            var Estd = new TuningStrings(new Int16[] { 0, 0, 0, 0, 0, 0 });
            tName = t.NameFromStrings(Estd, false);
            Assert.AreEqual("E Standard", tName);

            var Ebstd = new TuningStrings(new Int16[] { -1, -1, -1, -1, -1, -1 });
            tName = t.NameFromStrings(Ebstd, true);
            Assert.AreEqual("Eb Standard", tName);

            var EbstdB = new TuningStrings(new Int16[] { -1, -1, -1, -1 }); //TODO: support bass
            tName = t.NameFromStrings(EbstdB, true);
            //Assert.AreEqual("Eb Standard", tName);

            var Ccstd = new TuningStrings(new Int16[] { -3, -3, -3, -3, -3, -3 });
            tName = t.NameFromStrings(Ccstd, false);
            Assert.AreEqual("C# Standard", tName);

            var DropEb = new TuningStrings(new Int16[] { -3, -1, -1, -1, -1, -1 });
            tName = t.NameFromStrings(DropEb, true);
            Assert.AreEqual("Eb Drop Db", tName);

            var DropA = new TuningStrings(new Int16[] { 5, 7, 7, 7, 7, 7 });
            tName = t.NameFromStrings(DropA, false);
            Assert.AreEqual("B Drop A", tName);
        }
        public static TuningDefinition Convert2Bass(TuningDefinition tuningDefinition)
        {
            TuningDefinition bassTuning = tuningDefinition;

            bassTuning.Tuning = Convert2Bass(tuningDefinition.Tuning);

            return(bassTuning);
        }
Ejemplo n.º 3
0
        public static TuningDefinition Convert2Bass(TuningDefinition tuningDefinition)
        {
            TuningDefinition bassTuning = new TuningDefinition();

            bassTuning = tuningDefinition;
            bassTuning.Tuning.String0 = tuningDefinition.Tuning.String0;
            bassTuning.Tuning.String1 = tuningDefinition.Tuning.String1;
            bassTuning.Tuning.String2 = tuningDefinition.Tuning.String2;
            bassTuning.Tuning.String3 = tuningDefinition.Tuning.String3;
            bassTuning.Tuning.String4 = 0;
            bassTuning.Tuning.String5 = 0;

            return(bassTuning);
        }
        private void ShowTuningForm(ArrangementType selectedType, TuningDefinition tuning)
        {
            if (tuning == null)
            {
                MessageBox.Show("Pick a tuning definition to start editing.\r\n (Current tuning is Null)", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            bool addNew;
            TuningDefinition formTuning;
            using (var form = new TuningForm())
            {
                form.Tuning = tuning;
                form.IsBass = selectedType == ArrangementType.Bass;

                if (DialogResult.OK != form.ShowDialog())
                    return;

                // prevent any further SET calls to form.Tuning
                formTuning = form.Tuning;
                addNew = form.AddNew;
            }

            if (tuning.UIName != formTuning.UIName)
            {
                // Update LB slots if tuning name is changed
                for (int i = 0; i < parentControl.arrangementLB.Items.Count; i++)
                {
                    var selectedArrangement = (Arrangement)parentControl.arrangementLB.Items[i];

                    if (tuning.UIName.Equals(selectedArrangement.Tuning))
                    {
                        selectedArrangement.Tuning = formTuning.UIName;
                        parentControl.arrangementLB.Items[i] = selectedArrangement;
                    }
                }
            }

            // TODO: figure out logic behind unexpected LINQ behaviors
            // tuningComboBox list is being updated with custom tuning info
            // so refilling the combobox is required to produce the expected results
            // for now using old fashioned non-LINQ method
            FillTuningCombo(selectedType, currentGameVersion);

            int foundTuning = -1;
            tuningComboBox.SelectedIndex = -1;
            for (int tcbIndex = 0; tcbIndex < tuningComboBox.Items.Count; tcbIndex++)
            {
                tuningComboBox.SelectedIndex = tcbIndex;
                tuning = (TuningDefinition)tuningComboBox.Items[tcbIndex];
                if (tuning.Tuning == formTuning.Tuning)
                {
                    foundTuning = tcbIndex;
                    break;
                }
            }

            // add the custom tuning to tuningComboBox
            if (foundTuning == -1)
            {
                formTuning.Custom = true;
                tuningComboBox.Items.Add(formTuning);
                tuningComboBox.SelectedIndex = tuningComboBox.Items.Count - 1;

                if (addNew)
                    SaveTuningDefinition(formTuning);
            }
            else
                tuningComboBox.SelectedIndex = foundTuning;

            tuningComboBox.Refresh();
            Arrangement.TuningStrings = formTuning.Tuning; // forces SET update
        }
 private void SaveTuningDefinition(TuningDefinition formTuning)
 {
     // can mess up the TuningDefinition.xml file on multiple adds
     TuningDefinitionRepository.Instance().Add(formTuning, true);
     TuningDefinitionRepository.Instance().Save(true);
 }
        private void FillPackageCreatorForm(DLCPackageData info, string filesBaseDir)
        {
            RS2012.Checked = info.GameVersion == GameVersion.RS2012;
            RS2014.Checked = info.GameVersion == GameVersion.RS2014;

            platformPC.Checked = info.Pc;
            platformMAC.Checked = info.Mac;
            platformXBox360.Checked = info.XBox360;
            platformPS3.Checked = info.PS3;

            PackageVersion = info.PackageVersion;

            TonesLB.Items.Clear();
            switch (CurrentGameVersion) {
                case GameVersion.RS2012:
                    if (info.Tones == null)
                        info.Tones = new List<Tone>();
                    if (info.Tones.Count == 0)
                        info.Tones.Add(CreateNewTone());

                    foreach (var tone in info.Tones) {
                        if (String.IsNullOrEmpty(tone.Key))
                            tone.Key = tone.Name.GetValidName();

                        TonesLB.Items.Add(tone);
                    }
                    break;
                case GameVersion.RS2014:
                    if (info.TonesRS2014.Count == 0)
                        info.TonesRS2014.Add(CreateNewTone());

                    foreach (var toneRS2014 in info.TonesRS2014) {
                        if (String.IsNullOrEmpty(toneRS2014.Key))
                            toneRS2014.Key = toneRS2014.Name.GetValidName();

                        TonesLB.Items.Add(toneRS2014);
                    }
                    break;
            }

            var BasePath = Path.GetDirectoryName(filesBaseDir);

            // Song INFO
            DlcNameTB.Text = info.Name;

            PopulateAppIdCombo();
            Application.DoEvents();
            AppIdTB.Text = info.AppId;
            SelectComboAppId(info.AppId);

            AlbumTB.Text = info.SongInfo.Album;
            SongDisplayNameTB.Text = info.SongInfo.SongDisplayName;
            SongDisplayNameSortTB.Text = info.SongInfo.SongDisplayNameSort;
            YearTB.Text = info.SongInfo.SongYear.ToString();
            ArtistTB.Text = info.SongInfo.Artist;
            ArtistSortTB.Text = info.SongInfo.ArtistSort;
            AverageTempoTB.Text = info.SongInfo.AverageTempo.ToString();

            // Album art
            //AlbumArtPath = BasePath.AbsoluteTo(info.AlbumArt.Path);

            // Audio file
            //if (info.Audio != null)
            //    AudioPath = BasePath.AbsoluteTo(info.Audio.Path);
            //platformPC.Checked = !String.IsNullOrEmpty(info.Audio.Path);

            songVolumeBox.Value = Decimal.Round((decimal)info.Volume, 2);
            previewVolumeBox.Value = (info.PreviewVolume != null) ? Decimal.Round((decimal)info.PreviewVolume, 2) : songVolumeBox.Value;

            //if (platformXBox360.Checked)
            //    rbuttonSignatureLIVE.Checked = info.SignatureType == PackageMagic.LIVE;

            ArrangementLB.Items.Clear();
            foreach (var arrangement in info.Arrangements) {
                arrangement.SongXml.File = BasePath.AbsoluteTo(arrangement.SongXml.File);

                if (arrangement.ToneBase == null)
                {
                    switch (CurrentGameVersion) {
                        case GameVersion.RS2012:
                            arrangement.ToneBase = info.Tones[0].Name;
                            break;
                        case GameVersion.RS2014:
                            arrangement.ToneBase = info.TonesRS2014[0].Name;
                            break;
                    }
                }
                if (arrangement.ArrangementType != ArrangementType.Vocal)
                {
                    try
                    {
                        //Load tunig from Arrangement
                        var tuning = TuningDefinitionRepository.Instance().SelectAny(arrangement.TuningStrings, CurrentGameVersion);
                        if (tuning == null)
                        {
                            tuning = new TuningDefinition();
                            tuning.Tuning = arrangement.TuningStrings;
                            tuning.Custom = true;
                            tuning.GameVersion = CurrentGameVersion;
                            tuning.Name = tuning.UIName = arrangement.Tuning;
                            if (String.IsNullOrEmpty(tuning.Name))
                            {
                                tuning.Name = tuning.UIName = TuningDefinition.NameFromStrings(arrangement.TuningStrings, arrangement.ArrangementType == ArrangementType.Bass);
                            }

                            TuningDefinitionRepository.Instance().Add(tuning, true);
                        }
                        tuning = null; //Cleanup after
                    }
                    catch { /* Handle old types of *.dlc.xml */ }
                }
                ArrangementLB.Items.Add(arrangement);
            }
        }
        public static TuningDefinition Convert2Bass(TuningDefinition tuningDefinition)
        {
            TuningDefinition bassTuning = tuningDefinition;
            bassTuning.Tuning = Convert2Bass(tuningDefinition.Tuning);

            return bassTuning;
        }
        private void SetTuningCombo(TuningStrings tuningStrings, bool isBass = false)
        {
            //Detect tuning
            TuningDefinition tuning = TuningDefinitionRepository.Instance().SelectAny(tuningStrings, currentGameVersion);
            //Create tuning
            if (tuning == null) {
                using (var form = new TuningForm()) {
                    tuning = new TuningDefinition();
                    tuning.Tuning = tuningStrings;
                    tuning.Custom = true;
                    tuning.GameVersion = currentGameVersion;
                    tuning.Name = tuning.UIName = tuning.NameFromStrings(tuningStrings, isBass);

                    form.Tuning = tuning;
                    form.IsBass = isBass;
                    if (DialogResult.OK != form.ShowDialog()) {
                        return;
                    }

                    FillTuningCombo();
                }
            }
            //Set tuning
            tuningComboBox.SelectedItem = tuning;
        }