private void InnerWindowOnGUI(int x) { Rect rect = windowRect.AtZero(); UnityGUIBugsFixer.OnGUI(); Find.WindowStack.currentlyDrawnWindow = this; if (doWindowBackground) { Widgets.DrawWindowBackground(rect); } 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); } if (Event.current.type == EventType.KeyDown && !Find.WindowStack.GetsInput(this)) { Event.current.Use(); } if (!optionalTitle.NullOrEmpty()) { GUI.Label(new Rect(Margin, Margin, windowRect.width, 25f), optionalTitle); } if (doCloseX && Widgets.CloseButtonFor(rect)) { Close(); } if (resizeable && Event.current.type != EventType.Repaint) { Rect lhs = resizer.DoResizeControl(windowRect); if (lhs != windowRect) { resizeLater = true; resizeLaterRect = lhs; } } Rect rect2 = rect.ContractedBy(Margin); if (!optionalTitle.NullOrEmpty()) { rect2.yMin += Margin + 25f; } GUI.BeginGroup(rect2); try { DoWindowContents(rect2.AtZero()); } catch (Exception ex) { Log.Error(string.Concat("Exception filling window for ", GetType(), ": ", ex)); } GUI.EndGroup(); if (resizeable && Event.current.type == EventType.Repaint) { resizer.DoResizeControl(windowRect); } if (doCloseButton) { Text.Font = GameFont.Small; if (Widgets.ButtonText(new Rect(rect.width / 2f - CloseButSize.x / 2f, rect.height - 55f, CloseButSize.x, CloseButSize.y), "CloseButton".Translate())) { Close(); } } if (KeyBindingDefOf.Cancel.KeyDownEvent && IsOpen) { OnCancelKeyPressed(); } if (draggable) { GUI.DragWindow(); } else if (Event.current.type == EventType.MouseDown) { Event.current.Use(); } ScreenFader.OverlayOnGUI(rect.size); Find.WindowStack.currentlyDrawnWindow = null; }
public virtual void WindowOnGUI() { if (resizeable) { if (resizer == null) { resizer = new WindowResizer(); } if (resizeLater) { resizeLater = false; windowRect = resizeLaterRect; } } windowRect = windowRect.Rounded(); Rect winRect = windowRect.AtZero(); windowRect = GUI.Window(ID, windowRect, delegate { UnityGUIBugsFixer.OnGUI(); Find.WindowStack.currentlyDrawnWindow = this; if (doWindowBackground) { Widgets.DrawWindowBackground(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); } if (Event.current.type == EventType.KeyDown && !Find.WindowStack.GetsInput(this)) { Event.current.Use(); } if (!optionalTitle.NullOrEmpty()) { GUI.Label(new Rect(Margin, Margin, windowRect.width, 25f), optionalTitle); } if (doCloseX && Widgets.CloseButtonFor(winRect)) { Close(); } if (resizeable && Event.current.type != EventType.Repaint) { Rect lhs = resizer.DoResizeControl(windowRect); if (lhs != windowRect) { resizeLater = true; resizeLaterRect = lhs; } } Rect rect = winRect.ContractedBy(Margin); if (!optionalTitle.NullOrEmpty()) { rect.yMin += Margin + 25f; } GUI.BeginGroup(rect); try { DoWindowContents(rect.AtZero()); } catch (Exception ex) { Log.Error("Exception filling window for " + GetType() + ": " + ex); } GUI.EndGroup(); if (resizeable && Event.current.type == EventType.Repaint) { resizer.DoResizeControl(windowRect); } if (doCloseButton) { Text.Font = GameFont.Small; float num = winRect.width / 2f; Vector2 closeButSize = CloseButSize; float x2 = num - closeButSize.x / 2f; float y = winRect.height - 55f; Vector2 closeButSize2 = CloseButSize; float x3 = closeButSize2.x; Vector2 closeButSize3 = CloseButSize; Rect rect2 = new Rect(x2, y, x3, closeButSize3.y); if (Widgets.ButtonText(rect2, "CloseButton".Translate())) { Close(); } } if (KeyBindingDefOf.Cancel.KeyDownEvent && IsOpen) { OnCancelKeyPressed(); } if (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); }