View Single Post
09/05/15, 01:32 PM   #13
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
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:
  1. CustomerList = ZO_SortFilterList:Subclass()
CustomerList already has a New() & an Initialize() function (from ZO_SortFilterList:Subclass()).

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:
  1. function CustomerList:New()
  2.    -- ZO_SortFilterList:New(...) is the function I'm overwriting
  3.    -- So I call it here
  4.    local manager = ZO_SortFilterList.New(self, CustomerListContainer)
  5. ...
  6. end

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:
  1. function CustomerList:Initialize(control)
  2.    -- ZO_SortFilterList:Initialize() is the function he is overwriting
  3.    -- So he calls it here
  4.    ZO_SortFilterList.Initialize(self, control)
  5. ...
  6. end

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:
  1. function CustomerList:New(control)
  2.     local manager = ZO_SortFilterList.New(self, control)
  3. ...
  4. end
  5. TRADESMAN.CustomerList = CustomerList:New(CustomerListContainer)

Last edited by circonian : 09/05/15 at 01:52 PM.
  Reply With Quote