Thread Tools Display Modes
07/17/14, 07:32 AM   #1
esothomas
 
esothomas's Avatar
Join Date: Jun 2014
Posts: 24
"sort by level"

are items in this game categorizable by level? i feel like we could use a sorting mechanism in various crafting (and vendoring) windows that would allow us to quickly figure out what's worth using/saving, and what can be sold or whatever.
  Reply With Quote
07/17/14, 07:39 AM   #2
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by esothomas View Post
are items in this game categorizable by level? i feel like we could use a sorting mechanism in various crafting (and vendoring) windows that would allow us to quickly figure out what's worth using/saving, and what can be sold or whatever.
Afaik it is impossible to apply sorting of any kind to teh inventroy views.
We can only apply filters.

It is a somewhat odd limitation, but afaik it is the one that is there.
  Reply With Quote
07/17/14, 09:55 AM   #3
esothomas
 
esothomas's Avatar
Join Date: Jun 2014
Posts: 24
so the only "hack" for this would be to manually detect level values, and setup a filter for that?

i don't get why ZOS didn't include this...
  Reply With Quote
07/17/14, 10:39 AM   #4
ingeniousclown
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 122
This add-on proves that the inventory IS sortable, and probably even does what you're looking for.
  Reply With Quote
07/17/14, 11:38 AM   #5
esothomas
 
esothomas's Avatar
Join Date: Jun 2014
Posts: 24
i don't quite see what MrPlow actually does, though?
  Reply With Quote
07/17/14, 11:54 AM   #6
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
From the description and images I think it sorts items in inventory in a more natural way. Like swords always before bows and staves, and such. I don't use it, but many times cursed why I have gloves made from various materials scattered all over my bag That's how it could be useful.

Anyway, when you asked the question, I took it as an excersise. The UI code is probably a mess, I was just picking pieces to make it work, but I managed to add a "Level" sorting header to the inventory, and with the way I've overridden sortFn, you can replace orderByItemLevel with custom comparison function.

Lua Code:
  1. local function orderByItemLevel(data1, data2)
  2.     local lv1 = GetItemLevel(data1.bagId, data1.slotIndex)
  3.     local lv2 = GetItemLevel(data2.bagId, data2.slotIndex)
  4.     return lv1 < lv2
  5. end
  6.  
  7. local function initializeCustomInventorySortFn(inventory)
  8.     inventory.sortFn = function(entry1, entry2)
  9.         local sortKey = inventory.currentSortKey
  10.         local sortOrder = inventory.currentSortOrder
  11.         local res
  12.         if type(sortKey) == "function" then
  13.             if inventory.currentSortOrder == ZO_SORT_ORDER_UP then
  14.                 res = sortKey(entry1.data, entry2.data)
  15.             else
  16.                 res = sortKey(entry2.data, entry1.data)
  17.             end
  18.         else
  19.             local sortKeys = ZO_Inventory_GetDefaultHeaderSortKeys()
  20.             res = ZO_TableOrderingFunction(entry1.data, entry2.data, sortKey, sortKeys, sortOrder)
  21.         end
  22.         return res
  23.     end
  24. end
  25.  
  26. -- call from EVENT_ADD_ON_LOADED
  27. local function experimentalSortInventoryByLevel()
  28.     local invSortBy = ZO_PlayerInventorySortBy
  29.     local nameHeader = invSortBy:GetNamedChild("Name")
  30.     local levelHeader = CreateControlFromVirtual("$(parent)Level", invSortBy, "ZO_SortHeader")
  31.     levelHeader:SetAnchor(RIGHT, nameHeader, RIGHT, -5, 0)
  32.     levelHeader:SetDimensions(80, 20)
  33.     ZO_SortHeader_Initialize(levelHeader, "Level", orderByItemLevel,
  34.                              ZO_SORT_ORDER_UP, TEXT_ALIGN_RIGHT, "ZoFontHeader")
  35.  
  36.     local inventory = PLAYER_INVENTORY.inventories[INVENTORY_BACKPACK]
  37.     initializeCustomInventorySortFn(inventory)
  38.     inventory.sortHeaders:AddHeader(levelHeader)
  39. end
  Reply With Quote

ESOUI » AddOns » AddOn Search/Requests » "sort by level"


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