Exemple #1
0
        public override void OnLoad(ConfigNode node)
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <AntennaPrototype>();

            config.load();
            windowPosition = config.GetValue <Rect>("Window Position");
        }
        public void Load(ConfigNode node)
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <KerbalWeatherSystems>();

            config.load();
            MainGUI = config.GetValue <Rect>("Window Position");
        }
Exemple #3
0
        private void Start()
        {
            resourcePool     = new SortedList <string, double> ();
            requestPool      = new SortedList <string, double> ();
            vesselSpareSpace = new SortedList <string, double> ();

            partResources = new List <PartResource> ();

            config = PluginConfiguration.CreateForType <SimpleLogistics> ();
            config.load();

            windowRect = config.GetValue <Rect>(this.name, new Rect(0, 0, 400, 400));

            windowId = GUIUtility.GetControlID(FocusType.Passive);

            GUIglobalHidden = false;
            gamePaused      = false;
            GUIactive       = false;
            refreshGUI      = true;

            requested = false;
            CreateLauncher();

            GameEvents.onVesselChange.Add(onVesselChange);
            GameEvents.onLevelWasLoaded.Add(onLevelWasLoaded);
            GameEvents.onHideUI.Add(onHideUI);
            GameEvents.onShowUI.Add(onShowUI);
            GameEvents.onGamePause.Add(onGamePause);
            GameEvents.onGameUnpause.Add(onGameUnpause);
        }
		public void LoadConfigFile() {
			PluginConfiguration pc = PluginConfiguration.CreateForType<BackgroundProcessing>();
			if (pc == null) { return; }

			pc.load();
			config = new AddonConfig(pc);
			pc.save();
		}
Exemple #5
0
        public static void Getconfig()
        {
            PluginConfiguration cfg = PluginConfiguration.CreateForType <CVConfig>();

            cfg.load();
            MPWLog  = cfg.GetValue <bool>("MPWLog", true);
            KSPWLog = cfg.GetValue <bool>("KSPWLog", false);
        }
Exemple #6
0
        private void LoadConfigFile()
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <ExLaunchPad>();

            config.load();
            uis.windowpos         = config.GetValue <Rect>("Window Position");
            uis.showbuilduionload = config.GetValue <bool>("Show Build Menu on StartUp");
        }
Exemple #7
0
        private void SaveConfigKey(ConfigKey key)
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <Config>();

            config.load();
            SaveConfigKey(key, config);
            config.save();
        }
Exemple #8
0
 void Awake()
 {
     cfg = PluginConfiguration.CreateForType <Config>();
     cfg.load();
     TCPPort           = cfg.GetValue <int>("TCPPort", 9999);
     UpdatesPerSecond  = cfg.GetValue <int>("UpdatesPerSecond", 0);
     OrbitPlanSkipRate = cfg.GetValue <int>("OrbitPlanSkipRate", 1);
 }
        public override void OnLoad(ConfigNode node)
        {
            //LoadConfig();
            PluginConfiguration config = PluginConfiguration.CreateForType <OMCore>();

            config.load();
            uifs.defaultWindowPosition = config.GetValue <Rect>("Window Position");
        }
        public void SaveSettings()
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <KartographStyle> ();

            config.load();
            config.SetValue("Theme", _theme);
            config.save();
        }
        static private void readConfiguration()
        {
            config.load();

            // Read the port out of the config file
            int port = config.GetValue <int>("PORT");

            if (port != 0 && port.IsPortNumber())
            {
                serverConfig.port = port;
            }
            else if (!port.IsPortNumber())
            {
                PluginLogger.print("Port specified in configuration file '" + serverConfig.port + "' must be a value between 1 and 65535 inclusive");
            }
            else
            {
                PluginLogger.print("No port in configuration file - using default of " + serverConfig.port.ToString());
            }

            // Read a specific IP address to bind to
            string ip = config.GetValue <String>("IPADDRESS");

            if (ip != null)
            {
                IPAddress ipAddress = null;
                if (IPAddress.TryParse(ip, out ipAddress))
                {
                    serverConfig.ipAddress = ipAddress;
                }
                else
                {
                    PluginLogger.print("Invalid IP address in configuration file, falling back to default");
                }
            }
            else
            {
                PluginLogger.print("No IP address in configuration file.");
            }

            // Fill the serverconfig list of addresses.... if IPAddress.Any, then enumerate them
            if (serverConfig.ipAddress == IPAddress.Any)
            {
                // Build a list of addresses we will be able to recieve at
                serverConfig.ValidIpAddresses.Add(IPAddress.Loopback);
                serverConfig.ValidIpAddresses.AddRange(Dns.GetHostAddresses(Dns.GetHostName()));
            }
            else
            {
                serverConfig.ValidIpAddresses.Add(serverConfig.ipAddress);
            }

            serverConfig.version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            serverConfig.name    = "Telemachus";

            isPartless = config.GetValue <int>("PARTLESS") == 0 ? false : true;
            PluginLogger.print("Partless:" + isPartless);
        }
        public override void OnLoad(ConfigNode node)
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <LaunchUI>();

            config.load();
            _windowsPosition = config.GetValue <Rect>("Window Position");
            _audioSet        = config.GetValue("_audioSet", 0);
            _debug           = config.GetValue("_debug", false);
        }
