API 100008

CrazyDutchGuy [08-03-14 - 18:01]
API 100008
Filename
Libs/LibSort-1.0/LibSort-1.0.lua
Libs/LibStub/LibStub.lua
MrPlow.lua
MrPlow.txt
diff --git a/Libs/LibSort-1.0/LibSort-1.0.lua b/Libs/LibSort-1.0/LibSort-1.0.lua
index 11dbc92..496c3c1 100644
--- a/Libs/LibSort-1.0/LibSort-1.0.lua
+++ b/Libs/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/Libs/LibStub/LibStub.lua b/Libs/LibStub/LibStub.lua
index bfd96df..4dbff7b 100644
--- a/Libs/LibStub/LibStub.lua
+++ b/Libs/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/MrPlow.lua b/MrPlow.lua
index 2e37ac6..82d6c96 100644
--- a/MrPlow.lua
+++ b/MrPlow.lua
@@ -2,7 +2,7 @@ MrPlow = {}

 local LibSort, minor = LibStub:GetLibrary("LibSort-1.0")

-local watchedSlots = {[SLOT_TYPE_GUILD_BANK_ITEM] = true, [SLOT_TYPE_ITEM] = true, [SLOT_TYPE_BANK_ITEM] = true }
+local watchedSlots = {[INVENTORY_GUILD_BANK] = true, [INVENTORY_BACKPACK] = true, [INVENTORY_BANK] = true }

 local IS_WEAPON = { [EQUIP_TYPE_MAIN_HAND] = true, [EQUIP_TYPE_OFF_HAND] = true, [EQUIP_TYPE_ONE_HAND] = true, [EQUIP_TYPE_TWO_HAND] = true}

