Exemple #1
0
        internal override void Start()
        {
            base.Start();

            if (!KerbalAlarmClock.lstScenesForAngles.Contains(HighLogic.LoadedScene))
            {
                this.enabled = false;
                return;
            }

            LogFormatted("Initializing Phase Angle Render");

            //Get the orbit lines material so things look similar
            Material orbitLines = ((MapView)GameObject.FindObjectOfType(typeof(MapView))).orbitLinesMaterial;

            Material dottedLines = ((MapView)GameObject.FindObjectOfType(typeof(MapView))).dottedLineMaterial;

            //init all the lines
            lineStart     = InitLine(objLineStart, Color.blue, 2, 10, orbitLines);
            lineEnd       = InitLine(objLineEnd, Color.blue, 2, 10, orbitLines);
            lineArc       = InitLine(objLineArc, Color.blue, ArcPoints, 10, orbitLines);
            lineTarget    = InitLine(objLineTarget, Color.green, 2, 10, orbitLines);
            lineTargetArc = InitLine(objLineTargetArc, Color.green, ArcPoints, 10, orbitLines);

            styleLabelEnd = new GUIStyle();
            styleLabelEnd.normal.textColor = Color.white;
            styleLabelEnd.alignment        = TextAnchor.MiddleCenter;
            styleLabelTarget = new GUIStyle();
            styleLabelTarget.normal.textColor = Color.white;
            styleLabelTarget.alignment        = TextAnchor.MiddleCenter;

            //get the map camera - well need this for distance/width calcs
            cam = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));
        }
