UI Functions

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
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:
 
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)
 
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!
 
I'll add these here as they are related,

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

Code:
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();
 
Top Bottom