From 81a68708267f3f9e4e4d548d4e7006e2d82031ca Mon Sep 17 00:00:00 2001 From: pschifferer Date: Fri, 6 Mar 2009 04:55:02 +0000 Subject: [PATCH] Made the expand/collapse all button work. Added a check for reagent in the tooltip callback. Made the program stop de-selecting the current selection when a tradeskill event fires. --- CauldronMain.lua | 15 +++++++++------ CauldronMainUI.lua | 29 ++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/CauldronMain.lua b/CauldronMain.lua index 186e10b..7183df0 100644 --- a/CauldronMain.lua +++ b/CauldronMain.lua @@ -276,8 +276,9 @@ function Cauldron:OnSkillUpdate() if not Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL] then return; end - - Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.selected = 0; + + -- TODO check if the skill rank has changed, and unselect + -- Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.selected = 0; Cauldron:UpdateSkills(); CauldronQueue:CalculateAllRequiredItems(Cauldron.db.realm.userdata[Cauldron.vars.playername].queue); @@ -796,10 +797,12 @@ function Cauldron:SetTradeSkillItem(tooltip, itemIndex, reagentIndex) if reagentIndex then local skillInfo = Cauldron:GetSkillInfoByIndex(itemIndex); local reagentInfo = Cauldron:GetReagentInfoByIndex(itemIndex, reagentIndex); - - -- let the user know if the reagent is a "non-key" reagent - if not reagentInfo.key then - tooltip:AddLine("|cff666666"..L["Available at vendor"].."|r"); + + if reagentInfo then + -- let the user know if the reagent is a "non-key" reagent + if not reagentInfo.key then + tooltip:AddLine("|cff666666"..L["Available at vendor"].."|r"); + end end else -- link = GetTradeSkillItemLink(itemIndex); diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua index 4c6737b..dc0984c 100644 --- a/CauldronMainUI.lua +++ b/CauldronMainUI.lua @@ -1894,13 +1894,34 @@ function Cauldron:CollapseAllButton_OnClick(button) skillName = "Linked-"..skillName; end + local expand = true; + local skillCount = 0; + local expandedCount = 0; + local collapsedCount = 0; + + -- check if some items are expanded + for name, info in pairs(Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.skills) do + if info.expanded then + expandedCount = expandedCount + 1; + else + collapsedCount = collapsedCount + 1; + end + skillCount = skillCount + 1; + end + + if expandedCount == 0 then + expand = true; + elseif collapsedCount == 0 then + expand = false; + end + -- reset all the expanded fields to false for name, info in pairs(Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.skills) do - info.expanded = false; + info.expanded = expand; end -- unselect the selected skill - Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.selected = 0; + -- Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.selected = 0; -- update the UI Cauldron:UpdateSkillList(); @@ -1981,7 +2002,9 @@ function Cauldron:SkillItem_OnClick(frame, button, down) --@end-alpha@ -- select this frame - Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.selected = frame.skillIndex; + if frame.skillIndex then + Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.selected = frame.skillIndex; + end -- update the UI Cauldron:UpdateSkillList(); -- 1.7.9.5