GUI functions

Jump to: navigation, search

These are some HeroScript built-in functions which deal with the GUI (Graphical User Interface). They run specifically on the client, and probably do not require a server connection in order to function.


GUI Controls

Get GUI Popup Controls

This function, when called, populates the list with all of the popup controls (popup set to TRUE) which are currently on the screen, regardless of which layer that they're on.

GetGUIpopupControls(List as List of NodeRef)

Find GUI Control By Name

This function, when called, will return the named GUI Control that is contained in the passed noderef. If 0 is passed, then it will search all of the top level GUI Controls.

FindGUIControlByName(GUInode as NodeRef, name as String) as NodeRef

Get GUI Controls

GetGUIControls(List as List of NodeRef of Class GUIControl)

Note: Use of this function is not recommended. See GUI Layers.

This function, when called, populates the list with all of the GUI Controls which are currently on the screen. For example, a chat window, inventory window, and so forth.


controlList as list of noderef  
chatFound as boolean = false
foreach thingie in controlList
   if = "ChatWindow"
     println("There is a chat window currently on the screen.")
     chatFound = true
if not chatFound    // 
  println("No chat window is currently on the screen.")

Get GUI Label Text Size

Returns a vector3 where the x-value equals the the actual width required by the label text (after formatting). The y-value is the actual height.

function GetGUILabelTextSize(GUIlabel as NodeRef of class guilabel) as Vector3

Note: If both singleline and wordbreak are set to to TRUE on a GUILabel, this may cause unpredictable results from this function. However, the chomper shouldn't allow that combination.

Debug Font Texture

DebugFontTexture(guilabel as noderef of class guicontrol)

Exposed function which loads the font texture used by the given control into the texture management system so it can be viewed in the Scene Analysis panel, for debugging purposes.

Move GUI to Screen

moveGUItoScreen(guiNode as noderef)

Moves the GUIcontrol guiNode onto the GUIControl theScreen from wherever it currently is.

Other related HeroScript functions

ConvertToControlSpace(node as NodeRef, x as Float, y as Float) as Vector3

Converts the given X and Y screen coordinates into a position relative to the given GUIControl.

GetScreenSpacePosition(node as NodeRef) as Vector3

Returns the position of the given GUIControl in screen coordinates in the vector's .x and .y (.z is unused)

GetViewPortSize() as Vector3

Returns the size of the game viewport in screen pixels in the vector's .x and .y (.z is unused)

Node Moving and Rotating

Though a node's rotation can be changed directly via the HeroBlade Properties Panel, when working from a script, this property cannot be directly modified. Instead, the following functions must be used. This ensures that not only is the property changed via script, but that the new values are properly propagated to the graphics engine code.

Pitch, heading, and roll are values in degrees from 0-360.

RotateNode(node as NodeRef, pitchDelta as float, headingDelta as float, rollDelta as float)

RotateNodeLocal(node as NodeRef of class hbnode, pitchDelta as float, headingDelta as float, rollDelta as float)

Rotates a node in local space rather than world space. Rotating a node in its local space means applying the rotation with respect to its current rotation. If you had an arrow asset that pointed forward, and it was already rotated to point upwards, a world space rotation of 90 degrees to the side would turn it to point sideways, while a local space rotation of 90 degrees to the side would spin it while still keeping it faced upwards.

SetNodeRotation(node as NodeRef, rotation as Vector3)

SetNodePosition(node as NodeRef, position as Vector3)

GUI Tree Functions

function GUITreeClear()

Removes all nodes in the GUI Tree.

function GUITreeSelect(selectionID as NodeRef)

Selects the specified node in the GUI Tree.

function GUITreeAddNode(nodeID as NodeRef, parentNodeID as NodeRef)

Adds the specified node to the specified Parent Node in the GUI Tree

function GUITreeRemoveNode(nodeID as NodeRef)

Removes the specified node from the GUI Tree.

function GUITreeMoveNode(nodeID as NodeRef, parentID as NodeRef)

Moves the specified node to a new parent.

function GUITreeMoveUp(nodeID as NodeRef)

Moves the specified node up by one level among its current siblings. If it has no siblings, nothing happens.

function GUITreeMoveDown(nodeID as NodeRef)

Moves the specified node down by one level among its current siblings.

function GUIEditorDialogCmd(text as String)

Used by the GUI Editor script to communicate with HeroBlade

See also

Personal tools