Trigger API Reference DCEI Functions Custom UI5 - BLKTower/TestWiki GitHub Wiki
Trigger API Reference\DCEI Functions\Custom UI (6/8) {Trigger-API-ReferenceDCEI-FunctionsCustom-UI-68}
void SetFrameImageFillAmountExpression(Transform ui, string expression, bool inverse) {void-SetFrameImageFillAmountExpressionTransform-ui-string-expression-bool-inverse}
void SetFrameImageFillAmountExpression(Transform ui, string expression, bool inverse)Sets the fill amount for the background image. Expressions use data bound by DCEI.BindData() or BindUnit().
-
Transform
uithe frame to set the background image fill amount for. -
string
expressionan expression for the fill amount (between 0 and 1). -
bool
inverseif true, inverts the fill amount (does 1-expression).
local vstack = DCEI.NewVStack(DCEI.GetUiRoot())
local data = {fill = 0.7}
DCEI.BindData("data", data)
local data_frame = DCEI.NewFrame(vstack)
DCEI.SetSize(data_frame, 100, 100)
DCEI.SetBackgroundImage(data_frame, "airship_onMap")
DCEI.SetBackgroundImageFillAmountExpression(data_frame, "data.fill", false)
local unit_frame = DCEI.NewFrame(vstack)
DCEI.SetBackgroundImage(unit_frame, "quest_page_progression_fill")
DCEI.SetSize(unit_frame, 100, 10)
local unit = DCEI.CreateUnit(1, 1, "Standard MeleeUnit", 16, 16, 0, -1)
DCEI.BindUnit("selected", unit)
DCEI.SetBackgroundImageFillAmountExpression(unit_frame, "selected.Health.Fraction", false)- BindUnit()
- BindData()
- SetBackgroundImageFillAmount()
- GetBackgroundImageFillAmount()
- SetBackgroundImageFillHorizontal()
- SetBackgroundImageFillVertical()
- SetBackgroundImageFillRadial()
- SetBackgroundImageFillOrigin()
- AnimateBackgroundImageFillAmount()
void SetFrameWidthExpression(Transform ui, string expression) {void-SetFrameWidthExpressionTransform-ui-string-expression}
void SetFrameWidthExpression(Transform ui, string expression)Sets the width of a UI frame. Expressions use data bound by DCEI.BindData() or BindUnit().
local vstack = DCEI.NewVStack(DCEI.GetUiRoot())
local data_frame = DCEI.NewFrame(vstack)
DCEI.SetBackgroundImageColor(data_frame, 0.5, 0, 1, 1)
local data = {width = 100, height = 100}
DCEI.BindData("data", data)
DCEI.SetWidthExpression(data_frame, "data.width")
DCEI.SetHeightExpression(data_frame, "data.height")
local unit_frame = DCEI.NewFrame(vstack)
DCEI.SetBackgroundImageColor(unit_frame, 0, 1, 0.5, 1)
local unit = DCEI.CreateUnit(1, 1, "Standard MeleeUnit", 16, 16, 0, -1)
DCEI.BindUnit("selected", unit)
DCEI.SetWidthExpression(unit_frame, "selected.Health.Max")
DCEI.SetHeightExpression(unit_frame, "selected.Health.Current")void SetFrameHeightExpression(Transform ui, string expression) {void-SetFrameHeightExpressionTransform-ui-string-expression}
void SetFrameHeightExpression(Transform ui, string expression)Sets the height of a UI frame. Expressions use data bound by DCEI.BindData() or BindUnit().
local vstack = DCEI.NewVStack(DCEI.GetUiRoot())
local data_frame = DCEI.NewFrame(vstack)
DCEI.SetBackgroundImageColor(data_frame, 0.5, 0, 1, 1)
local data = {width = 100, height = 100}
DCEI.BindData("data", data)
DCEI.SetWidthExpression(data_frame, "data.width")
DCEI.SetHeightExpression(data_frame, "data.height")
local unit_frame = DCEI.NewFrame(vstack)
DCEI.SetBackgroundImageColor(unit_frame, 0, 1, 0.5, 1)
local unit = DCEI.CreateUnit(1, 1, "Standard MeleeUnit", 16, 16, 0, -1)
DCEI.BindUnit("selected", unit)
DCEI.SetWidthExpression(unit_frame, "selected.Health.Max")
DCEI.SetHeightExpression(unit_frame, "selected.Health.Current")void SetFrameImageColor(Transform ui, ColorRGBA color) {void-SetFrameImageColorTransform-ui-ColorRGBA-color}
void SetFrameImageColor(Transform ui, ColorRGBA color)void SetFrameImageColorRGBA(Transform ui, ColorRGBA color) {void-SetFrameImageColorRGBATransform-ui-ColorRGBA-color}
void SetFrameImageColorRGBA(Transform ui, ColorRGBA color)void SetFrameImageColorExpression(Transform ui, string r, string g, string b, string a) {void-SetFrameImageColorExpressionTransform-ui-string-r-string-g-string-b-string-a}
void SetFrameImageColorExpression(Transform ui, string r, string g, string b, string a)Applies a tint color to the frame using RGBA values (valid values are between 0 and 1). Note that frames without background images can be tinted a solid color. Alpha 1 is completely opaque, alpha 0 is completely transparent. Expressions use data bound by DCEI.BindData() or BindUnit().
-
Transform
uithe frame to tint. -
float
ran expression for the red value of the tint color (between 0 and 1). -
float
gan expression for the green value of the tint color (between 0 and 1). -
float
ban expression for the blue value of the tint color (between 0 and 1). -
float
aan expression for the alpha value of the tint color (between 0 and 1).
local vstack = DCEI.NewVStack(DCEI.GetUiRoot())
local data = {bg_color = {r = 0.5, g = 0, b = 1, a = 1}}
DCEI.BindData("data", data)
local data_frame = DCEI.NewFrame(vstack)
DCEI.SetSize(data_frame, 200, 100)
DCEI.SetBackgroundImageColorExpression(data_frame, "data.bg_color.r", "data.bg_color.g", "data.bg_color.b", "data.bg_color.a")
local unit_frame = DCEI.NewFrame(vstack)
DCEI.SetSize(unit_frame, 200, 100)
local unit = DCEI.CreateUnit(1, 1, "Standard MeleeUnit", 16, 16, 0, -1)
DCEI.BindUnit("selected", unit)
local rgbval = "selected.Health.Fraction"
DCEI.SetBackgroundImageColorExpression(unit_frame, rgbval, rgbval, rgbval, rgbval)void SetFrameImageGrayScale(Transform ui, bool isGrayScale) {void-SetFrameImageGrayScaleTransform-ui-bool-isGrayScale}
void SetFrameImageGrayScale(Transform ui, bool isGrayScale)Sets if the background image is rendered in gray scale for a UI frame.
-
Transform
uithe frame to set the background image gray scale for. -
bool
isGrayScaleif true, renders the background image in gray scale. The default value is false for newly created frames.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetBackgroundImageGrayScale(frame, true)void SetFrameTooltipText(Transform ui, string text) {void-SetFrameTooltipTextTransform-ui-string-text}
void SetFrameTooltipText(Transform ui, string text)Sets the tooltip text for a UI frame. Child frame tooltips will display over parent frame tooltips.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")- SetTooltipOffset()
- SetTooltipStyle()
- SetTooltipPosition()
- SetTooltipBackgroundImage()
- SetTooltipFontSize()
- SetTooltipPadding()
- SetTooltipMaxWidth()
- SetTooltipTextColor()
void SetFrameTooltipOffset(int offset)Sets the tooltip offset from the cursor. This will affect all tooltips.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipOffset(100)- SetTooltipText()
- SetTooltipStyle()
- SetTooltipPosition()
- SetTooltipBackgroundImage()
- SetTooltipFontSize()
- SetTooltipPadding()
- SetTooltipMaxWidth()
- SetTooltipTextColor()
void SetFrameTooltipStyle(int style)Sets the tooltip style. This will affect all tooltips. By default, tooltips are displayed next to the cursor.
-
int
stylethe style. A value of0will display the tooltip next to the cursor (default). A value of1will display the tooltip next to the frame.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipStyle(1)- SetTooltipText()
- SetTooltipOffset()
- SetTooltipPosition()
- SetTooltipBackgroundImage()
- SetTooltipFontSize()
- SetTooltipPadding()
- SetTooltipMaxWidth()
- SetTooltipTextColor()
void SetFrameTooltipPosition(int position)Sets the tooltip position. This will affect all tooltips.
-
int
positionthe position of the tooltip. A value of0will display the tooltip to the right of the frame. A value of1will display the tooltip at the top.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipPosition(1)- SetTooltipText()
- SetTooltipOffset()
- SetTooltipStyle()
- SetTooltipBackgroundImage()
- SetTooltipFontSize()
- SetTooltipPadding()
- SetTooltipMaxWidth()
- SetTooltipTextColor()
void SetFrameTooltipImage(string name)Sets a background image for tooltips. This will affect all tooltips.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipBackgroundImage("airship_onMap")- SetTooltipText()
- SetTooltipOffset()
- SetTooltipStyle()
- SetTooltipPosition()
- SetTooltipFontSize()
- SetTooltipPadding()
- SetTooltipMaxWidth()
- SetTooltipTextColor()
void SetFrameTooltipFontSize(int size)Sets the tooltip font size. This will affect all tooltips.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipFontSize(50)- SetTooltipText()
- SetTooltipOffset()
- SetTooltipStyle()
- SetTooltipPosition()
- SetTooltipBackgroundImage()
- SetTooltipPadding()
- SetTooltipMaxWidth()
- SetTooltipTextColor()
void SetFrameTooltipPadding(int left, int right, int top, int bottom) {void-SetFrameTooltipPaddingint-left-int-right-int-top-int-bottom}
void SetFrameTooltipPadding(int left, int right, int top, int bottom)Sets the tooltip padding. This will affect all tooltips.
-
int
leftthe left padding. -
int
rightthe right padding. -
int
topthe top padding. -
int
bottomthe bottom padding.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipPadding(30, 30, 30, 30)- SetTooltipText()
- SetTooltipOffset()
- SetTooltipStyle()
- SetTooltipPosition()
- SetTooltipBackgroundImage()
- SetTooltipFontSize()
- SetTooltipMaxWidth()
- SetTooltipTextColor()
void SetFrameTooltipMaxWidth(int width)Sets the tooltip max width. Tooltip text that exceeds this width will wrap. This will affect all tooltips.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipFontSize(50)
DCEI.SetTooltipMaxWidth(100)- SetTooltipText()
- SetTooltipOffset()
- SetTooltipStyle()
- SetTooltipPosition()
- SetTooltipBackgroundImage()
- SetTooltipFontSize()
- SetTooltipPadding()
- SetTooltipTextColor()
void SetFrameTooltipTextColor(ColorRGB color)void SetFrameTooltipTextColorRGB(ColorRGB color)void SetButtonFrameClickSound(Transform ui, string path) {void-SetButtonFrameClickSoundTransform-ui-string-path}
void SetButtonFrameClickSound(Transform ui, string path)Sets the click sound for the given button.
local button = DCEI.NewButton(DCEI.GetUiRoot())
DCEI.SetSize(button, 100, 100)
DCEI.SetButtonClickSound(button, "ancienttree_ability_01")void SetButtonFrameEnable(Transform ui, bool enable) {void-SetButtonFrameEnableTransform-ui-bool-enable}
void SetButtonFrameEnable(Transform ui, bool enable)Enables or disables a button. Disabled buttons don't accept mouse input and have their background image tinted darker unless given a disabled button background image.
-
Transform
uithe button frame. -
bool
enableif true, enables the button. This is true by default for newly created buttons.
local button = DCEI.NewButton(DCEI.GetUiRoot())
DCEI.SetSize(button, 100, 100)
DCEI.EnableButton(button, false)void SetButtonFrameDisabledImage(Transform ui, string name) {void-SetButtonFrameDisabledImageTransform-ui-string-name}
void SetButtonFrameDisabledImage(Transform ui, string name)Sets the background image for a button while it is disabled.
local button = DCEI.NewButton(DCEI.GetUiRoot())
DCEI.SetSize(button, 100, 100)
DCEI.EnableButton(button, false)
DCEI.SetDisabledButtonBackgroundImage(button, "airship_onMap")void SetFrameRotation(Transform ui, float degrees) {void-SetFrameRotationTransform-ui-float-degrees}
void SetFrameRotation(Transform ui, float degrees)Sets the rotation for a UI frame and its children.
-
Transform
uithe UI frame to rotate. -
float
degreesthe degrees to rotate counterclockwise. Negative values will cause clockwise rotation.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImageColor(frame, 1, 0, 1, 0.5)
DCEI.SetRotation(frame, 45)void SetFrameRotation3D(Transform ui, float x, float y, float z) {void-SetFrameRotation3DTransform-ui-float-x-float-y-float-z}
void SetFrameRotation3D(Transform ui, float x, float y, float z)
Rotates a frame and its children in 3D space. DCEI.SetRotation3D(ui, 0, 180, 0) will flip an image horizontally.
-
Transform
uithe frame to rotate. -
float
xthe angle to rotate the frame in the "x" plane. -
float
ythe angle to rotate the frame in the "y" plane. -
float
zthe angle to rotate the frame in the "z" plane.
local big_hand = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetBackgroundImage(big_hand, "pointy_finger")
DCEI.SetSize(big_hand, 108, 87)
DCEI.SetRotation3D(big_hand, 0, 180, 0)void BindUnitData(string name, unit unit)
Bind a given unit to a key, allowing the unit's attributes to be accessed by expressions. Data bound values can be formatted to specific decimal values by appending the expression such as :F2. DreamEditor also provides an additional specifier :K to format huge numbers as "xxxK", "xxxM" or "xxxB". The default parameter for :K is :K2. You can find more documentation here
-
string
namethe string to bind the unit to. -
unit
unitthe unit. Unit attributes list:
unit.Info.Icon
unit.Info.Name
unit.Health.Current
unit.Health.Max
unit.Health.Percentage
unit.Health.Fraction
unit.Health.Regeneration
unit.Shield.Current
unit.Shield.Max
unit.Shield.Percentage
unit.Shield.Fraction
unit.Shield.Regeneration
unit.Mana.Current
unit.Mana.Max
unit.Mana.Percentage
unit.Mana.Fraction
unit.Mana.Regeneration
unit.Ability.ability_name.CooldownRatio
unit.Ability.ability_name.MaxCharge
unit.Ability.ability_name.ChargeCount
unit.Expression.some_named_expression
-- create and bind a unit
local unit = DCEI.CreateUnit(1, 1, "Standard MeleeUnit", 16, 16, 0, -1)
DCEI.BindUnit("selected", unit)
local stats = {}
local vstack = DCEI.NewVStack(DCEI.GetUiRoot())
stats.health_label = DCEI.NewText(vstack)
-- make it so that the healthbar shows <current HP>/<max HP>
DCEI.SetTextExpression(stats.health_label, "{selected.Health.Current}/{selected.Health.Max}")
-- damage unit every second
DCEI.TriggerAddTimerEventPeriodicIndefinite(
function()
DCEI.SetHealth(unit, DCEI.GetHealth(unit) - 1)
end,
1, true
)- SetTextExpression()
- SetBackgroundImageExpression()
- SetBackgroundImageGrayScaleExpression()
- SetEnableButtonExpression()
- SetBackgroundImageFillAmountExpression()
- SetWidthExpression()
- SetHeightExpression()
- SetBackgroundImageColorExpression()
void BindLuaTable(string name, object value)
Binds a lua table to a string, allowing the data inside to be accessed by expressions. Updating the bound table values will update any UI that reference these values in an expression. Some expressions evaluate 1 and 0 as true and false, respectively.
-- create and bind a data table
local data_table = {
score = 0
}
DCEI.BindData("data", data_table)
-- create a new text frame and bind its text to the score variable
local label = DCEI.NewText(DCEI.GetUiRoot())
DCEI.SetTextExpression(label, "Score: {data.score}")
-- increment score every second
DCEI.TriggerAddTimerEventPeriodicIndefinite(
function()
data_table.score = data_table.score + 1
end,
1, true
)- SetTextExpression()
- SetBackgroundImageExpression()
- SetBackgroundImageGrayScaleExpression()
- SetEnableButtonExpression()
- SetBackgroundImageFillAmountExpression()
- SetWidthExpression()
- SetHeightExpression()
- SetBackgroundImageColorExpression()
bool IsFrameActive(Transform ui)Returns whether the given UI frame is active.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImageColor(frame, 1, 0, 1, 0.5)
local is_active = DCEI.IsActive(frame)
DCEI.LogMessage(tostring(is_active))void SetFrameActive(Transform ui, bool value)Sets whether the given UI frame and its children are active. Inactive frames are not displayed.
Creating new UI frames under inactive parent frames can cause issues and should be avoided. You can use DCEI.UpdateUi() to safely create new frames under inactive parents.
-
Transform
uithe UI frame to set the status of. -
bool
valueif true, sets the frame to active. Newly created frames are active by default.
local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImageColor(frame, 1, 0, 1, 0.5)
DCEI.SetActive(frame, false)void SetFrameBlockInput(Transform ui, bool value)Makes a UI frame block all input. Requires a background image to be set (but it can be made invisible).
local fullscreen_mask = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetMatchParent(fullscreen_mask, true)
DCEI.SetBackgroundImageColor(fullscreen_mask, 0, 0, 0, 0.5)
DCEI.SetBlockInput(fullscreen_mask, true)void AttachFrameToUnit(Transform ui, unit unit, UnitLabelOptions options, bool useCurrentUiRoot) {void-AttachFrameToUnitTransform-ui-unit-unit-UnitLabelOptions-options-bool-useCurrentUiRoot}
void AttachFrameToUnit(Transform ui, unit unit, UnitLabelOptions options, bool useCurrentUiRoot)Attaches a UI frame to a unit, useful for creating custom health and status bars.
-
Transform
uithe frame to attach. -
unit
unitthe unit to attach the frame to. -
table
optionsaccepted values:-
table
offsetas{up = 0, front = 0, right = 0}. -
boolean
center_at_unit_originwhen true, uses the unit's origin point rather than status bar height for UI attachment.
-
table
-
boolean
useCurrentUiRoot(optional) when true, uses the existing UI root for the attached UI layer. Otherwise the attached UI will be rendered beneath UI root.
local frame = DCEI.NewText(DCEI.GetUiRoot())
DCEI.SetText(frame, "Bob")
local unit = DCEI.CreateUnit(1, 1, "Standard MeleeUnit", 16, 16, 0, -1)
local options = {
offset = {up = 1.2},
center_at_unit_origin = true
}
DCEI.AttachToUnit(frame, unit, options)void SetMouseCursorFrame(Transform ui)Using an UI to replace current cursor image
local frame = DCEI.NewText(DCEI.GetUiRoot())
DCEI.SetText(frame, "Bob")
DCEI.SetMouseCursorFrame(frame)void SetMouseCursorFrameForPlayer(int player, Transform ui) {void-SetMouseCursorFrameForPlayerint-player-Transform-ui}
void SetMouseCursorFrameForPlayer(int player, Transform ui)Set cursor image only for a specific player. Only useful in multiplayer.
local frame = DCEI.NewText(DCEI.GetUiRoot())
DCEI.SetText(frame, "Bob")
DCEI.SetMouseCursorFrame(1, frame)