Exemple #2
0
        /// <summary>
        /// Update camera data, abstracting the different ways KSP does it
        /// depending on view mode:
        /// </summary>
        private void GetCamData()
        {
            prevIsOnMap    = isOnMap;
            prevCamLookVec = camLookVec;
            prevCamRot     = camRot;

            isOnMap = MapView.MapIsEnabled;

            if (isOnMap)
            {
                PlanetariumCamera pc = MapView.MapCamera;
                camPos = pc.transform.localPosition;
                // the Distance coming from from MapView.MapCamera.Distance
                // doesn't seem to work - calculating it myself below:
                // _camdist = pc.Distance();
                camRot = MapView.MapCamera.GetCameraTransform().rotation;
            }
            else
            {
                FlightCamera fc = FlightCamera.fetch;
                camPos = fc.transform.localPosition;
                // the Distance coming from from FlightCamera.Distance
                // doesn't seem to work - calculating it myself below:
                // _camdist = fc.Distance();
                camRot = FlightCamera.fetch.GetCameraTransform().rotation;
            }
            camLookVec = camPos - shipCenterCoords;
        }
        internal static void SetCurrentFlightStates()
        {
            if (HighLogic.CurrentGame != null)
            {
                KACWorkerGameState.CurrentSaveGameName = HighLogic.CurrentGame.Title;
            }
            else
            {
                KACWorkerGameState.CurrentSaveGameName = "";
            }

            try { KACWorkerGameState.CurrentTime.UT = Planetarium.GetUniversalTime(); }
            catch (Exception) { }
            //if (Planetarium.fetch!=null)KACWorkerGameState.CurrentTime.UT = Planetarium.GetUniversalTime();

            try
            {
                if (KACWorkerGameState.CurrentGUIScene == GameScenes.FLIGHT && FlightGlobals.ActiveVessel != null)
                {
                    KACWorkerGameState.CurrentVessel       = FlightGlobals.ActiveVessel;
                    KACWorkerGameState.CurrentSOIBody      = CurrentVessel.mainBody;
                    KACWorkerGameState.CurrentVesselTarget = CurrentVessel.targetObject;
                }
                else if (KACWorkerGameState.CurrentGUIScene == GameScenes.TRACKSTATION)
                {
                    SpaceTracking     st = (SpaceTracking)KACSpaceCenter.FindObjectOfType(typeof(SpaceTracking));
                    PlanetariumCamera c  = PlanetariumCamera.fetch;
                    if (c.target != null && c.target.type == MapObject.ObjectType.Vessel)
                    {
                        KACWorkerGameState.CurrentVessel       = c.target.vessel;
                        KACWorkerGameState.CurrentSOIBody      = CurrentVessel.mainBody;
                        KACWorkerGameState.CurrentVesselTarget = CurrentVessel.targetObject;
                    }
                    else
                    {
                        KACWorkerGameState.CurrentVessel       = null;
                        KACWorkerGameState.CurrentSOIBody      = null;
                        KACWorkerGameState.CurrentVesselTarget = null;
                    }
                }
                //else if (KACWorkerGameState.CurrentGUIScene == GameScenes.TRACKSTATION &&
                //        MapView.MapCamera.target.type == MapObject.MapObjectType.VESSEL)
                //{
                //    KACWorkerGameState.CurrentVessel = MapView.MapCamera.target.vessel;
                //    KACWorkerGameState.CurrentSOIBody = CurrentVessel.mainBody;
                //    KACWorkerGameState.CurrentVesselTarget = CurrentVessel.targetObject;
                //}
                else
                {
                    KACWorkerGameState.CurrentVessel       = null;
                    KACWorkerGameState.CurrentSOIBody      = null;
                    KACWorkerGameState.CurrentVesselTarget = null;
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #4
0
    protected virtual void Start()
    {
        cam = GameObject.FindObjectOfType <PlanetariumCamera> () as PlanetariumCamera;

        if (cam == null)
        {
            Debug.LogError("Cannot find required components. Please check objects in scene");
            gameObject.SetActive(false);
        }
    }
        public void Start()
        {
            LogDebug("window start");
            windowPosition.x = KSPSettings.get("PlanetSelectorWindow.x", (int)(Screen.width / 2 - windowWidth / 2));
            windowPosition.y = KSPSettings.get("PlanetSelectorWindow.y", (int)(Screen.height / 2 - windowHeight / 2));

            pCam = MapView.MapCamera;
            List <MapObject> targets = pCam.targets;

            foreach (MapObject mo in targets)
            {
                LogDebug("MapObject: " + mo.GetName() + " type: " + mo.type);
            }
        }
Exemple #6
0
        void onTrue()
        {
            PlanetariumCamera planetarium = PlanetariumCamera.fetch;

            if ((planetarium != null) && (planetarium.target != null) && (planetarium.target.vessel != null))
            {
                planetarium.target.vessel.RenameVessel();
                print(planetarium.target.vessel.name);
            }
            else
            {
                print("null");
            }
        }
Exemple #7
0
        internal override void Start()
        {
            base.Start();

            if (!TransferWindowPlanner.lstScenesForAngles.Contains(HighLogic.LoadedScene))
            {
                this.enabled = false;
                return;
            }

            LogFormatted("Initializing EjectAngle Render");
            objLineStart            = new GameObject("LineStart");
            objLineStartArrow1      = new GameObject("LineStartArrow1");
            objLineStartArrow2      = new GameObject("LineStartArrow2");
            objLineEnd              = new GameObject("LineEnd");
            objLineArc              = new GameObject("LineArc");
            objLineVesselVect       = new GameObject("LineVesselVect");
            objLineVesselVectArrow1 = new GameObject("LineVesselVectArrow1");
            objLineVesselVectArrow2 = new GameObject("LineVesselVectArrow2");

            //Get the orbit lines material so things look similar
            Material orbitLines = ((MapView)GameObject.FindObjectOfType(typeof(MapView))).orbitLinesMaterial;

            //Material dottedLines = ((MapView)GameObject.FindObjectOfType(typeof(MapView))).dottedLineMaterial;    //Commented because usage removed

            //init all the lines
            lineStart       = InitLine(objLineStart, Color.blue, 2, 10, orbitLines);
            lineStartArrow1 = InitLine(objLineStartArrow1, Color.blue, 2, 10, orbitLines);
            lineStartArrow2 = InitLine(objLineStartArrow2, Color.blue, 2, 10, orbitLines);

            lineEnd = InitLine(objLineEnd, Color.blue, 2, 10, orbitLines);
            lineArc = InitLine(objLineArc, Color.blue, ArcPoints, 10, orbitLines);

            lineVesselVect       = InitLine(objLineVesselVect, Color.green, 2, 10, orbitLines);
            lineVesselVectArrow1 = InitLine(objLineVesselVectArrow1, Color.green, 2, 10, orbitLines);
            lineVesselVectArrow2 = InitLine(objLineVesselVectArrow2, Color.green, 2, 10, orbitLines);

            styleLabelEnd = new GUIStyle();
            styleLabelEnd.normal.textColor = Color.white;
            styleLabelEnd.alignment        = TextAnchor.MiddleCenter;
            styleLabelTarget = new GUIStyle();
            styleLabelTarget.normal.textColor = Color.white;
            styleLabelTarget.alignment        = TextAnchor.MiddleCenter;

            //get the map camera - well need this for distance/width calcs
            cam = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));
        }
        private void focusOnSite(Vector2d loc)
        {
            Debug.Log("Focusing on site");
            PlanetariumCamera camera = PlanetariumCamera.fetch;
            CelestialBody     Kerbin = getKSCBody();
            Vector3d          point  = ScaledSpace.LocalToScaledSpace(Kerbin.GetWorldSurfacePosition(loc.x, loc.y, 0));
            Vector3           vec    = ScaledSpace.LocalToScaledSpace(Kerbin.transform.localPosition);

            point = (point - vec).normalized * Kerbin.Radius;
            camera.SetCamCoordsFromPosition(new Vector3((float)point.x, (float)point.y, (float)point.z));

            // this works for RSS, may have to change for other sizes.
            // float distance = camera.startDistance * 3.5f;
            float distance = (float)(Kerbin.Radius * 0.00035);

            camera.SetDistance(distance);
        }
Exemple #9
0
        public RemoteCore(Vessel v, float energyDrain)
        {
            if (v == null)
            {
                return;
            }
            vessel           = v;
            this.EnergyDrain = energyDrain;

            settings          = new SatSettings(this);
            computer          = new FlightComputer(this);
            flightComputerGUI = new FlightComputerGUI(this);

            Rnode = new RelayNode(vessel);

            try
            {
                vessel.OnFlyByWire -= new FlightInputCallback(this.drive);
            }
            catch { }
            try
            {
                vessel.OnFlyByWire += new FlightInputCallback(this.drive);
            }
            catch { }

            GetCommandPath();

            UpdateOtherModules();

            planetariumCamera = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));

            obj = new GameObject("Line");

            line = null;

            obj.layer          = 9;
            line               = obj.AddComponent <LineRenderer>();
            line.useWorldSpace = true;
            line.material      = new Material(Shader.Find("Particles/Additive"));
            line.SetColors(Color.blue, Color.blue);
            line.SetWidth(0, 0);

            localControl = vessel.GetCrewCount() > 0 || MechJeb;
        }
        public void UpdateCameraProperties(float camPitch, float camYaw, float camZoom, float camSensitivity)
        {
            switch (CameraManager.Instance.currentCameraMode)
            {
            case CameraManager.CameraMode.Flight:
            {
                FlightCamera.CamHdg   += camYaw * camSensitivity;
                FlightCamera.CamPitch += -camPitch * camSensitivity;
                FlightCamera.fetch.SetDistance(FlightCamera.fetch.Distance + camZoom * flightZoomStep);
                break;
            }

            case CameraManager.CameraMode.Map:
            {
                PlanetariumCamera cam = PlanetariumCamera.fetch;
                cam.camHdg   += camYaw * camSensitivity;
                cam.camPitch += -camPitch * camSensitivity;
                cam.SetDistance(Utility.Clamp(cam.Distance + (cam.Distance * camZoom * mapZoomStep), cam.minDistance, cam.maxDistance));
                break;
            }

            case CameraManager.CameraMode.IVA:
            case CameraManager.CameraMode.Internal:
            {
                //Hack: access private field that holds pitch/yaw in degrees before being applied to the camera.
                if (this.ivaCamFieldsLoaded)
                {
                    InternalCamera cam = InternalCamera.Instance;
                    ivaPitchField.SetValue(cam, (float)ivaPitchField.GetValue(cam) + camPitch * camSensitivity * ivaPanStep);
                    ivaYawField.SetValue(cam, (float)ivaYawField.GetValue(cam) + camYaw * camSensitivity * ivaPanStep);
                }
                if (camZoom != 0)
                {
                    // InternalCamera.Instance.SetFOV(Utility.Clamp(InternalCamera.Instance.camera.fieldOfView + camZoom * ivaFovStep, ivaFovMin, ivaFovMax));
                }
                break;
            }

            default:
                Debug.LogWarning("AFBW - Unsupported CameraMode: " + CameraManager.Instance.currentCameraMode.ToString());
                break;
            }
        }
