Beispiel #1
0
        public void CanSetValue()
        {
            var config = new PluginConfiguration();

            config.AddConfigurationSetting("foo", "bar");
            Assert.That(config.GetValue("foo"), Is.EqualTo("bar"));

            config.SetValue("foo", "none");
            Assert.That(config.GetValue("foo"), Is.EqualTo("none"));
        }
Beispiel #2
0
        public override void OnSave(ConfigNode node)
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <Proximity>();

            config.SetValue("Window Position", windowPos);
            config.SetValue("Beep type", beepIndex);
            config.SetValue("Beep length", beepLength);
            config.SetValue("Visual type", visualIndex);
            config.SetValue("Activation height", ActivationHeight);
            config.SetValue("Distance Speed threshold", DSThreshold);
            config.SetValue("Show settings", showsettings);
            config.SetValue("Pitch", pitchIndex);
            config.SetValue("On Ascent", beepAscent);

            config.save();
        }
Beispiel #3
0
        /// <summary>
        /// Cleanup on destruction.
        /// </summary>
        public void OnDestroy()
        {
            GameEvents.onGUIApplicationLauncherReady.Remove(onGUIApplicationLauncherReady);
            GameEvents.onGameSceneSwitchRequested.Remove(onGameSceneSwitchRequested);
            GameEvents.onLevelWasLoaded.Remove(onLevelWasLoaded);
            GameEvents.onVesselChange.Remove(onVesselChange);
            GameEvents.onHideUI.Remove(onHideUI);
            GameEvents.onShowUI.Remove(onShowUI);
            GameEvents.onGamePause.Remove(onGamePause);
            GameEvents.onGameUnpause.Remove(onGameUnpause);

            DestroyLauncher();

            config.SetValue("autoDewarp", autoDewarp);
            config.SetValue("guiRect", guiRect);
            config.SetValue("rcRect", rcRect);
            config.SetValue("useKSPSkin", useKSPSkin);
            config.SetValue("useToolbar", useToolbar);
            config.save();
            InputLockManager.RemoveControlLock("BonVoyageInputLock");
        }
Beispiel #4
0
 public override void save(PluginConfiguration config)
 {
     config.SetValue("NodePosition", windowPosition);
     config.SetValue("NodeMinimized", isMinimized);
     config.SetValue("NodeScale", (double)Scale);
     config.SetValue("NodeThrottle", throttleDelay);
     config.SetValue("NodeCalculatedBurn", useCalculatedBurn);
     config.SetValue("NodeAutoBurn", autoBurn);
     config.SetValue("NodeAutoStop", autoShutdown);
 }
Beispiel #5
0
        private void ParseString(string s)
        {
            _config.SetValue(_name, s);
            _config.save();

            var names = s.Split('+');
            var keys  = names.Select(Enums.Parse <KeyCode>).ToList();

            _trigger = keys.Last();

            SetModifiers(keys.SkipLast().ToList());
        }
        //Save persistant data to the config file
        public void SaveMe()
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <CustomBiomes>();

            config.SetValue("WindowPosition", _mainWindow);
            config.SetValue("WindowMinimized", _isMinimized);
            config.SetValue("MapPosition", _mapWindow);
            config.SetValue("MapMinimized", _mapMinimized);
            config.SetValue("WindowTab", _windowTab);
            config.SetValue("DefaultSets", _defaultSets);
            config.SetValue("GUIEnabled", _enableGUI);
            config.SetValue("UseLauncher", _useLauncher);
            config.save();
        }
        /** Called on destroy */
        public void OnDestroy()
        {
            debugPrint("OnDestroy()");

            /** Save to config */
            PluginConfiguration config = PluginConfiguration.CreateForType <ExperimentTracker>();

            config.SetValue("expGUI", expGUI);
            config.SetValue("expListRectX", (int)expListRect.x);
            config.SetValue("expListRectY", (int)expListRect.y);
            config.SetValue("infGUI", infGUI);
            config.SetValue("infRectX", (int)infRect.x);
            config.SetValue("infRectY", (int)infRect.y);
            config.save();

            /** Unregister for events */
            //GameEvents.onGUIApplicationLauncherReady.Remove(setupButton);

            /** Remove button */
#if false
            if (etButton != null)
            {
                ApplicationLauncher.Instance.RemoveModApplication(etButton);
            }
#endif
            toolbarControl.OnDestroy();
            Destroy(toolbarControl);
        }
