Пример #1
0
        protected override void DrawWindowPre(int id)
        {
            WindowCaption = SCANuiUtil.toDMS(spotmap.CenteredLat, spotmap.CenteredLong);

            if (IsResizing && !inRepaint())
            {
                if (Input.GetMouseButtonUp(0))
                {
                    double scale = spotmap.MapScale;
                    IsResizing = false;
                    if (resizeW < WindowSize_Min.x)
                    {
                        resizeW = WindowSize_Min.x;
                    }
                    else if (resizeW > WindowSize_Max.x)
                    {
                        resizeW = WindowSize_Max.x;
                    }
                    if (resizeH < WindowSize_Min.y)
                    {
                        resizeH = WindowSize_Min.y;
                    }
                    else if (resizeH > WindowSize_Max.y)
                    {
                        resizeH = WindowSize_Max.y;
                    }

                    spotmap.setSize((int)resizeW, (int)resizeH);
                    spotmap.MapScale = scale;
                    spotmap.centerAround(spotmap.CenteredLong, spotmap.CenteredLat);
                    spotmap.resetMap(spotmap.MType, false);
                }
                else
                {
                    float yy = Input.mousePosition.y;
                    float xx = Input.mousePosition.x;
                    if (Input.mousePosition.y < 0)
                    {
                        yy = 0;
                    }
                    if (Input.mousePosition.x < 0)
                    {
                        xx = 0;
                    }

                    resizeH    += dragStart.y - yy;
                    dragStart.y = yy;
                    resizeW    += xx - dragStart.x;
                    dragStart.x = xx;
                }
                if (Event.current.isMouse)
                {
                    Event.current.Use();
                }
            }

            //Lock space center click through
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    InputLockManager.RemoveControlLock(lockID);
                    controlLock = false;
                }
            }

            //Lock tracking scene click through
            if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    InputLockManager.RemoveControlLock(lockID);
                    controlLock = false;
                }
            }
        }