示例#1
0
 public Button(Interface parent, string text, int textSize, TextOrientation orientation, Vector2 position, Vector2 size, Color originColor, Color hoverColor, Color pressedColor,
               ButtonListSide side = ButtonListSide.LeftRight, bool hasBorder = true, bool addToUI = true, bool addToFront = false)
     : base(parent, side, true, addToUI, addToFront)
 {
     Position       = position;
     Size           = size;
     this.hasBorder = hasBorder;
     Init(text, textSize, orientation, originColor, hoverColor, pressedColor);
 }
 public ListBox(Interface parent, int textSize, TextOrientation to, Vector2 position, Vector2 size, Color?textColor, Color?innerColor, Color?outerColor, Color?selectColor,
                ButtonListSide side = ButtonListSide.TopBottom, bool pollEvents = true, bool addToUI = true, bool isFrontElement = false)
     : base(parent, position, size, side, pollEvents, addToUI, isFrontElement)
 {
     front            = isFrontElement;
     this.textSize    = textSize;
     orientation      = to;
     items            = new List <Label>();
     selected         = new Dictionary <Label, bool>();
     this.selectColor = selectColor.HasValue ? selectColor.Value : UI.BlueHighlightColor;
     this.textColor   = textColor.HasValue ? textColor.Value : Color.Black;
     surfaceColor     = new Color[] { innerColor.HasValue?innerColor.Value : UI.BGColor };
     borderColor      = new Color[] { outerColor.HasValue?outerColor.Value : UI.SurfaceColor };
     singleHeight     = UI.Font.MeasureString(textSize, "Log").Y + 2;
 }
示例#3
0
 public ButtonList(Element parent, ButtonListSide side, Vector2 origin, Vector2 buttonSize, int textSize)
 {
     Side              = side;
     buttons           = new List <Button>();
     this.parent       = parent;
     originPos         = origin;
     actualPos         = origin;
     this.buttonSize   = buttonSize;
     this.textSize     = textSize;
     down              = true;
     right             = true;
     reversed          = false;
     Showing           = false;
     bgColArr          = new Color[] { Color.White };
     buttonListOverlay = UI.BGColor;
 }
