Quantcast

Added item level and required level sorting to the filter dropdown.

pschifferer [10-25-09 - 14:58]
Added item level and required level sorting to the filter dropdown.
Filename
CauldronMainUI.lua
CauldronTradeskill.lua
Locale/Cauldron-enUS.lua
diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua
index a9300a5..1fb665f 100644
--- a/CauldronMainUI.lua
+++ b/CauldronMainUI.lua
@@ -1341,6 +1341,28 @@ function Cauldron:FilterDropDown_Initialize(level)
 	};
 	UIDropDownMenu_AddButton(sortDifficulty);

+	local sortItemLevel = {
+		text = L["By item level"],
+		checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortItemLevel,
+		tooltipTitle = L["By item level"],
+		tooltipText = L["Set the sorting method to use on the skills list"],
+		func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end,
+		arg1 = "itemlevel",
+		arg2 = "",
+	};
+	UIDropDownMenu_AddButton(sortItemLevel);
+
+	local sortReqLevel = {
+		text = L["By required level"],
+		checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortRequiredLevel,
+		tooltipTitle = L["By required level"],
+		tooltipText = L["Set the sorting method to use on the skills list"],
+		func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end,
+		arg1 = "reqlevel",
+		arg2 = "",
+	};
+	UIDropDownMenu_AddButton(sortReqLevel);
+
 	--[[
 	local sortBenefit = {
 		text = L["By benefit"],
@@ -1555,21 +1577,43 @@ function Cauldron:FilterDropDown_SetSort(info)
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault = true;
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha = false;
 	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDifficulty = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortItemLevel = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortRequiredLevel = false;
 	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortBenefit = false;
 	elseif sort == "alpha" then
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault = false;
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha = true;
 	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDifficulty = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortItemLevel = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortRequiredLevel = false;
 	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortBenefit = false;
 	elseif sort == "difficulty" then
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault = false;
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha = false;
 	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDifficulty = true;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortItemLevel = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortRequiredLevel = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortBenefit = false;
+	elseif sort == "itemlevel" then
+		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault = false;
+		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDifficulty = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortItemLevel = true;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortRequiredLevel = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortBenefit = false;
+	elseif sort == "reqlevel" then
+		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault = false;
+		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDifficulty = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortItemLevel = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortRequiredLevel = true;
 	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortBenefit = false;
 	elseif sort == "benefit" then
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault = false;
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha = false;
 	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDifficulty = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortItemLevel = false;
+	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortRequiredLevel = false;
 	   	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortBenefit = true;
 	end

diff --git a/CauldronTradeskill.lua b/CauldronTradeskill.lua
index 396acee..83b5ff1 100644
--- a/CauldronTradeskill.lua
+++ b/CauldronTradeskill.lua
@@ -392,23 +392,23 @@ function Cauldron:GetSkillList(playername, skillName)
 				return true;
 			end

---@alpha@
+			--@alpha@
 			self:debug("GetSkillList: sorting: r1.name="..r1.name.."; r2.name="..r2.name);
---@end-alpha@
+			--@end-alpha@
 			if self.db.realm.userdata[playername].skills[skillName].window.filter.sortDefault then
---@alpha@
+				--@alpha@
 				self:debug("GetSkillList: sorting by default (skill index)");
---@end-alpha@
+				--@end-alpha@
 				return r1.index < r2.index;
 			elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortAlpha then
---@alpha@
+				--@alpha@
 				self:debug("GetSkillList: sorting by alpha");
---@end-alpha@
+				--@end-alpha@
 				return r1.name < r2.name;
 			elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortDifficulty then
---@alpha@
+				--@alpha@
 				self:debug("GetSkillList: sorting by difficulty");
---@end-alpha@
+				--@end-alpha@
 				local difficulty = {
 					optimal = 4,
 					medium = 3,
@@ -416,25 +416,45 @@ function Cauldron:GetSkillList(playername, skillName)
 					trivial = 1,
 				};

---@alpha@
+				--@alpha@
 				self:debug("GetSkillList: r1.difficulty="..r1.difficulty);
 				self:debug("GetSkillList: r2.difficulty="..r2.difficulty);
---@end-alpha@
+				--@end-alpha@
 				return difficulty[r1.difficulty] > difficulty[r2.difficulty];
+			elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortItemLevel then
+				--@alpha@
+				self:debug("GetSkillList: sorting by item level");
+				--@end-alpha@
+
+				-- get item info from item link
+				local _,_,_,r1iLevel,_,_,_,_,_,_ = GetItemInfo(r1.itemLink);
+				local _,_,_,r2iLevel,_,_,_,_,_,_ = GetItemInfo(r2.itemLink);
+
+				return (r2iLevel or 0) < (r1iLevel or 0);
+			elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortRequiredLevel then
+				--@alpha@
+				self:debug("GetSkillList: sorting by required level");
+				--@end-alpha@
+
+				-- get item info from item link
+				local _,_,_,_,r1Level,_,_,_,_,_ = GetItemInfo(r1.itemLink);
+				local _,_,_,_,r2Level,_,_,_,_,_ = GetItemInfo(r2.itemLink);
+
+				return (r2Level or 0) < (r1Level or 0);
 			elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortBenefit then
---@alpha@
+				--@alpha@
 				self:debug("GetSkillList: returning true for benefit sorting");
---@end-alpha@
+				--@end-alpha@
 				return true; -- TODO
 			end

---@alpha@
+			--@alpha@
 			self:debug("GetSkillList: returning default true");
---@end-alpha@
+			--@end-alpha@
 			return true;
 		end);

---@alpha@
+	--@alpha@
 	self:debug("GetSkillList exit");

 	return skills;
diff --git a/Locale/Cauldron-enUS.lua b/Locale/Cauldron-enUS.lua
index 78866c0..eeebd8e 100644
--- a/Locale/Cauldron-enUS.lua
+++ b/Locale/Cauldron-enUS.lua
@@ -63,6 +63,8 @@ L["Default"] = true
 L["Alphabetically"] = true
 L["By difficulty"] = true
 L["By benefit"] = true
+L["By item level"] = true
+L["By required level"] = true
 L["Set the sorting method to use on the skills list"] = true

 L["Reset filters"] = true