From 055a92c6943b56cdc9e900d42a308a2618454f7a Mon Sep 17 00:00:00 2001 From: pschifferer Date: Thu, 19 Feb 2009 01:17:07 +0000 Subject: [PATCH] Added a label to the favorites checkbox in the skill list. Added a new sorting option: default (Blizzard skill index) sorting. Made the skill "learning" code smarter, so that it updates certain attributes of a skill when the appropriate event is fired instead of re-learning the entire skill (which should also resolve the issue of reagents being "forgotten.") --- Cauldron.toc | 2 +- CauldronMain.lua | 2 +- CauldronMain.xml | 2 +- CauldronMainUI.lua | 21 ++++- CauldronTradeskill.lua | 191 +++++++++++++++++++++++++++++----------------- Locale/Cauldron-enUS.lua | 2 + 6 files changed, 146 insertions(+), 74 deletions(-) diff --git a/Cauldron.toc b/Cauldron.toc index 56c2055..b2b89f0 100755 --- a/Cauldron.toc +++ b/Cauldron.toc @@ -1,6 +1,6 @@ ## Interface: 30000 ## Title: Cauldron |cff7fff7f -Ace3-|r -## Version: 0.9.9.@project-revision@ +## Version: 0.9.10.@project-revision@ ## Author: Caendra of Silver Hand ## Notes: An improved interface for your trade skills ## RequiredDeps: diff --git a/CauldronMain.lua b/CauldronMain.lua index 8fa5c2e..4845c99 100644 --- a/CauldronMain.lua +++ b/CauldronMain.lua @@ -4,7 +4,7 @@ Cauldron = LibStub("AceAddon-3.0"):NewAddon("Cauldron", "AceEvent-3.0", "AceTimer-3.0", "AceConsole-3.0", "AceHook-3.0", "LibLogger-1.0"); local L = LibStub("AceLocale-3.0"):GetLocale("Cauldron"); -Cauldron.version = "0.9.9.@project-revision@"; +Cauldron.version = "0.9.10.@project-revision@"; Cauldron.date = string.sub("$Date$", 8, 17); -- key binding names diff --git a/CauldronMain.xml b/CauldronMain.xml index a501f81..6fb5708 100644 --- a/CauldronMain.xml +++ b/CauldronMain.xml @@ -155,7 +155,7 @@ self:SetScale(0.625); - getglobal(self:GetName()):SetText(""); + getglobal(self:GetName()):SetText(Cauldron:LocaleString("Favorite?")); GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua index f5bafab..368d9c8 100644 --- a/CauldronMainUI.lua +++ b/CauldronMainUI.lua @@ -1114,6 +1114,17 @@ function Cauldron:FilterDropDown_Initialize(level) }; UIDropDownMenu_AddButton(sortingTitle); + local sortDefault = { + text = L["Default"], + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault, + tooltipTitle = L["Default"], + tooltipText = L["Set the sorting method to use on the skills list"], + func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end, + arg1 = "default", + arg2 = "", + }; + UIDropDownMenu_AddButton(sortDefault); + local sortAlpha = { text = L["Alphabetically"], checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha, @@ -1338,15 +1349,23 @@ function Cauldron:FilterDropDown_SetSort(info) local sort = info.arg1; - if sort == "alpha" then + if sort == "default" then + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortDefault = true; + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortAlpha = false; + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortDifficulty = false; + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortBenefit = false; + elseif sort == "alpha" then + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortDefault = false; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortAlpha = true; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortDifficulty = false; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortBenefit = false; elseif sort == "difficulty" then + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortDefault = false; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortAlpha = false; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortDifficulty = true; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortBenefit = false; elseif sort == "benefit" then + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortDefault = false; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortAlpha = false; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortDifficulty = false; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortBenefit = true; diff --git a/CauldronTradeskill.lua b/CauldronTradeskill.lua index 1ca1b64..7e283e3 100644 --- a/CauldronTradeskill.lua +++ b/CauldronTradeskill.lua @@ -23,7 +23,9 @@ function Cauldron:UpdateSkills() -- save the skill entry in a local var local skillDB = self.db.realm.userdata[self.vars.playername].skills[skillName]; - skillDB.recipes = {}; + if not skillDB.recipes then + skillDB.recipes = {}; + end -- initialize window information, if necessary if not skillDB.window then @@ -37,7 +39,8 @@ function Cauldron:UpdateSkills() haveAllReagents = false, haveKeyReagents = false, haveAnyReagents = false, - sortDifficulty = true, + sortDefault = true, + sortDifficulty = false, sortAlpha = false, sortBenefit = false, favorites = false, @@ -60,83 +63,99 @@ function Cauldron:UpdateSkills() -- self:debug("UpdateSkills: name="..name.."; difficulty="..difficulty.."; avail="..avail); if name and difficulty ~= "header" then - local itemLink = GetTradeSkillItemLink(i); - local recipeLink = GetTradeSkillRecipeLink(i); + local minMade, maxMade = GetTradeSkillNumMade(i); - local _, _, _, _, _, _, _, _, slot, _ = GetItemInfo(itemLink); - local keywords = name; - - -- fill in the db entry - skillDB.recipes[name] = { - ['index'] = i, - ['name'] = name, - ['itemLink'] = itemLink, - ['recipeLink'] = recipeLink, - ['icon'] = GetTradeSkillIcon(i), - ['tradeskill'] = baseSkillName, - ['difficulty'] = difficulty, - ['available'] = avail, - ['minMade'] = minMade, - ['maxMade'] = maxMade, + -- adjust min/max made for specialities + -- TODO + + -- check if we're updating or adding + if skillDB.recipes[name] then + -- update the recipe info + skillDB.recipes[name].index = i; + skillDB.recipes[name].difficulty = difficulty; + skillDB.recipes[name].available = avail; + skillDB.recipes[name].minMade = minMade; + skillDB.recipes[name].maxMade = maxMade; + else + -- add the recipe info and other miscellaneous info + local itemLink = GetTradeSkillItemLink(i); + local recipeLink = GetTradeSkillRecipeLink(i); + local _, _, _, _, _, _, _, _, slot, _ = GetItemInfo(itemLink); - -- filter information - ['slot'] = slot, - ['defaultCategory'] = category, - }; - - -- set the action verb for this skill - skillDB.recipes[name].verb = verb; - - -- make sure the skill window info is initialized - if not skillDB.window.skills[name] then - skillDB.window.skills[name] = { - ['expanded'] = false, - ['favorite'] = false, + local keywords = name; + + -- fill in the db entry + skillDB.recipes[name] = { + ['index'] = i, + ['name'] = name, + ['itemLink'] = itemLink, + ['recipeLink'] = recipeLink, + ['icon'] = GetTradeSkillIcon(i), + ['tradeskill'] = baseSkillName, + ['difficulty'] = difficulty, + ['available'] = avail, + ['minMade'] = minMade, + ['maxMade'] = maxMade, + + -- filter information + ['slot'] = slot, + ['defaultCategory'] = category, }; - end - -- make sure the category for the window is initialized - if category ~= "" then - if not skillDB.window.categories[category] then - skillDB.window.categories[category] = { - ['shown'] = true, - ['expanded'] = true, + -- set the action verb for this skill + skillDB.recipes[name].verb = verb; + + -- make sure the skill window info is initialized + if not skillDB.window.skills[name] then + skillDB.window.skills[name] = { + ['expanded'] = false, + ['favorite'] = false, }; end - end - - -- populate the slot list - if slot and (slot ~= "") then - if not skillDB.window.slots[slot] then - skillDB.window.slots[slot] = true; - end - end - - -- clear the reagent list - skillDB.recipes[name].reagents = {}; - ---[[ - for j=1,GetTradeSkillNumReagents(i) do - local rname, rtex, rcount, hasCount = GetTradeSkillReagentInfo(i,j); - self:debug("UpdateSkills: rname="..tostring(rname).."; rtex="..tostring(rtex).."; rcount="..tostring(rcount).."; hasCount="..tostring(hasCount)); - - if rname then - table.insert(skillDB.recipes[name].reagents, { - ['name'] = rname, - ['icon'] = rtex, - ['numRequired'] = rcount, - ['index'] = j, - ['skillIndex'] = i, - }); - keywords = keywords..","..rname; + -- make sure the category for the window is initialized + if category ~= "" then + if not skillDB.window.categories[category] then + skillDB.window.categories[category] = { + ['shown'] = true, + ['expanded'] = true, + }; + end + end + + -- populate the slot list + if slot and (slot ~= "") then + if not skillDB.window.slots[slot] then + skillDB.window.slots[slot] = true; + end end + + -- clear the reagent list + skillDB.recipes[name].reagents = {}; + + --[[ + for j=1,GetTradeSkillNumReagents(i) do + local rname, rtex, rcount, hasCount = GetTradeSkillReagentInfo(i,j); + self:debug("UpdateSkills: rname="..tostring(rname).."; rtex="..tostring(rtex).."; rcount="..tostring(rcount).."; hasCount="..tostring(hasCount)); + + if rname then + table.insert(skillDB.recipes[name].reagents, { + ['name'] = rname, + ['icon'] = rtex, + ['numRequired'] = rcount, + ['index'] = j, + ['skillIndex'] = i, + }); + + keywords = keywords..","..rname; + end + end + --]] + + -- fill in the db entry + skillDB.recipes[name].keywords = keywords; end ---]] - - -- fill in the db entry - skillDB.recipes[name].keywords = keywords; else -- save the header name if name then @@ -212,7 +231,9 @@ function Cauldron:GetSlots(player, skillName) end function Cauldron:GetSkillList(playername, skillName) +--@alpha@ self:debug("GetSkillList enter"); +--@end-alpha@ if (not playername) or (not skillName) then self:warn("GetSkillList: playername ("..tostring(playername)..") or skillName ("..tostring(skillName)..") not set!"); @@ -222,13 +243,17 @@ function Cauldron:GetSkillList(playername, skillName) local skills = {}; for name, recipe in pairs(self.db.realm.userdata[playername].skills[skillName].recipes) do +--@alpha@ self:debug("GetSkillList: name="..name); +--@end-alpha@ local add = true; -- check the search text local search = self.db.realm.userdata[playername].skills[skillName].window.search or ""; +--@alpha@ self:debug("GetSkillList: search="..search); +--@end-alpha@ if #search > 0 then -- check for numbers local minLevel, maxLevel; @@ -252,9 +277,13 @@ function Cauldron:GetSkillList(playername, skillName) -- SetTradeSkillItemLevelFilter(minLevel, maxLevel); else -- match name or reagents +--@alpha@ self:debug("GetSkillList: match by name or reagents"); +--@end-alpha@ if not string.find(string.lower(recipe.keywords), string.lower(search)) then +--@alpha@ self:debug("skipping recipe: "..name.." (keywords: "..recipe.keywords..")"); +--@end-alpha@ add = false; end end @@ -270,7 +299,9 @@ function Cauldron:GetSkillList(playername, skillName) -- check categories local catInfo = self.db.realm.userdata[playername].skills[skillName].window.categories[recipe.defaultCategory]; if catInfo and (not catInfo.shown) then +--@alpha@ self:debug("skipping recipe: "..name.." (category: "..recipe.defaultCategory..")"); +--@end-alpha@ add = false; end @@ -311,7 +342,9 @@ 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@ self:debug("skipping recipe: "..name.." (favorite: "..tostring(self.db.realm.userdata[playername].skills[skillName].window.skills[recipe.name].favorite)..")"); +--@end-alpha@ add = false; end end @@ -328,12 +361,23 @@ function Cauldron:GetSkillList(playername, skillName) return true; end +--@alpha@ self:debug("GetSkillList: sorting: r1.name="..r1.name.."; r2.name="..r2.name); - if self.db.realm.userdata[playername].skills[skillName].window.filter.sortAlpha then +--@end-alpha@ + if self.db.realm.userdata[playername].skills[skillName].window.filter.sortDefault then +--@alpha@ + self:debug("GetSkillList: sorting by default (skill index)"); +--@end-alpha@ + return r1.index < r2.index; + elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortAlpha then +--@alpha@ self:debug("GetSkillList: sorting by alpha"); +--@end-alpha@ return r1.name < r2.name; elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortDifficulty then +--@alpha@ self:debug("GetSkillList: sorting by difficulty"); +--@end-alpha@ local difficulty = { optimal = 4, medium = 3, @@ -341,18 +385,25 @@ function Cauldron:GetSkillList(playername, skillName) trivial = 1, }; +--@alpha@ self:debug("GetSkillList: r1.difficulty="..r1.difficulty); self:debug("GetSkillList: r2.difficulty="..r2.difficulty); +--@end-alpha@ return difficulty[r1.difficulty] > difficulty[r2.difficulty]; elseif self.db.realm.userdata[playername].skills[skillName].window.filter.sortBenefit then +--@alpha@ self:debug("GetSkillList: returning true for benefit sorting"); +--@end-alpha@ return true; -- TODO end +--@alpha@ self:debug("GetSkillList: returning default true"); +--@end-alpha@ return true; end); +--@alpha@ self:debug("GetSkillList exit"); return skills; diff --git a/Locale/Cauldron-enUS.lua b/Locale/Cauldron-enUS.lua index 816eb51..37e15cf 100644 --- a/Locale/Cauldron-enUS.lua +++ b/Locale/Cauldron-enUS.lua @@ -44,6 +44,7 @@ L["Reagent"] = true L["Search for reagents"] = true L["Sort"] = true +L["Default"] = true L["Alphabetically"] = true L["By difficulty"] = true L["By benefit"] = true @@ -60,6 +61,7 @@ L["Miscellaneous"] = true L["Favorites"] = true L["Display only favorite skills"] = true L["Mark this skill as a favorite"] = true +L["Favorite?"] = true L["Reagents"] = true L["Display the normal list of skills"] = true L["Set whether skills for which you have all the required reagents are shown in the list"] = true -- 1.7.9.5