public void OnGUI()
 {
     GUI.depth = 100;
     if (LongEventHandler.ShouldWaitForEvent)
     {
         return;
     }
     UnityGUIBugsFixer.OnGUI();
     this.mouseCoveredByUI = false;
     if (Find.WindowStack.GetWindowAt(UI.MousePositionOnUIInverted) != null)
     {
         this.mouseCoveredByUI = true;
     }
     if (!this.AnythingPreventsCameraMotion)
     {
         if (Event.current.type == EventType.MouseDrag && Event.current.button == 2)
         {
             this.mouseDragVect = Event.current.delta;
             Event.current.Use();
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.FrameInteraction);
         }
         float num = 0f;
         if (Event.current.type == EventType.ScrollWheel)
         {
             num -= Event.current.delta.y * 0.1f;
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
         }
         if (KeyBindingDefOf.MapZoom_In.KeyDownEvent)
         {
             num += 2f;
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
         }
         if (KeyBindingDefOf.MapZoom_Out.KeyDownEvent)
         {
             num -= 2f;
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
         }
         this.desiredAltitude -= num * this.config.zoomSpeed * this.altitude / 12f;
         this.desiredAltitude  = Mathf.Clamp(this.desiredAltitude, 125f, 1100f);
         this.desiredRotation  = Vector2.zero;
         if (KeyBindingDefOf.MapDolly_Left.IsDown)
         {
             this.desiredRotation.x = -this.config.dollyRateKeys;
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
         }
         if (KeyBindingDefOf.MapDolly_Right.IsDown)
         {
             this.desiredRotation.x = this.config.dollyRateKeys;
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
         }
         if (KeyBindingDefOf.MapDolly_Up.IsDown)
         {
             this.desiredRotation.y = this.config.dollyRateKeys;
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
         }
         if (KeyBindingDefOf.MapDolly_Down.IsDown)
         {
             this.desiredRotation.y = -this.config.dollyRateKeys;
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
         }
         if (this.mouseDragVect != Vector2.zero)
         {
             this.mouseDragVect   *= CameraDriver.HitchReduceFactor;
             this.mouseDragVect.x  = this.mouseDragVect.x * -1f;
             this.desiredRotation += this.mouseDragVect * this.config.dollyRateMouseDrag;
             this.mouseDragVect    = Vector2.zero;
         }
         this.config.ConfigOnGUI();
     }
 }
