Ejemplo n.º 1
0
        protected override void OnDrawBackground(GuiGraphics graphics)
        {
            base.OnDrawBackground(graphics);

            //e.TempCreateGraphics();

            //Graphics.SpriteBatch.Draw( tex, new Rectangle( 0, 0, (int)Size.X, (int)Size.Y ), new Rectangle( 237, 156, 770 - 237, 560 - 156 ), Color.White );

            //e.Graphics.Draw( tex, new Rectangle( 0, 0, tex.Width, tex.Height ), new Rectangle( (int)Position.X, (int)Position.Y, (int)Size.X, (int)Size.Y ), GuiAlign.None );


            //e.Graphics.DrawTiled( tex, new Rectangle( 100, 100, 200, 200 ),
            //    new Rectangle( (int)Position.X, (int)Position.Y, (int)Size.X, (int)Size.Y ),
            //    new Point( 50, 50 ),
            //    GuiAlign.None );


            int width  = (int)Size.X;
            int height = (int)Size.Y;

            if (borderStyle == WindowBorderStyle.Normal)
            {
                Rectangle sourceTopLeft   = tileSet.GetTileRectangle(0, 0);
                Rectangle sourceTopCenter = tileSet.GetTileRectangle(0, 1);
                Rectangle sourceTopRight  = tileSet.GetTileRectangle(0, 2);

                Rectangle sourceMiddleLeft   = tileSet.GetTileRectangle(1, 0);
                Rectangle sourceMiddleCenter = tileSet.GetTileRectangle(1, 1);
                Rectangle sourceMiddleRight  = tileSet.GetTileRectangle(1, 2);

                Rectangle sourceBottomLeft   = tileSet.GetTileRectangle(2, 0);
                Rectangle sourceBottomCenter = tileSet.GetTileRectangle(2, 1);
                Rectangle sourceBottomRight  = tileSet.GetTileRectangle(2, 2);

                TileSet target = new TileSet(0, 0,
                                             new int[] { tileSet.ColumnWidths[0], width - tileSet.ColumnWidths[0] - tileSet.ColumnWidths[2], tileSet.ColumnWidths[2] },
                                             new int[] { tileSet.RowHeights[0], height - tileSet.RowHeights[0] - tileSet.RowHeights[2], tileSet.RowHeights[2] }
                                             );


                for (int x = 0; x < 3; x++)
                {
                    for (int y = 0; y < 3; y++)
                    {
                        graphics.Draw(tex, tileSet.GetTileRectangle(x, y), target.GetTileRectangle(x, y), GuiAlign.None);
                    }
                }
            }
            else if (borderStyle == WindowBorderStyle.None)
            {
                graphics.Draw(tex, tileSet.GetTileRectangle(1, 1), new Rectangle(0, 0, (int)Size.X, (int)Size.Y), GuiAlign.None);
            }
        }
Ejemplo n.º 2
0
        protected override void OnDrawBackground(GuiGraphics graphics)
        {
            base.OnDrawBackground(graphics);
            if (texture == null)
            {
                return;
            }

            if (!sourceRectangle.HasValue)
            {
                sourceRectangle = new Rectangle(0, 0, texture.Width, texture.Height);
            }

            graphics.Draw(texture, sourceRectangle.Value, new Rectangle(0, 0, (int)Size.X, (int)Size.Y), GuiAlign.None);
        }
Ejemplo n.º 3
0
        protected override void OnDrawBackground(GuiGraphics graphics)
        {
            base.OnDrawBackground(graphics);

            int borderWidth = 10;

            int startIndex = 0;
            int endIndex   = items.Count - 1;

            int localI = 0;

            int itemHeight = 40;

            //Draw selection rectangle
            if (selectedIndex != -1)
            {
                Viewport oldViewport = graphics.Device.Viewport;

                Viewport newViewport = oldViewport;

                newViewport.X     += borderWidth;
                newViewport.Y     += borderWidth + selectedIndex * itemHeight;
                newViewport.Height = itemHeight;
                newViewport.Width  = (int)Size.X - borderWidth - borderWidth;

                graphics.Device.Viewport = newViewport;

                graphics.Device.Clear(Color.LightBlue);


                graphics.Device.Viewport = oldViewport;
            }


            for (int i = startIndex; i <= endIndex; i++)
            {
                graphics.DrawText(font, items[i].Text, textColor, new Microsoft.Xna.Framework.Rectangle(
                                      borderWidth, borderWidth + itemHeight * localI, (int)Size.X - borderWidth - borderWidth, itemHeight), textAlign);

                localI++;
            }
        }
Ejemplo n.º 4
0
        protected override void OnDrawBackground(GuiGraphics graphics)
        {
            base.OnDrawBackground(graphics);

            Rectangle bounding = GetBounding();

            int width  = (int)Size.X;
            int height = (int)Size.Y;


            TileSet target = new TileSet(0, 0,
                                         new int[] { tileSet.ColumnWidths[0] >> 1, width - (tileSet.ColumnWidths[0] >> 1) - (tileSet.ColumnWidths[2] >> 1), tileSet.ColumnWidths[2] >> 1 },
                                         new int[] { tileSet.RowHeights[0] >> 1, height - (tileSet.RowHeights[0] >> 1) - (tileSet.RowHeights[2] >> 1), tileSet.RowHeights[2] >> 1 }
                                         );



            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    Rectangle source = tileSet.GetTileRectangle(x, y);
                    Rectangle dest   = target.GetTileRectangle(x, y);

                    if (x == 1 || y == 1)
                    {
                        Vector2 minSize = new Vector2(source.Width, source.Height) * 0.5f;

                        graphics.Draw(texture, source, dest, new Vector2(0.5f));
                    }
                    else
                    {
                        graphics.Draw(texture, source, dest, GuiAlign.None);
                    }
                }
            }

            graphics.DrawText(font, text, textColor,
                              new Rectangle(textBorderSize, textBorderSize,
                                            bounding.Width - textBorderSize * 2, bounding.Height - textBorderSize * 2), textAlign);
        }
Ejemplo n.º 5
0
 public void TempCreateGraphics()
 {
     graphics = new GuiGraphics(device, spriteBatch);
 }
Ejemplo n.º 6
0
 protected virtual void OnDrawBackground(GuiGraphics graphics)
 {
     graphics.Device.Clear(ClearOptions.Target, backgroundColor, 1, 0);
 }