diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua index 274818b..ed34168 100644 --- a/CauldronMainUI.lua +++ b/CauldronMainUI.lua @@ -1283,7 +1283,7 @@ function Cauldron:FilterDropDown_Initialize(level) }; UIDropDownMenu_AddButton(miscTitle); - -- favorites + -- compact local compact = { text = L["Compact"], checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].options.compactView, @@ -1307,6 +1307,18 @@ function Cauldron:FilterDropDown_Initialize(level) }; UIDropDownMenu_AddButton(faves); + -- achievements + local achievements = { + text = L["Achievements"], + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.achievements, + tooltipTitle = L["Achievements"], + tooltipText = L["Display only skills for achievements"], + func = function(arg1, arg2) Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.achievements = not Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.achievements; Cauldron:UpdateSkillList(); end, + arg1 = "achievement", + arg2 = "", + }; + UIDropDownMenu_AddButton(achievements); + -- spacer UIDropDownMenu_AddButton({ text = "", @@ -1380,6 +1392,19 @@ function Cauldron:FilterDropDown_Initialize(level) UIDropDownMenu_AddButton(sortReqLevel); --[[ + local sortFaves = { + text = L["By favorites"], + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortFavorites, + tooltipTitle = L["By favorites"], + tooltipText = L["Set the sorting method to use on the skills list"], + func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end, + arg1 = "favorite", + arg2 = "", + }; + UIDropDownMenu_AddButton(sortFaves); + --]] + + --[[ local sortBenefit = { text = L["By benefit"], checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortBenefit, @@ -1595,6 +1620,7 @@ function Cauldron:FilterDropDown_SetSort(info) 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.sortFavorites = 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; @@ -1602,6 +1628,7 @@ function Cauldron:FilterDropDown_SetSort(info) 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.sortFavorites = 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; @@ -1609,6 +1636,7 @@ function Cauldron:FilterDropDown_SetSort(info) 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.sortFavorites = 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; @@ -1616,6 +1644,7 @@ function Cauldron:FilterDropDown_SetSort(info) 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.sortFavorites = 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; @@ -1623,6 +1652,7 @@ function Cauldron:FilterDropDown_SetSort(info) 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.sortFavorites = false; 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; @@ -1630,7 +1660,16 @@ function Cauldron:FilterDropDown_SetSort(info) 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.sortFavorites = false; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortBenefit = true; + elseif sort == "favorite" 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.sortFavorites = true; + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortBenefit = false; end -- update the UI diff --git a/CauldronTradeskill.lua b/CauldronTradeskill.lua index a599b66..22d0bde 100644 --- a/CauldronTradeskill.lua +++ b/CauldronTradeskill.lua @@ -56,7 +56,11 @@ function Cauldron:UpdateSkills() sortDifficulty = false, sortAlpha = false, sortBenefit = false, + sortItemLevel = true, + sortRequiredLevel = false, + sortFavorites = false, favorites = false, + achievements = false, }, skills = {}, slots = {}, @@ -297,24 +301,40 @@ function Cauldron:GetSkillList(playername, skillName) if #search > 0 then -- check for numbers local minLevel, maxLevel; - local approxLevel = strmatch(search, "^~(%d+)"); +-- local matchItemLevel = false; + local approxLevel, matchItemLevel = strmatch(search, "^~(%d+)(i?)"); -- self:debug("GetSkillList: approxLevel="..tostring(approxLevel)); - if ( approxLevel ) then + if approxLevel then minLevel = approxLevel - 2; maxLevel = approxLevel + 2; else - minLevel, maxLevel = strmatch(search, "^(%d+)%s*-*%s*(%d*)$"); + minLevel, maxLevel, matchItemLevel = strmatch(search, "^(%d+)%s*-*%s*(%d*)(i?)$"); -- self:debug("GetSkillList: minLevel="..tostring(minLevel).."; maxLevel="..tostring(maxLevel)); end - if ( minLevel ) then - if ( maxLevel == "" or maxLevel < minLevel ) then + if minLevel then + if maxLevel == "" or maxLevel == "i" or maxLevel < minLevel then maxLevel = minLevel; end + -- cleanse the level values + minLevel = tonumber(minLevel) or 0; + maxLevel = tonumber(maxLevel) or 0; - -- TODO - -- self:debug("GetSkillList: TODO; filter by level"); --- SetTradeSkillItemNameFilter(nil); --- SetTradeSkillItemLevelFilter(minLevel, maxLevel); + local _,_,_,itemLevel,reqLevel,_,_,_,_,_ = GetItemInfo(recipe.itemLink); + if itemLevel and (matchItemLevel == "i") then + itemLevel = tonumber(itemLevel) or 0; + self:debug("GetSkillList: match by item level"); + if itemLevel < minLevel or itemLevel > maxLevel then + self:debug("skipping recipe: "..name.." (level: "..tostring(itemLevel)..")"); + add = false; + end + elseif reqLevel then + reqLevel = tonumber(reqLevel) or 0; + self:debug("GetSkillList: match by required level"); + if reqLevel < minLevel or reqLevel > maxLevel then + self:debug("skipping recipe: "..name.." (level: "..tostring(reqLevel)..")"); + add = false; + end + end else -- match name or reagents self:debug("GetSkillList: match by name or reagents"); @@ -379,9 +399,20 @@ function Cauldron:GetSkillList(playername, skillName) -- check favorites filter if self.db.realm.userdata[playername].skills[skillName].window.filter.favorites then if not self.db.realm.userdata[playername].skills[skillName].window.skills[recipe.name].favorite then ---@alpha@ + --@alpha@ self:debug("skipping recipe: "..name.." (favorite: "..tostring(self.db.realm.userdata[playername].skills[skillName].window.skills[recipe.name].favorite)..")"); ---@end-alpha@ + --@end-alpha@ + add = false; + end + end + + -- check achievements filter + if self.db.realm.userdata[playername].skills[skillName].window.filter.achievements then + local achievements = Cauldron:GetAchievementsForSkill(recipe); + if (not achievements) or (#achievements == 0) then + --@alpha@ + self:debug("skipping recipe: "..name.." (achievements: "..tostring(self.db.realm.userdata[playername].skills[skillName].window.skills[recipe.name].achievements)..")"); + --@end-alpha@ add = false; end end @@ -447,6 +478,15 @@ function Cauldron:GetSkillList(playername, skillName) local _,_,_,_,r2Level,_,_,_,_,_ = GetItemInfo(r2.itemLink); return (r2Level or 0) < (r1Level or 0); + elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortFavorites then + --@alpha@ + self:debug("GetSkillList: sorting by favorites"); + --@end-alpha@ + + local r1f = r1.favorite and 100 or 1; + local r2f = r2.favorite and 100 or 1; + + return r2f < r1f; elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortBenefit then --@alpha@ self:debug("GetSkillList: returning true for benefit sorting"); diff --git a/Locale/Cauldron-enUS.lua b/Locale/Cauldron-enUS.lua index 6765316..d5bbba7 100644 --- a/Locale/Cauldron-enUS.lua +++ b/Locale/Cauldron-enUS.lua @@ -66,6 +66,7 @@ L["By difficulty"] = true L["By benefit"] = true L["By item level"] = true L["By required level"] = true +L["By favorites"] = true L["Set the sorting method to use on the skills list"] = true L["Reset filters"] = true @@ -94,6 +95,8 @@ L["Normal"] = true L["Have all"] = true L["Have key"] = true L["Have any"] = true +L["Achievements"] = true +L["Display only skills for achievements"] = true L["Slots"] = true L["All slots"] = true