Ejemplo n.º 1
0
    public void Load()
    {
        PlayerData data = PersistenceFile.Load <PlayerData>(m_FileName);

        transform.position = new Vector3(data.position[0], data.position[1], data.position[2]);
        m_Lives            = data.lives;
    }
Ejemplo n.º 2
0
    public void Save()
    {
        PlayerData data = new PlayerData();

        data.position[0] = transform.position.x;
        data.position[1] = transform.position.y;
        data.position[2] = transform.position.z;
        data.lives       = m_Lives;

        PersistenceFile.Save <PlayerData>(data, m_FileName);
    }
Ejemplo n.º 3
0
        private static void LoadState()
        {
            PersistenceFile.Deserialize(
                r =>
            {
                r.GetVersion();

                _Enabled      = r.ReadBool();
                _CommandDebug = r.ReadBool();
                _UberScript   = r.ReadBool();
            });
        }
Ejemplo n.º 4
0
        private static void SaveState()
        {
            PersistenceFile.Serialize(
                w =>
            {
                w.SetVersion(0);

                w.Write(_Enabled);
                w.Write(_CommandDebug);
                w.Write(_UberScript);
            });
        }
        // Open and close a launchsite
        public static void setSiteOpenCloseState(string sSiteName, string sState)
        {
            List <LaunchSite> sites = LaunchSiteManager.getLaunchSites();

            foreach (LaunchSite site in sites)
            {
                if (site.name == sSiteName)
                {
                    site.setOpenClose(sState);
                    PersistenceFile <LaunchSite> .SaveList(sites, "LAUNCHSITES", "KK");

                    return;
                }
            }
        }
Ejemplo n.º 6
0
        // Lock a launchsite so it cannot be opened or closed or launched from
        public static void setSiteLocked(string sSiteName)
        {
            List <LaunchSite> sites = LaunchSiteManager.getLaunchSites();

            foreach (LaunchSite site in sites)
            {
                if (site.name == sSiteName)
                {
                    site.openclosestate = site.openclosestate + "Locked";
                    PersistenceFile <LaunchSite> .SaveList(sites, "LAUNCHSITES", "KK");

                    return;
                }
            }
        }
        public async Task MediumTestFileParsesCorrectly()
        {
            // arrange
            TestHelper th    = new TestHelper();
            int        count = 0;
            bool       done  = false;

            // act
            PersistenceFile pf = new PersistenceFile(th.GetResourceTextFile(th.MEDIUMTESTFILE));

            pf.ElementSource.Subscribe(x => count++, () => done = true);
            await pf.Read();

            // verify
            Assert.AreEqual(4, count);
            Assert.IsTrue(done);
            Assert.IsTrue(pf.IsStop);
        }
