--[[---------------------------------------------------------------------------- |
Copyright (c) 2007, Tom Wieland |
All rights reserved. |
|
Redistribution and use in source and binary forms, with or without |
modification, are permitted provided that the following conditions are met: |
|
* Redistributions of source code must retain the above copyright notice, |
this list of conditions and the following disclaimer. |
* Redistributions in binary form must reproduce the above copyright notice, |
this list of conditions and the following disclaimer in the documentation |
and/or other materials provided with the distribution. |
* Neither the name of idQuestAutomation nor the names of its contributors |
may be used to endorse or promote products derived from this software |
without specific prior written permission. |
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
POSSIBILITY OF SUCH DAMAGE. |
------------------------------------------------------------------------------]] |
|
local _G = _G |
local lib = LibStub('idLibrary-1.1') |
|
local quests = {} |
|
local function stripText (t) -- thx Shadowed |
if not t then return end |
t = t:gsub('%[.*%]%s*','') |
t = t:gsub('|c%x%x%x%x%x%x%x%x(.+)|r','%1') |
t = t:gsub('(.+) %(.+%)', '%1') |
t = t:trim() |
return t |
end |
|
local function GOSSIP_SHOW (event) |
if IsShiftKeyDown() or not GossipFrame:IsVisible() then return end |
|
local button |
local text |
local action |
|
for i = 1, GossipFrame.buttonIndex do |
button = _G['GossipTitleButton'..i] |
text = stripText(button:GetText()) |
|
if button:IsVisible() then |
if button.type == 'Active' then |
if quests[text] then |
action = action or button |
quests[text] = nil |
end |
elseif button.type == 'Available' then |
action = action or button |
end |
end |
end |
if action then |
action:Click() |
end |
end |
|
local function QUEST_DETAIL (event) |
if IsShiftKeyDown() then return end |
AcceptQuest() |
end |
|
local function QUEST_ACCEPT_CONFIRM (event) |
if IsShiftKeyDown() then return end |
end |
|
local function QUEST_PROGRESS (event) |
if IsShiftKeyDown() then return end |
if IsQuestCompletable() then |
CompleteQuest() |
end |
end |
|
local function QUEST_COMPLETE (event) |
if IsShiftKeyDown() then return end |
if GetNumQuestChoices() <= 1 then |
GetQuestReward(QuestFrameRewardPanel.itemChoice) |
end |
end |
|
local function QUEST_LOG_UPDATE (event) |
local startingQuestLogSelection = GetQuestLogSelection() |
local numEntries, numQuests = GetNumQuestLogEntries() |
local q |
|
if numEntries > 0 then |
for i = 1, numEntries do |
SelectQuestLogEntry(i) |
q = {GetQuestLogTitle(i)} |
if q and q[7] then |
quests[q[1]] = true |
end |
end |
end |
|
SelectQuestLogEntry(startingQuestLogSelection) |
end |
|
local function enable () |
lib:RegisterEvent('idQuestAutomation', 'GOSSIP_SHOW', GOSSIP_SHOW) |
lib:RegisterEvent('idQuestAutomation', 'QUEST_DETAIL', QUEST_DETAIL) |
lib:RegisterEvent('idQuestAutomation', 'QUEST_PROGRESS', QUEST_PROGRESS) |
lib:RegisterEvent('idQuestAutomation', 'QUEST_COMPLETE', QUEST_COMPLETE) |
lib:RegisterEvent('idQuestAutomation', 'QUEST_LOG_UPDATE', QUEST_LOG_UPDATE) |
end |
|
local function disable () |
lib:UnregisterEvent('idQuestAutomation', 'GOSSIP_SHOW') |
lib:UnregisterEvent('idQuestAutomation', 'QUEST_DETAIL') |
lib:UnregisterEvent('idQuestAutomation', 'QUEST_PROGRESS') |
lib:UnregisterEvent('idQuestAutomation', 'QUEST_COMPLETE') |
lib:UnregisterEvent('idQuestAutomation', 'QUEST_LOG_UPDATE') |
end |
|
lib:RegisterEvent('idQuestAutomation-Enable', 'PLAYER_LOGIN', enable) |
lib:RegisterEvent('idQuestAutomation-Disable', 'PLAYER_LOGOUT', disable) |