Exemplo n.º 1
0
        public static GameConsole Create(Game game, SpriteFont font, ConsoleSkin skin = null)
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("Instance already created");
            }

            Instance = new GameConsole(game, font, skin ?? ConsoleSkins.Dark);
            return(Instance);
        }
Exemplo n.º 2
0
        protected GameConsole(Game game, SpriteFont font, ConsoleSkin skin)
            : base(game)
        {
            InputManager  = new ConsoleInputManager(this);
            RenderManager = new ConsoleRenderManager(this, font, skin);

            _spriteBatch = Game.Services.GetService <SpriteBatch>();

            DrawOrder = int.MaxValue - 1;             // TODO: find the better way
            Game.Services.AddService(typeof(IConsole), this);
            Game.Components.Add(this);

            LoadDefaultCommands();
        }
Exemplo n.º 3
0
        public ConsoleRenderManager(GameConsole console, SpriteFont font, ConsoleSkin skin)
        {
            if (console == null)
            {
                throw new ArgumentNullException(nameof(console));
            }

            Font     = font;
            Skin     = skin;
            _console = console;

            InputTarget.TextEditor.CursorPositionChanged += (_, __) => _shouldIgnoreBlinking = TimeSpan.FromSeconds(0.5f);
            InputTarget.TextEditor.CursorPositionChanged += CursorPositionChanged;
            InputTarget.TextEditor.TextRemoved           += InputTextRemoved;

            HistoryRenderer = new ConsoleHistoryRenderer(this);
            InitializeFacade();
        }
Exemplo n.º 4
0
        static ConsoleSkins()
        {
            _dark = new ConsoleSkin
            {
                AutoCompleteBorder            = Color.Black * 0.25f,
                AutoCompleteSelectedTextColor = Color.Gold,
                AutoCompleteField             = new ConsoleSkin.FieldSkin(Color.Black * 0.6f, Color.Gray * 0.8f),
                ConsoleBackground             = new Color(33, 28, 46) * 0.8f,
                HistoryField        = new ConsoleSkin.FieldSkin(Color.Black * 0.3f, Color.White),
                HistoryTimeColor    = Color.Green,
                HistoryWarningColor = Color.Red,
                CursorColor         = new Color(185, 214, 255),
                CursorWidth         = 2,
                HighlightColor      = Color.LightGray * 0.3f,
                InputField          = new ConsoleSkin.FieldSkin(Color.Black * 0.3f, new Color(185, 214, 255)),
                ScrollBarColor      = new Color(26, 28, 47) * 1f,
                ScrollBarPadding    = new Point(0, 0),
                ScrollBarStripColor = Color.Black * 0.5f,
                ScrollBarWidth      = 7,
                CursorBlinkSpeed    = TimeSpan.FromSeconds(0.5f)
            };

            _light = new ConsoleSkin
            {
                ConsoleBackground             = Color.OldLace * 0.5f,
                HistoryField                  = new ConsoleSkin.FieldSkin(Color.White * 0.45f, new Color(109, 0, 132)),
                InputField                    = new ConsoleSkin.FieldSkin(Color.White * 0.45f, new Color(0, 29, 94)),
                CursorColor                   = new Color(0, 29, 94),
                CursorWidth                   = 2,
                AutoCompleteField             = new ConsoleSkin.FieldSkin(Color.White * 0.65f, Color.DarkViolet),
                AutoCompleteBorder            = Color.DarkGray * 0.9f,
                AutoCompleteSelectedTextColor = Color.Lime,
                HistoryTimeColor              = new Color(0, 72, 170),
                HistoryWarningColor           = Color.DarkRed,
                HighlightColor                = Color.OliveDrab * 0.5f,
                ScrollBarColor                = Color.Gray * 0.4f,
                ScrollBarStripColor           = Color.Black * 0.25f,
                ScrollBarWidth                = 7,
                CursorBlinkSpeed              = TimeSpan.FromSeconds(0.5f),
                ScrollBarPadding              = new Point(1, 1)
            };
        }