private void EditConfigFile() { using (ProgressModal progress = new ProgressModal(20)) { progress.Show(this); //yeah, reloading the config file just to mod it and save again. Derp! //System.Windows.Forms. //SUPER LAME PROGRESS BAR AHOY! try{ Sluggy.Utility.XmlParser parser = new Sluggy.Utility.XmlParser(Globals.Files.ConfigFile); Sluggy.Utility.Tag imageboxes = parser.DepthSeekFirst(null, "imageboxes"); Sluggy.Utility.Tag nodeboxes = parser.DepthSeekFirst(null, "nodeboxes"); Sluggy.Utility.Tag baseroom = parser.DepthSeekFirst(null, "baseroom"); Sluggy.Utility.Tag startroom = parser.DepthSeekFirst(null, "startroom"); Sluggy.Utility.Tag exitWidth = parser.DepthSeekFirst(null, "exitlinewidth"); Sluggy.Utility.Tag lineending = parser.DepthSeekFirst(null, "lpclineending"); Sluggy.Utility.Tag encoding = parser.DepthSeekFirst(null, "lpcencoding"); progress.UpdateProgressBar(); if (imageboxes == null || nodeboxes == null || exitWidth == null) { MessageBox.Show("The config file has been corrupted and cannot be altered. The problem may be solved by deleting the file 'config.xml' in the Stellarmap assets folder."); return; } progress.UpdateProgressBar(); SetOrCreateAttribute(imageboxes, "width", System.Convert.ToString(Globals.ImageBoxProperties.width), progress); SetOrCreateAttribute(imageboxes, "height", System.Convert.ToString(Globals.ImageBoxProperties.height), progress); SetOrCreateAttribute(nodeboxes, "width", System.Convert.ToString(Globals.NodeProperties.width), progress); SetOrCreateAttribute(nodeboxes, "height", System.Convert.ToString(Globals.NodeProperties.height), progress); SetOrCreateAttribute(baseroom, "name", Globals.Model.BaseRoomName, progress); SetOrCreateAttribute(startroom, "name", Globals.Model.CustomStartRoomName, progress); SetOrCreateAttribute(exitWidth, "width", System.Convert.ToString(Globals.ImageBoxProperties.ExitLineWidth), progress); SetOrCreateAttribute(lineending, "type", Globals.WorkspaceSave.LineEndings, progress); SetOrCreateAttribute(encoding, "type", Globals.WorkspaceSave.LPCEncoding.WebName, progress); parser.Save(parser.FilePath); //TODO: need an option to save Parsed XML data in parser!!! } //end try catch (Sluggy.Utility.XMLParserException exc) { MessageBox.Show(exc.Message); } } //end progress modal return; }
public bool GenerateFile(ItemSaveType itemPath, string fileSaveName) { bool result = false; using (ProgressModal progress = new ProgressModal(5)) { progress.Show(); if (fileSaveName == null || fileSaveName.Length < 1) { return(false); } progress.UpdateProgressBar(); List <IFunctionControl> controls = this.CompileFunctionControlsList(this.refParentForm); progress.UpdateProgressBar(); FunctionCallsCollection inherits = this.CompileIheritList(controls); progress.UpdateProgressBar(); FunctionCallsCollection functions = this.CompileFunctioCallsList(controls); progress.UpdateProgressBar(); result = this.Item.SaveModelToDisk(functions, inherits, itemPath, fileSaveName); progress.UpdateProgressBar(); } return(result); }