diff --git a/Cauldron/CauldronMain.lua b/Cauldron/CauldronMain.lua index 8a43287..d49cddd 100644 --- a/Cauldron/CauldronMain.lua +++ b/Cauldron/CauldronMain.lua @@ -227,14 +227,15 @@ function Cauldron:OnBagUpdate() end if self.makingItem then - self:debug("OnBagUpdate: self.makingItem="..self.makingItem); + self:info("OnBagUpdate: self.makingItem="..self.makingItem); local count = GetItemCount(self.makingItem); - self:debug("OnBagUpdate: count="..count); - self:debug("OnBagUpdate: self.itemCurrentCount="..self.itemCurrentCount); + self:info("OnBagUpdate: count="..count); + self:info("OnBagUpdate: self.itemCurrentCount="..self.itemCurrentCount); if count ~= self.itemCurrentCount then local delta = self.itemCurrentCount - count; -- TODO: is this necessary? - self:debug("OnBagUpdate: delta="..delta); - CauldronQueue:AdjustItemCount(Cauldron:GetQueue(), self.makingItem, -1); + self:info("OnBagUpdate: delta="..delta); + CauldronQueue:AdjustItemCount(Cauldron:GetQueue(), self.queueInfo.name, -1); + self.itemCurrentCount = count; end else -- @@ -412,7 +413,7 @@ function Cauldron:ProcessQueue() end self:debug("ProcessQueue: process item: "..queueInfo.name); - Cauldron:ProcessItem(skillInfo, queueInfo.amount); + Cauldron:ProcessItem(skillInfo, queueInfo, queueInfo.amount); else if not queueInfo then self:Print("Missing queue info!"); @@ -426,20 +427,21 @@ function Cauldron:ProcessQueue() end -function Cauldron:ProcessItem(skillInfo, amount) +function Cauldron:ProcessItem(skillInfo, queueInfo, amount) self:debug("ProcessItem enter"); if (not skillInfo) or (amount < 1) then - self:Print("Missing skill info!"); + self:warn("Cauldron:ProcessItem: Missing skill info!"); return; end if ((not PartialPlayTime()) and (not NoPlayTime())) then -- record the item we're making self.makingItem, _ = GetItemInfo(skillInfo.link); - self:debug("ProcessItem: self.makingItem="..self.makingItem); + self:info("ProcessItem: self.makingItem="..self.makingItem); self.itemCurrentCount = GetItemCount(skillInfo.link); - self:debug("ProcessItem: self.itemCurrentCount="..self.itemCurrentCount); + self:info("ProcessItem: self.itemCurrentCount="..self.itemCurrentCount); + self.queueInfo = queueInfo; -- tell the user what we're doing self:Print(string.format(L["Crafting %1$d of %2$s..."], amount, self.makingItem)); diff --git a/Cauldron/CauldronMain.xml b/Cauldron/CauldronMain.xml index 62f04f5..6f1e874 100644 --- a/Cauldron/CauldronMain.xml +++ b/Cauldron/CauldronMain.xml @@ -254,7 +254,7 @@ </Button> <Button name="CauldronQueueItemFrameTemplate" virtual="true" enableMouse="true"> - <Size x="300" y="40" /> + <Size x="300" y="39" /> <Layers> <Layer level="OVERLAY"> <!-- item name --> @@ -280,6 +280,11 @@ <!-- Color r="1.0" g="1.0" b="1.0" / --> </FontString> </Layer> + <Layer level="HIGHLIGHT" setAllPoints="true"> + <Texture file="Interface\QuestFrame\UI-QuestLogTitleHighlight" alphaMode="ADD"> + <Color r="0.8" g="0.8" b="0.8" a="0.5" /> + </Texture> + </Layer> </Layers> <Frames> <!-- icon --> diff --git a/Cauldron/CauldronMainUI.lua b/Cauldron/CauldronMainUI.lua index 69cda87..c979542 100644 --- a/Cauldron/CauldronMainUI.lua +++ b/Cauldron/CauldronMainUI.lua @@ -261,7 +261,6 @@ function Cauldron:UpdateSkillList() -- set the disclosure button texture frame = _G["CauldronSkillItem"..i.."DiscloseButton"]; frame.skillInfo = skillInfo; - frame.skillIndex = i; local reagentsExpanded = self.db.realm.userdata[self.vars.playername].skills[skillName].window.skills[skillInfo.name].expanded; self:debug("UpdateSkillList: reagentsExpanded="..tostring(reagentsExpanded)); if reagentsExpanded then @@ -452,10 +451,14 @@ function Cauldron:UpdateQueue() CauldronQueueFrameQueueEmpty:Hide(); CauldronQueueFrameScrollFrame:Show(); + local itemFrameHeight = 39; + local height = 0; CauldronQueueFrameScrollFrameQueueSectionsMainItemsHeaderText:SetText(L["In order to make:"]); - + -- adjust the scroll child size + CauldronQueueFrameScrollFrameQueueSectionsMainItems:SetHeight(#itemQueue * itemFrameHeight); + for i, queueInfo in ipairs(itemQueue) do local queueItemFrame = _G["CauldronQueueItem"..i]; @@ -529,23 +532,20 @@ function Cauldron:UpdateQueue() if i > 1 then -- anchor to the frame above self:debug("UpdateQueue: anchor frame to top left of frame above"); - queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueItem"..(i-1)], "BOTTOMLEFT", 0, -2); + queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueItem"..(i-1)], "BOTTOMLEFT", 0, 0); else -- anchor to the parent self:debug("UpdateQueue: anchor frame to parent"); queueItemFrame:SetPoint("TOPLEFT", CauldronQueueFrameScrollFrameQueueSectionsMainItems, "TOPLEFT", 0, 0); end - height = height + queueItemFrame:GetHeight() + 2; - self:debug("UpdateQueue: height="..height); +-- height = height + queueItemFrame:GetHeight() + 2; +-- self:debug("UpdateQueue: height="..height); -- show the frame self:debug("UpdateQueue: show the frame"); queueItemFrame:Show(); end - - -- adjust the scroll child size - CauldronQueueFrameScrollFrameQueueSectionsMainItems:SetHeight(height); -- hide any remaining frames local j = #itemQueue + 1; @@ -555,6 +555,8 @@ function Cauldron:UpdateQueue() break; end + _G["CauldronQueueItem"..j] = nil; + frame:Hide(); frame:SetHeight(0); @@ -577,6 +579,8 @@ function Cauldron:UpdateQueue() else CauldronQueueFrameScrollFrameQueueSectionsSecondaryItemsHeader:SetHeight(12); CauldronQueueFrameScrollFrameQueueSectionsSecondaryItemsHeaderText:SetText(L["You first have to make:"]); + + CauldronQueueFrameScrollFrameQueueSectionsSecondaryItems:SetHeight(#intQueue * itemFrameHeight); local intHeight = 0; @@ -663,7 +667,7 @@ function Cauldron:UpdateQueue() if i > 1 then -- anchor to the frame above self:debug("UpdateQueue: anchor frame to top left of frame above"); - queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueIntItem"..(i-1)], "BOTTOMLEFT", 0, -2); + queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueIntItem"..(i-1)], "BOTTOMLEFT", 0, 0); else -- anchor to the parent self:debug("UpdateQueue: anchor frame to parent"); @@ -671,9 +675,9 @@ function Cauldron:UpdateQueue() end -- adjust the scroll child size - intHeight = intHeight + queueItemFrame:GetHeight() + 2; - self:debug("UpdateQueue: height="..height); - CauldronQueueFrameScrollFrameQueueSectionsSecondaryItems:SetHeight(intHeight); +-- intHeight = intHeight + queueItemFrame:GetHeight() + 2; +-- self:debug("UpdateQueue: height="..height); +-- CauldronQueueFrameScrollFrameQueueSectionsSecondaryItems:SetHeight(intHeight); -- show the frame self:debug("UpdateQueue: show the frame"); @@ -689,6 +693,8 @@ function Cauldron:UpdateQueue() break; end + _G["CauldronQueueIntItem"..j] = nil; + frame:Hide(); frame:SetHeight(0); @@ -698,6 +704,7 @@ function Cauldron:UpdateQueue() -- display reagent list CauldronQueueFrameScrollFrameQueueSectionsReagentsHeaderText:SetText(L["You will need:"]); + CauldronQueueFrameScrollFrameQueueSectionsReagents:SetHeight(#reagentList * itemFrameHeight); local reagentHeight = 0; @@ -788,7 +795,7 @@ function Cauldron:UpdateQueue() if i > 1 then -- anchor to the frame above self:debug("UpdateQueue: anchor frame to top left of frame above"); - queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueReagentItem"..(i-1)], "BOTTOMLEFT", 0, -2); + queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueReagentItem"..(i-1)], "BOTTOMLEFT", 0, 0); else -- anchor to the parent self:debug("UpdateQueue: anchor frame to parent"); @@ -796,9 +803,9 @@ function Cauldron:UpdateQueue() end -- adjust the scroll child size - reagentHeight = reagentHeight + queueItemFrame:GetHeight() + 2; - self:debug("UpdateQueue: height="..height); - CauldronQueueFrameScrollFrameQueueSectionsReagents:SetHeight(reagentHeight); +-- reagentHeight = reagentHeight + queueItemFrame:GetHeight() + 2; +-- self:debug("UpdateQueue: height="..height); +-- CauldronQueueFrameScrollFrameQueueSectionsReagents:SetHeight(reagentHeight); -- show the frame self:debug("UpdateQueue: show the frame"); @@ -813,6 +820,8 @@ function Cauldron:UpdateQueue() break; end + _G["CauldronQueueReagentItem"..j] = nil; + frame:Hide(); frame:SetHeight(0); @@ -911,6 +920,11 @@ function Cauldron:FilterDropDown_Initialize(level) if not Cauldron.db then return; end + + local skillName = CURRENT_TRADESKILL; + if IsTradeSkillLinked() then + skillName = "Linked-"..skillName; + end UIDropDownMenu_SetText(CauldronFiltersFilterDropDown, L["Filters"]); @@ -926,7 +940,7 @@ function Cauldron:FilterDropDown_Initialize(level) local sortAlpha = { text = L["Alphabetically"], - checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortAlpha, + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha, tooltipTitle = L["Alphabetically"], tooltipText = L["Set the sorting method to use on the skills list"], func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end, @@ -937,7 +951,7 @@ function Cauldron:FilterDropDown_Initialize(level) local sortDifficulty = { text = L["By difficulty"], - checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.sortDifficulty, + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDifficulty, tooltipTitle = L["By difficulty"], tooltipText = L["Set the sorting method to use on the skills list"], func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end, @@ -980,7 +994,7 @@ function Cauldron:FilterDropDown_Initialize(level) -- textR = 1.0, -- textG = 1.0, -- textB = 1.0, - checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.optimal, + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.optimal, -- keepShownOnClick = true, tooltipTitle = L["Optimal"], tooltipText = L["Set whether items of this difficulty level should be shown"], @@ -995,7 +1009,7 @@ function Cauldron:FilterDropDown_Initialize(level) -- textR = 1.0, -- textG = 1.0, -- textB = 1.0, - checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.medium, + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.medium, -- keepShownOnClick = true, tooltipTitle = L["Medium"], tooltipText = L["Set whether items of this difficulty level should be shown"], @@ -1010,7 +1024,7 @@ function Cauldron:FilterDropDown_Initialize(level) -- textR = 1.0, -- textG = 1.0, -- textB = 1.0, - checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.easy, + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.easy, -- keepShownOnClick = true, tooltipTitle = L["Easy"], tooltipText = L["Set whether items of this difficulty level should be shown"], @@ -1025,7 +1039,7 @@ function Cauldron:FilterDropDown_Initialize(level) -- textR = 1.0, -- textG = 1.0, -- textB = 1.0, - checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.trivial, + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.trivial, -- keepShownOnClick = true, tooltipTitle = L["Trivial"], tooltipText = L["Set whether items of this difficulty level should be shown"], @@ -1051,6 +1065,13 @@ function Cauldron:FilterDropDown_Initialize(level) }; UIDropDownMenu_AddButton(reagentsTitle); + -- force check "normal" if the list is linked + if IsTradeSkillLinked() then + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.haveAllReagents = false; + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.haveKeyReagents = false; + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.haveAnyReagents = false; + end + local normal = { text = L["Normal"], checked = Cauldron:ReagentsFilterNormalCheck(), @@ -1062,40 +1083,44 @@ function Cauldron:FilterDropDown_Initialize(level) }; UIDropDownMenu_AddButton(normal); - local haveAllReagents = { - text = L["Have all"], - checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.haveAllReagents, - tooltipTitle = L["Reagents"], - tooltipText = L["Set whether skills for which you have all the required reagents are shown in the list"], - func = function(arg1, arg2) Cauldron:FilterDropDown_SetReagentFilter(arg1) end, - arg1 = "all", - arg2 = "", - }; - UIDropDownMenu_AddButton(haveAllReagents); - - --[[ - local haveKeyReagents = { - text = L["Have key"], - checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.haveKeyReagents, - tooltipTitle = L["Reagents"], - tooltipText = L["Set whether skills for which you have all key reagents (non-vendor available) are shown in the list"], - func = function(arg1, arg2) Cauldron:FilterDropDown_SetReagentFilter(arg1) end, - arg1 = "key", - arg2 = "", - }; - UIDropDownMenu_AddButton(haveKeyReagents); - --]] - - local haveAnyReagents = { - text = L["Have any"], - checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.filter.haveAnyReagents, - tooltipTitle = L["Reagents"], - tooltipText = L["Set whether skills for which you have any reagents are shown in the list"], - func = function(arg1, arg2) Cauldron:FilterDropDown_SetReagentFilter(arg1) end, - arg1 = "any", - arg2 = "", - }; - UIDropDownMenu_AddButton(haveAnyReagents); + if not IsTradeSkillLinked() then + + local haveAllReagents = { + text = L["Have all"], + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.haveAllReagents, + tooltipTitle = L["Reagents"], + tooltipText = L["Set whether skills for which you have all the required reagents are shown in the list"], + func = function(arg1, arg2) Cauldron:FilterDropDown_SetReagentFilter(arg1) end, + arg1 = "all", + arg2 = "", + }; + UIDropDownMenu_AddButton(haveAllReagents); + + --[[ + local haveKeyReagents = { + text = L["Have key"], + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.haveKeyReagents, + tooltipTitle = L["Reagents"], + tooltipText = L["Set whether skills for which you have all key reagents (non-vendor available) are shown in the list"], + func = function(arg1, arg2) Cauldron:FilterDropDown_SetReagentFilter(arg1) end, + arg1 = "key", + arg2 = "", + }; + UIDropDownMenu_AddButton(haveKeyReagents); + --]] + + local haveAnyReagents = { + text = L["Have any"], + checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.haveAnyReagents, + tooltipTitle = L["Reagents"], + tooltipText = L["Set whether skills for which you have any reagents are shown in the list"], + func = function(arg1, arg2) Cauldron:FilterDropDown_SetReagentFilter(arg1) end, + arg1 = "any", + arg2 = "", + }; + UIDropDownMenu_AddButton(haveAnyReagents); + + end Cauldron:debug("FilterDropDown_Initialize exit"); end @@ -1448,7 +1473,7 @@ function Cauldron:CollapseItemButton_OnClick(button) local skillInfo = button.skillInfo; Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.skills[skillInfo.name].expanded = not Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.skills[skillInfo.name].expanded; - Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.selected = button.skillIndex; + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.selected = skillInfo.index; -- update the UI Cauldron:UpdateSkillList(); @@ -1490,7 +1515,7 @@ function Cauldron:SkillItem_OnClick(frame, button, down) self:debug("SkillItem_OnClick: skillName="..skillName); -- select this frame - Cauldron.db.realm.userdata[self.vars.playername].skills[skillName].window.selected = frame.skillIndex; + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.selected = frame.skillIndex; -- update the UI Cauldron:UpdateSkillList(); @@ -1502,6 +1527,18 @@ end function Cauldron:TradeSkillFilter_OnTextChanged(frame) self:debug("TradeSkillFilter_OnTextChanged enter"); + local skillName = CURRENT_TRADESKILL; + if IsTradeSkillLinked() then + skillName = "Linked-"..skillName; + end + + local text = frame:GetText(); + if text == SEARCH then + text = ""; + end + + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.search = text; + -- update the UI Cauldron:UpdateSkillList(); diff --git a/Cauldron/CauldronQueue.lua b/Cauldron/CauldronQueue.lua index bfa3295..d3d055a 100644 --- a/Cauldron/CauldronQueue.lua +++ b/Cauldron/CauldronQueue.lua @@ -8,7 +8,7 @@ CauldronQueue = {}; sections of the queue: queueItem = { - ["name"] = "<name of item>", + ["name"] = "<name of skill>", ["icon"] = "<icon path>", ["tradeskill"] = "<name of tradeskill>", ["index"] = <index of skill>, @@ -309,19 +309,32 @@ function CauldronQueue:AdjustItemCount(queue, name, delta) -- sanity checks if not queue then - -- TODO: display error + Cauldron:warn("CauldronQueue:AdjustItemCount: queue not found!"); return; end - local item = queue.main[itemName]; + local item = queue.main[name]; +--[[ + for qName, qInfo in pairs(queue.main) do + if name == qInfo.item then + item = qInfo; + break; + end + end +--]] + Cauldron:info("AdjustItemCount: item="..tostring(item)); if item then + Cauldron:info("AdjustItemCount: item.amount="..item.amount); item.amount = item.amount + delta; + Cauldron:info("AdjustItemCount: item.amount(delta)="..item.amount); if item.amount < 1 then + Cauldron:info("AdjustItemCount: remove item: "..itemName); queue.main[itemName] = nil; end end + Cauldron:info("AdjustItemCount: calculate required items"); CauldronQueue:CalculateAllRequiredItems(queue); end diff --git a/Cauldron/CauldronShoppingList.lua b/Cauldron/CauldronShoppingList.lua index 2ed6db8..50299c8 100644 --- a/Cauldron/CauldronShoppingList.lua +++ b/Cauldron/CauldronShoppingList.lua @@ -89,8 +89,8 @@ end function CauldronShopping:ContainsItems(list) if not list then - -- TODO: display error - return; + Cauldron:warn("CauldronShopping:ContainsItems: missing list!"); + return false; end for _, items in pairs(list) do @@ -107,8 +107,8 @@ end function CauldronShopping:HasItems(list, requestor) if not list then - -- TODO: display error - return; + Cauldron:warn("CauldronShopping:HasItems: missing list!"); + return false; end if list[requestor] then @@ -128,7 +128,7 @@ end function CauldronShopping:EmptyShoppingList(list, requestor) if not list then - -- TODO: display error + Cauldron:warn("CauldronShopping:EmptyShoppingList: missing list!"); return; end diff --git a/Cauldron/CauldronShoppingListUI.lua b/Cauldron/CauldronShoppingListUI.lua index 30ec14c..f30dea5 100644 --- a/Cauldron/CauldronShoppingListUI.lua +++ b/Cauldron/CauldronShoppingListUI.lua @@ -129,6 +129,8 @@ function Cauldron:UpdateShoppingList() _G["CauldronShoppingListItem"..itemIndex.."Item"]:SetText(str); _G["CauldronShoppingListItem"..itemIndex.."Item"]:SetWidth(width - 25); + + _G["CauldronShoppingListItem"..itemIndex]:SetWidth(width - 25); -- place the frame in the scroll view if frameAbove then diff --git a/Cauldron/CauldronTradeskill.lua b/Cauldron/CauldronTradeskill.lua index 462ff8b..6b99393 100644 --- a/Cauldron/CauldronTradeskill.lua +++ b/Cauldron/CauldronTradeskill.lua @@ -221,14 +221,14 @@ function Cauldron:GetSkillList(playername, skillName) if #search > 0 then -- check for numbers local minLevel, maxLevel; - local approxLevel = strmatch(text, "^~(%d+)"); - self:debug("GetSkillList: approxLevel="..tostring(approxLevel)); + local approxLevel = strmatch(search, "^~(%d+)"); + -- self:debug("GetSkillList: approxLevel="..tostring(approxLevel)); if ( approxLevel ) then minLevel = approxLevel - 2; maxLevel = approxLevel + 2; else - minLevel, maxLevel = strmatch(text, "^(%d+)%s*-*%s*(%d*)$"); - self:debug("GetSkillList: minLevel="..tostring(minLevel).."; maxLevel="..tostring(maxLevel)); + minLevel, maxLevel = strmatch(search, "^(%d+)%s*-*%s*(%d*)$"); + -- self:debug("GetSkillList: minLevel="..tostring(minLevel).."; maxLevel="..tostring(maxLevel)); end if ( minLevel ) then if ( maxLevel == "" or maxLevel < minLevel ) then @@ -236,13 +236,13 @@ function Cauldron:GetSkillList(playername, skillName) end -- TODO - self:debug("GetSkillList: TODO; filter by level"); + -- self:debug("GetSkillList: TODO; filter by level"); -- SetTradeSkillItemNameFilter(nil); -- SetTradeSkillItemLevelFilter(minLevel, maxLevel); else -- match name or reagents self:debug("GetSkillList: match by name or reagents"); - if not string.find(recipe.keywords, search) then + if not string.find(string.lower(recipe.keywords), string.lower(search)) then self:debug("skipping recipe: "..name.." (keywords: "..recipe.keywords..")"); add = false; end