Skip to content

Interface IOverlay

Definition

Namespace: StardewUI.Overlays
Assembly: StardewUI.dll

Definition of an overlay - i.e. a UI element that displays over all other UI.

public interface IOverlay

Members

Properties

Name Description
CapturingInput Whether the overlay wants to capture all keyboard and gamepad inputs, i.e. prevent them from being dispatched to the parent menu.
DimmingAmount Amount to dim whatever is underneath the overlay.
HorizontalAlignment Horizontal alignment of the overlay relative to the Parent edge.
HorizontalParentAlignment Specifies which edge of the Parent (or screen, if no parent is specified) will be used to align the overlay edge denoted by its HorizontalAlignment.
Parent The parent of this overlay, used for positioning. If not specified, then the overlay will be positioned relative to the entire UI viewport.
ParentOffset Additional pixel offset to apply to the overlay's position, after alignments.
VerticalAlignment Vertical alignment of the overlay relative to the Parent edge.
VerticalParentAlignment Specifies which edge of the Parent (or screen, if no parent is specified) will be used to align the overlay edge denoted by its VerticalAlignment.
View The view to be displayed/interacted with as an overlay.

Methods

Name Description
OnClose() Runs when the overlay is removed from the active stack.
Update(TimeSpan) Runs on every game update tick.

Events

Name Description
Close Event raised when the overlay is closed - i.e. removed from the current context stack.

Details

Properties

CapturingInput

Whether the overlay wants to capture all keyboard and gamepad inputs, i.e. prevent them from being dispatched to the parent menu.

bool CapturingInput { get; }
Property Value

Boolean

Remarks

This is not necessary to trap focus, which happens automatically; only to capture buttons/keys that would normally have a navigation function, like triggers/shoulders for paging, E/Esc/GamepadB for cancellation, etc. Overlays that enable capturing should provide their own way for the user to escape using keyboard/gamepad, although it is always possible to click the mouse outside the overlay to dismiss it (and implicitly stop the capturing).


DimmingAmount

Amount to dim whatever is underneath the overlay.

float DimmingAmount { get; }
Property Value

Single

Remarks

This is an alpha value for a black overlay, so the higher value (between 0 and 1) the darker the content underneath the overlay. These apply individually to each overlay, so multiple stacked overlays will dim not only the underlying main view but also any previous overlays.


HorizontalAlignment

Horizontal alignment of the overlay relative to the Parent edge.

StardewUI.Layout.Alignment HorizontalAlignment { get; }
Property Value

Alignment

Remarks

Specifies which edge of the overlay is used for positioning, regardless of which parent edge it is aligning to. For example, a HorizontalAlignment of Start and a HorizontalParentAlignment of End means that the overlay's left edge will be aligned to the parent's right edge; similarly, if both are set to Start, then the overlay's left edge is aligned to the parent's left edge.


HorizontalParentAlignment

Specifies which edge of the Parent (or screen, if no parent is specified) will be used to align the overlay edge denoted by its HorizontalAlignment.

StardewUI.Layout.Alignment HorizontalParentAlignment { get; }
Property Value

Alignment

Remarks

For example, a HorizontalAlignment of Start and a HorizontalParentAlignment of End means that the overlay's left edge will be aligned to the parent's right edge; similarly, if both are set to Start, then the overlay's left edge is aligned to the parent's left edge.


Parent

The parent of this overlay, used for positioning. If not specified, then the overlay will be positioned relative to the entire UI viewport.

StardewUI.IView Parent { get; }
Property Value

IView


ParentOffset

Additional pixel offset to apply to the overlay's position, after alignments.

Microsoft.Xna.Framework.Vector2 ParentOffset { get; }
Property Value

Vector2


VerticalAlignment

Vertical alignment of the overlay relative to the Parent edge.

StardewUI.Layout.Alignment VerticalAlignment { get; }
Property Value

Alignment

Remarks

Specifies which edge of the overlay is used for positioning, regardless of which parent edge it is aligning to. For example, a VerticalAlignment of Start and a VerticalParentAlignment of End means that the overlay's top edge will be aligned to the parent's bottom edge; similarly, if both are set to Start, then the overlay's top edge is aligned to the parent's top edge.


VerticalParentAlignment

Specifies which edge of the Parent (or screen, if no parent is specified) will be used to align the overlay edge denoted by its VerticalAlignment.

StardewUI.Layout.Alignment VerticalParentAlignment { get; }
Property Value

Alignment

Remarks

For example, a VerticalAlignment of Start and a VerticalParentAlignment of End means that the overlay's top edge will be aligned to the parent's bottom edge; similarly, if both are set to Start, then the overlay's top edge is aligned to the parent's top edge.


View

The view to be displayed/interacted with as an overlay.

StardewUI.IView View { get; }
Property Value

IView


Methods

OnClose()

Runs when the overlay is removed from the active stack.

void OnClose();

Update(TimeSpan)

Runs on every game update tick.

void Update(System.TimeSpan elapsed);
Parameters

elapsed   TimeSpan
The amount of real time elapsed since the last tick.


Events

Close

Event raised when the overlay is closed - i.e. removed from the current context stack.

event EventHandler<System.EventArgs>? Close;
Event Type

EventHandler<EventArgs>