Пример #1
0
        private void MetroWindow_Closed(object sender, EventArgs e)
        {
            if (NeedsSMDefInvalidation)
            {
                for (int i = 0; i < Program.Configs.Length; ++i)
                {
                    Program.Configs[i].InvalidateSMDef();
                }
            }
            Program.MainWindow.FillConfigMenu();
            Program.MainWindow.ChangeConfig(Program.SelectedConfig);
            StringBuilder     outString = new StringBuilder();
            XmlWriterSettings settings  = new XmlWriterSettings()
            {
                Indent = true, IndentChars = "\t", NewLineOnAttributes = false, OmitXmlDeclaration = true
            };

            using (XmlWriter writer = XmlWriter.Create(outString, settings))
            {
                writer.WriteStartElement("Configurations");
                for (int i = 0; i < Program.Configs.Length; ++i)
                {
                    Config c = Program.Configs[i];
                    writer.WriteStartElement("Config");
                    writer.WriteAttributeString("Name", c.Name);
                    StringBuilder SMDirOut = new StringBuilder();
                    foreach (string dir in c.SMDirectories)
                    {
                        SMDirOut.Append(dir.Trim() + ";");
                    }
                    writer.WriteAttributeString("SMDirectory", SMDirOut.ToString());
                    writer.WriteAttributeString("Standard", (c.Standard) ? "1" : "0");
                    writer.WriteAttributeString("CopyDirectory", c.CopyDirectory);
                    writer.WriteAttributeString("AutoCopy", (c.AutoCopy) ? "1" : "0");
                    writer.WriteAttributeString("ServerFile", c.ServerFile);
                    writer.WriteAttributeString("ServerArgs", c.ServerArgs);
                    writer.WriteAttributeString("PostCmd", c.PostCmd);
                    writer.WriteAttributeString("PreCmd", c.PreCmd);
                    writer.WriteAttributeString("OptimizationLevel", c.OptimizeLevel.ToString());
                    writer.WriteAttributeString("VerboseLevel", c.VerboseLevel.ToString());
                    writer.WriteAttributeString("DeleteAfterCopy", (c.DeleteAfterCopy) ? "1" : "0");
                    writer.WriteAttributeString("FTPHost", c.FTPHost);
                    writer.WriteAttributeString("FTPUser", c.FTPUser);
                    writer.WriteAttributeString("FTPPassword", ManagedAES.Encrypt(c.FTPPassword));
                    writer.WriteAttributeString("FTPDir", c.FTPDir);
                    writer.WriteAttributeString("RConSourceEngine", (c.RConUseSourceEngine) ? "1" : "0");
                    writer.WriteAttributeString("RConIP", c.RConIP);
                    writer.WriteAttributeString("RConPort", c.RConPort.ToString());
                    writer.WriteAttributeString("RConPassword", ManagedAES.Encrypt(c.RConPassword));
                    writer.WriteAttributeString("RConCommands", c.RConCommands);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
                writer.Flush();
            }
            File.WriteAllText("sourcepawn\\configs\\Configs.xml", outString.ToString());
        }
Пример #2
0
        private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // TODO: find out what is this for
            if (NeedsSMDefInvalidation)
            {
                foreach (var config in Program.Configs)
                {
                    config.InvalidateSMDef();
                }
            }

            // Fill a list with all configs from the ListBox

            var configsList = new List <string>();

            foreach (ListBoxItem item in ConfigListBox.Items)
            {
                configsList.Add(item.Content.ToString());
            }

            // Check for empty named configs and disallow saving configs

            foreach (var cfg in configsList)
            {
                if (cfg == string.Empty)
                {
                    e.Cancel = true;
                    this.ShowMessageAsync(Program.Translations.GetLanguage("ErrorSavingConfigs"),
                                          Program.Translations.GetLanguage("EmptyConfigNames"), MessageDialogStyle.Affirmative,
                                          MetroDialogOptions);
                    return;
                }
            }

            // Check for duplicate names in the config list and disallow saving configs

            if (configsList.Count != configsList.Distinct().Count())
            {
                e.Cancel = true;
                this.ShowMessageAsync(Program.Translations.GetLanguage("ErrorSavingConfigs"),
                                      Program.Translations.GetLanguage("DuplicateConfigNames"), MessageDialogStyle.Affirmative,
                                      MetroDialogOptions);
                return;
            }

            Program.MainWindow.FillConfigMenu();
            Program.MainWindow.ChangeConfig(Program.SelectedConfig);
            var outString = new StringBuilder();
            var settings  = new XmlWriterSettings
            {
                Indent              = true,
                IndentChars         = "\t",
                NewLineOnAttributes = false,
                OmitXmlDeclaration  = true
            };

            using (var writer = XmlWriter.Create(outString, settings))
            {
                writer.WriteStartElement("Configurations");
                foreach (var c in Program.Configs)
                {
                    writer.WriteStartElement("Config");
                    writer.WriteAttributeString("Name", c.Name);
                    var SMDirOut = new StringBuilder();
                    foreach (var dir in c.SMDirectories)
                    {
                        SMDirOut.Append(dir.Trim() + ";");
                    }

                    writer.WriteAttributeString("SMDirectory", SMDirOut.ToString());
                    writer.WriteAttributeString("Standard", c.Standard ? "1" : "0");
                    writer.WriteAttributeString("CopyDirectory", c.CopyDirectory);
                    writer.WriteAttributeString("AutoCopy", c.AutoCopy ? "1" : "0");
                    writer.WriteAttributeString("AutoUpload", c.AutoUpload ? "1" : "0");
                    writer.WriteAttributeString("AutoRCON", c.AutoRCON ? "1" : "0");
                    writer.WriteAttributeString("ServerFile", c.ServerFile);
                    writer.WriteAttributeString("ServerArgs", c.ServerArgs);
                    writer.WriteAttributeString("PostCmd", c.PostCmd);
                    writer.WriteAttributeString("PreCmd", c.PreCmd);
                    writer.WriteAttributeString("OptimizationLevel", c.OptimizeLevel.ToString());
                    writer.WriteAttributeString("VerboseLevel", c.VerboseLevel.ToString());
                    writer.WriteAttributeString("DeleteAfterCopy", c.DeleteAfterCopy ? "1" : "0");
                    writer.WriteAttributeString("FTPHost", c.FTPHost);
                    writer.WriteAttributeString("FTPUser", c.FTPUser);
                    writer.WriteAttributeString("FTPPassword", ManagedAES.Encrypt(c.FTPPassword));
                    writer.WriteAttributeString("FTPDir", c.FTPDir);
                    writer.WriteAttributeString("RConSourceEngine", c.RConUseSourceEngine ? "1" : "0");
                    writer.WriteAttributeString("RConIP", c.RConIP);
                    writer.WriteAttributeString("RConPort", c.RConPort.ToString());
                    writer.WriteAttributeString("RConPassword", ManagedAES.Encrypt(c.RConPassword));
                    writer.WriteAttributeString("RConCommands", c.RConCommands);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
                writer.Flush();
            }

            File.WriteAllText(Paths.GetConfigFilePath(), outString.ToString());
        }
Пример #3
0
        public static Config[] Load()
        {
            var configs = new List <Config>();

            if (File.Exists(Paths.GetConfigFilePath()))
            {
                try
                {
                    // Document gets loaded
                    var document = new XmlDocument();
                    document.Load(Paths.GetConfigFilePath());

                    // Document gets checked for proper Configurations tag
                    if (document.ChildNodes.Count < 1)
                    {
                        throw new Exception("No main 'Configurations' node.");
                    }

                    // We check for main node and its main child 'Config' node
                    var mainNode = document.ChildNodes[0];
                    if (mainNode.ChildNodes.Count < 1)
                    {
                        throw new Exception("No 'config' nodes found.");
                    }

                    // Start looping through all 'Config' child nodes
                    for (var i = 0; i < mainNode.ChildNodes.Count; ++i)
                    {
                        var node = mainNode.ChildNodes[i];

                        var _Standard      = ReadAttributeStringSafe(ref node, "Standard", "0");
                        var _AutoCopyStr   = ReadAttributeStringSafe(ref node, "AutoCopy", "0");
                        var _AutoUploadStr = ReadAttributeStringSafe(ref node, "AutoUpload", "0");
                        var _AutoRCONStr   = ReadAttributeStringSafe(ref node, "AutoRCON", "0");
                        var _CopyDirectory = ReadAttributeStringSafe(ref node, "CopyDirectory");
                        var _ServerFile    = ReadAttributeStringSafe(ref node, "ServerFile");
                        var _ServerArgs    = ReadAttributeStringSafe(ref node, "ServerArgs");
                        var _PostCmd       = ReadAttributeStringSafe(ref node, "PostCmd");
                        var _PreCmd        = ReadAttributeStringSafe(ref node, "PreCmd");

                        var IsStandardConfig = _Standard != "0" && !string.IsNullOrWhiteSpace(_Standard);
                        var _AutoCopy        = _AutoCopyStr != "0" && !string.IsNullOrWhiteSpace(_AutoCopyStr);
                        var _AutoUpload      = _AutoUploadStr != "0" && !string.IsNullOrWhiteSpace(_AutoUploadStr);
                        var _AutoRCON        = _AutoRCONStr != "0" && !string.IsNullOrWhiteSpace(_AutoRCONStr);

                        var _Name                 = ReadAttributeStringSafe(ref node, "Name", "UNKOWN CONFIG " + (i + 1));
                        var _SMDirectoryStr       = ReadAttributeStringSafe(ref node, "SMDirectory");
                        var SMDirectoriesSplitted = _SMDirectoryStr.Split(';');
                        var SMDirs                = new List <string>();

                        // If it's the default config the program comes with, add as SMDirectory the default one
                        // (calculate it based on installation being standalone or portable)
                        if (IsStandardConfig && string.IsNullOrEmpty(_SMDirectoryStr))
                        {
                            SMDirs.Add(Paths.GetConfigsDirectory());
                        }

                        foreach (var dir in SMDirectoriesSplitted)
                        {
                            var d = dir.Trim();
                            if (Directory.Exists(d))
                            {
                                SMDirs.Add(d);
                            }
                        }

                        // Extra assurance for the program to always load a proper config
                        if (IsStandardConfig && SMDirs.Count == 0)
                        {
                            SMDirs.Add(Paths.GetConfigsDirectory());
                        }

                        int _OptimizationLevel = 2, _VerboseLevel = 1;
                        if (int.TryParse(ReadAttributeStringSafe(ref node, "OptimizationLevel", "2"), out var subValue))
                        {
                            _OptimizationLevel = subValue;
                        }

                        if (int.TryParse(ReadAttributeStringSafe(ref node, "VerboseLevel", "1"), out subValue))
                        {
                            _VerboseLevel = subValue;
                        }

                        var _DeleteAfterCopy   = false;
                        var DeleteAfterCopyStr = ReadAttributeStringSafe(ref node, "DeleteAfterCopy", "0");
                        if (!(DeleteAfterCopyStr == "0" || string.IsNullOrWhiteSpace(DeleteAfterCopyStr)))
                        {
                            _DeleteAfterCopy = true;
                        }

                        var _FTPHost              = ReadAttributeStringSafe(ref node, "FTPHost", "ftp://localhost/");
                        var _FTPUser              = ReadAttributeStringSafe(ref node, "FTPUser");
                        var encryptedFTPPW        = ReadAttributeStringSafe(ref node, "FTPPassword");
                        var _FTPPW                = ManagedAES.Decrypt(encryptedFTPPW);
                        var _FTPDir               = ReadAttributeStringSafe(ref node, "FTPDir");
                        var _RConEngineSourceStr  = ReadAttributeStringSafe(ref node, "RConSourceEngine", "1");
                        var _RConEngineTypeSource = !(_RConEngineSourceStr == "0" || string.IsNullOrWhiteSpace(_RConEngineSourceStr));
                        var _RConIP               = ReadAttributeStringSafe(ref node, "RConIP", "127.0.0.1");
                        var _RConPortStr          = ReadAttributeStringSafe(ref node, "RConPort", "27015");

                        if (!ushort.TryParse(_RConPortStr, NumberStyles.Any, CultureInfo.InvariantCulture, out var _RConPort))
                        {
                            _RConPort = 27015;
                        }

                        var encryptedRConPassword = ReadAttributeStringSafe(ref node, "RConPassword");
                        var _RConPassword         = ManagedAES.Decrypt(encryptedRConPassword);
                        var _RConCommands         = ReadAttributeStringSafe(ref node, "RConCommands");

                        var c = new Config
                        {
                            Name                = _Name,
                            SMDirectories       = SMDirs.ToArray(),
                            Standard            = IsStandardConfig,
                            AutoCopy            = _AutoCopy,
                            AutoRCON            = _AutoRCON,
                            AutoUpload          = _AutoUpload,
                            CopyDirectory       = _CopyDirectory,
                            ServerFile          = _ServerFile,
                            ServerArgs          = _ServerArgs,
                            PostCmd             = _PostCmd,
                            PreCmd              = _PreCmd,
                            OptimizeLevel       = _OptimizationLevel,
                            VerboseLevel        = _VerboseLevel,
                            DeleteAfterCopy     = _DeleteAfterCopy,
                            FTPHost             = _FTPHost,
                            FTPUser             = _FTPUser,
                            FTPPassword         = _FTPPW,
                            FTPDir              = _FTPDir,
                            RConUseSourceEngine = _RConEngineTypeSource,
                            RConIP              = _RConIP,
                            RConPort            = _RConPort,
                            RConPassword        = _RConPassword,
                            RConCommands        = _RConCommands
                        };
                        if (IsStandardConfig)
                        {
                            c.LoadSMDef();
                        }
                        configs.Add(c);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(
                        "An error occured while reading the configs. Without them, the editor will not start. Reinstall your program." +
                        Environment.NewLine + "Details: " + e.Message
                        , "Error while reading configs."
                        , MessageBoxButton.OK
                        , MessageBoxImage.Warning);
                    Environment.Exit(Environment.ExitCode);
                }
            }
            else
            {
                MessageBox.Show(
                    "The Editor could not find the Configs.xml file, neither locally nor in AppData. Without it, the editor will not start. Reinstall your program.",
                    "Configs file not found.", MessageBoxButton.OK, MessageBoxImage.Warning);
                Environment.Exit(Environment.ExitCode);
            }

            return(configs.ToArray());
        }
Пример #4
0
        public static Config[] Load()
        {
            List <Config> configs = new List <Config>();

            if (File.Exists("sourcepawn\\configs\\Configs.xml"))
            {
                try
                {
                    XmlDocument document = new XmlDocument();
                    document.Load("sourcepawn\\configs\\Configs.xml");
                    if (document.ChildNodes.Count < 1)
                    {
                        throw new Exception("No main 'Configurations' node.");
                    }
                    XmlNode mainNode = document.ChildNodes[0];
                    if (mainNode.ChildNodes.Count < 1)
                    {
                        throw new Exception("No 'config' nodes found.");
                    }
                    for (int i = 0; i < mainNode.ChildNodes.Count; ++i)
                    {
                        XmlNode       node                  = mainNode.ChildNodes[i];
                        string        _Name                 = ReadAttributeStringSafe(ref node, "Name", "UNKOWN CONFIG " + (i + 1).ToString());
                        string        _SMDirectoryStr       = ReadAttributeStringSafe(ref node, "SMDirectory", "");
                        string[]      SMDirectoriesSplitted = _SMDirectoryStr.Split(';');
                        List <string> SMDirs                = new List <string>();
                        foreach (string dir in SMDirectoriesSplitted)
                        {
                            string d = dir.Trim();
                            if (Directory.Exists(d))
                            {
                                SMDirs.Add(d);
                            }
                        }
                        string _Standard        = ReadAttributeStringSafe(ref node, "Standard", "0");
                        bool   IsStandardConfig = false;
                        if (_Standard != "0" && !string.IsNullOrWhiteSpace(_Standard))
                        {
                            IsStandardConfig = true;
                        }
                        string _AutoCopyStr = ReadAttributeStringSafe(ref node, "AutoCopy", "0");
                        bool   _AutoCopy    = false;
                        if (_AutoCopyStr != "0" && !string.IsNullOrWhiteSpace(_AutoCopyStr))
                        {
                            _AutoCopy = true;
                        }
                        string _CopyDirectory = ReadAttributeStringSafe(ref node, "CopyDirectory", "");
                        string _ServerFile = ReadAttributeStringSafe(ref node, "ServerFile", "");
                        string _ServerArgs = ReadAttributeStringSafe(ref node, "ServerArgs", "");
                        string _PostCmd = ReadAttributeStringSafe(ref node, "PostCmd", "");
                        string _PreCmd = ReadAttributeStringSafe(ref node, "PreCmd", "");
                        int    _OptimizationLevel = 2, _VerboseLevel = 1;
                        int    subValue;
                        if (int.TryParse(ReadAttributeStringSafe(ref node, "OptimizationLevel", "2"), out subValue))
                        {
                            _OptimizationLevel = subValue;
                        }
                        if (int.TryParse(ReadAttributeStringSafe(ref node, "VerboseLevel", "1"), out subValue))
                        {
                            _VerboseLevel = subValue;
                        }
                        bool   _DeleteAfterCopy   = false;
                        string DeleteAfterCopyStr = ReadAttributeStringSafe(ref node, "DeleteAfterCopy", "0");
                        if (!(DeleteAfterCopyStr == "0" || string.IsNullOrWhiteSpace(DeleteAfterCopyStr)))
                        {
                            _DeleteAfterCopy = true;
                        }
                        string _FTPHost              = ReadAttributeStringSafe(ref node, "FTPHost", "ftp://localhost/");
                        string _FTPUser              = ReadAttributeStringSafe(ref node, "FTPUser", "");
                        string encryptedFTPPW        = ReadAttributeStringSafe(ref node, "FTPPassword", "");
                        string _FTPPW                = ManagedAES.Decrypt(encryptedFTPPW);
                        string _FTPDir               = ReadAttributeStringSafe(ref node, "FTPDir", "");
                        string _RConEngineSourceStr  = ReadAttributeStringSafe(ref node, "RConSourceEngine", "1");
                        bool   _RConEngineTypeSource = false;
                        if (!(_RConEngineSourceStr == "0" || string.IsNullOrWhiteSpace(_RConEngineSourceStr)))
                        {
                            _RConEngineTypeSource = true;
                        }
                        string _RConIP      = ReadAttributeStringSafe(ref node, "RConIP", "127.0.0.1");
                        string _RConPortStr = ReadAttributeStringSafe(ref node, "RConPort", "27015");
                        ushort _RConPort    = 27015;
                        if (!ushort.TryParse(_RConPortStr, NumberStyles.Any, CultureInfo.InvariantCulture, out _RConPort))
                        {
                            _RConPort = 27015;
                        }
                        string encryptedRConPassword = ReadAttributeStringSafe(ref node, "RConPassword", "");
                        string _RConPassword         = ManagedAES.Decrypt(encryptedRConPassword);
                        string _RConCommands         = ReadAttributeStringSafe(ref node, "RConCommands", "");
                        Config c = new Config()
                        {
                            Name          = _Name,
                            SMDirectories = SMDirs.ToArray(),
                            Standard      = IsStandardConfig
                            ,
                            AutoCopy      = _AutoCopy,
                            CopyDirectory = _CopyDirectory,
                            ServerFile    = _ServerFile,
                            ServerArgs    = _ServerArgs
                            ,
                            PostCmd         = _PostCmd,
                            PreCmd          = _PreCmd,
                            OptimizeLevel   = _OptimizationLevel,
                            VerboseLevel    = _VerboseLevel,
                            DeleteAfterCopy = _DeleteAfterCopy
                            ,
                            FTPHost     = _FTPHost,
                            FTPUser     = _FTPUser,
                            FTPPassword = _FTPPW,
                            FTPDir      = _FTPDir
                            ,
                            RConUseSourceEngine = _RConEngineTypeSource,
                            RConIP       = _RConIP,
                            RConPort     = _RConPort,
                            RConPassword = _RConPassword,
                            RConCommands = _RConCommands
                        };
                        if (IsStandardConfig)
                        {
                            c.LoadSMDef();
                        }
                        configs.Add(c);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("An error appeared while reading the configs. Without them, the editor wont start. Reinstall program!" + Environment.NewLine + "Details: " + e.Message
                                    , "Error while reading configs."
                                    , MessageBoxButton.OK
                                    , MessageBoxImage.Warning);
                    Environment.Exit(Environment.ExitCode);
                }
            }
            else
            {
                MessageBox.Show("The Editor could not find the Configs.xml file. Without it, the editor wont start. Reinstall program.", "File not found.", MessageBoxButton.OK, MessageBoxImage.Warning);
                Environment.Exit(Environment.ExitCode);
            }
            return(configs.ToArray());
        }
Пример #5
0
        public static Config[] Load()
        {
            List <Config> configs = new List <Config>();

            if (File.Exists("sourcepawn\\configs\\Configs.xml"))
            {
                try
                {
                    XmlDocument document = new XmlDocument();
                    document.Load("sourcepawn\\configs\\Configs.xml");
                    if (document.ChildNodes.Count < 1)
                    {
                        throw new Exception("No main 'Configurations' node.");
                    }
                    XmlNode mainNode = document.ChildNodes[0];
                    if (mainNode.ChildNodes.Count < 1)
                    {
                        throw new Exception("No 'config' nodes found.");
                    }
                    for (int i = 0; i < mainNode.ChildNodes.Count; ++i)
                    {
                        XmlNode       node                  = mainNode.ChildNodes[i];
                        string        _Name                 = ReadAttributeStringSafe(ref node, "Name", "UNKOWN CONFIG " + (i + 1).ToString());
                        string        _SMDirectoryStr       = ReadAttributeStringSafe(ref node, "SMDirectory", "");
                        string[]      SMDirectoriesSplitted = _SMDirectoryStr.Split(';');
                        List <string> SMDirs                = new List <string>();
                        foreach (string dir in SMDirectoriesSplitted)
                        {
                            string d = dir.Trim();
                            if (d.Equals(""))
                            {
                                continue; // Skip unset directories to avoid duplicate "semicolon" in path
                            }

                            // Allow relative paths that may not exist when the programs is started.
                            // For many projects includes are required, mostly placed in the project/include folder.
                            // Allowing just the entry "include" (relative path) as scripting directory should be fine.
                            // The sourcemod compiler can handle folders that does not exist (no error is thrown)
                            if (!Directory.Exists(d))
                            {
                                MessageBox.Show(
                                    string.Format("The scripting directory '{0}' specified in the configuration does not exists globally."
                                                  + Environment.NewLine + "If this is an in-project folder, everything is fine. Other projects should ignore it.", d)
                                    , "Scripting directory may not available"
                                    , MessageBoxButton.OK
                                    , MessageBoxImage.Information);
                            }
                            SMDirs.Add(d);
                        }
                        string _Standard        = ReadAttributeStringSafe(ref node, "Standard", "0");
                        bool   IsStandardConfig = false;
                        if (_Standard != "0" && !string.IsNullOrWhiteSpace(_Standard))
                        {
                            IsStandardConfig = true;
                        }
                        string _AutoCopyStr = ReadAttributeStringSafe(ref node, "AutoCopy", "0");
                        bool   _AutoCopy    = false;
                        if (_AutoCopyStr != "0" && !string.IsNullOrWhiteSpace(_AutoCopyStr))
                        {
                            _AutoCopy = true;
                        }
                        string _CopyDirectory = ReadAttributeStringSafe(ref node, "CopyDirectory", "");
                        string _ServerFile = ReadAttributeStringSafe(ref node, "ServerFile", "");
                        string _ServerArgs = ReadAttributeStringSafe(ref node, "ServerArgs", "");
                        string _PostCmd = ReadAttributeStringSafe(ref node, "PostCmd", "");
                        string _PreCmd = ReadAttributeStringSafe(ref node, "PreCmd", "");
                        int    _OptimizationLevel = 2, _VerboseLevel = 1;
                        int    subValue;
                        if (int.TryParse(ReadAttributeStringSafe(ref node, "OptimizationLevel", "2"), out subValue))
                        {
                            _OptimizationLevel = subValue;
                        }
                        if (int.TryParse(ReadAttributeStringSafe(ref node, "VerboseLevel", "1"), out subValue))
                        {
                            _VerboseLevel = subValue;
                        }
                        bool   _DeleteAfterCopy   = false;
                        string DeleteAfterCopyStr = ReadAttributeStringSafe(ref node, "DeleteAfterCopy", "0");
                        if (!(DeleteAfterCopyStr == "0" || string.IsNullOrWhiteSpace(DeleteAfterCopyStr)))
                        {
                            _DeleteAfterCopy = true;
                        }
                        string _FTPHost              = ReadAttributeStringSafe(ref node, "FTPHost", "ftp://localhost/");
                        string _FTPUser              = ReadAttributeStringSafe(ref node, "FTPUser", "");
                        string encryptedFTPPW        = ReadAttributeStringSafe(ref node, "FTPPassword", "");
                        string _FTPPW                = ManagedAES.Decrypt(encryptedFTPPW);
                        string _FTPDir               = ReadAttributeStringSafe(ref node, "FTPDir", "");
                        string _RConEngineSourceStr  = ReadAttributeStringSafe(ref node, "RConSourceEngine", "1");
                        bool   _RConEngineTypeSource = false;
                        if (!(_RConEngineSourceStr == "0" || string.IsNullOrWhiteSpace(_RConEngineSourceStr)))
                        {
                            _RConEngineTypeSource = true;
                        }
                        string _RConIP      = ReadAttributeStringSafe(ref node, "RConIP", "127.0.0.1");
                        string _RConPortStr = ReadAttributeStringSafe(ref node, "RConPort", "27015");
                        ushort _RConPort    = 27015;
                        if (!ushort.TryParse(_RConPortStr, NumberStyles.Any, CultureInfo.InvariantCulture, out _RConPort))
                        {
                            _RConPort = 27015;
                        }
                        string encryptedRConPassword = ReadAttributeStringSafe(ref node, "RConPassword", "");
                        string _RConPassword         = ManagedAES.Decrypt(encryptedRConPassword);
                        string _RConCommands         = ReadAttributeStringSafe(ref node, "RConCommands", "");
                        Config c = new Config()
                        {
                            Name          = _Name,
                            SMDirectories = SMDirs.ToArray(),
                            Standard      = IsStandardConfig
                            ,
                            AutoCopy      = _AutoCopy,
                            CopyDirectory = _CopyDirectory,
                            ServerFile    = _ServerFile,
                            ServerArgs    = _ServerArgs
                            ,
                            PostCmd         = _PostCmd,
                            PreCmd          = _PreCmd,
                            OptimizeLevel   = _OptimizationLevel,
                            VerboseLevel    = _VerboseLevel,
                            DeleteAfterCopy = _DeleteAfterCopy
                            ,
                            FTPHost     = _FTPHost,
                            FTPUser     = _FTPUser,
                            FTPPassword = _FTPPW,
                            FTPDir      = _FTPDir
                            ,
                            RConUseSourceEngine = _RConEngineTypeSource,
                            RConIP       = _RConIP,
                            RConPort     = _RConPort,
                            RConPassword = _RConPassword,
                            RConCommands = _RConCommands
                        };
                        if (IsStandardConfig)
                        {
                            c.LoadSMDef();
                        }
                        configs.Add(c);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("An error appeared while reading the configs. Without them, the editor wont start. Reinstall program!" + Environment.NewLine + "Details: " + e.Message
                                    , "Error while reading configs."
                                    , MessageBoxButton.OK
                                    , MessageBoxImage.Warning);
                    Environment.Exit(Environment.ExitCode);
                }
            }
            else
            {
                MessageBox.Show("The Editor could not find the Configs.xml file. Without it, the editor wont start. Reinstall program.", "File not found.", MessageBoxButton.OK, MessageBoxImage.Warning);
                Environment.Exit(Environment.ExitCode);
            }
            return(configs.ToArray());
        }