Thread Tools Display Modes
03/11/15, 06:29 PM   #1
Deome
 
Deome's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 29
Question Stumped By GUILD_ROSTER Changes

So, for some time now I've had a neat feature in ddSK that re-does the whole Guild Roster screen so that members sales data can be shown/ranked in the winder.

But now, for the life of me I can't get the UI to recognize the <Label> controls in individual rows--the data is there, and the text is there, but the controls ain't loading.

Prior to 1.6, this is the code I used to add those controls to ZO_GuildRosterList:
Code:
ZO_ScrollList_AddDataType(GUILD_ROSTER.list, 2, "ddSKRosterRow", 30, function(control, data) GUILD_ROSTER:SetupGuildMember(control, data) end)

Obviously, GUILD_ROSTER is now a mess of keyboard and gamepad changes. Here's the best effort I have to simply adapt to the new Roster classes:
Code:
ZO_ScrollList_AddDataType(GUILD_ROSTER_KEYBOARD.list, 2, "ddSKRosterRow", 30, function(control, data) GUILD_ROSTER_MANAGER:SetupRow(control, data) end)



I've also updated the XML file so that:
Code:
<Control name="ddSKRosterRow" mouseEnabled="true" virtual="true" inherits="ZO_GuildRosterRow">

is now:
Code:
<Control name="ddSKRosterRow" mouseEnabled="true" virtual="true" inherits="ZO_KeyboardGuildRosterRow">
due to the change in the RosterRow control names.

What am I missing here? I just need the labels themselves, the fancy things that make the window display text, from my ddSKRosterRow control to show up.
  Reply With Quote
03/11/15, 07:07 PM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Lua Code:
  1. function ZO_KeyboardGuildRosterManager:BuildMasterList()
  2.      -- The master list lives in the GUILD_ROSTER_MANAGER and is built there
  3. end
  4.  
  5. function ZO_KeyboardGuildRosterManager:FilterScrollList()
  6.     ...
  7.     local masterList = GUILD_ROSTER_MANAGER:GetMasterList()
  8.     ...
  9. end

So you need to hook BuildMasterList on GUILD_ROSTER_MANAGER, and FilterScrollList on GUILD_ROSTER_KEYBOARD.
Also for FilterScrollList, I wouldn't replace the function, but call the original and then rewrite all entries' typeId.

Or, and this may seem dirty but is nonetheless awesome, don't hook it at all, and make the original create entries with your typeId:
Lua Code:
  1. -- this will only work because GUILD_MEMBER_DATA is not local in ingame/guild/keyboard/guildroster_keyboard.lua
  2. local DDSK_G = setmetatable({GUILD_MEMBER_DATA = DDSK_DATA_TYPE}, {__index = _G})
  3. setfenv(GUILD_ROSTER_KEYBOARD.FilterScrollList, DDSK_G)
  Reply With Quote
03/11/15, 07:13 PM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,962
I didn't try it and don#t know your addon, so i couldn't test it, but couldn't you just use GUILD_ROSTER_MANAGER:SetupGuildMember() again to add the controls?
  Reply With Quote
03/11/15, 07:56 PM   #4
Deome
 
Deome's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 29
Question

Originally Posted by merlight View Post
Lua Code:
  1. function ZO_KeyboardGuildRosterManager:BuildMasterList()
  2.      -- The master list lives in the GUILD_ROSTER_MANAGER and is built there
  3. end
  4.  
  5. function ZO_KeyboardGuildRosterManager:FilterScrollList()
  6.     ...
  7.     local masterList = GUILD_ROSTER_MANAGER:GetMasterList()
  8.     ...
  9. end

So you need to hook BuildMasterList on GUILD_ROSTER_MANAGER, and FilterScrollList on GUILD_ROSTER_KEYBOARD.
Also for FilterScrollList, I wouldn't replace the function, but call the original and then rewrite all entries' typeId.

Or, and this may seem dirty but is nonetheless awesome, don't hook it at all, and make the original create entries with your typeId:
Lua Code:
  1. -- this will only work because GUILD_MEMBER_DATA is not local in ingame/guild/keyboard/guildroster_keyboard.lua
  2. local DDSK_G = setmetatable({GUILD_MEMBER_DATA = DDSK_DATA_TYPE}, {__index = _G})
  3. setfenv(GUILD_ROSTER_KEYBOARD.FilterScrollList, DDSK_G)
