Thread Tools Display Modes
05/05/15, 03:12 PM   #1
stAjora
Join Date: Apr 2015
Posts: 20
ScrollListExample & Dropdown Windows

I'm having trouble understanding how ScrollListExample add on functions. I'm completely lost on the ZO_ScrollList and ZO_SortFilteredList functions. I can't even determine how/where the add on finds/inserts data into the window.

This seems a little more complex than a simple drop down but even that I'm having trouble. Looking at the GuildSelector.xml in the game files, I see a function call ZO_ComboBox_DropdownClicked(self:GetParent()), I don't see how this window is being populated with information.
  Reply With Quote
05/05/15, 03:53 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,012
I'm not sure if I'm telling you bull**** about the guildselector combobox but I'll try to explain what I understood how it works

The combobox in the guildselector.xml is named "$(parent)ComboBox". As the $parent is a placeholder for the "parent" control, which is the TopLevelControl "ZO_GuildSelector", this full name will be:
ZO_GuildSelectorComboBox

You could use the ZGOO addon inagme, go to the guild roster e.g where you can see the guild selector combobox.
Now enter /zgoo ZO_GuildSelectorComboBox into the chat.
You'll see a list of all functions and controls, children etc. of this combobox.
At the function GetChildren(), if you expand it by the small ":" button, you can see 2 children where one is a label control and the other one is a button.
The label will show the text/name of the guild, the button is the small triangel button right to the selector combobox.

Hint:
You can always use the function A__ZGoo_ToggleHidden() to toggle the visibility of elements to see which element you are currently looking at

So where does the data of the combobox come from?
You can see a table "m_comboBox" beyond the combobox control ZO_GuildSelectorComboBox.
In there you'll find different functions and other tables, where one is holding the entries of the combobox:
m_sortedItems

The entries here must be somwhow "loaded" into the table. This must be done after the box has been created.
Inside the XML file you'll find the following part beyond the combobox control:
Code:
<OnInitialized>
                        ZO_ComboBox:New(self)
                    </OnInitialized>
This will call the standard creation methods of this combobox.

->
Somwhere this will trigger an event "EVENT_GUILD_DATA_LOADED", or at least this event will be used later on to populate the guild data. Maybe it is triggered as you open the guild roster.
YoU'll have to search the other guild files for the event name to check in detail-

lua file
Together with the XML file there is a lua file in the same directory, with the same name: "guildselector.lua".

In here you fnd additional source code, like the creation of the guild selector subclass (OO coding).
At the cretion of this subclass the combobox will be assigned to the subclass, in function "function GuildSelector:New(control)" at line 7ff
Lua Code:
  1. local comboBoxControl = GetControl(control, "ComboBox")
  2.     selector.comboBox = ZO_ComboBox_ObjectFromContainer(comboBoxControl)
  3.     selector.comboBox:SetSortsItems(false)
  4.     selector.comboBox:SetSelectedItemFont("ZoFontWindowTitle")
  5.     selector.comboBox:SetDropdownFont("ZoFontHeader2")
  6.     selector.comboBox:SetSpacing(8)


In additon here is added an event listener for this event that we have talked about above,
event "EVENT_GUILD_DATA_LOADED", see line 29:

Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("GuildsSelector", EVENT_GUILD_DATA_LOADED, function() selector:InitializeGuilds() end)

As the event gets triggered the callback function InitializeGuilds() will be executed and this function is filling the combobox then finally for the first time.

