Table of Contents

Class DefaultHUD

Namespace
Squiggles.Core.Scenes.UI
Assembly
SquigglesCommon4X.dll

A fairly robust Heads Up Display (HUD) that handles many of the built-in signals such as subtitles, alerts, reticle, interaction prompts, and such.

[MarkForRefactor("Separation of Duties", "This class manages all of the individual, independant components that can make up a HUD. Splitting responsibilities would allow more customization for HUD layout")]
[ScriptPath("res://Core/Scenes/UI/HUD/DefaultHUD.cs")]
public class DefaultHUD : Control, IDisposable
Inheritance
GodotObject
Node
CanvasItem
Control
DefaultHUD
Implements
Inherited Members
Control.NotificationResized
Control.NotificationMouseEnter
Control.NotificationMouseExit
Control.NotificationFocusEnter
Control.NotificationFocusExit
Control.NotificationThemeChanged
Control.NotificationScrollBegin
Control.NotificationScrollEnd
Control.NotificationLayoutDirectionChanged
Control._CanDropData(Vector2, Variant)
Control._DropData(Vector2, Variant)
Control._GetDragData(Vector2)
Control._GetMinimumSize()
Control._GetTooltip(Vector2)
Control._GuiInput(InputEvent)
Control._HasPoint(Vector2)
Control.AcceptEvent()
Control.GetMinimumSize()
Control.GetCombinedMinimumSize()
Control.SetBegin(Vector2)
Control.SetEnd(Vector2)
Control.ResetSize()
Control.GetBegin()
Control.GetEnd()
Control.GetParentAreaSize()
Control.GetScreenPosition()
Control.GetRect()
Control.GetGlobalRect()
Control.HasFocus()
Control.GrabFocus()
Control.ReleaseFocus()
Control.FindPrevValidFocus()
Control.FindNextValidFocus()
Control.BeginBulkThemeOverride()
Control.EndBulkThemeOverride()
Control.AddThemeIconOverride(StringName, Texture2D)
Control.AddThemeStyleboxOverride(StringName, StyleBox)
Control.AddThemeFontOverride(StringName, Font)
Control.AddThemeColorOverride(StringName, Color)
Control.RemoveThemeIconOverride(StringName)
Control.RemoveThemeStyleboxOverride(StringName)
Control.RemoveThemeFontOverride(StringName)
Control.RemoveThemeFontSizeOverride(StringName)
Control.RemoveThemeColorOverride(StringName)
Control.RemoveThemeConstantOverride(StringName)
Control.GetThemeIcon(StringName, StringName)
Control.GetThemeStylebox(StringName, StringName)
Control.GetThemeFont(StringName, StringName)
Control.GetThemeFontSize(StringName, StringName)
Control.GetThemeColor(StringName, StringName)
Control.GetThemeConstant(StringName, StringName)
Control.HasThemeIconOverride(StringName)
Control.HasThemeStyleboxOverride(StringName)
Control.HasThemeFontOverride(StringName)
Control.HasThemeFontSizeOverride(StringName)
Control.HasThemeColorOverride(StringName)
Control.HasThemeConstantOverride(StringName)
Control.HasThemeIcon(StringName, StringName)
Control.HasThemeStylebox(StringName, StringName)
Control.HasThemeFont(StringName, StringName)
Control.HasThemeFontSize(StringName, StringName)
Control.HasThemeColor(StringName, StringName)
Control.HasThemeConstant(StringName, StringName)
Control.GetThemeDefaultBaseScale()
Control.GetThemeDefaultFont()
Control.GetThemeDefaultFontSize()
Control.GetParentControl()
Control.GetTooltip(Vector2?)
Control.GetCursorShape(Vector2?)
Control.ForceDrag(Variant, Control)
Control.GrabClickFocus()
Control.SetDragForwarding(Callable, Callable, Callable)
Control.SetDragPreview(Control)
Control.IsDragSuccessful()
Control.WarpMouse(Vector2)
Control.UpdateMinimumSize()
Control.IsLayoutRtl()
Control.ClipContents
Control.CustomMinimumSize
Control.LayoutDirection
Control.LayoutMode
Control.AnchorsPreset
Control.AnchorLeft
Control.AnchorTop
Control.AnchorRight
Control.AnchorBottom
Control.OffsetLeft
Control.OffsetTop
Control.OffsetRight
Control.OffsetBottom
Control.GrowHorizontal
Control.GrowVertical
Control.Size
Control.Position
Control.GlobalPosition
Control.Rotation
Control.RotationDegrees
Control.Scale
Control.PivotOffset
Control.SizeFlagsHorizontal
Control.SizeFlagsVertical
Control.SizeFlagsStretchRatio
Control.AutoTranslate
Control.LocalizeNumeralSystem
Control.TooltipText
Control.FocusNeighborLeft
Control.FocusNeighborTop
Control.FocusNeighborRight
Control.FocusNeighborBottom
Control.FocusNext
Control.FocusPrevious
Control.FocusMode
Control.MouseFilter
Control.MouseForcePassScrollEvents
Control.MouseDefaultCursorShape
Control.ShortcutContext
Control.Theme
Control.ThemeTypeVariation
Control.Resized
Control.GuiInput
Control.MouseEntered
Control.MouseExited
Control.FocusEntered
Control.FocusExited
Control.SizeFlagsChanged
Control.MinimumSizeChanged
Control.ThemeChanged
CanvasItem.NotificationTransformChanged
CanvasItem.NotificationLocalTransformChanged
CanvasItem.NotificationDraw
CanvasItem.NotificationVisibilityChanged
CanvasItem.NotificationEnterCanvas
CanvasItem.NotificationExitCanvas
CanvasItem.NotificationWorld2DChanged
CanvasItem._Draw()
CanvasItem.GetCanvasItem()
CanvasItem.IsVisibleInTree()
CanvasItem.Show()
CanvasItem.Hide()
CanvasItem.QueueRedraw()
CanvasItem.MoveToFront()
CanvasItem.DrawTexture(Texture2D, Vector2, Color?)
CanvasItem.DrawLcdTextureRectRegion(Texture2D, Rect2, Rect2, Color?)
CanvasItem.DrawStyleBox(StyleBox, Rect2)
CanvasItem.DrawPrimitive(Vector2[], Color[], Vector2[], Texture2D)
CanvasItem.DrawPolygon(Vector2[], Color[], Vector2[], Texture2D)
CanvasItem.DrawColoredPolygon(Vector2[], Color, Vector2[], Texture2D)
CanvasItem.DrawMesh(Mesh, Texture2D, Transform2D?, Color?)
CanvasItem.DrawMultimesh(MultiMesh, Texture2D)
CanvasItem.DrawSetTransformMatrix(Transform2D)
CanvasItem.DrawEndAnimation()
CanvasItem.GetTransform()
CanvasItem.GetGlobalTransform()
CanvasItem.GetGlobalTransformWithCanvas()
CanvasItem.GetViewportTransform()
CanvasItem.GetViewportRect()
CanvasItem.GetCanvasTransform()
CanvasItem.GetScreenTransform()
CanvasItem.GetLocalMousePosition()
CanvasItem.GetGlobalMousePosition()
CanvasItem.GetCanvas()
CanvasItem.GetWorld2D()
CanvasItem.IsLocalTransformNotificationEnabled()
CanvasItem.IsTransformNotificationEnabled()
CanvasItem.ForceUpdateTransform()
CanvasItem.MakeCanvasPositionLocal(Vector2)
CanvasItem.MakeInputLocal(InputEvent)
CanvasItem.Visible
CanvasItem.Modulate
CanvasItem.SelfModulate
CanvasItem.ShowBehindParent
CanvasItem.TopLevel
CanvasItem.ClipChildren
CanvasItem.LightMask
CanvasItem.VisibilityLayer
CanvasItem.ZIndex
CanvasItem.ZAsRelative
CanvasItem.YSortEnabled
CanvasItem.TextureFilter
CanvasItem.TextureRepeat
CanvasItem.Material
CanvasItem.UseParentMaterial
CanvasItem.Draw
CanvasItem.VisibilityChanged
CanvasItem.Hidden
CanvasItem.ItemRectChanged
Node.NotificationEnterTree
Node.NotificationExitTree
Node.NotificationMovedInParent
Node.NotificationReady
Node.NotificationPaused
Node.NotificationUnpaused
Node.NotificationPhysicsProcess
Node.NotificationProcess
Node.NotificationParented
Node.NotificationUnparented
Node.NotificationSceneInstantiated
Node.NotificationDragBegin
Node.NotificationDragEnd
Node.NotificationPathRenamed
Node.NotificationChildOrderChanged
Node.NotificationInternalProcess
Node.NotificationInternalPhysicsProcess
Node.NotificationPostEnterTree
Node.NotificationDisabled
Node.NotificationEnabled
Node.NotificationNodeRecacheRequested
Node.NotificationEditorPreSave
Node.NotificationEditorPostSave
Node.NotificationWMMouseEnter
Node.NotificationWMMouseExit
Node.NotificationWMWindowFocusIn
Node.NotificationWMWindowFocusOut
Node.NotificationWMCloseRequest
Node.NotificationWMGoBackRequest
Node.NotificationWMSizeChanged
Node.NotificationWMDpiChange
Node.NotificationVpMouseEnter
Node.NotificationVpMouseExit
Node.NotificationOsMemoryWarning
Node.NotificationTranslationChanged
Node.NotificationWMAbout
Node.NotificationCrash
Node.NotificationOsImeUpdate
Node.NotificationApplicationResumed
Node.NotificationApplicationPaused
Node.NotificationApplicationFocusIn
Node.NotificationApplicationFocusOut
Node.NotificationTextServerChanged
Node.GetNode<T>(NodePath)
Node.GetNodeOrNull<T>(NodePath)
Node.GetOwner<T>()
Node.GetOwnerOrNull<T>()
Node.GetParent<T>()
Node.GetParentOrNull<T>()
Node._EnterTree()
Node._GetConfigurationWarnings()
Node._ShortcutInput(InputEvent)
Node._UnhandledInput(InputEvent)
Node._UnhandledKeyInput(InputEvent)
Node.PrintOrphanNodes()
Node.RemoveChild(Node)
Node.HasNode(NodePath)
Node.GetNode(NodePath)
Node.GetNodeOrNull(NodePath)
Node.GetParent()
Node.HasNodeAndResource(NodePath)
Node.GetNodeAndResource(NodePath)
Node.IsInsideTree()
Node.IsAncestorOf(Node)
Node.IsGreaterThan(Node)
Node.GetPath()
Node.RemoveFromGroup(StringName)
Node.IsInGroup(StringName)
Node.GetGroups()
Node.PrintTree()
Node.PrintTreePretty()
Node.GetPhysicsProcessDeltaTime()
Node.IsPhysicsProcessing()
Node.GetProcessDeltaTime()
Node.IsProcessing()
Node.IsProcessingInput()
Node.IsProcessingShortcutInput()
Node.IsProcessingUnhandledInput()
Node.IsProcessingUnhandledKeyInput()
Node.CanProcess()
Node.IsDisplayedFolded()
Node.IsProcessingInternal()
Node.IsPhysicsProcessingInternal()
Node.GetWindow()
Node.GetLastExclusiveWindow()
Node.GetTree()
Node.CreateTween()
Node.GetSceneInstanceLoadPlaceholder()
Node.IsEditableInstance(Node)
Node.GetViewport()
Node.QueueFree()
Node.RequestReady()
Node.IsNodeReady()
Node.GetMultiplayerAuthority()
Node.IsMultiplayerAuthority()
Node.RpcConfig(StringName, Variant)
Node.Rpc(StringName, params Variant[])
Node.UpdateConfigurationWarnings()
Node.CallDeferredThreadGroup(StringName, params Variant[])
Node.SetDeferredThreadGroup(StringName, Variant)
Node.CallThreadSafe(StringName, params Variant[])
Node.SetThreadSafe(StringName, Variant)
Node._ImportPath
Node.Name
Node.UniqueNameInOwner
Node.SceneFilePath
Node.Owner
Node.Multiplayer
Node.ProcessMode
Node.ProcessPriority
Node.ProcessPhysicsPriority
Node.ProcessThreadGroup
Node.ProcessThreadGroupOrder
Node.ProcessThreadMessages
Node.EditorDescription
Node.Ready
Node.Renamed
Node.TreeEntered
Node.TreeExiting
Node.TreeExited
Node.ChildEnteredTree
Node.ChildExitingTree
Node.ChildOrderChanged
Node.ReplacingBy
GodotObject.NotificationPostinitialize
GodotObject.NotificationPredelete
GodotObject.NativeInstance
GodotObject.ScriptChanged
GodotObject.PropertyListChanged
Extension Methods

