Class ContextStack
Manages a stack of input contexts with priority-based resolution. Allows for layered input handling (e.g., menus over gameplay).
Inherited Members
Namespace: PopcorningGuineaPig.Engine.Input
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public class ContextStack
Constructors
| Edit this page View SourceContextStack()
Creates a new context stack.
Declaration
public ContextStack()
Methods
| Edit this page View SourceClear()
Clears all contexts from the stack.
Declaration
public void Clear()
GetActiveContexts()
Gets all active contexts, including the global context.
Declaration
public IEnumerable<InputContext> GetActiveContexts()
Returns
| Type | Description |
|---|---|
| IEnumerable<InputContext> |
GetContext(string)
Gets a context by name.
Declaration
public InputContext GetContext(string contextName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contextName | Name of the context to find |
Returns
| Type | Description |
|---|---|
| InputContext | The context if found, null otherwise |
Pop(string)
Pops a context from the stack.
Declaration
public InputContext Pop(string contextName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | contextName | Name of the context to pop |
Returns
| Type | Description |
|---|---|
| InputContext | The popped context, or null if not found |
Push(InputContext)
Pushes a context onto the stack. The stack is sorted by priority after each push.
Declaration
public void Push(InputContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| InputContext | context | The context to push |
ResolveBinding(InputKey)
Resolves a binding for the given input key by checking contexts in priority order.
Declaration
public InputBinding ResolveBinding(InputKey inputKey)
Parameters
| Type | Name | Description |
|---|---|---|
| InputKey | inputKey | The input key to resolve |
Returns
| Type | Description |
|---|---|
| InputBinding | The highest priority binding, or null if not found |
SetGlobalContext(InputContext)
Sets the global context.
Declaration
public void SetGlobalContext(InputContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| InputContext | context | The global context |