Beispiel #8
0
        public void save_settings()
        {
            if (conf == null)
            {
                conf = PluginConfiguration.CreateForType <CorrectCoL>();
            }
            Debug.Log("[CorrectCoL]: serializing");
            if (wnd_rect != null)
            {
                conf.SetValue("x", wnd_rect.x.ToString());
                conf.SetValue("y", wnd_rect.y.ToString());
            }
            conf.SetValue("range", aoa_range.ToString());
            conf.save();

            // clear lock
            if (locked)
            {
                EditorLogic.fetch.Unlock("CorrectCoLWindow");
                locked = false;
            }
        }
Beispiel #9
0
        /// <summary>
        /// Destroy this instance.
        /// </summary>
        public void OnDestroy()
        {
            RenderingManager.RemoveFromPostDrawQueue(0, OnDraw);
            PluginConfiguration config = PluginConfiguration.CreateForType <KartographSettings> ();

            config.load();
            config.SetValue("ManeuverWindowPos", _windowPos);
            config.save();
            if (_instance == this)
            {
                _instance = null;
            }
        }
Beispiel #10
0
        public static int AssignNewID()
        {
            int id;

            PluginConfiguration config = PluginConfiguration.CreateForType <kOSProcessor>();

            config.load();
            id = config.GetValue <int>("CpuIDMax") + 1;
            config.SetValue("CpuIDMax", id);
            config.save();

            return(id);
        }
        public override void OnSave(ConfigNode node)
        {
            //if (uis.vesselInfo != null)
            //{
            //    uis.vesselInfo.Save(node.AddNode("DockedVesselInfo"));
            //}

            PluginConfiguration config = PluginConfiguration.CreateForType <OMCore>();

            config.SetValue("Window Position", uifs.defaultWindowPosition);
            //config.SetValue("Show Build Menu on StartUp", uis.showbuilduionload);
            config.save();
        }
        /// <summary>
        /// Callback for object destruction.
        /// </summary>
        public void OnDestroy()
        {
            ControlUnlock();

            PluginConfiguration config = PluginConfiguration.CreateForType <KartographSettings> ();

            config.load();
            config.SetValue("VesselWindowPos", _windowPos);
            config.SetValue("KrakenWarn", _krakenWarn);
            config.save();

            GameEvents.onVesselDestroy.Remove(VesselDestroyed);
            GameEvents.onHideUI.Remove(Hide);
            GameEvents.onShowUI.Remove(UnHide);
            GameEvents.onGamePause.Remove(Hide);
            GameEvents.onGameUnpause.Remove(UnHide);

            if (_instance == this)
            {
                _instance = null;
            }
        }
Beispiel #13
0
 /// <summary>
 /// Change the permanent ("don't remind me again") status of the permission
 /// in the kOS settings file.
 /// </summary>
 private void SetPermanentRealIPPermission(bool newValue)
 {
     try
     {
         PluginConfiguration savedPermissions = PluginConfiguration.CreateForType <TelnetMainServer>();
         savedPermissions.load();
         savedPermissions.SetValue("PermanentRealIPPermission", newValue);
         savedPermissions.save();
     }
     catch (Exception ex)
     {
         Debug.LogError(string.Format("{0} Exception Loading TelnetMainServer.xml (maybe the first time you ran and its not there yet): {1}", KSPLogger.LOGGER_PREFIX, ex.Message));
     }
 }
        /// <summary>
        /// Hail to The King, baby
        /// </summary>
        public void OnDestroy()
        {
            GameEvents.onGUIApplicationLauncherReady.Remove(onGUIApplicationLauncherReady);
            GameEvents.onLevelWasLoaded.Remove(onLevelWasLoaded);
            GameEvents.onVesselChange.Remove(onVesselChange);
            GameEvents.onHideUI.Remove(onHideUI);
            GameEvents.onShowUI.Remove(onShowUI);
            GameEvents.onGamePause.Remove(onGamePause);
            GameEvents.onGameUnpause.Remove(onGameUnpause);

            UnlockControls();
            DestroyLauncher();

            config.SetValue("windowRect", windowRect);
            config.SetValue("useToolbar", useToolbar);
            config.SetValue("maximized", maximized);
            config.save();

            if (Instance == this)
            {
                Instance = null;
            }
        }
