1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

UI Functions

Discussion in 'Civ5 - Modding Tutorials & Reference' started by Thalassicus, Feb 9, 2012.

  1. Thalassicus

    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:
     
  2. Pazyryk

    Pazyryk Chieftain

    Joined:
    Jun 13, 2008
    Messages:
    3,585
    Would be nice if they were. Everything in UI takes me 10 times longer to do than it should.
     
  3. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    7,996
    Location:
    Near Portsmouth, UK
    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)
     
  4. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    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.
     
  5. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    7,996
    Location:
    Near Portsmouth, UK
    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!
     
  6. Thalassicus

    Thalassicus Bytes and Nibblers

    Joined:
    Nov 9, 2005
    Messages:
    11,057
    Location:
    Texas
    Thank you for the tip, that should speed up my efforts a lot!
     
  7. The_J

    The_J Say No 2 Net Validations Retired Moderator

    Joined:
    Oct 22, 2008
    Messages:
    29,759
    Location:
    Germany / Netherlands
    Moderator Action: Moved to the tutorials and references subforum (due to post #2).
     
  8. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    7,996
    Location:
    Near Portsmouth, UK
    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();
     

Share This Page