Trigger API Reference DCEI Functions Custom UI5 - BLKTower/TestWiki GitHub Wiki

Table of Contents

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)

Description

Sets the fill amount for the background image. Expressions use data bound by DCEI.BindData() or BindUnit().

Parameters

  • Transform ui the frame to set the background image fill amount for.
  • string expression an expression for the fill amount (between 0 and 1).
  • bool inverse if true, inverts the fill amount (does 1-expression).

Example Usage

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)

Related

void SetFrameWidthExpression(Transform ui, string expression) {void-SetFrameWidthExpressionTransform-ui-string-expression}

void SetFrameWidthExpression(Transform ui, string expression)

Description

Sets the width of a UI frame. Expressions use data bound by DCEI.BindData() or BindUnit().

Parameters

  • Transform ui the frame to set the width for.
  • string expression an expression for the width.

Example Usage

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")

Related

void SetFrameHeightExpression(Transform ui, string expression) {void-SetFrameHeightExpressionTransform-ui-string-expression}

void SetFrameHeightExpression(Transform ui, string expression)

Description

Sets the height of a UI frame. Expressions use data bound by DCEI.BindData() or BindUnit().

Parameters

  • Transform ui the frame to set the height for.
  • string expression an expression for the height.

Example Usage

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")

Related

void SetFrameImageColor(Transform ui, ColorRGBA color) {void-SetFrameImageColorTransform-ui-ColorRGBA-color}

void SetFrameImageColor(Transform ui, ColorRGBA color)

Description

Parameters

Example Usage

void SetFrameImageColorRGBA(Transform ui, ColorRGBA color) {void-SetFrameImageColorRGBATransform-ui-ColorRGBA-color}

void SetFrameImageColorRGBA(Transform ui, ColorRGBA color)

⚠️Warning⚠️: This api was deprecated at 7/18/2022, and will be removed after 90 days.

Description

Parameters

Example Usage

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)

Description

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().

Parameters

  • Transform ui the frame to tint.
  • float r an expression for the red value of the tint color (between 0 and 1).
  • float g an expression for the green value of the tint color (between 0 and 1).
  • float b an expression for the blue value of the tint color (between 0 and 1).
  • float a an expression for the alpha value of the tint color (between 0 and 1).

Example Usage

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)

Related

void SetFrameImageGrayScale(Transform ui, bool isGrayScale) {void-SetFrameImageGrayScaleTransform-ui-bool-isGrayScale}

void SetFrameImageGrayScale(Transform ui, bool isGrayScale)

Description

Sets if the background image is rendered in gray scale for a UI frame.

Parameters

  • Transform ui the frame to set the background image gray scale for.
  • bool isGrayScale if true, renders the background image in gray scale. The default value is false for newly created frames.

Example Usage

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)

Description

Sets the tooltip text for a UI frame. Child frame tooltips will display over parent frame tooltips.

Parameters

  • Transform ui the frame to set the tooltip text for.
  • string text the text of the tooltip.

Example Usage

local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")

Related

void SetFrameTooltipOffset(int offset) {void-SetFrameTooltipOffsetint-offset}

void SetFrameTooltipOffset(int offset)

Description

Sets the tooltip offset from the cursor. This will affect all tooltips.

Parameters

  • int offset the offset from the cursor. Negative numbers will cause the tooltip to flicker.

Example Usage

local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipOffset(100)

Related

void SetFrameTooltipStyle(int style) {void-SetFrameTooltipStyleint-style}

void SetFrameTooltipStyle(int style)

Description

Sets the tooltip style. This will affect all tooltips. By default, tooltips are displayed next to the cursor.

Parameters

  • int style the style. A value of 0 will display the tooltip next to the cursor (default). A value of 1 will display the tooltip next to the frame.

Example Usage

local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipStyle(1)

Related

void SetFrameTooltipPosition(int position) {void-SetFrameTooltipPositionint-position}

void SetFrameTooltipPosition(int position)

Description

Sets the tooltip position. This will affect all tooltips.

Parameters

  • int position the position of the tooltip. A value of 0 will display the tooltip to the right of the frame. A value of 1 will display the tooltip at the top.

Example Usage

local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipPosition(1)

Related

void SetFrameTooltipImage(string name) {void-SetFrameTooltipImagestring-name}

void SetFrameTooltipImage(string name)

Description

Sets a background image for tooltips. This will affect all tooltips.

Parameters

  • string name the name of the background image.

Example Usage

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")

Related

void SetFrameTooltipFontSize(int size) {void-SetFrameTooltipFontSizeint-size}

void SetFrameTooltipFontSize(int size)

Description

Sets the tooltip font size. This will affect all tooltips.

Parameters

  • int size the font size.

Example Usage

local frame = DCEI.NewFrame(DCEI.GetUiRoot())
DCEI.SetSize(frame, 100, 100)
DCEI.SetBackgroundImage(frame, "airship_onMap")
DCEI.SetTooltipText(frame, "Frame 1")
DCEI.SetTooltipFontSize(50)

Related

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)

Description

Sets the tooltip padding. This will affect all tooltips.

Parameters

  • int left the left padding.
  • int right the right padding.
  • int top the top padding.
  • int bottom the bottom padding.

Example Usage

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)

Related

