comparison Modules/Queue.lua @ 225:2e4e52a589e5

Added onQueueStart and onQueueEnd events to crafting addon registering. GnomeWorks queue frame should automatically be closed before adding items to the queue and opened afterwards to speed this process up.
author Zerotorescue
date Mon, 07 Feb 2011 15:06:41 +0100
parents 1ed7ce9b1c5d
children
comparison
equal deleted inserted replaced
224:f1d08aaafeaa 225:2e4e52a589e5
371 371
372 function mod:QueueProcess() 372 function mod:QueueProcess()
373 -- Prepare a table with all possible tradeskill craftables 373 -- Prepare a table with all possible tradeskill craftables
374 local craftables = self:GetTradeskillCraftables(); 374 local craftables = self:GetTradeskillCraftables();
375 375
376 local craftingAddon = self:GetCraftingAddon(group);
377
378 if craftingAddon.OnQueueStart then
379 craftingAddon.OnQueueStart();
380 end
381
376 for _, q in pairs(queue) do 382 for _, q in pairs(queue) do
377 if craftables[q.itemId] then 383 if craftables[q.itemId] then
378 if self:QueueWithAddon(craftables[q.itemId].no, ceil(q.amount / craftables[q.itemId].quantity), q.groupName) == -1 then 384 if self:QueueWithAddon(craftables[q.itemId].no, ceil(q.amount / craftables[q.itemId].quantity), q.groupName) == -1 then
379 addon:Print("Couldn't queue, no supported crafting addon found.", addon.Colors.Red); 385 addon:Print("Couldn't queue, no supported crafting addon found.", addon.Colors.Red);
380 386
390 end 396 end
391 end 397 end
392 else 398 else
393 addon:Debug("Lost %s", IdToItemLink(q.itemId)); 399 addon:Debug("Lost %s", IdToItemLink(q.itemId));
394 end 400 end
401 end
402
403 if craftingAddon.OnQueueEnd then
404 craftingAddon.OnQueueEnd();
395 end 405 end
396 406
397 self:QueueHide(); 407 self:QueueHide();
398 end 408 end
399 409
532 ["itemId"] = itemId, 542 ["itemId"] = itemId,
533 ["reason"] = reason, 543 ["reason"] = reason,
534 }); 544 });
535 end 545 end
536 546
547 function mod:GetCraftingAddon(group)
548 local selectedExternalAddon = addon:GetOptionByKey(group, "craftingAddon");
549
550 if addon.supportedAddons.crafting[selectedExternalAddon] and addon.supportedAddons.crafting[selectedExternalAddon].IsEnabled() then
551 -- Try to use the default auction pricing addon
552
553 return addon.supportedAddons.crafting[selectedExternalAddon], selectedExternalAddon;
554 else
555 -- Default not available, get the first one then
556
557 for name, value in pairs(addon.supportedAddons.crafting) do
558 if value.IsEnabled() then
559 return value, name;
560 end
561 end
562 end
563
564 return;
565 end
566
537 function mod:QueueWithAddon(tradeSkillIndex, amount, group) 567 function mod:QueueWithAddon(tradeSkillIndex, amount, group)
538 -- Sanity check 568 -- Sanity check
539 tradeSkillIndex = tonumber(tradeSkillIndex); 569 tradeSkillIndex = tonumber(tradeSkillIndex);
540 amount = tonumber(amount); 570 amount = tonumber(amount);
541 571
542 local selectedExternalAddon = addon:GetOptionByKey(group, "craftingAddon"); 572 local craftingAddon = self:GetCraftingAddon(group);
543 573
544 if addon.supportedAddons.crafting[selectedExternalAddon] and addon.supportedAddons.crafting[selectedExternalAddon].IsEnabled() then 574 if craftingAddon then
545 -- Try to use the default auction pricing addon 575 return craftingAddon.Queue(tradeSkillIndex, amount);
546
547 return addon.supportedAddons.crafting[selectedExternalAddon].Queue(tradeSkillIndex, amount);
548 else 576 else
549 -- Default not available, get the first one then 577 return -1;
550 578 end
551 for name, value in pairs(addon.supportedAddons.crafting) do
552 if value.IsEnabled() then
553 return value.Queue(tradeSkillIndex, amount);
554 end
555 end
556 end
557
558 return -1;
559 end 579 end
560 580
561 function mod:OnEnable() 581 function mod:OnEnable()
562 -- Register our own slash commands 582 -- Register our own slash commands
563 -- /im queue 583 -- /im queue