View Full Version : UI Functions


Thalassicus
Feb 09, 2012, 09:23 PM
Do UI functions have any pattern to them, or api to look at? I could not find functions like SetToolTipString or GetOffsetVal in the Civ lua api.

Update: whoward69 posted a helpful list of UI functions he found below! :goodjob:

Pazyryk
Feb 09, 2012, 09:30 PM
Would be nice if they were. Everything in UI takes me 10 times longer to do than it should.

whoward69
Feb 11, 2012, 05:05 AM
Not sure if it's any use, but this is a list of all the (obvious) control methods


BranchResetAnimation
BuildEntry
CalculateInternals
CalculateInternalSize
CalculateSize
CallShowHideHandler
ClearEntries
ClearString
DestroyAllChildren
DoAutoSize
EnableToolTip
GetButton
GetOffsetX
GetOffsetY
GetRatio
GetSize
GetSizeVal
GetText
GetTextControl
HasMouseOver
IsChecked
IsHidden
IsTrackingLeftMouseButton
LocalizeAndSetText
LocalizeAndSetToolTip
Play
RegisterCallback
RegisterCheckHandler
RegisterSelectionCallback
RegisterSliderCallback
ReleaseChild
ReprocessAnchoring
SetAlpha
SetAnchor
SetCheck
SetColor
SetDisabled
SetFGColor
SetFontByName
SetHide
SetMapSize
SetOffsetVal
SetOffsetX
SetOffsetY
SetPercent
SetPercents
SetScrollValue
SetShadowPercent
SetSize
SetSizeVal
SetSizeX
SetSizeY
SetText
SetTexture
SetTextureAndResize
SetTextureHandle
SetTextureOffset
SetTextureOffsetVal
SetToBeginning
SetToolTipCallback
SetToolTipString
SetToolTipType
SetValue
SetVoid1
SetVoid2
SetVoids
SetWrapWidth
SortChildren
TakeFocus
UnloadTexture

(Found by scanning all the .lua files for the pattern "Controls.{something}:{something}(" so this won't find any methods only called on dynamically created controls)

Thalassicus
Feb 15, 2012, 10:20 PM
Thanks! That should help figuring out what search terms to use, to identify if a function applies to a particular UI class, such as box or button.

whoward69
Feb 16, 2012, 12:50 AM
It's also not obvious, but you can call control methods from the LiveTuner Lua console.

Just find any control of the type you are interested in with an ID and and select the Context it occurs in from the drop-down, eg enter the Diplo popup in game (the one that shows what resources etc each civ/sity state has), set the LiveTuner context to DiploOverview and do Controls.Icon:SetHide(true) and the civ icon at the top of the popup will vanish.

Changes are immediate, so if you're fine tuning a dialog the SetSizeX/Y, SetOffsetX/Y and SetAnchor are particular useful - not quite a visual UI editor, but a lot better than just guessing!

Thalassicus
Feb 16, 2012, 02:52 AM
Thank you for the tip, that should speed up my efforts a lot!

The_J
Feb 16, 2012, 06:38 AM
Moved to the tutorials and references subforum (due to post #2).

whoward69
Feb 18, 2012, 11:07 AM
I'll add these here as they are related,

All the UIManager methods (culled from the .lua files)

local iScreenX, iScreenY = UIManager:GetScreenSizeVal();
local iOldCursor = UIManager:SetUICursor(iNewCursor); -- iNewCursor = 0 for normal, = 1 for busy

local x, y = UIManager:GetMousePos();
local x, y = UIManager:GetMouseDelta();

UIManager:QueuePopup(ContextPtr, PopupPriority.eUtmost);
UIManager:DequeuePopup(ContextPtr);

UIManager:PushModal(ContextPtr, true);
UIManager:PopModal(Controls.ConsultPopup);
local bModal = UIManager:IsModal(Controls.ConsultPopup)

for i = 0, UIManager:GetResCount() - 1 do
local width, height, refresh, scale, display, adapter = UIManager:GetResInfo( i );
end

local control = UIManager:GetControl();
local bShift = UIManager:GetShift();
local bAlt = UIManager:GetAlt();
local bCtrl = UIManager:GetControl();