Esempio n. 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;
        }
Esempio n. 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();
        }
Esempio n. 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;
            }
        }
Esempio n. 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();
        }
Esempio n. 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;
            }
        }
Esempio n. 6
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);
            }
        }
        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);
            }
        }
Esempio n. 8
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);
 }
Esempio n. 9
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;
            }
        }
Esempio n. 10
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;
        }