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
Color
public Vec4f Color
Field Value
Composed
public bool Composed
Field Value
DialogName
public string DialogName
Field Value
Enabled
public bool Enabled
Field Value
MouseOverCursor
public string MouseOverCursor
Field Value
OnFocusChanged
public Action<bool> OnFocusChanged
Field Value
Outlines
public static int Outlines
Field Value
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
bounds
protected ElementBounds bounds
Field Value
conditionalAdds
protected Stack<bool> conditionalAdds
Field Value
currentElementKey
protected int currentElementKey
Field Value
currentFocusableElementKey
protected int currentFocusableElementKey
Field Value
interactiveElementsInDrawOrder
protected List<GuiElement> interactiveElementsInDrawOrder
Field Value
lastAddedElement
protected GuiElement lastAddedElement
Field Value
lastAddedElementBounds
protected ElementBounds lastAddedElementBounds
Field Value
parentBoundsForNextElement
protected Stack<ElementBounds> parentBoundsForNextElement
Field Value
staticElementsTexture
protected LoadedTexture staticElementsTexture
Field Value
zDepth
public float zDepth
Field Value
Properties
Bounds
public ElementBounds Bounds { get; }
Property Value
CurParentBounds
public ElementBounds CurParentBounds { get; }
Property Value
CurrentElementKey
A unique number assigned to each element
public int CurrentElementKey { get; }
Property Value
CurrentTabIndexElement
Gets the currently tabbed index element, if there is one currently focused.
public GuiElement CurrentTabIndexElement { get; }
Property Value
FirstTabbableElement
public GuiElement FirstTabbableElement { get; }
Property Value
this[string]
Retrieve gui element by key. Returns null if not found.
public GuiElement this[string key] { get; }
Parameters
key
string
Property Value
LastAddedElement
public GuiElement LastAddedElement { get; }
Property Value
LastAddedElementBounds
public ElementBounds LastAddedElementBounds { get; }
Property Value
MaxTabIndex
Gets the maximum tab index of the components.
public int MaxTabIndex { get; }
Property Value
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
boolWhen the following slots should be added
Returns
AddInteractiveElement(GuiElement, string)
Adds an interactive element to the composer.
public GuiComposer AddInteractiveElement(GuiElement element, string key = null)
Parameters
element
GuiElementThe element to add.
key
stringThe name of the element. (default: null)
Returns
AddStaticElement(GuiElement, string)
Adds a static element to the composer.
public GuiComposer AddStaticElement(GuiElement element, string key = null)
Parameters
element
GuiElementThe element to add.
key
stringThe name of the element (default: null)
Returns
BeginChildElements()
Starts a set of child elements.
public GuiComposer BeginChildElements()
Returns
BeginChildElements(ElementBounds)
Starts a set of child elements.
public GuiComposer BeginChildElements(ElementBounds bounds)
Parameters
bounds
ElementBoundsThe bounds for the child elements.
Returns
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
boolWhether or not to put the first element in focus.
Returns
CreateEmpty(ICoreClientAPI)
Creates an empty GuiComposer.
public static GuiComposer CreateEmpty(ICoreClientAPI api)
Parameters
api
ICoreClientAPIThe 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
EndIf()
End of the AddIf block.
public GuiComposer EndIf()
Returns
Execute(Action)
Runs given method
public GuiComposer Execute(Action method)
Parameters
method
Action
Returns
FocusElement(int)
marks an element as in focus.
public bool FocusElement(int tabIndex)
Parameters
tabIndex
intThe 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
stringThe name of the element to get.
Returns
OnKeyDown(KeyEvent, bool)
Fires the OnKeyDown events.
public void OnKeyDown(KeyEvent args, bool haveFocus)
Parameters
OnKeyPress(KeyEvent)
Fires the OnKeyPress event.
public void OnKeyPress(KeyEvent args)
Parameters
args
KeyEventThe keyboard information
OnKeyUp(KeyEvent)
Fires the OnKeyDown events.
public void OnKeyUp(KeyEvent args)
Parameters
args
KeyEventThe keyboard information.
OnMouseDown(MouseEvent)
Fires the OnMouseDown events.
public void OnMouseDown(MouseEvent mouseArgs)
Parameters
mouseArgs
MouseEventThe mouse information.
OnMouseEnterSlot(ItemSlot)
public bool OnMouseEnterSlot(ItemSlot slot)
Parameters
slot
ItemSlot
Returns
OnMouseLeaveSlot(ItemSlot)
public bool OnMouseLeaveSlot(ItemSlot slot)
Parameters
slot
ItemSlot
Returns
OnMouseMove(MouseEvent)
Fires the OnMouseMove events.
public void OnMouseMove(MouseEvent mouse)
Parameters
mouse
MouseEventThe mouse information.
OnMouseUp(MouseEvent)
Fires the OnMouseUp events.
public void OnMouseUp(MouseEvent mouse)
Parameters
mouse
MouseEventThe mouse information.
OnMouseWheel(MouseWheelEventArgs)
Fires the OnMouseWheel events.
public void OnMouseWheel(MouseWheelEventArgs mouse)
Parameters
mouse
MouseWheelEventArgsThe mouse wheel information.
OnlyDynamic()
Sets the render to Dynamic components only
public GuiComposer OnlyDynamic()
Returns
PostRender(float)
Fires the PostRender event.
public void PostRender(float deltaTime)
Parameters
deltaTime
floatThe 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
ReCompose()
Rebuilds the Composed GUI.
public void ReCompose()
Render(float)
Fires the render event.
public void Render(float deltaTime)
Parameters
deltaTime
floatThe 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
GuiElementThe element to remain in focus.
Events
OnComposed
Triggered when the gui scale changed or the game window was resized
public event Action OnComposed