Exemple #13
0
        private void LoadConfig()
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <AltimeterAutoHide>();

            config.load();
            activationPadding = config.GetValue <Vector2>("activationPadding", activationPadding);
            stickyOnLoad      = config.GetValue <bool>("stickyOnLoad", stickyOnLoad);
            config.save();
        }
Exemple #14
0
 internal void Load()
 {
     CONFIG.load();
     this.enableHotKey = CONFIG.GetValue <bool>("enableHotKey", this.enableHotKey);
     this.hotKey       = CONFIG.GetValue <KeyCode>("hotKey", this.hotKey);
     this.hideUnAct    = CONFIG.GetValue <bool>("hideUnAct", this.hideUnAct);
     this.altSkin      = CONFIG.GetValue <bool>("altSkin", this.altSkin);
     this.fontSize     = CONFIG.GetValue <int>("fontSize", this.fontSize);
 }
        public void Start()
        {
            _instance = this;
            DontDestroyOnLoad(this);
            PluginConfiguration config = PluginConfiguration.CreateForType <KartographSettings> ();

            config.load();
            _theme = config.GetValue <int> ("Theme", 0);
        }
Exemple #16
0
        public void Load()
        {
            _config.load();
            var rawNames = _config.GetValue(_name, "");

            if (!string.IsNullOrEmpty(rawNames))
            {
                ParseString(rawNames);
            }
        }
        void ReadConfig()
        {
            if (cfg != null)
            {
                return;
            }

            cfg = PluginConfiguration.CreateForType <SuitRefuel>();
            cfg.load();
        }
Exemple #18
0
        public void loadConfigXML()
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <MuMechGUI>();

            config.load();
            editorWinPos      = config.GetValue <Rect>("editorWinPos");
            tweakWinPos       = config.GetValue <Rect>("tweakWinPos");
            controlWinPos     = config.GetValue <Rect>("controlWinPos");
            groupEditorWinPos = config.GetValue <Rect>("groupEditorWinPos");
        }
Exemple #19
0
        public void loadConfigXML()
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <DevHelper>();

            config.load();

            autoLoadSave      = config.GetValue <bool>("autoLoadSave");
            autoLoadSaveName  = config.GetValue <string>("autoLoadSaveName");
            autoLoadScene     = config.GetValue <bool>("autoLoadScene");
            autoLoadSceneName = config.GetValue <string>("autoLoadSceneName");
        }
        public override void OnLoad(ConfigNode node)
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <Ca2LeeCam>();

            config.load();
            windowPosition  = config.GetValue <Vector2>("CLC Window Position");
            windowRectangle = new Rect(windowPosition.x, windowPosition.y, renderSize.x + 2 * windowBorder.x, renderSize.y + 2 * windowBorder.y + windowTitle);
            clcWindowActive = false;
            nodeInner       = node;
            Debug.Log(string.Format("[TRF CLC{0}] OnLoad() -  windowPosition = " + windowPosition.x.ToString() + " " + windowPosition.y.ToString(), WindowID));
        }
