public void OnGUI() { GUI.depth = 100; if (!LongEventHandler.ShouldWaitForEvent && Find.VisibleMap != null) { 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(); } float num = 0f; if (Event.current.type == EventType.ScrollWheel) { float num2 = num; Vector2 delta = Event.current.delta; num = (float)(num2 - delta.y * 0.34999999403953552); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.CameraZoom, KnowledgeAmount.TinyInteraction); } if (KeyBindingDefOf.MapZoomIn.KeyDownEvent) { num = (float)(num + 4.0); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.CameraZoom, KnowledgeAmount.SmallInteraction); } if (KeyBindingDefOf.MapZoomOut.KeyDownEvent) { num = (float)(num - 4.0); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.CameraZoom, KnowledgeAmount.SmallInteraction); } this.desiredSize -= (float)(num * 2.5999999046325684 * this.rootSize / 35.0); if (this.desiredSize < 11.0) { this.desiredSize = 11f; } if (this.desiredSize > 60.0) { this.desiredSize = 60f; } this.desiredDolly = Vector3.zero; if (KeyBindingDefOf.MapDollyLeft.IsDown) { this.desiredDolly.x = (float)(0.0 - this.config.dollyRateKeys); } if (KeyBindingDefOf.MapDollyRight.IsDown) { this.desiredDolly.x = this.config.dollyRateKeys; } if (KeyBindingDefOf.MapDollyUp.IsDown) { this.desiredDolly.y = this.config.dollyRateKeys; } if (KeyBindingDefOf.MapDollyDown.IsDown) { this.desiredDolly.y = (float)(0.0 - this.config.dollyRateKeys); } if (this.mouseDragVect != Vector2.zero) { this.mouseDragVect *= CameraDriver.HitchReduceFactor; this.mouseDragVect.x *= -1f; this.desiredDolly += this.mouseDragVect * this.config.dollyRateMouseDrag; this.mouseDragVect = Vector2.zero; } } } }
public virtual 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) { Widgets.DrawWindowBackground(winRect); } if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) { Find.WindowStack.Notify_PressedEscape(); } if (Event.current.type == EventType.MouseDown) { Find.WindowStack.Notify_ClickedInsideWindow(this); } if (Event.current.type == EventType.KeyDown && !Find.WindowStack.GetsInput(this)) { Event.current.Use(); } if (!this.optionalTitle.NullOrEmpty()) { GUI.Label(new Rect(this.Margin, this.Margin, this.windowRect.width, 25f), this.optionalTitle); } if (this.doCloseX && Widgets.CloseButtonFor(winRect)) { this.Close(true); } if (this.resizeable && Event.current.type != EventType.Repaint) { Rect lhs = this.resizer.DoResizeControl(this.windowRect); if (lhs != this.windowRect) { this.resizeLater = true; this.resizeLaterRect = lhs; } } Rect rect = winRect.ContractedBy(this.Margin); 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().ToString(), ": ", ex })); } GUI.EndGroup(); if (this.resizeable && Event.current.type == 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.closeOnEscapeKey && Event.current.type == EventType.KeyDown && (Event.current.keyCode == KeyCode.Escape || Event.current.keyCode == KeyCode.Return)) { this.Close(true); Event.current.Use(); } if (this.draggable) { GUI.DragWindow(); } else if (Event.current.type == EventType.MouseDown) { Event.current.Use(); } ScreenFader.OverlayOnGUI(winRect.size); Find.WindowStack.currentlyDrawnWindow = null; }, string.Empty, Widgets.EmptyStyle); }
internal void <> m__0(int x) { Profiler.BeginSample("WindowOnGUI: " + this.$this.GetType().Name); UnityGUIBugsFixer.OnGUI(); Find.WindowStack.currentlyDrawnWindow = this.$this; if (this.$this.doWindowBackground) { Widgets.DrawWindowBackground(this.winRect); } if (KeyBindingDefOf.Cancel.KeyDownEvent) { Find.WindowStack.Notify_PressedCancel(); } if (KeyBindingDefOf.Accept.KeyDownEvent) { Find.WindowStack.Notify_PressedAccept(); } if (Event.current.type == EventType.MouseDown) { Find.WindowStack.Notify_ClickedInsideWindow(this.$this); } if (Event.current.type == EventType.KeyDown && !Find.WindowStack.GetsInput(this.$this)) { Event.current.Use(); } if (!this.$this.optionalTitle.NullOrEmpty()) { GUI.Label(new Rect(this.$this.Margin, this.$this.Margin, this.$this.windowRect.width, 25f), this.$this.optionalTitle); } if (this.$this.doCloseX) { if (Widgets.CloseButtonFor(this.winRect)) { this.$this.Close(true); } } if (this.$this.resizeable) { if (Event.current.type != EventType.Repaint) { Rect rect = this.$this.resizer.DoResizeControl(this.$this.windowRect); if (rect != this.$this.windowRect) { this.$this.resizeLater = true; this.$this.resizeLaterRect = rect; } } } Rect rect2 = this.winRect.ContractedBy(this.$this.Margin); if (!this.$this.optionalTitle.NullOrEmpty()) { rect2.yMin += this.$this.Margin + 25f; } GUI.BeginGroup(rect2); try { this.$this.DoWindowContents(rect2.AtZero()); } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception filling window for ", this.$this.GetType(), ": ", ex }), false); } GUI.EndGroup(); if (this.$this.resizeable) { if (Event.current.type == EventType.Repaint) { this.$this.resizer.DoResizeControl(this.$this.windowRect); } } if (this.$this.doCloseButton) { Text.Font = GameFont.Small; Rect rect3 = new Rect(this.winRect.width / 2f - this.$this.CloseButSize.x / 2f, this.winRect.height - 55f, this.$this.CloseButSize.x, this.$this.CloseButSize.y); if (Widgets.ButtonText(rect3, "CloseButton".Translate(), true, false, true)) { this.$this.Close(true); } } if (KeyBindingDefOf.Cancel.KeyDownEvent && this.$this.IsOpen) { this.$this.OnCancelKeyPressed(); } if (this.$this.draggable) { GUI.DragWindow(); } else if (Event.current.type == EventType.MouseDown) { Event.current.Use(); } ScreenFader.OverlayOnGUI(this.winRect.size); Find.WindowStack.currentlyDrawnWindow = null; Profiler.EndSample(); }