tModLoader v2024.10
A mod to make and play Terraria mods
UIText Class Reference

Inherits UIElement.

Public Member Functions

 UIText (LocalizedText text, float textScale=1f, bool large=false)
 
 UIText (string text, float textScale=1f, bool large=false)
 
override void Recalculate ()
 
void SetText (LocalizedText text)
 
void SetText (LocalizedText text, float textScale, bool large)
 
void SetText (string text)
 
void SetText (string text, float textScale, bool large)
 
- Public Member Functions inherited from UIElement
void Activate ()
 
void Append (UIElement element)
 Adds the element as a child of this element. The UI system expects children elements to be positioned within the bounds of the parent element and will not work correctly if this restriction is not followed.
 
virtual int CompareTo (object obj)
 
virtual bool ContainsPoint (Vector2 point)
 
void CopyStyle (UIElement element)
 
void Deactivate ()
 
virtual void Draw (SpriteBatch spriteBatch)
 
void DrawDebugHitbox (BasicDebugDrawer drawer, float colorIntensity=0f)
 
delegate void ElementEvent (UIElement affectedElement)
 
virtual void ExecuteRecursively (UIElementAction action)
 
Rectangle GetClippingRectangle (SpriteBatch spriteBatch)
 
CalculatedStyle GetDimensions ()
 The dimensions of the area covered by this element. This is the area of this element interactible by the mouse. The width and height are derived from the Width and Height values of this element and will be limited by MinWidth/MaxWidth/MinHeight/MaxHeight as well as the GetInnerDimensions of the parent element. The position is derived from the Top, Left, HAlign, VAlign, and MarginLeft/Right/Top/Bottom values of this element as well as the GetInnerDimensions of the parent element.
 
UIElement GetElementAt (Vector2 point)
 
CalculatedStyle GetInnerDimensions ()
 The dimensions of the area within this element suitable for placing children elements. Takes into account PaddingLeft/Right/Top/Bottom.
 
CalculatedStyle GetOuterDimensions ()
 The dimensions of the area covered by this element plus the additional MarginLeft/Right/Top/Bottom.
 
bool GetSnapPoint (out SnapPoint point)
 
virtual List< SnapPointGetSnapPoints ()
 
virtual Rectangle GetViewCullingArea ()
 
bool HasChild (UIElement child)
 
void Initialize ()
 
virtual void LeftClick (UIMouseEvent evt)
 
virtual void LeftDoubleClick (UIMouseEvent evt)
 
virtual void LeftMouseDown (UIMouseEvent evt)
 Called when the UIElement under the mouse is left clicked. The default code calls the OnLeftMouseDown event and then calls LeftMouseDown on the Parent element. Since the method is called on all parent elements in the hierarchy, check if (evt.Target == this) for code only interested in direct clicks to this element. Children elements overlaying this element can be ignored by setting IgnoresMouseInteraction to true on them. More...
 
virtual void LeftMouseUp (UIMouseEvent evt)
 
virtual void MiddleClick (UIMouseEvent evt)
 
virtual void MiddleDoubleClick (UIMouseEvent evt)
 
virtual void MiddleMouseDown (UIMouseEvent evt)
 
virtual void MiddleMouseUp (UIMouseEvent evt)
 
delegate void MouseEvent (UIMouseEvent evt, UIElement listeningElement)
 
virtual void MouseOut (UIMouseEvent evt)
 Called once when this UIElement is no longer moused over. Default implementation sets IsMouseHovering to false, calls OnMouseOut event, then calls this same method on the Parent element. Useful for changing visuals to indicate the element is no longer interactable, as is the OnMouseOut event. MouseOver(UIMouseEvent) will be called when it is hovered once again. More...
 
virtual void MouseOver (UIMouseEvent evt)
 Called once when this UIElement becomes moused over (hovered). Default implementation sets IsMouseHovering to true, calls OnMouseOver event, then calls this same method on the Parent element. Useful for changing visuals to indicate the element is interactable, as is the OnMouseOver event. Any code that needs to run as long as the element is hovered should use check IsMouseHovering in Update(GameTime). MouseOut(UIMouseEvent) will be called when it no longer hovered. More...
 
virtual void OnActivate ()
 Called each time this element is activated, which is usually when a UIState is activated via UserInterface.SetState(UIState). Use this to run code to update elements whenever the UI is toggled on. More...
 
virtual void OnDeactivate ()
 
virtual void OnInitialize ()
 Called before the first time this element is activated (see OnActivate). Use this method to create and append other UIElement to this to build a UI. More...
 
virtual void Recalculate ()
 
virtual void RecalculateChildren ()
 
void Remove ()
 
void RemoveAllChildren ()
 
void RemoveChild (UIElement child)
 
virtual void RightClick (UIMouseEvent evt)
 
virtual void RightDoubleClick (UIMouseEvent evt)
 
virtual void RightMouseDown (UIMouseEvent evt)
 
virtual void RightMouseUp (UIMouseEvent evt)
 
virtual void ScrollWheel (UIScrollWheelEvent evt)
 
delegate void ScrollWheelEvent (UIScrollWheelEvent evt, UIElement listeningElement)
 
void SetPadding (float pixels)
 
void SetSnapPoint (string name, int id, Vector2? anchor=null, Vector2? offset=null)
 
delegate void UIElementAction (UIElement element)
 
virtual void Update (GameTime gameTime)
 
virtual void XButton1Click (UIMouseEvent evt)
 
virtual void XButton1DoubleClick (UIMouseEvent evt)
 
