Class Menus
A set of static methods to deal with MLEM.Ui and in-game menus
public static class Menus
- Inheritance
-
Menus
- Inherited Members
Methods
CreateHouseholdPreview(IEnumerable<PersonLike>, Point, float, Color)
A helper method that creates a preview of the given ExportedHousehold.
public static RenderTarget2D CreateHouseholdPreview(IEnumerable<PersonLike> people, Point size, float scale, Color backgroundColor)
Parameters
peopleIEnumerable<PersonLike>The people that are part of the household. ValidatePeople(Map) should have been called on this collection before this method is called.
sizePointThe size of the resulting preview image, in pixels.
scalefloatThe scale that the household is drawn onto the preview image with.
backgroundColorColorThe color to use for the background of the preview image.
Returns
- RenderTarget2D
The generated texture.
CreateHouseholdPreview(Map, string, Point, float, Color, bool)
A helper method that creates a preview of an ExportedHousehold at the given file path.
public static Func<Texture2D> CreateHouseholdPreview(Map map, string fileName, Point size, float scale, Color backgroundColor, bool async = true)
Parameters
mapMapThe map to create the household preview on.
fileNamestringThe file name to load the ExportedHousehold from.
sizePointThe size of the resulting preview image, in pixels.
scalefloatThe scale that the household is drawn onto the preview image with.
backgroundColorColorThe color to use for the background of the preview image.
asyncboolWhether the ExportedHousehold should be loaded from disk asynchronously.
Returns
- Func<Texture2D>
A function that gathers the generated texture. When first invoked, it is generated. Subsequent calls will return the same generated texture.
CreateLotPreview(ExportedLot, Point, Color, int?)
A helper method to create a Microsoft.Xna.Framework.Graphics.Texture2D instance that contains a rendered preview of the given ExportedLot.
public static RenderTarget2D CreateLotPreview(ExportedLot lot, Point size, Color backgroundColor, int? currentFloor = null)
Parameters
lotExportedLotThe exported lot of which to generate a preview. ValidateForPreview(Map) should have been called prior to this method being called.
sizePointThe size of the texture that should be returned.
backgroundColorColorThe background color to use for the texture.
currentFloorint?The currently selected floor, floors above which will not be drawn.
Returns
- RenderTarget2D
The generated texture.
CreateLotPreview(Map, string, Point, Color, bool, int?)
A helper method to create a Microsoft.Xna.Framework.Graphics.Texture2D instance that contains a rendered preview of an ExportedLot at the given file path.
public static Func<Texture2D> CreateLotPreview(Map map, string fileName, Point size, Color backgroundColor, bool async = true, int? currentFloor = null)
Parameters
mapMapThe map to mock rendering the lot on.
fileNamestringThe file name of the ExportedLot file.
sizePointThe size of the texture that should be returned.
backgroundColorColorThe background color to use for the texture.
asyncboolWhether the ExportedLot should be loaded from disk asynchronously.
currentFloorint?The currently selected floor, floors above which will not be drawn.
Returns
- Func<Texture2D>
A function that gathers the generated texture. When first invoked, it is generated. Subsequent calls will return the same generated texture.
DisplayBriefTooltip(Tooltip, Element, string, double)
A helper method that uses a Coroutine to display a static tooltip centered on the given element for the given amount of seconds. This is generally useful for situations in which a tooltip is usually displayed when hovering with a mouse, but for elements which aren't ever actively selected using a gamepad, like tabs.
public static void DisplayBriefTooltip(Tooltip tooltip, Element element, string name, double seconds)
Parameters
tooltipTooltipThe tooltip to display.
elementElementThe element to display the tooltip on.
namestringThe name of the tooltip, which will be used in Display(UiSystem, string).
secondsdoubleThe amount of seconds the tooltip should display for.
GamepadHint(Anchor, Func<Options, Buttons>, Vector2, Vector2?, Func<bool>)
Returns a new image that displays information about what gamepad Microsoft.Xna.Framework.Input.Buttons can be pressed to invoke an action.
This image is automatically hidden if gamepad controls are not currently being used, or if shouldHide returns true.
public static Image GamepadHint(Anchor anchor, Func<Options, Buttons> button, Vector2 positionOffset = default, Vector2? size = null, Func<bool> shouldHide = null)
Parameters
anchorAnchorThe anchor for the image.
buttonFunc<Options, Buttons>A function that returns the button that should be displayed.
positionOffsetVector2The position offset for the image.
sizeVector2?The size of the image, or null for the image to be 12 pixels big.
shouldHideFunc<bool>A function that determines whether the hint should currently be hidden, or null to only hide it when gamepad controls are not currently being used.
Returns
- Image
The created gamepad hint image.
IsTransitioning()
Returns whether the UI is currently transitioning, ie whether a transition is active that was invoked through Transition(Action, Action, TransitionType, TransitionType, float, float, float, Color?).
public static bool IsTransitioning()
Returns
- bool
Whether a transition is active.
MenuBackground(float, float, float, float)
Returns a MLEM.Textures.NinePatch that contains a menu background texture region, based on the given data.
public static NinePatch MenuBackground(float x, float y, float width = 1, float height = 1)
Parameters
xfloatThe x coordinate of the menu background section to return, which is expected to be between 0 and 1.
yfloatThe y coordinate of the menu background section to return, which is expected to be between 0 and 1.
widthfloatThe width of the menu background section to return, which is expected to be between 1 and 2.
heightfloatThe height of the menu background section to return, which is expected to be between 1 and 2.
Returns
- NinePatch
A MLEM.Textures.NinePatch that contains a menu background texture region.
Transition(Action, Action, TransitionType, TransitionType, float, float, float, Color?)
Displays a screen transition that includes a fade out, an inbetween action, followed by a fade back in and an after action.
Whether a transition is currently active can be checked for using IsTransitioning(), at which point this method will return false.
public static bool Transition(Action inbetween = null, Action after = null, Menus.TransitionType outType = TransitionType.Swipe, Menus.TransitionType inType = TransitionType.Swipe, float outSpeed = 0.05, float inSpeed = 0.05, float waitInbetween = 0.15, Color? color = null)
Parameters
inbetweenActionThe action that is invoked while the screen is faded out, or null to invoke no action.
afterActionThe action that is invoked after the full fade routine completes, or null to invoke no action.
outTypeMenus.TransitionTypeThe Menus.TransitionType used for fading out.
inTypeMenus.TransitionTypeThe Menus.TransitionType used for fading in.
outSpeedfloatThe speed with which
outTypeis displayed per frame.inSpeedfloatThe speed with which
inTypeis displayed per frame.waitInbetweenfloatThe amount of time to wait while the screen is faded out.
colorColor?The color that the fade should have, or null to use black.