Esempio n. 1
0
 public GUIButton(Point centerPosition, Rectangle elementRestriction, string text, SpriteFont font, Color textColor, Texture2D[] tileSequence, ButtonAction ClickAction, bool consumeMouse = true, ButtonAction HoverAction = null, ButtonAction UnHoverAction = null)
 {
     this.ClickAction = ClickAction;
     if (HoverAction != null)
     {
         this.HoverAction = HoverAction;
     }
     else
     {
         this.HoverAction = delegate
         {
         };
     }
     if (UnHoverAction != null)
     {
         this.UnHoverAction = UnHoverAction;
     }
     else
     {
         this.UnHoverAction = new ButtonAction((e) => { });
     }
     if (tileSequence.Length != 6)
     {
         throw new Exception("GUI Button instantiated with incorrect tile sequence");
     }
     modularTextures = tileSequence;
     if (elementRestriction.Height * 3 > elementRestriction.Width)
     {
         tileSize  = elementRestriction.Width / 3;
         tileCount = 3;
     }
     else
     {
         tileSize  = elementRestriction.Height;
         tileCount = elementRestriction.Width / tileSize;
     }
     elementRectangle = new Rectangle(centerPosition.X - ((tileSize * tileCount) / 2), centerPosition.Y - (tileSize / 2), tileSize * tileCount, tileSize);
     textLabel        = new GUILabel(centerPosition, text, font, textColor, elementRectangle);
 }
Esempio n. 2
0
 public void UpdateText(string text)
 {
     textLabel = new GUILabel(elementRectangle.Center, text, textLabel.Font, textLabel.TextColor, elementRectangle);
 }