Skip to content

ghostbane38/LibGuildRoster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

LibGuildRoster

🚩 Description

This is a Lib for the Elder Scrolls Online "Guild Roster" list. There are numerous popular addons that inject custom columns into the Guild Roster, which causes a bit of chaos as they typically conflict with one another. LibGuildRoster hopes to act as a standardisation for addons to create these columns and to prevent UI failures. The traditional way to piece into the Roster is via hijacking the vanilla ZO process, if multiple addons are doing this at the same time, we have issues of layer placement, anchor recycling and in-general render tearing. All of the above degrades performance and obviously, the experience.

Example Graphic

Addons running through one 'channel' will introduce a level of compatibility that benefits everyone. This also brings up a few additional benefits, such as fixing the background texture of the Roster window. The Lib calculates how the texture should render, based on the relative content available for the current guild in the Scene.

An extreme example

An extreme example 🤣 of ITTDB, ATT, MM3 and a dummy addon, side by side through the Lib.

Benefits

✔️ Compatibility

✔️ Working window background

✔️ Option to hide columns per guild

 

🚩 Example Usage

LibGuildRoster:AddColumn({
    
  key = 'MyAddon_CarrotCount',
        
  width = 80,
        
  header = {
    title = 'Carrots'
  },
        
  row = {

      align = TEXT_ALIGN_RIGHT,

      data = function( guildId, data, index )
        
        -- Return an unformated raw value
        return MyAddon:GetCarrotCount( guildId, data.displayName )
          
      end,

      format = function( value )
      
        return zo_strformat("<<1>>", ZO_LocalizeDecimalNumber(tonumber(value)))..' carrots'
          
      end

  }
})

 

Table of Contents

 

🚩 Options

key

Type: String

Example: 'MyAddon_CarrotCount'

⚠️ No spaces or special characters or the sorting/filtering will not work properly and drop performance

 

width

Type: Number

Example: 80

Default: 110

🏳️ this is optional

 

header.title

Type: String

Example: Carrots

 

header.align

Type: GLOBAL

Requires: TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER

Default: TEXT_ALIGN_LEFT

🏳️ this is optional

 

header.tooltip

Type: STRING

Example: 'A total of each member\'s carrots'

🏳️ this is optional

❓ This is for the tooltip when hovering over a column header, a string value can be displayed

 

row.align

Type: GLOBAL

Requires: TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER

Default: TEXT_ALIGN_LEFT

🏳️ this is optional

 

row.data

Type: FUNCTION

Args: guildId Number, rowData Object, rowIndex Number

Example:

...
data = function( guildId, data, index )
    
    -- Return an unformated raw value
    return MyAddon:GetCarrotCount( guildId, data.displayName )

end,
...

⚠️ Function must return a raw value, to design the value, see row.format below

🏳️ this is optional - See LibGuildRoster:SetBulkData() for other approach

 

row.format

Type: FUNCTION

Args: rowCallValue String

Example:

...
format = function( value )
    
    return zo_strformat("<<1>>", ZO_LocalizeDecimalNumber(tonumber(value)))..' carrots'

end,
...

⚠️ value will always be passed in as a String

🏳️ this is optional

 

row.mouseEnabled

Type: FUNCTION

Args: guildId Number, rowData Object, rowCellValue ( Number, String )

Example:

...
mouseEnabled = function( guildId, data, value )
    
    local condition = false
    
    if value >= 1 then
        condition = true
    end
    
    return condition

end,
...

⚠️ Function must return a true/false value

🏳️ this is optional

 

row.OnMouseEnter

Type: FUNCTION

Args: guildId Number, rowData Object, control Object / GUI

Example:

...
OnMouseEnter = function( guildId, data, control )

    InitializeTooltip(MyAddonTooltip)
    MyAddonTooltip:SetDimensionConstraints(380,-1,440,-1)
    MyAddonTooltip:ClearAnchors()
    MyAddonTooltip:SetAnchor(BOTTOMRIGHT, control, TOPLEFT, 100, 0)
    MyAddonTooltip_GetInfo(MyAddonTooltip, data.displayName)

end,
...

🏳️ this is optional

 

row.OnMouseExit

Type: FUNCTION

Args: guildId Number, rowData object, control object/GUI

Example:

...
OnMouseExit = function( guildId, data, control )

    ClearTooltip(MyAddonTooltip)

end,
...

🏳️ this is optional

 

guildFilter

Type: OBJECT

Requires: Object of guildId's

Example: { 10156, 117856, 39891 }

🏳️ this is optional

❓ This allows you to set what guilds your column will display in, this can be set further with Column:SetGuildFilter() ( as seen below )

 

beforeList

Type: FUNCTION

Example:

...
beforeList = function()
    
    -- Do something before the column renders

end,
...

🏳️ this is optional

❓ This function is fired before the column renders its data

 

afterList

Type: FUNCTION

Example:

...
afterList = function()
    
    -- Do something after the column renders

end,
...

🏳️ this is optional

❓ This function is fired after the column renders its data

 

🚩 API Reference

LibGuildRoster:AddColumn()

Args: settingsObject Object

Example: See main Example up above

Returns: A Column instance

 

LibGuildRoster:Refresh()

❓ Alias for GUILD_ROSTER_MANAGER:RefreshData()

 

LibGuildRoster:OnRosterReady()

Args: callback Function

Example:

LibGuildRoster:OnRosterReady(function()

    -- Roster has finished rendering, do something

end

❓ Handy if you have additional UI and need to anchor it to your custom column

 

LibGuildRoster:SetBulkData()

Args: columnList Object, callback Function ( SetRowData args )

Example:

local purchasesColumn = LibGuildRoster:AddColumn({ 
    key = 'MyAddon_Purchases',
    header = {
      title = 'Purchases'
    },
    row = {
        ...
    }
})

local salesColumn = LibGuildRoster:AddColumn({ 
    key = 'MyAddon_Sales',
    header = {
      title = 'Sales'
    },
    row = {
        ...
    }
})

LibGuildRoster:SetBulkData({ purchasesColumn, salesColumn }, function( guildId, data, index)

    local purchases, sales = MyAddon.GetNumbers( guildId, data.displayName )
    
    -- Add multiple values to the data object, use your defined column keys as the object key
    data['MyAddon_Purchases'] = purchases
    data['MyAddon_Sales'] = sales
    
    -- Return the data object that was passed through
    return data

end)

❓ This is a useful approach if you have multiple columns and your logic is repeative. Going through the bulk method, your logic only fires once, rather than per column.

 

Column:GetHeader()

Example:

local carrotColumn = LibGuildRoster:AddColumn({ 
    key = 'MyAddon_Carrots',
    header = {
      title = 'Carrots'
    },
    row = {
        ...
    }
})

-- Fire when the Roster has finished rendering
LibGuildRoster:OnRosterReady(function()

    MyAddon_CarrotDropdown:SetAnchor(TOP, carrotColumn:GetHeader(), CENTER, 0, 582)

end)

 

Column:SetGuildFilter()

Args: Object of guildId's

Example:

-- Inside callback of your Addons settings
carrotColumn:SetGuildFilter({ 10156, 117856, 39891 })

-- carrotColumn will not only display in the guilds with the ID of 10156, 117856, 39891

❓ This gives you some flexibility in making some nice filter settings on which guild should display which column(s)

 

Column:UpdateRowData()

Args: callback Function

Example:

carrotColumn:UpdateRowData(function( guildId, data, index )
    
    -- do stuff
    
end)

❓ This method allows you to update the function for getting the data of a rowCell

 

About

ESO Lib providing a universal api for addons to create custom columns in the Guild Roster

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages