Mercurial > wow > reagentmaker
diff SecureMenu.lua @ 110:d60d6b4cab0c
Tradeskill in external window should now be functional
author | contrebasse |
---|---|
date | Thu, 02 Jun 2011 18:23:42 +0200 |
parents | 618163a6d970 |
children | af23986010ef |
line wrap: on
line diff
--- a/SecureMenu.lua Thu Jun 02 14:12:49 2011 +0200 +++ b/SecureMenu.lua Thu Jun 02 18:23:42 2011 +0200 @@ -4,9 +4,10 @@ local MenuFrame = CreateFrame("Frame","ReagentMaker_ExternalFrame",UIParent) MenuFrame:Hide() MenuFrame:SetSize(192,256) -MenuFrame:SetFrameStrata("DIALOG") +--MenuFrame:SetFrameStrata("DIALOG") MenuFrame:EnableMouse(true) MenuFrame:SetPoint("CENTER") +MenuFrame:SetToplevel(true) -- raised if clicked tinsert(UISpecialFrames,"ReagentMaker_ExternalFrame") -- make it closable with escape local SCAN_DELAY = 0.2 @@ -137,7 +138,7 @@ btn:Hide() btn:SetSize(MENU_ENTRY_WIDTH,MENU_ENTRY_HEIGHT) - btn:SetFrameStrata("DIALOG") + --btn:SetFrameStrata("DIALOG") -- Set its position if #menuEntries>1 then @@ -167,6 +168,7 @@ local textureHighlight = btn:CreateTexture(nil,"BORDER") textureHighlight:Hide() textureHighlight:SetTexture("Interface\\BUTTONS\\CheckButtonHilight") + --textureHighlight:SetTexture("Interface\\BUTTONS\\ButtonHilight-Square") textureHighlight:SetBlendMode("ADD") textureHighlight:SetAllPoints(icon) btn.textureHighlight = textureHighlight @@ -184,6 +186,9 @@ resultNumber:SetFont("Fonts\\ARIALN.TTF", 12, "OUTLINE") btn.resultNumber = resultNumber + -- Used to choose the number of items to make + btn.SplitStack = A.SplitStack + btn:SetScript("OnEnter", btnEntered) btn:SetScript("OnLeave", btnLeft) @@ -198,15 +203,60 @@ end end +local function CraftFromExternal(btn) + local chooseNumber = IsShiftKeyDown() + local numReagentMakable = A.numRecipeMakable(btn.reagentID,btn.reagentsForOneRecipe) + local reagentIndex = A.findExactSkillIndex(btn.itemID,btn.itemNameString) + + -- to define + local numToMake = 1 + + -- Choose number or craft directly + if chooseNumber then + -- Store info to be able to run the function later + btn.ReagentMaker_reagentIndex = reagentIndex + + -- Open dialog + OpenStackSplitFrame(numReagentMakable, btn, "BOTTOMRIGHT", "TOP") + + -- Fill in the number to make + numToMake = tostring(numToMake) + for i = 1,numToMake:len() do + StackSplitFrame_OnChar(StackSplitFrame,numToMake:gsub(i,i)) + end + StackSplitFrame.typing = 0 -- reinit the frame so that the entered value will be erased on text entry + else + DoTradeSkill(reagentIndex,numToMake) + end -- if +end + -- Update counts and button actions function MenuFrame.updateCounts() local anyMakable for i=1,numActiveEntries do - btn = menuEntries[i] + local btn = menuEntries[i] local itemCount = GetItemCount(btn.reagentID) - local numMakable = math.floor(itemCount/(btn.reagentsForOneRecipe or 1)) - btn.countDetail:SetText(itemCount.."/"..(btn.reagentsForOneRecipe or 1)) + local numMakable + if btn.reagentID then + numMakable = math.floor(itemCount/(btn.reagentsForOneRecipe or 1)) + btn.countDetail:SetText(itemCount.."/"..(btn.reagentsForOneRecipe or 1)) + else + for _,reagent in pairs(btn.reagentsForOneRecipe) do + itemCount = GetItemCount(reagent[1]) + if not itemCount then + numMakable = 0 + break + end + if not numMakable then + numMakable = math.floor(itemCount/reagent[2]) + else + numMakable = math.min(numMakable,math.floor(itemCount/reagent[2])) + end + if numMakable==0 then break end + end + btn.countDetail:SetText(numMakable) + end if numMakable>0 then -- Set action @@ -362,9 +412,9 @@ noSkipped = menuAddItem(reagent.macro,itemID,reagent) and noSkipped else -- Standard tradeskill spell - if not reagent.spellName or reagent.spellName == A.currentTradeSkill then + if not reagent.tradeskillName or reagent.tradeskillName == A.currentTradeSkill then existsValidEntries = true - noSkipped = menuAddItem(A.craft,itemID,reagent) and noSkipped + noSkipped = menuAddItem(CraftFromExternal,itemID,reagent) and noSkipped end end -- if end -- for