Exemple #11
0
        public RemoteCore(Vessel v, float energyDrain)
        {
            if (v == null) return;
            vessel = v;
            this.EnergyDrain = energyDrain;

            settings = new SatSettings(this);
            computer = new FlightComputer(this);
            flightComputerGUI = new FlightComputerGUI(this);

            Rnode = new RelayNode(vessel);

            try
            {
                vessel.OnFlyByWire -= new FlightInputCallback(this.drive);
            }
            catch { }
            try
            {
                vessel.OnFlyByWire += new FlightInputCallback(this.drive);
            }
            catch { }

            GetCommandPath();

            UpdateOtherModules();

            planetariumCamera = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));

            obj = new GameObject("Line");

            line = null;

            obj.layer = 9;
            line = obj.AddComponent<LineRenderer>();
            line.useWorldSpace = true;
            line.material = new Material(Shader.Find("Particles/Additive"));
            line.SetColors(Color.blue, Color.blue);
            line.SetWidth(0, 0);

            localControl = vessel.GetCrewCount() > 0 || MechJeb;
        }
Exemple #12
0
        public void Awake()
        {
            //Initialize variables for GUI
            showGUI = false;
            windowRect = new Rect (20, 40, 200, 500); //Under Timewarp/Clock
            scrollPos = new Vector2 (0, 0);

            //Get Planetarium's MapObject information (Vessel, bodies, MNodes)
            pCamera = PlanetariumCamera.fetch;
            objects = pCamera.targets;

            #if DEBUG
            //Log all start up info, listing MO's before entering MapView for comparison
            Debug.Log ("[MVP] Registering Callback");
            Debug.Log ("[MVP] Called awake");
            Debug.Log("[MVP] listing the targets and indices before Map View");
            for(int i = 0; i < objects.Count; i++)
                Debug.Log("[MVP] " + objects[i].name + " has index " + i);
            #endif
        }
        internal static void FocusMapObject(CelestialBody body)
        {
            if (!(IsMapActive || IsTrackingCenterActive))
            {
                return;
            }

            Log.dbg("FocusMapObject(body)");

            PlanetariumCamera cam = getPlanetariumCamera();

            foreach (MapObject mapObject in cam.targets)
            {
                if (mapObject.celestialBody != null && mapObject.celestialBody.GetInstanceID() == body.GetInstanceID())
                {
                    cam.SetTarget(mapObject);
                    return;
                }
            }
        }
        internal static void FocusMapObject(Vessel vessel)
        {
            if (!(IsMapActive || IsTrackingCenterActive))
            {
                return;
            }

            Log.dbg("FocusMapObject(vessel)");

            PlanetariumCamera cam = getPlanetariumCamera();

            if (IsTrackingCenterActive)
            {
                foreach (MapObject mapObject in cam.targets)
                {
                    if (mapObject.vessel != null && mapObject.vessel.GetInstanceID() == vessel.GetInstanceID())
                    {
                        cam.SetTarget(mapObject);
                        return;
                    }
                }
                return;
            }

            // else
            // in flight map mode the active vessel is the only vessel in the list of targets
            // don't know why but will attempt to maintain that
            cam.targets.RemoveAll(mapObject => mapObject.vessel != null);

            Vessel activeVessel = FlightGlobals.ActiveVessel;

            if (activeVessel != null && activeVessel.GetInstanceID() != vessel.GetInstanceID())
            {
                cam.AddTarget(FlightGlobals.ActiveVessel.mapObject);
            }

            cam.AddTarget(vessel.mapObject);
            cam.SetTarget(vessel.mapObject);
        }