@@ -29,75 +29,76 @@ local WEAPON_ORDER = {
 }

 local ARMOUR_ORDER = {
-	[EQUIP_TYPE_HEAD] = 1,
-	[EQUIP_TYPE_NECK] = 2,
-	[EQUIP_TYPE_SHOULDERS] = 3,
-	[EQUIP_TYPE_CHEST] = 4,
-	[EQUIP_TYPE_HAND] = 5,
-	[EQUIP_TYPE_RING] = 6,
-	[EQUIP_TYPE_WAIST] = 7,
-	[EQUIP_TYPE_LEGS] = 8,
-	[EQUIP_TYPE_FEET] = 9,
-
-	[EQUIP_TYPE_MAIN_HAND] = 10,
-	[EQUIP_TYPE_OFF_HAND] = 11,
-	[EQUIP_TYPE_ONE_HAND] = 12,
-	[EQUIP_TYPE_TWO_HAND] = 13,
-	[EQUIP_TYPE_COSTUME] = 14,
+	[EQUIP_TYPE_HEAD] 	= 1,
+	[EQUIP_TYPE_SHOULDERS] 	= 2,
+	[EQUIP_TYPE_CHEST] 	= 3,
+	[EQUIP_TYPE_HAND] 	= 4,
+	[EQUIP_TYPE_WAIST] 	= 5,
+	[EQUIP_TYPE_LEGS] 	= 6,
+	[EQUIP_TYPE_FEET] 	= 7,
+
+	[EQUIP_TYPE_NECK] 	= 8,
+	[EQUIP_TYPE_RING] 	= 9,
+
+	[EQUIP_TYPE_MAIN_HAND] 	= 10,
+	[EQUIP_TYPE_OFF_HAND] 	= 11,
+	[EQUIP_TYPE_ONE_HAND] 	= 12,
+	[EQUIP_TYPE_TWO_HAND] 	= 13,
+	[EQUIP_TYPE_COSTUME] 	= 14,
 }

 local ITEM_TYPE_ORDER = {
-	[ITEMTYPE_WEAPON] = 					1,
-	[ITEMTYPE_ARMOR] = 						2,
-	[ITEMTYPE_FOOD] = 						3,
-	[ITEMTYPE_DRINK] = 						4,
-	[ITEMTYPE_RECIPE] =  					5,
-	[ITEMTYPE_POTION] =  					6,
-	[ITEMTYPE_POISON] =   					7,
-	[ITEMTYPE_CONTAINER] = 		  			8,
-	[ITEMTYPE_AVA_REPAIR] =   				9,
-	[ITEMTYPE_ARMOR_BOOSTER] =				10,
-	[ITEMTYPE_WEAPON_BOOSTER] = 			11,
-	[ITEMTYPE_BLACKSMITHING_BOOSTER] = 		12,
+	[ITEMTYPE_WEAPON] = 			1,
+	[ITEMTYPE_ARMOR] = 			2,
+	[ITEMTYPE_FOOD] = 			3,
+	[ITEMTYPE_DRINK] = 			4,
+	[ITEMTYPE_RECIPE] =  			5,
+	[ITEMTYPE_POTION] =  			6,
+	[ITEMTYPE_POISON] =   			7,
+	[ITEMTYPE_CONTAINER] = 			8,
+	[ITEMTYPE_AVA_REPAIR] =   		9,
+	[ITEMTYPE_ARMOR_BOOSTER] =		10,
+	[ITEMTYPE_WEAPON_BOOSTER] = 		11,
+	[ITEMTYPE_BLACKSMITHING_BOOSTER] = 	12,
 	[ITEMTYPE_BLACKSMITHING_RAW_MATERIAL] = 13,
 	[ITEMTYPE_BLACKSMITHING_MATERIAL] = 	14,
-	[ITEMTYPE_CLOTHIER_BOOSTER] = 			15,
-	[ITEMTYPE_CLOTHIER_RAW_MATERIAL] = 		16,
-	[ITEMTYPE_CLOTHIER_MATERIAL] = 			17,
-	[ITEMTYPE_WOODWORKING_BOOSTER] = 		18,
+	[ITEMTYPE_CLOTHIER_BOOSTER] = 		15,
+	[ITEMTYPE_CLOTHIER_RAW_MATERIAL] =	16,
+	[ITEMTYPE_CLOTHIER_MATERIAL] = 		17,
+	[ITEMTYPE_WOODWORKING_BOOSTER] =	18,
 	[ITEMTYPE_WOODWORKING_RAW_MATERIAL] = 	19,
-	[ITEMTYPE_WOODWORKING_MATERIAL] = 		20,
-	[ITEMTYPE_ALCHEMY_BASE] = 				21,
-	[ITEMTYPE_REAGENT] = 					22,
-	[ITEMTYPE_ENCHANTMENT_BOOSTER] =		23,
-	[ITEMTYPE_INGREDIENT] =   				24,
-	[ITEMTYPE_FLAVORING] =					25,
-	[ITEMTYPE_SPICE] =						26,
-	[ITEMTYPE_ADDITIVE] =					27,
-	[ITEMTYPE_RAW_MATERIAL] =				28,
-	[ITEMTYPE_SPELLCRAFTING_TABLET] = 		29,
-	[ITEMTYPE_STYLE_MATERIAL] =   			30,
-	[ITEMTYPE_GLYPH_WEAPON] =   			31,
-	[ITEMTYPE_GLYPH_ARMOR] =   				32,
-	[ITEMTYPE_GLYPH_JEWELRY] =   			33,
-	[ITEMTYPE_RACIAL_STYLE_MOTIF] =			34,
-	[ITEMTYPE_SOUL_GEM] =   				35,
-	[ITEMTYPE_SIEGE] =   					36,
-	[ITEMTYPE_MOUNT] =						37,
-	[ITEMTYPE_LURE] = 		  				38,
-	[ITEMTYPE_TRASH] = 	  					39,
-	[ITEMTYPE_COSTUME] =					40,
-	[ITEMTYPE_DISGUISE] =					41,
-	[ITEMTYPE_TABARD] =						42,
-	[ITEMTYPE_COLLECTIBLE] = 				43,
-	[ITEMTYPE_TROPHY] =   					44,
-	[ITEMTYPE_LOCKPICK] =					45,
-	[ITEMTYPE_TOOL] =						46,
-	[ITEMTYPE_ARMOR_TRAIT] =   				47,
-	[ITEMTYPE_WEAPON_TRAIT] =   			48,
-	[ITEMTYPE_PLUG] =						49,
-	[ITEMTYPE_NONE] =						50,
-	[ITEMTYPE_DEPRECATED] =					51,
+	[ITEMTYPE_WOODWORKING_MATERIAL] = 	20,
+	[ITEMTYPE_ALCHEMY_BASE] = 		21,
+	[ITEMTYPE_REAGENT] = 			22,
+	[ITEMTYPE_ENCHANTMENT_BOOSTER] =	23,
+	[ITEMTYPE_INGREDIENT] =   		24,
+	[ITEMTYPE_FLAVORING] =			25,
+	[ITEMTYPE_SPICE] =			26,
+	[ITEMTYPE_ADDITIVE] =			27,
+	[ITEMTYPE_RAW_MATERIAL] =		28,
+	[ITEMTYPE_SPELLCRAFTING_TABLET] = 	29,
+	[ITEMTYPE_STYLE_MATERIAL] =   		30,
+	[ITEMTYPE_GLYPH_WEAPON] =   		31,
+	[ITEMTYPE_GLYPH_ARMOR] =   		32,
+	[ITEMTYPE_GLYPH_JEWELRY] =   		33,
+	[ITEMTYPE_RACIAL_STYLE_MOTIF] =		34,
+	[ITEMTYPE_SOUL_GEM] =   		35,
+	[ITEMTYPE_SIEGE] =   			36,
+	[ITEMTYPE_MOUNT] =			37,
+	[ITEMTYPE_LURE] = 			38,
+	[ITEMTYPE_TRASH] = 	  		39,
+	[ITEMTYPE_COSTUME] =			40,
+	[ITEMTYPE_DISGUISE] =			41,
+	[ITEMTYPE_TABARD] =			42,
+	[ITEMTYPE_COLLECTIBLE] = 		43,
+	[ITEMTYPE_TROPHY] =   			44,
+	[ITEMTYPE_LOCKPICK] =			45,
+	[ITEMTYPE_TOOL] =			46,
+	[ITEMTYPE_ARMOR_TRAIT] =   		47,
+	[ITEMTYPE_WEAPON_TRAIT] =   		48,
+	[ITEMTYPE_PLUG] =			49,
+	[ITEMTYPE_NONE] =			50,
+	[ITEMTYPE_DEPRECATED] =			51,
 }

 local ENCHANTING_RUNE_ORDER = {
@@ -117,49 +118,34 @@ function MrPlow:Loaded(...)
    LibSort:Register("Item Sort", "Armour Type", "The weight of armour", "armorType", function(...) return MrPlow:ArmorType(...) end)
    LibSort:Register("Item Sort", "Crafting Type", "The crafting type of an item", "craftingType", function(...) return MrPlow:CraftingType(...) end)

-   LibSort:Register("Item Sort", "Subjective Level", "The calculated subjective level", "subjectiveLevel", function(slotType, bag, index) return GetItemLevel(bag, index) end)
+   LibSort:Register("Item Sort", "Subjective Level", "The calculated subjective level", "subjectiveLevel", function(bag, index) return GetItemLevel(bag, index) end)

    LibSort:RegisterDefaultOrder("Item Sort", {"Item Type", "Weapon Type", "Armour Equip Type", "Armour Type", "Crafting Type"}, {"Subjective Level"})
 end

-function MrPlow:ItemType(slotType, bag, index)
-   if watchedSlots[slotType] then
-      return ITEM_TYPE_ORDER[GetItemType(bag, index)] or 100
-   end
+function MrPlow:SubjectiveLevel(bag, index)
+	return GetItemLevel(bag, index)
+end
+
+function MrPlow:ItemType(bag, index)
+      	return ITEM_TYPE_ORDER[GetItemType(bag, index)] or 100
 end

-function MrPlow:WeaponType(slotType, bag, index)
-   if watchedSlots[slotType] then
-      local _, _, _, _, _, equipType = GetItemInfo(bag, index)
-      if equipType > 0 then
-         if IS_WEAPON[equipType] then
-            return WEAPON_ORDER[GetItemWeaponType(GetItemLink(bag, index))]
-         end
-      end
-   end
+function MrPlow:WeaponType(bag, index)
+        return WEAPON_ORDER[GetItemLinkWeaponType(GetItemLink(bag, index))]
 end

-function MrPlow:ArmorType(slotType, bag, index)
-   if watchedSlots[slotType] then
-      local _, _, _, _, _, equipType = GetItemInfo(bag, index)
-      if equipType <= 9 and equipType > 0  then
-         return GetItemArmorType(GetItemLink(bag, index))
-      end
-   end
+function MrPlow:ArmorType(bag, index)
+	return GetItemLinkArmorType(GetItemLink(bag, index))
 end

-function MrPlow:ArmourEquipType(slotType, bag, index)
-   if watchedSlots[slotType] then
-      local _, _, _, _, _, equipType = GetItemInfo(bag, index)
-      return ARMOUR_ORDER[equipType]
-   end
+function MrPlow:ArmourEquipType(bag, index)
+	return ARMOUR_ORDER[GetItemLinkEquipType(GetItemLink(bag, index))]
 end

-function MrPlow:CraftingType(slotType, bag, index)
-   if watchedSlots[slotType] then
-      local _, _, extra1 = GetItemCraftingInfo(bag, index)
-      return ENCHANTING_RUNE_ORDER[extra1 or 4]
-   end
+function MrPlow:CraftingType(bag, index)
+	local _, _, extra1 = GetItemCraftingInfo(bag, index)
+	return ENCHANTING_RUNE_ORDER[extra1 or 4]
 end

-EVENT_MANAGER:RegisterForEvent("MrPlowLoaded", EVENT_ADD_ON_LOADED, function(...) MrPlow:Loaded(...) end)
\ No newline at end of file
+EVENT_MANAGER:RegisterForEvent("MrPlowLoaded", EVENT_ADD_ON_LOADED, function(...) MrPlow:Loaded(...) end)
diff --git a/MrPlow.txt b/MrPlow.txt
index 2ad68d1..7d661cb 100644
--- a/MrPlow.txt
+++ b/MrPlow.txt
@@ -1,10 +1,10 @@
-## Title: |cFFFFB0MrPlow|r by |c00C000Wobin & CrazyDutchGuy|r
-## Author: Wobin & CrazyDutchGuy
-## Version: @project-version@
-## APIVersion: 100007
-## OptionalDependsOn: LibStub LibSort
-
-Libs/LibStub/LibStub.lua
-Libs/LibSort-1.0/LibSort-1.0.lua
-
-MrPlow.lua
+## Title: |cFFFFB0MrPlow|r by |c00C000Wobin & CrazyDutchGuy|r
+## Author: Wobin & CrazyDutchGuy
+## Version: @project-version@
+## APIVersion: 100008
+## OptionalDependsOn: LibStub LibSort
+
+Libs/LibStub/LibStub.lua
+Libs/LibSort-1.0/LibSort-1.0.lua
+
+MrPlow.lua