Beispiel #15
0
        public void Save()
        {
            foreach (var x in GetType().GetProperties()
                     .Select(x => new
            {
                x.Name,
                Value = x.GetGetMethod().Invoke(this, null)
            }))
            {
                _kspPluginConfiguration.SetValue(x.Name, x.Value);
            }

            _kspPluginConfiguration.save();
        }
 /// <summary>
 /// Change the permanent ("don't remind me again") status of the permission
 /// in the kOS settings file.
 /// </summary>
 private void SetPermanentRealIPPermission(bool newValue)
 {
     try
     {
         PluginConfiguration savedPermissions = PluginConfiguration.CreateForType <TelnetMainServer>();
         savedPermissions.load();
         savedPermissions.SetValue("PermanentRealIPPermission", newValue);
         savedPermissions.save();
     }
     catch (Exception ex)
     {
         Debug.LogError(string.Format("{0} Exception loading telnet config options: {1}", KSPLogger.LOGGER_PREFIX, ex.Message));
     }
 }
Beispiel #17
0
        /// <summary>
        /// Called when destroying this instance.
        /// </summary>
        public void OnDestroy()
        {
            ControlUnlock();
            PluginConfiguration config = PluginConfiguration.CreateForType <KartographSettings> ();

            config.load();
            config.SetValue("AutoHide", _autoHide);
            config.SetValue("KrakenDisable", _disableKraken);
            config.SetValue("UseKspSkin", _useKspSkin);
            config.SetValue("UseToolbar", _useToolbar);
            config.SetValue("SettingsWindowPos", _windowPos);
            config.save();

            GameEvents.onHideUI.Remove(Hide);
            GameEvents.onShowUI.Remove(UnHide);
            GameEvents.onGamePause.Remove(Hide);
            GameEvents.onGameUnpause.Remove(UnHide);

            if (_instance == this)
            {
                _instance = null;
            }
        }
Beispiel #18
0
 //Save the configurable values
 public override void save(PluginConfiguration config)
 {
     config.SetValue("RZPosition", windowPosition);
     config.SetValue("RZMinimized", isMinimized);
     config.SetValue("RZRedDist", closestRed);
     config.SetValue("RZYellowDist", closestYellow);
     config.SetValue("RZGreenDist", closestGreen);
     config.SetValue("RZScale", (double)Scale);
 }
Beispiel #19
0
 public override void save(PluginConfiguration config)
 {
     config.SetValue("AirPosition", windowPosition);
     config.SetValue("AirMinimized", isMinimized);
     config.SetValue("AirScale", (double)Scale);
     config.SetValue("AirMinMach", (double)_minMach);
     config.SetValue("AirAoA", criticalAOA);
     config.SetValue("AirUseEAS", useEAS);
 }
Beispiel #20
0
        /// <summary>
        /// Closes the KISS window, unpauses the game and writes the specified reason into the Debug.Log.
        /// </summary>
        /// <param name="reason">Why/How was the window closed?</param>
        private void Close(string reason)
        {
            // save window position and current settings into config file
            config.SetValue("Window Position", windowPosSize);
            config.SetValue("confirmOverwrite", confirmOverwrite);
            config.SetValue("confirmDelete", confirmDelete);
            config.SetValue("useGameTime", useGameTime);
            config.SetValue("reverseOrder", reverseOrder);
            config.SetValue("selectedDfltSaveNameInt", selectedDfltSaveName);
            config.SetValue("quickSaveMode", quickSaveMode);
            config.SetValue("kissKeyCode", kissKeyCode);
            config.SetValue("kissKeyCaption", kissKeyCaption);

            config.save();

            // code to remove window from UI
            isVisible = false;
            Debug.Log(modLogTag + reason);
            FlightDriver.SetPause(false);
        }
        public override void OnSave(ConfigNode node)
        {
            if ((HighLogic.LoadedSceneIsFlight && IsInitedModule) /*|| HighLogic.LoadedSceneIsEditor*/)
            {
                PluginConfiguration config = PluginConfiguration.CreateForType <Ca2LeeCam>();

                windowPosition.x = windowRectangle.x;
                windowPosition.y = windowRectangle.y;
                config.SetValue("CLC Window Position", windowPosition);
                config.save();
                nodeInner = node;
                Debug.Log(string.Format("[TRF CLC{0}] OnSave() -  windowRectangle = " + windowRectangle.x.ToString() + " " + windowRectangle.y.ToString(), WindowID));
                Debug.Log(string.Format("[TRF CLC{0}] OnSave() -  windowPosition = " + windowPosition.x.ToString() + " " + windowPosition.y.ToString(), WindowID));
            }
        }
