public UIRenderPlane(UISpriteBatch batch, Promise<Texture2D> texture)
        {
            this.GD = batch.GraphicsDevice;
            this.Target = batch.GetBuffer();
            this.Texture = texture;
            this.Batch = batch;

            //GD.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;

            /** Switch the render target **/
            Batch.Pause();
            GD.SetRenderTarget(0, Target);
            GD.Clear(Color.TransparentBlack);
            Batch.Resume();

            /**
                batch.Pause();
                var buffer = batch.GetBuffer();
                var gd = GameFacade.GraphicsDevice;

                var renderTarget = gd.GetRenderTarget(0);
                gd.SetRenderTarget(0, buffer);
                batch.Resume();
                gd.render
                //gd.Clear(Color.TransparentBlack);**/
        }
Ejemplo n.º 2
0
 public override void Draw(UISpriteBatch batch)
 {
     for (int i = 0; i < 4; i++)
     {
         DrawMotive(batch, 20, 13 + 20 * i, i); //left side
         DrawMotive(batch, 120, 13 + 20 * i, i+4); //right side
     }
 }
Ejemplo n.º 3
0
        //public override void Update(TSOClient.Code.UI.Model.UpdateState state)
        //{
        //    base.Update(state);
        //    /** Hit test **/
        //    color = Color.White;
        //    if (HitTestArea(state, new Microsoft.Xna.Framework.Rectangle(0, 0, 50, 50)))
        //    {
        //    }
        //    //color
        //}
        public override void Draw(UISpriteBatch batch)
        {
            var whiteRectangle = new Texture2D(batch.GraphicsDevice, 1, 1);
            whiteRectangle.SetData(new[] { color });

            var pos = LocalRect(0, 0, 50, 50);
            batch.Draw(whiteRectangle, pos, Color.White);
        }
Ejemplo n.º 4
0
        public UIRenderPlane(UISpriteBatch batch, Promise<Texture2D> texture)
        {
            this.GD = batch.GraphicsDevice;
            this.Target = batch.GetBuffer();
            this.Texture = texture;
            this.Batch = batch;

            /** Switch the render target **/
            Batch.Pause();
            GD.SetRenderTarget(0, Target);
            GD.Clear(Color.TransparentBlack);
            Batch.Resume();
        }
Ejemplo n.º 5
0
 public override void Draw(UISpriteBatch batch)
 {
     DrawLocalTexture(batch, Background, new Vector2(0, 0));
     if (Icon != null)
     {
         if (Icon.Height > 48) //poor mans way of saying "special icon" eg floors
         {
             float scale = 37.0f / Math.Max(Icon.Height, Icon.Width);
             DrawLocalTexture(batch, Icon, new Rectangle(0, 0, Icon.Width, Icon.Height), new Vector2(2+((37-Icon.Width*scale)/2), 2 + ((37 - Icon.Height * scale) / 2)), new Vector2(scale, scale));
         }
         else
             DrawLocalTexture(batch, Icon, new Rectangle(0, 0, Icon.Width / 2, Icon.Height), new Vector2(2, 2));
     }
 }
Ejemplo n.º 6
0
        public UIRenderPlane(UISpriteBatch batch, Promise <Texture2D> texture)
        {
            this.GD      = batch.GraphicsDevice;
            this.Target  = batch.GetBuffer();
            this.Texture = texture;
            this.Batch   = batch;

            if (!UISpriteBatch.Invalidated)
            {
                /** Switch the render target **/
                Batch.Pause();
                GD.SetRenderTarget(0, Target);
                GD.Clear(Color.TransparentBlack);
                Batch.Resume();
            }
        }
