Exemple #1
0
        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;
        }
Exemple #2
0
        private void okButton_Click(object sender, EventArgs e)
        {
            if (Tuning == null) {
                MessageBox.Show("All fields are required!", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (IsBass && Tuning.Tuning.String4 == 0 && Tuning.Tuning.String5 == 0)
                if (MessageBox.Show("Strings 4 and 5 are really 0 (B and E)?" + Environment.NewLine +
                                    "We recommend add all strings to cover also guitar tuning to avoid two same tuning for different instruments." + Environment.NewLine +
                                    "Cancel save and fix it now?", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    return;

            if (EditMode) {
                // Update tuning by strings
                TuningDefinition t = (IsBass) ? TuningDefinitionRepository.Instance().Select(tuning.Tuning, tuning.GameVersion) : TuningDefinitionRepository.Instance().SelectForBass(tuning.Tuning, tuning.GameVersion);
                if (t != null) {
                    t.UIName = Tuning.UIName;
                    t.Name = Tuning.Name;
                    TuningDefinitionRepository.Instance().Save(true);
                } else
                    TuningDefinitionRepository.Instance().Add(Tuning, true);
            } else
                TuningDefinitionRepository.Instance().Add(Tuning, true);

            this.DialogResult = DialogResult.OK;
            Close();
        }
Exemple #3
0
        public AttributesHeader2014(string arrangementFileName, Arrangement arrangement, DLCPackageData info, Platform platform)
        {
            IsVocal     = arrangement.ArrangementType == Sng.ArrangementType.Vocal;
            SongContent = (IsVocal) ? null : Song2014.LoadFromFile(arrangement.SongXml.File);
            var dlcName = info.Name.ToLower();

            var albumUrn = String.Format(URN_TEMPLATE, TagValue.Image.GetDescription(), TagValue.DDS.GetDescription(), String.Format("album_{0}", dlcName));
            var jsonUrn  = String.Format(URN_TEMPLATE, TagValue.Database.GetDescription(), TagValue.JsonDB.GetDescription(), String.Format("{0}_{1}", dlcName, arrangementFileName));

            //FILL ATTRIBUTES
            this.AlbumArt              = albumUrn;
            ArrangementName            = arrangement.Name.ToString();
            DLC                        = true;
            DLCKey                     = info.Name;
            LeaderboardChallengeRating = 0;
            ManifestUrn                = jsonUrn;
            MasterID_RDV               = arrangement.MasterId;
            PersistentID               = arrangement.Id.ToString().Replace("-", "").ToUpper();
            Shipping                   = true;
            SKU                        = "RS2";
            SongKey                    = info.Name;

            if (!IsVocal)
            {
                AlbumName      = AlbumNameSort = info.SongInfo.Album;
                ArtistName     = info.SongInfo.Artist;
                CentOffset     = arrangement.TuningPitch != 0 ? TuningFrequency.Frequency2Cents(arrangement.TuningPitch) : 0.0;
                ArtistNameSort = info.SongInfo.ArtistSort;
                CapoFret       = (arrangement.Sng2014.Metadata.CapoFretId == 0xFF) ? CapoFret = 0 : Convert.ToDecimal(arrangement.Sng2014.Metadata.CapoFretId);
                DNA_Chords     = arrangement.Sng2014.DNACount[(int)DNAId.Chord];
                DNA_Riffs      = arrangement.Sng2014.DNACount[(int)DNAId.Riff];
                DNA_Solo       = arrangement.Sng2014.DNACount[(int)DNAId.Solo];
                NotesEasy      = arrangement.Sng2014.NoteCount[0];
                NotesMedium    = arrangement.Sng2014.NoteCount[1];
                NotesHard      = arrangement.Sng2014.NoteCount[2];
                EasyMastery    = NotesEasy / NotesHard;
                MediumMastery  = NotesMedium / NotesHard;
                Representative = Convert.ToInt32(!arrangement.BonusArr);
                RouteMask      = (int)arrangement.RouteMask;

                // TODO this is not quite it but much closer
                SongDiffEasy   = SongContent.SongLength / NotesEasy;
                SongDiffMed    = SongContent.SongLength / NotesMedium;
                SongDiffHard   = SongContent.SongLength / NotesHard;
                SongDifficulty = SongDiffHard;

                SongLength   = (double?)Math.Round(SongContent.SongLength, 3, MidpointRounding.AwayFromZero);
                SongName     = info.SongInfo.SongDisplayName;
                SongNameSort = info.SongInfo.SongDisplayNameSort;
                SongYear     = info.SongInfo.SongYear;

                var tunDef = TuningDefinitionRepository.Instance().Select(arrangement.Tuning, platform.version);
                Tuning = tunDef.Tuning;
            }
        }
Exemple #4
0
        private void FillTuningCombo()
        {
            TuningDefinition firstTuning = null;

            tuningComboBox.Items.Clear();
            foreach (var tuning in TuningDefinitionRepository.Instance().Select(currentGameVersion))
            {
                tuningComboBox.Items.Add(tuning);
                if (firstTuning == null)
                {
                    firstTuning = tuning;
                }
            }
            tuningComboBox.SelectedItem = firstTuning;
            tuningComboBox.Refresh();
        }
Exemple #5
0
        private void tuningEditButton_Click(object sender, EventArgs e)
        {
            var selectedType        = ((ArrangementType)((ComboBox)arrangementTypeCombo).SelectedItem);
            TuningDefinition tuning = (TuningDefinition)tuningComboBox.SelectedItem;

            if (tuning == null)
            {
                MessageBox.Show("At least one tuning definition is needed to edit.\r\n (Current tuning is Null)", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (var form = new TuningForm())
            {
                form.Tuning   = tuning;
                form.IsBass   = selectedType == ArrangementType.Bass;
                form.EditMode = true;

                var oldUIName = tuning.UIName.Clone().ToString(); //Important to set it here
                if (DialogResult.OK != form.ShowDialog())
                {
                    return;
                }

                if (oldUIName != form.Tuning.UIName && !form.AddNew)
                {
                    // Update LB slots if tuning name are changed
                    for (int i = 0; i < parentControl.ArrangementLB.Items.Count; i++)
                    {
                        var selectedArrangement = (Arrangement)parentControl.ArrangementLB.Items[i];

                        if (oldUIName.Equals(selectedArrangement.Tuning))
                        {
                            selectedArrangement.Tuning           = form.Tuning.UIName;
                            parentControl.ArrangementLB.Items[i] = selectedArrangement;
                        }
                    }
                }
                //Update from xml definition
                tuning = form.Tuning;
                tuning = TuningDefinitionRepository.Instance().SelectAny(tuning.Tuning, tuning.GameVersion);

                FillTuningCombo();
                tuningComboBox.SelectedItem = tuning;
                Arrangement.TuningStrings   = tuning.Tuning;
            }
        }
Exemple #6
0
        private void FillTuningCombo(ArrangementType arrangementType, GameVersion gameVersion)
        {
            tuningComboBox.Items.Clear();
            var tuningDefinitions = TuningDefinitionRepository.LoadTuningDefinitions(gameVersion);

            // LINQ method produces unexpected results on subsequent calls
            // foreach (var tuning in TuningDefinitionRepository.Instance().Select(gameVersion))
            foreach (var tuning in tuningDefinitions)
            {
                // need to populate for Vocals too even though not used
                //if (arrangementType != ArrangementType.Bass)
                tuningComboBox.Items.Add(tuning);
                //if (arrangementType == ArrangementType.Bass)
                // tuningComboBox.Items.Add(TuningDefinition.Convert2Bass(tuning));
            }

            tuningComboBox.SelectedIndex = 0;
            tuningComboBox.Refresh();
        }
Exemple #7
0
        private void tuningEditButton_Click(object sender, EventArgs e)
        {
            var selectedType = ((ArrangementType)((ComboBox)arrangementTypeCombo).SelectedItem);
            TuningDefinition selectedTuning = (TuningDefinition)tuningComboBox.SelectedItem;

            if (selectedTuning == null)
            {
                MessageBox.Show("At least one tuning definition is needed to edit.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (var form = new TuningForm()) {
                form.Tuning   = selectedTuning;
                form.IsBass   = selectedType == ArrangementType.Bass;
                form.EditMode = true;

                var oldUIName = selectedTuning.UIName.Clone().ToString();
                if (DialogResult.OK != form.ShowDialog())
                {
                    return;
                }

                if (oldUIName != form.Tuning.UIName)
                {
                    // Update LB slots if name are changed
                    for (int i = 0; i < parentControl.ArrangementLB.Items.Count; i++)
                    {
                        var arrangement = (Arrangement)parentControl.ArrangementLB.Items[i];

                        if (oldUIName.Equals(arrangement.Tuning))
                        {
                            arrangement.Tuning = form.Tuning.UIName;
                            parentControl.ArrangementLB.Items[i] = arrangement;
                        }
                    }
                }

                FillTuningCombo();
                tuningComboBox.SelectedItem = (form.IsBass) ? TuningDefinitionRepository.Instance().SelectForBass(form.Tuning.Tuning, currentGameVersion) : TuningDefinitionRepository.Instance().Select(form.Tuning.Tuning, currentGameVersion);
            }
        }
        private void FillTuningCombo(ArrangementType arrangementType, GameVersion gameVersion)
        {
            tuningComboBox.Items.Clear();
            var tuningDefinitions = TuningDefinitionRepository.LoadTuningDefinitions(gameVersion);

            // LINQ method produces unexpected results on subsequent calls
            // foreach (var tuning in TuningDefinitionRepository.Instance().Select(gameVersion))
            foreach (var tuning in tuningDefinitions)
            {
                if (arrangementType == ArrangementType.Guitar)
                {
                    tuningComboBox.Items.Add(tuning);
                }
                if (arrangementType == ArrangementType.Bass)
                {
                    tuningComboBox.Items.Add(TuningDefinition.Convert2Bass(tuning));
                }
            }

            tuningComboBox.SelectedIndex = 0;
            tuningComboBox.Refresh();
        }
        public Arrangement(Attributes2014 attr, string xmlSongFile)
        {
            var song = Song2014.LoadFromFile(xmlSongFile);

            this.SongFile      = new SongFile();
            this.SongFile.File = "";

            this.SongXml      = new SongXML();
            this.SongXml.File = xmlSongFile;
            //Tuning
            TuningDefinition tuning = null;

            switch ((ArrangementName)attr.ArrangementType)
            {
            case ArrangementName.Lead:
            case ArrangementName.Rhythm:
            case ArrangementName.Combo:
                this.ArrangementType = Sng.ArrangementType.Guitar;
                tuning = TuningDefinitionRepository.Instance().Select(song.Tuning, GameVersion.RS2014);
                break;

            case ArrangementName.Bass:
                this.ArrangementType = Sng.ArrangementType.Bass;
                // TODO: trying to fix bass tuning issue
                tuning = TuningDefinitionRepository.Instance().Select(song.Tuning, GameVersion.RS2014);
                // tuning = TuningDefinitionRepository.Instance().SelectForBass(song.Tuning, GameVersion.RS2014);
                break;

            case ArrangementName.Vocals:
                this.ArrangementType = Sng.ArrangementType.Vocal;
                break;
            }

            if (tuning == null)
            {
                tuning             = new TuningDefinition();
                tuning.UIName      = tuning.Name = tuning.NameFromStrings(song.Tuning, this.ArrangementType == Sng.ArrangementType.Bass);
                tuning.Custom      = true;
                tuning.GameVersion = GameVersion.RS2014;
                tuning.Tuning      = song.Tuning;
                TuningDefinitionRepository.Instance().Add(tuning, true);
            }

            this.Tuning        = tuning.UIName;
            this.TuningStrings = tuning.Tuning;
            this.CapoFret      = attr.CapoFret;
            if (attr.CentOffset != null)
            {
                this.TuningPitch = attr.CentOffset.Cents2Frequency();
            }
            //Properties
            this.ArrangementSort = attr.ArrangementSort;
            this.Name            = (ArrangementName)Enum.Parse(typeof(ArrangementName), attr.ArrangementName);
            this.ScrollSpeed     = Convert.ToInt32(attr.DynamicVisualDensity.Last() * 10);
            this.PluckedType     = (PluckedType)attr.ArrangementProperties.BassPick;
            this.RouteMask       = (RouteMask)attr.ArrangementProperties.RouteMask;
            this.BonusArr        = attr.ArrangementProperties.BonusArr == 1;
            this.Metronome       = (Metronome)attr.ArrangementProperties.Metronome;
            this.ToneMultiplayer = attr.Tone_Multiplayer;
            this.Id          = Guid.Parse(attr.PersistentID);
            this.MasterId    = attr.MasterID_RDV;
            this.XmlComments = Song2014.ReadXmlComments(xmlSongFile);
            //Tones
            if (attr.Tones == null) // RS2012
            {
                this.ToneBase = attr.Tone_Base;

                if (attr.Tone_A != null || attr.Tone_B != null || attr.Tone_C != null || attr.Tone_D != null)
                {
                    throw new DataException("RS2012 CDLC has extraneous tone data.");
                }
            }
            else // RS2014 or Converter RS2012
            {
                // TODO: optimize using common Arrangment.cs method
                // verify the xml Tone_ exists in tone.manifest.json
                foreach (var jsonTone in attr.Tones)
                {
                    if (jsonTone == null)
                    {
                        continue;
                    }

                    // fix for tone.id (may not be needed/used by game)
                    Int32 toneId = 0;

                    // cleanup the xml arrangment file too
                    if (jsonTone.Name.ToLower() == attr.Tone_Base.ToLower())
                    {
                        this.ToneBase = song.ToneBase = attr.Tone_Base;
                    }
                    if (jsonTone.Name.ToLower() == attr.Tone_A.ToLower())
                    {
                        this.ToneA = song.ToneA = attr.Tone_A;
                    }
                    if (jsonTone.Name.ToLower() == attr.Tone_B.ToLower())
                    {
                        this.ToneB = song.ToneB = attr.Tone_B;
                        toneId     = 1;
                    }
                    if (jsonTone.Name.ToLower() == attr.Tone_C.ToLower())
                    {
                        this.ToneC = song.ToneC = attr.Tone_C;
                        toneId     = 2;
                    }
                    if (jsonTone.Name.ToLower() == attr.Tone_D.ToLower())
                    {
                        this.ToneD = song.ToneD = attr.Tone_D;
                        toneId     = 3;
                    }

                    // update EOF tone name and set tone id
                    if (song.Tones != null)
                    {
                        foreach (var xmlTone in song.Tones)
                        {
                            // fix some old toolkit behavior
                            if (xmlTone.Name == "ToneA")
                            {
                                xmlTone.Name = attr.Tone_A;
                            }
                            if (xmlTone.Name == "ToneB")
                            {
                                xmlTone.Name = attr.Tone_B;
                            }
                            if (xmlTone.Name == "ToneC")
                            {
                                xmlTone.Name = attr.Tone_C;
                            }
                            if (xmlTone.Name == "ToneD")
                            {
                                xmlTone.Name = attr.Tone_D;
                            }

                            if (xmlTone.Name.ToLower() == jsonTone.Name.ToLower() || jsonTone.Name.ToLower().Contains(xmlTone.Name.ToLower()))
                            {
                                xmlTone.Name = jsonTone.Name;
                                xmlTone.Id   = toneId;
                            }
                        }
                    }

                    if (song.Tones == null && toneId > 0)
                    {
                        throw new InvalidDataException("Custom tones were not set properly in EOF" + Environment.NewLine + "Please reauthor XML arrangement in EOF and fix custom tone consistency.");
                    }
                }

                // write changes to xml arrangement
                using (var stream = File.Open(xmlSongFile, FileMode.Create))
                    song.Serialize(stream);
            }
        }
Exemple #10
0
 private void SaveTuningDefinition(TuningDefinition formTuning)
 {
     // can mess up the TuningDefinition.xml file on multiple adds
     TuningDefinitionRepository.Instance().Add(formTuning, true);
     TuningDefinitionRepository.Instance().Save(true);
 }
Exemple #11
0
        private void ShowTuningForm(ArrangementType selectedType, TuningDefinition tuning)
        {
            if (tuning == null)
            {
                MessageBox.Show("Pick a tuning definition to start editing.\r\n (DEBUG: Current tuning is Null)", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // get the latest comments from the XML to check if previous bass fixed is valid
            if (!String.IsNullOrEmpty(Arrangement.SongXml.File) && selectedType == ArrangementType.Bass)
            {
                //var debugMe = "";
                var xmlComments = Song2014.ReadXmlComments(Arrangement.SongXml.File);
                var isBassFixed = xmlComments.Any(xComment => xComment.ToString().Contains("Low Bass Tuning Fixed")) || Convert.ToDouble(txtFrequency.Text) == 220.00;

                // commented out ... Arrangement.XmlComments may not be populated
                // var isBassFixed = Arrangement.XmlComments.Any(xComment => xComment.ToString().Contains("Low Bass Tuning Fixed")) || Convert.ToDouble(txtFrequency.Text) == 220.00;

                if (isBassFixed && !tuning.UIName.Contains("Fixed"))
                {
                    // UIName may contain spaces, where as Name contains no spaces
                    tuning.UIName = String.Format("{0} Fixed", tuning.UIName);
                    tuning.Name = tuning.UIName.ReplaceSpaceWith("");
                    tuning.Custom = true;
                    // fixed bass tuning definition is auto added to repository
                    TuningDefinitionRepository.SaveUnique(tuning);
                }
            }

            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 lstArrangements slots if tuning name is changed
                for (int i = 0; i < _parentControl.lstArrangements.Items.Count; i++)
                {
                    var selectedArrangement = (Arrangement)_parentControl.lstArrangements.Items[i];

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

            FillTuningCombo(_gameVersion);

            int foundTuning = -1;
            cmbTuningName.SelectedIndex = -1;
            for (int tcbIndex = 0; tcbIndex < cmbTuningName.Items.Count; tcbIndex++)
            {
                cmbTuningName.SelectedIndex = tcbIndex;
                tuning = (TuningDefinition)cmbTuningName.Items[tcbIndex];

                // check at least tuning strings and name match
                if (tuning.Tuning == formTuning.Tuning && tuning.Name == formTuning.Name)
                {
                    foundTuning = tcbIndex;
                    break;
                }
            }

            // add the custom tuning to tuningComboBox
            if (foundTuning == -1)
            {
                if (addNew)
                    TuningDefinitionRepository.SaveUnique(formTuning);

                formTuning.Custom = true;
                cmbTuningName.Items.Add(formTuning);
                cmbTuningName.SelectedIndex = cmbTuningName.Items.Count - 1;
            }
            else
                cmbTuningName.SelectedIndex = foundTuning;

            cmbTuningName.Refresh();
            Arrangement.TuningStrings = formTuning.Tuning;
            Arrangement.Tuning = formTuning.UIName;
        }
Exemple #12
0
        public AttributesHeader2014(string arrangementFileName, Arrangement arrangement, DLCPackageData info, Platform platform)
        {
            if (arrangement.ArrangementType == ArrangementType.ShowLight)
            {
                return;
            }

            IsVocal     = arrangement.ArrangementType == Sng.ArrangementType.Vocal;
            SongContent = (IsVocal) ? null : Song2014.LoadFromFile(arrangement.SongXml.File);
            var dlcName = info.Name.ToLower();

            var albumUrn = String.Format(URN_TEMPLATE, TagValue.Image.GetDescription(), TagValue.DDS.GetDescription(), String.Format("album_{0}", dlcName));
            var jsonUrn  = String.Format(URN_TEMPLATE, TagValue.Database.GetDescription(), TagValue.JsonDB.GetDescription(), String.Format("{0}_{1}", dlcName, arrangementFileName));

            //FILL ATTRIBUTES
            this.AlbumArt              = albumUrn;
            JapaneseVocal             |= arrangement.Name == Sng.ArrangementName.JVocals;
            ArrangementName            = IsVocal ? Sng.ArrangementName.Vocals.ToString() : arrangement.Name.ToString(); //HACK: weird vocals stuff
            DLC                        = true;
            DLCKey                     = info.Name;
            LeaderboardChallengeRating = 0;
            ManifestUrn                = jsonUrn;
            MasterID_RDV               = arrangement.MasterId;
            PersistentID               = arrangement.Id.ToString().Replace("-", "").ToUpper();
            Shipping                   = true;
            SKU                        = "RS2";
            SongKey                    = info.Name;

            if (!IsVocal)
            {
                AlbumName      = AlbumNameSort = info.SongInfo.Album;
                ArtistName     = info.SongInfo.Artist;
                CentOffset     = (!arrangement.TuningPitch.Equals(0)) ? TuningFrequency.Frequency2Cents(arrangement.TuningPitch) : 0.0;
                ArtistNameSort = info.SongInfo.ArtistSort;
                CapoFret       = (arrangement.Sng2014.Metadata.CapoFretId == 0xFF) ? CapoFret = 0 : Convert.ToDecimal(arrangement.Sng2014.Metadata.CapoFretId);
                DNA_Chords     = arrangement.Sng2014.DNACount[(int)DNAId.Chord];
                DNA_Riffs      = arrangement.Sng2014.DNACount[(int)DNAId.Riff];
                DNA_Solo       = arrangement.Sng2014.DNACount[(int)DNAId.Solo];
                NotesEasy      = arrangement.Sng2014.NoteCount[0];
                NotesMedium    = arrangement.Sng2014.NoteCount[1];
                NotesHard      = arrangement.Sng2014.NoteCount[2];
                EasyMastery    = NotesEasy / NotesHard;
                MediumMastery  = NotesMedium / NotesHard;
                Metronome      = (int?)arrangement.Metronome;
                Representative = Convert.ToInt32(!arrangement.BonusArr);
                RouteMask      = (int)arrangement.RouteMask;

                // TODO use ManifestFunctions.GetSongDifficulty() method (fix generation alghorythm)
                SongDiffEasy   = SongContent.SongLength / NotesEasy;
                SongDiffMed    = SongContent.SongLength / NotesMedium;
                SongDiffHard   = SongContent.SongLength / NotesHard;
                SongDifficulty = SongDiffHard;

                SongLength   = (double?)Math.Round(SongContent.SongLength, 3, MidpointRounding.AwayFromZero);
                SongName     = info.SongInfo.SongDisplayName;
                SongNameSort = info.SongInfo.SongDisplayNameSort;
                SongYear     = info.SongInfo.SongYear;

                //Detect tuning
                var tuning = TuningDefinitionRepository.Instance().SelectAny(SongContent.Tuning, platform.version);
                if (tuning == null)
                {
                    tuning        = new TuningDefinition();
                    tuning.Tuning = SongContent.Tuning;
                    tuning.Name   = tuning.UIName = arrangement.Tuning;
                    if (String.IsNullOrEmpty(tuning.Name))
                    {
                        tuning.Name = tuning.UIName = tuning.NameFromStrings(arrangement.TuningStrings, arrangement.ArrangementType == ArrangementType.Bass);
                    }
                    tuning.Custom      = true;
                    tuning.GameVersion = GameVersion.RS2014;
                    TuningDefinitionRepository.Instance().Add(tuning, true);
                }
                Tuning = tuning.Tuning;
            }
        }
Exemple #13
0
        // only for RS2014
        public static bool ApplyBassFix(Arrangement arr, bool saveTuningDefinition = false)
        {
            var debubMe = arr;

            // get the latest comments from the XML
            var xmlComments = Song2014.ReadXmlComments(arr.SongXml.File);
            var isBassFixed = xmlComments.Any(xComment => xComment.ToString().Contains("Low Bass Tuning Fixed")) || arr.TuningPitch.Equals(220.0);

            if (isBassFixed)
            {
                Debug.WriteLine("Low bass tuning may already be fixed: " + arr.SongXml.File);
                // return false;
            }

            // TODO: check guitar compatibility
            // Octave up for each string
            Int16[] strings = arr.TuningStrings.ToArray();
            for (int s = 0; s < strings.Length; s++)
            {
                if (strings[s] < 0)
                {
                    strings[s] += 12;
                }
            }

            // update XML arrangement
            Song2014 songXml = Song2014.LoadFromFile(arr.SongXml.File);

            songXml.CentOffset = "-1200.0"; // Force 220Hz
            songXml.Tuning     = new TuningStrings(strings);

            // bass tuning definition gets auto added/saved to repository
            if (saveTuningDefinition)
            {
                var tuningDef = TuningDefinitionRepository.Instance.Detect(songXml.Tuning, GameVersion.RS2014, false);

                if (!tuningDef.Name.Contains("Fixed"))
                {
                    var tuningUiName = String.Format("{0} Fixed", tuningDef.UIName);
                    var bassTuning   = new TuningDefinition
                    {
                        Custom      = true,
                        GameVersion = GameVersion.RS2014,
                        Name        = tuningUiName.Replace(" ", ""),
                        Tuning      = songXml.Tuning,
                        UIName      = tuningUiName
                    };

                    TuningDefinitionRepository.SaveUnique(bassTuning);
                }
            }

            using (var stream = File.Open(arr.SongXml.File, FileMode.Create))
                songXml.Serialize(stream, true);

            // write xml comments back to fixed bass arrangement
            if (!isBassFixed)
            {
                Song2014.WriteXmlComments(arr.SongXml.File, xmlComments, customComment: "Low Bass Tuning Fixed");
            }

            return(true);
        }
Exemple #14
0
        public Arrangement(Attributes2014 attr, string xmlSongFile)
        {
            var song = Song2014.LoadFromFile(xmlSongFile);

            this.SongFile      = new SongFile();
            this.SongFile.File = "";

            this.SongXml      = new SongXML();
            this.SongXml.File = xmlSongFile;

            bool             isBass = false;
            TuningDefinition tuning = null;

            switch ((ArrangementName)attr.ArrangementType)
            {
            case ArrangementName.Lead:
            case ArrangementName.Rhythm:
            case ArrangementName.Combo:
                this.ArrangementType = Sng.ArrangementType.Guitar;
                tuning = TuningDefinitionRepository.Instance().Select(song.Tuning, GameVersion.RS2014);
                break;

            case ArrangementName.Bass:
                this.ArrangementType = Sng.ArrangementType.Bass;
                tuning = TuningDefinitionRepository.Instance().SelectForBass(song.Tuning, GameVersion.RS2014);
                isBass = true;
                break;

            case ArrangementName.Vocals:
                this.ArrangementType = Sng.ArrangementType.Vocal;
                break;
            }

            if (tuning == null)
            {
                tuning             = new TuningDefinition();
                tuning.UIName      = tuning.Name = tuning.NameFromStrings(song.Tuning, isBass);
                tuning.Custom      = true;
                tuning.GameVersion = GameVersion.RS2014;
                tuning.Tuning      = song.Tuning;
                TuningDefinitionRepository.Instance().Add(tuning, true);
            }
            this.Tuning = tuning.UIName;
            if (attr.CentOffset != null)
            {
                this.TuningPitch = attr.CentOffset.Cents2Frequency();
            }

            this.ArrangementSort = attr.ArrangementSort;
            this.Name            = (ArrangementName)Enum.Parse(typeof(ArrangementName), attr.ArrangementName);
            this.ScrollSpeed     = Convert.ToInt32(attr.DynamicVisualDensity.Last() * 10);
            this.PluckedType     = (PluckedType)attr.ArrangementProperties.BassPick;
            this.RouteMask       = (RouteMask)attr.ArrangementProperties.RouteMask;
            this.BonusArr        = attr.ArrangementProperties.BonusArr == 1;
            this.ToneBase        = attr.Tone_Base;
            this.ToneMultiplayer = attr.Tone_Multiplayer;
            this.ToneA           = attr.Tone_A;
            this.ToneB           = attr.Tone_B;
            this.ToneC           = attr.Tone_C;
            this.ToneD           = attr.Tone_D;

            this.Id       = Guid.Parse(attr.PersistentID);
            this.MasterId = attr.MasterID_RDV;
        }