Exemple #21
0
        public void Load()
        {
            _kspPluginConfiguration.load();
            foreach (var x in GetType().GetProperties())
            {
                var getValueMethodGeneric = _getValueMethod.MakeGenericMethod(new[] { x.PropertyType });
                x.GetSetMethod().Invoke(this, new[] { getValueMethodGeneric.Invoke(_kspPluginConfiguration, new[] { x.Name, x.GetGetMethod().Invoke(this, null) }) });
            }

            Validate();
        }
Exemple #22
0
        internal void loadConfig()
        {
            Debug.Log("Loading PreciseManeuver settings.");
            PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <PreciseManeuver> (null);

            config.load();

            try {
                _showMainWindow = config.GetValue <bool> ("enabled", _showMainWindow);
                isInBackground  = config.GetValue <bool> ("background", isInBackground);

                foreach (HotkeyType type in Enum.GetValues(typeof(HotkeyType)))
                {
                    hotkeys[(int)type] = (KeyCode)Enum.Parse(typeof(KeyCode), config.GetValue <string> (type.ToString(), hotkeys[(int)type].ToString()));
                }

                foreach (ModuleType type in Enum.GetValues(typeof(ModuleType)))
                {
                    moduleState[(int)type] = config.GetValue <bool> (type.ToString(), moduleState[(int)type]);
                }

                _increment     = config.GetValue <int> ("increment", _increment);
                x10UTincrement = config.GetValue <bool> ("x10UTincrement", x10UTincrement);

                guiScale         = (float)config.GetValue <int> ("scale", (int)(guiScale * 1000f)) / 1000f;
                gizmoSensitivity = (float)config.GetValue <int> ("sensitivity", (int)(gizmoSensitivity * 10000f)) / 10000f;


                _mainWindowPos.x      = config.GetValue <int> ("mainWindowX", (int)_mainWindowPos.x);
                _mainWindowPos.y      = config.GetValue <int> ("mainWindowY", (int)_mainWindowPos.y);
                _keymapperWindowPos.x = config.GetValue <int> ("keyWindowX", (int)_keymapperWindowPos.x);
                _keymapperWindowPos.y = config.GetValue <int> ("keyWindowY", (int)_keymapperWindowPos.y);

                // presets
                var count = config.GetValue <int> ("presetsCount", 0);
                for (int i = 0; i < count; i++)
                {
                    var    name = config.GetValue <string> ("preset" + i.ToString() + "name", "");
                    double dx;
                    double dy;
                    double dz;

                    if (name != "" &&
                        Double.TryParse(config.GetValue <string> ("preset" + i.ToString() + "dx", ""), out dx) &&
                        Double.TryParse(config.GetValue <string> ("preset" + i.ToString() + "dy", ""), out dy) &&
                        Double.TryParse(config.GetValue <string> ("preset" + i.ToString() + "dz", ""), out dz))
                    {
                        presets.Add(name, new Vector3d(dx, dy, dz));
                    }
                }
            } catch (Exception) {
                // do nothing here, the defaults are already set
            }
        }
        internal void LoadConfig()
        {
            Debug.Log("[Precise Maneuver] Loading settings.");
            PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <PreciseManeuver> (null);

            config.load();

            try {
                showMainWindow = config.GetValue <bool> ("enabled", showMainWindow);
                IsInBackground = config.GetValue <bool> ("background", IsInBackground);

                foreach (HotkeyType type in Enum.GetValues(typeof(HotkeyType)))
                {
                    hotkeys[(int)type] = (KeyCode)Enum.Parse(typeof(KeyCode), config.GetValue <string> (type.ToString(), hotkeys[(int)type].ToString()));
                }

                foreach (ModuleType type in Enum.GetValues(typeof(ModuleType)))
                {
                    moduleState[(int)type] = config.GetValue <bool> (type.ToString(), moduleState[(int)type]);
                }

                increment      = config.GetValue <int> ("increment", increment);
                X10UTincrement = config.GetValue <bool> ("x10UTincrement", X10UTincrement);

                GUIScale         = (float)config.GetValue <int> ("scale", (int)(GUIScale * 1000f)) / 1000f;
                GizmoSensitivity = (float)config.GetValue <int> ("sensitivity", (int)(GizmoSensitivity * 10000f)) / 10000f;

                Vector2 mainWindowPos;
                mainWindowPos.x = config.GetValue <int> ("mainWindowX", (int)MainWindowPos.x);
                mainWindowPos.y = config.GetValue <int> ("mainWindowY", (int)MainWindowPos.y);
                MainWindowPos   = mainWindowPos;
                Vector2 keymapperWindowPos;
                keymapperWindowPos.x = config.GetValue <int> ("keyWindowX", (int)KeymapperWindowPos.x);
                keymapperWindowPos.y = config.GetValue <int> ("keyWindowY", (int)KeymapperWindowPos.y);
                KeymapperWindowPos   = keymapperWindowPos;

                // presets
                var count = config.GetValue <int> ("presetsCount", 0);
                for (int i = 0; i < count; i++)
                {
                    var name = config.GetValue <string> ("preset" + i.ToString() + "name", "");
                    if (name != "" &&
                        Double.TryParse(config.GetValue <string> ("preset" + i.ToString() + "dx", ""), out double dx) &&
                        Double.TryParse(config.GetValue <string> ("preset" + i.ToString() + "dy", ""), out double dy) &&
                        Double.TryParse(config.GetValue <string> ("preset" + i.ToString() + "dz", ""), out double dz))
                    {
                        presets.Add(name, new Vector3d(dx, dy, dz));
                    }
                }
            } catch (Exception e) {
                Debug.Log("[Precise Maneuver] There was an error reading config. That's OK if you're launching the mod the first time. " + e);
            }
        }
        private static void LoadWindowData()
        {
            config = PluginConfiguration.CreateForType <DockCamToolbarButton>(null);
            config.load();
            Rect rect = default(Rect);

            toolbarWindowPosition = config.GetValue <Rect>("toolbarWindowPosition", rect);
            shadersToUse0         = config.GetValue <bool>("shadersToUse0", shadersToUse0);
            shadersToUse1         = config.GetValue <bool>("shadersToUse1", shadersToUse1);
            shadersToUse2         = config.GetValue <bool>("shadersToUse2", shadersToUse2);
            FCS = config.GetValue <bool>("FCS", FCS);
        }