virtual void XButton1MouseDown (UIMouseEvent evt)
 
virtual void XButton1MouseUp (UIMouseEvent evt)
 
virtual void XButton2Click (UIMouseEvent evt)
 
virtual void XButton2DoubleClick (UIMouseEvent evt)
 
virtual void XButton2MouseDown (UIMouseEvent evt)
 
virtual void XButton2MouseUp (UIMouseEvent evt)
 

Public Attributes

bool DynamicallyScaleDownToWidth
 
- Public Attributes inherited from UIElement
float HAlign
 Aligns the element horizontally within the available space. A value of 1 will place the element at the right side. A value of 0.5 will place the element centered horizontally.
 
StyleDimension Height
 How tall this element intends to be. The calculated height will be clamped between MinHeight and MaxHeight according to the GetInnerDimensions of the parent element.
 
bool IgnoresMouseInteraction
 If true, this element will be ignored for mouse interactions. This can be used to allow UIElement placed over other UIElement to not be the target of mouse clicks. Defaults to false.
 
StyleDimension Left
 How far right from the left edge of the Parent element's GetInnerDimensions that this element will be positioned. See also VAlign for another positioning option.
 
float MarginBottom
 
float MarginLeft
 
float MarginRight
 
float MarginTop
 Additional spacing between this element and the GetInnerDimensions of its parent element.
 
StyleDimension MaxHeight = StyleDimension.Fill
 The maximum height of this element. Defaults to the full height.
 
StyleDimension MaxWidth = StyleDimension.Fill
 The maximum width of this element. Defaults to the full width.
 
StyleDimension MinHeight = StyleDimension.Empty
 The maximum width of this element. Defaults to no height.
 
StyleDimension MinWidth = StyleDimension.Empty
 The minimum width of this element. Defaults to no width.
 
bool OverflowHidden
 
SamplerState OverrideSamplerState
 
float PaddingBottom
 
float PaddingLeft
 
float PaddingRight
 
float PaddingTop
 Additional spacing between this element's GetDimensions and the position of its children placed within.
 
StyleDimension Top
 How far down from the top edge of the Parent element's GetInnerDimensions that this element will be positioned. See also HAlign for another positioning option.
 
bool UseImmediateMode
 
float VAlign
 Aligns the element vertically within the available space. A value of 1 will place the element at the bottom. A value of 0.5 will place the element centered vertically.
 
StyleDimension Width
 How wide this element intends to be. The calculated width will be clamped between MinWidth and MaxWidth according to the GetInnerDimensions of the parent element.
 

Protected Member Functions

override void DrawSelf (SpriteBatch spriteBatch)
 
- Protected Member Functions inherited from UIElement
virtual void DrawChildren (SpriteBatch spriteBatch)
 
virtual void DrawSelf (SpriteBatch spriteBatch)
 

Properties

bool IsWrapped [get, set]
 
Color ShadowColor [get, set]
 
string Text [get]
 
Color TextColor [get, set]
 
float TextOriginX [get, set]
 
float TextOriginY [get, set]
 
float WrappedTextBottomPadding [get, set]
 
- Properties inherited from UIElement
IEnumerable< UIElementChildren [get]
 
bool IsMouseHovering [get]
 True when the mouse is hovering over this UIElement. Useful for setting hover tooltips in DrawSelf or drawing hover visual indicators. Note that this is true for all elements in the hierarchy that are hovered, not just the topmost element. For example, hovering over a button that is appended to a panel will mean that IsMouseHovering is true for the button and the panel. Use this or ContainsPoint(Main.MouseScreen) for behaviors that use this logic, such as setting Player.mouseInterface to true.
 
UIElement Parent [get]
 The element this element is appended to.
 
int UniqueId [get]
 

Events

Action OnInternalTextChange
 
- Events inherited from UIElement
MouseEvent OnLeftClick
 
MouseEvent OnLeftDoubleClick
 
MouseEvent OnLeftMouseDown
 
MouseEvent OnLeftMouseUp
 
MouseEvent OnMiddleClick
 
MouseEvent OnMiddleDoubleClick
 
MouseEvent OnMiddleMouseDown
 
MouseEvent OnMiddleMouseUp
 
MouseEvent OnMouseOut
 Called by MouseOut(UIMouseEvent). Use this event instead of inheritance if suitable.
 
MouseEvent OnMouseOver
 Called by MouseOver(UIMouseEvent). Use this event instead of inheritance if suitable.
 
MouseEvent OnRightClick
 
MouseEvent OnRightDoubleClick
 
MouseEvent OnRightMouseDown
 
MouseEvent OnRightMouseUp
 
ScrollWheelEvent OnScrollWheel
 
ElementEvent OnUpdate
 
MouseEvent OnXButton1Click
 
MouseEvent OnXButton1DoubleClick
 
MouseEvent OnXButton1MouseDown
 
MouseEvent OnXButton1MouseUp
 
MouseEvent OnXButton2Click
 
MouseEvent OnXButton2DoubleClick
 
MouseEvent OnXButton2MouseDown
 
MouseEvent OnXButton2MouseUp
 

Additional Inherited Members

- Protected Attributes inherited from UIElement
readonly List< UIElementElements = new List<UIElement>()
 

Member Function Documentation

◆ DrawSelf()

override void UIText.DrawSelf ( SpriteBatch  spriteBatch)
protectedvirtual

Reimplemented from UIElement.

◆ Recalculate()

override void UIText.Recalculate ( )
virtual

Reimplemented from UIElement.