View Single Post
11/23/14, 07:33 PM   #5
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
I don't have much time & I am leaving for thanksgiving soon and will be gone for a week. I didn't find anything else wrong, but if all else fails...this may or may not be a better way to do it, just giving options.
I know this is not what your asking, but you could just filter the items yourself, eliminating libFitlers. I haven't used itemSaver or Advanced Filters so this may or may not cover everything you need to do in your addons.

Creating filters is not very hard, it can be done with 1 function & 1 line of code to change the filter. This is how the game does its filtering, I did it in an addon. The only problem I see is that since Advanced Filters is using libFilter & you would not be, Advanced filters might not filter your stuff correctly...but that could easily be solved. I wrote my own filter library (um never released it though wasn't really designed to track stuff for other addons also, maybe I will change that and release it when I get back next week).

Anyhow if your interested or for anyone else reading this creating filters is pretty easy. All you have to do is create a tabFilter & put it into the inventories tabFilter table, then call that inventories ChangeFilter(tabData) passing in your tabFitler....thats it.
Note: this has some extra code you would not need since you do not need a physical button...but advanced filters would so although some of this code (namely all of the parameters) are not used, I left some of the code from my addon in there to give everyone ideas on what you could do with it.

Warning: Spoiler


The default, built in, filterTypes that you can call are:
Lua Code:
  1. ITEMFILTERTYPE_ALL
  2. ITEMFILTERTYPE_WEAPONS
  3. ITEMFILTERTYPE_ARMOR
  4. ITEMFILTERTYPE_CONSUMABLE
  5. ITEMFILTERTYPE_CRAFTING
  6. ITEMFILTERTYPE_MISCELLANEOUS
  7. ITEMFILTERTYPE_JUNK

If you want to create your own filters to only display certain items all you have to do now is add a UNIQUE filter number to the items filterData table (found in /zgoo the item, goto dataEntry, data, filterData).
So say you create your own filterType:
Lua Code:
  1. local ITEMFILTERTYPE_FCOLOCKED = 137  -- whatever unique number
Then just place that number in the locked items filterData table, create a filterTab out of it, put the filterTab into the inventories tabFilters table, then when your ready call this (passing in your tabData filter)
Lua Code:
  1. PLAYER_INVENTORY:ChangeFilter(tabData)

You could create your own buttons to change the filters, add buttons to the inventory menu bar to do it, or hook the inventory menu bar buttons to change what they actualy show, whatever...

You would just have to handle the slotUpdate to handle when items are moved, sold, destroyed, looted, exc..to update its filterData values.
Oh and on initializing loop putting the filterData values into the tables too so they are there when the player logs in or /reloadui.

P.S. do be aware that bank inventory slots are not populated until the user opens the bank so you could not insert filterData until its populated..although you can do this to fix that problem:
Lua Code:
  1. PLAYER_INVENTORY:RefreshAllInventorySlots(iInventory)
Will refresh the slots, use it on the bank for example then the items (slots) will become available even before the user opens the bank.

So when you originally populate the slots on load you could do something like this:
Lua Code:
  1. local tSlots = PLAYER_INVENTORY.inventories[iInventory].slots
  2.     if not tSlot then
  3.         PLAYER_INVENTORY:RefreshAllInventorySlots(iInventory)
  4.         tSlots   = PLAYER_INVENTORY.inventories[iInventory].slots
  5.     end
  Reply With Quote