Exemple #25
0
        public void Update()
        {
            if (config == null) {
                config = PluginConfiguration.CreateForType<KerbalGIS> ();
                config.load ();
            }
            if (server == null) {
                server = new HTTPServer ();
            }

            server.Update ();
        }
Exemple #26
0
        private static void LoadWindowData()
        {
            _config = PluginConfiguration.CreateForType <DockCamToolbarButton>();
            _config.load();
            var defaultWindow = new Rect();

            _windowPosition = _config.GetValue("toolbarWindowPosition", defaultWindow);
            _shadersToUse0  = _config.GetValue("shadersToUse0", _shadersToUse0);
            _shadersToUse1  = _config.GetValue("shadersToUse1", _shadersToUse1);
            _shadersToUse2  = _config.GetValue("shadersToUse2", _shadersToUse2);
            FCS             = _config.GetValue("FCS", FCS);
        }
Exemple #27
0
        static private void readConfiguration()
        {
            config.load();

            int port = config.GetValue <int>("PORT");

            if (port != 0)
            {
                serverConfig.port = port;
            }
            else
            {
                PluginLogger.print("No port in configuration file.");
            }

            String ip = config.GetValue <String>("IPADDRESS");

            if (ip != null)
            {
                try
                {
                    serverConfig.addIPAddressAsString(ip);
                }
                catch
                {
                    PluginLogger.print("Invalid IP address in configuration file, falling back to find.");
                }
            }
            else
            {
                PluginLogger.print("No IP address in configuration file.");
            }


            serverConfig.maxRequestLength = config.GetValue <int>("MAXREQUESTLENGTH");

            if (serverConfig.maxRequestLength < 8000)
            {
                PluginLogger.print("No max request length specified, setting to 8000.");
                serverConfig.maxRequestLength = 10000;
            }
            else
            {
                PluginLogger.print("Max request length set to:" + serverConfig.maxRequestLength);
            }

            serverConfig.version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            serverConfig.name    = "Telemachus";
            serverConfig.backLog = 1000;

            isPartless = config.GetValue <int>("PARTLESS") == 0 ? false : true;
            PluginLogger.print("Partless:" + isPartless);
        }
