Exemple #1
0
        void Update()
        {
            if (showWindow)
            {
                if (HighLogic.LoadedSceneIsFlight)
                {
                    /// TODO: Handle refresh of application launcher when switching ships
                    if (FlightGlobals.ActiveVessel != null)
                    {
                        if (thisVessel == null)
                        {
                            thisVessel = FlightGlobals.ActiveVessel;
                        }
                        if (thisVessel != FlightGlobals.ActiveVessel)
                        {
                            thisVessel = FlightGlobals.ActiveVessel;
                        }
                    }
                    if (toolbarPanel.loopPanel.activeSelf)
                    {
                        toolbarPanel.rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 400f);
                    }

                    toolbarPanel.rect.position = stockToolbarButton.GetAnchorUL() - new Vector3(toolbarPanel.rect.rect.width, toolbarPanel.rect.rect.height, 0f);
                }
                if (HighLogic.LoadedSceneIsEditor)
                {
                    if (stockToolbarButton != null)
                    {
                        toolbarPanel.rect.position = stockToolbarButton.GetAnchorUL();
                    }
                }
            }
        }
 public void ShowGUI()
 {
     kalkulatorUI.rect.position = toolbarButton.GetAnchorUL();
     kalkulatorUI.rect.position = new Vector3(kalkulatorUI.rect.position.x, kalkulatorUI.rect.position.y + ((kalkulatorUI.rect.rect.height / 2) * GameSettings.UI_SCALE));
     K3InfoWindow.SetActive(true);
     toolbarButton.SetTexture(GameDatabase.Instance.GetTexture("KerbalismCompanionCalculator/Icon/AppButton_active", false));
 }
        public void Open()
        {
            SafeHouse.Logger.SuperVerbose("KOSToolBarWindow: PROOF: Open()");

            float assumeStagingListWidth = 64f; // hardcoded for now.  Might try to see how to read it on the fly later.

            bool isTop = ApplicationLauncher.Instance.IsPositionedAtTop;

            if (launcherButton == null)
            {
                if (isTop)
                {
                    rectToFit  = new Rect(0, 0, UnityEngine.Screen.width - assumeStagingListWidth, UnityEngine.Screen.height);
                    windowRect = new Rect(UnityEngine.Screen.width, 0, 0, 0);
                }
                else
                {
                    rectToFit  = new Rect(0, 0, UnityEngine.Screen.width - assumeStagingListWidth, UnityEngine.Screen.height - assumeStagingListWidth);
                    windowRect = new Rect(UnityEngine.Screen.width, UnityEngine.Screen.height, 0, 0);
                }
                isOpen = true;
                return;
            }
            Vector3 launcherScreenCenteredPos = launcherButton.GetAnchorUL();

            // There has *got* to be a method somewhere in Unity that does this transformation
            // without having to hardcode the formula, but after wasting 5 hours searching
            // Unity docs and google and ILSpy, I give up trying to find it.  This formula is
            // probably sitting on top of fragile assumptions, but I give up on trying to find
            // the "right" way.  (The values returned by the  RectTransform appear to be using
            // screen pixel coords, but with the center of the screen being (0,0) rather than
            // one of the corners.  This does not appear to be any of the named reference
            // frames Unity docs talk about ("World", "Viewport", and "Screen")):
            //
            // If any other kOS devs want to try a hand at fighting the Unity docs to figure this
            // out, be my guest.  In the mean time, this is the hardcoded solution:
            float launcherScreenX = launcherScreenCenteredPos.x + UnityEngine.Screen.width / 2;
            float launcherScreenY = launcherScreenCenteredPos.y + UnityEngine.Screen.height / 2;

            // amount to pad on the right side depending on what's there on the screen:

            float fitWidth  = (isTop ? launcherScreenX : UnityEngine.Screen.width - assumeStagingListWidth);
            float fitHeight = (isTop ? UnityEngine.Screen.height : UnityEngine.Screen.height - launcherScreenY);

            // subset of the screen we'll clamp to stay within:
            rectToFit = new Rect(0, 0f, fitWidth, fitHeight);

            // Attempt to place the window at first in a position that would extend
            // outside the rectToFit, but at least establishes it at the correct corner
            // of the screen.  Later the auto-layout elsewhere in this class will shift
            // it as needed to obey rectToFit:
            float leftEdge = UnityEngine.Screen.width;
            float topEdge  = isTop ? 0f : UnityEngine.Screen.height;

            windowRect = new Rect(leftEdge, topEdge, 0, 0); // will resize and move upon first GUILayout-ing.

            isOpen = true;
        }
