コード例 #1
0
        protected override void OnBuild()
        {
            base.OnBuild();

            // Adjust configuration defaults
            TerminalGameOptions cfg = ServiceProvider.GetService <IOptions <TerminalGameOptions> >().Value;

            if (cfg.UseLargestWindow)
            {
                cfg.WindowWidth  = Console.LargestWindowWidth;
                cfg.WindowHeight = Console.LargestWindowHeight;
            }
            if (cfg.MatchBufferSizeToWindow)
            {
                cfg.BufferWidth  = cfg.WindowWidth;
                cfg.BufferHeight = cfg.WindowHeight;
            }

            // Set up the Console window
            Console.SetWindowSize(cfg.WindowWidth, cfg.WindowHeight);
            Console.SetWindowPosition(cfg.WindowLeft, cfg.WindowTop);
            Console.SetBufferSize(cfg.BufferWidth, cfg.BufferHeight);

            Console.Title = Scene.Name;

            Console.CursorVisible        = false;
            Console.TreatControlCAsInput = true;
        }
コード例 #2
0
        public TerminalRenderer(IOptions <RendererOptions> rendererOptions, IOptions <TerminalGameOptions> gameOptions)
        {
            _rendererOpts = rendererOptions.Value;
            _gameOpts     = gameOptions.Value;

            // Create the blank buffer
            int numRows = _gameOpts.BufferHeight;
            int numCols = _gameOpts.BufferWidth;

            _blankBuffer = new char[numRows][];
            for (int r = 0; r < numRows; ++r)
            {
                _blankBuffer[r] = new char[numCols];
                for (int c = 0; c < numCols; ++c)
                {
                    _blankBuffer[r][c] = _rendererOpts.FillCharacter;
                }
            }

            // Start all color buffers off cleared
            clearBuffer((_rendererOpts.FillForeColor, _rendererOpts.FillBackColor));
        }