Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public bool LoadXmlArrangement(string xmlFilePath)
        {
            // only use this method when adding arrangements
            if (EditMode)
                return false;

            Arrangement = new Arrangement
            {
                SongFile = new SongFile { File = "" },
                SongXml = new SongXML { File = xmlFilePath }
            };

            try
            {
                // SETUP FIELDS
                if (xmlFilePath.ToLower().EndsWith("vocals.xml") || xmlFilePath.ToLower().EndsWith("vocals_rs2.xml"))
                {
                    cmbArrangementType.SelectedItem = ArrangementType.Vocal;
                    Arrangement.ArrangementType = ArrangementType.Vocal;

                    if (xmlFilePath.ToLower().EndsWith("_jvocals.xml") || xmlFilePath.ToLower().EndsWith("jvocals_rs2.xml"))
                        cmbArrangementName.SelectedItem = ArrangementName.JVocals;
                    else
                        cmbArrangementName.SelectedItem = ArrangementName.Vocals;
                }
                else if (xmlFilePath.ToLower().EndsWith("_showlights.xml"))
                {
                    cmbArrangementType.SelectedItem = ArrangementType.ShowLight;
                    Arrangement.ArrangementType = ArrangementType.ShowLight;
                }
                else
                {
                    _xmlSong = Song2014.LoadFromFile(xmlFilePath);
                    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 (_gameVersion)
                        {
                            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));
                                }
                                _gameVersion = 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 (_gameVersion != version && version != GameVersion.None)
                    {
                        Debug.WriteLine("Please choose valid Rocksmith {0} Arrangement file!", _gameVersion);
                        //XmlFilePath.Text = "";
                        //return;
                    }

                    // SONG AND ARRANGEMENT INFO / ROUTE MASK
                    chkBonusArrangement.Checked = Equals(_xmlSong.ArrangementProperties.BonusArr, 1);
                    chkMetronome.Checked = Equals(_xmlSong.ArrangementProperties.Metronome, 2);
                    Arrangement.ArrangementPropeties = _xmlSong.ArrangementProperties;
                    Arrangement.CapoFret = _xmlSong.Capo;
                    Arrangement.TuningStrings = _xmlSong.Tuning;

                    if (!String.IsNullOrEmpty(_xmlSong.CentOffset))
                        Arrangement.TuningPitch = Convert.ToDouble(_xmlSong.CentOffset).Cents2Frequency();

                    txtFrequency.Text = (Arrangement.TuningPitch > 0) ? Arrangement.TuningPitch.ToString() : "440.00";

                    var arr = _xmlSong.Arrangement.ToLowerInvariant();

                    if (arr.Contains("guitar") || arr.Contains("lead") || arr.Contains("rhythm") || arr.Contains("combo"))
                    {
                        cmbArrangementType.SelectedItem = ArrangementType.Guitar;
                        Arrangement.ArrangementType = ArrangementType.Guitar;

                        if (arr.Contains("combo"))
                        {
                            cmbArrangementName.SelectedItem = ArrangementName.Combo;
                            if (_gameVersion != GameVersion.RS2012) RouteMask = RouteMask.Lead;
                        }
                        else if (arr.Contains("guitar_22") || arr.Contains("lead") || Equals(_xmlSong.ArrangementProperties.PathLead, 1))
                        {
                            cmbArrangementName.SelectedItem = ArrangementName.Lead;
                            if (_gameVersion != GameVersion.RS2012) RouteMask = RouteMask.Lead;
                        }
                        else if (arr.Contains("guitar") || arr.Contains("rhythm") || Equals(_xmlSong.ArrangementProperties.PathRhythm, 1))
                        {
                            cmbArrangementName.SelectedItem = ArrangementName.Rhythm;
                            if (_gameVersion != GameVersion.RS2012) RouteMask = RouteMask.Rhythm;
                        }
                    }
                    else if (arr.Contains("bass"))
                    {
                        cmbArrangementType.SelectedItem = ArrangementType.Bass;
                        Arrangement.ArrangementType = ArrangementType.Bass;
                        chkBassPicked.Checked = Equals(_xmlSong.ArrangementProperties.BassPick, 1);
                        if (_gameVersion != GameVersion.RS2012) RouteMask = RouteMask.Bass;
                    }

                    if (_gameVersion != 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);
                    }

                    if (Arrangement.ArrangementType == ArrangementType.Bass)
                        FixBassTuning();

                    SelectTuningName();
                    CheckTuning();

                    // save converted RS1 to RS2014 Song2014 XML
                    if (version == GameVersion.None)
                    {
                        var srcDir = Path.GetDirectoryName(xmlFilePath);
                        var srcName = Path.GetFileNameWithoutExtension(xmlFilePath);
                        var backupSrcPath = String.Format("{0}_{1}.xml", Path.Combine(srcDir, srcName), "RS1");

                        // backup original RS1 file
                        File.Copy(xmlFilePath, backupSrcPath);

                        // write converted RS1 file
                        using (var stream = new FileStream(xmlFilePath, 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;
        }
        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)
                        ShowTuningForm(selectedType, new TuningDefinition { Tuning = xmlSong.Tuning, Custom = true, GameVersion = currentGameVersion });
                    else
                    {
                        if (selectedType == ArrangementType.Bass)
                        {
                            MessageBox.Show(@"Remember to set the correct tuning using Edit for" + Environment.NewLine +
                                @"Bass Arrangement: " + Path.GetFileName(xmlFilePath),
                                DLCPackageCreator.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Warning);

                            tuningComboBox.SelectedIndex = 0;
                        }
                        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 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)
                    XmlFilePath.Text = ofd.FileName;
                else
                    return;
            }
            try {
                Song2014 xmlSong = null;
                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;

                    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;
                    }

                    // SONG INFO
                    if (String.IsNullOrEmpty(parentControl.SongTitle)) parentControl.SongTitle = xmlSong.Title ?? String.Empty;
                    if (String.IsNullOrEmpty(parentControl.SongTitleSort)) parentControl.SongTitleSort = xmlSong.SongNameSort ?? parentControl.SongTitle;
                    if (String.IsNullOrEmpty(parentControl.DLCName)) parentControl.DLCName = parentControl.SongTitleSort;
                    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 ?? parentControl.Artist;
                    if (String.IsNullOrEmpty(parentControl.Album)) parentControl.Album = xmlSong.AlbumName ?? String.Empty;
                    if (String.IsNullOrEmpty(parentControl.AlbumYear)) parentControl.AlbumYear = xmlSong.AlbumYear ?? String.Empty;

                    //Setup tuning
                    SetTuningCombo(xmlSong.Tuning);

                    // SONG AND ARRANGEMENT INFO / ROUTE MASK
                    string arr = xmlSong.Arrangement;
                    bool Edit = routeMaskNoneRadio.Checked;
                    if (arr.ToLower().Contains("guitar") || arr.ToLower().Contains("lead") || arr.ToLower().Contains("rhythm") || arr.ToLower().Contains("combo"))
                    {
                        arrangementTypeCombo.SelectedItem = ArrangementType.Guitar;
                        if (Edit & arr.ToLower().Contains("guitar 22") || arr.ToLower().Contains("lead") || arr.ToLower().Contains("combo"))
                        {
                            arrangementNameCombo.SelectedItem = ArrangementName.Lead;
                            if (currentGameVersion == GameVersion.RS2014) RouteMask = RocksmithToolkitLib.DLCPackage.RouteMask.Lead;
                        }
                        if (Edit & arr.ToLower().Contains("guitar") || arr.ToLower().Contains("rhythm"))
                        {
                            arrangementNameCombo.SelectedItem = ArrangementName.Rhythm;
                            if (currentGameVersion == GameVersion.RS2014) RouteMask = RocksmithToolkitLib.DLCPackage.RouteMask.Rhythm;
                        }
                    }
                    if (arr.ToLower().Contains("bass"))
                    {
                        SetTuningCombo(xmlSong.Tuning, true);
                        arrangementTypeCombo.SelectedItem = ArrangementType.Bass;
                        Picked.Checked = xmlSong.ArrangementProperties.BassPick == 1;
                        if (currentGameVersion == GameVersion.RS2014) RouteMask = RocksmithToolkitLib.DLCPackage.RouteMask.Bass;
                    }
                    //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);
                    }
                }
            } 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);
            }
        }
