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(Map, string, Point, float, Color, bool, Func<string, ExportedHousehold>)
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, Func<string, ExportedHousehold> load = null)
Parameters
map
MapThe map to create the household preview on.
fileName
stringThe file name to load the ExportedHousehold from.
size
PointThe size of the resulting preview image, in pixels.
scale
floatThe scale that the household is drawn onto the preview image with.
backgroundColor
ColorThe color to use for the background of the preview image.
async
boolWhether the ExportedHousehold should be loaded from disk asynchronously.
load
Func<string, ExportedHousehold>A function that can optionally be used to load the ExportedHousehold to draw. It receives the
fileName
passed as an argument.
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(Map, string, Point, float, Color, bool, Func<string, ExportedLot>)
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, float tileScale, Color backgroundColor, bool async = true, Func<string, ExportedLot> load = null)
Parameters
map
MapThe map to mock rendering the lot on.
fileName
stringThe file name of the ExportedLot file.
size
PointThe size of the texture that should be returned.
tileScale
floatThe scale that tiles should be rendered with.
backgroundColor
ColorThe background color to use for the texture.
async
boolWhether the ExportedLot should be loaded from disk asynchronously.
load
Func<string, ExportedLot>A function that can optionally be used to load the ExportedLot to draw. It receives the
fileName
passed as an argument.
Returns
- Func<Texture2D>
A function that gathers the generated texture. When first invoked, it is generated. Subsequent calls will return the same generated texture.
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
anchor
AnchorThe anchor for the image.
button
Func<Options, Buttons>A function that returns the button that should be displayed.
positionOffset
Vector2The position offset for the image.
size
Vector2?The size of the image, or null for the image to be 12 pixels big.
shouldHide
Func<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
x
floatThe x coordinate of the menu background section to return, which is expected to be between 0 and 1.
y
floatThe y coordinate of the menu background section to return, which is expected to be between 0 and 1.
width
floatThe width of the menu background section to return, which is expected to be between 1 and 2.
height
floatThe 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
inbetween
ActionThe action that is invoked while the screen is faded out, or null to invoke no action.
after
ActionThe action that is invoked after the full fade routine completes, or null to invoke no action.
outType
Menus.TransitionTypeThe Menus.TransitionType used for fading out.
inType
Menus.TransitionTypeThe Menus.TransitionType used for fading in.
outSpeed
floatThe speed with which
outType
is displayed per frame.inSpeed
floatThe speed with which
inType
is displayed per frame.waitInbetween
floatThe amount of time to wait while the screen is faded out.
color
Color?The color that the fade should have, or null to use black.