示例#1
0
        public ConsoleWindow(
            GraphicsDevice Graphics,
            ContentManager Content,
            Rectangle ScreenPosition,
            int FontScale)
        {
            this.Graphics = Graphics;
            this.Content  = Content;

            font = new Gui.BitmapFont(Content.Load <Texture2D>("Content/small-font"), 6, 8, 6);

            Resize(ScreenPosition, FontScale);
        }
示例#2
0
        public ConsoleWindow(
            GraphicsDevice Graphics,
            ContentManager Content,
            Rectangle ScreenPosition,
            int FontScale)
        {
            this.Graphics = Graphics;
            this.Content = Content;

            font = new Gui.BitmapFont(Content.Load<Texture2D>("Content/small-font"), 6, 8, 6);

            Resize(ScreenPosition, FontScale);
        }
示例#3
0
        public ConsoleDisplay(int width, int height, Gui.BitmapFont font, GraphicsDevice device, ContentManager content)
        {
            this.Width  = width;
            this.Height = height;

            this.Font = font;
            effect    = content.Load <Effect>("Content/draw-console");


            //Prepare the index buffer.
            var indicies = new short[width * 6];

            for (int i = 0; i < width; ++i)
            {
                indicies[i * 6 + 0] = (short)(i * 4 + 0);
                indicies[i * 6 + 1] = (short)(i * 4 + 1);
                indicies[i * 6 + 2] = (short)(i * 4 + 2);
                indicies[i * 6 + 3] = (short)(i * 4 + 2);
                indicies[i * 6 + 4] = (short)(i * 4 + 3);
                indicies[i * 6 + 5] = (short)(i * 4 + 0);
            }

            indexBuffer = new IndexBuffer(device, IndexElementSize.SixteenBits, indicies.Length, BufferUsage.WriteOnly);
            indexBuffer.SetData(indicies);

            //Prepare vertex buffers
            lines = new Line[height];

            for (int y = 0; y < height; ++y)
            {
                lines[y]       = new Line();
                lines[y].verts = new ConsoleVertex[width * 4];
                for (int i = 0; i < width; ++i)
                {
                    lines[y].verts[i * 4 + 0].Position = new Vector3(i * font.glyphWidth - 0.5f, y * font.glyphHeight - 0.5f, 0);
                    lines[y].verts[i * 4 + 1].Position = new Vector3((i + 1) * font.glyphWidth - 0.5f, y * font.glyphHeight - 0.5f, 0);
                    lines[y].verts[i * 4 + 2].Position = new Vector3((i + 1) * font.glyphWidth - 0.5f, (y + 1) * font.glyphHeight - 0.5f, 0);
                    lines[y].verts[i * 4 + 3].Position = new Vector3(i * font.glyphWidth - 0.5f, (y + 1) * font.glyphHeight - 0.5f, 0);

                    lines[y].verts[i * 4 + 0].FGColor = Color.White.ToVector4();
                    lines[y].verts[i * 4 + 1].FGColor = Color.White.ToVector4();
                    lines[y].verts[i * 4 + 2].FGColor = Color.White.ToVector4();
                    lines[y].verts[i * 4 + 3].FGColor = Color.White.ToVector4();
                    lines[y].verts[i * 4 + 0].BGColor = Color.Black.ToVector4();
                    lines[y].verts[i * 4 + 1].BGColor = Color.Black.ToVector4();
                    lines[y].verts[i * 4 + 2].BGColor = Color.Black.ToVector4();
                    lines[y].verts[i * 4 + 3].BGColor = Color.Black.ToVector4();
                }
                lines[y].buffer = new VertexBuffer(device, typeof(ConsoleVertex), lines[y].verts.Length, BufferUsage.None);
            }
        }