diff --git a/ItemSort.lua b/ItemSort.lua
deleted file mode 100644
index 0201fb5..0000000
--- a/ItemSort.lua
+++ /dev/null
@@ -1,91 +0,0 @@
-ItemSort = {}
-
-local LibSort = LibStub("LibSort-1.0", 1)
-
-local watchedSlots = {[SLOT_TYPE_GUILD_BANK_ITEM] = true, [SLOT_TYPE_ITEM] = true, [SLOT_TYPE_BANK_ITEM] = true }
-
-local IS_WEAPON = { [EQUIP_TYPE_MAIN_HAND] = true, [EQUIP_TYPE_OFF_HAND] = true, [EQUIP_TYPE_ONE_HAND] = true, [EQUIP_TYPE_TWO_HAND] = true}
-
-local WEAPON_ORDER = {
- [WEAPONTYPE_AXE] = 1,
- [WEAPONTYPE_DAGGER] = 2,
- [WEAPONTYPE_HAMMER] = 3,
- [WEAPONTYPE_SWORD] = 4,
-
- [WEAPONTYPE_TWO_HANDED_AXE] = 5,
- [WEAPONTYPE_TWO_HANDED_HAMMER] = 6,
- [WEAPONTYPE_TWO_HANDED_SWORD] = 7,
-
- [WEAPONTYPE_BOW] = 8,
-
- [WEAPONTYPE_FIRE_STAFF] = 9,
- [WEAPONTYPE_FROST_STAFF] = 10,
- [WEAPONTYPE_LIGHTNING_STAFF] = 11,
- [WEAPONTYPE_HEALING_STAFF] = 12,
-
- [WEAPONTYPE_NONE] = 13,
- [WEAPONTYPE_RUNE] = 14,
- [WEAPONTYPE_SHIELD] = 15
-}
-
-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,
-}
-
-function ItemSort:Loaded(...)
- local eventCode, addonName = ...
- if addonName ~= "ItemSort" then return end
-
-
- LibSort:RegisterDefaultOrder("Item Sort", {"Weapon Type", "Armour Equip Type", "Armour Type", "Subjective Level"})
-
- LibSort:Register("Item Sort", "Subjective Level", "The calculated subjective level", "subjectiveLevel", function(slotType, bag, index) return GetItemLevel(bag, index) end)
- LibSort:Register("Item Sort", "Weapon Type", "The type of weapon", "weaponType", function(...) return ItemSort:WeaponType(...) end)
- LibSort:Register("Item Sort", "Armour Type", "The weight of armour", "armorType", function(...) return ItemSort:ArmorType(...) end)
- LibSort:Register("Item Sort", "Armour Equip Type", "The type of armour", "armorEquipType", function(...) return ItemSort:ArmourEquipType(...) end)
-end
-
-function ItemSort: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
-end
-
-function ItemSort: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
-end
-
-function ItemSort:ArmourEquipType(slotType, bag, index)
- if watchedSlots[slotType] then
- local _, _, _, _, _, equipType = GetItemInfo(bag, index)
- return ARMOUR_ORDER[equipType]
- end
-end
-
-
-
-EVENT_MANAGER:RegisterForEvent("ItemSortLoaded", EVENT_ADD_ON_LOADED, function(...) ItemSort:Loaded(...) end)
\ No newline at end of file
diff --git a/ItemSort.txt b/ItemSort.txt
deleted file mode 100644
index 92c90d7..0000000
--- a/ItemSort.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-## Title: ItemSort
-## Author: Wobin
-## Version: @project-version@
-## APIVersion: 100004
-
-Libs/LibStub/LibStub-1.0.lua
-Libs/LibSort/LibSort-1.0.lua
-
-ItemSort.lua
diff --git a/Libs/LibSort/LibSort-1.0.lua b/Libs/LibSort/LibSort-1.0.lua
index 76fd3de..8fdf028 100644
--- a/Libs/LibSort/LibSort-1.0.lua
+++ b/Libs/LibSort/LibSort-1.0.lua
@@ -27,7 +27,8 @@ end
--- Storage variables ---
LibSort.RegisteredCallbacks = {}
LibSort.AddonOrder = {}
-LibSort.DefaultOrders = {}
+LibSort.DefaultOrdersLow = {}
+LibSort.DefaultOrdersHigh = {}
--- Arrow generation ---
@@ -86,27 +87,33 @@ function LibSort:InjectKeys()
self.sortKeys[data.key][data.dataType] = true
end
end
- end
+ end
self:ReOrderKeys()
end
function LibSort:ReOrderKeys()
local first
local previous
- for i, addonName in ipairs(self.AddonOrder) do
- if self.DefaultOrders[addonName] then
- for _, name in ipairs(self.DefaultOrders[addonName]) do
+ for i, addonName in ipairs(self.AddonOrder) do
+ if self.DefaultOrdersLow[addonName] then
+ for _, name in ipairs(self.DefaultOrdersLow[addonName]) do
local data = self.RegisteredCallbacks[addonName][name]
if data then -- we skip the ones we haven't registered yet
first, previous = self:SetKeyOrder(first, previous, data)
end
end
- else
- for name, data in pairs(self.RegisteredCallbacks[addonName]) do
- first, previous = self:SetKeyOrder(first, previous, data)
- end
end
end
+ for i, addonName in ipairs(self.AddonOrder) do
+ if self.DefaultOrdersHigh[addonName] then
+ for _, name in ipairs(self.DefaultOrdersHigh[addonName]) do
+ local data = self.RegisteredCallbacks[addonName][name]
+ if data then -- we skip the ones we haven't registered yet
+ first, previous = self:SetKeyOrder(first, previous, data)
+ end
+ end
+ end
+ end
self.sortKeys[previous].tiebreaker = "name"
PLAYER_INVENTORY:ChangeSort("age", INVENTORY_BACKPACK, true)
PLAYER_INVENTORY:ChangeSort("age", INVENTORY_BANK, true)
@@ -122,9 +129,8 @@ function LibSort:SetKeyOrder(first, previous, data)
if previous then
self.sortKeys[previous].tiebreaker = data.key
end
- end
- previous = data.key
- return first, previous
+ end
+ return first, data.key
end
function LibSort:ProcessInventory(inventoryType)
@@ -166,6 +172,8 @@ function LibSort:Register(addonName, name, desc, key, func, dataType)
if not dataType then dataType = "isNumeric" end
if not self.RegisteredCallbacks[addonName] then self.RegisteredCallbacks[addonName] = {} table.insert(self.AddonOrder, addonName) end
self.RegisteredCallbacks[addonName][name] = {key = makePrefix(addonName)..key, func = func, desc = desc, dataType = dataType}
+ if not self.DefaultOrdersHigh[addonName] then self.DefaultOrdersHigh[addonName] = {} end
+ table.insert(self.DefaultOrdersHigh[addonName], name)
self:InjectKeys()
end
@@ -181,8 +189,10 @@ function LibSort:RegisterString(addonName, name, desc, key, func)
self:Register(addonName, name, desc, key, func, "isString")
end
-function LibSort:RegisterDefaultOrder(addonName, keyTable)
- self.DefaultOrders[addonName] = keyTable
+function LibSort:RegisterDefaultOrder(addonName, keyTableLow, keyTableHigh)
+ self.DefaultOrdersHigh[addonName] = keyTableHigh
+ self.DefaultOrdersLow[addonName] = keyTableLow
+ self:ReOrderKeys()
end
function LibSort:SetDebugging(flag)
diff --git a/Libs/LibSort/README.md b/Libs/LibSort/README.md
index c20f590..06d8d3d 100644
--- a/Libs/LibSort/README.md
+++ b/Libs/LibSort/README.md
@@ -104,14 +104,17 @@ This will unregister a sortKey registration
+ Example: "ISWeaponSort"
###RegisterDefaultOrder
-Your addon may have multiple registrations, and this function will allow you to indicate what order you want them in as a block
+Your addon may have multiple registrations, and this function will allow you to indicate what order you want them in as a block. There are two tables you can pass in, for low level and high level keys. Low level keys are values that are unique to certain types of items, like weaponType, and armourType. High level keys are those linked to values that are common across larger swathes of items, like item level, or name. If you separate your keys in the two tables, LibSort will first chain all the low level keys before all high level keys, so that multiple addons can apply sort orders without getting cut off. (It's highly recommended that you split keys if you use high level definitions)
- LibSort:RegisterDefaultOrder(addonName, keyTable)
+Default behaviour, by not using this API call will be order of registration at a high level to avoid breaking other registrations
+
+ LibSort:RegisterDefaultOrder(addonName, keyTableLow, keyTableHigh)
- *addonName* -The name of the registering addon
+ Example: "Item Sort"
-- *keyTable* - A table indicating the order of sortKeys for this addon
+- *keyTableLow* - A table indicating the order of low level sortKeys for this addon
+ Example: {"weaponType", "armorEquipType", "armorType", "subjectiveItemLevel"}
+- *keyTableHigh* - **Optional** A table indicating of the order of high level sortKeys for this addon
###SetDebugging
Set the debug flag for the library
diff --git a/MrPlow.lua b/MrPlow.lua
new file mode 100644
index 0000000..3934636
--- /dev/null
+++ b/MrPlow.lua
@@ -0,0 +1,133 @@
+MrPlow = {}
+
+local LibSort = LibStub("LibSort-1.0", 1)
+
+local watchedSlots = {[SLOT_TYPE_GUILD_BANK_ITEM] = true, [SLOT_TYPE_ITEM] = true, [SLOT_TYPE_BANK_ITEM] = true }
+
+local IS_WEAPON = { [EQUIP_TYPE_MAIN_HAND] = true, [EQUIP_TYPE_OFF_HAND] = true, [EQUIP_TYPE_ONE_HAND] = true, [EQUIP_TYPE_TWO_HAND] = true}
+
+local WEAPON_ORDER = {
+ [WEAPONTYPE_AXE] = 1,
+ [WEAPONTYPE_DAGGER] = 2,
+ [WEAPONTYPE_HAMMER] = 3,
+ [WEAPONTYPE_SWORD] = 4,
+
+ [WEAPONTYPE_TWO_HANDED_AXE] = 5,
+ [WEAPONTYPE_TWO_HANDED_HAMMER] = 6,
+ [WEAPONTYPE_TWO_HANDED_SWORD] = 7,
+
+ [WEAPONTYPE_BOW] = 8,
+
+ [WEAPONTYPE_FIRE_STAFF] = 9,
+ [WEAPONTYPE_FROST_STAFF] = 10,
+ [WEAPONTYPE_LIGHTNING_STAFF] = 11,
+ [WEAPONTYPE_HEALING_STAFF] = 12,
+
+ [WEAPONTYPE_NONE] = 13,
+ [WEAPONTYPE_RUNE] = 14,
+ [WEAPONTYPE_SHIELD] = 15
+}
+
+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,
+}
+local ITEM_TYPE_ORDER = {
+ [ITEMTYPE_FOOD] = 1,
+ [ITEMTYPE_DRINK] = 2,
+ [ITEMTYPE_RECIPE] = 3,
+ [ITEMTYPE_POTION] = 4,
+ [ITEMTYPE_POISON] = 5,
+ [ITEMTYPE_SCROLL] = 6,
+ [ITEMTYPE_CONTAINER] = 7,
+ [ITEMTYPE_AVA_REPAIR] = 8,
+ [ITEMTYPE_BLACKSMITHING_BOOSTER] = 9,
+ [ITEMTYPE_BLACKSMITHING_RAW_MATERIAL] = 10,
+ [ITEMTYPE_BLACKSMITHING_MATERIAL] = 11,
+ [ITEMTYPE_CLOTHIER_BOOSTER] = 12,
+ [ITEMTYPE_CLOTHIER_RAW_MATERIAL] = 13,
+ [ITEMTYPE_CLOTHIER_MATERIAL] = 14,
+ [ITEMTYPE_WOODWORKING_BOOSTER] = 15,
+ [ITEMTYPE_WOODWORKING_RAW_MATERIAL] = 16,
+ [ITEMTYPE_WOODWORKING_MATERIAL] = 17,
+ [ITEMTYPE_ALCHEMY_BASE] = 18,
+ [ITEMTYPE_REAGENT] = 19,
+ [ITEMTYPE_ENCHANTING_RUNE] = 20,
+ [ITEMTYPE_INGREDIENT] = 21,
+ [ITEMTYPE_STYLE_MATERIAL] = 22,
+ [ITEMTYPE_GLYPH_WEAPON] = 23,
+ [ITEMTYPE_GLYPH_ARMOR] = 24,
+ [ITEMTYPE_GLYPH_JEWELRY] = 25,
+ [ITEMTYPE_SOUL_GEM] = 26,
+ [ITEMTYPE_SIEGE] = 27,
+ [ITEMTYPE_LURE] = 28,
+ [ITEMTYPE_TRASH] = 29,
+ [ITEMTYPE_TROPHY] = 30,
+ [ITEMTYPE_ARMOR_TRAIT] = 31,
+ [ITEMTYPE_WEAPON_TRAIT] = 32,
+}
+
+function MrPlow:Loaded(...)
+ local eventCode, addonName = ...
+ if addonName ~= "MrPlow" then return end
+
+ LibSort:Register("Item Sort", "Item Type", "The type of item", "itemType", function(...) return MrPlow:ItemType(...) end)
+ LibSort:Register("Item Sort", "Weapon Type", "The type of weapon", "weaponType", function(...) return MrPlow:WeaponType(...) end)
+ LibSort:Register("Item Sort", "Armour Equip Type", "The type of armour", "armorEquipType", function(...) return MrPlow:ArmourEquipType(...) end)
+ LibSort:Register("Item Sort", "Armour Type", "The weight of armour", "armorType", function(...) return MrPlow:ArmorType(...) end)
+
+ LibSort:Register("Item Sort", "Subjective Level", "The calculated subjective level", "subjectiveLevel", function(slotType, bag, index) return GetItemLevel(bag, index) end)
+
+ LibSort:RegisterDefaultOrder("Item Sort", {"Item Type", "Weapon Type", "Armour Equip Type", "Armour Type"}, {"Subjective Level"})
+end
+
+function MrPlow:ItemType(slotType, bag, index)
+ if watchedSlots[slotType] then
+ return ITEM_TYPE_ORDER[GetItemType(bag, index)]
+ end
+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
+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
+end
+
+function MrPlow:ArmourEquipType(slotType, bag, index)
+ if watchedSlots[slotType] then
+ local _, _, _, _, _, equipType = GetItemInfo(bag, index)
+ return ARMOUR_ORDER[equipType]
+ end
+end
+
+
+
+EVENT_MANAGER:RegisterForEvent("MrPlowLoaded", EVENT_ADD_ON_LOADED, function(...) MrPlow:Loaded(...) end)
+
\ No newline at end of file
diff --git a/MrPlow.txt b/MrPlow.txt
new file mode 100644
index 0000000..8cf80c0
--- /dev/null
+++ b/MrPlow.txt
@@ -0,0 +1,9 @@
+## Title: MrPlow
+## Author: Wobin
+## Version: @project-version@
+## APIVersion: 100004
+
+Libs/LibStub/LibStub-1.0.lua
+Libs/LibSort/LibSort-1.0.lua
+
+MrPlow.lua