Пример #1
0
        private void MainGUI(int WindowID)
        {
            timer     += Planetarium.GetUniversalTime() - storedTime;
            storedTime = Planetarium.GetUniversalTime();

            //Top right hand corner button that exits the window.
            if (GUI.Button(new Rect(WindowPosition.width - 18, 2, 16, 16), ""))
            {
                Toggle();
            }

            //What you see looking through the telescope.
            ScopeRect = GUILayoutUtility.GetRect(Screen.width * 0.4f, Screen.width * 0.4f);
            Texture2D ScopeScreen = CameraModule.UpdateTexture(ActiveProcessor);

            GUI.DrawTexture(ScopeRect, ScopeScreen);

            //Draw the preview texture
            GUI.DrawTexture(new Rect(ScopeRect.xMin, ScopeRect.yMax - 32f, 128f, 32f), PreviewTexture);
            //Draw the crosshair texture
            GUI.DrawTexture(new Rect(ScopeRect.xMin + (0.5f * ScopeRect.width) - 64, ScopeRect.yMin + (0.5f * ScopeRect.height) - 64, 128, 128), CrosshairTexture);
            //Draw the notification label
            if (timer > 5f)
            {
                Notification = "";
            }
            GUI.Label(new Rect(ScopeRect.xMin + 16, ScopeRect.yMin + 16, 600, 32), new GUIContent(Notification));

            //Draw Processor controls in bottom center of display, with observation and screenshot buttons in center.
            DrawProcessorControls();
            DrawTargetPointer();

            if (ActiveProcessor)
            {
                //Close window down if we run out of power
                if (!ActiveProcessor.IsActive())
                {
                    //    Toggle();
                    //    ScreenMessages.PostScreenMessage("Image processor is out of power. Please restore power to telescope.", 6, ScreenMessageStyle.UPPER_CENTER);
                    ActiveProcessor = null;
                    Notification    = "Image Processor is out of power. Please restore power to telescope";
                    timer           = 0f;
                }

                //Zoom Feedback Label.
                string LabelZoom = "Zoom/Magnification: x";
                if (CameraModule.FieldOfView > 0.0064)
                {
                    LabelZoom += string.Format("{0:####0.0}", 64 / CameraModule.FieldOfView);
                }
                else
                {
                    LabelZoom += string.Format("{0:0.00E+0}", (64 / CameraModule.FieldOfView));
                }
                GUILayout.BeginHorizontal();
                GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft;
                GUILayout.Label(LabelZoom);

                //Active Processor and status Label
                GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperCenter;
                GUILayout.Label("Active Processor: " + ActiveProcessor.GetProcessorType());
                GUILayout.EndHorizontal();

                //Zoom Slider Controls.
                GUILayout.BeginHorizontal();
                FieldOfView = GUILayout.HorizontalSlider(FieldOfView, 0f, 1f);
                CameraModule.FieldOfView = 0.5f * Mathf.Pow(4f - FieldOfView * (4f - Mathf.Pow(ActiveProcessor.GetMinimumFOV(), (1f / 3f))), 3);
                GUILayout.EndHorizontal();

                //Log spam
                //Debug.Log("CactEye 2: MinimumFOV = " + ActiveProcessor.GetMinimumFOV().ToString());
            }

            else
            {
                GUILayout.BeginHorizontal();
                GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft;
                GUILayout.Label("Processor not installed; optics module cannot function without an image processor.");
                GUILayout.EndHorizontal();
            }

            //Gyro GUI. Active only if the craft has an active gyro
            if (GyroEnabled)
            {
                //Gyro Slider Label
                GUILayout.BeginHorizontal();
                GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft;
                GUILayout.Label("Gyro Sensitivity:  " + GyroSensitivity.ToString("P") + " + minimum gyroscopic torgue.", GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();

                //Gyro Slider Controls.
                GUILayout.BeginHorizontal();
                GyroSensitivity = GUILayout.HorizontalSlider(GyroSensitivity, 0f, 1f, GUILayout.ExpandWidth(true));
                GUILayout.EndHorizontal();

                SetTorgue();
            }

            //Make the window draggable by the top bar only.
            GUI.DragWindow(new Rect(0, 0, WindowPosition.width, 16));
        }
Пример #2
0
        private void MainGUI(int WindowID)
        {
            timer     += Planetarium.GetUniversalTime() - storedTime;
            storedTime = Planetarium.GetUniversalTime();
            GUILayout.BeginHorizontal();
            //Top right hand corner button that exits the window.
            if (GUI.Button(new Rect(WindowPosition.width - 18, 2, 16, 16), ""))
            {
                Toggle();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            //What you see looking through the telescope.
            ScopeRect = GUILayoutUtility.GetRect(400f, 400f);
            Texture2D ScopeScreen = CameraModule.UpdateTexture(ActiveProcessor);

            GUI.DrawTexture(ScopeRect, ScopeScreen);


            //Draw the preview texture
            GUI.DrawTexture(new Rect(ScopeRect.xMin, ScopeRect.yMax - 32f, 128f, 32f), PreviewTexture);
            //Draw the crosshair texture
            GUI.DrawTexture(new Rect(ScopeRect.xMin + (0.5f * ScopeRect.width) - 64, ScopeRect.yMin + (0.5f * ScopeRect.height) - 64, 128, 128), CrosshairTexture);
            //Draw the notification label
            if (timer > 5f)
            {
                Notification = "";
            }
            GUI.Label(new Rect(ScopeRect.xMin + 16, ScopeRect.yMin + 16, 600, 32), new GUIContent(Notification));


            ControlRect = GUILayoutUtility.GetRect(300f, 20f);

            if (Processors.Count > 1)
            {
                //Previous button
                if (GUI.Button(new Rect(433f, 72f, 32, 32), Back9Icon))
                {
                    ActiveProcessor.Active = false;
                    ActiveProcessor        = GetPrevious(Processors, ActiveProcessor);
                    ActiveProcessor.Active = true;
                }
                if (GUI.Button(new Rect(635f, 72f, 32, 32), Forward9Icon))
                {
                    ActiveProcessor.Active = false;
                    ActiveProcessor        = GetNext(Processors, ActiveProcessor);
                    ActiveProcessor.Active = true;
                }
            }
            GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperCenter;
            GUI.Label(new Rect(475f, 40f, 150, 32), "Active Processor");
            GUI.Label(new Rect(475f, 72f, 150, 32), ActiveProcessor.GetProcessorType());
            if (!isSmallOptics)
            {
                if (GUI.Button(new Rect(475f, 124f, 150, 48), ToggleAperatureIcon))
                {
                    aperature.Toggle();
                }
            }

            if (FlightGlobals.fetch.VesselTarget != null && ActiveProcessor && ActiveProcessor.GetProcessorType().Contains("Wide Field"))
            {
                GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleRight;
                GUI.Label(new Rect(425f, 188f, 150, 32), "Store Image:");
                if (GUI.Button(new Rect(585f, 188f, 32, 32), SaveScreenshotTexture))
                {
                    //DisplayText("Saved screenshot to " + opticsModule.GetTex(true, targetName));
                    Notification = " Screenshot saved to " + WriteTextureToDrive(CameraModule.TakeScreenshot(ActiveProcessor));
                    timer        = 0f;
                }
            }
            else
            {
                GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter;
                GUI.Label(new Rect(475f, 188f, 150, 32), "Imaging not available.");
            }
            if (FlightGlobals.fetch.VesselTarget != null && ActiveProcessor && HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX)
            {
                GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleRight;
                GUI.Label(new Rect(425f, 252f, 150, 32), "Process Data:");
                if (GUI.Button(new Rect(585f, 252f, 32, 32), Atom6Icon))
                {
                    //DisplayText("Saved screenshot to " + opticsModule.GetTex(true, targetName));
                    //ActiveProcessor.GenerateScienceReport(TakeScreenshot(ActiveProcessor.GetType()));
                    try
                    {
                        Notification = ActiveProcessor.DoScience(GetTargetPos(FlightGlobals.fetch.VesselTarget.GetTransform().position, 500f), scienceMultiplier, CameraModule.FieldOfView, CameraModule.TakeScreenshot(ActiveProcessor));
                    }
                    catch (Exception e)
                    {
                        Notification = "An error occured. Please post that you're having this error on the official CactEye 2 thread on the Kerbal Forums.";
                        Debug.Log("CactEye 2: Exception 4: An error occured producing a science report!");
                        Debug.Log(e.ToString());
                    }

                    timer = 0f;
                }
            }
            else
            {
                GUI.skin.GetStyle("Label").alignment = TextAnchor.MiddleCenter;
                GUI.Label(new Rect(425f, 252f, 250, 32), "Data processing not available.");
            }

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            //Draw Processor controls in bottom center of display, with observation and screenshot buttons in center.
            DrawTargetPointer();

            if (ActiveProcessor)
            {
                //Close window down if we run out of power
                if (!ActiveProcessor.IsActive())
                {
                    //    Toggle();
                    //    ScreenMessages.PostScreenMessage("Image processor is out of power. Please restore power to telescope.", 6, ScreenMessageStyle.UPPER_CENTER);
                    ActiveProcessor = null;
                    Notification    = "Image Processor is out of power. Please restore power to telescope";
                    ScreenMessages.PostScreenMessage(Notification, 3f, ScreenMessageStyle.UPPER_CENTER);
                    timer = 0f;
                    Toggle();
                }

                //Zoom Feedback Label.
                string LabelZoom = "Zoom/Magnification: x";
                if (CameraModule.FieldOfView > 0.0064)
                {
                    LabelZoom += string.Format("{0:####0.0}", 64 / CameraModule.FieldOfView);
                }
                else
                {
                    LabelZoom += string.Format("{0:0.00E+0}", (64 / CameraModule.FieldOfView));
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft;
                GUILayout.Label(LabelZoom);
                GUILayout.EndHorizontal();

                //Zoom Slider Controls.
                GUILayout.BeginHorizontal();
                FieldOfView = GUILayout.HorizontalSlider(FieldOfView, 0f, 1f);
                CameraModule.FieldOfView = 0.5f * Mathf.Pow(4f - FieldOfView * (4f - Mathf.Pow(ActiveProcessor.GetMinimumFOV(), (1f / 3f))), 3);
                GUILayout.EndHorizontal();

                //Log spam
                //Debug.Log("CactEye 2: MinimumFOV = " + ActiveProcessor.GetMinimumFOV().ToString());
            }

            else
            {
                GUILayout.BeginHorizontal();
                GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft;
                GUILayout.Label("Processor not installed; optics module cannot function without an image processor.");
                GUILayout.EndHorizontal();
            }

            //Gyro GUI. Active only if the craft has an active gyro
            if (GyroEnabled)
            {
                //Gyro Slider Label
                GUILayout.BeginHorizontal();
                GUI.skin.GetStyle("Label").alignment = TextAnchor.UpperLeft;
                GUILayout.Label("Gyro Sensitivity:  " + GyroSensitivity.ToString("P") + " + minimum gyroscopic torgue.", GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();

                //Gyro Slider Controls.
                GUILayout.BeginHorizontal();
                GyroSensitivity = GUILayout.HorizontalSlider(GyroSensitivity, 0f, 1f, GUILayout.ExpandWidth(true));
                GUILayout.EndHorizontal();

                SetTorgue();
            }

            //Make the window draggable by the top bar only.
            GUI.DragWindow(new Rect(0, 0, WindowPosition.width, 16));
        }