diff --git a/CauldronMain.lua b/CauldronMain.lua index b3b33d2..dd603bb 100644 --- a/CauldronMain.lua +++ b/CauldronMain.lua @@ -25,8 +25,8 @@ Cauldron.libs = {}; -- Cauldron.libs.PT = LibStub("LibPeriodicTable-3.1"); -- logging --- Cauldron:SetLogLevel(Cauldron.logLevels.INFO); -Cauldron:SetLogLevel(Cauldron.logLevels.DEBUG); +Cauldron:SetLogLevel(Cauldron.logLevels.INFO); +-- Cauldron:SetLogLevel(Cauldron.logLevels.DEBUG); CURRENT_TRADESKILL = ""; @@ -792,6 +792,7 @@ end function Cauldron:DisplayVersion() self:Print(L["Version "],Cauldron.version); + self:Print(L["Date: "],Cauldron.date); end ---------------------------------------------------------------- @@ -1003,20 +1004,24 @@ function Cauldron:Disable() end function Cauldron:Reset() - self:Print("Resetting data structures..."); + self:Print("Starting reset."); -- close the window + self:Print("Closing windows..."); Cauldron:Frame_Hide(); HideUIPanel(TradeSkillFrame); Cauldron:HideShoppingList(); -- reset some internal variables + self:Print("Resetting internal variables..."); self.vars.enabled = true; -- reset the shopping list + self:Print("Clearing shopping list..."); self.db.realm.shopping = CauldronShopping:NewList(); -- reset the skills for each character + self:Print("Purging data structures..."); for toon, info in pairs(self.db.realm.userdata) do self.db.realm.userdata[toon] = {}; self.db.realm.userdata[toon].skills = {}; diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua index f2e9707..6f66cf4 100644 --- a/CauldronMainUI.lua +++ b/CauldronMainUI.lua @@ -5,6 +5,8 @@ local L = LibStub("AceLocale-3.0"):GetLocale("Cauldron") -- CauldronUI = LibStub("AceAddon-3.0"):NewAddon("CauldronUI", "AceEvent-3.0", "AceConsole-3.0", "LibDebugLog-1.0") +local SLOT_NONE = "none"; + function Cauldron:Frame_Show() --@alpha@ self:debug("Frame_Show enter"); @@ -1622,15 +1624,7 @@ function Cauldron:FilterDropDown_ToggleDifficulty(info) end function Cauldron:InvSlotDropDown_Initialize(level) ---@alpha@ Cauldron:debug("InvSlotDropDown_Initialize enter"); ---@end-alpha@ - ---[[ - if CURRENT_TRADESKILL == "" or CURRENT_TRADESKILL == "UNKNOWN" then - return; - end ---]] local skillName = CURRENT_TRADESKILL; if IsTradeSkillLinked() then @@ -1641,75 +1635,41 @@ function Cauldron:InvSlotDropDown_Initialize(level) local all = UIDropDownMenu_CreateInfo(); all.text = ALL_INVENTORY_SLOTS; -- L["All slots"], --- checked = false, --- tooltipTitle = L["All slots"], all.func = function(arg1, arg2) Cauldron:InvSlotDropDown_SetSlot(arg1) end; all.arg1 = "all"; --- arg2 = "", --- }; UIDropDownMenu_AddButton(all); - local none = UIDropDownMenu_CreateInfo(); - none.text = L["(None)"]; - none.checked = true; --- tooltipTitle = L["(None)"], - none.func = function(arg1, arg2) Cauldron:InvSlotDropDown_SetSlot(arg1) end; - none.arg1 = "none"; --- arg2 = "", --- }; - UIDropDownMenu_AddButton(none); - local slots = Cauldron:GetSlots(Cauldron.vars.playername, skillName); + Cauldron:debug("InvSlotDropDown_Initialize: slots="..#slots); + + --[[ + if slots["none"] then + local none = UIDropDownMenu_CreateInfo(); + none.text = L["(None)"]; + none.checked = slots.none.checked; + none.func = function(arg1, arg2) Cauldron:InvSlotDropDown_SetSlot(arg1) end; + none.arg1 = "none"; + UIDropDownMenu_AddButton(none); + end + --]] for name, _ in pairs(slots) do - self:debug("InvSlotDropDown_Initialize: name="..tostring(name)); + Cauldron:debug("InvSlotDropDown_Initialize: name="..tostring(name)); if name ~= "" then local slot = UIDropDownMenu_CreateInfo(); - slot.text = _G[name]; - slot.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[name]; --- tooltipTitle = _G[name], + slot.text = _G[name] or L["(None)"]; + slot.checked = slots[name].checked; slot.func = function(arg1, arg2) Cauldron:InvSlotDropDown_SetSlot(arg1) end; slot.arg1 = name; --- arg2 = "", --- }; UIDropDownMenu_AddButton(slot); - --[[ - UIDropDownMenu_SetSelectedID(TradeSkillInvSlotDropDown, nil); - local allChecked = GetTradeSkillInvSlotFilter(0); - local info = UIDropDownMenu_CreateInfo(); - local filterCount = select("#", ...); - info.text = ALL_INVENTORY_SLOTS; - info.func = TradeSkillInvSlotDropDownButton_OnClick; - info.checked = allChecked; - UIDropDownMenu_AddButton(info); - local checked; - for i=1, filterCount, 1 do - if ( allChecked and filterCount > 1 ) then - checked = nil; - UIDropDownMenu_SetText(TradeSkillInvSlotDropDown, ALL_INVENTORY_SLOTS); - else - checked = GetTradeSkillInvSlotFilter(i); - if ( checked ) then - UIDropDownMenu_SetText(TradeSkillInvSlotDropDown, select(i, ...)); - end - end - info.text = select(i, ...); - info.func = TradeSkillInvSlotDropDownButton_OnClick; - info.checked = checked; - - UIDropDownMenu_AddButton(info); - end - --]] - end + end end ---@alpha@ Cauldron:debug("InvSlotDropDown_Initialize exit"); ---@end-alpha@ end function Cauldron:SlotsFilterAllCheck() - self:debug("SlotsFilterAllCheck enter"); + Cauldron:debug("SlotsFilterAllCheck enter"); local skillName = CURRENT_TRADESKILL; if IsTradeSkillLinked() then @@ -1719,10 +1679,10 @@ function Cauldron:SlotsFilterAllCheck() local checked = true; if Cauldron.db then - for name, _ in pairs(Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots) do - if Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[name] then + for name, slotInfo in pairs(Cauldron:GetSlots(Cauldron.vars.playername, skillName)) do + if slotInfo.checked then checked = false; - self:debug("breaking from slot check"); + Cauldron:debug("breaking from slot check"); break; end end @@ -1741,33 +1701,44 @@ function Cauldron:InvSlotDropDown_SetSlot(info) skillName = "Linked-"..skillName; end - self:debug("InvSlotDropDown_SetSlot: info.arg1="..info.arg1); + Cauldron:debug("InvSlotDropDown_SetSlot: info.arg1="..info.arg1); + + local slots = Cauldron:GetSlots(Cauldron.vars.playername, skillName); if info.arg1 == "all" then - self:debug("InvSlotDropDown_SetSlot: selecting all slots..."); - Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots["(none)"] = true; - for name, _ in pairs(Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots) do - self:debug("InvSlotDropDown_SetSlot: name="..name); - Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[name] = true; + Cauldron:debug("InvSlotDropDown_SetSlot: selecting all slots..."); +-- slots["(None)"] = true; + for name, slotInfo in pairs(slots) do + Cauldron:debug("InvSlotDropDown_SetSlot: name="..name); + slotInfo.checked = true; end + --[[ elseif info.arg1 == "none" then - self:debug("InvSlotDropDown_SetSlot: selecting special 'none' slot..."); - local slotName = "(None)"; - if not Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[slotName] then - Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[slotName] = true; + Cauldron:debug("InvSlotDropDown_SetSlot: selecting special 'none' slot..."); +-- local slotName = "(None)"; + if not slots[slotName] then + slots[slotName] = true; else - Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[slotName] = not Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[slotName]; + slots[slotName] = not slots[slotName]; end + --]] else self:debug("InvSlotDropDown_SetSlot: select a specific slot: "..info.arg1); + for name, slotInfo in pairs(slots) do + Cauldron:debug("InvSlotDropDown_SetSlot: name="..name); + slotInfo.checked = false; + end + slots[info.arg1].checked = true; -- if not Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[info.arg1] then -- Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[info.arg1] = true; -- else - Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[info.arg1] = not Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[info.arg1]; +-- Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[info.arg1] = not Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.slots[info.arg1]; -- end end + + Cauldron:UpdateSkillList(); - self:debug("InvSlotDropDown_SetSlot exit"); + Cauldron:debug("InvSlotDropDown_SetSlot exit"); end function Cauldron:CategoryDropDown_Initialize(level) diff --git a/CauldronTradeskill.lua b/CauldronTradeskill.lua index f2bfe7b..21a1710 100644 --- a/CauldronTradeskill.lua +++ b/CauldronTradeskill.lua @@ -132,12 +132,18 @@ function Cauldron:UpdateSkills() end -- populate the slot list + Cauldron:debug("slot: "..tostring(slot)); if slot and (slot ~= "") then -- if not skillDB.window.slots[slot] then - skillDB.window.slots[slot] = true; + skillDB.window.slots[slot] = { + checked = true, + }; -- end --- else --- skillDB.window.slots["None"] = true; + else + -- special slot representing items that don't have a slot + skillDB.window.slots.none = { + checked = true, + }; end -- populate the reagent list @@ -246,9 +252,7 @@ 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!"); @@ -258,17 +262,13 @@ 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; @@ -292,13 +292,9 @@ 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 or ""), string.lower(search)) then ---@alpha@ self:debug("skipping recipe: "..name.." (keywords: "..tostring(recipe.keywords)..")"); ---@end-alpha@ add = false; end end @@ -314,25 +310,21 @@ 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 -- check slot - --[[ local slotName = recipe.slot; - if slotName == "" then - slotName = "(none)"; + if (not slotName) or (slotName == "") then + slotName = "none"; end local slotInfo = self.db.realm.userdata[playername].skills[skillName].window.slots[slotName]; self:debug("slotInfo: "..tostring(slotInfo)); - if not slotInfo then -- more + if slotInfo and not(slotInfo.checked) then self:debug("skipping recipe: "..name.." (slot: "..slotName..")"); add = false; end - --]] -- check reagent filter if self.db.realm.userdata[playername].skills[skillName].window.filter.haveAllReagents then diff --git a/Locale/Cauldron-enUS.lua b/Locale/Cauldron-enUS.lua index 8c2a75e..ac5578c 100644 --- a/Locale/Cauldron-enUS.lua +++ b/Locale/Cauldron-enUS.lua @@ -8,6 +8,7 @@ if not L then return end L["Cauldron"] = true L["Cauldron loaded; version "] = true L["Version "] = true +L["Date: "] = true L["Current log level: "] = true L["Setting log level: "] = true L["Config"] = true