示例#1
0
        public void LoadContent(GraphicsDevice device, GraphicsDeviceManager deviceManager,
                                SpriteFont font, Effect bgEffect)
        {
            Check.ArgumentNotNull(deviceManager, nameof(deviceManager), "Cannot instantiate the console without graphics device manager.");
            Check.ArgumentNotNull(font, nameof(font), "Cannot instantiate the console without a font.");

            GraphicsDevice         = device;
            _graphicsDeviceManager = deviceManager;
            _defaultFont           = font;
            if (Font == null)
            {
                Font = _defaultFont;
            }

            SpriteBatch = new SpriteBatch(GraphicsDevice);

            _graphicsDeviceManager.PreparingDeviceSettings += OnPreparingDeviceChanged;
#if MONOGAME
            WhiteTexture = new Texture2D(GraphicsDevice, 2, 2, false, SurfaceFormat.Color);
            WhiteTexture.SetData(new[] { Color.White, Color.White, Color.White, Color.White });
#else
            WhiteTexture = Texture.New2D(GraphicsDevice, 2, 2, PixelFormat.R8G8B8A8_UNorm, new[] { Color.White, Color.White, Color.White, Color.White });
#endif
            _loaded = true;

            MeasureFontSize();
            SetWindowWidthAndHeight();

            ConsoleInput.LoadContent(this);
            ConsoleOutput.LoadContent(this);
            BgRenderer.LoadContent(this, bgEffect);
        }