Table of Contents

Class GuiComposer

Namespace
Vintagestory.API.Client
Assembly
VintagestoryAPI.dll

Composes a dialog which are made from a set of elements The composed dialog is cached, so to recompose you have to Recompose All elements or instantiate a new composer with doCache set to false The caching allows the dialog using the composer to not worry about performance and just call compose whenever it has to display a new composed dialog You add components by chaining the functions of the composer together for building the result.

public class GuiComposer : IDisposable
Inheritance
GuiComposer
Implements
Inherited Members
Extension Methods

Fields

Api

public ICoreClientAPI Api

Field Value

ICoreClientAPI

Color

public Vec4f Color

Field Value

Vec4f

Composed

public bool Composed

Field Value

bool

Enabled

public bool Enabled

Field Value

bool

MouseOverCursor

public string MouseOverCursor

Field Value

string

OnFocusChanged

public Action<bool> OnFocusChanged

Field Value

Action<bool>

Outlines

public static int Outlines

Field Value

int

Tabbable

Whether or not the Tab-Key down event should be used and consumed to cycle-focus individual gui elements

public bool Tabbable

Field Value

bool

bounds

protected ElementBounds bounds

Field Value

ElementBounds

conditionalAdds

protected Stack<bool> conditionalAdds

Field Value

Stack<bool>

currentElementKey

protected int currentElementKey

Field Value

int

currentFocusableElementKey

protected int currentFocusableElementKey

Field Value

int

interactiveElementsInDrawOrder

protected List<GuiElement> interactiveElementsInDrawOrder

Field Value

List<GuiElement>

lastAddedElement

protected GuiElement lastAddedElement

Field Value

GuiElement

lastAddedElementBounds

protected ElementBounds lastAddedElementBounds

Field Value

ElementBounds

parentBoundsForNextElement

protected Stack<ElementBounds> parentBoundsForNextElement

Field Value

Stack<ElementBounds>

staticElementsTexture

protected LoadedTexture staticElementsTexture

Field Value

LoadedTexture

zDepth

public float zDepth

Field Value

float

Properties

Bounds

public ElementBounds Bounds { get; }

Property Value

ElementBounds

CurParentBounds

public ElementBounds CurParentBounds { get; }

Property Value

ElementBounds

CurrentElementKey

A unique number assigned to each element

public int CurrentElementKey { get; }

Property Value

int

CurrentTabIndexElement

Gets the currently tabbed index element, if there is one currently focused.

public GuiElement CurrentTabIndexElement { get; }

Property Value

GuiElement

FirstTabbableElement

public GuiElement FirstTabbableElement { get; }

Property Value

GuiElement

this[string]

Retrieve gui element by key. Returns null if not found.

public GuiElement this[string key] { get; }

Parameters

key string

Property Value

GuiElement

LastAddedElement

public GuiElement LastAddedElement { get; }

Property Value

GuiElement

MaxTabIndex

Gets the maximum tab index of the components.

public int MaxTabIndex { get; }

Property Value

int

Methods

AddIf(bool)

Adds a condition for adding a group of items to the GUI- eg: if you have a crucible in the firepit, add those extra slots. Should always pair with an EndIf()

public GuiComposer AddIf(bool condition)

Parameters

condition bool

When the following slots should be added

Returns

GuiComposer

AddInteractiveElement(GuiElement, string)

Adds an interactive element to the composer.

public GuiComposer AddInteractiveElement(GuiElement element, string key = null)

Parameters

element GuiElement

The element to add.

key string

The name of the element. (default: null)

Returns

GuiComposer

AddStaticElement(GuiElement, string)

Adds a static element to the composer.

public GuiComposer AddStaticElement(GuiElement element, string key = null)

Parameters

element GuiElement

The element to add.

key string

The name of the element (default: null)

Returns

GuiComposer

BeginChildElements()

Starts a set of child elements.

public GuiComposer BeginChildElements()

Returns

GuiComposer

BeginChildElements(ElementBounds)

Starts a set of child elements.

public GuiComposer BeginChildElements(ElementBounds bounds)

Parameters

bounds ElementBounds

The bounds for the child elements.

Returns

GuiComposer

Clear(ElementBounds)

public void Clear(ElementBounds newBounds)

Parameters