Beispiel #22
0
        private void Save()
        {
            var result = "";

            foreach (var kv in _modifiers)
            {
                if (kv.Value)
                {
                    result += kv.Key + "+";
                }
            }

            _config.SetValue(_name, result + _trigger);
            _config.save();
        }
Beispiel #23
0
        private void Save()
        {
            string result = "";

            foreach (KeyValuePair <KeyCode, bool> kv in _modifiers)
            {
                if (kv.Value)
                {
                    result += kv.Key + "+";
                }
            }

            _config.SetValue(_name, result + _trigger);
            _config.save();
        }
Beispiel #24
0
        public void SaveConfiguration()
        {
            try
            {
                foreach (string key in _keys.Keys)
                {
                    _pluginConfiguration.SetValue(key, _keys[key].Value);
                }

                _pluginConfiguration.save();
            }
            catch (Exception ex)
            {
                Log.E(ex, "An exception occured!");
            }
        }
Beispiel #25
0
        private void SaveSettings()
        {
            print("[img_viewer.dll] Saving Config...");
            PluginConfiguration _configfile = PluginConfiguration.CreateForType <ImgViewer>();

            _configfile.SetValue("windowpos", _windowRect);
            _configfile.SetValue("windowpos2", _windowRect2);
            _configfile.SetValue("keybind", _keybind);
            _configfile.SetValue("version", _version);
            _configfile.SetValue("kspskin", _useKSPskin);
            _configfile.SetValue("visible", _visible);
            _configfile.SetValue("lastimage", _selectionGridInt);

            _configfile.save();
            print("[img_viewer.dll] Config Saved ");
        }
Beispiel #26
0
        private void OnDestroy()
        {
            config.SetValue(this.name, windowRect);
            config.save();

            GameEvents.onLevelWasLoaded.Remove(onLevelWasLoaded);
            GameEvents.onVesselChange.Remove(onVesselChange);
            GameEvents.onHideUI.Remove(onHideUI);
            GameEvents.onShowUI.Remove(onShowUI);
            GameEvents.onGamePause.Remove(onGamePause);
            GameEvents.onGameUnpause.Remove(onGameUnpause);

            UnlockControls();
            DestroyLauncher();

            if (instance == this)
            {
                instance = null;
            }
        }
Beispiel #27
0
        internal void OnDestroy()
        {
            toolbarControl.OnDestroy();
            Destroy(toolbarControl);

            #if DEBUG
            // don't save configs because KramaxReload screws up PluginConfiguration
            #else
            PluginConfiguration config = PluginConfiguration.CreateForType <AutoAsparagus> ();
            config.SetValue("vizualize", vizualize);
            config.SetValue("stageParachutes", stageParachutes);
            config.SetValue("stageLaunchClamps", stageLaunchClamps);
            config.SetValue("launchClampsStage", launchClampsStage);
            config.SetValue("stagesepratrons", stagesepratrons);
            config.SetValue("useSmartStage", useSmartStage);
            config.SetValue("windowRectX", (int)windowRect.x);
            config.SetValue("windowRectY", (int)windowRect.y);
            config.save();
                        #endif

            GameEvents.onEditorShipModified.Remove(onCraftChange);
        }
