Пример #1
0
        /// <summary>
        /// Constructor for this module, will be child of the Application module to
        /// be executed as part of the Application.Run.
        /// </summary>
        /// <param name="bindConsole">The button to open and close the console</param>
        /// <param name="consoleMargin">The space between the screenspace and the console. Pass NULL to use the default value.</param>
        /// <param name="consoleBackground">The console background color or material. Pass NULL to use the default value.</param>
        /// <param name="consoleFontColor">The color for the font to display text. Pass NULL to use the default value.</param>
        /// <param name="maxNumberOfLines">The max. number of lines that will be displayed befor the oldest entry will be deleted. Pass NULL to use the default value.</param>
        public Module(InputButton bindConsoleButton, Margin consoleMargin, Material2DColored consoleBackground, Color consoleFontColor, int? maxNumberOfLines )
            : base("Delta.Console", typeof(Application))
        {

            if (consoleMargin.Left == 0 && consoleMargin.Top == 0 && consoleMargin.Right == 0)
            {
                consoleMargin = new Margin() { Left = 0.01f, Top = 0.01f, Right = 0.02f };
            }

            if (consoleBackground == null)
            {
                consoleBackground = new Material2DColored(new Color(new Color(0, 167, 255), 0.5f));
            }

            if (consoleFontColor.PackedRGBA == 0)
            {
                consoleFontColor = new Color(200, 220, 255);
            }

            if (maxNumberOfLines == null)
            {
                maxNumberOfLines = 20;
            }

            // Initialize
            console = new Delta.Console.Console(bindConsoleButton, consoleMargin, consoleBackground, consoleFontColor, (int)maxNumberOfLines);
            graph = new GraphManager();

            // Add command to the console to enable or disable the graph
            console.AddCmdToConsole(typeof(Module).GetMethod("SetGraphState"), this);
        }
Пример #2
0
        public Console(InputButton bindConsoleButton, Margin consoleMargin, Material2DColored consoleBackground, Color consoleFontColor, int maxNumberOfLines)
        {
            // Set the Material2DColored
            this.consoleBackground = consoleBackground;
            // The console should be topmost
            this.consoleBackground.DrawLayer = Delta.ContentSystem.Rendering.RenderLayer.Front;

            // Set the margin and max. line count
            this.consoleMargin = consoleMargin;
            this.maxNumberOfLines = maxNumberOfLines;

            // Initialize the console dimension
            consoleDimension = new Rectangle();

            // Initialize empty history
            history = new List<string>();
            cmdHistory = new Stack<string>();

            // Initialize empty suggestions
            autoCompletionCache = new List<string>();

            // Initialize with empty string
            inputText = "";
            lastInputText = "";

            // Set the console font with the given color
            consoleFont = new Font(Font.Default, consoleFontColor, HorizontalAlignment.Left, VerticalAlignment.Top);

            // Create a new instance of the CommandManager
            cmdManager = new CommandManager();

            // Register input commands
            registerInputCommands(bindConsoleButton);

            // Initialize calculation
            calculateConsoleDimension();
        }