Remarks

Future refactor should probably strip logic into the individual components such that the "DefaultHUD" scene is just a composition of independantly functioning elements. This would allow users to quickly get up and running with a default hud, then customize as they develop.

Fields

MONEY_FORMAT_STRING

private const string MONEY_FORMAT_STRING = "N0"

Field Value

string

_colourTransparent

private Color _colourTransparent

Field Value

Color

_colourVisible

private Color _colourVisible

Field Value

Color

_curMoneyPopLabelTween

private Tween _curMoneyPopLabelTween

Field Value

Tween

_genericGUIRoot

The root control to load generic GUI elements into

[Export(PropertyHint.None, "")]
private Control _genericGUIRoot

Field Value

Control

_interactionPrompt

The label which handles interation prompts

[Export(PropertyHint.None, "")]
private Label _interactionPrompt

Field Value

Label

_inventorySlotPacked

The packed scene for the inventory

[ExportGroup("Inventory Stuff", "")]
[Export(PropertyHint.None, "")]
private PackedScene _inventorySlotPacked

Field Value

PackedScene

_lastKnownPlayerMoney

private int _lastKnownPlayerMoney

Field Value

int

_lblAlert

The label for taking in alert text

[Export(PropertyHint.None, "")]
private Label _lblAlert

Field Value

