xMissCorielx

Untitled

Jun 21st, 2021
740
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         private void ParseEvent()
  2.         {
  3.             //Divide Event to Key and Value
  4.             string conditions = eventFileData.SelectedItem.ToString().Substring(0, eventFileData.SelectedItem.ToString().IndexOf(':'));
  5.             string commands = eventFileData.SelectedItem.ToString().Substring(eventFileData.SelectedItem.ToString().IndexOf(':') + 2); // +2 to get past the : and space
  6.             //Now, divide conditions and isolate eventID
  7.             char splitArea = '/';
  8.             List<string> parseConditions = new List<string>();
  9.             string[] dividedConditions = conditions.Split(splitArea);
  10.             foreach (var condition in dividedConditions)
  11.             {
  12.                 parseConditions.Add(condition.ToString());
  13.             }
  14.             //Acquire EventID
  15.             string eventID = parseConditions[0].ToString();
  16.             parseConditions.Remove(parseConditions[0]); //Removes event ID from conditions list
  17.             //create a temporary file space for next window to look for
  18.             Directory.CreateDirectory(Environment.CurrentDirectory + "\\Save Data\\tmp\\editevent");
  19.             //Create Files
  20.             File.WriteAllText(Environment.CurrentDirectory + "\\Save Data\\tmp\\editevent\\eventID.txt", eventID);//just stores the event ID
  21.             if(parseConditions.Count > 0)
  22.             {
  23.                 File.WriteAllLines(Environment.CurrentDirectory + "\\Save Data\\tmp\\editevent\\conditions.txt", parseConditions);//Add Conditions File if conditions present
  24.  
  25.             }
  26.             //Divide Commands
  27.             List<string> parsedCommands = new List<string>();
  28.             string[] dividedCommands = commands.Split(splitArea);
  29.             foreach(var command in dividedCommands)
  30.             {
  31.                 parsedCommands.Add(command.ToString());
  32.             }
  33.             //Create Text File containing all commands
  34.             //Check to see if there is anything there
  35.             if(parsedCommands.Count > 0)
  36.             {
  37.                 File.WriteAllLines(Environment.CurrentDirectory + "\\Save Data\\tmp\\editevent\\commands.txt", parsedCommands);
  38.             }
  39.             //Delete Old Event
  40.             eventFileData.Items.Remove(eventFileData.SelectedItem);
  41.             //Open Event Editing
  42.             Conditions frRem = new Conditions();
  43.             frRem.Text = "Edit Event";
  44.             frRem.ShowDialog();
  45.         }
  46.  
RAW Paste Data