Exemple #15
0
        public void Awake()
        {
            //Initialize variables for GUI
            showGUI    = false;
            windowRect = new Rect(20, 40, 200, 500);              //Under Timewarp/Clock
            scrollPos  = new Vector2(0, 0);

            //Get Planetarium's MapObject information (Vessel, bodies, MNodes)
            pCamera = PlanetariumCamera.fetch;
            objects = pCamera.targets;

                        #if DEBUG
            //Log all start up info, listing MO's before entering MapView for comparison
            Debug.Log("[MVP] Registering Callback");
            Debug.Log("[MVP] Called awake");
            Debug.Log("[MVP] listing the targets and indices before Map View");
            for (int i = 0; i < objects.Count; i++)
            {
                Debug.Log("[MVP] " + objects[i].name + " has index " + i);
            }
                        #endif
        }
Exemple #16
0
        void Start()
        {
            if (!isInitialized)
            {
                initialize();
            }
            approach_obj = new GameObject("Line");
            loadsettings();
            if ((windowPos.x == 0) && (windowPos.y == 0))//windowPos is used to position the GUI window, lets set it in the center of the screen
            {
                windowPos = new Rect(Screen.width / 2, Screen.height / 2, 10, 10);
            }

            approach_obj.layer = 9;
            cam = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));

            approach = approach_obj.AddComponent<LineRenderer>();
            approach.transform.parent = null;
            approach.enabled = false;
            approach.SetColors(Color.green, Color.green);
            approach.useWorldSpace = true;
            approach.SetVertexCount(2);
            approach.SetWidth(10, 10);  //was 15, 5

            approach.material = ((MapView)GameObject.FindObjectOfType(typeof(MapView))).orbitLinesMaterial;

            if (ToolbarManager.ToolbarAvailable)
            {
                Debug.Log("Protractor: Blizzy's toolbar present");
                CreateToolbarButton();
            }
            else
            {
                Debug.Log("Protractor: Blizzy's toolbar NOT present");
                //loadicons();
                if (appButton == null)
                {
                    if (ApplicationLauncher.Ready)
                    {
                        OnGUIAppLauncherReady();
                    } else {
                        GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
                    }
                }
            }

            RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
            //vessel.OnFlyByWire += new FlightInputCallback(fly);
        }
    public override void OnStart(PartModule.StartState state)
    {
        base.OnStart(state);
        if (state != StartState.Editor)
        {
            loadsettings();
            if ((windowPos.x == 0) && (windowPos.y == 0))//windowPos is used to position the GUI window, lets set it in the center of the screen
            {
                windowPos = new Rect(Screen.width / 2, Screen.height / 2, 10, 10);
            }

            approach_obj.layer = 9;
            cam = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));

            approach = approach_obj.AddComponent<LineRenderer>();
            approach.transform.parent = null;
            approach.enabled = false;
            approach.SetColors(Color.green, Color.green);
            approach.useWorldSpace = true;
            approach.SetVertexCount(2);
            approach.SetWidth(10, 10);  //was 15, 5

            approach.material = ((MapView)GameObject.FindObjectOfType(typeof(MapView))).orbitLinesMaterial;

            loadicons();
            RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
            vessel.OnFlyByWire += new FlightInputCallback(fly);
        }
    }
        public void Update()
        {
            try
            {
                if (gameRunning && FlightDriver.Pause) FlightDriver.SetPause(false);

                //Find an instance of the game's RenderingManager
                if (renderManager == null)
                    renderManager = (RenderingManager) FindObjectOfType(typeof(RenderingManager));

                //Find an instance of the game's PlanetariumCamera
                if (planetariumCam == null)
                    planetariumCam = (PlanetariumCamera)FindObjectOfType(typeof(PlanetariumCamera));

                if (Input.GetKeyDown(KMPGlobalSettings.instance.guiToggleKey))
                    KMPInfoDisplay.infoDisplayActive = !KMPInfoDisplay.infoDisplayActive;

                if (Input.GetKeyDown(KMPGlobalSettings.instance.screenshotKey))
                    StartCoroutine(shareScreenshot());

                if (Input.anyKeyDown)
                    lastKeyPressTime = UnityEngine.Time.realtimeSinceStartup;

                //Handle key-binding
                if (mappingGUIToggleKey)
                {
                    KeyCode key = KeyCode.F7;
                    if (getAnyKeyDown(ref key))
                    {
                        KMPGlobalSettings.instance.guiToggleKey = key;
                        mappingGUIToggleKey = false;
                    }
                }

                if (mappingScreenshotKey)
                {
                    KeyCode key = KeyCode.F8;
                    if (getAnyKeyDown(ref key))
                    {
                        KMPGlobalSettings.instance.screenshotKey = key;
                        mappingScreenshotKey = false;
                    }
                }
            } catch (Exception ex) { KMPClientMain.DebugLog ("u err: " + ex.Message + " " + ex.StackTrace); }
        }
        public void Update()
        {
            try
            {
                if (!gameRunning)
                    return;

                if (pauseMenu != null)
                {
                    if (PauseMenu.isOpen && syncing)
                    {
                        if (KMPClientMain.tcpClient != null)
                        {
                            closePauseMenu = true;
                        }
                        else
                        {
                            disconnect("Connection terminated during sync");
                            forceQuit = true;
                        }
                    }
                    if (PauseMenu.isOpen && closePauseMenu)
                    {
                        closePauseMenu = false;
                        PauseMenu.Close();
                    }
                }

                if (FlightDriver.Pause) FlightDriver.SetPause(false);
                if (gameCheatsEnabled == false) {
                    CheatOptions.InfiniteFuel = false;
                    CheatOptions.InfiniteEVAFuel = false;
                    CheatOptions.InfiniteRCS = false;
                    CheatOptions.NoCrashDamage = false;
                    Destroy(FindObjectOfType(typeof(DebugToolbar)));
                }

                //Find an instance of the game's PauseMenu
                if (pauseMenu == null)
                    pauseMenu = (PauseMenu)FindObjectOfType(typeof(PauseMenu));

                //Find an instance of the game's RenderingManager
                if (renderManager == null)
                    renderManager = (RenderingManager)FindObjectOfType(typeof(RenderingManager));

                //Find an instance of the game's PlanetariumCamera
                if (planetariumCam == null)
                    planetariumCam = (PlanetariumCamera)FindObjectOfType(typeof(PlanetariumCamera));

                if (Input.GetKeyDown(KeyCode.F2))
                {
                    isGameHUDHidden = !isGameHUDHidden;
                }

                if (Input.GetKeyDown(KMPGlobalSettings.instance.guiToggleKey) && !isGameHUDHidden && KMPToggleButtonState)
                    KMPInfoDisplay.infoDisplayActive = !KMPInfoDisplay.infoDisplayActive;

                if (Input.GetKeyDown(KMPGlobalSettings.instance.screenshotKey))
                    StartCoroutine(shareScreenshot());

                if (Input.GetKeyDown(KMPGlobalSettings.instance.screenshotToggleKey) && !isGameHUDHidden && KMPToggleButtonState)
                    KMPScreenshotDisplay.windowEnabled = !KMPScreenshotDisplay.windowEnabled;

                if (Input.GetKeyDown(KMPGlobalSettings.instance.chatTalkKey))
                {
                    KMPChatDX.showInput = true;
                    //DISABLE SHIP CONTROL
                    InputLockManager.SetControlLock(ControlTypes.All,"KMP_ChatActive");
                }

                if (Input.GetKeyDown(KeyCode.Escape) && KMPChatDX.showInput)
                {
                    KMPChatDX.showInput = false;
                    //ENABLE SHIP CONTROL
                    InputLockManager.RemoveControlLock("KMP_ChatActive");
                    closePauseMenu = true;
                }

                if (Input.GetKeyDown(KMPGlobalSettings.instance.chatHideKey) && !isGameHUDHidden && KMPToggleButtonState)
                {
                    KMPGlobalSettings.instance.chatDXWindowEnabled = !KMPGlobalSettings.instance.chatDXWindowEnabled;
                    //if (KMPGlobalSettings.instance.chatDXWindowEnabled) KMPChatDX.enqueueChatLine("Press Chat key (" + (KMPGlobalSettings.instance.chatTalkKey == KeyCode.BackQuote ? "~" : KMPGlobalSettings.instance.chatTalkKey.ToString()) + ") to send a message");
                }

                if (Input.anyKeyDown)
                    lastKeyPressTime = UnityEngine.Time.realtimeSinceStartup;

                //Handle key-binding
                if (mappingGUIToggleKey)
                {
                    KeyCode key = KeyCode.F7;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.guiToggleKey = key;
                            mappingGUIToggleKey = false;
                        }
                    }
                }

                if (mappingScreenshotKey)
                {
                    KeyCode key = KeyCode.F8;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.screenshotKey = key;
                            mappingScreenshotKey = false;
                        }
                    }
                }

                if (mappingScreenshotToggleKey)
                {
                    KeyCode key = KeyCode.F10;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.screenshotToggleKey = key;
                            mappingScreenshotToggleKey = false;
                        }
                    }
                }

                if (mappingChatKey)
                {
                    KeyCode key = KeyCode.Y;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.chatTalkKey = key;
                            mappingChatKey = false;
                        }
                    }
                }

                if (mappingChatDXToggleKey)
                {
                    KeyCode key = KeyCode.F9;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.chatHideKey = key;
                            mappingChatDXToggleKey = false;
                        }
                    }
                }
            } catch (Exception ex) { Log.Debug("Exception thrown in Update(), catch 2, Exception: {0}", ex.ToString()); Log.Debug ("u err: " + ex.Message + " " + ex.StackTrace); }
        }
        public void Update()
        {
            if (HighLogic.LoadedScene == GameScenes.LOADING || HighLogic.LoadedScene == GameScenes.MAINMENU)
                return; //Don't do anything while the game is loading

            //Find an instance of the game's PlanetariumCamera
            if (planetariumCam == null)
                planetariumCam = (PlanetariumCamera)FindObjectOfType(typeof(PlanetariumCamera));

            if (Input.GetKeyDown(KLFGlobalSettings.instance.guiToggleKey))
            {
                KLFInfoDisplay.infoDisplayActive = !KLFInfoDisplay.infoDisplayActive;
                if (KLFInfoDisplay.infoDisplayActive)
                { KLF_Button.SetTexture(KLF_button_on); KLF_button_alert_anim = 0; }
                else
                {
                    KLF_Button.SetTexture(KLF_button_off);
                    CheckEditorLock();
                }
            }

            if (Input.GetKeyDown(KLFGlobalSettings.instance.screenshotKey))
                shareScreenshot();

            if (Input.GetKeyDown(KLFGlobalSettings.instance.chatKey))
            {
                KLFGlobalSettings.instance.chatWindowEnabled = !KLFGlobalSettings.instance.chatWindowEnabled;
                if (KLFGlobalSettings.instance.chatWindowEnabled && KLFInfoDisplay.infoDisplayActive)
                {
                    KLF_Button.SetTexture(KLF_button_on); KLF_button_alert_anim = 0;
                }
            }

            if (Input.GetKeyDown(KLFGlobalSettings.instance.viewKey))
                KLFScreenshotDisplay.windowEnabled = !KLFScreenshotDisplay.windowEnabled;

            if (Input.anyKeyDown)
                lastKeyPressTime = UnityEngine.Time.realtimeSinceStartup;

            //Handle key-binding
            if (mappingGUIToggleKey)
            {
                KeyCode key = KeyCode.F7;
                if (getAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.instance.guiToggleKey = key;
                    mappingGUIToggleKey = false;
                }
            }

            if (mappingScreenshotKey)
            {
                KeyCode key = KeyCode.F8;
                if (getAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.instance.screenshotKey = key;
                    mappingScreenshotKey = false;
                }
            }
            if (mappingChatKey)
            {
                KeyCode key = KeyCode.F9;
                if (getAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.instance.chatKey = key;
                    mappingChatKey = false;
                }
            }
            if (mappingViewKey)
            {
                KeyCode key = KeyCode.F10;
                if (getAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.instance.viewKey = key;
                    mappingViewKey = false;
                }
            }
        }
