09/04/15, 07:45 PM | #1 |
|
ZO_Templates ScrollTemplates
Hello,
Does anyone have recommendations for me change my Scroll lists in TradesMan? It looks like they have removed or deprecated the Filter ScrollList base I was relying on to build my addon. any feedback/suggestions are appreciated! below is the message i'm getting since the new update. |
09/04/15, 08:23 PM | #2 |
|
You're either passing nil instead of proper list control to ZO_ScrollList_AddDataType, or it hasn't been initialized properly with ZO_ScrollList_Initialize.
|
09/04/15, 08:30 PM | #3 |
|
Ok, read some more.
In order to be used as ZO_SortFilterList, CustomerListContainer must contain a control named "$(parent)List" that inherits="ZO_ScrollList". Delete all your X:New functions, they're not needed, and wrong. ZO_SortFilterList.New itself calls :Initialize, you don't want to call it a second time. Fix your :Initialize functions to call the base as the very first thing. |
09/04/15, 08:41 PM | #4 | |
|
Code:
function CustomerList:New() local customers = ZO_SortFilterList.New(self, CustomerListContainer) customers:Initialize() return customers end |
|
09/04/15, 08:58 PM | #5 |
|
Remove the function CustomerList:New(), it's overriding the base with nothing "new" to add
TRADESMAN.CustomerList = CustomerList:New(CustomerListContainer) will work just fine without it, because CustomerList is already defined as ZO_SortFilterList:Subclass(), so it will call the correct New and YOUR Initialize (that's why you need to call ZO_SortFilterList.Initialize from there) |
09/04/15, 09:17 PM | #6 |
|
Example: (I combined your New & Initialize functions)
Lua Code:
Last edited by circonian : 09/04/15 at 09:21 PM. |
09/04/15, 10:09 PM | #7 | |
|
|
|
09/04/15, 10:10 PM | #8 | |
|
|
|
09/05/15, 06:03 AM | #9 |
|
Should've posted more concrete code -- but it was way too late, sorry -- to show why overriding New isn't needed at all thanks to how it's written (it passes all arguments to Initialize).
Lua Code:
This way CustomerListContainer is not hard-coded in the class, thus you could create multiple instances (on different container controls). Not really useful in your case, I know, but still cleaner IMO. Another little suggestion that's good getting used to. In BuildMasterList(), don't create a new table, discarding the old one -- unless you have a million items in there and really want to free the memory and only insert a thousand -- just clear the existing table with Lua Code:
|
09/05/15, 07:39 AM | #10 | |
|
Code:
function CustomerList:New() local customers = ZO_SortFilterList.New(self, CustomerListContainer) customers.masterList = {} ZO_ScrollList_AddDataType(customers.list, 1, "CustomerUnitRow", 30, function(control, data) customers:SetupUnitRow(control, data) end) ZO_ScrollList_EnableHighlight(customers.list, "ZO_ThinListHighlight") customers.sortFunction = function(listEntry1, listEntry2) return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, customers.currentSortKey, CustomerList.SORT_KEYS, customers.currentSortOrder) end customers.sortHeaderGroup:SelectHeaderByKey("name") customers:RefreshData() return customers end function CustomerList:BuildMasterList() self.masterList = {} local transactions = TRADESMAN.savedVariables.Transactions table.insert(self.masterList, transactions) end end Last edited by Argusus : 09/05/15 at 08:23 AM. |
|
09/05/15, 08:34 AM | #11 | |
|
Lua Code:
My/TheirTradeItemsList look like they could be merged. Just pass the things that differ as additional arguments to initialize, and store them in the instance. Lua Code:
|
|
09/05/15, 10:06 AM | #12 | |
|
|
|
09/05/15, 01:32 PM | #13 |
|
One thing I want to point out to hopefully eliminate any confusion I may have caused (maybe I should have just stayed out of it & let him answer :P)
I know merlight kept saying don't overwrite CustomerList:New() ...but, yet that's exactly what I did. It looks like we both did the same thing, but with a different approach. Since: Lua Code:
I overwrote the CustomerList:New() (from ZO_SortFilterList:Subclass()) function, but then called it in MY New() function. I call the :New() function I created, which calls the original :New() function, which then calls the original Initialize() function so both the original :New() & :Initialize() both still run. Lua Code:
Merlight left the original CustomerList:New() function (from ZO_SortFilterList:Subclass()) and overwrote the CutomerList:Initialize() function, but then he manually called it in his Initialize() He calls the Original :New() function, which automatically calls the :Initialize() function that he wrote and it calls the original :Initialize() function. So again both the original :New() & :Initialize() functions get ran. Lua Code:
He is right about the hard coding of CustomerListContainer in the code. I didn't think about it, but the same could have been accomplished this way by just passing it to the new function Lua Code:
Last edited by circonian : 09/05/15 at 01:52 PM. |
ESOUI » Developer Discussions » Lua/XML Help » ZO_Templates ScrollTemplates |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|