private void editLevelDetailsToolStripMenuItem_Click(object sender, EventArgs e) { dynamic _load = new JObject(); try { //atempt to parse JSON of LEVEL DETAILS. This wil lalso take care of the situation if it doesn't exist _load = JsonConvert.DeserializeObject(Regex.Replace(File.ReadAllText($@"{workingfolder}\LEVEL DETAILS.txt"), "#.*", "")); } catch { } DialogInput customlevel = new DialogInput(); //set the form text fields to whatever is in LEVEL DETAILS customlevel.txtCustomPath.Text = workingfolder; //if the LEVEL DETAILS file is missing, or missing parameters, this fill fill the blanks will empty space customlevel.txtCustomName.Text = _load.ContainsKey("level_name") ? (string)_load["level_name"] : ""; customlevel.txtCustomDiff.Text = _load.ContainsKey("difficulty") ? (string)_load["difficulty"] : ""; customlevel.txtDesc.Text = _load.ContainsKey("description") ? (string)_load["description"] : ""; customlevel.txtCustomAuthor.Text = _load.ContainsKey("author") ? (string)_load["author"] : ""; //set samp pack checks customlevel.chkLevel2.Checked = File.Exists($@"{workingfolder}\samp_level2_340bpm.txt"); customlevel.chkLevel3.Checked = File.Exists($@"{workingfolder}\samp_level3_360bpm.txt"); customlevel.chkLevel4.Checked = File.Exists($@"{workingfolder}\samp_level4_380bpm.txt"); customlevel.chkLevel5.Checked = File.Exists($@"{workingfolder}\samp_level5_400bpm.txt"); customlevel.chkLevel6.Checked = File.Exists($@"{workingfolder}\samp_level6_420bpm.txt"); customlevel.chkLevel7.Checked = File.Exists($@"{workingfolder}\samp_level7_440bpm.txt"); customlevel.chkLevel8.Checked = File.Exists($@"{workingfolder}\samp_level8_460bpm.txt"); customlevel.chkLevel9.Checked = File.Exists($@"{workingfolder}\samp_level9_480bpm.txt"); //show the new level folder dialog box if (customlevel.ShowDialog() == DialogResult.OK) { //if all OK, populate new JObject with data from the form CreateCustomLevelFolder(customlevel); } customlevel.Dispose(); }
/// NEW CUSTOM LEVEL FOLDER private void newLevelFolderToolStripMenuItem_Click(object sender, EventArgs e) { DialogInput customlevel = new DialogInput(); //show the new level folder dialog box if (customlevel.ShowDialog() == DialogResult.OK) { //if all OK, populate new JObject with data from the form CreateCustomLevelFolder(customlevel); } customlevel.Dispose(); }