void SetFrameTooltipMaxWidth(int width) {void-SetFrameTooltipMaxWidthint-width}

void SetFrameTooltipMaxWidth(int width)

Description

Sets the tooltip max width. Tooltip text that exceeds this width will wrap. This will affect all tooltips.

Parameters

  • int width the max width.

Example Usage

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)

Related

void SetFrameTooltipTextColor(ColorRGB color) {void-SetFrameTooltipTextColorColorRGB-color}

void SetFrameTooltipTextColor(ColorRGB color)

Description

Parameters

Example Usage

void SetFrameTooltipTextColorRGB(ColorRGB color) {void-SetFrameTooltipTextColorRGBColorRGB-color}

void SetFrameTooltipTextColorRGB(ColorRGB color)

⚠️Warning⚠️: This api was deprecated at 7/18/2022, and will be removed after 90 days.

Description

Parameters

Example Usage

void SetButtonFrameClickSound(Transform ui, string path) {void-SetButtonFrameClickSoundTransform-ui-string-path}

void SetButtonFrameClickSound(Transform ui, string path)

Description

Sets the click sound for the given button.

Parameters

  • Transform ui the button.
  • string path the sound file.

Example Usage

local button = DCEI.NewButton(DCEI.GetUiRoot())
DCEI.SetSize(button, 100, 100)
DCEI.SetButtonClickSound(button, "ancienttree_ability_01")

Related

void SetButtonFrameEnable(Transform ui, bool enable) {void-SetButtonFrameEnableTransform-ui-bool-enable}

void SetButtonFrameEnable(Transform ui, bool enable)

Description

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.

Parameters

  • Transform ui the button frame.
  • bool enable if true, enables the button. This is true by default for newly created buttons.

Example Usage

local button = DCEI.NewButton(DCEI.GetUiRoot())
DCEI.SetSize(button, 100, 100)
DCEI.EnableButton(button, false)

Related

void SetButtonFrameDisabledImage(Transform ui, string name) {void-SetButtonFrameDisabledImageTransform-ui-string-name}

void SetButtonFrameDisabledImage(Transform ui, string name)

Description

Sets the background image for a button while it is disabled.

Parameters

  • Transform ui the button frame.
  • string name the name of the background image.

Example Usage

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)

Description

Sets the rotation for a UI frame and its children.

Parameters

  • Transform ui the UI frame to rotate.
  • float degrees the degrees to rotate counterclockwise. Negative values will cause clockwise rotation.

Example Usage

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)

Description

Rotates a frame and its children in 3D space. DCEI.SetRotation3D(ui, 0, 180, 0) will flip an image horizontally.

Parameters

  • Transform ui the frame to rotate.
  • float x the angle to rotate the frame in the "x" plane.
  • float y the angle to rotate the frame in the "y" plane.
  • float z the angle to rotate the frame in the "z" plane.

Example Usage

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) {void-BindUnitDatastring-name-unit-unit}

void BindUnitData(string name, unit unit)

Description

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

Parameters

  • string name the string to bind the unit to.
  • unit unit the 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

Example Usage

-- 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
)

Related

void BindLuaTable(string name, object value) {void-BindLuaTablestring-name-object-value}

void BindLuaTable(string name, object value)

Description

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.

Parameters

  • string name the string to bind the data to.
  • object value the lua table.

Example Usage

-- 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
)

Related

bool IsFrameActive(Transform ui) {bool-IsFrameActiveTransform-ui}

bool IsFrameActive(Transform ui)

Description

Returns whether the given UI frame is active.

Parameters

  • Transform ui the UI frame to return the status of.

Example Usage

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))

Related

void SetFrameActive(Transform ui, bool value) {void-SetFrameActiveTransform-ui-bool-value}

void SetFrameActive(Transform ui, bool value)

Description

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.

Parameters

  • Transform ui the UI frame to set the status of.
  • bool value if true, sets the frame to active. Newly created frames are active by default.

Example Usage

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) {void-SetFrameBlockInputTransform-ui-bool-value}

void SetFrameBlockInput(Transform ui, bool value)

Description

Makes a UI frame block all input. Requires a background image to be set (but it can be made invisible).

Parameters

  • Transform ui the frame to adjust.
  • boolean value whether or not the frame blocks input.

Example Usage

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)

Description

Attaches a UI frame to a unit, useful for creating custom health and status bars.

Parameters

  • Transform ui the frame to attach.
  • unit unit the unit to attach the frame to.
  • table options accepted values:
    • table offset as {up = 0, front = 0, right = 0}.
    • boolean center_at_unit_origin when true, uses the unit's origin point rather than status bar height for UI attachment.
  • 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.

Example Usage

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) {void-SetMouseCursorFrameTransform-ui}

void SetMouseCursorFrame(Transform ui)

Description

Using an UI to replace current cursor image

Parameters

  • Transform ui the frame to attach.

Example Usage

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)

Description

Set cursor image only for a specific player. Only useful in multiplayer.

Parameters

  • int player player id
  • Transform ui the frame to attach.

Example Usage

local frame = DCEI.NewText(DCEI.GetUiRoot())
DCEI.SetText(frame, "Bob")

DCEI.SetMouseCursorFrame(1, frame)

⚠️ **GitHub.com Fallback** ⚠️