Example #1
0
        public UiBackground(GraphicsDevice graphics, Blob images)
        {
            _images = images;
            TopLeft = new UiTexture2D(context => Texture2D.FromStream(context.Graphics.GraphicsDevice, GameContext.ContentLoader.ReadStream(_images.GetString("topLeft"))));
            TopLeft.TakeRender();

            TopMiddle = new UiTexture2D(context => Texture2D.FromStream(context.Graphics.GraphicsDevice, GameContext.ContentLoader.ReadStream(_images.GetString("topMiddle"))));
            TopMiddle.TakeRender();

            TopRight = new UiTexture2D(context => Texture2D.FromStream(context.Graphics.GraphicsDevice, GameContext.ContentLoader.ReadStream(_images.GetString("topRight"))));
            TopRight.TakeRender();

            MiddleLeft = new UiTexture2D(context => Texture2D.FromStream(context.Graphics.GraphicsDevice, GameContext.ContentLoader.ReadStream(_images.GetString("middleLeft"))));
            MiddleLeft.TakeRender();

            MiddleMiddle = new UiTexture2D(context => Texture2D.FromStream(context.Graphics.GraphicsDevice, GameContext.ContentLoader.ReadStream(_images.GetString("middleMiddle"))));
            MiddleMiddle.TakeRender();

            MiddleRight = new UiTexture2D(context => Texture2D.FromStream(context.Graphics.GraphicsDevice, GameContext.ContentLoader.ReadStream(_images.GetString("middleRight"))));
            MiddleRight.TakeRender();

            BottomLeft = new UiTexture2D(context => Texture2D.FromStream(context.Graphics.GraphicsDevice, GameContext.ContentLoader.ReadStream(_images.GetString("bottomLeft"))));
            BottomLeft.TakeRender();

            BottomMiddle = new UiTexture2D(context => Texture2D.FromStream(context.Graphics.GraphicsDevice, GameContext.ContentLoader.ReadStream(_images.GetString("bottomMiddle"))));
            BottomMiddle.TakeRender();

            BottomRight = new UiTexture2D(context => Texture2D.FromStream(context.Graphics.GraphicsDevice, GameContext.ContentLoader.ReadStream(_images.GetString("bottomRight"))));
            BottomRight.TakeRender();

            if (images.Contains("topLeftOffset"))
            {
                TopLeftOffset = images.GetBlob("topLeftOffset").GetVector2F().ToVector2();
            }

            if (images.Contains("bottomRightOffset"))
            {
                BottomRightOffset = images.GetBlob("bottomRightOffset").GetVector2F().ToVector2();
            }

            if (images.Contains("topLeftPadding"))
            {
                TopLeftPadding = images.GetBlob("topLeftPadding").GetVector2F().ToVector2();
            }

            if (images.Contains("bottomRightPadding"))
            {
                BottomRightPadding = images.GetBlob("bottomRightPadding").GetVector2F().ToVector2();
            }
        }
Example #2
0
 public void SetCaret(uint width = 1)
 {
     _caretHeight = (uint)Math.Ceiling(_font.MeasureString("W").Y - 4);
     _caret       = new UiTexture2D(context => Helpers.GetTexture(context, width, _caretHeight));
     _caret.TakeRender();
 }