Mercurial > wow > reagentmaker
comparison SecureMenu.lua @ 73:a77fd9d06ba4
Use the new internal data format everywhere
| author | contrebasse |
|---|---|
| date | Sat, 14 May 2011 20:55:49 +0200 |
| parents | 4f9fd025112b |
| children | 3d344a2d8fdf |
comparison
equal
deleted
inserted
replaced
| 72:9cf4ca2145a3 | 73:a77fd9d06ba4 |
|---|---|
| 208 local numMakable = math.floor(itemCount/(btn.reagentsForOneRecipe or 1)) | 208 local numMakable = math.floor(itemCount/(btn.reagentsForOneRecipe or 1)) |
| 209 btn.countDetail:SetText(itemCount.."/"..(btn.reagentsForOneRecipe or 1)) | 209 btn.countDetail:SetText(itemCount.."/"..(btn.reagentsForOneRecipe or 1)) |
| 210 | 210 |
| 211 if numMakable>0 then | 211 if numMakable>0 then |
| 212 -- Set action | 212 -- Set action |
| 213 if type(action)=="function" then | 213 if type(btn.action)=="function" then |
| 214 btn:SetScript("PreClick",btn.action) | 214 btn:SetScript("PreClick",btn.action) |
| 215 btn:SetAttribute("type", nil) | 215 btn:SetAttribute("type", nil) |
| 216 btn:SetAttribute("macrotext", nil) | 216 btn:SetAttribute("macrotext", nil) |
| 217 else --if type(action)=="string" then | 217 else --if type(action)=="string" then |
| 218 btn:SetScript("PreClick",nil) | 218 btn:SetScript("PreClick",nil) |
| 219 btn:SetAttribute("type", "macro") | 219 btn:SetAttribute("type", "macro") |
| 220 btn:SetAttribute("macrotext", btn.action..btn.itemNameString) | 220 btn:SetAttribute("macrotext", btn.action:format(btn.itemNameString)) |
| 221 end -- if | 221 end -- if |
| 222 | 222 |
| 223 anyMakable = true | 223 anyMakable = true |
| 224 btn.countDetail:SetTextColor(1, 1, 1, 1) | 224 btn.countDetail:SetTextColor(1, 1, 1, 1) |
| 225 btn.icon:SetVertexColor(1,1,1); | 225 btn.icon:SetVertexColor(1,1,1); |
| 247 itemIcon:SetVertexColor(0.5, 0.5, 0.5) | 247 itemIcon:SetVertexColor(0.5, 0.5, 0.5) |
| 248 TitleText:SetTextColor(r,g,b,0.7) | 248 TitleText:SetTextColor(r,g,b,0.7) |
| 249 end | 249 end |
| 250 end | 250 end |
| 251 | 251 |
| 252 local function menuAddItem(action,itemID,reagent,spellLink) | 252 local function menuAddItem(action,itemID,reagent) |
| 253 local btn | 253 local btn |
| 254 -- Create a button only if necessary | 254 -- Create a button only if necessary |
| 255 if numActiveEntries >= #menuEntries then | 255 if numActiveEntries >= #menuEntries then |
| 256 btn = createMenuEntry() | 256 btn = createMenuEntry() |
| 257 else | 257 else |
| 258 btn = menuEntries[numActiveEntries+1] | 258 btn = menuEntries[numActiveEntries+1] |
| 259 end | 259 end |
| 260 | 260 |
| 261 -- Set text and icon | 261 -- Set text and icon |
| 262 local name, link, _, _, _, _, _, _, _, texture = GetItemInfo(reagent[1]) | 262 local name, link, _, _, _, _, _, _, _, texture = GetItemInfo(reagent[1]) |
| 263 if name then | 263 if not (name and link and texture) then |
| 264 btn.itemName:SetText(name) | 264 -- Will be retried on next OnUpdate |
| 265 else | |
| 266 --A.DEBUG("No item name : "..reagent[1]) | |
| 267 return | 265 return |
| 268 end | 266 end |
| 269 | 267 btn.itemName:SetText(name) |
| 270 if texture then | 268 btn.icon:SetTexture(texture) |
| 271 btn.icon:SetTexture(texture) | |
| 272 else | |
| 273 --A.DEBUG("No item texture : "..reagent[1]) | |
| 274 return | |
| 275 end | |
| 276 | 269 |
| 277 -- Set chance to have the item or the number of items created | 270 -- Set chance to have the item or the number of items created |
| 278 if reagent[3] then | 271 if reagent[3] then |
| 279 if reagent[3]<1 then | 272 if reagent[3]<1 then |
| 280 btn.resultNumber:SetText((reagent[3]*100).."%") | 273 btn.resultNumber:SetText((reagent[3]*100).."%") |
| 288 -- Save params | 281 -- Save params |
| 289 btn.itemID = itemID | 282 btn.itemID = itemID |
| 290 btn.reagentID = reagent[1] | 283 btn.reagentID = reagent[1] |
| 291 btn.reagentLink = link | 284 btn.reagentLink = link |
| 292 btn.reagentsForOneRecipe = reagent[2] | 285 btn.reagentsForOneRecipe = reagent[2] |
| 293 btn.spellLink = spellLink | 286 btn.spellLink = reagent.spellLink |
| 294 btn.action = action | 287 btn.action = action |
| 295 btn.itemNameString = name | 288 btn.itemNameString = name |
| 296 | 289 |
| 297 btn:Show() | 290 btn:Show() |
| 298 | 291 |
| 334 local color = ITEM_QUALITY_COLORS[quality] | 327 local color = ITEM_QUALITY_COLORS[quality] |
| 335 TitleText:SetTextColor(color.r, color.g, color.b) | 328 TitleText:SetTextColor(color.r, color.g, color.b) |
| 336 | 329 |
| 337 -- Save vars to show the tooltip later | 330 -- Save vars to show the tooltip later |
| 338 MenuFrame.reagentLink = link | 331 MenuFrame.reagentLink = link |
| 339 MenuFrame.spellLink = A.data[itemID].spellLink | 332 MenuFrame.spellLink = A.isRecipeUnique(A.data[itemID]) and A.data[itemID][1].spellLink |
| 340 MenuFrame.itemID = itemID | 333 MenuFrame.itemID = itemID |
| 341 MenuFrame.superItemID = superItemID -- optional | 334 MenuFrame.superItemID = superItemID -- optional, will be nil if not set |
| 342 | 335 |
| 343 -- Loop over the available recipes | 336 -- Loop over the available recipes |
| 344 MenuFrame.state = true | 337 MenuFrame.state = true |
| 345 for _,reagent in ipairs(A.data[itemID]) do | 338 for _,reagent in ipairs(A.data[itemID]) do |
| 346 if A.data[itemID].spell then | 339 if reagent.macro then |
| 347 -- Special spell | 340 -- Special spell |
| 348 MenuFrame.state = menuAddItem(A.data[itemID].spell,itemID,reagent,A.data[itemID].spellLink) and MenuFrame.state | 341 MenuFrame.state = menuAddItem(reagent.macro,itemID,reagent) and MenuFrame.state |
| 349 else | 342 else |
| 350 -- Standard tradeskill spell UNTESTED | 343 -- Standard tradeskill spell UNTESTED |
| 351 MenuFrame.state = menuAddItem(A.craft,itemID,reagent) and MenuFrame.state | 344 MenuFrame.state = menuAddItem(A.craft,itemID,reagent) and MenuFrame.state |
| 352 end -- if | 345 end -- if |
| 353 end -- for | 346 end -- for |