Actually, I have my own hooks for BuildMasterList and FilterScrollList (though I've made no real changes to the latter) hooks. The sales data is in the ZO_GuildRoster control and all its children--I've already tested and noted that the "LabelText" that I use for the ddSKRosterRow controls can easily be posted to chat. The issue isn't in SetupGuildMember or even SetupRow as best I can tell; here's how those controls, and the normal ones, appear in my SetupGuildMember replacement function:

Code:
function ddShopkeeper.SetupGuildMember(self, control, data)
	origSetupGuildMember(self, control, data)
	
	local UserId = GetControl(control, "DisplayName")
	local Zone = GetControl(control, "Zone")
	local Class = GetControl(control, "Class")
	local Level = GetControl(control, "Level")
	local Vet = GetControl(control, "Veteran")
	local Note = GetControl(control, "Note")
	UserId:SetText(data.sortIndex.."  "..data.displayName)
		
	local tRosterSales = ddShopkeeper.Ledger.Options.cRosterSales.getFunc()
	local tRosterPurchases = ddShopkeeper.Ledger.Options.cRosterPurchases.getFunc()
	local tRosterTax = ddShopkeeper.Ledger.Options.cRosterTax.getFunc()
	local Sales = GetControl(control, "SalesLabel")
	local Purchases = GetControl(control, "PurchaseLabel")
	local Tax = GetControl(control, "TaxLabel")
	local SalesText = ddShopkeeper.LocalizedNumber(data.sales).." "..zo_iconFormat("esoui/art/currency/currency_gold.dds", 14, 14)
	local PurchText = ddShopkeeper.LocalizedNumber(data.purchases).." "..zo_iconFormat("esoui/art/currency/currency_gold.dds", 14, 14)
	local TaxesText = ddShopkeeper.LocalizedNumber(data.tax).." "..zo_iconFormat("esoui/art/currency/currency_gold.dds", 14, 14)

So, "SalesText" etc. can easily go to chat with a simple display function ( d(SalesText) ) and it'll post 500 lines of it to chat. Likewise, I can manipulate all the original controls like Vet and Note. But the "Sales", etc., variables, based on a GetControl("MyddSKRosterRowLabelName") function, come up nil.

As best I can tell, the issue is that my control(s) never get added like they used to, from this function:
Code:
ZO_ScrollList_AddDataType(GUILD_ROSTER_KEYBOARD.list, 2, "ddSKRosterRow", 30, function(control, data) GUILD_ROSTER_MANAGER:SetupRow(control, data) end)
  Reply With Quote
03/11/15, 09:40 PM   #5
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Deome View Post
As best I can tell, the issue is that my control(s) never get added like they used to, from this function:
Code:
ZO_ScrollList_AddDataType(GUILD_ROSTER_KEYBOARD.list, 2, "ddSKRosterRow", 30, function(control, data) GUILD_ROSTER_MANAGER:SetupRow(control, data) end)
I guess you know this, but just to be clear: that only registers the data type, it must the be used to create data entries in FilterScrollList. Could it be that the list is built and filtered even before you hook that? Try RefreshData after you setup hooks. Oh and now I noticed: SetupRow is a method of ZO_KeyboardGuildRosterManager, not the shared manager. How come it doesn't spit errors?

Btw, you should give that "2" type a name, it'll be easier to find where it's used in the code

And final note for tonight. ZO_ScrollList_AddDataType with setup function that calls the base version, and then overriding the base version, is complicated and wrong -- if you're adding data type 2, you should not be changing the setup procedure for data type 1. Instead, provide a function that will call the base setup, and then your additional setup:
Lua Code:
  1. ZO_ScrollList_AddDataType(GUILD_ROSTER_KEYBOARD.list, 2, "ddSKRosterRow", 30,
  2. function(control, data)
  3.     GUILD_ROSTER_KEYBOARD:SetupRow(control, data)
  4.     ddShopkeeper.SetupGuildMember(GUILD_ROSTER_MANAGER, control, data) -- don't call origSetupGuildMember from there, only init your own stuff
  5. end)
  Reply With Quote
03/11/15, 09:47 PM   #6
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by merlight View Post
I guess you know this, but just to be clear: that only registers the data type, it must the be used to create data entries in FilterScrollList. Could it be that the list is built and filtered even before you hook that? Try RefreshData after you setup hooks. Oh and now I noticed: SetupRow is a method of ZO_KeyboardGuildRosterManager, not the shared manager. How come it doesn't spit errors?
After I posted that and re-read again to check, it started coming together. Here's what I think is happening.
1. game starting
2. original BuildMasterList
3. original FilterScrollList => all entries have typeId == 1
4. ddSK installs hooks
5. list is shown, row controls are created for type 1
6. ddSK SetupGuildMember wonders where are children for type 2
  Reply With Quote
03/12/15, 02:35 AM   #7
Minceraft
 
Minceraft's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 51
MailBuddy

I've also had similar problems with MailBuddy. ZO_FriendsList was renamed and we've tried to account for it by changing the name in the code, but it still doesn't anchor AT ALL... stumped...
  Reply With Quote
03/12/15, 08:15 PM   #8
Deome
 
Deome's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 29
Unhappy

Originally Posted by merlight View Post
After I posted that and re-read again to check, it started coming together. Here's what I think is happening.
1. game starting
2. original BuildMasterList
3. original FilterScrollList => all entries have typeId == 1
4. ddSK installs hooks
5. list is shown, row controls are created for type 1
6. ddSK SetupGuildMember wonders where are children for type 2
Okay, I'm starting to see it too. I really had no idea FilterScrollList is involved. Guess I'll be digging through the API tonight.
  Reply With Quote
03/13/15, 03:41 AM   #9
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Deome View Post
Okay, I'm starting to see it too. I really had no idea FilterScrollList is involved. Guess I'll be digging through the API tonight.
Yea that's kind of unexpected, more so that different parts of ZOS code do that differently.

For example KEYBINDING_MANAGER creates complete data entries for the underlying ZO_ScrollList in BuildMasterList, and then in FilterScrollList only throws these into ZO_ScrollList.

GUILD_ROSTER_MANAGER, on the other hand, creates only its inner data tables in BuildMasterList, and GUILD_ROSTER_KEYBOARD wraps them in ZO_ScrollList_CreateDataEntry later in FilterScrollList. This is necessary because the masterList is shared between KB and GP lists, but ZO_ScrollList assumes ownership of the entries you put in it, so KB and GP must create their own entries.
  Reply With Quote
03/13/15, 12:30 PM   #10
Deome
 
Deome's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 29
Question

Originally Posted by merlight View Post
Yea that's kind of unexpected, more so that different parts of ZOS code do that differently.

For example KEYBINDING_MANAGER creates complete data entries for the underlying ZO_ScrollList in BuildMasterList, and then in FilterScrollList only throws these into ZO_ScrollList.

GUILD_ROSTER_MANAGER, on the other hand, creates only its inner data tables in BuildMasterList, and GUILD_ROSTER_KEYBOARD wraps them in ZO_ScrollList_CreateDataEntry later in FilterScrollList. This is necessary because the masterList is shared between KB and GP lists, but ZO_ScrollList assumes ownership of the entries you put in it, so KB and GP must create their own entries.
Okay, so here's what I've tested and found:

1) I still need to replace the old SetupGuildMember with my own, and call the old one in it first. Splitting it into two functions in the AddDataType function seems to only create more problems.