Beispiel #28
0
        /// <summary>
        /// Called when this object is destroyed.
        /// </summary>
        public void OnDestroy()
        {
            ControlUnlock();

            PluginConfiguration config = PluginConfiguration.CreateForType <KartographSettings> ();

            config.load();
            config.SetValue("AppLaunchPos", _windowPos);
            config.save();

            DestroyButtons();

            GameEvents.onGUIApplicationLauncherReady.Remove(OnAppLaunchReady);
            GameEvents.onHideUI.Remove(Hide);
            GameEvents.onShowUI.Remove(UnHide);
            GameEvents.onGamePause.Remove(Hide);
            GameEvents.onGameUnpause.Remove(UnHide);

            if (_instance == this)
            {
                _instance = null;
            }
        }
        public void OnDestroy()
        {
            PluginConfiguration Config = PluginConfiguration.CreateForType <StationKeeping>();

            //Debug.Log ("[StationKeeping] Saving " + WindowRect);
            Config.SetValue("AltSkin", AltSkin);
            Config.SetValue("RCSOnly", RCSOnly);
            Config.SetValue("RealSMA", RealSMA);
            Config.SetValue("Tolerance", Tolerance);
            Config.SetValue("WindowX", (double)WindowRect.x);
            Config.SetValue("WindowY", (double)WindowRect.y);
            //Debug.Log ("Saved WindowX: " + Config ["WindowX"]);
            //Debug.Log ("Saved WindowY: " + Config ["WindowY"]);
            Config.save();

            toolbarControl.OnDestroy();
            Destroy(toolbarControl);
        }
Beispiel #30
0
 private void SaveConfigKey(ConfigKey key, PluginConfiguration config)
 {
     config.SetValue(key.StringKey, keys[key.StringKey.ToUpper()].Value);
 }
Beispiel #31
0
 private void SetColor(PluginConfiguration config, string text, Color color)
 {
     config.SetValue(text + "R", (double)color.r);
     config.SetValue(text + "G", (double)color.g);
     config.SetValue(text + "B", (double)color.b);
     config.SetValue(text + "A", (double)color.a);
 }
Beispiel #32
0
 public void Save(PluginConfiguration config)
 {
     SetColor(config, "hudTextColor", _hudTextColor);
     SetColor(config, "upperHalfColor", _upperHalfColor);
     SetColor(config, "lowerHalfColor", _lowerHalfColor);
     SetColor(config, "horizonColor", _horizonColor);
     SetColor(config, "azimuthColor", _azimuthColor);
     SetColor(config, "northColor", _northColor);
     SetColor(config, "eastColor", _eastColor);
     SetColor(config, "southColor", _southColor);
     SetColor(config, "westColor", _westColor);
     SetColor(config, "headingColor", _headingColor);
     SetColor(config, "alignmentColor", _alignmentColor);
     SetColor(config, "progradeColor", _progradeColor);
     SetColor(config, "normalColor", _normalColor);
     SetColor(config, "radialColor", _radialColor);
     SetColor(config, "targetColor", _targetColor);
     SetColor(config, "maneuverColor", _maneuverColor);
     config.SetValue("numberZenithLinesHalf", _numberZenithLinesHalf);
     config.SetValue("numberAzimuthLinesQuarter", _numberAzimuthLinesQuarter);
     config.SetValue("numberZenithVerts", _numberZenithVerts);
     config.SetValue("numberAzimuthVerts", _numberAzimuthVerts);
     config.SetValue("vectorSize", (double)_vectorSize);
     config.SetValue("lineWidth", (double)_lineWidth);
     config.SetValue("distance", (double)_distance);
 }
        /// <summary>
        /// Gets a value indicating whether an unknown element is encountered during deserialization.
        /// </summary>
        /// <param name="elementName">The name of the unknown subelement.</param>
        /// <param name="reader">The <see cref="global::System.Xml.XmlReader"/> being used for deserialization.</param>
        /// <returns>
        /// <see langword="true"/> when an unknown element is encountered while deserializing; otherwise, <see langword="false"/>.
        /// </returns>
        /// <exception cref="global::System.Configuration.ConfigurationErrorsException">The element identified by <paramref name="elementName"/> is locked.- or -One or more of the element's attributes is locked.- or -<paramref name="elementName"/> is unrecognized, or the element has an unrecognized attribute.- or -The element has a Boolean attribute with an invalid value.- or -An attempt was made to deserialize a property more than once.- or -An attempt was made to deserialize a property that is not a valid member of the element.- or -The element cannot contain a CDATA or text element.</exception>
        protected override bool OnDeserializeUnrecognizedElement(string elementName, global::System.Xml.XmlReader reader)
        {
            if (elementName == PluginConfigurationPropertyName && reader.AttributeCount > 0)
            {
                PluginConfiguration config = new PluginConfiguration(reader[0].ToString());

                if (reader.AttributeCount == 3)
                    config.SetValue(reader[1].ToString(), reader[2].ToString());
                else if (reader.AttributeCount == 2)
                    config.SetValue(reader[1].ToString());

                this.Add(config);
            }

            return true;
        }