Ejemplo n.º 8
0
        void drawMapManagerWindow(int windowID)
        {
            ButtonRed = new GUIStyle(GUI.skin.button);
            ButtonRed.normal.textColor  = Color.red;
            ButtonRed.active.textColor  = Color.red;
            ButtonRed.focused.textColor = Color.red;
            ButtonRed.hover.textColor   = Color.red;

            ButtonKK = new GUIStyle(GUI.skin.button);
            ButtonKK.padding.left      = 0;
            ButtonKK.padding.right     = 0;
            ButtonKK.normal.background = tNormalButton;
            ButtonKK.hover.background  = tHoverButton;

            Yellowtext = new GUIStyle(GUI.skin.box);
            Yellowtext.normal.textColor  = Color.yellow;
            Yellowtext.normal.background = null;

            TextAreaNoBorder = new GUIStyle(GUI.skin.textArea);
            TextAreaNoBorder.normal.background = null;

            BoxNoBorder = new GUIStyle(GUI.skin.box);
            BoxNoBorder.normal.background = null;

            if (!loadedPersistence && MiscUtils.isCareerGame())
            {
                PersistenceFile <LaunchSite> .LoadList(LaunchSiteManager.AllLaunchSites, "LAUNCHSITES", "KK");

                foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics())
                {
                    if ((string)obj.getSetting("FacilityType") == "TrackingStation")
                    {
                        PersistenceUtils.loadStaticPersistence(obj);
                    }
                }

                loadedPersistence = true;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Box(" ", BoxNoBorder, GUILayout.Height(34));

            GUI.enabled = (MiscUtils.isCareerGame());
            if (!MiscUtils.isCareerGame())
            {
                GUILayout.Button(tOpenBasesOff, GUILayout.Width(32), GUILayout.Height(32));
                GUILayout.Button(tClosedBasesOff, GUILayout.Width(32), GUILayout.Height(32));
                GUILayout.Box(" ", BoxNoBorder, GUILayout.Height(34));
                GUILayout.Button(tTrackingOff, GUILayout.Width(32), GUILayout.Height(32));
            }
            else
            {
                if (KerbalKonstructs.instance.mapShowOpen)
                {
                    if (GUILayout.Button(new GUIContent(tOpenBasesOn, "Opened"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowOpen = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(new GUIContent(tOpenBasesOff, "Opened"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowOpen = true;
                    }
                }

                if (!KerbalKonstructs.instance.disableDisplayClosed)
                {
                    if (KerbalKonstructs.instance.mapShowClosed)
                    {
                        if (GUILayout.Button(new GUIContent(tClosedBasesOn, "Closed"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                        {
                            KerbalKonstructs.instance.mapShowClosed = false;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button(new GUIContent(tClosedBasesOff, "Closed"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                        {
                            KerbalKonstructs.instance.mapShowClosed = true;
                        }
                    }
                }

                GUILayout.Box(" ", BoxNoBorder, GUILayout.Height(34));
                if (KerbalKonstructs.instance.mapShowOpenT)
                {
                    if (GUILayout.Button(new GUIContent(tTrackingOn, "Tracking Stations"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowOpenT = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(new GUIContent(tTrackingOff, "Tracking Stations"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowOpenT = true;
                    }
                }
            }
            GUI.enabled = true;

            GUILayout.Box(" ", BoxNoBorder, GUILayout.Height(34));

            if (KerbalKonstructs.instance.mapShowRocketbases)
            {
                if (GUILayout.Button(new GUIContent(tLaunchpadsOn, "Rocketpads"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowRocketbases = false;
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent(tLaunchpadsOff, "Rocketpads"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowRocketbases = true;
                }
            }

            if (KerbalKonstructs.instance.mapShowHelipads)
            {
                if (GUILayout.Button(new GUIContent(tHelipadsOn, "Helipads"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowHelipads = false;
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent(tHelipadsOff, "Helipads"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowHelipads = true;
                }
            }

            if (KerbalKonstructs.instance.mapShowRunways)
            {
                if (GUILayout.Button(new GUIContent(tRunwaysOn, "Runways"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowRunways = false;
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent(tRunwaysOff, "Runways"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowRunways = true;
                }
            }

            if (KerbalKonstructs.instance.mapShowOther)
            {
                if (GUILayout.Button(new GUIContent(tOtherOn, "Other"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowOther = false;
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent(tOtherOff, "Other"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowOther = true;
                }
            }

            GUILayout.Box(" ", BoxNoBorder, GUILayout.Height(34));

            if (GUILayout.Button("X", ButtonRed, GUILayout.Height(20), GUILayout.Width(20)))
            {
                loadedPersistence = false;
                KerbalKonstructs.instance.showMapIconManager = false;
            }

            GUILayout.EndHorizontal();

            if (GUI.tooltip != "")
            {
                var labelSize = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(GUI.tooltip));
                GUI.Box(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y + 20, labelSize.x + 2, labelSize.y + 2), GUI.tooltip, BoxNoBorder);
            }

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
Ejemplo n.º 9
0
        public static void getClosestSpaceCenter(Vector3 position, out SpaceCenter ClosestCenter, out float ClosestDistance,
                                                 out float RecoveryFactor, out float RecoveryRange, out string BaseName)
        {
            CustomSpaceCenter closest = null;

            float smallestDist = Vector3.Distance(KSC.gameObject.transform.position, position);
            // Debug.Log("KK: Distance to KSC is " + smallestDist);

            bool isCareer = false;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                if (!KerbalKonstructs.instance.disableCareerStrategyLayer)
                {
                    isCareer = true;
                    PersistenceFile <LaunchSite> .LoadList(LaunchSiteManager.AllLaunchSites, "LAUNCHSITES", "KK");
                }
            }

            string sOpenCloseState  = "Closed";
            string sBaseName        = "";
            float  fMyBaseRecovFact = 0f;
            float  fMyBaseRecovRang = 0f;

            foreach (CustomSpaceCenter csc in spaceCenters)
            {
                if (isCareer)
                {
                    string OpenCloseState;
                    float  OpenCost;
                    // ASH Get openclosestate of launchsite with same name as space centre
                    LaunchSiteManager.getSiteOpenCloseState(csc.SpaceCenterName, out OpenCloseState, out OpenCost);
                    sOpenCloseState = OpenCloseState;
                }

                StaticObject myBase = csc.getStaticObject();
                if ((float)myBase.getSetting("RecoveryFactor") == 0)
                {
                    continue;
                }

                float dist = Vector3.Distance(position, csc.getStaticObject().gameObject.transform.position);

                if (dist < smallestDist)
                {
                    bool bBaseIsOpen = true;
                    if (sOpenCloseState == "Closed" || sOpenCloseState == "ClosedLocked" || sOpenCloseState == "OpenLocked")
                    {
                        bBaseIsOpen = false;
                    }

                    if (isCareer && !bBaseIsOpen)
                    {
                    }
                    else
                    {
                        closest          = csc;
                        smallestDist     = dist;
                        fMyBaseRecovFact = (float)myBase.getSetting("RecoveryFactor");
                        fMyBaseRecovRang = (float)myBase.getSetting("RecoveryRange");
                        sBaseName        = (string)myBase.getSetting("LaunchSiteName");
                        // Debug.Log("KK: closest updated to " + closest.SpaceCenterName + ", distance " + smallestDist);
                    }
                }
            }

            SpaceCenter sc;

            if (closest == null)
            {
                sc = null;
            }
            else
            {
                // Debug.Log("KK: closest is " + closest.SpaceCenterName);
                sc = closest.getSpaceCenter();
            }

            // Debug.Log("KK: smallestDist is " + smallestDist);
            // Debug.Log("KK: returning closest space centre: " + sc.name);


            if (smallestDist < 1)
            {
                smallestDist = 0;
            }
            if (sc == null)
            {
                sc = KSC;
                fMyBaseRecovFact = 100;
                sBaseName        = "KSC";
            }

            ClosestCenter   = sc;
            ClosestDistance = smallestDist;
            RecoveryFactor  = fMyBaseRecovFact;
            RecoveryRange   = fMyBaseRecovRang;
            BaseName        = sBaseName;
        }
        void drawMapManagerWindow(int windowID)
        {
            if (!loadedPersistence && MiscUtils.isCareerGame())
            {
                PersistenceFile <LaunchSite> .LoadList(LaunchSiteManager.AllLaunchSites, "LAUNCHSITES", "KK");

                foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics())
                {
                    if ((string)obj.getSetting("FacilityType") == "TrackingStation")
                    {
                        PersistenceUtils.loadStaticPersistence(obj);
                    }
                }

                loadedPersistence = true;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Box(" ", UIMain.BoxNoBorder, GUILayout.Height(34));

            GUI.enabled = (MiscUtils.isCareerGame());
            if (!MiscUtils.isCareerGame())
            {
                GUILayout.Button(UIMain.tOpenBasesOff, GUILayout.Width(32), GUILayout.Height(32));
                GUILayout.Button(UIMain.tClosedBasesOff, GUILayout.Width(32), GUILayout.Height(32));
                GUILayout.Box(" ", UIMain.BoxNoBorder, GUILayout.Height(34));
                GUILayout.Button(UIMain.tTrackingOff, GUILayout.Width(32), GUILayout.Height(32));
            }
            else
            {
                if (KerbalKonstructs.instance.mapShowOpen)
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tOpenBasesOn, "Opened"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowOpen = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tOpenBasesOff, "Opened"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowOpen = true;
                    }
                }

                if (!KerbalKonstructs.instance.disableDisplayClosed)
                {
                    if (KerbalKonstructs.instance.mapShowClosed)
                    {
                        if (GUILayout.Button(new GUIContent(UIMain.tClosedBasesOn, "Closed"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                        {
                            KerbalKonstructs.instance.mapShowClosed = false;
                        }
                    }
                    else
                    {
                        if (GUILayout.Button(new GUIContent(UIMain.tClosedBasesOff, "Closed"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                        {
                            KerbalKonstructs.instance.mapShowClosed = true;
                        }
                    }
                }

                GUILayout.Box(" ", UIMain.BoxNoBorder, GUILayout.Height(34));
                if (KerbalKonstructs.instance.mapShowOpenT)
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tTrackingOn, "Tracking Stations"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowOpenT = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tTrackingOff, "Tracking Stations"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowOpenT = true;
                    }
                }
            }
            GUI.enabled = true;

            GUILayout.Box(" ", UIMain.BoxNoBorder, GUILayout.Height(34));

            if (KerbalKonstructs.instance.mapShowRocketbases)
            {
                if (GUILayout.Button(new GUIContent(UIMain.tLaunchpadsOn, "Rocketpads"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowRocketbases = false;
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent(UIMain.tLaunchpadsOff, "Rocketpads"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowRocketbases = true;
                }
            }

            if (KerbalKonstructs.instance.mapShowHelipads)
            {
                if (GUILayout.Button(new GUIContent(UIMain.tHelipadsOn, "Helipads"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowHelipads = false;
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent(UIMain.tHelipadsOff, "Helipads"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowHelipads = true;
                }
            }

            if (KerbalKonstructs.instance.mapShowRunways)
            {
                if (GUILayout.Button(new GUIContent(UIMain.tRunwaysOn, "Runways"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowRunways = false;
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent(UIMain.tRunwaysOff, "Runways"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowRunways = true;
                }
            }

            if (KerbalKonstructs.instance.mapShowOther)
            {
                if (GUILayout.Button(new GUIContent(UIMain.tOtherOn, "Other"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowOther = false;
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent(UIMain.tOtherOff, "Other"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapShowOther = true;
                }
            }

            GUILayout.Box(" ", UIMain.BoxNoBorder, GUILayout.Height(34));

            GUI.enabled = (MiscUtils.isCareerGame());
            if (!MiscUtils.isCareerGame())
            {
                GUILayout.Button(UIMain.tDownlinksOff, GUILayout.Width(32), GUILayout.Height(32));
                GUILayout.Button(UIMain.tUplinksOff, GUILayout.Width(32), GUILayout.Height(32));
                GUILayout.Button(UIMain.tRadarOff, GUILayout.Width(32), GUILayout.Height(32));
                GUILayout.Button(UIMain.tGroundCommsOff, GUILayout.Width(32), GUILayout.Height(32));
            }
            else
            {
                if (KerbalKonstructs.instance.mapShowDownlinks)
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tDownlinksOn, "Downlinks"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowDownlinks = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tDownlinksOff, "Downlinks"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowDownlinks = true;
                    }
                }

                if (KerbalKonstructs.instance.mapShowUplinks)
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tUplinksOn, "Uplinks"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowUplinks = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tUplinksOff, "Uplinks"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowUplinks = true;
                    }
                }

                if (KerbalKonstructs.instance.mapShowRadar)
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tRadarOn, "Radar"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowRadar = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tRadarOff, "Radar"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowRadar = true;
                    }
                }

                if (KerbalKonstructs.instance.mapShowGroundComms)
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tGroundCommsOn, "Ground Comms"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowGroundComms = false;
                    }
                }
                else
                {
                    if (GUILayout.Button(new GUIContent(UIMain.tGroundCommsOff, "Ground Comms"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        KerbalKonstructs.instance.mapShowGroundComms = true;
                    }
                }
            }
            GUI.enabled = true;

            GUILayout.Box(" ", UIMain.BoxNoBorder, GUILayout.Height(34));

            if (KerbalKonstructs.instance.mapHideIconsBehindBody)
            {
                if (GUILayout.Button(new GUIContent(UIMain.tHideOn, "Occlude"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapHideIconsBehindBody = false;
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent(UIMain.tHideOff, "Occlude"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    KerbalKonstructs.instance.mapHideIconsBehindBody = true;
                }
            }

            GUILayout.Box(" ", UIMain.BoxNoBorder, GUILayout.Height(34));

            if (GUILayout.Button("X", UIMain.ButtonRed, GUILayout.Height(20), GUILayout.Width(20)))
            {
                loadedPersistence = false;
                WindowManager.instance.CloseWindow(KerbalKonstructs.instance.GUI_MapIconManager.drawManager);
            }

            GUILayout.EndHorizontal();

            if (GUI.tooltip != "")
            {
                var labelSize = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(GUI.tooltip));
                GUI.Box(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y + 20, labelSize.x + 5, labelSize.y + 6), GUI.tooltip, UIMain.KKToolTip);
            }

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
        public void drawBaseManagerWindow(int windowID)
        {
            DeadButton = new GUIStyle(GUI.skin.button);
            DeadButton.normal.background  = null;
            DeadButton.hover.background   = null;
            DeadButton.active.background  = null;
            DeadButton.focused.background = null;
            DeadButton.normal.textColor   = Color.white;
            DeadButton.hover.textColor    = Color.white;
            DeadButton.active.textColor   = Color.white;
            DeadButton.focused.textColor  = Color.white;
            DeadButton.fontSize           = 14;
            DeadButton.fontStyle          = FontStyle.Bold;

            DeadButtonRed = new GUIStyle(GUI.skin.button);
            DeadButtonRed.normal.background  = null;
            DeadButtonRed.hover.background   = null;
            DeadButtonRed.active.background  = null;
            DeadButtonRed.focused.background = null;
            DeadButtonRed.normal.textColor   = Color.red;
            DeadButtonRed.hover.textColor    = Color.yellow;
            DeadButtonRed.active.textColor   = Color.red;
            DeadButtonRed.focused.textColor  = Color.red;
            DeadButtonRed.fontSize           = 12;
            DeadButtonRed.fontStyle          = FontStyle.Bold;

            Yellowtext = new GUIStyle(GUI.skin.box);
            Yellowtext.normal.textColor  = Color.yellow;
            Yellowtext.normal.background = null;

            TextAreaNoBorder = new GUIStyle(GUI.skin.textArea);
            TextAreaNoBorder.normal.background = null;
            TextAreaNoBorder.normal.textColor  = Color.white;
            TextAreaNoBorder.fontSize          = 12;
            TextAreaNoBorder.padding.left      = 1;
            TextAreaNoBorder.padding.right     = 1;
            TextAreaNoBorder.padding.top       = 4;

            BoxNoBorder = new GUIStyle(GUI.skin.box);
            BoxNoBorder.normal.background = null;
            BoxNoBorder.normal.textColor  = Color.white;

            LabelWhite = new GUIStyle(GUI.skin.label);
            LabelWhite.normal.background = null;
            LabelWhite.normal.textColor  = Color.white;
            LabelWhite.fontSize          = 12;
            LabelWhite.padding.left      = 1;
            LabelWhite.padding.right     = 1;
            LabelWhite.padding.top       = 4;

            LabelInfo = new GUIStyle(GUI.skin.label);
            LabelInfo.normal.background = null;
            LabelInfo.normal.textColor  = Color.white;
            LabelInfo.fontSize          = 13;
            LabelInfo.fontStyle         = FontStyle.Bold;
            LabelInfo.padding.left      = 3;
            LabelInfo.padding.top       = 0;
            LabelInfo.padding.bottom    = 0;

            KKWindowTitle = new GUIStyle(GUI.skin.box);
            KKWindowTitle.normal.background = null;
            KKWindowTitle.normal.textColor  = Color.white;
            KKWindowTitle.fontSize          = 14;
            KKWindowTitle.fontStyle         = FontStyle.Bold;

            SmallButton = new GUIStyle(GUI.skin.button);
            SmallButton.normal.textColor  = Color.red;
            SmallButton.hover.textColor   = Color.white;
            SmallButton.padding.top       = 1;
            SmallButton.padding.left      = 1;
            SmallButton.padding.right     = 1;
            SmallButton.padding.bottom    = 4;
            SmallButton.normal.background = null;
            SmallButton.hover.background  = null;
            SmallButton.fontSize          = 12;

            if (!loadedPersistence && MiscUtils.isCareerGame())
            {
                PersistenceFile <LaunchSite> .LoadList(LaunchSiteManager.AllLaunchSites, "LAUNCHSITES", "KK");

                loadedPersistence = true;
            }

            string sButtonName = "";

            sButtonName = selectedSite.name;
            if (selectedSite.name == "Runway")
            {
                sButtonName = "KSC Runway";
            }
            if (selectedSite.name == "LaunchPad")
            {
                sButtonName = "KSC LaunchPad";
            }

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Base Manager", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (HighLogic.LoadedScene != GameScenes.EDITOR)
                {
                    if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21)))
                    {
                        InputLockManager.RemoveControlLock("KKEditorLock");
                        selectedSite      = null;
                        loadedPersistence = false;
                        KerbalKonstructs.instance.showBaseManager = false;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            if (selectedSite.name == "Runway")
            {
                GUILayout.Box("KSC Runway", Yellowtext);
            }
            else
            if (selectedSite.name == "LaunchPad")
            {
                GUILayout.Box("KSC LaunchPad", Yellowtext);
            }
            else
            {
                GUILayout.Box("" + selectedSite.name, Yellowtext);
            }

            if (!foldedIn)
            {
                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(2);
                    GUILayout.Box(tVerticalSep, BoxNoBorder, GUILayout.Width(4), GUILayout.Height(135));
                    GUILayout.FlexibleSpace();
                    GUILayout.Box(selectedSite.logo, BoxNoBorder, GUILayout.Height(135), GUILayout.Width(135));
                    GUILayout.FlexibleSpace();
                    GUILayout.Box(tVerticalSep, BoxNoBorder, GUILayout.Width(4), GUILayout.Height(135));
                    GUILayout.Space(2);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(3);

                descriptionScrollPosition = GUILayout.BeginScrollView(descriptionScrollPosition, GUILayout.Height(120));
                {
                    GUI.enabled = false;
                    GUILayout.Label(selectedSite.description, LabelWhite);
                    GUI.enabled = true;
                }
                GUILayout.EndScrollView();
            }

            GUILayout.Space(1);

            isFavourite = (selectedSite.favouritesite == "Yes");

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = (!displayStats);
                if (GUILayout.Button("Stats", GUILayout.Height(23)))
                {
                    displayLog   = false;
                    displayStats = true;
                }
                GUI.enabled = true;

                GUI.enabled = (!displayLog);
                if (GUILayout.Button("Log", GUILayout.Height(23)))
                {
                    displayLog   = true;
                    displayStats = false;
                }
                GUI.enabled = true;

                if (isFavourite)
                {
                    tFaveTemp = tIsFave;
                }
                else
                {
                    tFaveTemp = tMakeFavourite;
                }

                if (GUILayout.Button(tFaveTemp, GUILayout.Height(23), GUILayout.Width(23)))
                {
                    if (isFavourite)
                    {
                        selectedSite.favouritesite = "No";
                    }
                    else
                    {
                        selectedSite.favouritesite = "Yes";
                    }

                    List <LaunchSite> sites = LaunchSiteManager.getLaunchSites();
                    PersistenceFile <LaunchSite> .SaveList(sites, "LAUNCHSITES", "KK");
                }

                if (foldedIn)
                {
                    tFolded = tFoldOut;
                }
                if (!foldedIn)
                {
                    tFolded = tFoldIn;
                }

                if (GUILayout.Button(tFolded, GUILayout.Height(23), GUILayout.Width(23)))
                {
                    if (foldedIn)
                    {
                        foldedIn = false;
                    }
                    else
                    {
                        foldedIn = true;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);

            if (displayStats)
            {
                GUILayout.Label("Altitude: " + selectedSite.refalt.ToString("#0.0") + " m", LabelInfo);
                GUILayout.Label("Longitude: " + selectedSite.reflon.ToString("#0.000"), LabelInfo);
                GUILayout.Label("Latitude: " + selectedSite.reflat.ToString("#0.000"), LabelInfo);
                GUILayout.Space(3);
                GUILayout.Label("Length: " + selectedSite.sitelength.ToString("#0" + " m"), LabelInfo);
                GUILayout.Label("Width: " + selectedSite.sitewidth.ToString("#0" + " m"), LabelInfo);

                GUILayout.FlexibleSpace();
            }

            iFundsOpen  = selectedSite.opencost;
            iFundsClose = selectedSite.closevalue;

            bool isAlwaysOpen   = false;
            bool cannotBeClosed = false;

            if (iFundsOpen == 0)
            {
                isAlwaysOpen = true;
            }

            if (iFundsClose == 0)
            {
                cannotBeClosed = true;
            }

            if (MiscUtils.isCareerGame())
            {
                if (displayStats)
                {
                    if (!KerbalKonstructs.instance.disableRemoteRecovery)
                    {
                        if (selectedSite.recoveryfactor > 0)
                        {
                            GUILayout.Label("Recovery Factor: " + selectedSite.recoveryfactor.ToString() + "%", LabelInfo);
                            if (selectedSite.name != "Runway" && selectedSite.name != "LaunchPad")
                            {
                                if (selectedSite.recoveryrange > 0)
                                {
                                    rangekm = selectedSite.recoveryrange / 1000;
                                }
                                else
                                {
                                    rangekm = 0;
                                }

                                GUILayout.Label("Effective Range: " + rangekm.ToString() + " km", LabelInfo);
                            }
                            else
                            {
                                GUILayout.Label("Effective Range: Unlimited", LabelInfo);
                            }
                        }
                        else
                        {
                            GUILayout.Label("No Recovery Capability", LabelInfo);
                        }
                    }

                    GUILayout.FlexibleSpace();
                    GUILayout.Label("Launch Refund: " + selectedSite.launchrefund.ToString() + "%", LabelInfo);
                }

                if (displayLog)
                {
                    logScrollPosition = GUILayout.BeginScrollView(logScrollPosition, GUILayout.Height(120));
                    {
                        GUILayout.Box("Feature is WIP");
                        GUILayout.Box("Log Entry");
                        GUILayout.Box("Log Entry");
                        GUILayout.Box("Log Entry");
                    }
                    GUILayout.EndScrollView();

                    GUILayout.FlexibleSpace();
                }

                isOpen      = (selectedSite.openclosestate == "Open");
                GUI.enabled = !isOpen;
                List <LaunchSite> sites = LaunchSiteManager.getLaunchSites();
                if (!isAlwaysOpen)
                {
                    if (!KerbalKonstructs.instance.disableRemoteBaseOpening)
                    {
                        if (GUILayout.Button("Open Base for \n" + iFundsOpen + " funds", GUILayout.Height(40)))
                        {
                            double currentfunds = Funding.Instance.Funds;

                            if (iFundsOpen > currentfunds)
                            {
                                MiscUtils.HUDMessage("Insufficient funds to open this base!", 10,
                                                     3);
                            }
                            else
                            {
                                selectedSite.openclosestate = "Open";
                                Funding.Instance.AddFunds(-iFundsOpen, TransactionReasons.Cheating);
                                PersistenceFile <LaunchSite> .SaveList(sites, "LAUNCHSITES", "KK");
                            }
                        }
                    }
                }
                GUI.enabled = true;

                GUI.enabled = isOpen;
                if (!cannotBeClosed)
                {
                    if (GUILayout.Button("Close Base for \n" + iFundsClose + " funds", GUILayout.Height(40)))
                    {
                        Funding.Instance.AddFunds(iFundsClose, TransactionReasons.Cheating);
                        selectedSite.openclosestate = "Closed";

                        PersistenceFile <LaunchSite> .SaveList(sites, "LAUNCHSITES", "KK");
                    }
                }
                GUI.enabled = true;

                GUILayout.FlexibleSpace();

                if (HighLogic.LoadedScene == GameScenes.EDITOR)
                {
                    GUILayout.BeginHorizontal();
                    {
                        if (selectedSite.name == EditorLogic.fetch.launchSiteName)
                        {
                            tStatusLaunchsite = tSetLaunchsite;
                        }
                        else
                        if (isOpen || isAlwaysOpen)
                        {
                            tStatusLaunchsite = tOpenedLaunchsite;
                        }
                        else
                        {
                            tStatusLaunchsite = tClosedLaunchsite;
                        }

                        GUILayout.Label(tStatusLaunchsite, GUILayout.Height(32), GUILayout.Width(32));

                        GUI.enabled = (isOpen || isAlwaysOpen) && !(selectedSite.name == EditorLogic.fetch.launchSiteName);
                        if (GUILayout.Button("Set as \nLaunchsite", GUILayout.Height(40)))
                        {
                            LaunchSiteManager.setLaunchSite(selectedSite);
                            string smessage = sButtonName + " has been set as the launchsite";
                            MiscUtils.HUDMessage(smessage, 10, 0);
                        }
                        GUI.enabled = true;
                    }
                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.Space(3);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(1);

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
 public void SetUp()
 {
     path            = @".\TestFile.txt";
     persistenceFile = new PersistenceFile(path);
 }