See lines 68ff:
Lua Code:
  1. function GuildSelector:InitializeGuilds()
  2.     if(not self.scenesCreated) then return end
  3.  
  4.     local selectedEntry
  5.     local lastGuildId = self.guildId
  6.    
  7.     self.guildId = nil
  8.     self.comboBox:ClearItems() -- cler the combobox
  9.    
  10.     local numGuilds = GetNumGuilds() -- get the total number of guilds that you joined
  11.     for i = 1, numGuilds do -- loop every guild now
  12. --Get guild information, name, fraction, etc.
  13.         local guildId = GetGuildId(i)
  14.         local guildName = GetGuildName(guildId)
  15.         local guildAlliance = GetGuildAlliance(guildId)
  16. -_Add the fraction icon + text together to a string
  17.         local entryText = zo_strformat(SI_GUILD_SELECTOR_FORMAT, GetAllianceBannerIcon(guildAlliance), i, guildName)
  18.  
  19. --Add the string into the combobox
  20.         local entry = self.comboBox:CreateItemEntry(entryText, self.OnGuildChanged)
  21.         entry.guildId = guildId
  22.         entry.selectedText = guildName
  23.         self.comboBox:AddItem(entry)
  24.  
  25.         if(not selectedEntry or (lastGuildId and guildId == lastGuildId)) then
  26.             selectedEntry = entry
  27.         end
  28.  
  29.         if(not playerIsGuildMaster) then
  30.             local guildPlayerIndex = GetPlayerGuildMemberIndex(guildId)
  31.             local _, _, rankIndex = GetGuildMemberInfo(guildId, guildPlayerIndex)
  32.             if(IsGuildRankGuildMaster(guildId, rankIndex)) then
  33.                 playerIsGuildMaster = true
  34.             end
  35.         end
  36.     end
  37.  
  38.     local CREATE_WINDOW_TITLE = GetString(SI_GUILD_CREATE_TITLE)
  39.     local entry = self.comboBox:CreateItemEntry(CREATE_WINDOW_TITLE, self.OnGuildChanged)
  40.     entry.selectedText = CREATE_WINDOW_TITLE
  41.     self.comboBox:AddItem(entry)
  42.  
  43.     if(numGuilds == 0) then
  44.         self.comboBox:SetSelectedItem(CREATE_WINDOW_TITLE)
  45.         self.OnGuildChanged(nil, CREATE_WINDOW_TITLE, entry)
  46.     else
  47.         self.comboBox:SetSelectedItem(selectedEntry.selectedText)
  48.         self.OnGuildChanged(nil, selectedEntryText, selectedEntry)
  49.     end
  50. end
  Reply With Quote
05/05/15, 04:35 PM   #3
stAjora
Join Date: Apr 2015
Posts: 20
Holy crap that is a lot of functionality...

I'm going to attempt to create a simple example, create a combo box and make it display the data of a hard coded table. If someone more experienced beats me to it, please post it. I know im going to spend 80 years on this.
  Reply With Quote
05/05/15, 05:22 PM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,012
Basically you only need to create the combobox that you need, anchor it somehwhere to a parent control to show it and give it some entries.

You said you wish to have a table for this, let's call it myTable.
And your combobox is named, let's say, myComboBox (created by help of XML or lua code):

Lua Code:
  1. local myTable = {
  2. [1] ="Hello",
  3. [2] = "World",
  4. }
  5.  
  6. --Im not sure what the first parameter is. I guesss the selected index, or maybe it is the control (combobox) itsself. If the chat output will tell oyu it's a table then it's probably the combobox control :-)
  7. local function myCallbackFunction(amItheSelectedIndex, entryText, entry)
  8.    d("[" .. tostring(amItheSelectedIndex) .. "] Combobox entry " .. entryText .. " callback function is executed")
  9. end
  10.  
  11. for index, text in pairs(myTable) do
  12.         local entry = myComboBox.comboBox:CreateItemEntry(text, myCallbackFunction)
  13.         entry.selectedText = text
  14.         myComboBox.comboBox:AddItem(entry)
  15. end
  Reply With Quote
05/10/15, 10:00 PM   #5
stAjora
Join Date: Apr 2015
Posts: 20
I know LAM is supposed to be used for addon settings menus but couldn't it be used in an add on just the same outside a settings option window to do the things I requested in this thread?

edit

I still couldn't get a functional drop down.

Last edited by stAjora : 05/10/15 at 10:05 PM.
  Reply With Quote
05/10/15, 10:15 PM   #6
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Look at autoInvite he pushed it's lam2 panel into its window xml.
  Reply With Quote