Ejemplo n.º 7
0
        private void DrawMotive(UISpriteBatch batch, int x, int y, int motive)
        {
            double p = (MotiveValues[motive]+100)/200.0;
            Color barcol = new Color((byte)(57 * (1 - p)), (byte)(213 * p + 97 * (1 - p)), (byte)(49 * p + 90 * (1 - p)));
            Color bgcol = new Color((byte)(57 * p + 214*(1-p)), (byte)(97 * p), (byte)(90 * p));

            batch.Draw(Filler, LocalRect(x, y, 60, 5), bgcol);
            batch.Draw(Filler, LocalRect(x, y, (int)(60*p), 5), barcol);
            batch.Draw(Filler, LocalRect(x+(int)(60 * p), y, 1, 5), Color.Black);
            var style = TextStyle.DefaultLabel.Clone();
            style.Size = 8;

            var temp = style.Color;
            style.Color = Color.Black;
            DrawLocalString(batch, MotiveNames[motive], new Vector2(x+1, y - 12), style, new Rectangle(0, 0, 60, 12), TextAlignment.Center); //shadow

            style.Color = temp;
            DrawLocalString(batch, MotiveNames[motive], new Vector2(x, y - 13), style, new Rectangle(0, 0, 60, 12), TextAlignment.Center);
        }
        public override void PreDraw(UISpriteBatch batch)
        {
            lock (Children)
            {
                foreach (var child in Children)
                {
                    child.PreDraw(batch);
                }
            }

            /** If we have opacity, draw ourself to a texture so we can blend it later **/
            if (_HasOpacity)
            {
                Promise<Texture2D> bufferTexture = null;
                using (batch.WithBuffer(ref bufferTexture))
                {
                    lock (Children)
                    {
                        foreach (var child in Children)
                        {
                            child.Draw(batch);
                        }
                    }
                }

                AlphaBlendedScene = bufferTexture.Get();
            }
        }
