Exemplo n.º 1
0
        public GameConsoleComponent(GameConsole console, Game game, SpriteBatch spriteBatch)
            : base(game)
        {
            this.console = console;
            EventInput.Initialize(game.Window);
            this.spriteBatch = spriteBatch;
            AddPresetCommands();
            inputProcesser        = new InputProcessor(new CommandProcesser());
            inputProcesser.Open  += (s, e) => renderer.Open();
            inputProcesser.Close += (s, e) => renderer.Close();

            renderer = new Renderer(game, spriteBatch, inputProcesser);
            var inbuiltCommands = new IConsoleCommand[]
            {
                new ClearScreenCommand(inputProcesser),
                new ExitCommand(game),
                new MouseCommand(game),
                new TitleCommand(game),
                new PromptCommand(game),
                new BugCommand(game),
                new HelpCommand()
            };

            GameConsoleOptions.Commands.AddRange(inbuiltCommands);
        }
Exemplo n.º 2
0
 public Renderer(Game game, SpriteBatch spriteBatch, InputProcessor inputProcessor)
 {
     currentState        = State.Closed;
     width               = game.GraphicsDevice.Viewport.Width;
     position            = closedPosition = new Vector2(GameConsoleOptions.Options.Margin, -GameConsoleOptions.Options.Height - GameConsoleOptions.Options.RoundedCorner.Height);
     openedPosition      = new Vector2(GameConsoleOptions.Options.Margin, 0);
     this.spriteBatch    = spriteBatch;
     this.inputProcessor = inputProcessor;
     pixel               = new Texture2D(game.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
     pixel.SetData(new[] { Color.White });
     firstCommandPositionOffset = Vector2.Zero;
     oneCharacterWidth          = GameConsoleOptions.Options.Font.MeasureString("x").X;
     maxCharactersPerLine       = (int)((Bounds.Width - GameConsoleOptions.Options.Padding * 2) / oneCharacterWidth);
 }
Exemplo n.º 3
0
 public Renderer(Game game, SpriteBatch spriteBatch, InputProcessor inputProcessor)
 {
     currentState = State.Closed;
     width = game.GraphicsDevice.Viewport.Width;
     position = closedPosition = new Vector2(GameConsoleOptions.Options.Margin, -GameConsoleOptions.Options.Height - GameConsoleOptions.Options.RoundedCorner.Height);
     openedPosition = new Vector2(GameConsoleOptions.Options.Margin, 0);
     this.spriteBatch = spriteBatch;
     this.inputProcessor = inputProcessor;
     pixel = new Texture2D(game.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
     pixel.SetData(new[] { Color.White });
     firstCommandPositionOffset = Vector2.Zero;
     oneCharacterWidth = GameConsoleOptions.Options.Font.MeasureString("x").X;
     maxCharactersPerLine = (int)((Bounds.Width - GameConsoleOptions.Options.Padding * 2) / oneCharacterWidth);
 }
        public GameConsoleComponent(GameConsole console, Game game, SpriteBatch spriteBatch)
            : base(game)
        {
            this.console = console;
            EventInput.Initialize(game.Window);
            this.spriteBatch = spriteBatch;
            AddPresetCommands();
            inputProcesser = new InputProcessor(new CommandProcesser());
            inputProcesser.Open += (s, e) => renderer.Open();
            inputProcesser.Close += (s, e) => renderer.Close();

            renderer = new Renderer(game, spriteBatch, inputProcesser);
            var inbuiltCommands = new IConsoleCommand[] {new ClearScreenCommand(inputProcesser),new ExitCommand(game),new HelpCommand()};
            GameConsoleOptions.Commands.AddRange(inbuiltCommands);
        }