Exemplo n.º 1
0
        internal static void LoadSettings()
        {
            LoadColors();

            if (Settings == null)
            {
                LoadSettingsFile();
            }
            if (Settings != null)
            {
                ConfigNode windowsNode = Settings.HasNode("SM_Windows")
          ? Settings.GetNode("SM_Windows")
          : Settings.AddNode("SM_Windows");
                ConfigNode realismNode = Settings.HasNode("SM_Realism")
          ? Settings.GetNode("SM_Realism")
          : Settings.AddNode("SM_Realism");
                ConfigNode highlightNode = Settings.HasNode("SM_Highlight")
          ? Settings.GetNode("SM_Highlight")
          : Settings.AddNode("SM_Highlight");
                ConfigNode toolTipsNode = Settings.HasNode("SM_ToolTips")
          ? Settings.GetNode("SM_ToolTips")
          : Settings.AddNode("SM_ToolTips");
                ConfigNode soundsNode = Settings.HasNode("SM_Sounds")
          ? Settings.GetNode("SM_Sounds")
          : Settings.AddNode("SM_Sounds");
                ConfigNode configNode = Settings.HasNode("SM_Config")
          ? Settings.GetNode("SM_Config")
          : Settings.AddNode("SM_Config");
                ConfigNode hiddenNode = Settings.HasNode("SM_Hidden")
          ? Settings.GetNode("SM_Hidden")
          : Settings.AddNode("SM_Hidden");

                // Lets get our rectangles...
                WindowManifest.Position = GetRectangle(windowsNode, "ManifestPosition", WindowManifest.Position);
                WindowTransfer.Position = GetRectangle(windowsNode, "TransferPosition", WindowTransfer.Position);
                WindowDebugger.Position = GetRectangle(windowsNode, "DebuggerPosition", WindowDebugger.Position);
                WindowSettings.Position = GetRectangle(windowsNode, "SettingsPosition", WindowSettings.Position);
                WindowControl.Position  = GetRectangle(windowsNode, "ControlPosition", WindowControl.Position);
                WindowRoster.Position   = GetRectangle(windowsNode, "RosterPosition", WindowRoster.Position);

                // now the settings
                // Realism Settings
                RealismMode = realismNode.HasValue("RealismMode")
          ? int.Parse(realismNode.GetValue("RealismMode"))
          : RealismMode;
                RealXfers = realismNode.HasValue("RealXfers")
          ? bool.Parse(realismNode.GetValue("RealXfers"))
          : RealXfers;
                RealControl = realismNode.HasValue("RealControl")
          ? bool.Parse(realismNode.GetValue("RealControl"))
          : RealControl;
                EnableCrew = realismNode.HasValue("EnableCrew")
          ? bool.Parse(realismNode.GetValue("EnableCrew"))
          : EnableCrew;
                EnableKerbalRename = realismNode.HasValue("EnableKerbalRename")
          ? bool.Parse(realismNode.GetValue("EnableKerbalRename"))
          : EnableKerbalRename;
                EnableChangeProfession = realismNode.HasValue("EnableChangeProfession")
          ? bool.Parse(realismNode.GetValue("EnableChangeProfession"))
          : EnableChangeProfession;
                EnableCrewModify = realismNode.HasValue("EnableCrewModify")
          ? bool.Parse(realismNode.GetValue("EnableCrewModify"))
          : EnableCrewModify;
                EnablePfCrews = realismNode.HasValue("EnablePfCrews")
          ? bool.Parse(realismNode.GetValue("EnablePfCrews"))
          : EnablePfCrews;
                EnableStockCrewXfer = realismNode.HasValue("EnableStockCrewTransfer")
          ? bool.Parse(realismNode.GetValue("EnableStockCrewTransfer"))
          : EnableStockCrewXfer;

                EnableScience = realismNode.HasValue("EnableScience")
          ? bool.Parse(realismNode.GetValue("EnableScience"))
          : EnableScience;
                EnableResources = realismNode.HasValue("EnableResources")
          ? bool.Parse(realismNode.GetValue("EnableResources"))
          : EnableResources;
                EnablePfResources = realismNode.HasValue("EnablePFResources")
          ? bool.Parse(realismNode.GetValue("EnablePFResources"))
          : EnablePfResources;
                EnableCls = realismNode.HasValue("EnableCLS")
          ? bool.Parse(realismNode.GetValue("EnableCLS"))
          : EnableCls;
                OverrideStockCrewXfer = realismNode.HasValue("OverrideStockCrewTransfer")
          ? bool.Parse(realismNode.GetValue("OverrideStockCrewTransfer"))
          : OverrideStockCrewXfer;
                EnableClsAllowTransfer = realismNode.HasValue("EnableClsAllowTransfer")
          ? bool.Parse(realismNode.GetValue("EnableClsAllowTransfer"))
          : EnableClsAllowTransfer;
                FlowRate = realismNode.HasValue("FlowRate")
          ? double.Parse(realismNode.GetValue("FlowRate"))
          : FlowRate;
                FlowCost = realismNode.HasValue("FlowCost")
          ? double.Parse(realismNode.GetValue("FlowCost"))
          : FlowCost;
                MinFlowRate = realismNode.HasValue("MinFlowRate")
          ? double.Parse(realismNode.GetValue("MinFlowRate"))
          : MinFlowRate;
                MaxFlowRate = realismNode.HasValue("MaxFlowRate")
          ? double.Parse(realismNode.GetValue("MaxFlowRate"))
          : MaxFlowRate;
                MaxFlowTimeSec = realismNode.HasValue("MaxFlowTimeSec")
          ? int.Parse(realismNode.GetValue("MaxFlowTimeSec"))
          : MaxFlowTimeSec;
                EnableXferCost = realismNode.HasValue("EnableXferCost")
          ? bool.Parse(realismNode.GetValue("EnableXferCost"))
          : EnableXferCost;
                LockSettings = realismNode.HasValue("LockSettings")
          ? bool.Parse(realismNode.GetValue("LockSettings"))
          : LockSettings;

                // Highlighting settings
                EnableHighlighting = highlightNode.HasValue("EnableHighlighting")
          ? bool.Parse(highlightNode.GetValue("EnableHighlighting"))
          : EnableHighlighting;
                OnlySourceTarget = highlightNode.HasValue("OnlySourceTarget")
          ? bool.Parse(highlightNode.GetValue("OnlySourceTarget"))
          : OnlySourceTarget;
                EnableClsHighlighting = highlightNode.HasValue("EnableCLSHighlighting")
          ? bool.Parse(highlightNode.GetValue("EnableCLSHighlighting"))
          : EnableClsHighlighting;
                EnableEdgeHighlighting = highlightNode.HasValue("EnableEdgeHighlighting")
          ? bool.Parse(highlightNode.GetValue("EnableEdgeHighlighting"))
          : EnableClsHighlighting;
                ResourcePartColor = hiddenNode.HasValue("ResourcePartColor")
          ? hiddenNode.GetValue("ResourcePartColor")
          : ResourcePartColor;

                // ToolTip Settings
                ShowToolTips = toolTipsNode.HasValue("ShowToolTips")
          ? bool.Parse(toolTipsNode.GetValue("ShowToolTips"))
          : ShowToolTips;
                WindowManifest.ShowToolTips = toolTipsNode.HasValue("ManifestToolTips")
          ? bool.Parse(toolTipsNode.GetValue("ManifestToolTips"))
          : WindowManifest.ShowToolTips;
                WindowTransfer.ShowToolTips = toolTipsNode.HasValue("TransferToolTips")
          ? bool.Parse(toolTipsNode.GetValue("TransferToolTips"))
          : WindowTransfer.ShowToolTips;
                WindowSettings.ShowToolTips = toolTipsNode.HasValue("SettingsToolTips")
          ? bool.Parse(toolTipsNode.GetValue("SettingsToolTips"))
          : WindowSettings.ShowToolTips;
                TabRealism.ShowToolTips = toolTipsNode.HasValue("RealismToolTips")
          ? bool.Parse(toolTipsNode.GetValue("RealismToolTips"))
          : TabRealism.ShowToolTips;
                TabHighlight.ShowToolTips = toolTipsNode.HasValue("HighlightingToolTips")
          ? bool.Parse(toolTipsNode.GetValue("HighlightingToolTips"))
          : TabHighlight.ShowToolTips;
                TabToolTips.ShowToolTips = toolTipsNode.HasValue("ToolTipsToolTips")
          ? bool.Parse(toolTipsNode.GetValue("ToolTipsToolTips"))
          : TabToolTips.ShowToolTips;
                TabSounds.ShowToolTips = toolTipsNode.HasValue("SoundsToolTips")
          ? bool.Parse(toolTipsNode.GetValue("SoundsToolTips"))
          : TabSounds.ShowToolTips;
                TabConfig.ShowToolTips = toolTipsNode.HasValue("ConfigToolTips")
          ? bool.Parse(toolTipsNode.GetValue("ConfigToolTips"))
          : TabConfig.ShowToolTips;
                WindowRoster.ShowToolTips = toolTipsNode.HasValue("RosterToolTips")
          ? bool.Parse(toolTipsNode.GetValue("RosterToolTips"))
          : WindowRoster.ShowToolTips;
                WindowControl.ShowToolTips = toolTipsNode.HasValue("ControlToolTips")
          ? bool.Parse(toolTipsNode.GetValue("ControlToolTips"))
          : WindowControl.ShowToolTips;
                TabHatch.ShowToolTips = toolTipsNode.HasValue("HatchToolTips")
          ? bool.Parse(toolTipsNode.GetValue("HatchToolTips"))
          : TabHatch.ShowToolTips;
                TabSolarPanel.ShowToolTips = toolTipsNode.HasValue("PanelToolTips")
          ? bool.Parse(toolTipsNode.GetValue("PanelToolTips"))
          : TabSolarPanel.ShowToolTips;
                TabAntenna.ShowToolTips = toolTipsNode.HasValue("AntennaToolTips")
          ? bool.Parse(toolTipsNode.GetValue("AntennaToolTips"))
          : TabAntenna.ShowToolTips;
                TabLight.ShowToolTips = toolTipsNode.HasValue("LightToolTips")
          ? bool.Parse(toolTipsNode.GetValue("LightToolTips"))
          : TabLight.ShowToolTips;
                WindowDebugger.ShowToolTips = toolTipsNode.HasValue("DebuggerToolTips")
          ? bool.Parse(toolTipsNode.GetValue("DebuggerToolTips"))
          : WindowDebugger.ShowToolTips;

                // Sounds Settings
                PumpSoundStart = soundsNode.HasValue("PumpSoundStart")
          ? soundsNode.GetValue("PumpSoundStart")
          : PumpSoundStart;
                PumpSoundRun = soundsNode.HasValue("PumpSoundRun")
          ? soundsNode.GetValue("PumpSoundRun")
          : PumpSoundRun;
                PumpSoundStop = soundsNode.HasValue("PumpSoundStop")
          ? soundsNode.GetValue("PumpSoundStop")
          : PumpSoundStop;
                CrewSoundStart = soundsNode.HasValue("CrewSoundStart")
          ? soundsNode.GetValue("CrewSoundStart")
          : CrewSoundStart;
                CrewSoundRun = soundsNode.HasValue("CrewSoundRun")
          ? soundsNode.GetValue("CrewSoundRun")
          : CrewSoundRun;
                CrewSoundStop = soundsNode.HasValue("CrewSoundStop")
          ? soundsNode.GetValue("CrewSoundStop")
          : CrewSoundStop;

                PumpSoundVol = soundsNode.HasValue("PumpSoundVol")
          ? double.Parse(soundsNode.GetValue("PumpSoundVol"))
          : PumpSoundVol;
                CrewSoundVol = soundsNode.HasValue("CrewSoundVol")
          ? double.Parse(soundsNode.GetValue("CrewSoundVol"))
          : CrewSoundVol;

                // Config Settings
                EnableBlizzyToolbar = configNode.HasValue("EnableBlizzyToolbar")
          ? bool.Parse(configNode.GetValue("EnableBlizzyToolbar"))
          : EnableBlizzyToolbar;
                WindowDebugger.ShowWindow = configNode.HasValue("ShowDebugger")
          ? bool.Parse(configNode.GetValue("ShowDebugger"))
          : WindowDebugger.ShowWindow;
                VerboseLogging = configNode.HasValue("VerboseLogging")
          ? bool.Parse(configNode.GetValue("VerboseLogging"))
          : VerboseLogging;
                AutoSave = configNode.HasValue("AutoSave")
          ? bool.Parse(configNode.GetValue("AutoSave"))
          : AutoSave;
                SaveIntervalSec = configNode.HasValue("SaveIntervalSec")
          ? int.Parse(configNode.GetValue("SaveIntervalSec"))
          : SaveIntervalSec;
                AutoDebug = configNode.HasValue("AutoDebug")
          ? bool.Parse(configNode.GetValue("AutoDebug"))
          : AutoDebug;
                DebugLogPath = configNode.HasValue("DebugLogPath")
          ? configNode.GetValue("DebugLogPath")
          : DebugLogPath;
                ErrorLogLength = configNode.HasValue("ErrorLogLength")
          ? configNode.GetValue("ErrorLogLength")
          : ErrorLogLength;
                SaveLogOnExit = configNode.HasValue("SaveLogOnExit")
          ? bool.Parse(configNode.GetValue("SaveLogOnExit"))
          : SaveLogOnExit;
                UseUnityStyle = configNode.HasValue("UseUnityStyle")
          ? bool.Parse(configNode.GetValue("UseUnityStyle"))
          : UseUnityStyle;

                // Hidden Settings
                // Hidden Highlighting
                SourcePartColor = hiddenNode.HasValue("SourcePartColor")
          ? hiddenNode.GetValue("SourcePartColor")
          : SourcePartColor;
                TargetPartColor = hiddenNode.HasValue("TargetPartColor")
          ? hiddenNode.GetValue("TargetPartColor")
          : TargetPartColor;
                TargetPartCrewColor = hiddenNode.HasValue("TargetPartCrewColor")
          ? hiddenNode.GetValue("TargetPartCrewColor")
          : TargetPartCrewColor;
                MouseOverColor = hiddenNode.HasValue("MouseOverColor")
          ? hiddenNode.GetValue("MouseOverColor")
          : MouseOverColor;

                // Hidden config
                CrewXferDelaySec = hiddenNode.HasValue("CrewXferDelaySec")
          ? double.Parse(hiddenNode.GetValue("CrewXferDelaySec"))
          : CrewXferDelaySec;
                IvaUpdateFrameDelay = hiddenNode.HasValue("IvaUpdateFrameDelay")
          ? int.Parse(hiddenNode.GetValue("IvaUpdateFrameDelay"))
          : IvaUpdateFrameDelay;
                // Okay, set the Settings loaded flag
                Loaded = true;
                MemStoreTempSettings();
            }

            // Enable/Disable crewed parts CrewTransferDialog
            SetStockCrewTransferState();

            // Force Styles to refresh/load.
            SMStyle.WindowStyle = null;

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