Vixen
02b45cc4
csharp
public sealed class ConsoleOverlay

The console: a prompt, what has been typed, and what the commands answered.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

⚠ Keystrokes are pushed in; the overlay does not read a keyboard. Which device produces a character, and whether the game should stop seeing it while the console is open, are the host's questions — and answering them here would mean Vixen.Engine deciding how text entry works on every platform it runs on. Type, Backspace, Submit and the history moves are the whole surface, which also makes the console testable without an input stack.

IsCapturingInput is what a host polls to know that the game should not act on this frame's keys. Getting that wrong is how typing reload also makes the player reload.

Fields and properties (9)

  • public const int MaxInputLength

    How long a line may be typed.

  • public ConsoleCommands Commands

    What it runs.

  • public string Name

    What the console and the toggles call it. Lower case, no spaces.

  • public OverlayAnchor Anchor

    Which corner it is pinned to.

  • public bool Enabled

    Whether it is drawn.

  • public float Width

    How wide the panel is, in pixels.

  • public int Lines

    How many lines of output are shown above the prompt.

  • public string Input

    What has been typed so far.

  • public bool IsCapturingInput

    Whether the host should keep this frame's keystrokes away from the game.

Methods (9)

  • public ConsoleOverlay(ConsoleCommands commands)

    Uses a registry.

  • public void Type(char character)

    Adds a character to the line.

  • public void Type(ReadOnlySpan<char> text)

    Adds a run of characters to the line.

  • public void Backspace()

    Removes the last character.

  • public void ClearInput()

    Throws the typed line away.

  • public bool Submit()

    Runs what has been typed and clears the line.

  • public void Recall(bool back)

    Replaces the line with an earlier one.

  • public bool Complete()

    Completes the typed line against the command names.

  • public void Draw(OverlaySurface surface, in GameTime time)

    Draws it.

Used by (1)

  • ConsoleTestsVixen.Engine.Tests