diff --git a/LibSort-1.0/LibSort-1.0.lua b/LibSort-1.0/LibSort-1.0.lua index 11dbc92..496c3c1 100644 --- a/LibSort-1.0/LibSort-1.0.lua +++ b/LibSort-1.0/LibSort-1.0.lua @@ -1,5 +1,8 @@ -local MAJOR, MINOR = "LibSort-1.0", 5 -local LibSort, oldminor = LibStub:NewLibrary(MAJOR, MINOR) +local LibSort, oldminor = LibStub:NewLibrary("LibSort-1.0", 6) +d("LIBSORT"); +d(LibSort); +d(oldminor); + if not LibSort then return end --the same or newer version of this lib is already loaded into memory if not LibSort.RegisteredCallbacks then LibSort.RegisteredCallbacks = {} end @@ -39,17 +42,17 @@ function LibSort:SetupArrows() LibSort.ItemSortBank:SetDimensions(16, 32) LibSort.ItemSortBank:SetAnchor(RIGHT, ZO_PlayerBankSortByName, LEFT, -15) ZO_SortHeader_SetTooltip(LibSort.ItemSortBank, "Sort", BOTTOMRIGHT, 0, 32) - ZO_SortHeader_InitializeArrowHeader(LibSort.ItemSortBank, "age", ZO_SORT_ORDER_DOWN) + ZO_SortHeader_InitializeArrowHeader(LibSort.ItemSortBank, "age", ZO_SORT_ORDER_DOWN) - PLAYER_INVENTORY.inventories[INVENTORY_BANK].sortHeaders:AddHeader(ItemSortBank) + PLAYER_INVENTORY.inventories[INVENTORY_BANK].sortHeaders:AddHeader(ItemSortBank) - LibSort.ItemSortGuild = WINDOW_MANAGER:CreateControlFromVirtual("ItemSortGuild", ZO_GuildBankSortBy, "ZO_SortHeaderIcon") + LibSort.ItemSortGuild = WINDOW_MANAGER:CreateControlFromVirtual("ItemSortGuild", ZO_GuildBankSortBy, "ZO_SortHeaderIcon") LibSort.ItemSortGuild:SetDimensions(16, 32) LibSort.ItemSortGuild:SetAnchor(RIGHT, ZO_GuildBankSortByName, LEFT, -15) ZO_SortHeader_SetTooltip(LibSort.ItemSortGuild, "Sort", BOTTOMRIGHT, 0, 32) - ZO_SortHeader_InitializeArrowHeader(LibSort.ItemSortGuild, "age", ZO_SORT_ORDER_DOWN) - - PLAYER_INVENTORY.inventories[INVENTORY_GUILD_BANK].sortHeaders:AddHeader(ItemSortGuild) + ZO_SortHeader_InitializeArrowHeader(LibSort.ItemSortGuild, "age", ZO_SORT_ORDER_DOWN) + + PLAYER_INVENTORY.inventories[INVENTORY_GUILD_BANK].sortHeaders:AddHeader(ItemSortGuild) end --- Main functions --- @@ -111,11 +114,14 @@ function LibSort:ProcessInventory(inventoryType) local container = inventoryTypes[inventoryType] if not container then return end for i, slot in ipairs(container.data) do - local slotType, bag, index = slot.data.slotType, slot.data.bagId, slot.data.slotIndex + -- slotType no longer exists, slotType determenes BACKPACK=2,PLAYERBANK=9,GUOLDBANK=10 + -- replaced by bagID BACKPACK=1,PLAYERBANK=2,GUOLDBANK=3 + -- local slotType, bag, index = slot.data.slotType, slot.data.bagId, slot.data.slotIndex + local bag, index = slot.data.bagId, slot.data.slotIndex for addon, callbacks in pairs(self.RegisteredCallbacks) do for name, data in pairs(callbacks) do if not slot.data[data.key] then - slot.data[data.key] = data.func(slotType, bag, index) or defaultType[data.dataType] + slot.data[data.key] = data.func(bag, index) or defaultType[data.dataType] end end end diff --git a/LibSort.txt b/LibSort.txt index 2de83ef..7f48cb2 100644 --- a/LibSort.txt +++ b/LibSort.txt @@ -1,9 +1,9 @@ -## APIVersion: 100007 +## APIVersion: 100008 ## Title: LibSort -## Version: 1.0 r3 +## Version: 1.0 r6 ## Author: CrazyDutchGuy & Wobin ## Description: A library to aid in your sorting needs. LibStub\LibStub.lua -LibSort-1.0\LibSort-1.0.lua \ No newline at end of file +LibSort-1.0\LibSort-1.0.lua diff --git a/LibStub/LibStub.lua b/LibStub/LibStub.lua index bfd96df..4dbff7b 100644 --- a/LibStub/LibStub.lua +++ b/LibStub/LibStub.lua @@ -1,34 +1,34 @@ --- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info --- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke --- LibStub developed for World of Warcraft by above members of the WowAce community. --- Ported to Elder Scrolls Online by Seerah - -local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 1 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! -local LibStub = _G[LIBSTUB_MAJOR] - -local strformat = string.format -if not LibStub or LibStub.minor < LIBSTUB_MINOR then - LibStub = LibStub or {libs = {}, minors = {} } - _G[LIBSTUB_MAJOR] = LibStub - LibStub.minor = LIBSTUB_MINOR - - function LibStub:NewLibrary(major, minor) - assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") - minor = assert(tonumber(zo_strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") - - local oldminor = self.minors[major] - if oldminor and oldminor >= minor then return nil end - self.minors[major], self.libs[major] = minor, self.libs[major] or {} - return self.libs[major], oldminor - end - - function LibStub:GetLibrary(major, silent) - if not self.libs[major] and not silent then - error(("Cannot find a library instance of %q."):strformat(tostring(major)), 2) - end - return self.libs[major], self.minors[major] - end - - function LibStub:IterateLibraries() return pairs(self.libs) end - setmetatable(LibStub, { __call = LibStub.GetLibrary }) -end +-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info +-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke +-- LibStub developed for World of Warcraft by above members of the WowAce community. +-- Ported to Elder Scrolls Online by Seerah + +local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! +local LibStub = _G[LIBSTUB_MAJOR] + +local strformat = string.format +if not LibStub or LibStub.minor < LIBSTUB_MINOR then + LibStub = LibStub or {libs = {}, minors = {} } + _G[LIBSTUB_MAJOR] = LibStub + LibStub.minor = LIBSTUB_MINOR + + function LibStub:NewLibrary(major, minor) + assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") + minor = assert(tonumber(zo_strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") + + local oldminor = self.minors[major] + if oldminor and oldminor >= minor then return nil end + self.minors[major], self.libs[major] = minor, self.libs[major] or {} + return self.libs[major], oldminor + end + + function LibStub:GetLibrary(major, silent) + if not self.libs[major] and not silent then + error(strformat("Cannot find a library instance of %q.", tostring(major)), 2) + end + return self.libs[major], self.minors[major] + end + + function LibStub:IterateLibraries() return pairs(self.libs) end + setmetatable(LibStub, { __call = LibStub.GetLibrary }) +end diff --git a/README.md b/README.md index f1fb4ef..8b5e83e 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ This will register a numeric sortKey + Example: "Will sort by Weapon Type" - *key* - A unique key used to identify the datapoint + Example: "weaponType" -- *func* - The function to call to retrieve the sort value. Function signature **needs** to be (slotType, bag, index) +- *func* - The function to call to retrieve the sort value. Function signature **needs** to be (bag, index) + Example: ItemSort.WeaponSort ###RegisterNumeric @@ -130,4 +130,4 @@ Set the debug flag for the library. Not actually used atm, but for future stuff. LibSort:SetDebugging(flag) -- *flag* - a boolean indicating if you wish to have debug messages \ No newline at end of file +- *flag* - a boolean indicating if you wish to have debug messages