Ejemplo n.º 1
0
        /// <summary>
        /// Active vessel changed, deal with it.
        /// </summary>
        /// <param name="vessel">Vessel.</param>
        public void onVesselChange(Vessel vessel)
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            currentModule = vessel.FindPartModuleImplementing <BonVoyageModule> ();
            if (currentModule != null)
            {
                currentModule.SystemCheck();
                UpdateWayPoints();
                if (currentModule.isActive)
                {
                    InputLockManager.SetControlLock(lockMask, "BonVoyageInputLock");
                    return;
                }
            }
            InputLockManager.RemoveControlLock("BonVoyageInputLock");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Active vessel changed, deal with it.
        /// </summary>
        /// <param name="vessel">Vessel.</param>
        public void onVesselChange(Vessel vessel)
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            currentModule = vessel.FindPartModuleImplementing <BonVoyageModule> ();
//			if (wayPoints != null)
//				wayPoints.Clear ();
            if (currentModule != null)
            {
                currentModule.SystemCheck();
                UpdateWayPoints();
//				wayPoints = PathUtils.DecodePath (currentModule.pathEncoded, currentModule.vessel.mainBody);
                if (currentModule.isActive)
                {
                    InputLockManager.SetControlLock(lockMask, "BonVoyageInputLock");
                    return;
                }
            }

//			currentModule = null;
//			foreach (var rover in activeRovers)
//			{
//				if (rover.vessel == vessel)
////					ControlThis (rover.vessel.FindPartModuleImplementing<BonVoyageModule> (), false);
//					currentModule = rover.vessel.FindPartModuleImplementing<BonVoyageModule>();
//
//				if (rover.vessel == vessel && rover.bvActive)
//				{
//					InputLockManager.SetControlLock(lockMask, "BonVoyageInputLock");
//					return;
//				}
//			}
            InputLockManager.RemoveControlLock("BonVoyageInputLock");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Draws main UI
        /// </summary>
        /// <param name="guiId">GUI identifier.</param>
        public void DrawGUI(int guiId)
        {
            double currentTime = Planetarium.GetUniversalTime();

            GUILayout.BeginVertical();
            mainWindowScrollPosition = GUILayout.BeginScrollView(mainWindowScrollPosition);
            for (int i = 0; i < activeRovers.Count; i++)
            {
                var rover = activeRovers [i];
                switch (rover.status)
                {
                case "current":
                    GUI.contentColor = Color.white;
                    break;

                case "roving":
                    GUI.contentColor = Palette.green;
                    break;

                case "idle":
                    GUI.contentColor = Palette.yellow;
                    break;

                case "awaiting sunlight":
                    GUI.contentColor = Palette.red;
                    break;
                }
                GUILayout.BeginHorizontal();
                if (Layout.Button(rover.vessel.vesselName, GUILayout.Width(200)))
                {
                    if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
                    {
                        PlanetariumCamera.fetch.SetTarget(rover.vessel.mapObject);
                    }
                    if (HighLogic.LoadedSceneIsFlight)
                    {
                        MapView.EnterMapView();
                        PlanetariumCamera.fetch.SetTarget(rover.vessel.mapObject);
                    }
                }
                if (Layout.Button("Switch to", GUILayout.Width(100)))
                {
                    if (rover.vessel.loaded)
                    {
                        FlightGlobals.SetActiveVessel(rover.vessel);
                    }
                    else
                    {
                        GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                        FlightDriver.StartAndFocusVessel("persistent", FlightGlobals.Vessels.IndexOf(rover.vessel));
                    }
                }

                Layout.Label(rover.vessel.mainBody.bodyDisplayName.Replace("^N", ""), GUILayout.Width(75));
                Layout.Label(rover.status + (rover.status == "roving" ? rover.status2 : ""), GUILayout.Width(125));

                if (rover.status == "roving" || rover.status == "awaiting sunlight")
                {
                    Layout.Label(
                        "v̅ = " + rover.AverageSpeed.ToString("N") + ", yet to travel " +
                        rover.yetToTravel.ToString("N0") + " meters"
                        );
                }

                if (rover.status == "idle")
                {
                    TimeSpan t = TimeSpan.FromSeconds(currentTime - rover.LastTime);

                    string idlePeriod = string.Format(
                        "{0:D2}h:{1:D2}m:{2:D2}s",
                        t.Hours,
                        t.Minutes,
                        t.Seconds
                        );

                    Layout.Label(idlePeriod);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
            GUI.contentColor = Color.white;
            autoDewarp       = Layout.Toggle(autoDewarp, "Automagic Dewarp");
//			useKSPSkin = Layout.Toggle (useKSPSkin, "Use KSP Skin");
            GUILayout.BeginHorizontal();
            if (Layout.Button("Close", GUILayout.Height(25)))
            {
                if (appLauncherButton != null)
                {
                    appLauncherButton.SetFalse();
                }
                else
                {
                    onToggle();
                }
            }
            if (Layout.Button("Switch Toolbar", GUILayout.Height(25), GUILayout.Width(150)))
            {
                useToolbar = !useToolbar;
                DestroyLauncher();
                CreateLauncher();
            }
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (Layout.Button("BV Control Panel", GUILayout.Height(25), GUILayout.Width(200)))
                {
                    if ((currentModule != null) && !currentModule.isShutdown)
                    {
                        currentModule.SystemCheck();
                        rcVisible = true;
                        if (appLauncherButton != null)
                        {
                            appLauncherButton.SetFalse();
                        }
                        else
                        {
                            onToggle();
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUI.DragWindow();
        }