newBounds ElementBounds

Compose(bool)

Tells the composer to compose the gui.

public GuiComposer Compose(bool focusFirstElement = true)

Parameters

focusFirstElement bool

Whether or not to put the first element in focus.

Returns

GuiComposer

CreateEmpty(ICoreClientAPI)

Creates an empty GuiComposer.

public static GuiComposer CreateEmpty(ICoreClientAPI api)

Parameters

api ICoreClientAPI

The Client API

Returns

GuiComposer

An empty GuiComposer.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

EndChildElements()

End of the current set of child elements.

public GuiComposer EndChildElements()

Returns

GuiComposer

EndIf()

End of the AddIf block.

public GuiComposer EndIf()

Returns

GuiComposer

Execute(Action)

Runs given method

public GuiComposer Execute(Action method)

Parameters

method Action

Returns

GuiComposer

FocusElement(int)

marks an element as in focus.

public bool FocusElement(int tabIndex)

Parameters

tabIndex int

The tab index to focus at.

Returns

bool

Whether or not the focus could be done.

GetElement(string)

Gets the element by name.

public GuiElement GetElement(string key)

Parameters

key string

The name of the element to get.

Returns

GuiElement

OnKeyDown(KeyEvent, bool)

Fires the OnKeyDown events.

public void OnKeyDown(KeyEvent args, bool haveFocus)

Parameters

args KeyEvent

The keyboard information.

haveFocus bool

Whether or not the gui has focus.

OnKeyPress(KeyEvent)

Fires the OnKeyPress event.

public void OnKeyPress(KeyEvent args)

Parameters

args KeyEvent

The keyboard information

OnKeyUp(KeyEvent)

Fires the OnKeyDown events.

public void OnKeyUp(KeyEvent args)

Parameters

args KeyEvent

The keyboard information.

OnMouseDown(MouseEvent)

Fires the OnMouseDown events.

public void OnMouseDown(MouseEvent mouseArgs)

Parameters

mouseArgs MouseEvent

The mouse information.

OnMouseEnterSlot(ItemSlot)

public bool OnMouseEnterSlot(ItemSlot slot)

Parameters

slot ItemSlot

Returns

bool

OnMouseLeaveSlot(ItemSlot)

public bool OnMouseLeaveSlot(ItemSlot slot)

Parameters

slot ItemSlot

Returns

bool

OnMouseMove(MouseEvent)

Fires the OnMouseMove events.

public void OnMouseMove(MouseEvent mouse)

Parameters

mouse MouseEvent

The mouse information.

OnMouseUp(MouseEvent)

Fires the OnMouseUp events.

public void OnMouseUp(MouseEvent mouse)

Parameters

mouse MouseEvent

The mouse information.

OnMouseWheel(MouseWheelEventArgs)

Fires the OnMouseWheel events.

public void OnMouseWheel(MouseWheelEventArgs mouse)

Parameters

mouse MouseWheelEventArgs

The mouse wheel information.

OnlyDynamic()

Sets the render to Dynamic components only

public GuiComposer OnlyDynamic()

Returns

GuiComposer

PostRender(float)

Fires the PostRender event.

public void PostRender(float deltaTime)

Parameters

deltaTime float

The change in time.

PremultipliedAlpha(bool)

On by default, is passed on to the gui elements as well. Disabling it means has a performance impact. Recommeded to leave enabled, but may need to be disabled to smoothly alpha blend text elements. Must be called before adding elements and before composing. Notice! Most gui elements even yet support non-premul alpha mode

public GuiComposer PremultipliedAlpha(bool enable)

Parameters

enable bool

Returns

GuiComposer

ReCompose()

Rebuilds the Composed GUI.

public void ReCompose()

Render(float)

Fires the render event.

public void Render(float deltaTime)

Parameters

deltaTime float

The change in time.

UnfocusOwnElements()

Unfocuses the elements within this GUI composer.

public void UnfocusOwnElements()

UnfocusOwnElementsExcept(GuiElement)

Unfocuses all elements except one specific element.

public void UnfocusOwnElementsExcept(GuiElement elem)

Parameters

elem GuiElement

The element to remain in focus.

Events

OnComposed

Triggered when the gui scale changed or the game window was resized

public event Action OnComposed

Event Type

Action