Label

_lblSubtitle

the label that takes in subtitle text

[ExportGroup("Paths", "")]
[Export(PropertyHint.None, "")]
private Label _lblSubtitle

Field Value

Label

_playerInventory

the root control for the player's inventory to be instanced in

[Export(PropertyHint.None, "")]
private Control _playerInventory

Field Value

Control

_playerMoneyDecreaseCol

The colour for the player's money pop label. Specifically when money is decreasing

[Export(PropertyHint.None, "")]
private Color _playerMoneyDecreaseCol

Field Value

Color

_playerMoneyIncreaseCol

The colour for the player's money pop label. Specifically when money is increasing

[ExportGroup("Player Money", "_playerMoney")]
[Export(PropertyHint.None, "")]
private Color _playerMoneyIncreaseCol

Field Value

Color

_playerMoneyLabel

the label for the money display

[Export(PropertyHint.None, "")]
private Label _playerMoneyLabel

Field Value

Label

_playerMoneyPopLabel

the label that is used as a pop label using SceneTreeTween

[Export(PropertyHint.None, "")]
private Label _playerMoneyPopLabel

Field Value

Label

_playerMoneyTexture

The texture for the money icon

[Export(PropertyHint.None, "")]
private Control _playerMoneyTexture

Field Value

Control

