From f911199cb0cdc2661303f5a5d5cc29de24b6c6cd Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Sun, 23 Nov 2014 08:02:43 +0100 Subject: [PATCH] Always mark best quest reward regardless of preference - This required an upgraded event handler --- QuickQuest.lua | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/QuickQuest.lua b/QuickQuest.lua index bc27ac3..5aae487 100644 --- a/QuickQuest.lua +++ b/QuickQuest.lua @@ -4,14 +4,32 @@ QuickQuest:SetScript('OnEvent', function(self, event, ...) self[event](...) end) local atBank, atMail, atMerchant local choiceQueue, autoCompleteIndex +local metatable = { + __call = function(methods, ...) + for _, method in next, methods do + method(...) + end + end +} + local modifier = false -function QuickQuest:Register(event, func, override) - self:RegisterEvent(event) - self[event] = function(...) - if(override or QuickQuestDB.toggle and QuickQuestDB.reverse == modifier) then - func(...) +function QuickQuest:Register(event, method, override) + local newmethod + if(not override) then + newmethod = function(...) + if(QuickQuestDB.toggle and QuickQuestDB.reverse == modifier) then + method(...) + end end end + + local methods = self[event] + if(methods) then + self[event] = setmetatable({methods, newmethod or method}, metatable) + else + self[event] = newmethod or method + self:RegisterEvent(event) + end end local function IsTrackingTrivial() @@ -133,7 +151,7 @@ QuickQuest:Register('QUEST_ITEM_UPDATE', function() if(choiceQueue and QuickQuest[choiceQueue]) then QuickQuest[choiceQueue]() end -end) +end, true) QuickQuest:Register('QUEST_PROGRESS', function() if(IsQuestCompletable()) then @@ -163,7 +181,12 @@ QuickQuest:Register('QUEST_COMPLETE', function() local choices = GetNumQuestChoices() if(choices <= 1) then GetQuestReward(1) - elseif(choices > 1) then + end +end) + +QuickQuest:Register('QUEST_COMPLETE', function() + local choices = GetNumQuestChoices() + if(choices > 1) then local bestValue, bestIndex = 0 for index = 1, choices do @@ -186,10 +209,10 @@ QuickQuest:Register('QUEST_COMPLETE', function() end if(bestIndex) then - QuestInfoRewardsFrame.RewardButtons[bestIndex]:Click() + QuestInfoItem_OnClick(QuestInfoRewardsFrame.RewardButtons[bestIndex]) end end -end) +end, true) QuickQuest:Register('QUEST_FINISHED', function() choiceQueue = nil -- 1.7.9.5