void InitializePlanetside2Editor() { this.Text = _applicationName + " " + _versionString; this.VersionStringLabel1.Text = _versionString; _currentUserOptionsINI = new UserOptionsINI(); /// <summary> /// Initialize UserOptions.INI location information /// </summary> /// <param name="sender"></param> /// <param name="e"></param> if (UseroptionsLocationTextbox.Text == "") { for(int i=0;i<_defaultGamePaths.Length;i++) { if (File.Exists(_currentRootDirectory+_defaultGamePaths[i]+"UserOptions.ini")) { UseroptionsLocationTextbox.Text = _currentRootDirectory+_defaultGamePaths[i]+"UserOptions.ini"; break; } } } /// <summary> /// Initialize Backup location information /// </summary> /// <param name="sender"></param> /// <param name="e"></param> if (BackupLocationTextbox.Text == "") { if (Directory.Exists(_currentWorkDirectory+"Backups\\")) BackupLocationTextbox.Text = _currentWorkDirectory+"Backups\\"; } /// <summary> /// Initialize Value Catalogue Location Information /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// if (ValueCatalogueLcationTextbox.Text == "") { if (File.Exists(_currentWorkDirectory+"PS2ValueCatalogue.INI")) ValueCatalogueLcationTextbox.Text = _currentWorkDirectory+"PS2ValueCatalogue.INI"; } /// <summary> /// LoadINI if current location information is correct /// </summary> /// <param name="sender"></param> /// <param name="e"></param> if (UseroptionsLocationTextbox.Text != "") { _currentUserOptionsINI._location= UseroptionsLocationTextbox.Text; LoadINI(); PopulateValueTree(); RawINITextBox.Text = _currentUserOptionsINI.toString(); } SomethingUpdated(); }
private bool LoadINIFromStringArray(string[] _stringArrayToLoadFrom) { UserOptionsINI _tempINI = new UserOptionsINI(); string[] _sectionStringArray; //second level data set, a section chopped out of the ini file int _sectionStart=0; // to be set to the start of each section, used respectively int _sectionEnd=0; // to be set to the end of each section, used respectively int _foruses = 0; try { for(var _currentLine=0;_currentLine<_stringArrayToLoadFrom.Length;_currentLine++) // loop running through each individual line, will skip to later lines with controls inside another loop { _foruses++; if (isThisASectionHeader(_stringArrayToLoadFrom[_currentLine])) { _sectionStart = _currentLine;// we've found a section! the temp is set to the current line for(var _startOfNextSectionPosition=_currentLine+1;_startOfNextSectionPosition<_stringArrayToLoadFrom.Length;_startOfNextSectionPosition++)// loop running through the next set of lines to find the start of the next section { _foruses++; //if (_currentLine>=116) // System.Diagnostics.Debug.WriteLine(isThisASectionHeader(_lines[_startOfNextSectionPosition]).ToString()); if (isThisASectionHeader(_stringArrayToLoadFrom[_startOfNextSectionPosition]) || _startOfNextSectionPosition == (_stringArrayToLoadFrom.Length-1))// we have found the start of the next section! { int _sectionLength; //if (_currentLine>=116) System.Diagnostics.Debug.WriteLine(isThisASectionHeader(_lines[_currentLine]).ToString()); if (_stringArrayToLoadFrom[_startOfNextSectionPosition-1].Length>3)//is this large enough to actually be meaningful? a=1 makes 3 chars { _sectionEnd = _startOfNextSectionPosition - 1; // we have found the end of the current section! _sectionLength = _startOfNextSectionPosition-_currentLine; } else if (_startOfNextSectionPosition != (_stringArrayToLoadFrom.Length-1)) { _sectionEnd = _startOfNextSectionPosition - 2; // we have found the end of the current section! _sectionLength = _startOfNextSectionPosition-_currentLine; } else { _sectionEnd = _startOfNextSectionPosition; // we have found the end of the current section! _sectionLength = _startOfNextSectionPosition-_currentLine; } _sectionStringArray = new string[_sectionLength];// initialize dat string array for (var _currentLineOfCurrentSection = 0;_currentLineOfCurrentSection<_sectionLength;_currentLineOfCurrentSection++)// loop running through each line of the section { _foruses++; _sectionStringArray[_currentLineOfCurrentSection] = _stringArrayToLoadFrom[_currentLine + _currentLineOfCurrentSection];// copy all lines in the found section to the string array } //if(_lines[_startOfNextSectionPosition]=="[Rendering]") // System.Diagnostics.Debug.WriteLine(isThisASectionHeader(_lines[_startOfNextSectionPosition])); if (_tempINI.FindSection(_sectionStringArray[0]) == -1) // combine sections of same name { _tempINI._sectionList.Add(new Section());// we need a new section object to put the found section into _tempINI._sectionList[_tempINI._sectionList.Count-1].fromStringArray(_sectionStringArray);// throw our found section into our new section object } else { _tempINI._sectionList[_tempINI.FindSection(_sectionStringArray[0])].fromStringArray(_sectionStringArray); } _sectionStringArray = null;// uninitialize the string array, it's been used and now discarded break;// end current for loop } if (_startOfNextSectionPosition>=1000) MessageBox.Show("Sanity Check, _sectionEndPosition length exceeded 1000"); if (_foruses>=1000) MessageBox.Show("Sanity Check, _forUses length exceeded 1000"); //if (_sectionEndPosition >= 110) //System.Diagnostics.Debug.WriteLine(_lines[116]); //MessageBox.Show("Problem in cookies ville!" + isThisASectionHeader(_lines[_sectionEndPosition]).ToString()); //Console. } _currentLine = _sectionEnd;// move our first loop interater to just before the next section } if (_currentLine>=10000) MessageBox.Show("Sanity Check, INI length exceeded 10000"); } _tempINI._sectionList = AddDisabled(_tempINI._sectionList); _sectionList = _tempINI._sectionList; return true; } catch { return false; } }
void DeleteINIButtonClick(object sender, EventArgs e) { DialogResult _areWeSure = MessageBox.Show("Are you sure you want to delete your UserOptions.INI?", "Delete UserOptions.INI", MessageBoxButtons.YesNo); switch(_areWeSure){ case DialogResult.Yes: { File.Delete(_currentUserOptionsINI._location); MessageBox.Show("You will now need to restart PlanetSide 2 to make a new UserOptions.INI.","Information"); _currentUserOptionsINI = new UserOptionsINI(); InitializePlanetside2Editor(); break; }; case DialogResult.No: break; } }