View Single Post
09/05/15, 10:06 AM   #12
Argusus
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 120
Originally Posted by merlight View Post
Well, they have different row control template, default sort header, vastly different BuildMasterList, I think they deserve being separate classes. You can move a few things to a common base, like FilterScrollList and SortScrollList which are identical, and derive your special classes from that base.

Lua Code:
  1. local StuffListBase = ZO_SortFilterList:Subclass()
  2. local CustomerList = StuffListBase:Subclass()
  3. local XTradeItemsList = StuffListBase:Subclass()
  4. ...

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:
  1. function XTradeItemsList:Initialize(control, itemsKey)
  2.     StuffListBase.Initialize(self, control)
  3.     self.itemsKey = itemsKey
  4.     ...
  5. end
  6.  
  7. function XTradeItemsList:BuildMasterList()
  8.     ...
  9.     for key, itemObject in pairs(selectedTrade[self.itemsKey]) do
  10.         ...
  11.     end
  12. end
  13.  
  14. TRADESMAN.MyTradeItemsList = XTradeItemsList:New(MyTradeItemsContainer, "MyItems")
  15. TRADESMAN.TheirTradeItemsList = XTradeItemsList:New(TheirTradeItemsContainer, "TheirItems")
Cool, thank you! Let me look this over and get my head around it... I really appreciate this!
  Reply With Quote