Exemple #1
0
        public UIButton(Vector2 size, Vector2 position, float scale = 1.0f)
            : base(size, position)
        {
            Colour = Color4.White;

            PaddingLeft = PaddingTop = PaddingRight = PaddingBottom = 4.0f * scale;

            myButtonSprite = new FrameSprite(Res.Get <Texture>("images_gui_panels"), scale)
            {
                SubrectSize           = new Vector2(16, 16),
                SubrectOffset         = new Vector2(32, 16),
                FrameTopLeftOffet     = new Vector2(4, 4),
                FrameBottomRightOffet = new Vector2(4, 4),
                Size = size
            };

            myLabel = new UILabel(Font.Large, scale);

            AddChild(myLabel);
        }
Exemple #2
0
        public UIWindow(Vector2 size, Vector2 position, float scale = 1.0f)
            : base(size, position)
        {
            myScale = scale;

            PaddingLeft   = 4.0f * scale;
            PaddingTop    = 20.0f * scale;
            PaddingRight  = 4.0f * scale;
            PaddingBottom = 4.0f * scale;

            myFrameSprite = new FrameSprite(Res.Get <Texture2D>("images_gui_panels"), scale)
            {
                SubrectSize           = new Vector2(32, 32),
                SubrectOffset         = new Vector2(0, 0),
                FrameTopLeftOffet     = new Vector2(4, 20),
                FrameBottomRightOffet = new Vector2(4, 4),
                Size = size
            };

            myTitleText = new UILabel(Font.Large, scale)
            {
                Position  = new Vector2(6 * scale - PaddingLeft, 4 * scale - PaddingTop),
                IsEnabled = false
            };

            AddChild(myTitleText);

            myCloseButton = new UIWindowCloseButton(new Vector2(size.X - 18.0f * scale - PaddingLeft, 2.0f * scale - PaddingTop), scale);

            myCloseButton.Click += delegate(object sender, OpenTK.Input.MouseButtonEventArgs e)
            {
                Close();
            };

            AddChild(myCloseButton);

            CanBringToFront = true;
            CanClose        = true;
            CanDrag         = true;
        }
Exemple #3
0
        public UITextBox(Vector2 size, Vector2 position, float scale = 1.0f)
            : base(size, position)
        {
            PaddingLeft = PaddingTop = PaddingRight = PaddingBottom = 4.0f * scale;

            mySprite = new FrameSprite(Res.Get <Texture>("images_gui_panels"), scale)
            {
                SubrectSize           = new Vector2(16, 16),
                SubrectOffset         = new Vector2(0, 32),
                FrameTopLeftOffet     = new Vector2(4, 4),
                FrameBottomRightOffet = new Vector2(4, 4),
                Size = size
            };

            myFont = Font.Large;
            myText = new UILabel(myFont, scale);
            AddChild(myText);

            CharacterLimit = (int)(InnerWidth / (myFont.CharWidth * scale));

            myUnderlineChar = new Sprite(scale * myFont.CharWidth, scale * 2.0f, OpenTK.Graphics.Color4.Black);
        }
Exemple #4
0
 public virtual void Draw(SpriteBatch spriteBatch)
 {
     FrameSprite?.Draw(spriteBatch, Position);
     Widgets.Draw(spriteBatch);
 }