Ejemplo n.º 9
0
        public override void Draw(UISpriteBatch SBatch)
        {
            if (Background != null)
            {
                Background.Draw(SBatch, this, 0, 0, m_Width, m_Height);
            }

            var percent = (m_Value - m_MinValue) / (m_MaxValue - m_MinValue);

            if (m_Value != 0 && Bar != null)
            {
                /** Draw progress bar **/
                var trackSize = m_Width - BarOffset.Right - BarMargin.Right;
                var barWidth = BarMargin.Right + (trackSize * percent);
                var barHeight = m_Height - BarOffset.Bottom;

                Bar.Draw(SBatch, this, BarOffset.Left, BarOffset.Y, barWidth, barHeight);
            }

            /** Draw value label **/
            if (Caption != null && CaptionStyle != null)
            {
                if (!UISpriteBatch.Invalidated)
                {
                    var displayPercent = Math.Round(percent * 100);
                    this.DrawLocalString(SBatch, string.Format(Caption, displayPercent), Vector2.Zero, CaptionStyle, m_Bounds, TextAlignment.Center | TextAlignment.Middle);
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="batch"></param>
        /// <param name="mtx"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (!Visible)
            {
                return;
            }

            /**
             * If opacity is not 100% we need to draw to a texture
             * and then paint that with our opacity value
             */
            if (_HasOpacity)
            {
                if (AlphaBlendedScene != null)
                {
                    batch.Draw(AlphaBlendedScene, Vector2.Zero, _BlendColor);
                }
                //texture.Dispose();
            }
            else
            {
                lock (Children)
                {
                    foreach (var child in Children)
                    {
                        child.Draw(batch);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Render
        /// </summary>
        /// <param name="batch"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (!Visible) { return; }

            if (m_DrawDirty)
            {
                ComputeDrawingCommands();
            }

            /** Can have a text box without a background **/
            if (m_BackgroundTex != null && NineSliceMargins != null)
            {
                NineSliceMargins.DrawOnto(batch, this, m_BackgroundTex, m_Width, m_Height);
            }
            if (m_BackgroundTexRef != null)
            {
                m_BackgroundTexRef.Draw(batch, this, 0, 0, m_Width, m_Height);
            }

            /**
             * Draw border
             */
            if (m_frameBlinkOn && m_frameBlink)
            {
                DrawingUtils.DrawBorder(batch, LocalRect(0, 0, m_Width, m_Height), 1, m_FrameTexture, Color.White);
            }

            /**
             * Draw text
             */
            foreach (var cmd in m_DrawCmds)
            {
                cmd.Draw(this, batch);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new UISpriteBatch(GraphicsDevice, 3);

            // TODO: use this.Content to load your game content here
            int Channel = Bass.BASS_StreamCreateFile("Sounds\\BUTTON.WAV", 0, 0, BASSFlag.BASS_DEFAULT);
            UISounds.AddSound(new UISound(0x01, Channel));

            GameFacade.MainFont = new TSOClient.Code.UI.Framework.Font();
            GameFacade.MainFont.AddSize(10, Content.Load<SpriteFont>("Fonts/ProjectDollhouse_10px"));
            GameFacade.MainFont.AddSize(12, Content.Load<SpriteFont>("Fonts/ProjectDollhouse_12px"));
            GameFacade.MainFont.AddSize(14, Content.Load<SpriteFont>("Fonts/ProjectDollhouse_14px"));
            GameFacade.MainFont.AddSize(16, Content.Load<SpriteFont>("Fonts/ProjectDollhouse_16px"));

            GameFacade.SoundManager = new TSOClient.Code.Sound.SoundManager();
            GameFacade.GameThread = Thread.CurrentThread;

            ScreenMgr = new ScreenManager(this, Content.Load<SpriteFont>("ComicSans"),
                Content.Load<SpriteFont>("ComicSansSmall"));
            SceneMgr = new SceneManager(this);

            GameFacade.Controller = new GameController();
            GameFacade.Screens = ScreenMgr;
            GameFacade.Scenes = SceneMgr;
            GameFacade.GraphicsDevice = GraphicsDevice;

            /** Init any computed values **/
            GameFacade.Init();

            GameFacade.LastUpdateState = m_UpdateState;
            GameFacade.Strings = new ContentStrings();
            GameFacade.Controller.StartLoading();
        }
Ejemplo n.º 13
0
 public override void Draw(UISpriteBatch batch)
 {
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Basic draw method. Your component should implement this
 /// and add any drawing behavior it needs.
 /// </summary>
 /// <param name="batch"></param>
 public abstract void Draw(UISpriteBatch batch);
Ejemplo n.º 15
0
 public void PreDraw(UISpriteBatch SBatch)
 {
     mainUI.PreDraw(SBatch);
 }
Ejemplo n.º 16
0
        public override void Draw(UISpriteBatch SBatch)
        {
            if (!Visible) { return; }

            if (NineSlice)
            {

                if (m_Texture == null) { return; }

                /**
                 * We need to draw 9 pieces
                 */

                /** TL **/
                DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.TL, Vector2.Zero);

                /** TC **/
                DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.TC, new Vector2(NineSliceMargins.Left, 0), NineSliceMargins.TC_Scale);

                /** TR **/
                DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.TR, new Vector2(Width - NineSliceMargins.Right, 0));

                /** ML **/
                DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.ML, new Vector2(0, NineSliceMargins.Top), NineSliceMargins.ML_Scale);

                /** MC **/
                DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.MC, new Vector2(NineSliceMargins.Left, NineSliceMargins.Top), NineSliceMargins.MC_Scale);

                /** MR **/
                DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.MR, new Vector2(Width - NineSliceMargins.Right, NineSliceMargins.Top), NineSliceMargins.MR_Scale);

                /** BL **/
                var bottomY = Height - NineSliceMargins.Bottom;
                DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.BL, new Vector2(0, bottomY));

                /** BC **/
                DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.BC, new Vector2(NineSliceMargins.Left, bottomY), NineSliceMargins.BC_Scale);

                /** BR **/
                DrawLocalTexture(SBatch, m_Texture, NineSliceMargins.BR, new Vector2(Width - NineSliceMargins.Right, bottomY));

            }
            else if (m_TextureRef != null)
            {
                m_TextureRef.Draw(SBatch, this, 0, 0, m_Width, m_Height);
            }
            else
            {

                if (m_Texture == null) { return; }

                if (m_Width != 0 && m_Height != 0)
                {
                    DrawLocalTexture(SBatch, m_Texture, null, Vector2.Zero, new Vector2(m_Width / m_Texture.Width, m_Height / m_Texture.Height));
                }
                else
                {
                    DrawLocalTexture(SBatch, m_Texture, Vector2.Zero);
                }
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// May be removed - Called before the draw method.
 /// </summary>
 /// <param name="batch"></param>
 public virtual void PreDraw(UISpriteBatch batch)
 {
 }
Ejemplo n.º 18
0
        public void Draw(UISpriteBatch SBatch, float FPS)
        {
            fpsStopwatch.Stop();
            m_FPS = (float)(1000.0f / fpsStopwatch.ElapsedMilliseconds);
            fpsStopwatch.Reset();
            fpsStopwatch.Start();

            mainUI.Draw(SBatch);

            if (TooltipProperties.UpdateDead) TooltipProperties.Show = false;
            if (Tooltip != null && TooltipProperties.Show) DrawTooltip(SBatch, TooltipProperties.Position, TooltipProperties.Opacity);
            TooltipProperties.UpdateDead = true;

            SBatch.DrawString(m_SprFontBig, "FPS: " + FPS.ToString(), new Vector2(0, 0), Color.Red);
        }
Ejemplo n.º 19
0
        public void Draw(UISpriteBatch SBatch, float FPS)
        {
            mainUI.Draw(SBatch);

            SBatch.DrawString(m_SprFontBig, "FPS: " + FPS.ToString(), new Vector2(0, 0), Color.Red);
        }
Ejemplo n.º 20
0
        public override void Draw(UISpriteBatch SBatch)
        {
            if (!Visible) { return; }

            if (m_CalcAutoSize)
            {
                CalculateAutoSize();
            }

            /** Draw the button as a 3 slice **/
            var frame = m_CurrentFrame;
            if (Selected)
            {
                frame = 1;
            }
            if (m_Disabled)
            {
                frame = 3;
            }
            frame = Math.Min(m_ImageStates - 1, frame);
            int offset = frame * m_Width;

            if (Width != 0)
            {
                //TODO: Work out these numbers once & cache them. Invalidate when texture or width changes

                /** left **/
                base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset, 0, m_WidthDiv3, m_Texture.Height), Vector2.Zero);

                /** center **/
                base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset + m_WidthDiv3, 0, m_WidthDiv3, m_Texture.Height), new Vector2(m_WidthDiv3, 0), new Vector2( (Width - (m_WidthDiv3 * 2)) / m_WidthDiv3, 1.0f));

                /** right **/
                base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset + (m_Width - m_WidthDiv3), 0, m_WidthDiv3, m_Texture.Height), new Vector2(Width - m_WidthDiv3, 0));
            }
            else
            {
                base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset, 0, m_Width, m_Texture.Height), Vector2.Zero);
            }

            /**
             * Label
             */
            if (m_Caption != null && m_CaptionStyle != null)
            {
                var box =GetBounds();
                //Little hack to get slightly better centering on text on buttons
                box.Height -= 2;
                this.DrawLocalString(SBatch, m_Caption, Vector2.Zero, m_CaptionStyle, box, TextAlignment.Center | TextAlignment.Middle, Rectangle.Empty, m_State);
            }
        }
