Interface IMenuController
Definition
Namespace: StardewUI.Framework
Assembly: StardewUI.dll
Wrapper for a mod-managed IClickableMenu that allows further customization of menu-level properties not accessible to StarML or data binding.
Implements
IDisposable
Members
Properties
Name | Description |
---|---|
CanClose | Gets or sets a function that returns whether or not the menu can be closed. |
CloseAction | Gets or sets an action that replaces the default menu-close behavior. |
CloseButtonOffset | Offset from the menu view's top-right edge to draw the close button. |
CloseOnOutsideClick | Whether to automatically close the menu when a mouse click is detected outside the bounds of the menu and any floating elements. |
CloseSound | Sound to play when closing the menu. |
DimmingAmount | How much the menu should dim the entire screen underneath. |
Menu | Gets the menu, which can be opened using activeClickableMenu, or as a child menu. |
PositionSelector | Gets or sets a function that returns the top-left position of the menu. |
Methods
Name | Description |
---|---|
ClearCursorAttachment() | Removes any cursor attachment previously set by SetCursorAttachment(Texture2D, Rectangle?, Point?, Point?, Color?). |
Close() | Closes the menu. |
EnableCloseButton(Texture2D, Rectangle?, Single) | Configures the menu to display a close button on the upper-right side. |
SetCursorAttachment(Texture2D, Rectangle?, Point?, Point?, Color?) | Begins displaying a cursor attachment, i.e. a sprite that follows the mouse cursor. |
SetGutters(Int32, Int32, Int32, Int32) | Configures the menu's gutter widths/heights. |
Events
Name | Description |
---|---|
Closed | Event raised after the menu has been closed. |
Closing | Event raised when the menu is about to close. |
Details
Properties
CanClose
Gets or sets a function that returns whether or not the menu can be closed.
Property Value
Remarks
This is equivalent to implementing readyToClose().
CloseAction
Gets or sets an action that replaces the default menu-close behavior.
Property Value
Remarks
Most users should leave this property unset. It is intended for use in unusual contexts, such as replacing the mod settings in a Generic Mod Config Menu integration. Setting any non-null value to this property will suppress the default behavior of exitThisMenu(Boolean) entirely, so the caller is responsible for handling all possible scenarios (e.g. child of another menu, or sub-menu of the title menu).
CloseButtonOffset
Offset from the menu view's top-right edge to draw the close button.
Property Value
Remarks
Only applies when EnableCloseButton(Texture2D, Rectangle?, Single) has been called at least once.
CloseOnOutsideClick
Whether to automatically close the menu when a mouse click is detected outside the bounds of the menu and any floating elements.
Property Value
Remarks
This setting is primarily intended for submenus and makes them behave more like overlays.
CloseSound
Sound to play when closing the menu.
Property Value
DimmingAmount
How much the menu should dim the entire screen underneath.
Property Value
Remarks
The default dimming is appropriate for most menus, but if the menu is being drawn as a delegate of some other macro-menu, then it can be lowered or removed (set to 0
) entirely.
Menu
Gets the menu, which can be opened using activeClickableMenu, or as a child menu.
Property Value
IClickableMenu
PositionSelector
Gets or sets a function that returns the top-left position of the menu.
Property Value
Remarks
Setting any non-null value will disable the auto-centering functionality, and is equivalent to setting the xPositionOnScreen and yPositionOnScreen fields.
Methods
ClearCursorAttachment()
Removes any cursor attachment previously set by SetCursorAttachment(Texture2D, Rectangle?, Point?, Point?, Color?).
Close()
Closes the menu.
Remarks
This method allows programmatic closing of the menu. It performs the same action that would be performed by pressing one of the configured menu keys (e.g. ESC), clicking the close button, etc., and follows the same rules, i.e. will not allow closing if CanClose is false
.
EnableCloseButton(Texture2D, Rectangle?, float)
Configures the menu to display a close button on the upper-right side.
void EnableCloseButton(Microsoft.Xna.Framework.Graphics.Texture2D texture, Microsoft.Xna.Framework.Rectangle? sourceRect, float scale);
Parameters
texture
Texture2D
The source image/tile sheet containing the button image.
sourceRect
Nullable<Rectangle>
The location within the texture
where the image is located, or null
to draw the entire texture
.
scale
Single
Scale to apply, if the destination size should be different from the size of the sourceRect
.
Remarks
If no texture
is specified, then all other parameters are ignored and the default close button sprite is drawn. Otherwise, a custom sprite will be drawn using the specified parameters.
SetCursorAttachment(Texture2D, Rectangle?, Point?, Point?, Color?)
Begins displaying a cursor attachment, i.e. a sprite that follows the mouse cursor.
void SetCursorAttachment(Microsoft.Xna.Framework.Graphics.Texture2D texture, Microsoft.Xna.Framework.Rectangle? sourceRect, Microsoft.Xna.Framework.Point? size, Microsoft.Xna.Framework.Point? offset, Microsoft.Xna.Framework.Color? tint);
Parameters
texture
Texture2D
The source image/tile sheet containing the cursor image.
sourceRect
Nullable<Rectangle>
The location within the texture
where the image is located, or null
to draw the entire texture
.
size
Nullable<Point>
Destination size for the cursor sprite, if different from the size of the sourceRect
.
offset
Nullable<Point>
Offset between the actual mouse position and the top-left corner of the drawn cursor sprite.
tint
Nullable<Color>
Optional tint color to apply to the drawn cursor sprite.
Remarks
The cursor is shown in addition to, not instead of, the normal mouse cursor.
SetGutters(int, int, int, int)
Configures the menu's gutter widths/heights.
Parameters
left
Int32
The gutter width on the left side of the viewport.
top
Int32
The gutter height at the top of the viewport.
right
Int32
The gutter width on the right side of the viewport. The default value of -1
specifies that the left
value should be mirrored on the right.
bottom
Int32
The gutter height at the bottom of the viewport. The default value of -1
specifies that the top
value should be mirrored on the bottom.
Remarks
Gutters are areas of the screen that the menu should not occupy. These are typically used with a menu whose root view uses Stretch() for one of its Layout dimensions, and allows limiting the max width/height relative to the viewport size.
The historical reason for gutters is overscan, however they are still commonly used for aesthetic reasons.
Events
Closed
Event raised after the menu has been closed.
Event Type
Closing
Event raised when the menu is about to close.
Event Type
Remarks
This has the same lifecycle as cleanupBeforeExit().