示例#4
0
        public TextBox(Interface parent, string originText, int textSize, int?pointerBlinkInterval, Vector2 position, Vector2 size, Color?textColor, Color?innerColor, Color?outerColor, Color?pointerColor,
                       ButtonListSide side = ButtonListSide.TopBottom, bool pollEvents = true, bool addToUI = true, bool isFrontElement = false)
            : base(parent, position, size, side, pollEvents, addToUI, isFrontElement)
        {
            tbText = new Text(originText, position, textColor.HasValue ? textColor.Value : Color.Black, TextOrientation.Left, textSize, 0);
            SetText(originText);
            pointerPos = tbText.String.Length > 0 ? tbText.String.Length : 0;
            this.pointerBlinkInterval = pointerBlinkInterval.HasValue ? pointerBlinkInterval.Value : 12;
            pointerBlinkCounter       = 0;
            pointerShowing            = false;
            active            = false;
            surfaceColor      = new Color[] { innerColor.HasValue?innerColor.Value : UI.BGColor };
            borderColor       = new Color[] { outerColor.HasValue?outerColor.Value : UI.SurfaceColor };
            this.pointerColor = new Color[] { pointerColor.HasValue?pointerColor.Value : Color.Black };

            keyCombos = new KeyComboList(30, 0);
            keyCombos.AddKeyCombo(new Keys[] { Keys.Left }, "LEFT");
            keyCombos.AddKeyCombo(new Keys[] { Keys.Right }, "RIGHT");
            keyCombos.AddKeyCombo(new Keys[] { Keys.Enter }, "ENTER");
            keyCombos.AddKeyCombo(new Keys[] { Keys.Back }, "BACK");

            Clicked           += (sender) => { active = true; };
            ResetState        += (sender) => { active = false; };
            LeftButtonPressed += (sender) => {
                if (pointerPos > 0)
                {
                    pointerPos--;
                }
                pointerShowing = true;
            };
            RightButtonPressed += (sender) => {
                if (pointerPos < tbText.String.Length)
                {
                    pointerPos++;
                }
                pointerShowing = true;
            };
            BackPressed += (sender) => {
                if (pointerPos > 0)
                {
                    SetText(tbText.String.Remove(pointerPos - 1, 1));
                    pointerPos--;
                    pointerShowing = true;
                }
            };
        }
        public ProgressBar(Interface parent, Vector2 position, Vector2 size, double min, double max, double originValue, int textSize, bool showText, Color?outer, Color?inner, Color?value, Color?text,
                           ButtonListSide side = ButtonListSide.LeftRight, bool pollEvents = true, bool addToUI = true, bool isFrontElement = false)
            : base(parent, position, size, side, pollEvents, addToUI, isFrontElement)
        {
            MinValue = min;
            MaxValue = max;
            Value    = originValue;
            ShowText = showText;

            valueText = new Text("", Vector2.Zero, text.HasValue ? text.Value : Color.Black, TextOrientation.Center, textSize, 0);
            SetText();

            borderColor  = new Color[] { outer.HasValue?outer.Value : UI.BGColor };
            surfaceColor = new Color[] { inner.HasValue?inner.Value : UI.SurfaceColor };
            valueColor   = new Color[] { value.HasValue?value.Value : UI.BlueHighlightColor };
            ValueColor   = valueColor[0];
        }
 private void Init(Interface parent, Vector2 position, Vector2 size, Vector2 origin, ButtonListSide side, bool pollEvents, bool addToUI, bool isFrontElement)
 {
     if (parent != null)
     {
         ParentInterface = parent;
     }
     else
     {
         ParentInterface = UI.CurrentInterface;
     }
     Position      = position;
     Size          = size;
     Origin        = origin;
     EventsEnabled = pollEvents;
     if (addToUI && !isFrontElement)
     {
         UI.AddBackElement(this, ParentInterface);
     }
     else if (addToUI)
     {
         UI.AddFrontElement(this, ParentInterface);
     }
     DrawEnabled     = true;
     ClickButtonList = new ButtonList(this, side, position, new Vector2(200, 20), 12);
     HoverButtonList = new ButtonList(this, side, position, new Vector2(200, 20), 12);
 }
 public Element(Interface parent, ButtonListSide side, bool pollEvents = true, bool addToUI = true, bool isFrontElement = false)
 {
     Init(parent, Vector2.Zero, new Vector2(1), Vector2.Zero, side, pollEvents, addToUI, isFrontElement);
 }
 public Element(Interface parent, Vector2 position, Vector2 size, Vector2 origin, ButtonListSide side, bool pollEvents = true, bool addToUI = true, bool isFrontElement = false)
 {
     Init(parent, position, size, origin, side, pollEvents, addToUI, isFrontElement);
 }
示例#9
0
 public Separator(Interface parent, Vector2 position, Vector2 size, Color?surfaceColor, Color?lineColor, bool down = false, ButtonListSide side = ButtonListSide.LeftRight, bool pollEvents = true, bool addToUI = true, bool isFrontElement = true)
     : base(parent, position, size, side, pollEvents, addToUI, isFrontElement)
 {
     this.down         = down;
     this.surfaceColor = new Color[] { surfaceColor.HasValue?surfaceColor.Value : UI.SurfaceColor };
     this.lineColor    = new Color[] { lineColor.HasValue?lineColor.Value : UI.SurfacePressedColor };
 }
 public TextureButton(Interface parent, Texture2D texture, Vector2 position, Vector2 size, Vector2 bgOffset, Color?origin, Color?hover, Color?pressed, bool overlayTexture, ButtonListSide side = ButtonListSide.LeftRight, bool hasBorder = true, bool pollEvents = true, bool addToUI = true, bool isFrontElement = false)
     : base(parent, side, pollEvents, addToUI, isFrontElement)
 {
     BGOffset       = bgOffset;
     Position       = position;
     Size           = size;
     this.hasBorder = hasBorder;
     OverlayTexture = overlayTexture;
     Init(texture, origin.HasValue ? origin.Value : UI.BGColor, hover.HasValue ? hover.Value : UI.BGHoverColor, pressed.HasValue ? pressed.Value : UI.BGPressedColor);
 }
示例#11
0
 public Label(Interface parent, string text, int textSize, TextOrientation orientation, Vector2 position, Vector2 size, Color textColor, Color bgColor, ButtonListSide side = ButtonListSide.LeftRight, bool addToUI = true, bool addToFront = false)
     : base(parent, side, true, addToUI, addToFront)
 {
     Orientation = orientation;
     Color       = bgColor;
     Position    = position;
     Size        = size;
     Init(text, textSize, textColor);
 }