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); } }
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); }
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; } try { bool isVocal = false; try { xmlSong = Song2014.LoadFromFile(XmlFilePath.Text); } 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 { MessageBox.Show("You are using a old version of EoF application, please update first.", DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (currentGameVersion != version) { MessageBox.Show(String.Format("Please choose valid Rocksmith {0} arrangement file!", currentGameVersion)); XmlFilePath.Text = ""; return; } // Setup tuning SetTuningCombo(xmlSong.Tuning); Arrangement.Tuning = tuningComboBox.SelectedItem.ToString(); Arrangement.TuningStrings = xmlSong.Tuning; Arrangement.CapoFret = xmlSong.Capo; frequencyTB.Text = Arrangement.TuningPitch.ToString(); UpdateCentOffset(); // 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("guitar_22") || arr.Contains("lead") || arr.Contains("combo") || Equals(xmlSong.ArrangementProperties.PathLead, 1)) { arrangementNameCombo.SelectedItem = ArrangementName.Lead; if (currentGameVersion == GameVersion.RS2014) { RouteMask = RocksmithToolkitLib.DLCPackage.RouteMask.Lead; } } else if (arr.Contains("guitar") || arr.Contains("rhythm") || Equals(xmlSong.ArrangementProperties.PathRhythm, 1)) { arrangementNameCombo.SelectedItem = ArrangementName.Rhythm; if (currentGameVersion == GameVersion.RS2014) { RouteMask = RocksmithToolkitLib.DLCPackage.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.RS2014) { RouteMask = RocksmithToolkitLib.DLCPackage.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.RS2014) { 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); frequencyTB.Text = Arrangement.TuningPitch.ToString(); UpdateCentOffset(); SetTuningCombo(Arrangement.TuningStrings); } } } 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); } }