Exemple #21
0
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);
            if (state != StartState.Editor)
            {
                loadsettings();
                if ((mainwindow.x == 0) && (mainwindow.y == 0))//mainwindow is used to position the GUI window, lets set it in the center of the screen
                {
                    mainwindow = new Rect(Screen.width / 2, Screen.height / 2, 10, 10);
                }

                approach_obj.layer = 9;

                cam = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));
                RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));

                approach = approach_obj.AddComponent<LineRenderer>();
                approach.transform.parent = null;
                approach.enabled = false;
                approach.SetColors(Color.green, Color.green);
                approach.useWorldSpace = true;
                approach.SetVertexCount(2);
                approach.SetWidth(10, 10);  //was 15, 5

                approach.material = ((MapView)GameObject.FindObjectOfType(typeof(MapView))).orbitLinesMaterial;

                //protractor2icon.LoadImage(KSP.IO.File.ReadAllBytes<Protractor2Module>("protractor-on.png"));

                if (ToolbarManager.ToolbarAvailable)
                {
                    Debug.Log("Protractor2: Blizzy's toolbar present");

                    button = ToolbarManager.Instance.add("Protractor2", "protractor2Button");
                    button.TexturePath = "Protractor2/icon";
                    button.ToolTip = "Toggle Protractor2 UI";
                    button.Visibility = new GameScenesVisibility(GameScenes.FLIGHT);
                    button.OnClick += (e) =>
                    {
                        isVisible = !isVisible;
                    };
                }
                else
                {
                    Debug.Log("Protractor2: Blizzy's toolbar NOT present");
                    //loadicons();
                    isVisible = true;
                }

                RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
            }
        }
        internal override void Start()
        {
            base.Start();

            if (!TransferWindowPlanner.lstScenesForAngles.Contains(HighLogic.LoadedScene)) { 
                this.enabled = false;
                return;
            }

            LogFormatted("Initializing Phase Angle Render");

            //Get the orbit lines material so things look similar
            Material orbitLines = ((MapView)GameObject.FindObjectOfType(typeof(MapView))).orbitLinesMaterial;

            Material dottedLines = ((MapView)GameObject.FindObjectOfType(typeof(MapView))).dottedLineMaterial;

            //init all the lines
            lineStart = InitLine(objLineStart, Color.blue, 2, 10, orbitLines);
            lineEnd = InitLine(objLineEnd, Color.blue, 2, 10, orbitLines);
            lineArc = InitLine(objLineArc, Color.blue, ArcPoints, 10, orbitLines);
            lineTarget = InitLine(objLineTarget, Color.green, 2, 10, orbitLines);
            lineTargetArc = InitLine(objLineTargetArc, Color.green, ArcPoints, 10, orbitLines);

            styleLabelEnd = new GUIStyle();
            styleLabelEnd.normal.textColor = Color.white;
            styleLabelEnd.alignment = TextAnchor.MiddleCenter;
            styleLabelTarget = new GUIStyle();
            styleLabelTarget.normal.textColor = Color.white;
            styleLabelTarget.alignment = TextAnchor.MiddleCenter;

            //get the map camera - well need this for distance/width calcs
            cam = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));
        }
        public void Update()
        {
            try
            {
                if (!gameRunning) return;

                try { if (PauseMenu.isOpen && syncing) PauseMenu.Close(); } catch { }

                if (FlightDriver.Pause) FlightDriver.SetPause(false);
                if (gameCheatsEnabled == false) {
                    if (CheatOptions.InfiniteFuel == true)
                        CheatOptions.InfiniteFuel = false;
                    if (CheatOptions.InfiniteEVAFuel == true)
                        CheatOptions.InfiniteEVAFuel = false;
                    if (CheatOptions.InfiniteRCS == true)
                        CheatOptions.InfiniteRCS = false;
                    if (CheatOptions.NoCrashDamage == true)
                        CheatOptions.NoCrashDamage = false;
                    Destroy(FindObjectOfType(typeof(DebugToolbar)));
                }

                //Find an instance of the game's RenderingManager
                if (renderManager == null)
                    renderManager = (RenderingManager)FindObjectOfType(typeof(RenderingManager));

                //Find an instance of the game's PlanetariumCamera
                if (planetariumCam == null)
                    planetariumCam = (PlanetariumCamera)FindObjectOfType(typeof(PlanetariumCamera));
                if (Input.GetKeyDown(KeyCode.F2))
                {
                    isGameHUDHidden = !isGameHUDHidden;
                }

                if (Input.GetKeyDown(KMPGlobalSettings.instance.guiToggleKey) && isGameHUDHidden == false)
                    KMPInfoDisplay.infoDisplayActive = !KMPInfoDisplay.infoDisplayActive;

                if (Input.GetKeyDown(KMPGlobalSettings.instance.screenshotKey))
                    StartCoroutine(shareScreenshot());

                if (Input.GetKeyDown(KMPGlobalSettings.instance.screenshotToggleKey) && isGameHUDHidden == false)
            KMPScreenshotDisplay.windowEnabled = !KMPScreenshotDisplay.windowEnabled;

                if (Input.GetKeyDown(KMPGlobalSettings.instance.chatTalkKey))
                    KMPChatDX.showInput = true;

                if (Input.GetKeyDown(KMPGlobalSettings.instance.chatHideKey) && isGameHUDHidden == false)
                {
            KMPGlobalSettings.instance.chatDXWindowEnabled = !KMPGlobalSettings.instance.chatDXWindowEnabled;
                    if (KMPGlobalSettings.instance.chatDXWindowEnabled) KMPChatDX.enqueueChatLine("Press Chat key (" + (KMPGlobalSettings.instance.chatTalkKey == KeyCode.BackQuote ? "~" : KMPGlobalSettings.instance.chatTalkKey.ToString()) + ") to send a message");
                }

                if (Input.anyKeyDown)
                    lastKeyPressTime = UnityEngine.Time.realtimeSinceStartup;

                //Handle key-binding
                if (mappingGUIToggleKey)
                {
                    KeyCode key = KeyCode.F7;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.guiToggleKey = key;
                            mappingGUIToggleKey = false;
                        }
                    }
                }

                if (mappingScreenshotKey)
                {
                    KeyCode key = KeyCode.F8;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.screenshotKey = key;
                            mappingScreenshotKey = false;
                        }
                    }
                }

                if (mappingScreenshotToggleKey)
                {
                    KeyCode key = KeyCode.F10;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.screenshotToggleKey = key;
                            mappingScreenshotToggleKey = false;
                        }
                    }
                }

                if (mappingChatKey)
                {
                    KeyCode key = KeyCode.Y;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.chatTalkKey = key;
                            mappingChatKey = false;
                        }
                    }
                }

                if (mappingChatDXToggleKey)
                {
                    KeyCode key = KeyCode.F9;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.chatHideKey = key;
                            mappingChatDXToggleKey = false;
                        }
                    }
                }
            } catch (Exception ex) { Log.Debug("Exception thrown in Update(), catch 1, Exception: {0}", ex.ToString()); Log.Debug ("u err: " + ex.Message + " " + ex.StackTrace); }
        }
        //////////////////////////////
        // VESSEL HISTORY UPDATES ////
        //////////////////////////////
        public override void onFlightStart()
        {
            foreach (ComputerModule module in core.modules)
            {
                if (module is MechJebModuleOrbitOper) orbitOper = (MechJebModuleOrbitOper)module;
            }

            planetariumCamera = (PlanetariumCamera)GameObject.FindObjectOfType(typeof(PlanetariumCamera));
        }
