Example #1
0
 public virtual void Update()
 {
     if (this.Parent == null)
     {
         UIView.mouseDownHandled     = false;
         UIView.mouseUpHandled       = false;
         UIView.gameMouseOverwritten = false;
     }
     this.mouseForChildrenHandled = false;
     if (this.Visible)
     {
         for (int i = 0; i < this.children.Count; i++)
         {
             UIView uIView = this.children[this.children.Count - 1 - i];
             if (uIView.UpdateWhenOutOfBounds || uIView.InParent())
             {
                 this.children[this.children.Count - 1 - i].Update();
             }
         }
         while (this.childrenToRemove.Count > 0)
         {
             this.children.Remove(this.childrenToRemove[0]);
             this.childrenToRemove.RemoveAt(0);
         }
         if ((UIView.exclusiveControl == null && this.Parent == null) || this == UIView.exclusiveControl)
         {
             this.HandleMouseInput();
         }
     }
 }
Example #2
0
 public virtual void Draw(SpriteBatch spriteBatch)
 {
     if (this.Visible)
     {
         int childCount = this.ChildCount;
         for (int i = 0; i < this.ChildCount; i++)
         {
             if (this.ChildCount != childCount)
             {
                 return;
             }
             UIView uIView = this.children[i];
             if ((uIView.UpdateWhenOutOfBounds || uIView.InParent()) && uIView.Visible)
             {
                 uIView.Draw(spriteBatch);
             }
         }
     }
 }
Example #3
0
 public virtual void Draw(SpriteBatch spriteBatch)
 {
     if (this.Visible)
     {
         int childCount = this.ChildCount;
         for (int i = 0; i < this.ChildCount; i++)
         {
             if (this.ChildCount != childCount)
             {
                 return;
             }
             UIView uIView = this.children[i];
             if ((uIView.UpdateWhenOutOfBounds || uIView.InParent()) && uIView.Visible)
             {
                 uIView.Draw(spriteBatch);
             }
         }
         // Debug Draw UIView area.
         //if(Parent != null)
         //{
         //	spriteBatch.Draw(Main.magicPixel, new Rectangle((int)(Position.X + Parent.X), (int)(Position.Y + Parent.Y), (int)Width, (int)Height), foregroundColor * 0.6f);
         //}
     }
 }
Example #4
0
 private void HandleMouseInput()
 {
     for (int i = 0; i < this.children.Count; i++)
     {
         UIView uIView = this.children[this.children.Count - 1 - i];
         if (uIView.Visible && (uIView.Parent == null || uIView.UpdateWhenOutOfBounds || (uIView.InParent() && (uIView.Parent.MouseInside || uIView.Parent.UpdateWhenOutOfBounds) && !uIView.Parent.mouseForChildrenHandled)))
         {
             uIView.HandleMouseInput();
         }
     }
     if (this.MouseInside)
     {
         EventHandler arg_8F_0 = this.onMouseLeave;
         if (this.Parent != null)
         {
             this.Parent.mouseForChildrenHandled = true;
             if (this.OverridesMouse)
             {
                 this.OverWriteGameMouseInput();
             }
         }
         if (this.onHover != null)
         {
             this.onHover(this, new EventArgs());
         }
         if (!this.mousePreviouslyIn && this.onMouseEnter != null)
         {
             this.onMouseEnter(this, new EventArgs());
         }
         if (!UIView.MousePrevLeftButton && UIView.MouseLeftButton)
         {
             this.leftButtonDown = true;
             if (this.onMouseDown != null && !UIView.mouseDownHandled)
             {
                 this.onMouseDown(this, 0);
             }
         }
         if (UIView.MousePrevLeftButton && !UIView.MouseLeftButton)
         {
             if (this.onMouseUp != null && !UIView.mouseUpHandled)
             {
                 this.onMouseUp(this, 0);
             }
             if (this.leftButtonDown && this.onLeftClick != null)
             {
                 this.onLeftClick(this, EventArgs.Empty);
             }
         }
         if (!UIView.MousePrevRightButton && UIView.MouseRightButton)
         {
             this.rightButtonDown = true;
             if (this.onMouseDown != null)
             {
                 this.onMouseDown(this, 1);
             }
         }
         if (UIView.MousePrevRightButton && !UIView.MouseRightButton)
         {
             if (this.onMouseUp != null)
             {
                 this.onMouseUp(this, 1);
             }
             if (this.rightButtonDown && this.onRightClick != null)
             {
                 this.onRightClick(this, EventArgs.Empty);
             }
         }
         this.mousePreviouslyIn = true;
     }
     else
     {
         EventHandler arg_1E5_0 = this.onMouseLeave;
         if (this.mousePreviouslyIn && this.onMouseLeave != null)
         {
             this.onMouseLeave(this, new EventArgs());
         }
         this.mousePreviouslyIn = false;
     }
     if (!UIView.MouseLeftButton)
     {
         this.leftButtonDown = false;
     }
     if (!UIView.MouseRightButton)
     {
         this.rightButtonDown = false;
     }
 }