2) "2" has been assigned to a new local global DDSK_GUILD_ROSTER_DATA, just for fancy naming purposes.

3) Everything goes right in BuildMasterList. But my FilterScrollList replacement hook ain't adding DDSK_GUILD_ROSTER_DATA to row controls like it did pre-1.6. That seems to be where I'm screwed--all the data is available, but my XML label controls just aren't getting added to each row control's children so there's no control, like "SalesLabel", for my GetControl calls in the SetupGuildMember function. Why?
  Reply With Quote
03/13/15, 01:08 PM   #11
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Deome View Post
1) I still need to replace the old SetupGuildMember with my own, and call the old one in it first. Splitting it into two functions in the AddDataType function seems to only create more problems.
No, that's just wrong. You're adding a new data type, you can do everything you need in your own setup function.
GUILD_MEMBER_DATA -> template "ZO_KeyboardGuildRosterRow" -> function ZO_KeyboardGuildRosterManager:SetupRow
DDSK_GUILD_ROSTER_DATA -> template "ddSKRosterRow" -> function ddSKRosterRowSetup

All row controls created from the template "ddSKRosterRow" will use your ddSKRosterRowSetup function. There's no point in hooking SetupGuildMember, any control not going through ddSKRosterRowSetup wil not have been created from your template.

Originally Posted by Deome View Post
3) Everything goes right in BuildMasterList. But my FilterScrollList replacement hook ain't adding DDSK_GUILD_ROSTER_DATA to row controls like it did pre-1.6. That seems to be where I'm screwed--all the data is available, but my XML label controls just aren't getting added to each row control's children so there's no control, like "SalesLabel", for my GetControl calls in the SetupGuildMember function. Why?
Do you have the latest code somewhere? I could only guess. FilterScrollList was changed in 1.6 due to the surrounding changes.
  Reply With Quote
03/13/15, 02:31 PM   #12
Deome
 
Deome's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 29
Lightbulb Solved it.

Originally Posted by merlight View Post
No, that's just wrong. You're adding a new data type, you can do everything you need in your own setup function.
GUILD_MEMBER_DATA -> template "ZO_KeyboardGuildRosterRow" -> function ZO_KeyboardGuildRosterManager:SetupRow
DDSK_GUILD_ROSTER_DATA -> template "ddSKRosterRow" -> function ddSKRosterRowSetup

