Table of Contents

Class Menus

Namespace
TinyLife.Uis
Assembly
Tiny Life.dll

A set of static methods to deal with MLEM.Ui and in-game menus

public static class Menus
Inheritance
Menus
Inherited Members

Methods

CreateHouseholdPreview(string, bool)

A helper method that creates an action that can be invoked to render a preview of an ExportedHousehold at the given file path.

public static Action<(SpriteBatch Batch, Vector2 Position, float Width, float Scale)> CreateHouseholdPreview(string fileName, bool async = true)

Parameters

fileName string

The file name to load the ExportedHousehold from.

async bool

Whether the ExportedHousehold should be loaded from disk asynchronously.

Returns

Action<(SpriteBatch Batch, Vector2 Position, float Width, float Scale)>

An action that can be invoked to render a preview of the household.

CreateLotPreview(Map, string, Point, float, Color, bool)

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)

Parameters

map Map

The map to mock rendering the lot on.

fileName string

The file name of the ExportedLot file.

size Point

The size of the texture that should be returned.

tileScale float

The scale that tiles should be rendered with.

backgroundColor Color

The background color to use for the texture.

async bool

Whether the ExportedLot 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.

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 Anchor

The anchor for the image.

button Func<Options, Buttons>

A function that returns the button that should be displayed.

positionOffset Vector2

The 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.

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 float

The x coordinate of the menu background section to return, which is expected to be between 0 and 1.

y float

The y coordinate of the menu background section to return, which is expected to be between 0 and 1.

width float

The width of the menu background section to return, which is expected to be between 1 and 2.

height float

The 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.

public static void 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 Action

The action that is invoked while the screen is faded out, or null to invoke no action.

after Action

The action that is invoked after the full fade routine completes, or null to invoke no action.

outType Menus.TransitionType

The Menus.TransitionType used for fading out.

inType Menus.TransitionType

The Menus.TransitionType used for fading in.

outSpeed float

The speed with which outType is displayed per frame.

inSpeed float

The speed with which inType is displayed per frame.

waitInbetween float

The 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.

Exceptions

InvalidOperationException

Thrown when a fade is already happening when this method is called.