Exemplo n.º 1
0
        internal static void ToggleButtonOn()
        {
            if (HighLogic.LoadedScene == GameScenes.EDITOR)
            {
                LaunchSiteSelectorGUI.instance.Open();
                return;
            }
            if ((HighLogic.LoadedScene == GameScenes.FLIGHT) && (!MapView.MapIsEnabled))
            {
                BaseBossFlight.instance.Open();
                return;
            }

            if ((HighLogic.LoadedScene == GameScenes.TRACKSTATION) || (MapView.MapIsEnabled))
            {
                Modules.MapIconManager.instance.Open();
                return;
            }

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                //KSCManager.instance.Open();
                InputLockManager.SetControlLock("KK_KSC");
                KSCManager.CreatePopUp();
                return;
            }
        }
Exemplo n.º 2
0
        public static void TrackingInterface(StaticObject soStation)
        {
            fRange      = (float)soStation.getSetting("TrackingShort");
            sTargetType = (string)soStation.getSetting("TargetType");
            sTarget     = (string)soStation.getSetting("TargetID");
            fMaxAngle   = (float)soStation.getSetting("TrackingAngle");
            sGroup      = (string)soStation.getSetting("Group");
            bCraftLock  = false;

            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;

            BoxInfo = new GUIStyle(GUI.skin.box);
            BoxInfo.normal.textColor  = Color.cyan;
            BoxInfo.fontSize          = 13;
            BoxInfo.padding.top       = 2;
            BoxInfo.padding.bottom    = 1;
            BoxInfo.padding.left      = 5;
            BoxInfo.padding.right     = 5;
            BoxInfo.normal.background = null;

            GUILayout.Space(2);

            if (fRange < 1f)
            {
                bNotInit = true;
            }
            if (fMaxAngle < 1f)
            {
                bNotInit = true;
            }

            if (bNotInit)
            {
                sFacLvl = KSCManager.DetermineFacilityLevel("TrackingStation");
                if (sGroup == "KSCUpgrades")
                {
                    fTSRange = 250000f;
                    fTSAngle = 75f;
                    if (sFacLvl == "Lvl 2/3")
                    {
                        fTSRange = 10000000f;
                        fTSAngle = 85f;
                    }
                    if (sFacLvl == "Lvl 3/3")
                    {
                        fTSRange = 25000000f;
                        fTSAngle = 90f;
                    }

                    fRange    = fTSRange;
                    fMaxAngle = fTSAngle;

                    soStation.setSetting("TrackingShort", fTSRange);
                    soStation.setSetting("TrackingAngle", fTSAngle);
                    soStation.setSetting("OpenCloseState", "Open");
                    PersistenceUtils.saveStaticPersistence(soStation);
                    bNotInit = false;
                }
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(5);
                GUILayout.Label("Short Range: " + (fRange / 1000f).ToString("#0") + "km", LabelInfo, GUILayout.Height(25));
                GUILayout.FlexibleSpace();
                GUILayout.Label("Max Angle: " + fMaxAngle.ToString("#0") + "°", LabelInfo, GUILayout.Height(25));

                /* if (KerbalKonstructs.instance.DevMode)
                 * {
                 *      GUILayout.FlexibleSpace();
                 *      if (GUILayout.Button("Upgrade", GUILayout.Height(20), GUILayout.Width(70)))
                 *      {
                 *              MiscUtils.HUDMessage("Unable to upgrade this facility. Insufficient materials.", 10, 0);
                 *      }
                 * } */
            }
            GUILayout.EndHorizontal();

            /* if (KerbalKonstructs.instance.DevMode)
             * {
             *      GUILayout.Space(1);
             *      GUILayout.Box("To upgrade a kerbonaut Scientist and Engineer must be at the station. Then processed ore can be ordered for delivery to the station.", BoxInfo);
             * } */

            GUILayout.Space(2);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(5);
                GUILayout.Label("Target Type: " + sTargetType, LabelInfo, GUILayout.Height(25));
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Change", GUILayout.Height(20), GUILayout.Width(70)))
                {
                    bChangeTargetType = true;
                    sTarget           = "None";

                    if (sTargetType == "None")
                    {
                        sTargetType = "Craft";
                    }
                    else
                    if (sTargetType == "Craft")
                    {
                        sTargetType = "Celestial Body";
                    }
                    else
                    if (sTargetType == "Celestial Body")
                    {
                        sTargetType = "Asteroid";
                    }
                    else
                    if (sTargetType == "Asteroid")
                    {
                        sTargetType = "Station's Discretion";
                    }
                    else
                    if (sTargetType == "Station's Discretion")
                    {
                        sTargetType = "None";
                    }

                    FacilityManager.changeTargetType(sTargetType);

                    soStation.setSetting("TargetID", sTarget);
                    soStation.setSetting("TargetType", sTargetType);
                    PersistenceUtils.saveStaticPersistence(soStation);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(5);

                int iU = sTarget.IndexOf("(");
                if (iU < 2)
                {
                    iU = sTarget.Length + 1;
                }

                sDisplayTarget = sTarget.Substring(0, iU - 1);

                GUILayout.Label("Tracking: " + sDisplayTarget + " ", LabelInfo, GUILayout.Height(25));
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Change", GUILayout.Height(20), GUILayout.Width(70)))
                {
                    if (sTargetType == "None" || sTargetType == "Station's Discretion")
                    {
                        MiscUtils.HUDMessage("Please select a target type first.", 10, 3);
                    }
                    else
                    {
                        sSelectedTrackingTarget = "None";
                        FacilityManager.changeTarget(true);
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(5);

                GUILayout.Label("Status: ", LabelInfo, GUILayout.Height(25));
                string sStationStatus = "Offline";
                sUplink = "None";

                if (sTarget != "None")
                {
                    sStationStatus = "Error. Please reset";

                    if (sTargetType == "Craft")
                    {
                        Vessel vTargetVessel = GetTargetVessel(sTarget);

                        if (vTargetVessel == null)
                        {
                            sStationStatus = "Cannot find craft";
                        }
                        else
                        {
                            if (vTargetVessel.state == Vessel.State.DEAD)
                            {
                                sStationStatus = "Cannot find craft";
                            }
                            else
                            {
                                StationLOS = StationHasLOS(soStation, vTargetVessel);

                                if (StationLOS <= fMaxAngle)
                                {
                                    bCraftLock    = true;
                                    sDisplayRange = "0m";
                                    float fRangeToTarget = GetRangeToCraft(soStation, vTargetVessel);

                                    if (fRangeToTarget > 100000f)
                                    {
                                        sDisplayRange = (fRangeToTarget / 1000f).ToString("#0") + " km";
                                    }
                                    else
                                    {
                                        sDisplayRange = fRangeToTarget.ToString("#0") + "m";
                                    }

                                    if (fRangeToTarget > fRange)
                                    {
                                        int iUplink = GetUplinkQuality(fRange, fRangeToTarget);
                                        sUplink        = iUplink.ToString() + "%";
                                        sStationStatus = "Lock " + StationLOS.ToString("#0") + "° " + sDisplayRange;
                                    }
                                    else
                                    {
                                        sStationStatus = "Lock " + StationLOS.ToString("#0") + "° " + sDisplayRange;
                                        sUplink        = "100%";
                                    }
                                }
                                else
                                {
                                    sStationStatus = "No lock";
                                    bCraftLock     = false;
                                }
                            }
                        }
                    }

                    if (sTargetType == "Asteroid")
                    {
                        Vessel vTargetVessel = GetTargetVessel(sTarget);

                        bool bAsteroidDetected = true;
                        if (vTargetVessel == null)
                        {
                            bAsteroidDetected = false;
                        }
                        else
                        {
                            if (vTargetVessel.state == Vessel.State.DEAD)
                            {
                                bAsteroidDetected = false;
                            }
                        }

                        if (!bAsteroidDetected)
                        {
                            sStationStatus = "Cannot find asteroid";
                        }
                        else
                        {
                            StationLOS = StationHasLOS(soStation, vTargetVessel);

                            vTargetVessel.DiscoveryInfo.SetLastObservedTime(Planetarium.GetUniversalTime());
                            vTargetVessel.DiscoveryInfo.SetLevel((DiscoveryLevels)29);

                            if (StationLOS <= fMaxAngle)
                            {
                                sDisplayRange = "0m";
                                float fRangeToTarget = GetRangeToCraft(soStation, vTargetVessel);

                                if (fRangeToTarget > 100000f)
                                {
                                    sDisplayRange = (fRangeToTarget / 1000f).ToString("#0") + " km";
                                }
                                else
                                {
                                    sDisplayRange = fRangeToTarget.ToString("#0") + "m";
                                }

                                if (fRangeToTarget > fRange)
                                {
                                    sStationStatus = "Lock " + StationLOS.ToString("#0") + "° " + sDisplayRange;
                                }
                                else
                                {
                                    sStationStatus = "Lock " + StationLOS.ToString("#0") + "° " + sDisplayRange;
                                }
                            }
                            else
                            {
                                sStationStatus = "No lock";
                            }
                        }
                    }

                    if (sTargetType == "Celestial Body")
                    {
                        CelestialBody cTargetPlanet = GetTargetPlanet(sTarget);

                        if (cTargetPlanet == null)
                        {
                            sStationStatus = "Cannot find body";
                        }
                        else
                        {
                            StationLOS = StationHasLOStoPlanet(soStation, cTargetPlanet);

                            if (StationLOS <= fMaxAngle)
                            {
                                sDisplayRange = "0m";
                                float fRangeToTarget = GetRangeToPlanet(soStation, cTargetPlanet);

                                sDisplayRange  = (fRangeToTarget / 1000f).ToString("#0") + "km";
                                sStationStatus = "Sighted " + StationLOS.ToString("#0") + "° " + sDisplayRange;
                            }
                            else
                            {
                                sStationStatus = "No sighting";
                            }
                        }
                    }
                }

                if (sTargetType == "Station's Discretion")
                {
                    sStationStatus = " Busy ";
                }

                GUILayout.Label(sStationStatus, LabelInfo, GUILayout.Height(30));
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Stop", GUILayout.Height(20), GUILayout.Width(70)))
                {
                    sTargetType = "None";
                    sTarget     = "None";
                    soStation.setSetting("TargetType", sTargetType);
                    soStation.setSetting("TargetID", sTarget);
                    PersistenceUtils.saveStaticPersistence(soStation);
                }
            }
            GUILayout.EndHorizontal();
            if (sTargetType == "Craft" && bCraftLock)
            {
                GUILayout.Label("Uplink Quality:" + sUplink, LabelInfo);
            }
            GUILayout.Space(5);
        }