Exemple #7
0
        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)
                {
                    XmlFilePath.Text = ofd.FileName;
                }
                else
                {
                    return;
                }
            }
            try {
                Song2014 xmlSong = null;
                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;

                    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;
                    }

                    // SONG INFO
                    if (String.IsNullOrEmpty(parentControl.SongTitle))
                    {
                        parentControl.SongTitle = xmlSong.Title ?? String.Empty;
                    }
                    if (String.IsNullOrEmpty(parentControl.SongTitleSort))
                    {
                        parentControl.SongTitleSort = xmlSong.SongNameSort ?? parentControl.SongTitle;
                    }
                    if (String.IsNullOrEmpty(parentControl.DLCName))
                    {
                        parentControl.DLCName = parentControl.SongTitleSort;
                    }
                    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 ?? parentControl.Artist;
                    }
                    if (String.IsNullOrEmpty(parentControl.Album))
                    {
                        parentControl.Album = xmlSong.AlbumName ?? String.Empty;
                    }
                    if (String.IsNullOrEmpty(parentControl.AlbumYear))
                    {
                        parentControl.AlbumYear = xmlSong.AlbumYear ?? String.Empty;
                    }

                    //Setup tuning
                    SetTuningCombo(xmlSong.Tuning);

                    // SONG AND ARRANGEMENT INFO / ROUTE MASK
                    string arr  = xmlSong.Arrangement;
                    bool   Edit = routeMaskNoneRadio.Checked;
                    if (arr.ToLower().Contains("guitar") || arr.ToLower().Contains("lead") || arr.ToLower().Contains("rhythm") || arr.ToLower().Contains("combo"))
                    {
                        arrangementTypeCombo.SelectedItem = ArrangementType.Guitar;
                        if (Edit & arr.ToLower().Contains("guitar 22") || arr.ToLower().Contains("lead") || arr.ToLower().Contains("combo"))
                        {
                            arrangementNameCombo.SelectedItem = ArrangementName.Lead;
                            if (currentGameVersion == GameVersion.RS2014)
                            {
                                RouteMask = RocksmithToolkitLib.DLCPackage.RouteMask.Lead;
                            }
                        }
                        if (Edit & arr.ToLower().Contains("guitar") || arr.ToLower().Contains("rhythm"))
                        {
                            arrangementNameCombo.SelectedItem = ArrangementName.Rhythm;
                            if (currentGameVersion == GameVersion.RS2014)
                            {
                                RouteMask = RocksmithToolkitLib.DLCPackage.RouteMask.Rhythm;
                            }
                        }
                    }
                    if (arr.ToLower().Contains("bass"))
                    {
                        SetTuningCombo(xmlSong.Tuning, true);
                        arrangementTypeCombo.SelectedItem = ArrangementType.Bass;
                        Picked.Checked = xmlSong.ArrangementProperties.BassPick == 1;
                        if (currentGameVersion == GameVersion.RS2014)
                        {
                            RouteMask = RocksmithToolkitLib.DLCPackage.RouteMask.Bass;
                        }
                    }
                    //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);
                    }
                }
            } 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 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);
                    Arrangement.ArrangementPropeties = xmlSong.ArrangementProperties;
                    Arrangement.CapoFret = xmlSong.Capo;

                    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;
        }
Exemple #9
0
        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);
            }
        }
        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;

                    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);

                    // SONG AND ARRANGEMENT INFO / ROUTE MASK
                    BonusCheckBox.Checked = Equals(xmlSong.ArrangementProperties.BonusArr, 1);
                    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;
                            }
                            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;
                            }

                        }
                        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;
                        }
                    }
                    //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);
                    }
                }
            } 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);
            }
        }