Ejemplo n.º 21
0
        public override void Draw(UISpriteBatch batch)
        {
            base.Draw(batch);

            if (Caption != null && CaptionStyle != null)
            {
                DrawLocalString(batch, Caption, Vector2.Zero, CaptionStyle, GetBounds(), TextAlignment.Top | TextAlignment.Center, CaptionMargin);
            }
        }
Ejemplo n.º 22
0
 public override void Draw(UISpriteBatch batch)
 {
     base.Draw(batch);
     if (m_CurrentItem == m_PieTree)
     {
         //var oldd = GameFacade.GraphicsDevice.DepthStencilBuffer;
         //GameFacade.GraphicsDevice.DepthStencilBuffer = new DepthStencilBuffer(GameFacade.GraphicsDevice, oldd.Width, oldd.Height, oldd.Format);
         //todo: how to do this in xna4...
         GameFacade.GraphicsDevice.Clear(ClearOptions.DepthBuffer, new Vector4(0), 16777215, 0); //use a temp depth buffer for drawing this... this is an awful idea but will do until we get a better 3D UI element drawing system.
         batch.Pause();
         m_Head.Draw(GameFacade.GraphicsDevice);
         batch.Resume();
         //GameFacade.GraphicsDevice.DepthStencilBuffer = oldd;
     } //if we're top level, draw head!
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Render
        /// </summary>
        /// <param name="batch"></param>
        public override void Draw(UISpriteBatch batch)
        {
            if (m_DrawDirty)
            {
                ComputeDrawingCommands();
            }

            /** Can have a text box without a background **/
            if (m_BackgroundTex != null && NineSliceMargins != null)
            {
                NineSliceMargins.DrawOnto(batch, this, m_BackgroundTex, m_Width, m_Height);
            }

            /**
             * Draw text
             */
            foreach (var cmd in m_DrawCmds)
            {
                cmd.Draw(this, batch);
            }
        }
Ejemplo n.º 24
0
        public override void Draw(UISpriteBatch batch)
        {
            if (!Visible) { return; }

            var layout = m_LayoutCache.Calculate("layout", x => CalculateLayout());

            batch.Draw(m_Texture, layout.TrackStartTo, layout.TrackStartFrom, Color.White, 0, Vector2.Zero, _Scale, SpriteEffects.None, 0);
            batch.Draw(m_Texture, layout.TrackMiddleTo, layout.TrackMiddleFrom, Color.White, 0, Vector2.Zero, layout.TrackMiddleScale, SpriteEffects.None, 0);
            batch.Draw(m_Texture, layout.TrackEndTo, layout.TrackEndFrom, Color.White, 0, Vector2.Zero, _Scale, SpriteEffects.None, 0);

            if (m_MaxValue > m_MinValue)
            {
                var buttonPosition = m_LayoutCache.Calculate("btn", x => CalculateButtonPosition(layout));
                batch.Draw(m_Texture, buttonPosition, layout.ThumbFrom, Color.White, 0, Vector2.Zero, _Scale, SpriteEffects.None, 0);
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Basic draw method. Your component should implement this
 /// and add any drawing behavior it needs.
 /// </summary>
 /// <param name="batch"></param>
 public abstract void Draw(UISpriteBatch batch);
Ejemplo n.º 26
0
 /// <summary>
 /// May be removed - Called before the draw method.
 /// </summary>
 /// <param name="batch"></param>
 public virtual void PreDraw(UISpriteBatch batch)
 {
 }
Ejemplo n.º 27
0
        public override void Draw(UISpriteBatch SBatch)
        {
            if (!Visible)
            {
                return;
            }

            if (m_Text != null && CaptionStyle != null)
            {
                //DrawLocalTexture(SBatch, TextureUtils.TextureFromColor(SBatch.GraphicsDevice, Color.Red), null, Vector2.Zero, new Vector2(10, 10));

                if (m_Size != Rectangle.Empty)
                {
                    DrawLocalString(SBatch, m_Text, Vector2.Zero, CaptionStyle, m_Size, Alignment);
                }
                else
                {
                    DrawLocalString(SBatch, m_Text, Vector2.Zero, CaptionStyle);
                }
            }
        }
Ejemplo n.º 28
0
 public override void Draw(UISpriteBatch batch)
 {
     if (!UISpriteBatch.Invalidated)
     {
         if (!_3DScene.IsInvalidated)
         {
             batch.Pause();
             Avatar.Draw(GameFacade.GraphicsDevice);
             batch.Resume();
         }
     }
 }
Ejemplo n.º 29
0
        public override void Draw(UISpriteBatch SBatch)
        {
            if (!Visible)
            {
                return;
            }

            if (m_Text != null && CaptionStyle != null)
            {
                if (m_Size != Rectangle.Empty)
                {
                    DrawLocalString(SBatch, m_Text, Vector2.Zero, CaptionStyle, m_Size, Alignment);
                }
                else
                {
                    DrawLocalString(SBatch, m_Text, Vector2.Zero, CaptionStyle);
                }
            }
        }
Ejemplo n.º 30
0
        public UILayer(Microsoft.Xna.Framework.Game G, SpriteFont SprFontBig, SpriteFont SprFontSmall)
        {
            fpsStopwatch = new Stopwatch();
            fpsStopwatch.Start();

            m_G = G;
            m_SprFontBig = SprFontBig;
            m_SprFontSmall = SprFontSmall;

            m_WorldMatrix = Matrix.Identity;
            m_ViewMatrix = Matrix.CreateLookAt(Vector3.Right * 5, Vector3.Zero, Vector3.Forward);
            m_ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.Pi / 4.0f,
                    (float)GraphicsDevice.PresentationParameters.BackBufferWidth /
                    (float)GraphicsDevice.PresentationParameters.BackBufferHeight,
                    1.0f, 100.0f);

            TextStyle.DefaultTitle = new TextStyle {
                Font = GameFacade.MainFont,
                Size = 10,
                Color = new Color(255,249,157),
                SelectedColor = new Color(0x00, 0x38, 0x7B),
                SelectionBoxColor = new Color(255, 249, 157)
            };

            TextStyle.DefaultButton = new TextStyle
            {
                Font = GameFacade.MainFont,
                Size = 10,
                Color = new Color(255, 249, 157),
                SelectedColor = new Color(0x00, 0x38, 0x7B),
                SelectionBoxColor = new Color(255, 249, 157)
            };

            TextStyle.DefaultLabel = new TextStyle
            {
                Font = GameFacade.MainFont,
                Size = 10,
                Color = new Color(255, 249, 157),
                SelectedColor = new Color(0x00, 0x38, 0x7B),
                SelectionBoxColor = new Color(255, 249, 157)
            };

            Tween = new UITween();
            this.AddProcess(Tween);

            inputManager = new InputManager();
            mainUI = new UIContainer();
            dialogContainer = new UIContainer();
            mainUI.Add(dialogContainer);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new UISpriteBatch(GraphicsDevice, 3);

            GameFacade.OnContentLoaderReady += new BasicEventHandler(GameFacade_OnContentLoaderReady);
            m_G.GraphicsDevice.DeviceReset += new EventHandler<EventArgs>(GraphicsDevice_DeviceReset);
        }
Ejemplo n.º 31
0
        public override void Draw(UISpriteBatch batch)
        {
            base.Draw(batch);

            if (m_TextDirty)
            {
                ComputeText();
            }
            TextRenderer.DrawText(MessageText.DrawingCommands, this, batch);
        }
Ejemplo n.º 32
0
 public override void Draw(UISpriteBatch batch)
 {
     DrawLocalTexture(batch, Background, new Vector2(0, 0));
     if (Icon != null) DrawLocalTexture(batch, Icon, new Rectangle(0, 0, Icon.Width/2, Icon.Height), new Vector2(4, 4));
     if (Overlay != null) DrawLocalTexture(batch, Overlay, new Vector2(0, 0));
 }
Ejemplo n.º 33
0
        public override void Draw(UISpriteBatch SBatch)
        {
            if (!Visible) { return; }

            if (m_CalcAutoSize)
            {
                CalculateAutoSize();
            }

            /** Draw the button as a 3 slice **/
            var frame = m_CurrentFrame;
            if (Selected)
            {
                frame = 1;
            }
            if (m_Disabled)
            {
                frame = 3;
            }
            int offset = frame * m_Width;

            if (Width != 0)
            {
                //TODO: Work out these numbers once & cache them. Invalidate when texture or width changes

                /** left **/
                base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset, 0, m_WidthDiv3, m_Texture.Height), Vector2.Zero);

                /** center **/
                base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset + m_WidthDiv3, 0, m_WidthDiv3, m_Texture.Height), new Vector2(m_WidthDiv3, 0), new Vector2( (Width - (m_WidthDiv3 * 2)) / m_WidthDiv3, 1.0f));

                /** right **/
                base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset + (m_Width - m_WidthDiv3), 0, m_WidthDiv3, m_Texture.Height), new Vector2(Width - m_WidthDiv3, 0));
            }
            else
            {

                base.DrawLocalTexture(SBatch, m_Texture, new Rectangle(offset, 0, m_Width, m_Texture.Height), Vector2.Zero);
            }

            /**
             * Label
             */
            if (m_Caption != null && m_CaptionStyle != null)
            {
                var box =GetBounds();
                //Little hack to get slightly better centering on text on buttons
                box.Height -= 2;
                this.DrawLocalString(SBatch, m_Caption, Vector2.Zero, m_CaptionStyle, box, TextAlignment.Center | TextAlignment.Middle, Rectangle.Empty, m_State);
            }

            //SBatch.DrawString(m_Screen.ScreenMgr.SprFontSmall, m_Caption,
            //                new Vector2(m_X + ((ButtonWidth - CaptionSize.X) / 2.1f) * GlobalScale,
            //                    m_Y + ((ButtonHeight - CaptionSize.Y) / 2) * GlobalScale), Color.Wheat);

            //base.Draw(SBatch);

            //if (!Invisible)
            //{
            //    float GlobalScale = GlobalSettings.Default.ScaleFactor;

            //    if (m_ScaleX == 0 && m_ScaleY == 0)
            //    {
            //        //WARNING: Do NOT refer to m_CurrentFrame, as the accessor ensures the right
            //        //value is returned.
            //        SBatch.Draw(m_Texture, new Vector2(m_X * GlobalScale, m_Y * GlobalScale), new Rectangle(CurrentFrame, 0, m_Width, m_Texture.Height),
            //            Color.White, 0.0f, new Vector2(0.0f, 0.0f), GlobalScale, SpriteEffects.None, 0.0f);

            //        if (m_Caption != null)
            //        {
            //            Vector2 CaptionSize = m_Screen.ScreenMgr.SprFontSmall.MeasureString(m_Caption);
            //            CaptionSize.X += GlobalScale;
            //            CaptionSize.Y += GlobalScale;
            //            float ButtonWidth = m_Width * GlobalScale;
            //            float ButtonHeight = m_Texture.Height * GlobalScale;

            //            SBatch.DrawString(m_Screen.ScreenMgr.SprFontSmall, m_Caption,
            //                new Vector2(m_X + (((ButtonWidth - CaptionSize.X) / 2.1f) * GlobalScale),
            //                    m_Y + ((ButtonHeight - CaptionSize.Y) / 2) * GlobalScale), Color.Wheat);
            //        }
            //    }
            //    else
            //    {
            //        //WARNING: Do NOT refer to m_CurrentFrame, as the accessor ensures the right
            //        //value is returned.
            //        SBatch.Draw(m_Texture, new Vector2(m_X * GlobalScale, m_Y * GlobalScale), new Rectangle(CurrentFrame, 0, m_Width, m_Texture.Height),
            //            Color.White, 0.0f, new Vector2(0.0f, 0.0f), new Vector2(m_ScaleX + GlobalScale, m_ScaleY + GlobalScale),
            //            SpriteEffects.None, 0.0f);

            //        if (m_Caption != null)
            //        {
            //            Vector2 CaptionSize = m_Screen.ScreenMgr.SprFontSmall.MeasureString(m_Caption);
            //            CaptionSize.X += GlobalScale;
            //            CaptionSize.Y += GlobalScale;
            //            float ButtonWidth = m_Width * (GlobalScale + m_ScaleX);
            //            float ButtonHeight = m_Texture.Height * (GlobalScale + m_ScaleY);

            //            SBatch.DrawString(m_Screen.ScreenMgr.SprFontSmall, m_Caption,
            //                new Vector2(m_X + ((ButtonWidth - CaptionSize.X) / 2.1f) * GlobalScale,
            //                    m_Y + ((ButtonHeight - CaptionSize.Y) / 2) * GlobalScale), Color.Wheat);
            //        }
            //    }
            //}
        }