_gui_helper
GUI helper functions for ParaEngine
Description
Member Functions
_guihelper.SetUIColor
[[
Set all texture layers of an UI object to the specifed color
if UIobject is nil or is an invalid UI object, this function does nothing.
e.g. _guihelper.SetUIColor(uiobject, "255 0 0"); or _guihelper.SetUIColor(uiobject, "255 0 0 128");
]]
syntax
function _guihelper.SetUIColor(uiobject, color)
parameters
_guihelper.SetFontColor
set the text font color of a UI control.
- param color : it can be "255 255 255", "#FFFFFF", "255 255 255 100", alpha is supported.
syntax
function _guihelper.SetFontColor(uiobject, color)
parameters
uiobject |
|
color |
it can be "255 255 255", "#FFFFFF", "255 255 255 100", alpha is supported. |
_guihelper.SetButtonTextColor
set the text font color of a UI control.
- param color : it can be "255 255 255", "#FFFFFF", "255 255 255 100", alpha is supported.
syntax
function _guihelper.SetButtonTextColor(uiobject, color)
parameters
uiobject |
|
color |
it can be "255 255 255", "#FFFFFF", "255 255 255 100", alpha is supported. |
_guihelper.GetTextWidth
get the width of text of a given font. It internally cache the font object and UI object on first call.
- param text : text for which to determine the width
- param fontName : font name, such as "System;12". If nil, it will use the default font of text control.
- return the : width of text of a given font
syntax
function _guihelper.GetTextWidth(text, fontName)
parameters
text |
text for which to determine the width |
fontName |
|
return |
width of text of a given font |
_guihelper.SetUIFontFormat
- param uiobject : uiobject such as button
- param format : 0 for left alignment; 1 for horizontal center alignment; 4 for vertical center aligntment; 5 for both vertical and horizontal; 32 for single-lined left bottom alignment, 36 for single-lined vertical center alignment DT_TOP 0x00000000 DT_LEFT 0x00000000 DT_CENTER 0x00000001 DT_RIGHT 0x00000002 DT_VCENTER 0x00000004 DT_BOTTOM 0x00000008 DT_SINGLELINE 0x00000020 DT_WORDBREAK 0x00000010 DT_NOCLIP 0x00000100
syntax
function _guihelper.SetUIFontFormat(uiobject, format)
parameters
uiobject |
uiobject such as button |
format |
|
_guihelper.RGBA_TO_DWORD
- param r :, g, b, a: each in [0,255]
syntax
function _guihelper.RGBA_TO_DWORD(r, g, b, a)
parameters
r |
, g, b, a: each in [0,255] |
g |
|
b |
|
a |
|
_guihelper.DWORD_TO_RGBA
- param r :, g, b, a: each in [0,255]
- return r :, g, b, a: each in [0,255]
syntax
function _guihelper.DWORD_TO_RGBA(w)
parameters
_guihelper.SafeSetText
[[ set the text of a ui control by its name.
- param objName :name of the object
- param newText : string of the new text.
]]
syntax
function _guihelper.SafeSetText(objName, newText)
parameters
objName |
name of the object |
newText |
|
_guihelper.SafeGetNumber
[[ get the text of a ui control as a number. return nil if invalid.
- param objName :name of the object
- return __ : number or nil
]]
syntax
function _guihelper.SafeGetNumber(objName)
parameters
objName |
name of the object |
_guihelper.SafeGetText
[[ get the text of a ui control as a number. return nil if invalid.
- param objName :name of the object, such as {"name1", "name2"}
- return __ : number or nil
]]
syntax
function _guihelper.SafeGetText(objName)
parameters
objName |
name of the object, such as {"name1", "name2"} |
_guihelper.CheckRadioButtons
[[
- param objList : an array of button names.
- param selectedName : name of the selected button. If nil, nothing will be selected.
- param color : color used for highlighting the checked button.
- param checked :_bg, unchecked_bg: can be nil or the texture of the checked and unchecked state.
]]
syntax
function _guihelper.CheckRadioButtons(objList, selectedName, color, checked_bg, unchecked_bg)
parameters
objList |
an array of button names. |
selectedName |
|
color |
color used for highlighting the checked button. |
checked |
|
bg |
|
unchecked |
|
bg |
|
_guihelper.CheckRadioButtons2
NOTE: --WangTian: change background for group of buttons
[[
- param objList : an array of button names.
- param selectedName : name of the selected button. If nil, nothing will be selected.
- param color : color used for highlighting the checked button.
- param checked :_bg, unchecked_bg: can be nil or the texture of the checked and unchecked state.
]]
syntax
function _guihelper.CheckRadioButtons2(objList, selectedName, color, checked_bg, unchecked_bg)
parameters
objList |
an array of button names. |
selectedName |
|
color |
color used for highlighting the checked button. |
checked |
|
bg |
|
unchecked |
|
bg |
|
_guihelper.CheckRadioButtonsByIndex
[[
- param objList : an array <index, button names>, such as {[1] = "name1", [2] ="name2",}
- param nSelectedIndex : index of the selected button. If nil, nothing will be selected.
- param color : color used for highlighting the checked button.
- param checked :_bg, unchecked_bg: can be nil or the texture of the checked and unchecked state.
]]
syntax
function _guihelper.CheckRadioButtonsByIndex(objList, nSelectedIndex, color, checked_bg, unchecked_bg)
parameters
objList |
an array <index, button names>, such as {[1] = "name1", [2] ="name2",} |
nSelectedIndex |
|
color |
color used for highlighting the checked button. |
checked |
|
bg |
|
unchecked |
|
bg |
|
_guihelper.SwitchVizGroup
[[
for all objects in objList, only the selectedName is made visible.
- param objList : an array of button names, such as {"name1", "name2"}
- param selectedName : name of the selected button. If nil, nothing will be selected.
]]
syntax
function _guihelper.SwitchVizGroup(objList, selectedName)
parameters
objList |
an array of button names, such as {"name1", "name2"} |
selectedName |
|
_guihelper.SwitchVizGroupByIndex
[[
for all objects in objList, only the selectedName is made visible.
- param objList : an array <index, button names>, such as {[1] = "name1", [2] ="name2",}
- param nSelectedIndex : index of the selected button. If nil, nothing will be selected.
]]
syntax
function _guihelper.SwitchVizGroupByIndex(objList, nSelectedIndex)
parameters
objList |
an array <index, button names>, such as {[1] = "name1", [2] ="name2",} |
nSelectedIndex |
|
_guihelper.OnClick
[[this is a message handler for placeholder buttons,etc. it will display the name of control, the texture file path, etc in the messagebox
- param ctrlName : control name
- param comments : if not nil, it is additional text that will be displayed.
]]
syntax
function _guihelper.OnClick(ctrlName, comments)
parameters
ctrlName |
control name |
comments |
|
_guihelper.PrintTableStructure
print out the table structure
- param t : table to print
- param filename : the file name to print out the table
syntax
function _guihelper.PrintTableStructure(t, filename)
parameters
t |
table to print |
filename |
|
_guihelper.PrintUIObjectStructure
print out the ui object structure
- param obj : ui object to print
- param filename : the file name to print out the ui object
syntax
function _guihelper.PrintUIObjectStructure(obj, filename)
parameters
obj |
ui object to print |
filename |
|
_guihelper.SetContainerEnabled
set the container enabled, this will iterately set the enabled attribute in the UI object child container
- param bEnabled : true or false
syntax
function _guihelper.SetContainerEnabled(obj, bEnabled)
parameters
obj |
|
bEnabled |
true or false |
_guihelper.HSL2RGB
Given H,S,L in range of 0-1
Returns a Color (RGB struct) in range of 0-255
syntax
function _guihelper.HSL2RGB(h, s, l)
parameters
_guihelper.RGB2HSL
Given a Color (RGB Struct) in range of 0-255
Return H,S,L in range of 0-1
syntax
function _guihelper.RGB2HSL(r, g, b)
parameters
_guihelper.HSL2RGB2
Given H,S,L in range of 0-1
Returns a Color (RGB struct) in range of 0-255
syntax
function _guihelper.HSL2RGB2(H, S, L)
parameters