Mercurial > wow > reagentmaker
comparison SecureMenu.lua @ 20:4ea38bae4174
Lots of display arrangements (tooltips and counts)
Corrected an id in data
author | contrebasse |
---|---|
date | Sun, 10 Apr 2011 19:26:33 +0200 |
parents | f7b23db7bcc6 |
children | 15123d11fc64 |
comparison
equal
deleted
inserted
replaced
19:f7b23db7bcc6 | 20:4ea38bae4174 |
---|---|
7 MenuFrame:SetFrameStrata("DIALOG") | 7 MenuFrame:SetFrameStrata("DIALOG") |
8 MenuFrame:EnableMouse(true) | 8 MenuFrame:EnableMouse(true) |
9 MenuFrame:SetPoint("CENTER") | 9 MenuFrame:SetPoint("CENTER") |
10 tinsert(UISpecialFrames,"ReagentMaker_ExternalFrame") -- make it closable with escape | 10 tinsert(UISpecialFrames,"ReagentMaker_ExternalFrame") -- make it closable with escape |
11 | 11 |
12 local SCAN_DELAY = 0.2 | |
13 local t_throttle = SCAN_DELAY | |
14 function MenuFrame.throttleUpdateCounts(self, t_elapsed) | |
15 t_throttle = t_throttle - t_elapsed | |
16 if t_throttle<0 then | |
17 self:SetScript("OnUpdate", nil) | |
18 | |
19 -- Update counts | |
20 MenuFrame.updateCounts() | |
21 end | |
22 end | |
12 MenuFrame:SetScript("OnEvent",function(self,event,...) | 23 MenuFrame:SetScript("OnEvent",function(self,event,...) |
13 if event == "TRADE_SKILL_UPDATE" then | 24 if event == "BAG_UPDATE" then |
14 MenuFrame.updateCounts() | 25 t_throttle = SCAN_DELAY |
26 self:SetScript("OnUpdate", MenuFrame.throttleUpdateCounts) | |
15 elseif event == "TRADE_SKILL_CLOSE" or event == "PLAYER_REGEN_DISABLED" then | 27 elseif event == "TRADE_SKILL_CLOSE" or event == "PLAYER_REGEN_DISABLED" then |
16 MenuFrame:Hide() | 28 MenuFrame:Hide() |
17 end | 29 end |
18 end) | 30 end) |
19 MenuFrame:RegisterEvent("TRADE_SKILL_CLOSE") | 31 MenuFrame:RegisterEvent("TRADE_SKILL_CLOSE") |
20 MenuFrame:RegisterEvent("PLAYER_REGEN_ENABLED") | 32 MenuFrame:RegisterEvent("PLAYER_REGEN_ENABLED") |
21 MenuFrame:RegisterEvent("TRADE_SKILL_UPDATE") | 33 MenuFrame:RegisterEvent("BAG_UPDATE") |
34 MenuFrame:SetScript("OnEnter",function(self) | |
35 if self.reagentLink then | |
36 GameTooltip:SetOwner(self) | |
37 GameTooltip:SetHyperlink(self.reagentLink) | |
38 GameTooltip:Show() | |
39 GameTooltip:ClearAllPoints() | |
40 GameTooltip:SetPoint("TOPRIGHT",self,"TOPLEFT",10,0) | |
41 end | |
42 end) | |
43 MenuFrame:SetScript("OnLeave",function() | |
44 GameTooltip:Hide() | |
45 end) | |
22 A.MenuFrame = MenuFrame | 46 A.MenuFrame = MenuFrame |
23 | 47 |
24 -- Background adaptable vertically | 48 -- Background adaptable vertically |
25 local bg_top = MenuFrame:CreateTexture(nil,"BACKGROUND",nil,0) | 49 local bg_top = MenuFrame:CreateTexture(nil,"BACKGROUND",nil,0) |
26 bg_top:SetTexture("Interface\\LootFrame\\UI-LootPanel") | 50 bg_top:SetTexture("Interface\\LootFrame\\UI-LootPanel") |
60 local numActiveEntries = 0 | 84 local numActiveEntries = 0 |
61 local menuEntries = {} | 85 local menuEntries = {} |
62 | 86 |
63 -- Button hovering | 87 -- Button hovering |
64 local function btnEntered(btn) | 88 local function btnEntered(btn) |
65 --[[ | 89 if btn.numMakable and btn.numMakable>0 then |
66 -- Index of the reagent in the recipe, taken from the button name | |
67 local reagentRecipeIndex = A.buttonNumber(btn) | |
68 | |
69 -- ID of the reagent we want to craft | |
70 local reagentID = A.link2ID(GetTradeSkillReagentItemLink(GetTradeSkillSelectionIndex(), reagentRecipeIndex)) | |
71 | |
72 -- Continue only if the reagent is known | |
73 if not reagentID or not A.data[reagentID] then return end | |
74 --]] | |
75 | |
76 if btn.numMakable>0 then | |
77 btn.textureHighlight:Show() | 90 btn.textureHighlight:Show() |
78 end | 91 end |
79 | 92 |
80 GameTooltip:SetOwner(btn,"ANCHOR_TOPLEFT") | 93 GameTooltip:SetOwner(btn,"ANCHOR_LEFT") |
81 GameTooltip:SetHyperlink(btn.reagentLink) | 94 GameTooltip:SetHyperlink(btn.reagentLink) |
82 GameTooltip:Show() | 95 GameTooltip:Show() |
83 local link, tradeLink = GetSpellLink(btn.spellID) | 96 if btn.spellID then |
84 A.tooltipRecipe:SetOwner(GameTooltip) | 97 local link = GetSpellLink(btn.spellID) |
85 A.tooltipRecipe:SetHyperlink(link) | 98 if link then |
86 A.tooltipRecipe:Show() | 99 A.tooltipRecipe:SetOwner(GameTooltip) |
87 A.tooltipRecipe:ClearAllPoints() | 100 A.tooltipRecipe:SetHyperlink(link) |
88 A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") | 101 A.tooltipRecipe:Show() |
102 A.tooltipRecipe:ClearAllPoints() | |
103 A.tooltipRecipe:SetPoint("TOPRIGHT",GameTooltip,"BOTTOMRIGHT") | |
104 end | |
105 end | |
89 end | 106 end |
90 local function btnLeft(btn) | 107 local function btnLeft(btn) |
91 btn.textureHighlight:Hide() | 108 btn.textureHighlight:Hide() |
92 GameTooltip:Hide() | 109 GameTooltip:Hide() |
93 A.tooltipRecipe:Hide() | 110 A.tooltipRecipe:Hide() |
143 resultNumber:SetJustifyH("LEFT") | 160 resultNumber:SetJustifyH("LEFT") |
144 resultNumber:SetJustifyV("TOP") | 161 resultNumber:SetJustifyV("TOP") |
145 resultNumber:SetFont("Fonts\\ARIALN.TTF", 12, "OUTLINE") | 162 resultNumber:SetFont("Fonts\\ARIALN.TTF", 12, "OUTLINE") |
146 btn.resultNumber = resultNumber | 163 btn.resultNumber = resultNumber |
147 | 164 |
148 btn:HookScript("OnEnter", btnEntered) | 165 btn:SetScript("OnEnter", btnEntered) |
149 btn:HookScript("OnLeave", btnLeft) | 166 btn:SetScript("OnLeave", btnLeft) |
150 | 167 |
151 return btn | 168 return btn |
152 end | 169 end |
153 | |
154 | 170 |
155 local function menuCraftItem() | 171 local function menuCraftItem() |
156 action(itemID,reagentIndex,IsShiftKeyDown()) | 172 action(itemID,reagentIndex,IsShiftKeyDown()) |
157 end | 173 end |
158 | 174 |
270 SetPortraitToTexture(itemIcon, texture) | 286 SetPortraitToTexture(itemIcon, texture) |
271 TitleText:SetText(name) | 287 TitleText:SetText(name) |
272 local color = ITEM_QUALITY_COLORS[quality] | 288 local color = ITEM_QUALITY_COLORS[quality] |
273 TitleText:SetTextColor(color.r, color.g, color.b) | 289 TitleText:SetTextColor(color.r, color.g, color.b) |
274 | 290 |
291 -- Save vars to show the tooltip later | |
292 MenuFrame.reagentLink = link | |
293 | |
275 -- Loop over the available recipes | 294 -- Loop over the available recipes |
276 for _,reagent in ipairs(A.data[itemID]) do | 295 for _,reagent in ipairs(A.data[itemID]) do |
277 if A.data[itemID].spell then | 296 if A.data[itemID].spell then |
278 -- Special spell | 297 -- Special spell |
279 menuAddItem(A.data[itemID].spell,itemID,reagent,A.data[itemID].spellID) | 298 menuAddItem(A.data[itemID].spell,itemID,reagent,A.data[itemID].spellID) |