Exemple #25
0
 void Start()
 {
     cam = GameObject.FindObjectOfType <PlanetariumCamera> () as PlanetariumCamera;
 }
Exemple #26
0
        public void Update()
        {
            if (HighLogic.LoadedScene == GameScenes.LOADING)
                return; //Don't do anything while the game is loading
            if (RenderManager == null)
                RenderManager = (RenderingManager) FindObjectOfType(typeof(RenderingManager));
            if (PlanetariumCam == null)
                PlanetariumCam = (PlanetariumCamera)FindObjectOfType(typeof(PlanetariumCamera));
            //key events
            if (Input.GetKeyDown(KLFGlobalSettings.Instance.GuiToggleKey))
                KLFInfoDisplay.InfoDisplayActive = !KLFInfoDisplay.InfoDisplayActive;
            if (Input.GetKeyDown(KLFGlobalSettings.Instance.GuiToggleKey))
            {
                KLFInfoDisplay.InfoDisplayActive = !KLFInfoDisplay.InfoDisplayActive;
                if (KLFInfoDisplay.InfoDisplayActive)
                {
                    KLF_Button.SetTexture(KLF_button_on);
                    KLF_button_alert_anim = 0;
                }
                else
                {
                    KLF_Button.SetTexture(KLF_button_off);
                    CheckEditorLock();
                }
            }
            if (Input.GetKeyDown(KLFGlobalSettings.Instance.ScreenshotKey) || SharingScreenshot)
                ShareScreenshot();
            if (Input.GetKeyDown(KLFGlobalSettings.Instance.ChatKey))
            {
                KLFGlobalSettings.Instance.ChatWindowEnabled = !KLFGlobalSettings.Instance.ChatWindowEnabled;
                if (KLFGlobalSettings.Instance.ChatWindowEnabled && KLFInfoDisplay.InfoDisplayActive)
                {
                    KLF_Button.SetTexture(KLF_button_on);
                    KLF_button_alert_anim = 0;
                }
            }
            if (Input.GetKeyDown(KLFGlobalSettings.Instance.ViewKey))
                KLFScreenshotDisplay.WindowEnabled = !KLFScreenshotDisplay.WindowEnabled;

            //idle monitor
            if (Input.anyKeyDown)
                LastKeyPressTime = UnityEngine.Time.realtimeSinceStartup;

            //Handle custom key-bindings
            if (MappingGUIToggleKey)
            {
                KeyCode key = KeyCode.F7;
                if (GetAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.Instance.GuiToggleKey = key;
                    MappingGUIToggleKey = false;
                }
            }
            if (MappingScreenshotKey)
            {
                KeyCode key = KeyCode.F8;
                if (GetAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.Instance.ScreenshotKey = key;
                    MappingScreenshotKey = false;
                }
            }
            if (MappingChatKey)
            {
                KeyCode key = KeyCode.F9;
                if (GetAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.Instance.ChatKey = key;
                    MappingChatKey = false;
                }
            }
            if (MappingViewKey)
            {
                KeyCode key = KeyCode.F10;
                if (GetAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.Instance.ViewKey = key;
                    MappingViewKey = false;
                }
            }
        }
