Mercurial > wow > reagentmaker
diff ReagentMaker.lua @ 1:5fc29ed07094
First atempt at using secure menus, it doesn't open yet...
author | contrebasse |
---|---|
date | Mon, 28 Mar 2011 22:59:20 +0200 |
parents | eba26c900e99 |
children | 04c5b817eead |
line wrap: on
line diff
--- a/ReagentMaker.lua Mon Mar 28 22:32:26 2011 +0200 +++ b/ReagentMaker.lua Mon Mar 28 22:59:20 2011 +0200 @@ -38,15 +38,10 @@ --------------------------------------------------- -- Initialize --------------------------------------------------- +local toInitialize = true function A:Initialize() -- This part is done the first time only - if not self.MenuFrame then - -- Prepare the menu - self.MenuFrame = CreateFrame("Frame", "ReagentMakerDropDownMenu"); -- Needs a global name - self.MenuFrame.displayMode = "MENU"; - self.MenuFrame.initialize = self.FillMenu; - self.MenuFrame.point = "TOPLEFT"; - self.MenuFrame.relativePoint = "TOPRIGHT"; + if toInitialize then -- Register clics on reagent's buttons for i=1,7 do @@ -55,6 +50,8 @@ --button:HookScript("OnEnter", function() self:Entered(button, i) end) --button:HookScript("OnLeave", function() self:Left(button, i) end) end -- for + + toInitialize = nil end -- if -- Scan availabe recipes @@ -115,24 +112,17 @@ DoTradeSkill(owner.ReagentMakerIndex,tonumber(split)) end - function A.craft(self,itemID, spell) - -- self is the menu entry - if spell then - CastSpellByName("Mouture") - RunSlashCmd(spell) --CastSpellByName(spell) - --RunSlashCmd("/use "..itemID) --CastSpellByName("/use "..itemID) - return - end - local index = A.findSkillIndex(itemID) + function A.craft(btn,...) + local index = A.findSkillIndex(btn:GetAttribute(target-item)) if index then local skillName, skillType, numAvailable, isExpanded, serviceType, numSkillUps = GetTradeSkillInfo(index) if IsShiftKeyDown() and numAvailable>1 and not spell then - if not self.SplitStack then - self.SplitStack = SplitStack + if not btn.SplitStack then + btn.SplitStack = SplitStack end - self.ReagentMakerIndex = index + btn.ReagentMakerIndex = index - OpenStackSplitFrame(numAvailable, self, "TOPLEFT", "TOPRIGHT") + OpenStackSplitFrame(numAvailable, btn, "TOPLEFT", "TOPRIGHT") else DoTradeSkill(index,1) end @@ -161,8 +151,8 @@ local itemID = A.link2ID(GetTradeSkillReagentItemLink(GetTradeSkillSelectionIndex(), index)) if itemID and A.data[itemID] then - self.MenuFrame.ReagentMakerItemID = itemID - ToggleDropDownMenu(1, nil, A.MenuFrame, button,-4,0) + A.FillMenu(itemID) + A.menuOpen(button) end -- if end -- function end -- do @@ -173,42 +163,36 @@ -- Wow functions local GetItemInfo = GetItemInfo - local UIDropDownMenu_AddButton = UIDropDownMenu_AddButton -- persistent vars local Minfo = {notCheckable = true, func = A.craft} - local Tinfo = {notCheckable = true, isTitle = true} -- function to define the menu items - function A.FillMenu(self, level) + function A.FillMenu(itemID) -- Title - local itemName, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(self.ReagentMakerItemID) - Tinfo.text = "Make "..link.." with:" - UIDropDownMenu_AddButton(Tinfo,level) + --local itemName, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemID) + --Tinfo.text = "Make "..link.." with:" - -- Loop over the availible reciepes - for spellID,reagents in pairs(A.data[self.ReagentMakerItemID]) do + -- Loop over the available reciepes + for spellID,reagents in pairs(A.data[itemID]) do --name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemID) or GetItemInfo("itemName") or GetItemInfo("itemLink") -- Right now, manage only sub-recipes with only one reagent if type(reagents[1]) == "number" then local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(reagents[1]) if link then - Minfo.text = "|T"..texture..":0|t "..link - if #reagents>1 and reagents[2] > 1 then - Minfo.text = reagents[2].."x "..Minfo.text + local text = reagents[2].."x |T"..texture..":0|t "..link + + if reagents.spell then + -- Special spell + -- Minfo.func = RunMacroText + -- Minfo.arg1 = reagents.spell..itemName + -- Minfo.arg2 = nil + A.menuAddItem(text,action,itemID) + else + -- Standard tradeskill spell + A.menuAddItem(text,A.craft,itemID) end -- if - - --if reagents.spell then - -- Minfo.func = RunMacroText - -- Minfo.arg1 = reagents.spell..itemName - -- Minfo.arg2 = nil - --else - Minfo.func = A.craft - Minfo.arg1 = self.ReagentMakerItemID - Minfo.arg2 = reagents.spell - --end -- if - UIDropDownMenu_AddButton(Minfo,level) else A.DEBUG("Erreur, objet inconnu :"..reagents[1]) end -- if