Mercurial > wow > reagentmaker
changeset 40:5a6091dddf69
Disable actions on buttons with not enough reagents (external frame), and warn the user
author | contrebasse |
---|---|
date | Fri, 29 Apr 2011 23:58:43 +0200 |
parents | 71e8b39f056e |
children | c6a1f1cf560c |
files | SecureMenu.lua |
diffstat | 1 files changed, 24 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/SecureMenu.lua Fri Apr 29 23:43:59 2011 +0200 +++ b/SecureMenu.lua Fri Apr 29 23:58:43 2011 +0200 @@ -189,6 +189,11 @@ action(itemID,reagentIndex,IsShiftKeyDown()) end +local function WarnNotMakable(btn) + A.Error("You do not have enough ["..btn.itemNameString.."] to craft ["..TitleText:GetText().."]") +end + +-- Update counts and button actions function MenuFrame.updateCounts() local anyMakable for i=1,numActiveEntries do @@ -199,12 +204,28 @@ btn.countDetail:SetText(itemCount.."/"..(btn.reagentsForOneRecipe or 1)) if numMakable>0 then + -- Set action + if type(action)=="function" then + btn:SetScript("PreClick",btn.action) + btn:SetAttribute("type", nil) + btn:SetAttribute("macrotext", nil) + else --if type(action)=="string" then + btn:SetScript("PreClick",nil) + btn:SetAttribute("type", "macro") + btn:SetAttribute("macrotext", btn.action..btn.itemNameString) + end -- if + anyMakable = true btn.countDetail:SetTextColor(1, 1, 1, 1) btn.icon:SetVertexColor(1,1,1); btn.itemName:SetTextColor(1,1,1,1) else -- Do not disable the button, to be able to show the tooltip + -- Disable only the effects + btn:SetScript("PreClick",WarnNotMakable) + btn:SetAttribute("type", nil) + btn:SetAttribute("macrotext", nil) + btn.countDetail:SetTextColor(1, 0.1, 0.1, 1) btn.icon:SetVertexColor(0.5, 0.5, 0.5) btn.itemName:SetTextColor(1,1,1,0.5) @@ -265,17 +286,8 @@ btn.reagentLink = link btn.reagentsForOneRecipe = reagent[2] btn.spellLink = spellLink - - -- Set action - if type(action)=="function" then - btn:SetScript("PreClick",action) - btn:SetAttribute("type", nil) - btn:SetAttribute("macrotext", nil) - else --if type(action)=="string" then - btn:SetScript("PreClick",nil) - btn:SetAttribute("type", "macro") - btn:SetAttribute("macrotext", action..name) - end -- if + btn.action = action + btn.itemNameString = name btn:Show() @@ -340,6 +352,7 @@ MenuFrame:ClearAllPoints() MenuFrame:SetPoint("TOPLEFT",TradeSkillFrame,"TOPRIGHT",-2,14) + -- Update counts and set actions MenuFrame.updateCounts() MenuFrame:Show()