_playerStatsEnergyBar

the progress bar for the player's energy

[Export(PropertyHint.None, "")]
private TextureProgressBar _playerStatsEnergyBar

Field Value

TextureProgressBar

_playerStatsEnergyLabel

the label for the player's energy

[Export(PropertyHint.None, "")]
private Label _playerStatsEnergyLabel

Field Value

Label

_playerStatsHealthBar

The progress bar related to the player's health

[Export(PropertyHint.None, "")]
private TextureProgressBar _playerStatsHealthBar

Field Value

TextureProgressBar

_playerStatsHealthLabel

The label for the player health

[Export(PropertyHint.None, "")]
private Label _playerStatsHealthLabel

Field Value

Label

_previousSelectSlot

private int _previousSelectSlot

Field Value

int

_promptTween

private Tween _promptTween

Field Value

Tween

_reticle

The reticle texture

[Export(PropertyHint.None, "")]
private TextureRect _reticle

Field Value

TextureRect

_rootAlert

The root of the alert panel

[Export(PropertyHint.None, "")]
private Control _rootAlert

Field Value

Control

_rootSubtitle

The root of the subtitle panel

[Export(PropertyHint.None, "")]
private Control _rootSubtitle

Field Value

Control

_transitionTime

The time it takes for the reticle to transition between scales.

