Beispiel #1
0
 public void OnGUI()
 {
     try
     {
         if (!this.destroyed)
         {
             GUI.depth = 50;
             UI.ApplyUIScale();
             LongEventHandler.LongEventsOnGUI();
             if (LongEventHandler.ShouldWaitForEvent)
             {
                 ScreenFader.OverlayOnGUI(new Vector2((float)UI.screenWidth, (float)UI.screenHeight));
             }
             else
             {
                 this.uiRoot.UIRootOnGUI();
                 ScreenFader.OverlayOnGUI(new Vector2((float)UI.screenWidth, (float)UI.screenHeight));
             }
         }
     }
     catch (Exception e)
     {
         Log.Notify_Exception(e);
         throw;
     }
 }
Beispiel #2
0
 public void OnGUI()
 {
     try
     {
         if (!this.destroyed)
         {
             GUI.depth = 50;
             UI.ApplyUIScale();
             LongEventHandler.LongEventsOnGUI();
             if (LongEventHandler.ShouldWaitForEvent)
             {
                 ScreenFader.OverlayOnGUI(new Vector2((float)UI.screenWidth, (float)UI.screenHeight));
             }
             else
             {
                 this.uiRoot.UIRootOnGUI();
                 ScreenFader.OverlayOnGUI(new Vector2((float)UI.screenWidth, (float)UI.screenHeight));
             }
         }
     }
     catch (Exception arg)
     {
         Log.Error("Root level exception in OnGUI(): " + arg, false);
     }
 }
Beispiel #3
0
 public void OnGUI()
 {
     try
     {
         if (destroyed)
         {
             return;
         }
         GUI.depth = 50;
         UI.ApplyUIScale();
         LongEventHandler.LongEventsOnGUI();
         if (LongEventHandler.ShouldWaitForEvent)
         {
             ScreenFader.OverlayOnGUI(new Vector2(UI.screenWidth, UI.screenHeight));
             return;
         }
         uiRoot.UIRootOnGUI();
         ScreenFader.OverlayOnGUI(new Vector2(UI.screenWidth, UI.screenHeight));
         if (Find.CameraDriver != null && Find.CameraDriver.isActiveAndEnabled)
         {
             Find.CameraDriver.CameraDriverOnGUI();
         }
         if (Find.WorldCameraDriver != null && Find.WorldCameraDriver.isActiveAndEnabled)
         {
             Find.WorldCameraDriver.WorldCameraDriverOnGUI();
         }
     }
     catch (Exception arg)
     {
         Log.Error("Root level exception in OnGUI(): " + arg);
     }
 }
        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;
        }
            internal void <> m__0(int x)
            {
                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 && Widgets.CloseButtonFor(this.winRect))
                {
                    this.$this.Close(true);
                }
                if (this.$this.resizeable && 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 && 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;
            }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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 += (float)(this.Margin + 25.0);
                }
                GUI.BeginGroup(rect);
                try
                {
                    this.DoWindowContents(rect.AtZero());
                }
                catch (Exception ex)
                {
                    Log.Error("Exception filling window for " + base.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;
                    double num            = winRect.width / 2.0;
                    Vector2 closeButSize  = this.CloseButSize;
                    double x2             = num - closeButSize.x / 2.0;
                    double y              = winRect.height - 55.0;
                    Vector2 closeButSize2 = this.CloseButSize;
                    float x3              = closeButSize2.x;
                    Vector2 closeButSize3 = this.CloseButSize;
                    Rect rect2            = new Rect((float)x2, (float)y, x3, closeButSize3.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);
        }
Beispiel #8
0
        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)
            {
                Profiler.BeginSample("WindowOnGUI: " + this.GetType().Name);
                UnityGUIBugsFixer.OnGUI();
                Find.WindowStack.currentlyDrawnWindow = this;
                if (this.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 (!this.optionalTitle.NullOrEmpty())
                {
                    GUI.Label(new Rect(this.Margin, this.Margin, this.windowRect.width, 25f), this.optionalTitle);
                }
                if (this.doCloseX)
                {
                    if (Widgets.CloseButtonFor(winRect))
                    {
                        this.Close(true);
                    }
                }
                if (this.resizeable)
                {
                    if (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(),
                        ": ",
                        ex
                    }), false);
                }
                GUI.EndGroup();
                if (this.resizeable)
                {
                    if (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 (KeyBindingDefOf.Cancel.KeyDownEvent && this.IsOpen)
                {
                    this.OnCancelKeyPressed();
                }
                if (this.draggable)
                {
                    GUI.DragWindow();
                }
                else if (Event.current.type == EventType.MouseDown)
                {
                    Event.current.Use();
                }
                ScreenFader.OverlayOnGUI(winRect.size);
                Find.WindowStack.currentlyDrawnWindow = null;
                Profiler.EndSample();
            }, "", Widgets.EmptyStyle);
        }