All row controls created from the template "ddSKRosterRow" will use your ddSKRosterRowSetup function. There's no point in hooking SetupGuildMember, any control not going through ddSKRosterRowSetup wil not have been created from your template.
Actually, it works just fine now. I had to add a call to GUILD_ROSTER_KEYBOARD:ColorRow at the top of my SetupGuildMember function, right above where I call the old function, but that was never the issue.

Originally Posted by merlight View Post
Do you have the latest code somewhere? I could only guess. FilterScrollList was changed in 1.6 due to the surrounding changes.
Boom. That was exactly what changed--once I got and replaced the new FilterScrollList function, it was a very short trip downhill.

For everyone's benefit, these are my hooks, the FilterScrollList function, and the critical first part of my SetupGuildMember function:

Hooks:
Code:
origSetupGuildMember = GUILD_ROSTER_MANAGER.SetupGuildMember
origBuildMasterList = GUILD_ROSTER_MANAGER.BuildMasterList
GUILD_ROSTER_MANAGER.SetupGuildMember = ddShopkeeper.SetupGuildMember
GUILD_ROSTER_MANAGER.BuildMasterList = ddShopkeeper.RosterBuildMasterList
GUILD_ROSTER_KEYBOARD.FilterScrollList = ddShopkeeper.RosterFilterScrollList
GUILD_ROSTER_KEYBOARD.CompareGuildMembers = ddShopkeeper.CompareGuildMembers
		
ZO_ScrollList_AddDataType(ZO_GuildRosterList, DDSK_GUILD_MEMBER_DATA, "ddSKRosterRow", 30, function(control, data) GUILD_ROSTER_MANAGER:SetupGuildMember(control, data) end)
FilterScrollList:
Code:
function ddShopkeeper.RosterFilterScrollList(self)
  local scrollData = ZO_ScrollList_GetDataList(self.list)
  ZO_ClearNumericallyIndexedTable(scrollData)

  local searchTerm = self.searchBox:GetText()
  local masterList = GUILD_ROSTER_MANAGER:GetMasterList()
	
  for i = 1, #masterList do
    local data = masterList[i]
    if (searchTerm == "" or GUILD_ROSTER_MANAGER:IsMatch(searchTerm, data)) then
      table.insert(scrollData, ZO_ScrollList_CreateDataEntry(DDSK_GUILD_MEMBER_DATA, data))
    end
  end
end
New SetupGuildMember:
Code:
function ddShopkeeper.SetupGuildMember(self, control, data, selected)
	GUILD_ROSTER_KEYBOARD:ColorRow(control, data, selected)
	origSetupGuildMember(self, control, data, selected)
Should be ready to publish soon; the guild roster window is working just fine now.

Last edited by Deome : 03/13/15 at 02:36 PM.
  Reply With Quote
03/13/15, 02:47 PM   #13
Elijafire
Join Date: Jun 2014
Posts: 2
Nice

Great work Deome, thanks for your hard work we appreciate it. Thanks for those who bounced ideas off him too.

Be blessed!

E
  Reply With Quote
03/13/15, 04:03 PM   #14
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Deome View Post
Lua Code:
  1. ZO_ScrollList_AddDataType(ZO_GuildRosterList, DDSK_GUILD_MEMBER_DATA, "ddSKRosterRow", 30, function(control, data) GUILD_ROSTER_MANAGER:SetupGuildMember(control, data) end)
I know I'm repeating myself, but... Why do you insist on calling SetupGuildMember, which doesn't do everything you want, effectively forcing yourself into hooking it? I'm always looking for ways to avoid unnecessary hooks, and this is exactly the case where you can do it cleanly and simply without hooking.
Lua Code:
  1. ZO_ScrollList_AddDataType(ZO_GuildRosterList, DDSK_GUILD_MEMBER_DATA, "ddSKRosterRow", 30,
  2.   function(control, data)
  3.     GUILD_ROSTER_KEYBOARD:SetupRow(control, data) -- original "ZO_KeyboardGuildRosterRow" setup
  4.     -- ... your setup here
  5.   end)

Note the original setup function, which I also used a few posts above, you should've copied that. Here is the function for reference:
Lua Code:
  1. function ZO_KeyboardGuildRosterManager:SetupRow(control, data)
  2.     ZO_SortFilterList.SetupRow(self, control, data)
  3.     GUILD_ROSTER_MANAGER:SetupGuildMember(control, data)
  4. end
ZO_SortFilterList.SetupRow, among other things, calls ColorRow.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Stumped By GUILD_ROSTER Changes

Thread Tools
Display Modes

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