[ExportGroup("Reticle Settings", "")]
[Export(PropertyHint.None, "")]
private float _transitionTime

Field Value

float

Methods

EnsureInventorySlots(int)

private void EnsureInventorySlots(int index)

Parameters

index int

HandleAnimation(Control, bool)

private void HandleAnimation(Control control, bool isVisible)

Parameters

control Control
isVisible bool

OnCanInteract(string)

private void OnCanInteract(string text)

Parameters

text string

OnCannotInteract()

private void OnCannotInteract()

OnInventorySelect(int)

private void OnInventorySelect(int index)

Parameters

index int

OnInventorySlotUpdate(int, string, int)

private void OnInventorySlotUpdate(int index, string item, int qty)

Parameters

index int
item string
qty int

OnPlayerMoneyChange(int)

private void OnPlayerMoneyChange(int new_total)

Parameters

new_total int

OnPlayerStatsUpdated(float, float, float, float)

private void OnPlayerStatsUpdated(float health, float max_health, float energy, float max_energy)

Parameters

health float
max_health float
energy float
max_energy float

OnRequestCloseGUI()

private void OnRequestCloseGUI()

OnRequestGenericGUI(Control)

private void OnRequestGenericGUI(Control gui)

Parameters

gui Control

ShowAlert(string)

public void ShowAlert(string text)

Parameters

text string

ShowSubtitle(string)

public void ShowSubtitle(string text)

Parameters

text string

_ExitTree()

Called when the node is about to leave the Godot.SceneTree (e.g. upon freeing, scene changing, or after calling Godot.Node.RemoveChild(Godot.Node) in a script). If the node has children, its Godot.Node._ExitTree() callback will be called last, after all its children have left the tree.

Corresponds to the Godot.Node.NotificationExitTree notification in _Notification(int) and signal Godot.Node.TreeExiting. To get notified when the node has already left the active tree, connect to the Godot.Node.TreeExited.

public override void _ExitTree()

_Input(InputEvent)

A functionality I would like to preserve is to allow hiding the HUD with F1. Not only is it incredibly useful for making cinematics for trailers and videos, but it's generally a nice feature for players as well (think minecraft). Making your game easier for youtubers/streamers to play makes it easier to get your game into public consciousness (spelling?) and that's pretty fricking awesome if it happens.

public override void _Input(InputEvent @event)

Parameters

event InputEvent

_Ready()

Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their Godot.Node._Ready() callbacks get triggered first, and the parent node will receive the ready notification afterwards.

Corresponds to the Godot.Node.NotificationReady notification in _Notification(int). See also the @onready annotation for variables.

Usually used for initialization. For even earlier initialization, Godot.GodotObject.GodotObject() may be used. See also Godot.Node._EnterTree().

Note: Godot.Node._Ready() may be called only once for each node. After removing a node from the scene tree and adding it again, _ready will not be called a second time. This can be bypassed by requesting another call with Godot.Node.RequestReady(), which may be called anywhere before adding the node again.

public override void _Ready()