Esempio n. 1
0
        public void Load()
        {
            ManifestUtilities.LogMessage("Settings load started...", "Info");

            try
            {
                KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <CrewManifestModule>();
                configfile.load();

                ManifestPosition = configfile.GetValue <Rect>("ManifestPosition");
                TransferPosition = configfile.GetValue <Rect>("TransferPosition");
                RosterPosition   = configfile.GetValue <Rect>("RosterPosition");
                SettingsPosition = configfile.GetValue <Rect>("SettingsPosition");
                DebuggerPosition = configfile.GetValue <Rect>("DebuggerPosition");

                ShowDebugger = configfile.GetValue <bool>("ShowDebugger");

                ManifestUtilities.LogMessage(string.Format("ManifestPosition Loaded: {0}, {1}, {2}, {3}", ManifestPosition.xMin, ManifestPosition.xMax, ManifestPosition.yMin, ManifestPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("TransferPosition Loaded: {0}, {1}, {2}, {3}", TransferPosition.xMin, TransferPosition.xMax, TransferPosition.yMin, TransferPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("RosterPosition Loaded: {0}, {1}, {2}, {3}", RosterPosition.xMin, RosterPosition.xMax, RosterPosition.yMin, RosterPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("SettingsPosition Loaded: {0}, {1}, {2}, {3}", SettingsPosition.xMin, SettingsPosition.xMax, SettingsPosition.yMin, SettingsPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("DebuggerPosition Loaded: {0}, {1}, {2}, {3}", DebuggerPosition.xMin, DebuggerPosition.xMax, DebuggerPosition.yMin, DebuggerPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("ShowDebugger Loaded: {0}", ShowDebugger.ToString()), "Info");
            }
            catch (Exception e)
            {
                ManifestUtilities.LogMessage(string.Format("Failed to Load Settings: {0} \r\n\r\n{1}", e.Message, e.StackTrace), "Exception");
            }
        }
Esempio n. 2
0
        public void Save()
        {
            try
            {
                KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <CrewManifestModule>();

                configfile.SetValue("ManifestPosition", ManifestPosition);
                configfile.SetValue("TransferPosition", TransferPosition);
                configfile.SetValue("RosterPosition", RosterPosition);
                configfile.SetValue("SettingsPosition", SettingsPosition);
                configfile.SetValue("DebuggerPosition", DebuggerPosition);
                configfile.SetValue("ShowDebugger", ShowDebugger);

                configfile.save();

                ManifestUtilities.LogMessage(string.Format("ManifestPosition Saved: {0}, {1}, {2}, {3}", ManifestPosition.xMin, ManifestPosition.xMax, ManifestPosition.yMin, ManifestPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("TransferPosition Saved: {0}, {1}, {2}, {3}", TransferPosition.xMin, TransferPosition.xMax, TransferPosition.yMin, TransferPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("RosterPosition Saved: {0}, {1}, {2}, {3}", RosterPosition.xMin, RosterPosition.xMax, RosterPosition.yMin, RosterPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("SettingsPosition Saved: {0}, {1}, {2}, {3}", SettingsPosition.xMin, SettingsPosition.xMax, SettingsPosition.yMin, SettingsPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("DebuggerPosition Saved: {0}, {1}, {2}, {3}", DebuggerPosition.xMin, DebuggerPosition.xMax, DebuggerPosition.yMin, DebuggerPosition.yMax), "Info");
                ManifestUtilities.LogMessage(string.Format("ShowDebugger Saved: {0}", ShowDebugger.ToString()), "Info");
                ManifestUtilities.LogMessage(string.Format("AllowRespawn Saved: {0}", ShowDebugger.ToString()), "Info");
            }
            catch (Exception e)
            {
                ManifestUtilities.LogMessage(string.Format("Failed to Save Settings: {0} \r\n\r\n{1}", e.Message, e.StackTrace), "Exception");
            }
        }
Esempio n. 3
0
        /*
         * Called after the scene is loaded.
         */
        void Awake()
        {
            //Load settings.
            KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <Kerbdometer>();
            config.load();
            isActive    = config.GetValue <bool>("isActive");
            guiPosition = config.GetValue <Rect>("guiPosition");
            defaultSkin = config.GetValue <bool>("defaultSkin");
            toolbarInt  = config.GetValue <int>("toolbarInt");

            //Toolbar button.
            toolbarButton             = ToolbarManager.Instance.add("Kerbdometer", "toolbarButton");
            toolbarButton.TexturePath = (isActive)? "Kerbdometer/Icons/toolbarOn": "Kerbdometer/Icons/toolbarOff";
            toolbarButton.ToolTip     = "Kerbdometer";
            toolbarButton.Visibility  = new GameScenesVisibility(GameScenes.FLIGHT);
            toolbarButton.OnClick    += (e) => ToggleDisplay();

            objectTypeAll         = FindObjectsOfType(typeof(UnityEngine.Object)).Length;
            objectTypeTextures    = FindObjectsOfType(typeof(Texture)).Length;
            objectTypeAudioClips  = FindObjectsOfType(typeof(AudioClip)).Length;
            objectTypeMeshes      = FindObjectsOfType(typeof(Mesh)).Length;
            objectTypeMaterials   = FindObjectsOfType(typeof(Material)).Length;
            objectTypeGameObjects = FindObjectsOfType(typeof(GameObject)).Length;
            objectTypeComponents  = FindObjectsOfType(typeof(Component)).Length;
        }
Esempio n. 4
0
        public void GUILoad()
        {
            KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <MissionController>();
            configfile.load();

            mainWindowPosition     = configfile.GetValue <Rect>("maineWindowPostion");
            settingsWindowPosition = configfile.GetValue <Rect>("settingsWindowPostion");
            financeWindowPosition  = configfile.GetValue <Rect>("finanaceWindowPostion");
            kerbalnautswinpostion  = configfile.GetValue <Rect>("kerbalnautWindowPostion");
            packageWindowPosition  = configfile.GetValue <Rect>("packageWindowPostion");
        }
Esempio n. 5
0
        /*
         * Called when the game is leaving the scene (or exiting). Perform any clean up work here.
         */
        void OnDestroy()
        {
            toolbarButton.Destroy();
            KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <Kerbdometer>();

            config.SetValue("isActive", isActive);
            config.SetValue("guiPosition", guiPosition);
            config.SetValue("defaultSkin", defaultSkin);
            config.SetValue("toolbarInt", toolbarInt);
            config.save();
        }
Esempio n. 6
0
        public void GUISave()
        {
            KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <MissionController>();

            configfile.SetValue("maineWindowPostion", mainWindowPosition);
            configfile.SetValue("settingsWindowPostion", settingsWindowPosition);
            configfile.SetValue("finanaceWindowPostion", financeWindowPosition);
            configfile.SetValue("kerbalnautWindowPostion", kerbalnautswinpostion);
            configfile.SetValue("packageWindowPostion", packageWindowPosition);

            configfile.save();
        }
        private static void LoadConstants(KIO.PluginConfiguration config)
        {
            reinforceAttachNodes             = config.GetValue <bool>("reinforceAttachNodes", reinforceAttachNodes);
            multiPartAttachNodeReinforcement = config.GetValue <bool>("multiPartAttachNodeReinforcement", multiPartAttachNodeReinforcement);
            reinforceDecouplersFurther       = config.GetValue <bool>("reinforceDecouplersFurther", reinforceDecouplersFurther);
            reinforceLaunchClampsFurther     = config.GetValue <bool>("reinforceLaunchClampsFurther", reinforceLaunchClampsFurther);
            useVolumeNotArea = config.GetValue <bool>("useVolumeNotArea", useVolumeNotArea);

            angularDriveSpring    = config.GetValue <float>("angularDriveSpring", angularDriveSpring);
            angularDriveDamper    = config.GetValue <float>("angularDriveDamper", angularDriveDamper);
            angularMaxForceFactor = config.GetValue <float>("angularMaxForceFactor", angularMaxForceFactor);
            if (angularMaxForceFactor < 0)
            {
                angularMaxForceFactor = float.MaxValue;
            }

            breakForceMultiplier  = config.GetValue <float>("breakForceMultiplier", breakForceMultiplier);
            breakTorqueMultiplier = config.GetValue <float>("breakTorqueMultiplier", breakTorqueMultiplier);

            breakStrengthPerArea = config.GetValue <float>("breakStrengthPerArea", breakStrengthPerArea);
            breakTorquePerMOI    = config.GetValue <float>("breakTorquePerMOI", breakTorquePerMOI);

            decouplerAndClampJointStrength = config.GetValue <float>("decouplerAndClampJointStrength", decouplerAndClampJointStrength);
            if (decouplerAndClampJointStrength < 0)
            {
                decouplerAndClampJointStrength = float.PositiveInfinity;
            }

            stiffeningExtensionMassRatioThreshold = config.GetValue <float>("stiffeningExtensionMassRatioThreshold", stiffeningExtensionMassRatioThreshold);

            massForAdjustment = config.GetValue <float>("massForAdjustment", massForAdjustment);

            int i = 0;

            do
            {
                string tmpPart, tmpModule, tmpDecoupler;
                tmpPart      = config.GetValue <string>("exemptPartType" + i, null);
                tmpModule    = config.GetValue <string>("exemptModuleType" + i, null);
                tmpDecoupler = config.GetValue <string>("decouplerStiffeningExtensionType" + i, null);

                if (null == tmpPart && null == tmpModule && null == tmpDecoupler)
                {
                    break;
                }

                if (null != tmpPart)
                {
                    exemptPartTypes.Add(tmpPart);
                }
                if (null != tmpModule)
                {
                    exemptModuleTypes.Add(tmpModule);
                }
                if (null != tmpDecoupler)
                {
                    decouplerStiffeningExtensionType.Add(tmpDecoupler);
                }

                i++;
            } while (true);

            debug = config.GetValue <bool>("debug", debug);
        }
Esempio n. 8
0
        internal static void Save()
        {
            try
            {
                // For some reason, saving floats does not seem to work.  (maybe I just don't know enough, but converted flowrates to doubles and it works.
                KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <ShipManifestModule>();

                // Window settings
                configfile.SetValue("ManifestPosition", ManifestPosition);
                configfile.SetValue("TransferPosition", TransferPosition);
                configfile.SetValue("RosterPosition", RosterPosition);
                configfile.SetValue("SettingsPosition", SettingsPosition);
                configfile.SetValue("ControlPosition", ControlPosition);
                configfile.SetValue("DebuggerPosition", DebuggerPosition);

                // Realism settings
                configfile.SetValue("RealismMode", RealismMode);
                configfile.SetValue("EnableCrew", EnableCrew);
                configfile.SetValue("OverrideStockCrewXfer", OverrideStockCrewXfer);
                configfile.SetValue("EnableCLS", EnableCLS);
                configfile.SetValue("EnableScience", EnableScience);
                configfile.SetValue("EnableResources", EnableResources);
                configfile.SetValue("EnablePFResources", EnablePFResources);
                configfile.SetValue("EnableXferCost", EnableXferCost);
                configfile.SetValue("FlowCost", (double)FlowCost);
                configfile.SetValue("FlowRate", (double)FlowRate);
                configfile.SetValue("MinFlowRate", (double)MinFlowRate);
                configfile.SetValue("MaxFlowRate", (double)MaxFlowRate);
                configfile.SetValue("MaxFlowTimeSec", MaxFlowTimeSec);
                configfile.SetValue("LockSettings", LockSettings);

                //Highlighting Settings
                configfile.SetValue("EnableHighlighting", EnableHighlighting);
                configfile.SetValue("OnlySourceTarget", OnlySourceTarget);
                configfile.SetValue("EnableCLSHighlighting", EnableCLSHighlighting);
                configfile.SetValue("SourcePartColor", SourcePartColor);
                configfile.SetValue("TargetPartColor", TargetPartColor);
                configfile.SetValue("TargetPartCrewColor", TargetPartCrewColor);
                configfile.SetValue("MouseOverColor", MouseOverColor);

                // ToolTip settings
                configfile.SetValue("ShowToolTips", ShowToolTips);
                configfile.SetValue("ManifestToolTips", ManifestToolTips);
                configfile.SetValue("TransferToolTips", TransferToolTips);
                configfile.SetValue("SettingsToolTips", SettingsToolTips);
                configfile.SetValue("RosterToolTips", RosterToolTips);
                configfile.SetValue("HatchToolTips", HatchToolTips);
                configfile.SetValue("PanelToolTips", PanelToolTips);
                configfile.SetValue("AntennaToolTips", AntennaToolTips);
                configfile.SetValue("LightToolTips", LightToolTips);
                configfile.SetValue("DebuggerToolTips", DebuggerToolTips);

                // Sound Settings
                configfile.SetValue("PumpSoundStart", PumpSoundStart);
                configfile.SetValue("PumpSoundRun", PumpSoundRun);
                configfile.SetValue("PumpSoundStop", PumpSoundStop);
                configfile.SetValue("PumpSoundVol", PumpSoundVol);
                configfile.SetValue("CrewSoundStart", CrewSoundStart);
                configfile.SetValue("CrewSoundRun", CrewSoundRun);
                configfile.SetValue("CrewSoundStop", CrewSoundStop);
                configfile.SetValue("CrewSoundVol", CrewSoundVol);

                // Configuration settings.
                configfile.SetValue("EnableBlizzyToolbar", EnableBlizzyToolbar);
                configfile.SetValue("ShowDebugger", ShowDebugger);
                configfile.SetValue("VerboseLogging", VerboseLogging);
                configfile.SetValue("AutoDebug", AutoDebug);
                configfile.SetValue("SaveLogOnExit", SaveLogOnExit);
                configfile.SetValue("ErrorLogLength", ErrorLogLength);
                configfile.SetValue("EnableKerbalRename", EnableKerbalRename);
                configfile.SetValue("RenameWithProfession", RenameWithProfession);
                configfile.SetValue("AutoSave", AutoSave);
                configfile.SetValue("SaveIntervalSec", (double)SaveIntervalSec);
                configfile.SetValue("DebugLogPath", DebugLogPath);
                configfile.SetValue("IVATimeDelaySec", IVATimeDelaySec);
                configfile.SetValue("ShowIVAUpdateBtn", ShowIVAUpdateBtn);
                configfile.SetValue("EnableTextureReplacer", EnableTextureReplacer);

                configfile.save();
                LogSettingsSave();
            }
            catch (Exception ex)
            {
                Utilities.LogMessage(string.Format("Failed to Save Settings: {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true);
            }
        }
Esempio n. 9
0
        internal static void Load()
        {
            //Utilities.LogMessage("Settings load started...", "Info", VerboseLogging);

            try
            {
                LoadColors();

                // Interestingly, Floats seem to load fine.   Saves seem to be problematic.  attempts to save float are not persisted in the file...
                // Update:   to save floats. write the ToString value.
                // So, FlowRate vars now use double and are converted at load
                KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <ShipManifestModule>();
                configfile.load();

                ManifestPosition = configfile.GetValue <Rect>("ManifestPosition", ManifestPosition);
                TransferPosition = configfile.GetValue <Rect>("TransferPosition", TransferPosition);
                DebuggerPosition = configfile.GetValue <Rect>("DebuggerPosition", DebuggerPosition);
                SettingsPosition = configfile.GetValue <Rect>("SettingsPosition", SettingsPosition);
                ControlPosition  = configfile.GetValue <Rect>("ControlPosition", ControlPosition);
                RosterPosition   = configfile.GetValue <Rect>("RosterPosition", RosterPosition);
                ShowDebugger     = configfile.GetValue <bool>("ShowDebugger", ShowDebugger);
                RealismMode      = configfile.GetValue <bool>("RealismMode", RealismMode);
                LockSettings     = configfile.GetValue <bool>("LockSettings", LockSettings);
                VerboseLogging   = configfile.GetValue <bool>("VerboseLogging", VerboseLogging);
                AutoSave         = configfile.GetValue <bool>("AutoSave", AutoSave);
                SaveIntervalSec  = configfile.GetValue <int>("SaveIntervalSec", SaveIntervalSec);
                FlowRate         = configfile.GetValue <double>("FlowRate", FlowRate);
                FlowCost         = configfile.GetValue <double>("FlowCost", FlowCost);
                MinFlowRate      = configfile.GetValue <double>("MinFlowRate", MinFlowRate);
                MaxFlowRate      = configfile.GetValue <double>("MaxFlowRate", MaxFlowRate);
                MaxFlowTimeSec   = configfile.GetValue <int>("MaxFlowTimeSec", MaxFlowTimeSec);
                EnableXferCost   = configfile.GetValue <bool>("EnableXferCost", EnableXferCost);

                PumpSoundStart = configfile.GetValue <string>("PumpSoundStart", PumpSoundStart);
                PumpSoundRun   = configfile.GetValue <string>("PumpSoundRun", PumpSoundRun);
                PumpSoundStop  = configfile.GetValue <string>("PumpSoundStop", PumpSoundStop);
                CrewSoundStart = configfile.GetValue <string>("CrewSoundStart", CrewSoundStart);
                CrewSoundRun   = configfile.GetValue <string>("CrewSoundRun", CrewSoundRun);
                CrewSoundStop  = configfile.GetValue <string>("CrewSoundStop", CrewSoundStop);

                PumpSoundVol = configfile.GetValue <double>("PumpSoundVol", PumpSoundVol);
                CrewSoundVol = configfile.GetValue <double>("CrewSoundVol", CrewSoundVol);

                SourcePartColor     = configfile.GetValue <string>("SourcePartColor", SourcePartColor);
                TargetPartColor     = configfile.GetValue <string>("TargetPartColor", TargetPartColor);
                TargetPartCrewColor = configfile.GetValue <string>("TargetPartCrewColor", TargetPartCrewColor);
                MouseOverColor      = configfile.GetValue <string>("MouseOverColor", MouseOverColor);

                EnableHighlighting    = configfile.GetValue <bool>("EnableHighlighting", EnableHighlighting);
                OnlySourceTarget      = configfile.GetValue <bool>("OnlySourceTarget", OnlySourceTarget);
                EnableCLSHighlighting = configfile.GetValue <bool>("EnableCLSHighlighting", EnableCLSHighlighting);
                EnableCrew            = configfile.GetValue <bool>("EnableCrew", EnableCrew);
                EnableScience         = configfile.GetValue <bool>("EnableScience", EnableScience);
                EnableResources       = configfile.GetValue <bool>("EnableResources", EnableResources);
                EnablePFResources     = configfile.GetValue <bool>("EnablePFResources", EnablePFResources);
                EnableCLS             = configfile.GetValue <bool>("EnableCLS", EnableCLS);
                OverrideStockCrewXfer = configfile.GetValue <bool>("OverrideStockCrewXfer", OverrideStockCrewXfer);
                EnableBlizzyToolbar   = configfile.GetValue <bool>("EnableBlizzyToolbar", EnableBlizzyToolbar);

                IVATimeDelaySec       = configfile.GetValue <double>("IVATimeDelaySec", IVATimeDelaySec);
                ShowIVAUpdateBtn      = configfile.GetValue <bool>("ShowIVAUpdateBtn", ShowIVAUpdateBtn);
                AutoDebug             = configfile.GetValue <bool>("AutoDebug", AutoDebug);
                DebugLogPath          = configfile.GetValue <string>("DebugLogPath", DebugLogPath);
                ErrorLogLength        = configfile.GetValue <string>("ErrorLogLength", ErrorLogLength);
                SaveLogOnExit         = configfile.GetValue <bool>("SaveLogOnExit", SaveLogOnExit);
                EnableKerbalRename    = configfile.GetValue <bool>("EnableKerbalRename", EnableKerbalRename);
                RenameWithProfession  = configfile.GetValue <bool>("RenameWithProfession", RenameWithProfession);
                EnableTextureReplacer = configfile.GetValue <bool>("EnableTextureReplacer", EnableTextureReplacer);
                ShowToolTips          = configfile.GetValue <bool>("ShowToolTips", ShowToolTips);
                ManifestToolTips      = configfile.GetValue <bool>("ManifestToolTips", ManifestToolTips);
                TransferToolTips      = configfile.GetValue <bool>("TransferToolTips", TransferToolTips);
                SettingsToolTips      = configfile.GetValue <bool>("SettingsToolTips", SettingsToolTips);
                RosterToolTips        = configfile.GetValue <bool>("RosterToolTips", RosterToolTips);
                HatchToolTips         = configfile.GetValue <bool>("HatchToolTips", HatchToolTips);
                PanelToolTips         = configfile.GetValue <bool>("PanelToolTips", PanelToolTips);
                AntennaToolTips       = configfile.GetValue <bool>("AntennaToolTips", AntennaToolTips);
                LightToolTips         = configfile.GetValue <bool>("LightToolTips", LightToolTips);
                DebuggerToolTips      = configfile.GetValue <bool>("DebuggerToolTips", DebuggerToolTips);

                // Lets make sure that the windows can be seen on the screen. (different resolutions)
                RepositionWindows();

                // Default values for Flow rates
                if (FlowRate == 0)
                {
                    FlowRate = 100;
                }
                if (MaxFlowRate == 0)
                {
                    MaxFlowRate = 1000;
                }

                // Default sound license: CC-By-SA
                // http://www.freesound.org/people/vibe_crc/sounds/59328/
                if (PumpSoundStart == "")
                {
                    PumpSoundStart = "ShipManifest/Sounds/59328-1";
                }
                if (PumpSoundRun == "")
                {
                    PumpSoundRun = "ShipManifest/Sounds/59328-2";
                }
                if (PumpSoundStop == "")
                {
                    PumpSoundStop = "ShipManifest/Sounds/59328-3";
                }

                // Default sound license: CC-By-SA
                // http://www.freesound.org/people/vibe_crc/sounds/14214/
                if (CrewSoundStart == "")
                {
                    CrewSoundStart = "ShipManifest/Sounds/14214-1";
                }
                if (CrewSoundRun == "")
                {
                    CrewSoundRun = "ShipManifest/Sounds/14214-2";
                }
                if (CrewSoundStop == "")
                {
                    CrewSoundStop = "ShipManifest/Sounds/14214-3";
                }

                LogSettingsLoad();
                Loaded = true;
            }
            catch (Exception ex)
            {
                Utilities.LogMessage(string.Format("Failed to Load Settings: {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true);
            }
        }