/// <summary>
 /// Create a console input handler
 /// </summary>
 /// <param name="OnCommand">Call back to invoke when ctrl+enter is pressed</param>
 /// <param name="Buffer">Buffer this handler will manipulate</param>
 /// <param name="DisplayWidth">The width of the underlying display, in characters</param>
 public ConsoleInputHandler(
     Action<String> OnCommand,
     DynamicConsoleBuffer Buffer,
     int DisplayWidth)
 {
     this.displayWidth = DisplayWidth;
     this.OnCommand = OnCommand;
     this.textBuffer = Buffer;
 }
Example #2
0
        public VirtualConsole(
            Action<String> processCommand,
            GraphicsDevice graphicsDevice, 
            ContentManager contentManager)
        {
            commandHandler = processCommand;

            this.graphicsDevice = graphicsDevice;
            this.contentManager = contentManager;

            display = new TextDisplay(80, 25, graphicsDevice, contentManager);
            dynamicConsole = new DynamicConsoleBuffer(2048, display);
        }
Example #3
0
        public void Resize(Rectangle ScreenPosition, int FontScale)
        {
            int width = ScreenPosition.Width / (6 * FontScale);
            int height = ScreenPosition.Height / (8 * FontScale);

            var rowSize = ScreenPosition.Height / height;
            var realHeight = height * rowSize;
            var colSize = ScreenPosition.Width / width;
            var realWidth = width * colSize;

            ActualDrawSize = new Rectangle(
                ScreenPosition.X + ((ScreenPosition.Width - realWidth) / 2),
                ScreenPosition.Y + ((ScreenPosition.Height - realHeight) / 2),
                realWidth,
                realHeight);

            Display = new ConsoleDisplay(width, height, font, Graphics, Content);
            Buffer = new DynamicConsoleBuffer(2048, Display);
            InputHandler = new ConsoleInputHandler(ConsoleCommandHandler, Buffer, width);

            this.ScreenPosition = ScreenPosition;
            ConsoleRenderSurface = new RenderTarget2D(Graphics, width * font.glyphWidth, height * font.glyphHeight, false,
                SurfaceFormat.Color, DepthFormat.Depth16);
        }