05/11/15, 04:04 AM   #7
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by stAjora View Post
I'm going to attempt to create a simple example, create a combo box and make it display the data of a hard coded table. If someone more experienced beats me to it, please post it. I know im going to spend 80 years on this.
Originally Posted by stAjora View Post
I still couldn't get a functional drop down.
I'm not sure what you want, the thread is posted as scrollList, but everyone is talking about a combo box.
Did you want something like this?

Code to create top level window, a background, & the comboBox:
Warning: Spoiler


Code to populate the comboBox:

There are a lot of ways to populate the comboBox, you can loop through a table and use CreateItemEntry to create the item entries for you like this:
Warning: Spoiler


Code to call those functions to create the window/box, & populate it:
Warning: Spoiler


Other ways to populate it:

CreateItemEntry just creates a table from the data you pass it that looks like this:
Warning: Spoiler


So if you wanted to store extra data with each item, you could create the entry yourself & just add the extra data like this:
Warning: Spoiler



or if you create the itemEntries yourself you could let the game handle the loop & addItem(...) calls for you with:
Warning: Spoiler

Last edited by circonian : 05/11/15 at 04:08 AM.
  Reply With Quote
05/12/15, 04:07 PM   #8
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
Originally Posted by stAjora View Post
I know LAM is supposed to be used for addon settings menus but couldn't it be used in an add on just the same outside a settings option window to do the things I requested in this thread?

edit

I still couldn't get a functional drop down.
Yeah, you use the LAMCreateControl functionality as indicated here:
https://github.com/sirinsidiator/ESO...ethods-on-LAM2

I use that extensively for the UI controls in AutoInvite. The group list and some of the buttons are separate, but most of the options are using LAM creation. This file has most of the control creation:
http://git.esoui.com/?a=viewblob&p=A...s_fragment.lua

For dropdown, it should be something like:
Lua Code:
  1. local myDropdown = LAMCreateControl.dropdown(PARENT_CONTROL, {
  2.     type = "dropdown",
  3.     name = "My Dropdown",
  4.     tooltip = "Dropdown's tooltip text.",
  5.     choices = {"table", "of", "choices"},
  6.     sort = "name-up", --or "name-down", "numeric-up", "numeric-down" (optional) - if not provided, list will not be sorted
  7.     getFunc = function() return db.var end,
  8.     setFunc = function(var) db.var = var doStuff() end,
  9.     width = "full", --or "half" (optional)
  10.     disabled = function() return db.someBooleanSetting end, --or boolean (optional)
  11.     warning = "Will need to reload the UI.",    --(optional)
  12.     default = defaults.var, --(optional)
  13.     reference = "MyAddonDropdown"   --(optional) unique global reference to control
  14. })
  15. --Table contents taken from documentation at top of the dropdown.lua control in LAM
  16.  
  17. --You will need to set an anchor after creating the control.
  18. myDropdown:SetAnchor(TOPLEFT, PARENT_CONTROL, TOPLEFT, 0, 25)

If you're familiar with LAM, it's (much) easier to setup this way. The only window manager stuff you need to get into is making sure you have a parent control and setting the anchor. On the downside, you don't have as much flexibility in terms of sizing. If the option-styling of LAM works for you, though, it's much easier to setup.
  Reply With Quote
06/03/15, 11:24 AM   #9
Argusus
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 120
Is this something like you are looking for?

http://www.esoui.com/downloads/info5...stExample.html

Basically the data is
assigned via tables in the initialization functions. I can't remember which one but it's either New or Initialize. I'll have to double check when I'm on a pc.



Originally Posted by stAjora View Post
I'm having trouble understanding how ScrollListExample add on functions. I'm completely lost on the ZO_ScrollList and ZO_SortFilteredList functions. I can't even determine how/where the add on finds/inserts data into the window.

This seems a little more complex than a simple drop down but even that I'm having trouble. Looking at the GuildSelector.xml in the game files, I see a function call ZO_ComboBox_DropdownClicked(self:GetParent()), I don't see how this window is being populated with information.

Last edited by Argusus : 06/03/15 at 11:27 AM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » ScrollListExample & Dropdown Windows


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off