Exemple #28
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);
        }
Exemple #29
0
        public void SaveConfig()
        {
            PluginConfiguration config = PluginConfiguration.CreateForType <Config>();

            config.load();

            foreach (ConfigKey key in keys.Values)
            {
                SaveConfigKey(key, config);
            }

            config.save();
        }
Exemple #30
0
        public static void Getconfig()
        {
            Debug.Log("[Maritime Pack] : cfg file loading...");
            PluginConfiguration cfg = PluginConfiguration.CreateForType <MPConfig>();

            cfg.load();
            MPWLog      = cfg.GetValue <bool>("MPWLog", false);
            KSPWLog     = cfg.GetValue <bool>("KSPWLog", false);
            MPDepthWarn = cfg.GetValue <bool>("MPDepthWarn", false);
            MPMaxDepth  = cfg.GetValue <float>("MPMaxDepth", 990.00f);
            MPLoadIcons = cfg.GetValue <bool>("MPLoadIcons", true);
            Debug.Log("[Maritime Pack] : cfg file loaded.");
        }
Exemple #31
0
        public void LoadConfigFile()
        {
            PluginConfiguration pc = PluginConfiguration.CreateForType <STAXK>();

            if (pc == null)
            {
                return;
            }

            pc.load();
            config = new STAXKConfig(pc);
            pc.save();
        }
        public static void LoadConfigs()
        {
            config = KSP.IO.PluginConfiguration.CreateForType<FAREditorGUI>();
            config.load();
            FARDebugValues.displayForces = Convert.ToBoolean(config.GetValue("displayForces", "false"));
            FARDebugValues.displayCoefficients = Convert.ToBoolean(config.GetValue("displayCoefficients", "false"));
            FARDebugValues.displayShielding = Convert.ToBoolean(config.GetValue("displayShielding", "false"));

            FAREditorGUI.windowPos = config.GetValue("windowPos", new Rect());
            FAREditorGUI.minimize = config.GetValue("EditorGUIBool", true);
            if (FAREditorGUI.windowPos.y < 75)
                FAREditorGUI.windowPos.y = 75;

            FARPartClassification.LoadClassificationTemplates();
            FARAeroUtil.LoadAeroDataFromConfig();
        }
Exemple #33
0
        public Configuration()
        {
            _plugConf = PluginConfiguration.CreateForType<Configuration>();
            _plugConf.load();
            PropertyChanged += Configuration_PropertyChanged;
            string rawPersistedFlights = _plugConf.GetValue<string>("persistedFlights");
            _iP = _plugConf.GetValue<string>("iP");
            _port = _plugConf.GetValue<int>("port",-1);
            _persistedFlightsLock = new object();

            if(_port == -1)
            {
                log.Debug("Port was not found in the configuration");
                Port = 10000;
            }

            if (_iP == null)
            {
                log.Debug("IP was not found in the configuration");
                IP = "192.168.1.7";
            }
            if (rawPersistedFlights == null)
            {
                log.Debug("Persisted flights was not found in the configuration");
                PersistedFlights = new List<string>();
            }
            else
            {
                try
                {
                    _persistedFlights = rawPersistedFlights.Split('|').Reverse().ToList<string>();
                }
                catch (Exception ex)
                {
                    log.Info(string.Format("Could not format persisted flights into an array, resetting it to default value. Persistedflights value is {0}", rawPersistedFlights), ex);
                    PersistedFlights = new List<string>();
                }
            }
        }
Exemple #34
0
        // Max patched conics buttons
        //private bool bMC_minus = false;
        //private bool bMC_plus = false;
        //private string bMC = FlightGlobals.ActiveVessel.patchedConicRenderer.
        // private double rad2deg = (180.0 / Math.PI);
        //private static Core _core;
        //private static bool _draw = true;
        public void Awake()
        {
            //DontDestroyOnLoad (this);
            CancelInvoke ();
            //InvokeRepeating ("ClockUpdate",0.2F,0.2F);
            Debug.Log ("NodeFreeze is alive");

            if (cfgLoaded == false) {
                Debug.Log ("Enabling cfg file");
                cfg = KSP.IO.PluginConfiguration.CreateForType<NodeSelect>(null);
                Debug.Log ("Loading cfg");
                cfg.load ();
                Debug.Log ("CFG loaded");
                cfgLoaded = true;
                try {
                    string cfgCycleKey = cfg.GetValue<String> ("cycleKey", "undefined");
                    if (cfgCycleKey.Equals ("undefined")) {
                        cfg ["cycleKey"] = "O";
                        cfgCycleKey = "O";
                        cfg.save ();
                    }
                    cycleKey = (KeyCode)Enum.Parse (typeof(KeyCode), "O");
                    Debug.Log ("Cycle key set through try");
                    string cfgConicsMode = cfg.GetValue<String> ("conicsMode", "3");
                } catch (ArgumentException) {
                    cycleKey = KeyCode.O;
                    Debug.Log ("Cycle key set through exception");
                }

                // Setting hide key
                /*
                try {
                    string cfgHideKey = cfg.GetValue<String> ("hideKey", "undefined");
                    if (cfgHideKey.Equals ("undefined")) {
                        cfg ["hideKey"] = "I";
                        cfgHideKey = "I";
                        cfg.save ();
                    }
                    hideKey = (KeyCode)Enum.Parse (typeof(KeyCode), cfgHideKey);
                    Debug.Log ("Hide key set through try");
                } catch (ArgumentException) {
                    hideKey = KeyCode.I;
                    Debug.Log ("Hide key set through exception");
                }
                */
            }
        }
        private void loadConfig()
        {
            Debug.Log("Loading PartDamage settings.");
            if(!configLoaded) {
                config = KSP.IO.PluginConfiguration.CreateForType<PartDamage>(null);
                config.load();
                configLoaded = true;

                try {
                    checkInterval = config.GetValue<double>("checkInterval", 10.0);
                    checkThreshold = config.GetValue<double>("checkThreshold", 0.9);
                    randomTries = config.GetValue<int>("randomTries", 5);
                } catch(ArgumentException) {
                    // do nothing here, the defaults are already set
                }
            }
        }
        public static void LoadConfigs()
        {
            config = KSP.IO.PluginConfiguration.CreateForType<FAREditorGUI>();
            config.load();
            FARControlSys.windowPos = config.GetValue("FlightWindowPos", new Rect(100, 100, 150, 100));
            FARControlSys.AutopilotWinPos = config.GetValue("AutopilotWinPos", new Rect());
            FARControlSys.HelpWindowPos = config.GetValue("HelpWindowPos", new Rect());
            FARControlSys.FlightDataPos = config.GetValue("FlightDataPos", new Rect());
            FARControlSys.FlightDataHelpPos = config.GetValue("FlightDataHelpPos", new Rect());
            FARControlSys.AirSpeedPos = config.GetValue("AirSpeedPos", new Rect());
            FARControlSys.AirSpeedHelpPos = config.GetValue("AirSpeedHelpPos", new Rect());
            FARControlSys.minimize = config.GetValue<bool>("FlightGUIBool", false);
            FARControlSys.k_wingleveler_str = config.GetValue("k_wingleveler", "0.05");
            FARControlSys.k_wingleveler = Convert.ToDouble(FARControlSys.k_wingleveler_str);
            FARControlSys.kd_wingleveler_str = config.GetValue("kd_wingleveler", "0.002");
            FARControlSys.kd_wingleveler = Convert.ToDouble(FARControlSys.kd_wingleveler_str);
            FARControlSys.k_yawdamper_str = config.GetValue("k_yawdamper", "0.1");
            FARControlSys.k_yawdamper = Convert.ToDouble(FARControlSys.k_yawdamper_str);
            FARControlSys.k_pitchdamper_str = config.GetValue("k_pitchdamper", "0.25f");
            FARControlSys.k_pitchdamper = Convert.ToDouble(FARControlSys.k_pitchdamper_str);
            FARControlSys.scaleVelocity_str = config.GetValue("scaleVelocity", "150");
            FARControlSys.scaleVelocity = Convert.ToDouble(FARControlSys.scaleVelocity_str);
            FARControlSys.alt_str = config.GetValue("alt", "0");
            FARControlSys.alt = Convert.ToDouble(FARControlSys.alt_str);
            FARControlSys.upperLim_str = config.GetValue("upperLim", "25");
            FARControlSys.upperLim = Convert.ToDouble(FARControlSys.upperLim_str);
            FARControlSys.lowerLim_str = config.GetValue("lowerLim", "-25");
            FARControlSys.lowerLim = Convert.ToDouble(FARControlSys.lowerLim_str);
            FARControlSys.k_limiter_str = config.GetValue("k_limiter", "0.25f");
            FARControlSys.k_limiter = Convert.ToDouble(FARControlSys.k_limiter_str);

            FARControlSys.unitMode = (FARControlSys.SurfaceVelUnit)config.GetValue("unitMode", 0);
            FARControlSys.velMode = (FARControlSys.SurfaceVelMode)config.GetValue("velMode", 0);

            FARDebugValues.displayForces = Convert.ToBoolean(config.GetValue("displayForces", "false"));
            FARDebugValues.displayCoefficients = Convert.ToBoolean(config.GetValue("displayCoefficients", "false"));
            FARDebugValues.displayShielding = Convert.ToBoolean(config.GetValue("displayShielding", "false"));
            FARDebugValues.useSplinesForSupersonicMath = Convert.ToBoolean(config.GetValue("useSplinesForSupersonicMath", "true"));
            FARDebugValues.allowStructuralFailures = Convert.ToBoolean(config.GetValue("allowStructuralFailures", "true"));

            FARAeroStress.LoadStressTemplates();
            FARPartClassification.LoadClassificationTemplates();
            FARAeroUtil.LoadAeroDataFromConfig();
        }
        /// <summary>
        /// Load any saved configuration from file.
        /// </summary>
        private void loadConfig()
        {
            Debug.Log("Loading PreciseNode settings.");
            if(!configLoaded) {
                config = KSP.IO.PluginConfiguration.CreateForType<PreciseNode>(null);
                config.load();
                configLoaded = true;

                try {
                    options.conicsMode = config.GetValue<int>("conicsMode", 3);
                    options.mainWindowPos.x = config.GetValue<int>("mainWindowX", Screen.width / 10);
                    options.mainWindowPos.y = config.GetValue<int>("mainWindowY", 20);
                    options.optionsWindowPos.x = config.GetValue<int>("optWindowX", Screen.width / 3);
                    options.optionsWindowPos.y = config.GetValue<int>("optWindowY", 20);
                    options.keymapperWindowPos.x = config.GetValue<int>("keyWindowX", Screen.width / 5);
                    options.keymapperWindowPos.y = config.GetValue<int>("keyWindowY", 20);
                    options.clockWindowPos.x = config.GetValue<int>("clockWindowX", Screen.width / 3);
                    options.clockWindowPos.y = config.GetValue<int>("clockWindowY", Screen.height / 2);
                    options.conicsWindowPos.x = config.GetValue<int>("conicsWindowX", Screen.width / 5);
                    options.conicsWindowPos.y = config.GetValue<int>("conicsWindowY", Screen.height / 2);
                    options.tripWindowPos.x = config.GetValue<int>("tripWindowX", Screen.width / 5);
                    options.tripWindowPos.y = config.GetValue<int>("tripWindowY", Screen.height / 5);
                    options.showClock = config.GetValue<bool>("showClock", false);
                    options.showEAngle = config.GetValue<bool>("showEAngle", true);
                    options.showConicsAlways = config.GetValue<bool>("showConicsAlways", false);
                    options.showOrbitInfo = config.GetValue<bool>("showOrbitInfo", false);
                    options.showUTControls = config.GetValue<bool>("showUTControls", false);
                    options.showManeuverPager = config.GetValue<bool>("showManeuverPager", true);
                    options.removeUsedNodes = config.GetValue<bool>("removeUsedNodes", false);
                    options.usedNodeThreshold = config.GetValue<double>("usedNodeThreshold", 0.5);
                    options.largeUTIncrement = config.GetValue<bool>("largeUTIncrement", false);

                    string temp = config.GetValue<String>("progInc", "Keypad8");
                    options.progInc = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("progDec", "Keypad5");
                    options.progDec = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("normInc", "Keypad9");
                    options.normInc = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("normDec", "Keypad7");
                    options.normDec = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("radiInc", "Keypad6");
                    options.radiInc = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("radiDec", "Keypad4");
                    options.radiDec = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("timeInc", "Keypad3");
                    options.timeInc = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("timeDec", "Keypad1");
                    options.timeDec = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("pageIncrement", "Keypad0");
                    options.pageIncrement = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("pageConics", "KeypadEnter");
                    options.pageConics = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("hideWindow", "P");
                    options.hideWindow = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                    temp = config.GetValue<String>("addWidget", "O");
                    options.addWidget = (KeyCode)Enum.Parse(typeof(KeyCode), temp);
                } catch(ArgumentException) {
                    // do nothing here, the defaults are already set
                }
            }
        }
