# HG changeset patch # User Zerotorescue # Date 1297087601 -3600 # Node ID 2e4e52a589e5c95e042f1018aeeee0306d88e63f # Parent f1d08aaafeaa580c987234c5e1edb740023a8dac 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. diff -r f1d08aaafeaa -r 2e4e52a589e5 Core.lua --- a/Core.lua Mon Feb 07 00:06:07 2011 +0100 +++ b/Core.lua Mon Feb 07 15:06:41 2011 +0100 @@ -445,11 +445,13 @@ }; end -function IMRegisterCraftingAddon(name, queue, enabled, onSelect) +function IMRegisterCraftingAddon(name, queue, enabled, onSelect, onQueueStart, onQueueEnd) addon.supportedAddons.crafting[name] = { ["Queue"] = queue, ["IsEnabled"] = enabled, ["OnSelect"] = onSelect, + ["OnQueueStart"] = onQueueStart, + ["OnQueueEnd"] = onQueueEnd, }; end diff -r f1d08aaafeaa -r 2e4e52a589e5 Modules/Queue.lua --- a/Modules/Queue.lua Mon Feb 07 00:06:07 2011 +0100 +++ b/Modules/Queue.lua Mon Feb 07 15:06:41 2011 +0100 @@ -373,6 +373,12 @@ -- Prepare a table with all possible tradeskill craftables local craftables = self:GetTradeskillCraftables(); + local craftingAddon = self:GetCraftingAddon(group); + + if craftingAddon.OnQueueStart then + craftingAddon.OnQueueStart(); + end + for _, q in pairs(queue) do if craftables[q.itemId] then if self:QueueWithAddon(craftables[q.itemId].no, ceil(q.amount / craftables[q.itemId].quantity), q.groupName) == -1 then @@ -394,6 +400,10 @@ end end + if craftingAddon.OnQueueEnd then + craftingAddon.OnQueueEnd(); + end + self:QueueHide(); end @@ -534,28 +544,38 @@ }); end +function mod:GetCraftingAddon(group) + local selectedExternalAddon = addon:GetOptionByKey(group, "craftingAddon"); + + if addon.supportedAddons.crafting[selectedExternalAddon] and addon.supportedAddons.crafting[selectedExternalAddon].IsEnabled() then + -- Try to use the default auction pricing addon + + return addon.supportedAddons.crafting[selectedExternalAddon], selectedExternalAddon; + else + -- Default not available, get the first one then + + for name, value in pairs(addon.supportedAddons.crafting) do + if value.IsEnabled() then + return value, name; + end + end + end + + return; +end + function mod:QueueWithAddon(tradeSkillIndex, amount, group) -- Sanity check tradeSkillIndex = tonumber(tradeSkillIndex); amount = tonumber(amount); - local selectedExternalAddon = addon:GetOptionByKey(group, "craftingAddon"); + local craftingAddon = self:GetCraftingAddon(group); - if addon.supportedAddons.crafting[selectedExternalAddon] and addon.supportedAddons.crafting[selectedExternalAddon].IsEnabled() then - -- Try to use the default auction pricing addon - - return addon.supportedAddons.crafting[selectedExternalAddon].Queue(tradeSkillIndex, amount); + if craftingAddon then + return craftingAddon.Queue(tradeSkillIndex, amount); else - -- Default not available, get the first one then - - for name, value in pairs(addon.supportedAddons.crafting) do - if value.IsEnabled() then - return value.Queue(tradeSkillIndex, amount); - end - end + return -1; end - - return -1; end function mod:OnEnable() diff -r f1d08aaafeaa -r 2e4e52a589e5 Plugins/CraftingAddons/GnomeWorks.lua --- a/Plugins/CraftingAddons/GnomeWorks.lua Mon Feb 07 00:06:07 2011 +0100 +++ b/Plugins/CraftingAddons/GnomeWorks.lua Mon Feb 07 15:06:41 2011 +0100 @@ -1,17 +1,26 @@ do + local function QueueStart() + -- If the queue frame is open while queueing, each item takes many seconds to be added, + -- closing it resolves this. + GnomeWorksQueueFrame:Hide(); + end + + local function QueueEnd() + GnomeWorks:ShowQueueList(); + end + local function Queue(tradeSkillIndex, amount) local link = GetTradeSkillRecipeLink(tradeSkillIndex); - local recipeId = tonumber(link:match("|Henchant:([-0-9]+)|h")); - - GnomeWorks:ShowQueueList(); - return GnomeWorks:AddToQueue(GnomeWorks.player, tradeSkillIndex, recipeId, amount); + local recipeId = tonumber(link:match("enchant:(%d+)")); + . + return GnomeWorks:AddToQueue(GnomeWorks.player, GnomeWorks.tradeID, recipeId, amount); end local function IsEnabled() return (GnomeWorks and GnomeWorks.AddToQueue); end - IMRegisterCraftingAddon("GnomeWorks", Queue, IsEnabled); + IMRegisterCraftingAddon("GnomeWorks", Queue, IsEnabled, nil, QueueStart, QueueEnd); end