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; this.TuningStrings = tuning.Tuning; 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; }
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(); }
private bool CheckTuning() { // for now just check bass arrangements if (Arrangement.ArrangementType != ArrangementType.Bass) { return(true); } // Error check 220.00 and Fixed TuningDefinition tuning = (TuningDefinition)cmbTuningName.SelectedItem; Arrangement.Tuning = tuning.UIName; Arrangement.TuningStrings = tuning.Tuning; UpdateCentOffset(); // RE: annoying stuff. ony indicate that arrangement isn't autofixed since you won't name tuning that way. if ((Arrangement.TuningPitch == 220.00 && !Arrangement.Tuning.Contains("Fixed")) || (Arrangement.TuningPitch != 220.00 && Arrangement.Tuning.Contains("Fixed"))) { MessageBox.Show(@"The bass tuning name and frequency are not set correctly." + Environment.NewLine + Environment.NewLine + @"Tuning name must contain 'Fixed' when frequency is 220Hz" + Environment.NewLine + @"and name may not contain 'Fixed' if frequency is not 220Hz.", @"Error ... Low Bass Tuning", MessageBoxButtons.OK); return(false); } return(true); }
private void SelectTuningName() { if (Arrangement.ArrangementType == ArrangementType.Vocal || Arrangement.ArrangementType == ArrangementType.ShowLight) return; // find tuning in tuningComboBox list and make selection int foundTuning = -1; for (int tcbIndex = 0; tcbIndex < cmbTuningName.Items.Count; tcbIndex++) { cmbTuningName.SelectedIndex = tcbIndex; TuningDefinition tuning = (TuningDefinition)cmbTuningName.Items[tcbIndex]; // check both tuning strings and name match if (tuning.Tuning == Arrangement.TuningStrings) // && tuning.UIName == Arrangement.Tuning) { foundTuning = tcbIndex; break; } } // TODO: testing toolkit's AI // toolkit is pretty smart now so let it automatically set tuning if found // E Standard, Drop D, and Open E tuning are now the same for both guitar and bass if (foundTuning == -1) { cmbTuningName.SelectedIndex = 0; var selectedType = ((ArrangementType)cmbArrangementType.SelectedItem); ShowTuningForm(selectedType, new TuningDefinition(Arrangement.TuningStrings, _gameVersion)); } }
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; }
private void tuningEditButton_Click(object sender, EventArgs e) { var selectedType = ((ArrangementType)((ComboBox)arrangementTypeCombo).SelectedItem); TuningDefinition tuning = (TuningDefinition)tuningComboBox.SelectedItem; ShowTuningForm(selectedType, tuning); }
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); }
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(); }
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; } }
// only for RS2014 public static bool ApplyBassFix(Arrangement arr) { if (arr.TuningPitch.Equals(220.0)) { // MessageBox.Show("This song is already at 220Hz pitch (bass fixed applied already?)", MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } Song2014 songXml = Song2014.LoadFromFile(arr.SongXml.File); // Force 220Hz arr.TuningPitch = 220.0; songXml.CentOffset = "-1200.0"; // 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; } //Detect tuning var tuning = TuningDefinitionRepository.Instance().SelectAny(new TuningStrings(strings), GameVersion.RS2014); if (tuning == null) { tuning = new TuningDefinition(); tuning.Tuning = new TuningStrings(strings); tuning.Name = tuning.NameFromStrings(tuning.Tuning); tuning.UIName = tuning.Name = String.Format("{0} Fixed", tuning.Name); tuning.Custom = true; tuning.GameVersion = GameVersion.RS2014; TuningDefinitionRepository.Instance().Add(tuning, true); } arr.TuningStrings = tuning.Tuning; arr.Tuning = tuning.Name; songXml.Tuning = tuning.Tuning; File.Delete(arr.SongXml.File); using (var stream = File.OpenWrite(arr.SongXml.File)) { songXml.Serialize(stream, true); } return true; }
public void GenerateTuningData(Attributes2014 attribute, dynamic song) { if (song.Tuning == null) { return; } attribute.Tuning = song.Tuning; var tuning = new TuningDefinition(); var tuningName = tuning.NameFromStrings(attribute.Tuning); if (tuningName == "E Standard") { attribute.ArrangementProperties.StandardTuning = 1; } else { attribute.ArrangementProperties.StandardTuning = 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 void GenerateTuningData(Attributes2014 attribute, dynamic song) { // packer currently does very limited error checking (used mainly by advanced toolkit users) // this is a good place to ensure manifest data is the same as song xml data if (song.Version == "7") { if (song.CentOffset == null) { song.CentOffset = 0.0; } attribute.CentOffset = Convert.ToDouble(song.CentOffset); } if (song.Tuning == null) { song.Tuning = new TuningStrings { String0 = 0, String1 = 0, String2 = 0, String3 = 0, String4 = 0, String5 = 0 } } ; attribute.Tuning = song.Tuning; var tuning = new TuningDefinition(); var tuningName = tuning.NameFromStrings(attribute.Tuning); if (tuningName == "E Standard") { attribute.ArrangementProperties.StandardTuning = 1; } else { attribute.ArrangementProperties.StandardTuning = 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; }
public void LoadArrangementData(string xmlFilePath) { //Song XML File Arrangement.SongXml.File = xmlFilePath; Arrangement.XmlComments = Song2014.ReadXmlComments(xmlFilePath); // Song Info if (!ReferenceEquals(_xmlSong, null)) { var defaultAuthor = ConfigRepository.Instance()["general_defaultauthor"].Trim(); if (String.IsNullOrEmpty(_parentControl.SongTitle)) _parentControl.SongTitle = _xmlSong.Title.GetValidAtaSpaceName(); if (String.IsNullOrEmpty(_parentControl.SongTitleSort)) _parentControl.SongTitleSort = _xmlSong.SongNameSort.GetValidSortableName(); if (String.IsNullOrEmpty(_parentControl.AverageTempo)) _parentControl.AverageTempo = _xmlSong.AverageTempo.ToString().GetValidTempo(); if (String.IsNullOrEmpty(_parentControl.Artist)) _parentControl.Artist = _xmlSong.ArtistName.GetValidAtaSpaceName(); if (String.IsNullOrEmpty(_parentControl.ArtistSort)) _parentControl.ArtistSort = _xmlSong.ArtistNameSort.GetValidSortableName(); if (String.IsNullOrEmpty(_parentControl.Album)) _parentControl.Album = _xmlSong.AlbumName.GetValidAtaSpaceName(); if (String.IsNullOrEmpty(_parentControl.AlbumYear)) _parentControl.AlbumYear = _xmlSong.AlbumYear.GetValidYear(); // using first three letters of defaultAuthor to make DLCKey unique if (String.IsNullOrEmpty(_parentControl.DLCKey)) _parentControl.DLCKey = String.Format("{0}{1}{2}", defaultAuthor.Substring(0, Math.Min(3, defaultAuthor.Length)), _parentControl.Artist.GetValidAcronym(), _parentControl.SongTitle).GetValidKey(_parentControl.SongTitle); if (String.IsNullOrEmpty(_parentControl.AlbumSort)) { // use default author for AlbumSort or generate var useDefaultAuthor = ConfigRepository.Instance().GetBoolean("creator_usedefaultauthor"); if (useDefaultAuthor) _parentControl.AlbumSort = defaultAuthor.GetValidSortableName(); else _parentControl.AlbumSort = _xmlSong.AlbumNameSort.GetValidSortableName(); } } // Arrangment Information Arrangement.Name = (ArrangementName)cmbArrangementName.SelectedItem; Arrangement.ArrangementType = (ArrangementType)cmbArrangementType.SelectedItem; Arrangement.ScrollSpeed = tbarScrollSpeed.Value; Arrangement.PluckedType = chkBassPicked.Checked ? PluckedType.Picked : PluckedType.NotPicked; Arrangement.BonusArr = chkBonusArrangement.Checked; Arrangement.Metronome = chkMetronome.Checked ? Metronome.Generate : Metronome.None; // Tuning TuningDefinition tuning = (TuningDefinition)cmbTuningName.SelectedItem; Arrangement.Tuning = tuning.UIName; Arrangement.TuningStrings = tuning.Tuning; // TODO: Add capo selection to arrangement form if (!ReferenceEquals(_xmlSong, null)) Arrangement.CapoFret = _xmlSong.Capo; UpdateCentOffset(); // ToneSelector //TODO: add parsing tones events Arrangement.ToneBase = cmbToneBase.SelectedItem.ToString(); Arrangement.ToneA = (cmbToneA.SelectedItem != null) ? cmbToneA.SelectedItem.ToString() : ""; //Only need if have more than one tone Arrangement.ToneB = (cmbToneB.SelectedItem != null) ? cmbToneB.SelectedItem.ToString() : ""; Arrangement.ToneC = (cmbToneC.SelectedItem != null) ? cmbToneC.SelectedItem.ToString() : ""; Arrangement.ToneD = (cmbToneD.SelectedItem != null) ? cmbToneD.SelectedItem.ToString() : ""; // Gameplay Path Arrangement.RouteMask = RouteMask; // Xml data cleanup _xmlSong = null; // DLC IDs Guid guid; if (Guid.TryParse(txtPersistentId.Text, out guid) == false) txtPersistentId.Focus(); else Arrangement.Id = guid; int masterId; if (int.TryParse(txtMasterId.Text, out masterId) == false) txtMasterId.Focus(); else Arrangement.MasterId = masterId; }
public bool LoadArrangementData(string xmlfilepath) { //Song XML File Arrangement.SongXml.File = xmlfilepath; // SONG INFO // TODO: get song info from json or hsan file (would be better than from xml) if (!ReferenceEquals(xmlSong, null)) { var defaultAuthor = ConfigRepository.Instance()["general_defaultauthor"].Trim(); if (String.IsNullOrEmpty(parentControl.SongTitle)) { parentControl.SongTitle = xmlSong.Title ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.SongTitleSort)) { parentControl.SongTitleSort = xmlSong.SongNameSort.GetValidSortableName() ?? parentControl.SongTitle.GetValidSortableName(); } if (String.IsNullOrEmpty(parentControl.AverageTempo)) { parentControl.AverageTempo = Math.Round(xmlSong.AverageTempo).ToString() ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.Artist)) { parentControl.Artist = xmlSong.ArtistName ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.ArtistSort)) { parentControl.ArtistSort = xmlSong.ArtistNameSort.GetValidSortableName() ?? parentControl.Artist.GetValidSortableName(); } if (String.IsNullOrEmpty(parentControl.Album)) { parentControl.Album = xmlSong.AlbumName ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.AlbumYear)) { parentControl.AlbumYear = xmlSong.AlbumYear ?? String.Empty; } // using first three letters of defaultAuthor to make DLCKey unique if (String.IsNullOrEmpty(parentControl.DLCKey)) { parentControl.DLCKey = String.Format("{0}{1}{2}", defaultAuthor.Substring(0, Math.Min(3, defaultAuthor.Length)), parentControl.Artist.GetValidAcronym(), parentControl.SongTitle).GetValidKey(parentControl.SongTitle); } if (String.IsNullOrEmpty(parentControl.AlbumSort)) { // use default author for AlbumSort or generate var useDefaultAuthor = ConfigRepository.Instance().GetBoolean("creator_usedefaultauthor"); if (useDefaultAuthor) // && currentGameVersion == GameVersion.RS2014) { parentControl.AlbumSort = defaultAuthor.GetValidSortableName(); } else { parentControl.AlbumSort = xmlSong.AlbumNameSort.GetValidSortableName() ?? parentControl.Album.GetValidSortableName(); } } } //Arrangment Information Arrangement.Name = (ArrangementName)arrangementNameCombo.SelectedItem; Arrangement.ArrangementType = (ArrangementType)arrangementTypeCombo.SelectedItem; Arrangement.ScrollSpeed = scrollSpeedTrackBar.Value; Arrangement.PluckedType = Picked.Checked ? PluckedType.Picked : PluckedType.NotPicked; Arrangement.BonusArr = BonusCheckBox.Checked; Arrangement.Metronome = MetronomeCb.Checked ? Metronome.Generate : Metronome.None; // Tuning TuningDefinition tuning = (TuningDefinition)tuningComboBox.SelectedItem; Arrangement.Tuning = tuning.UIName; Arrangement.TuningStrings = tuning.Tuning; // TODO: Add capo selection to arrangement form if (!ReferenceEquals(xmlSong, null)) { Arrangement.CapoFret = xmlSong.Capo; } UpdateCentOffset(); //ToneSelector //TODO: add parsing tones events Arrangement.ToneBase = toneBaseCombo.SelectedItem.ToString(); Arrangement.ToneA = (toneACombo.SelectedItem != null) ? toneACombo.SelectedItem.ToString() : ""; //Only need if have more than one tone Arrangement.ToneB = (toneBCombo.SelectedItem != null) ? toneBCombo.SelectedItem.ToString() : ""; Arrangement.ToneC = (toneCCombo.SelectedItem != null) ? toneCCombo.SelectedItem.ToString() : ""; Arrangement.ToneD = (toneDCombo.SelectedItem != null) ? toneDCombo.SelectedItem.ToString() : ""; //Gameplay Path Arrangement.RouteMask = RouteMask; //Xml data cleanup xmlSong = null; // DLC IDs Guid guid; if (Guid.TryParse(PersistentId.Text, out guid) == false) { PersistentId.Focus(); } else { Arrangement.Id = guid; } int masterId; if (int.TryParse(MasterId.Text, out masterId) == false) { MasterId.Focus(); } else { Arrangement.MasterId = masterId; } return(true); }
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; }
private static void ParseTuning(Arrangement dest, Attributes2014 attr) { bool isBass = false; TuningDefinition tuning = null; switch (dest.Name) { case ArrangementName.Bass: tuning = TuningDefinitionRepository.Instance().SelectForBass(attr.Tuning, GameVersion.RS2014); isBass = true; break; case ArrangementName.Vocals: break; default: tuning = TuningDefinitionRepository.Instance().Select(attr.Tuning, GameVersion.RS2014); break; } if (tuning == null) { tuning = new TuningDefinition(); tuning.UIName = tuning.Name = TuningDefinition.NameFromStrings(attr.Tuning, isBass); tuning.Custom = true; tuning.GameVersion = GameVersion.RS2014; tuning.Tuning = attr.Tuning; TuningDefinitionRepository.Instance().Add(tuning, true); } dest.Tuning = tuning.UIName; dest.TuningStrings = tuning.Tuning; if (attr.CentOffset != null) dest.TuningPitch = attr.CentOffset.Cents2Frequency(); }
public bool LoadArrangementData(string xmlfilepath) { //Song XML File Arrangement.SongXml.File = xmlfilepath; // SONG INFO if (!ReferenceEquals(xmlSong, null)) { if (String.IsNullOrEmpty(parentControl.SongTitle)) { parentControl.SongTitle = xmlSong.Title ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.SongTitleSort)) { parentControl.SongTitleSort = xmlSong.SongNameSort.GetValidSortName() ?? parentControl.SongTitle.GetValidSortName(); } if (String.IsNullOrEmpty(parentControl.AverageTempo)) { parentControl.AverageTempo = Math.Round(xmlSong.AverageTempo).ToString() ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.Artist)) { parentControl.Artist = xmlSong.ArtistName ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.ArtistSort)) { parentControl.ArtistSort = xmlSong.ArtistNameSort.GetValidSortName() ?? parentControl.Artist.GetValidSortName(); } if (String.IsNullOrEmpty(parentControl.Album)) { parentControl.Album = xmlSong.AlbumName ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.AlbumYear)) { parentControl.AlbumYear = xmlSong.AlbumYear ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.DLCName)) { parentControl.DLCName = parentControl.Artist.Acronym() + parentControl.SongTitleSort; } } //Arrangment Information Arrangement.Name = (ArrangementName)arrangementNameCombo.SelectedItem; Arrangement.ArrangementType = (ArrangementType)arrangementTypeCombo.SelectedItem; Arrangement.ScrollSpeed = scrollSpeedTrackBar.Value; Arrangement.PluckedType = Picked.Checked ? PluckedType.Picked : PluckedType.NotPicked; Arrangement.BonusArr = BonusCheckBox.Checked; Arrangement.Metronome = MetronomeCb.Checked ? Metronome.Generate : Metronome.None; // Tuning TuningDefinition tuning = (TuningDefinition)tuningComboBox.SelectedItem; Arrangement.Tuning = tuning.UIName; Arrangement.TuningStrings = tuning.Tuning; // TODO: Add capo selection to arrangement form if (!ReferenceEquals(xmlSong, null)) { Arrangement.CapoFret = xmlSong.Capo; } UpdateCentOffset(); //ToneSelector Arrangement.ToneBase = toneBaseCombo.SelectedItem.ToString(); Arrangement.ToneA = (toneACombo.SelectedItem != null) ? toneACombo.SelectedItem.ToString() : ""; //Only need if have more than one tone Arrangement.ToneB = (toneBCombo.SelectedItem != null) ? toneBCombo.SelectedItem.ToString() : ""; Arrangement.ToneC = (toneCCombo.SelectedItem != null) ? toneCCombo.SelectedItem.ToString() : ""; Arrangement.ToneD = (toneDCombo.SelectedItem != null) ? toneDCombo.SelectedItem.ToString() : ""; //Gameplay Path Arrangement.RouteMask = RouteMask; //Xml data cleanup xmlSong = null; // DLC IDs Guid guid; if (Guid.TryParse(PersistentId.Text, out guid) == false) { PersistentId.Focus(); } else { Arrangement.Id = guid; } int masterId; if (int.TryParse(MasterId.Text, out masterId) == false) { MasterId.Focus(); } else { Arrangement.MasterId = masterId; } return(true); }
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 songXmlBrowseButton_Click(object sender, EventArgs e) { using (var ofd = new OpenFileDialog()) { ofd.Filter = "Rocksmith Song Xml Files (*.xml)|*.xml"; if (ofd.ShowDialog() != DialogResult.OK) { return; } if (isAlreadyAdded(ofd.FileName)) { MessageBox.Show("This arrangement already added, please choose another one. ", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } XmlFilePath.Text = ofd.FileName; } string xmlFilePath = XmlFilePath.Text; try { bool isVocal = false; try { xmlSong = Song2014.LoadFromFile(xmlFilePath); Arrangement.XmlComments = Song2014.ReadXmlComments(xmlFilePath); } catch (Exception ex) { if (ex.InnerException.Message.ToLower().Contains("<vocals")) { isVocal = true; } else { MessageBox.Show("Unable to get information from the arrangement XML. \nYour version of the EoF is up to date? \n" + ex.Message, DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } // SETUP FIELDS if (isVocal) { arrangementTypeCombo.SelectedItem = ArrangementType.Vocal; } else { var version = GameVersion.None; //Detect arrangement GameVersion if (xmlSong != null && xmlSong.Version != null) { var verAttrib = Convert.ToInt32(xmlSong.Version); if (verAttrib <= 6) { version = GameVersion.RS2012; } else if (verAttrib >= 7) { version = GameVersion.RS2014; } } else if (currentGameVersion == GameVersion.RS2012) { // add missing XML elements xmlSong.Version = "4"; xmlSong.Tuning = new TuningStrings { String0 = 0, String1 = 0, String2 = 0, String3 = 0, String4 = 0, String5 = 0 }; xmlSong.ArrangementProperties = new SongArrangementProperties2014 { StandardTuning = 1 }; version = GameVersion.RS2012; } else if (currentGameVersion == GameVersion.None) { using (var obj = new Rs1Converter()) { xmlSong = null; xmlSong = obj.SongToSong2014(Song.LoadFromFile(XmlFilePath.Text)); } currentGameVersion = GameVersion.RS2014; } else { MessageBox.Show("You are using a old version of EoF application, please update first.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); } // TODO: fix error checking logic for new types of conversion if (currentGameVersion != version && version != GameVersion.None) { Debug.WriteLine(String.Format("Please choose valid Rocksmith {0} arrangement file!", currentGameVersion)); //XmlFilePath.Text = ""; //return; } // SONG AND ARRANGEMENT INFO / ROUTE MASK BonusCheckBox.Checked = Equals(xmlSong.ArrangementProperties.BonusArr, 1); MetronomeCb.Checked = Equals(xmlSong.ArrangementProperties.Metronome, 2); if (!EditMode) { string arr = xmlSong.Arrangement.ToLowerInvariant(); if (arr.Contains("guitar") || arr.Contains("lead") || arr.Contains("rhythm") || arr.Contains("combo")) { arrangementTypeCombo.SelectedItem = ArrangementType.Guitar; if (arr.Contains("combo")) { arrangementNameCombo.SelectedItem = ArrangementName.Combo; if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Lead; } } else if (arr.Contains("guitar_22") || arr.Contains("lead") || Equals(xmlSong.ArrangementProperties.PathLead, 1)) { arrangementNameCombo.SelectedItem = ArrangementName.Lead; if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Lead; } } else if (arr.Contains("guitar") || arr.Contains("rhythm") || Equals(xmlSong.ArrangementProperties.PathRhythm, 1)) { arrangementNameCombo.SelectedItem = ArrangementName.Rhythm; if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Rhythm; } } } else if (arr.Contains("bass")) { arrangementTypeCombo.SelectedItem = ArrangementType.Bass; //SetTuningCombo(xmlSong.Tuning, true); Picked.Checked = Equals(xmlSong.ArrangementProperties.BassPick, 1); if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Bass; //Low tuning fix for bass, If lowstring is B and bass fix not applied if (xmlSong.Tuning.String0 < -4 && this.frequencyTB.Text == "440") { bassFix |= MessageBox.Show("Your tuning is too low, would you like to apply \"Low Tuning Fix?\"\n" + "Note, that this won't work if you re-save arangement in EOF.\n", "Low Tuning Fix Required!", MessageBoxButtons.YesNo) == DialogResult.Yes; } } } } //Tones setup if (currentGameVersion != GameVersion.RS2012) { Arrangement.ToneBase = xmlSong.ToneBase; Arrangement.ToneA = xmlSong.ToneA; Arrangement.ToneB = xmlSong.ToneB; Arrangement.ToneC = xmlSong.ToneC; Arrangement.ToneD = xmlSong.ToneD; Arrangement.ToneMultiplayer = null; SetupTones(Arrangement); //Apply bass Fix, refactor me. if (bassFix) { bassFix = false; Arrangement.SongXml.File = XmlFilePath.Text; parentControl.ApplyBassFix(Arrangement); } } // Setup tuning var selectedType = new ArrangementType(); if (xmlSong.Arrangement.ToLower() == "bass") { selectedType = ArrangementType.Bass; } else { selectedType = ArrangementType.Guitar; } FillTuningCombo(selectedType, currentGameVersion); // find tuning in tuningComboBox list and make selection int foundTuning = -1; for (int tcbIndex = 0; tcbIndex < tuningComboBox.Items.Count; tcbIndex++) { tuningComboBox.SelectedIndex = tcbIndex; TuningDefinition tuning = (TuningDefinition)tuningComboBox.Items[tcbIndex]; if (TuningDefinition.TuningEquals(tuning.Tuning, xmlSong.Tuning)) { foundTuning = tcbIndex; break; } } if (foundTuning == -1) { ShowTuningForm(selectedType, new TuningDefinition() { Tuning = xmlSong.Tuning, Custom = true, GameVersion = currentGameVersion }); } else { tuningComboBox.SelectedIndex = foundTuning; } tuningComboBox.Refresh(); Arrangement.Tuning = tuningComboBox.SelectedItem.ToString(); Arrangement.TuningStrings = xmlSong.Tuning; Arrangement.CapoFret = xmlSong.Capo; frequencyTB.Text = Arrangement.TuningPitch.ToString(); UpdateCentOffset(); // save converted RS1 to RS2014 Song2014 XML if (version == GameVersion.None) { var srcDir = Path.GetDirectoryName(XmlFilePath.Text); var srcName = Path.GetFileNameWithoutExtension(XmlFilePath.Text); var backupSrcPath = String.Format("{0}_{1}.xml", Path.Combine(srcDir, srcName), "RS1"); // backup original RS1 file File.Copy(XmlFilePath.Text, backupSrcPath); // write converted RS1 file using (FileStream stream = new FileStream(XmlFilePath.Text, FileMode.Create)) xmlSong.Serialize(stream, true); } } } catch (Exception ex) { MessageBox.Show("Unable to get information from the arrangement XML. \nYour version of the EoF is up to date? \n" + ex.Message, DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Convert RS1 Song Object to RS2 Song2014 Object /// RS1 to RS2014 Mapping Method /// </summary> /// <param name="rsSong"></param> /// <param name="srcPath"></param> /// <returns>Song2014</returns> public Song2014 SongToSong2014(Song rsSong) { // Song to Song2014 Mapping Song2014 rsSong2014 = new Song2014(); // NOTE: better more accurate/complete song info may be parsed and loaded // from the RS1 song.manifest.json file using RS1LoadFromFolder method rsSong2014.Version = "7"; rsSong2014.Title = rsSong.Title; rsSong2014.Arrangement = rsSong.Arrangement; rsSong2014.Part = rsSong.Part; rsSong2014.Offset = rsSong.Offset; rsSong2014.CentOffset = "0"; rsSong2014.SongLength = rsSong.SongLength; rsSong2014.LastConversionDateTime = DateTime.Now.ToString("MM-dd-yy HH:mm"); rsSong2014.StartBeat = rsSong.Ebeats[0].Time; // if RS1 CDLC Song XML originates from EOF it may // already contain AverageTempo otherwise it gets calculated rsSong2014.AverageTempo = rsSong.AverageTempo == 0 ? AverageBPM(rsSong) : rsSong.AverageTempo; // tuning parsed from RS1 song.manifest.json file by RS1LoadFromFolder rsSong2014.Tuning = rsSong.Tuning == null ? new TuningStrings { String0 = 0, String1 = 0, String2 = 0, String3 = 0, String4 = 0, String5 = 0 } : rsSong.Tuning; rsSong2014.Capo = 0; rsSong2014.ArtistName = rsSong.ArtistName; rsSong2014.AlbumName = rsSong.AlbumName; rsSong2014.AlbumYear = rsSong.AlbumYear; rsSong2014.CrowdSpeed = "1"; // RS1 before Bass Edition did not contain ArrangementProperties if (rsSong.ArrangementProperties == null) { rsSong.ArrangementProperties = new SongArrangementProperties(); } // initialize arrangement properties with zero's rsSong2014.ArrangementProperties = new SongArrangementProperties2014 { Represent = rsSong.ArrangementProperties.Represent, NonStandardChords = rsSong.ArrangementProperties.NonStandardChords, BarreChords = rsSong.ArrangementProperties.BarreChords, PowerChords = rsSong.ArrangementProperties.PowerChords, DropDPower = rsSong.ArrangementProperties.DropDPower, OpenChords = rsSong.ArrangementProperties.OpenChords, FingerPicking = rsSong.ArrangementProperties.FingerPicking, PickDirection = rsSong.ArrangementProperties.PickDirection, DoubleStops = rsSong.ArrangementProperties.DoubleStops, PalmMutes = rsSong.ArrangementProperties.PalmMutes, Harmonics = rsSong.ArrangementProperties.Harmonics, PinchHarmonics = rsSong.ArrangementProperties.PinchHarmonics, Hopo = rsSong.ArrangementProperties.Hopo, Tremolo = rsSong.ArrangementProperties.Tremolo, Slides = rsSong.ArrangementProperties.Slides, UnpitchedSlides = rsSong.ArrangementProperties.UnpitchedSlides, Bends = rsSong.ArrangementProperties.Bends, Tapping = rsSong.ArrangementProperties.Tapping, Vibrato = rsSong.ArrangementProperties.Vibrato, FretHandMutes = rsSong.ArrangementProperties.FretHandMutes, SlapPop = rsSong.ArrangementProperties.SlapPop, TwoFingerPicking = rsSong.ArrangementProperties.TwoFingerPicking, FifthsAndOctaves = rsSong.ArrangementProperties.FifthsAndOctaves, Syncopation = rsSong.ArrangementProperties.Syncopation, BassPick = rsSong.ArrangementProperties.BassPick, Sustain = rsSong.ArrangementProperties.Sustain }; var tuning = new TuningDefinition(); var tuningName = tuning.NameFromStrings(rsSong2014.Tuning); rsSong2014.ArrangementProperties.StandardTuning = tuningName == "E Standard" ? 1 : 0; rsSong2014.ArrangementProperties.Represent = 1; rsSong2014.ArrangementProperties.BonusArr = 0; // initial SWAG based on RS1 arrangement element rsSong2014.ArrangementProperties.RouteMask = rsSong.Arrangement.ToLower().Contains("lead") ? 1 : (rsSong.Arrangement.ToLower().Contains("rhythm") ? 2 : (rsSong.Arrangement.ToLower().Contains("combo") ? 2 // may not always be true : (rsSong.Arrangement.ToLower().Contains("bass") ? 4 : 1))); // but ok for now rsSong2014.ArrangementProperties.PathLead = rsSong2014.ArrangementProperties.RouteMask == 1 ? 1 : 0; rsSong2014.ArrangementProperties.PathRhythm = rsSong2014.ArrangementProperties.RouteMask == 1 ? 1 : 0; rsSong2014.ArrangementProperties.PathBass = rsSong2014.ArrangementProperties.RouteMask == 1 ? 1 : 0; // set tone defaults used to produce RS2014 CDLC rsSong2014.ToneBase = "Default"; rsSong2014.ToneA = ""; rsSong2014.ToneB = ""; rsSong2014.ToneC = ""; rsSong2014.ToneD = ""; // these elements have direct mappings rsSong2014.Phrases = rsSong.Phrases; rsSong2014.FretHandMuteTemplates = rsSong.FretHandMuteTemplates; rsSong2014.Ebeats = rsSong.Ebeats; rsSong2014.Sections = rsSong.Sections; rsSong2014.Events = rsSong.Events; // these prevent in game hanging rsSong2014.LinkedDiffs = new SongLinkedDiff[0]; rsSong2014.PhraseProperties = new SongPhraseProperty[0]; // these elements have no direct mapping, processing order is important rsSong2014 = ConvertChordTemplates(rsSong, rsSong2014); rsSong2014 = ConvertLevels(rsSong, rsSong2014); rsSong2014 = ConvertPhraseIterations(rsSong, rsSong2014); // these prevent in game hanging rsSong2014.Tones = new SongTone2014[0]; rsSong2014.NewLinkedDiff = new SongNewLinkedDiff[0]; // tested ... not the source of in game hangs // rsSong2014.TranscriptionTrack = TranscriptionTrack2014.GetDefault(); // tested ... confirmed this is a source of in game hangs // check alignment of Sections time with Ebeats first beat of measure time // TODO: use LINQ float fbomTime = 0; float nfbomTime = 0; foreach (var section in rsSong2014.Sections) { foreach (var ebeat in rsSong2014.Ebeats) { // save Ebeats first beat of measure time if (ebeat.Measure != -1) { fbomTime = ebeat.Time; } else { nfbomTime = ebeat.Time; } if (section.Name.ToLower().Contains("noguitar") && Math.Abs(ebeat.Time - section.StartTime) < 0.001) { // CRITICAL - fix Section noguitar time (matches EOF output) if (ebeat.Measure != -1) { section.StartTime = nfbomTime; Console.WriteLine("Applied fix to RS1->RS2 Section StartTime for: " + section.Name); } break; } // found a valid Section time if (ebeat.Measure != -1 && Math.Abs(ebeat.Time - section.StartTime) < 0.001) { break; } // fix invalid Section time if (ebeat.Measure == -1 && ebeat.Time > section.StartTime) { section.StartTime = fbomTime; Console.WriteLine("Applied fix to RS1->RS2 Section StartTime for: " + section.Name); break; } } } return(rsSong2014); }
private void OkButton_Click(object sender, EventArgs e) { //Validations var xmlfilepath = XmlFilePath.Text; if (!File.Exists(xmlfilepath)) { if (MessageBox.Show("Xml Arrangement file path is not valid.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { XmlFilePath.Focus(); return; } } if (currentGameVersion != GameVersion.RS2012) { if (!routeMaskLeadRadio.Checked && !routeMaskRhythmRadio.Checked && !routeMaskBassRadio.Checked && (ArrangementType)arrangementTypeCombo.SelectedItem != ArrangementType.Vocal) { if (MessageBox.Show("You did not select a Gameplay Path for this arrangement.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel) { gbGameplayPath.Focus(); return; } } } //Song XML File Arrangement.SongXml.File = xmlfilepath; // SONG INFO if (!ReferenceEquals(xmlSong, null)) { if (String.IsNullOrEmpty(parentControl.SongTitle)) { parentControl.SongTitle = xmlSong.Title ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.SongTitleSort)) { parentControl.SongTitleSort = xmlSong.SongNameSort.GetValidSortName() ?? parentControl.SongTitle.GetValidSortName(); } if (String.IsNullOrEmpty(parentControl.AverageTempo)) { parentControl.AverageTempo = Math.Round(xmlSong.AverageTempo).ToString() ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.Artist)) { parentControl.Artist = xmlSong.ArtistName ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.ArtistSort)) { parentControl.ArtistSort = xmlSong.ArtistNameSort.GetValidSortName() ?? parentControl.Artist.GetValidSortName(); } if (String.IsNullOrEmpty(parentControl.Album)) { parentControl.Album = xmlSong.AlbumName ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.AlbumYear)) { parentControl.AlbumYear = xmlSong.AlbumYear ?? String.Empty; } if (String.IsNullOrEmpty(parentControl.DLCName)) { parentControl.DLCName = parentControl.Artist.Acronym() + parentControl.SongTitleSort; } } //Arrangment Information Arrangement.Name = (ArrangementName)arrangementNameCombo.SelectedItem; Arrangement.ArrangementType = (ArrangementType)arrangementTypeCombo.SelectedItem; Arrangement.ScrollSpeed = scrollSpeedTrackBar.Value; Arrangement.PluckedType = Picked.Checked ? PluckedType.Picked : PluckedType.NotPicked; Arrangement.BonusArr = BonusCheckBox.Checked; Arrangement.Metronome = MetronomeCb.Checked ? Metronome.Generate : Metronome.None; // Tuning TuningDefinition tuning = (TuningDefinition)tuningComboBox.SelectedItem; Arrangement.Tuning = tuning.UIName; Arrangement.TuningStrings = tuning.Tuning; // TODO: Add capo selection to arrangement form if (!ReferenceEquals(xmlSong, null)) { Arrangement.CapoFret = xmlSong.Capo; } UpdateCentOffset(); //ToneSelector Arrangement.ToneBase = toneBaseCombo.SelectedItem.ToString(); Arrangement.ToneA = (toneACombo.SelectedItem != null) ? toneACombo.SelectedItem.ToString() : ""; //Only need if have more than one tone Arrangement.ToneB = (toneBCombo.SelectedItem != null) ? toneBCombo.SelectedItem.ToString() : ""; Arrangement.ToneC = (toneCCombo.SelectedItem != null) ? toneCCombo.SelectedItem.ToString() : ""; Arrangement.ToneD = (toneDCombo.SelectedItem != null) ? toneDCombo.SelectedItem.ToString() : ""; //Gameplay Path Arrangement.RouteMask = RouteMask; //Xml data cleanup xmlSong = null; // DLC IDs Guid guid; if (Guid.TryParse(PersistentId.Text, out guid) == false) { PersistentId.Focus(); } else { Arrangement.Id = guid; } int masterId; if (int.TryParse(MasterId.Text, out masterId) == false) { MasterId.Focus(); } else { Arrangement.MasterId = masterId; } DialogResult = DialogResult.OK; Close(); }
private void SaveTuningDefinition(TuningDefinition formTuning) { // can mess up the TuningDefinition.xml file on multiple adds TuningDefinitionRepository.Instance().Add(formTuning, true); TuningDefinitionRepository.Instance().Save(true); }
// 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); }
public bool LoadXmlArrangement(string xmlFilePath) { if (isAlreadyAdded(xmlFilePath)) { MessageBox.Show(@"XML Arrangement: " + Path.GetFileName(xmlFilePath) + " " + Environment.NewLine + @"has already been added. Please choose a new file. ", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } try { bool isVocal = false; bool isShowlight = false; try { xmlSong = Song2014.LoadFromFile(xmlFilePath); Arrangement.XmlComments = Song2014.ReadXmlComments(xmlFilePath); } catch (Exception ex) { if (ex.InnerException.Message.ToLower().Contains("<vocals")) { isVocal = true; } else if (ex.InnerException.Message.ToLower().Contains("<showlights")) { isShowlight = true; } else { MessageBox.Show(@"Unable to get information from XML arrangement: " + Environment.NewLine + Path.GetFileName(xmlFilePath) + Environment.NewLine + @"It may not be a valid arrangment or " + Environment.NewLine + @"your version of the EOF may be out of date." + Environment.NewLine + ex.Message, DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } } // SETUP FIELDS if (isVocal) { arrangementTypeCombo.SelectedItem = ArrangementType.Vocal; _arrangement.ArrangementType = ArrangementType.Vocal; } else if (isShowlight) { arrangementTypeCombo.SelectedItem = ArrangementType.ShowLight; _arrangement.ArrangementType = ArrangementType.ShowLight; } else { var version = GameVersion.None; //Detect arrangement GameVersion if (xmlSong != null && xmlSong.Version != null) { var verAttrib = Convert.ToInt32(xmlSong.Version); if (verAttrib <= 6) { version = GameVersion.RS2012; } else if (verAttrib >= 7) { version = GameVersion.RS2014; } } else if (currentGameVersion == GameVersion.RS2012) { // add missing XML elements xmlSong.Version = "4"; xmlSong.Tuning = new TuningStrings { String0 = 0, String1 = 0, String2 = 0, String3 = 0, String4 = 0, String5 = 0 }; xmlSong.ArrangementProperties = new SongArrangementProperties2014 { StandardTuning = 1 }; version = GameVersion.RS2012; } else if (currentGameVersion == GameVersion.None) { using (var obj = new Rs1Converter()) { xmlSong = null; xmlSong = obj.SongToSong2014(Song.LoadFromFile(XmlFilePath.Text)); } currentGameVersion = GameVersion.RS2014; } else { MessageBox.Show("Your version of EOF may be out of date, please update.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); } // TODO: fix error checking logic for new types of conversion if (currentGameVersion != version && version != GameVersion.None) { Debug.WriteLine(String.Format("Please choose valid Rocksmith {0} arrangement file!", currentGameVersion)); //XmlFilePath.Text = ""; //return; } // SONG AND ARRANGEMENT INFO / ROUTE MASK BonusCheckBox.Checked = Equals(xmlSong.ArrangementProperties.BonusArr, 1); MetronomeCb.Checked = Equals(xmlSong.ArrangementProperties.Metronome, 2); if (!EditMode) { string arr = xmlSong.Arrangement.ToLowerInvariant(); if (arr.Contains("guitar") || arr.Contains("lead") || arr.Contains("rhythm") || arr.Contains("combo")) { arrangementTypeCombo.SelectedItem = ArrangementType.Guitar; if (arr.Contains("combo")) { arrangementNameCombo.SelectedItem = ArrangementName.Combo; if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Lead; } } else if (arr.Contains("guitar_22") || arr.Contains("lead") || Equals(xmlSong.ArrangementProperties.PathLead, 1)) { arrangementNameCombo.SelectedItem = ArrangementName.Lead; if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Lead; } } else if (arr.Contains("guitar") || arr.Contains("rhythm") || Equals(xmlSong.ArrangementProperties.PathRhythm, 1)) { arrangementNameCombo.SelectedItem = ArrangementName.Rhythm; if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Rhythm; } } } else if (arr.Contains("bass")) { arrangementTypeCombo.SelectedItem = ArrangementType.Bass; //SetTuningCombo(xmlSong.Tuning, true); Picked.Checked = Equals(xmlSong.ArrangementProperties.BassPick, 1); if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Bass; //Low tuning fix for bass, If lowstring is B and bass fix not applied if (xmlSong.Tuning.String0 < -4 && this.frequencyTB.Text == "440") { bassFix |= MessageBox.Show("Your tuning is too low, would you like to apply \"Low Tuning Fix?\"\n" + "Note, that this won't work if you re-save arangement in EOF.\n", "Low Tuning Fix Required!", MessageBoxButtons.YesNo) == DialogResult.Yes; } } } } if (currentGameVersion != GameVersion.RS2012) { //Tones setup Arrangement.ToneBase = xmlSong.ToneBase; Arrangement.ToneA = xmlSong.ToneA; Arrangement.ToneB = xmlSong.ToneB; Arrangement.ToneC = xmlSong.ToneC; Arrangement.ToneD = xmlSong.ToneD; Arrangement.ToneMultiplayer = null; SetupTones(Arrangement); //Apply bass Fix, refactor me. if (bassFix) { bassFix = false; Arrangement.SongXml.File = XmlFilePath.Text; parentControl.ApplyBassFix(Arrangement); } } // Setup tuning var selectedType = new ArrangementType(); if (xmlSong.Arrangement.ToLower() == "bass") { selectedType = ArrangementType.Bass; } else { selectedType = ArrangementType.Guitar; } FillTuningCombo(selectedType, currentGameVersion); // find tuning in tuningComboBox list and make selection int foundTuning = -1; for (int tcbIndex = 0; tcbIndex < tuningComboBox.Items.Count; tcbIndex++) { tuningComboBox.SelectedIndex = tcbIndex; TuningDefinition tuning = (TuningDefinition)tuningComboBox.Items[tcbIndex]; if (tuning.Tuning == xmlSong.Tuning) { foundTuning = tcbIndex; break; } } if (foundTuning == -1 && selectedType != ArrangementType.Bass) { tuningComboBox.SelectedIndex = 0; ShowTuningForm(selectedType, new TuningDefinition { Tuning = xmlSong.Tuning, Custom = true, GameVersion = currentGameVersion }); } else { // E Standard, Drop D, and Open E tuning are same for both guitar and bass if (selectedType == ArrangementType.Bass) { if (xmlSong.Tuning.String4 == 0 && xmlSong.Tuning.String5 == 0) { Debug.WriteLine("Bass Tuning is the same as Guitar Tuning"); } else { tuningComboBox.SelectedIndex = 0; MessageBox.Show("Toolkit was not able to automatically set tuning for " + Environment.NewLine + "Bass Arrangement: " + Path.GetFileName(xmlFilePath) + Environment.NewLine + "Use the tuning selector dropdown or Tunining Editor " + Environment.NewLine + "to manually set the correct bass tuning.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } tuningComboBox.Refresh(); Arrangement.Tuning = tuningComboBox.SelectedItem.ToString(); Arrangement.TuningStrings = xmlSong.Tuning; Arrangement.CapoFret = xmlSong.Capo; frequencyTB.Text = Arrangement.TuningPitch.ToString(); UpdateCentOffset(); // save converted RS1 to RS2014 Song2014 XML if (version == GameVersion.None) { var srcDir = Path.GetDirectoryName(XmlFilePath.Text); var srcName = Path.GetFileNameWithoutExtension(XmlFilePath.Text); var backupSrcPath = String.Format("{0}_{1}.xml", Path.Combine(srcDir, srcName), "RS1"); // backup original RS1 file File.Copy(XmlFilePath.Text, backupSrcPath); // write converted RS1 file using (FileStream stream = new FileStream(XmlFilePath.Text, FileMode.Create)) xmlSong.Serialize(stream, true); } } } catch (Exception ex) { MessageBox.Show(@"Unable to get information from XML arrangement: " + Environment.NewLine + Path.GetFileName(xmlFilePath) + Environment.NewLine + @"It may not be a valide arrangment or " + Environment.NewLine + @"your version of the EOF may be out of date." + Environment.NewLine + ex.Message, DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } return(true); }
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; } }
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; } }
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); } }
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 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; } 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; } } } 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 }
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 (attr.Tone_A != null && jsonTone.Name.ToLower() == attr.Tone_A.ToLower()) this.ToneA = song.ToneA = attr.Tone_A; if (attr.Tone_B != null && jsonTone.Name.ToLower() == attr.Tone_B.ToLower()) { this.ToneB = song.ToneB = attr.Tone_B; toneId = 1; } if (attr.Tone_C != null && jsonTone.Name.ToLower() == attr.Tone_C.ToLower()) { this.ToneC = song.ToneC = attr.Tone_C; toneId = 2; } if (attr.Tone_D != null && 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); } }
public bool LoadXmlArrangement(string xmlFilePath) { if (IsAlreadyAdded(xmlFilePath)) { MessageBox.Show(@"XML Arrangement: " + Path.GetFileName(xmlFilePath) + @" " + Environment.NewLine + @"has already been added. Please choose a new file. ", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } try { bool isVocal = false; bool isShowlight = false; try { xmlSong = Song2014.LoadFromFile(xmlFilePath); Arrangement.XmlComments = Song2014.ReadXmlComments(xmlFilePath); } catch (Exception ex) { if (ex.InnerException.Message.ToLower().Contains("<vocals")) { isVocal = true; } else if (ex.InnerException.Message.ToLower().Contains("<showlights")) { isShowlight = true; } else { MessageBox.Show(@"Unable to get information from XML arrangement: " + Environment.NewLine + Path.GetFileName(xmlFilePath) + Environment.NewLine + @"It may not be a valid arrangement or " + Environment.NewLine + @"your version of the EOF may be out of date." + Environment.NewLine + ex.Message, DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } } // SETUP FIELDS if (isVocal) { arrangementTypeCombo.SelectedItem = ArrangementType.Vocal; _arrangement.ArrangementType = ArrangementType.Vocal; } else if (isShowlight) { arrangementTypeCombo.SelectedItem = ArrangementType.ShowLight; _arrangement.ArrangementType = ArrangementType.ShowLight; } else { var version = GameVersion.None; //Detect arrangement GameVersion if (xmlSong != null && xmlSong.Version != null) { var verAttrib = Convert.ToInt32(xmlSong.Version); if (verAttrib <= 6) { version = GameVersion.RS2012; } else if (verAttrib >= 7) { version = GameVersion.RS2014; } } else { switch (currentGameVersion) { case GameVersion.RS2012: // add missing XML elements xmlSong.Version = "4"; xmlSong.Tuning = new TuningStrings { String0 = 0, String1 = 0, String2 = 0, String3 = 0, String4 = 0, String5 = 0 }; xmlSong.ArrangementProperties = new SongArrangementProperties2014 { StandardTuning = 1 }; version = GameVersion.RS2012; break; case GameVersion.None: using (var obj = new Rs1Converter()) { xmlSong = null; xmlSong = obj.SongToSong2014(Song.LoadFromFile(XmlFilePath.Text)); } currentGameVersion = GameVersion.RS2014; break; default: MessageBox.Show("Your version of EOF may be out of date, please update.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } } // TODO: fix error checking logic for new types of conversion if (currentGameVersion != version && version != GameVersion.None) { Debug.WriteLine("Please choose valid Rocksmith {0} arrangement file!", currentGameVersion); //XmlFilePath.Text = ""; //return; } // SONG AND ARRANGEMENT INFO / ROUTE MASK BonusCheckBox.Checked = Equals(xmlSong.ArrangementProperties.BonusArr, 1); MetronomeCb.Checked = Equals(xmlSong.ArrangementProperties.Metronome, 2); if (!EditMode) { string arr = xmlSong.Arrangement.ToLowerInvariant(); if (arr.Contains("guitar") || arr.Contains("lead") || arr.Contains("rhythm") || arr.Contains("combo")) { arrangementTypeCombo.SelectedItem = ArrangementType.Guitar; if (arr.Contains("combo")) { arrangementNameCombo.SelectedItem = ArrangementName.Combo; if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Lead; } } else if (arr.Contains("guitar_22") || arr.Contains("lead") || Equals(xmlSong.ArrangementProperties.PathLead, 1)) { arrangementNameCombo.SelectedItem = ArrangementName.Lead; if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Lead; } } else if (arr.Contains("guitar") || arr.Contains("rhythm") || Equals(xmlSong.ArrangementProperties.PathRhythm, 1)) { arrangementNameCombo.SelectedItem = ArrangementName.Rhythm; if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Rhythm; } } } else if (arr.Contains("bass")) { arrangementTypeCombo.SelectedItem = ArrangementType.Bass; Picked.Checked = Equals(xmlSong.ArrangementProperties.BassPick, 1); if (currentGameVersion != GameVersion.RS2012) { RouteMask = RouteMask.Bass; //Low tuning fix for bass, If lowest string is B and bass fix not applied TODO:applyonly when 'generate' if (xmlSong.Tuning.String0 < -4 && Arrangement.TuningPitch != 220) { bassFix |= MessageBox.Show(@"The bass tuning may be too low. Apply Low Bass Tuning Fix?" + Environment.NewLine + @"Note: The fix will revert if bass arrangement is re-saved in EOF. ", @"Warning ... Low Bass Tuning", MessageBoxButtons.YesNo) == DialogResult.Yes; } } } } if (currentGameVersion != GameVersion.RS2012) { //Tones setup //TODO: add parsing tones events Arrangement.ToneBase = xmlSong.ToneBase; Arrangement.ToneA = xmlSong.ToneA; Arrangement.ToneB = xmlSong.ToneB; Arrangement.ToneC = xmlSong.ToneC; Arrangement.ToneD = xmlSong.ToneD; Arrangement.ToneMultiplayer = null; SetupTones(Arrangement); // Fix Low Bass Tuning if (bassFix) { bassFix = false; Arrangement.SongXml.File = XmlFilePath.Text; if (Arrangement.TuningStrings == null) { // need to load tuning here from the xml arrangement Arrangement.TuningStrings = new TuningStrings(); Arrangement.TuningStrings = xmlSong.Tuning; } if (!TuningFrequency.ApplyBassFix(Arrangement)) { MessageBox.Show("This bass arrangement is already at 220Hz pitch. ", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var commentsList = Arrangement.XmlComments.ToList(); commentsList.Add(new XComment("Low Bass Tuning Fixed")); Arrangement.XmlComments = commentsList; } xmlSong.Tuning = Arrangement.TuningStrings; } } // Setup tuning ArrangementType selectedType; if (xmlSong.Arrangement.ToLower() == "bass") { selectedType = ArrangementType.Bass; } else { selectedType = ArrangementType.Guitar; } FillTuningCombo(selectedType, currentGameVersion); // find tuning in tuningComboBox list and make selection int foundTuning = -1; for (int tcbIndex = 0; tcbIndex < tuningComboBox.Items.Count; tcbIndex++) { tuningComboBox.SelectedIndex = tcbIndex; TuningDefinition tuning = (TuningDefinition)tuningComboBox.Items[tcbIndex]; if (tuning.Tuning == xmlSong.Tuning) { foundTuning = tcbIndex; break; } } if (foundTuning == -1 && selectedType != ArrangementType.Bass) { tuningComboBox.SelectedIndex = 0; ShowTuningForm(selectedType, new TuningDefinition(xmlSong.Tuning, currentGameVersion)); //FIXME: Don't use this for QuickAdd call } // E Standard, Drop D, and Open E tuning are now the same for both guitar and bass if (foundTuning == -1 && selectedType == ArrangementType.Bass) { tuningComboBox.SelectedIndex = 0; MessageBox.Show("Toolkit was not able to automatically set tuning for" + Environment.NewLine + "Bass Arrangement: " + Path.GetFileName(xmlFilePath) + Environment.NewLine + "Use the tuning selector dropdown or Tuning Editor" + Environment.NewLine + "to customize bass tuning (as defined for six strings). ", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); } tuningComboBox.Refresh(); Arrangement.Tuning = tuningComboBox.SelectedItem.ToString(); Arrangement.TuningStrings = xmlSong.Tuning; Arrangement.CapoFret = xmlSong.Capo; frequencyTB.Text = Arrangement.TuningPitch.ToString(CultureInfo.InvariantCulture); // bastard bass hack if (Arrangement.Tuning.ToLower().Contains("fixed")) { frequencyTB.Text = "220"; } //UpdateCentOffset();//bad way to update tuning info, IMO // save converted RS1 to RS2014 Song2014 XML if (version == GameVersion.None) { var srcDir = Path.GetDirectoryName(XmlFilePath.Text); var srcName = Path.GetFileNameWithoutExtension(XmlFilePath.Text); var backupSrcPath = String.Format("{0}_{1}.xml", Path.Combine(srcDir, srcName), "RS1"); // backup original RS1 file File.Copy(XmlFilePath.Text, backupSrcPath); // write converted RS1 file using (var stream = new FileStream(XmlFilePath.Text, FileMode.Create)) xmlSong.Serialize(stream, true); } } } catch (Exception ex) { MessageBox.Show(@"Unable to get information from XML arrangement: " + Environment.NewLine + Path.GetFileName(xmlFilePath) + Environment.NewLine + @"It may not be a valid arrangement or " + Environment.NewLine + @"your version of the EOF may be out of date." + Environment.NewLine + ex.Message, DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } return(true); }