Exemple #4
0
 void Update()
 {
     if (showWindow && toolbarPanel)
     {
         if (HighLogic.LoadedSceneHasPlanetarium)
         {
             toolbarPanel.rect.position = stockToolbarButton.GetAnchorUL() - new Vector3(toolbarPanel.rect.rect.width + 50f, toolbarPanel.rect.rect.height, 0f);
         }
     }
 }
Exemple #5
0
 void Update()
 {
     if (showWindow && reactorPanel != null)
     {
         if (HighLogic.LoadedSceneIsFlight)
         {
             if (reactorPanel && stockToolbarButton)
             {
                 reactorPanel.rect.position = stockToolbarButton.GetAnchorUL() - new Vector3(reactorPanel.rect.rect.width, reactorPanel.rect.rect.height, 0f);
             }
         }
         if (HighLogic.LoadedSceneIsEditor)
         {
             if (stockToolbarButton != null)
             {
                 reactorPanel.rect.position = stockToolbarButton.GetAnchorUL();
             }
         }
     }
 }
Exemple #6
0
        void Update()
        {
            if (showWindow)
            {
                if (HighLogic.LoadedSceneIsFlight)
                {
                    /// TODO: Handle refresh of application launcher when switching ships
                    if (FlightGlobals.ActiveVessel != null)
                    {
                        if (thisVessel == null)
                        {
                            thisVessel = FlightGlobals.ActiveVessel;
                        }
                        if (thisVessel != FlightGlobals.ActiveVessel)
                        {
                            thisVessel = FlightGlobals.ActiveVessel;
                        }
                    }

                    if (toolbarPanel != null && stockToolbarButton != null)
                    {
                        if (toolbarPanel.loopPanel.activeSelf)
                        {
                            toolbarPanel.rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 400f);
                        }

                        toolbarPanel.rect.position = stockToolbarButton.GetAnchorUL() - new Vector3(
                            toolbarPanel.rect.rect.width * UIMasterController.Instance.uiScale,
                            toolbarPanel.rect.rect.height * UIMasterController.Instance.uiScale, 0f);
                    }
                }


                if (HighLogic.LoadedSceneIsEditor)
                {
                    if (stockToolbarButton != null)
                    {
                        //toolbarPanel.rect.localScale = new Vector3(UIMasterController.Instance.appCanvas.scaleFactor,
                        // UIMasterController.Instance.appCanvas.scaleFactor, UIMasterController.Instance.appCanvas.scaleFactor);

                        if (toolbarPanel.loopPanel.activeSelf)
                        {
                            toolbarPanel.rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 400f);
                        }
                        else
                        {
                            toolbarPanel.rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 200f);
                        }

                        toolbarPanel.rect.position = stockToolbarButton.GetAnchorUR() - new Vector3(toolbarPanel.rect.rect.width * UIMasterController.Instance.uiScale, 0f, 0f);
                    }
                }
            }
        }
Exemple #7
0
 void Update()
 {
     if (showWindow && reactorPanel != null)
     {
         if (HighLogic.LoadedSceneIsFlight)
         {
             if (reactorPanel && stockToolbarButton)
             {
                 reactorPanel.rect.position = stockToolbarButton.GetAnchorUL() - new Vector3(
                     reactorPanel.rect.rect.width * UIMasterController.Instance.uiScale,
                     reactorPanel.rect.rect.height * UIMasterController.Instance.uiScale, 0f);
             }
         }
         if (HighLogic.LoadedSceneIsEditor)
         {
             if (stockToolbarButton != null)
             {
                 reactorPanel.rect.position = stockToolbarButton.GetAnchorUL();
                 reactorPanel.rect.position = stockToolbarButton.GetAnchorUR() - new Vector3(reactorPanel.rect.rect.width * UIMasterController.Instance.uiScale, 0, 0);
             }
         }
     }
 }
Exemple #8
0
        void Open()
        {
            if (launcherButton == null)
            {
                toolbarWindow?.SetPosition(ApplicationLauncher.Instance.IsPositionedAtTop);
            }
            else
            {
                toolbarWindow?.SetPosition(ApplicationLauncher.Instance.IsPositionedAtTop,
                                           launcherButton.GetAnchorUL());
            }

            isOpen    = true;
            hoverStay = false;
        }