Exemple #38
0
        public void Start()
        {
            config = PluginConfiguration.CreateForType<Targetron>();
            config.load();
            //Load position and collapse state from config file
            pos = config.GetValue("pos", new Rect(Screen.width - windowWidth - 10, Screen.height / 3.0f - windowHeight / 2.0f, windowWidth, windowHeight));
            expand = config.GetValue("expand", true);
            toggleOn = config.GetValue("toggleOn", true);
            sortMode = config.GetValue("sortMode", 0);

            for (int i = 0; i < filters.Count; i++)
                filters[i].Enabled = config.GetValue("filter" + i, true);

            //Make sure width and height are within limits
            pos.width = Mathf.Clamp(pos.width, minWindowWidth, maxWindowWidth);
            pos.height = Mathf.Clamp(pos.height, minWindowHeight, maxWindowHeight);

            RenderingManager.AddToPostDrawQueue(0, OnDraw);

            if (!ToolbarManager.ToolbarAvailable) return;
            ToolbarButton = ToolbarManager.Instance.add("Targetron", "tgbutton");
            ToolbarButton.Text = "Targetron " + VERSION;
            ToolbarButton.ToolTip = "Targetron " + VERSION;
            ToolbarButton.TexturePath = "Targetron/Icons/targetron";
            ToolbarButton.Visibility = new GameScenesVisibility(GameScenes.FLIGHT);
            ToolbarButton.OnClick += e => toggleOn = !toggleOn;
        }