Beispiel #2
0
        public override void WindowOnGUI()
        {
            if (this.resizeable)
            {
                if (this.resizer == null)
                {
                    this.resizer = new WindowResizer();
                }
                if (this.resizeLater)
                {
                    this.resizeLater = false;
                    this.windowRect  = this.resizeLaterRect;
                }
            }
            this.windowRect = this.windowRect.Rounded();
            Rect winRect = this.windowRect.AtZero();

            this.windowRect = GUI.Window(this.ID, this.windowRect, delegate(int x)
            {
                UnityGUIBugsFixer.OnGUI();
                Find.WindowStack.currentlyDrawnWindow = this;
                if (this.doWindowBackground)
                {
                    //DrawWindowBackground(winRect);
                }
                if (KeyBindingDefOf.Accept.KeyDownEvent)
                {
                    Find.WindowStack.Notify_PressedAccept();
                }
                if (UnityEngine.Event.current.type == UnityEngine.EventType.KeyDown && !Find.WindowStack.GetsInput(this))
                {
                    UnityEngine.Event.current.Use();
                }
                if (!this.optionalTitle.NullOrEmpty())
                {
                    GUI.Label(new Rect(this.Margin, this.Margin, this.windowRect.width, 25f), this.optionalTitle);
                }
                if (this.resizeable && UnityEngine.Event.current.type != UnityEngine.EventType.Repaint)
                {
                    Rect lhs = this.resizer.DoResizeControl(this.windowRect);
                    if (lhs != this.windowRect)
                    {
                        this.resizeLater     = true;
                        this.resizeLaterRect = lhs;
                    }
                }
                Rect rect = winRect;
                if (!this.optionalTitle.NullOrEmpty())
                {
                    rect.yMin += this.Margin + 25f;
                }
                GUI.BeginGroup(rect);
                try
                {
                    this.DoWindowContents(rect.AtZero());
                }
                catch (Exception ex)
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Exception filling window for ",
                        this.GetType(),
                        ": ",
                        ex
                    }), false);
                }
                GUI.EndGroup();
                if (this.resizeable && UnityEngine.Event.current.type == UnityEngine.EventType.Repaint)
                {
                    this.resizer.DoResizeControl(this.windowRect);
                }
                if (this.doCloseButton)
                {
                    Text.Font  = GameFont.Small;
                    Rect rect2 = new Rect(winRect.width / 2f - this.CloseButSize.x / 2f, winRect.height - 55f, this.CloseButSize.x, this.CloseButSize.y);
                    if (Widgets.ButtonText(rect2, "CloseButton".Translate(), true, false, true))
                    {
                        this.Close(true);
                    }
                }
                if (this.draggable)
                {
                    GUI.DragWindow();
                }
                else if (UnityEngine.Event.current.type == UnityEngine.EventType.MouseDown)
                {
                    UnityEngine.Event.current.Use();
                }
                ScreenFader.OverlayOnGUI(winRect.size);
                Find.WindowStack.currentlyDrawnWindow = null;
            }, string.Empty, Widgets.EmptyStyle);
        }
 public void OnGUI()
 {
     GUI.depth = 100;
     if (!LongEventHandler.ShouldWaitForEvent)
     {
         UnityGUIBugsFixer.OnGUI();
         this.mouseCoveredByUI = false;
         if (Find.WindowStack.GetWindowAt(UI.MousePositionOnUIInverted) != null)
         {
             this.mouseCoveredByUI = true;
         }
         if (!this.AnythingPreventsCameraMotion)
         {
             if (Event.current.type == EventType.MouseDrag && Event.current.button == 2)
             {
                 this.mouseDragVect = Event.current.delta;
                 Event.current.Use();
                 PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.FrameInteraction);
             }
             float num = 0f;
             if (Event.current.type == EventType.ScrollWheel)
             {
                 float   num2  = num;
                 Vector2 delta = Event.current.delta;
                 num = (float)(num2 - delta.y * 0.10000000149011612);
                 PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
             }
             if (KeyBindingDefOf.MapZoomIn.KeyDownEvent)
             {
                 num = (float)(num + 2.0);
                 PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
             }
             if (KeyBindingDefOf.MapZoomOut.KeyDownEvent)
             {
                 num = (float)(num - 2.0);
                 PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
             }
             this.desiredAltitude -= (float)(num * 2.5999999046325684 * this.altitude / 12.0);
             this.desiredAltitude  = Mathf.Clamp(this.desiredAltitude, 125f, 1100f);
             this.desiredRotation  = Vector2.zero;
             if (KeyBindingDefOf.MapDollyLeft.IsDown)
             {
                 this.desiredRotation.x = -170f;
                 PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
             }
             if (KeyBindingDefOf.MapDollyRight.IsDown)
             {
                 this.desiredRotation.x = 170f;
                 PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
             }
             if (KeyBindingDefOf.MapDollyUp.IsDown)
             {
                 this.desiredRotation.y = 170f;
                 PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
             }
             if (KeyBindingDefOf.MapDollyDown.IsDown)
             {
                 this.desiredRotation.y = -170f;
                 PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorldCameraMovement, KnowledgeAmount.SpecificInteraction);
             }
             if (this.mouseDragVect != Vector2.zero)
             {
                 this.mouseDragVect   *= CameraDriver.HitchReduceFactor;
                 this.mouseDragVect.x *= -1f;
                 this.desiredRotation += this.mouseDragVect * 25f;
                 this.mouseDragVect    = Vector2.zero;
             }
         }
     }
 }