Exemplo n.º 1
0
        public GameSettings()
        {
            try
            {

                m_lDBCon = new SQL.DBConnector(Program.DBCon.ConfigData, true);

                //Load DisplaySettings from AppData
                LoadDisplaySettings();

                //Load AppConfig
                AppConfigGlobal = LoadAppConfig("AppConfig.xml", false);
                AppConfigLocal  = LoadAppConfig("AppConfigLocal.xml", true);

                //Set up some filewatchers, If user changes config its reflected here
                WatcherDisplaySettings();
                WatcherAppDataSettings(); //Currently disabled as we only check Verbose logging and that cant be changed from the game

                // not more necessary since E:D 2.2 (journal)
                //if((AppConfigGlobal.Network.VerboseLogging != 1) && ((AppConfigLocal == null) || (AppConfigLocal.Network.VerboseLogging != 1)))
                //{ 
                //    //Check and Request for Verbose Logging
                //    AppConfigLocal = CheckAndRequestVerboseLogging("AppConfigLocal.xml", AppConfigLocal);
                //}
            }
            catch (Exception ex)
            {
                throw new Exception("Error while creating the object", ex);
            }
        }
Exemplo n.º 2
0
        AppConfig CheckAndRequestVerboseLogging(String fileName, AppConfig configuration)
        {
            try
            {
                if ((configuration == null) || (configuration.Network.VerboseLogging != 1))
                {
                    if(!Program.SplashScreen.IsDisposed)
                        Program.SplashScreen.TopMost = false;

                    var setLog =
                        MessageBox.Show(
                            "Verbose logging isn't set in your Elite Dangerous AppConfig.xml, so I can't read system names. Would you like me to set it for you?",
                            "Set verbose logging?", MessageBoxButtons.YesNo);

                    if(!Program.SplashScreen.IsDisposed)
                        Program.SplashScreen.TopMost = true;

                    if (setLog == DialogResult.Yes)
                    {
                        var appConfigFilePath = Path.Combine(m_lDBCon.getIniValue<String>(IBE.IBESettingsView.DB_GROUPNAME, "GamePath"), fileName);
                        var doc = new XmlDocument();

                        //Make backup
                        if(File.Exists(appConfigFilePath))
                        {
                            File.Copy(appConfigFilePath, appConfigFilePath+".bak", true);
                            doc.Load(appConfigFilePath);
                        }
                        else
                        {
                            doc.LoadXml("<AppConfig><Network></Network></AppConfig>");
                        }

                        var ie = doc.SelectNodes("/AppConfig/Network").GetEnumerator();

                        while (ie.MoveNext())
                        {
                            if ((ie.Current as XmlNode).Attributes["VerboseLogging"] != null)
                            {
                                (ie.Current as XmlNode).Attributes["VerboseLogging"].Value = "1";
                            }
                            else
                            {
                                var verb = doc.CreateAttribute("VerboseLogging");
                                verb.Value = "1";

                                (ie.Current as XmlNode).Attributes.Append(verb);
                            }
                        }

                        try
                        {
                            doc.Save(appConfigFilePath);

                            if(!Program.SplashScreen.IsDisposed)
                                Program.SplashScreen.TopMost = false;

                            MessageBox.Show(
                                fileName + " updated.  You'll need to restart Elite Dangerous if it's already running.");

                            if(!Program.SplashScreen.IsDisposed)
                                Program.SplashScreen.TopMost = true;
                        }
                        catch (Exception ex)
                        {
                            if(!Program.SplashScreen.IsDisposed)
                                Program.SplashScreen.TopMost = false;

                            MessageBox.Show("I can't save the file (no permission). Please set the 'VorboseLogging' manually.", "Can't write", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                            if(!Program.SplashScreen.IsDisposed)
                                Program.SplashScreen.TopMost = true;
                        }

                    }

                    //Update config
                    configuration = LoadAppConfig(fileName, false);
                }

                return configuration;
            }
            catch (Exception ex)
            {
                throw new Exception("Error while checking VerboseLogging", ex);
            }
        }
Exemplo n.º 3
0
        void LoadAppConfig()
        {
            AppConfig locAppConfig;

            DialogResult MBResult = DialogResult.Ignore;
            string configFile = Path.Combine(Program.DBCon.getIniValue<String>(IBE.MTSettings.tabSettings.DB_GROUPNAME, "GamePath"), "AppConfig.xml");
            XmlSerializer serializer;

            do{

                try
                {
                    serializer = new XmlSerializer(typeof(AppConfig));
                    using (var myFileStream = new FileStream(configFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        locAppConfig = (AppConfig)serializer.Deserialize(myFileStream);
                        AppConfig = locAppConfig;
                    }
                }
                catch (Exception ex)
                {

                    if (AppConfig == null)
                    {
                        // ignore if it was loaded before
                        cErr.processError(ex, String.Format("Error while loading ED-Appconfig from file <{0}>", configFile));
                    }

                }
            } while (MBResult == DialogResult.Retry);
        }