Beispiel #1
0
        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;
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        private void SetOrCreateAttribute(Sluggy.Utility.Tag tag, string attributeName, string stringizedValue, ProgressModal progress)
        {
            //TODO: add tag if it does not exist

            if (tag != null && tag.Attributes != null)
            {
                if (!tag.Attributes.ContainsKey(attributeName))
                {
                    tag.Attributes.Add(attributeName, stringizedValue);
                }
                else
                {
                    tag.Attributes[attributeName] = stringizedValue;
                }
            }

            if (progress != null)
            {
                progress.UpdateProgressBar();
            }
        }