Exemple #27
0
        public void Update()
        {
            try
            {
                if (!gameRunning) return;
                if (FlightDriver.Pause) FlightDriver.SetPause(false);

                //Find an instance of the game's RenderingManager
                if (renderManager == null)
                    renderManager = (RenderingManager)FindObjectOfType(typeof(RenderingManager));

                //Find an instance of the game's PlanetariumCamera
                if (planetariumCam == null)
                    planetariumCam = (PlanetariumCamera)FindObjectOfType(typeof(PlanetariumCamera));

                if (Input.GetKeyDown(KMPGlobalSettings.instance.guiToggleKey))
                    KMPInfoDisplay.infoDisplayActive = !KMPInfoDisplay.infoDisplayActive;

                if (Input.GetKeyDown(KMPGlobalSettings.instance.screenshotKey))
                    StartCoroutine(shareScreenshot());

                if (Input.GetKeyDown(KMPGlobalSettings.instance.chatTalkKey))
                    KMPChatDX.showInput = true;

                if (Input.GetKeyDown(KMPGlobalSettings.instance.chatHideKey))
                {
                    KMPGlobalSettings.instance.chatDXWindowEnabled = !KMPGlobalSettings.instance.chatDXWindowEnabled;
                    if (KMPGlobalSettings.instance.chatDXWindowEnabled) KMPChatDX.enqueueChatLine("Press Chat key (" + (KMPGlobalSettings.instance.chatTalkKey == KeyCode.BackQuote ? "~" : KMPGlobalSettings.instance.chatTalkKey.ToString()) + ") to send a message");
                }

                if (Input.anyKeyDown)
                    lastKeyPressTime = UnityEngine.Time.realtimeSinceStartup;

                //Handle key-binding
                if (mappingGUIToggleKey)
                {
                    KeyCode key = KeyCode.F7;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.guiToggleKey = key;
                            mappingGUIToggleKey = false;
                        }
                    }
                }

                if (mappingScreenshotKey)
                {
                    KeyCode key = KeyCode.F8;
                    if (getAnyKeyDown(ref key))
                    {
                        if (key != KeyCode.Mouse0)
                        {
                            KMPGlobalSettings.instance.screenshotKey = key;
                            mappingScreenshotKey = false;
                        }
                    }
                }

                if (mappingChatKey)
                {
                    KeyCode key = KeyCode.Y;
                    if (getAnyKeyDown(ref key))
                    {
                        KMPGlobalSettings.instance.chatTalkKey = key;
                        mappingChatKey = false;
                    }
                }

                if (mappingChatDXToggleKey)
                {
                    KeyCode key = KeyCode.F9;
                    if (getAnyKeyDown(ref key))
                    {
                        KMPGlobalSettings.instance.chatHideKey = key;
                        mappingChatDXToggleKey = false;
                    }
                }
            } catch (Exception ex) { KMPClientMain.DebugLog ("u err: " + ex.Message + " " + ex.StackTrace); }
        }
        public void Update()
        {
            if (HighLogic.LoadedScene == GameScenes.LOADING)
                return; //Don't do anything while the game is loading

            //Find an instance of the game's RenderingManager
            if (renderManager == null)
                renderManager = (RenderingManager) FindObjectOfType(typeof(RenderingManager));

            //Find an instance of the game's PlanetariumCamera
            if (planetariumCam == null)
                planetariumCam = (PlanetariumCamera)FindObjectOfType(typeof(PlanetariumCamera));

            if (Input.GetKeyDown(KLFGlobalSettings.instance.guiToggleKey))
                KLFInfoDisplay.infoDisplayActive = !KLFInfoDisplay.infoDisplayActive;

            if (Input.GetKeyDown(KLFGlobalSettings.instance.screenshotKey))
                shareScreenshot();

            if (Input.anyKeyDown)
                lastKeyPressTime = UnityEngine.Time.realtimeSinceStartup;

            //Handle key-binding
            if (mappingGUIToggleKey)
            {
                KeyCode key = KeyCode.F7;
                if (getAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.instance.guiToggleKey = key;
                    mappingGUIToggleKey = false;
                }
            }

            if (mappingScreenshotKey)
            {
                KeyCode key = KeyCode.F8;
                if (getAnyKeyDown(ref key))
                {
                    KLFGlobalSettings.instance.screenshotKey = key;
                    mappingScreenshotKey = false;
                }
            }
        }