@@ -56,10 +56,6 @@ local DEFAULTS = {
5656 minimapSummary = true , -- the minimap button's tooltip lists the open objectives
5757 hideWhileFighting = false , -- a mob you are fighting loses its icon (back if it survives)
5858 highLevelRed = true , -- level alert: red icon for quests 2+ levels above you (deeper per level)
59- questPickup = false , -- Gameplay: accept the quests NPCs offer
60- questPickupMode = " auto" , -- "auto" (on talk, Shift skips) or "button" ("Accept all" on the window)
61- questPickupRepeatable = true , -- dailies and repeatables too
62- questTurnIn = false , -- Gameplay: hand in finished quests (rewards to choose are left alone)
6359 soundChoice = " coins" , -- key in QUEST_SOUNDS
6460 soundVolume = 100 , -- its volume in percent
6561}
@@ -1123,7 +1119,8 @@ local function FillDefaults(profile)
11231119 for key , value in pairs (DEFAULTS ) do
11241120 if profile [key ] == nil then profile [key ] = value end
11251121 end
1126- profile .cursor = nil -- removed option
1122+ profile .cursor = nil -- removed options (quest pickup / turn-in went in 1.2.8)
1123+ profile .questPickup , profile .questPickupMode , profile .questPickupRepeatable , profile .questTurnIn = nil , nil , nil , nil
11271124 profile .style = OLD_STYLES [profile .style ] or profile .style
11281125 if not VALID_STYLE [profile .style ] then profile .style = DEFAULT_STYLE end
11291126 if not QUEST_SOUNDS [profile .soundChoice ] then profile .soundChoice = DEFAULTS .soundChoice end
@@ -2870,43 +2867,8 @@ function BuildPanel()
28702867 return pieces
28712868 end
28722869
2873- -- Gameplay: quest pickup (on/off, mode, repeatables). Laid out from the panel's top like
2874- -- Profiles. (Inline: a named local here would cross Lua's 200-locals limit.)
2875- local builders = { BuildSettingsTab , function (tab )
2876- local top , left = TOP - 48 , LEFT + 20
2877- local intro = tab :CreateFontString (nil , " ARTWORK" , " GameFontHighlightSmall" )
2878- intro :SetPoint (" TOPLEFT" , left , top )
2879- intro :SetWidth (PROFILE_TEXT_WIDTH )
2880- intro :SetJustifyH (" LEFT" )
2881- Loc (intro , " GAMEPLAY_INTRO" )
2882- AddHeading (tab , " PICKUP_HEADING" , left , top - 34 )
2883- local function PickupOn () return db .active and db .questPickup end
2884- GateCheck (On .AddonOn , AddCheck (tab , " QUEST_PICKUP" , " QUEST_PICKUP_TIP" , " questPickup" , left - 4 , top - 52 ))
2885- Gate (PickupOn , AddDropdown (tab , " PICKUP_MODE" , { " auto" , " button" },
2886- function (value ) return value == " button" and L .PICKUP_MODE_BUTTON or L .PICKUP_MODE_AUTO end ,
2887- function () return db .questPickupMode end ,
2888- function (value ) db .questPickupMode = value end ,
2889- left , top - 108 , COLUMN_DROPDOWN ))
2890- GateCheck (PickupOn , AddCheck (tab , " PICKUP_REPEATABLE" , " PICKUP_REPEATABLE_TIP" , " questPickupRepeatable" , left - 4 , top - 160 ))
2891- GateCheck (On .AddonOn , AddCheck (tab , " QUEST_TURNIN" , " QUEST_TURNIN_TIP" , " questTurnIn" , left - 4 , top - 214 ))
2892- -- How it behaves, in one visible line (not only in the hover help).
2893- local how = tab :CreateFontString (nil , " ARTWORK" , " GameFontHighlightSmall" )
2894- how :SetPoint (" TOPLEFT" , left , top - 270 )
2895- how :SetWidth (PROFILE_TEXT_WIDTH )
2896- how :SetJustifyH (" LEFT" )
2897- Loc (how , " PICKUP_HOW" )
2898- -- Another addon already accepts or hands in quests: say so (ours waits while it does).
2899- local other = tab :CreateFontString (nil , " ARTWORK" , " GameFontNormalSmall" )
2900- other :SetPoint (" TOPLEFT" , left , top - 318 )
2901- other :SetWidth (PROFILE_TEXT_WIDTH )
2902- other :SetJustifyH (" LEFT" )
2903- other :SetTextColor (1 , 0.6 , 0.2 )
2904- tab :HookScript (" OnShow" , function ()
2905- local name = questLog .OtherPickupAddon and questLog .OtherPickupAddon ()
2906- other :SetText (name and string.format (L .PICKUP_OTHER_ADDON , name ) or " " )
2907- end )
2908- end , BuildProfilesTab }
2909- local keys = { " TAB_SETTINGS" , " TAB_GAMEPLAY" , " TAB_PROFILES" }
2870+ local builders = { BuildSettingsTab , BuildProfilesTab }
2871+ local keys = { " TAB_SETTINGS" , " TAB_PROFILES" }
29102872 local tabs , frames = {}, {}
29112873 local selected = 1
29122874 local TAB_GAP = 4
@@ -3109,13 +3071,6 @@ local function BuildWizard()
31093071 AddWizardText (extraPage , " WIZ_EXTRA_TITLE" , " WIZ_EXTRA_TEXT" )
31103072 AddCheck (extraPage , " HIGH_LEVEL" , " HIGH_LEVEL_TIP" , " highLevelRed" , 28 , - 126 )
31113073 AddCheck (extraPage , " HIDE_FIGHTING" , " HIDE_FIGHTING_TIP" , " hideWhileFighting" , 28 , - 204 )
3112- AddCheck (extraPage , " QUEST_PICKUP" , " QUEST_PICKUP_TIP" , " questPickup" , 28 , - 282 )
3113- Gate (function () return db .questPickup end , AddDropdown (extraPage , " PICKUP_MODE" , { " auto" , " button" },
3114- function (value ) return value == " button" and L .PICKUP_MODE_BUTTON or L .PICKUP_MODE_AUTO end ,
3115- function () return db .questPickupMode end ,
3116- function (value ) db .questPickupMode = value end ,
3117- 32 , - 340 , 200 ))
3118-
31193074 -- 5. Done.
31203075 local donePage = NewPage ()
31213076 AddWizardText (donePage , " WIZ_DONE_TITLE" , " WIZ_DONE_TEXT" )
@@ -3318,240 +3273,6 @@ function MeasurePlate(unit, force)
33183273end
33193274end
33203275
3321- ---- -----------------------------------------------------------------------------------------
3322- -- Gameplay tab: quest pickup and turn-in, two separate switches, both off by default.
3323- -- Pickup accepts every quest an NPC offers:
3324- -- "auto": talking to the NPC accepts them all, one after the other.
3325- -- "button": an NPC's list gets an "Accept all" button that does the same on click; an NPC
3326- -- with a single quest (no list, the quest opens straight away) is accepted at once.
3327- -- Turn-in hands in finished quests when you talk to the NPC. A quest whose reward must be
3328- -- chosen (more than one choice) is left for you: nothing is done on that page.
3329- -- Shift held when the talk starts leaves that whole conversation manual.
3330- -- How it walks a list: open the first wanted quest (gossip or old greeting window), handle it
3331- -- (QUEST_DETAIL accept, QUEST_PROGRESS / QUEST_COMPLETE hand in); the game reopens the NPC's
3332- -- window, which opens the next one. A quest that can't be done (full quest log, missing items)
3333- -- is not opened again for 10 s, so the walk always ends. Finished quests go first: handing one
3334- -- in can unlock the next.
3335- -- Only real NPCs: quests shared by players and quests started from items are left alone.
3336- -- Another addon already doing it (Questie's auto-accept / auto-complete, Leatrix Plus...)
3337- -- always wins: ours stays out of its way.
3338- -- (Own block: no main-chunk locals, which are at Lua's 200 limit.)
3339- ---- -----------------------------------------------------------------------------------------
3340- do
3341- local paused = false -- Shift held at the start of the talk: manual until the windows close
3342- local batch = false -- an "Accept all" click is walking through the list
3343- local sawList = false -- the NPC showed a list in this talk (a quest opened from it is the player's pick)
3344- local tried = {} -- quest key -> when we last opened it
3345- local button
3346-
3347- local function PickupOn () return db and db .active and db .questPickup end
3348- local function TurnInOn () return db and db .active and db .questTurnIn end
3349- local function AutoMode () return PickupOn () and db .questPickupMode ~= " button" end
3350-
3351- local function FromNPC (unit )
3352- local guid = UnitGUID and UnitGUID (unit )
3353- if Hidden .Value (guid ) or type (guid ) ~= " string" then return false end
3354- return guid :find (" ^Creature" ) ~= nil or guid :find (" ^Vehicle" ) ~= nil or guid :find (" ^GameObject" ) ~= nil
3355- end
3356- local function QuestUnit () return (UnitExists (" questnpc" ) and " questnpc" ) or " npc" end
3357-
3358- -- Another addon that accepts or hands in quests by itself: we never interfere with it. Each
3359- -- check says whether that addon does it right now, for "accept" or "turnin" (its own switch
3360- -- when we can read it; addons whose whole job is automating quests count as soon as they are
3361- -- loaded). Every read is guarded.
3362- local function Loaded (name )
3363- return C_AddOns and C_AddOns .IsAddOnLoaded and C_AddOns .IsAddOnLoaded (name ) or false
3364- end
3365- local OTHERS = {
3366- { " Questie" , function (kind )
3367- local profile = type (Questie ) == " table" and Questie .db and Questie .db .profile
3368- if not profile then return false end
3369- if kind == " turnin" then return profile .autocomplete end
3370- return profile .autoAccept and profile .autoAccept .enabled
3371- end },
3372- { " Leatrix_Plus" , function () return type (LeaPlusDB ) == " table" and LeaPlusDB .AutomateQuests == " On" end , " Leatrix Plus" },
3373- { " QuickQuest" , function () return true end },
3374- { " AutoTurnIn" , function () return true end },
3375- -- (Zygor's setting names are a best guess, not checked: if wrong, they just never match.)
3376- { " ZygorGuidesViewerClassic" , function (kind )
3377- local profile = type (ZGV ) == " table" and ZGV .db and ZGV .db .profile
3378- if not profile then return false end
3379- if kind == " turnin" then return profile .autoturnin end
3380- return profile .autoaccept
3381- end , " Zygor Guides" },
3382- }
3383- -- The name of the addon doing it ("accept" or "turnin"; nil kind = either), or nil.
3384- -- (Shared with the Gameplay tab, which shows a note.)
3385- function questLog .OtherPickupAddon (kind )
3386- for _ , other in ipairs (OTHERS ) do
3387- if Loaded (other [1 ]) then
3388- local ok , on = pcall (other [2 ], kind or " accept" )
3389- if not (ok and on ) and not kind then ok , on = pcall (other [2 ], " turnin" ) end
3390- if ok and on then return other [3 ] or other [1 ] end
3391- end
3392- end
3393- return nil
3394- end
3395-
3396- local function Wanted (repeatable , frequency )
3397- if db .questPickupRepeatable then return true end
3398- return not (repeatable or (tonumber (frequency ) or 0 ) > 0 )
3399- end
3400- local function Fresh (key )
3401- local last = tried [key ]
3402- return not last or GetTime () - last > 10
3403- end
3404-
3405- -- The next quest of the open window to accept / to hand in: its key and a function that
3406- -- opens it.
3407- local function NextGossip ()
3408- if not (C_GossipInfo and C_GossipInfo .GetAvailableQuests and C_GossipInfo .SelectAvailableQuest ) then return nil end
3409- for _ , quest in ipairs (C_GossipInfo .GetAvailableQuests () or {}) do
3410- local key = quest .questID or quest .title
3411- if key and Wanted (quest .repeatable , quest .frequency ) and Fresh (key ) then
3412- return key , function () C_GossipInfo .SelectAvailableQuest (quest .questID ) end
3413- end
3414- end
3415- end
3416- local function NextGreeting ()
3417- if not (GetNumAvailableQuests and SelectAvailableQuest ) then return nil end
3418- for i = 1 , GetNumAvailableQuests () or 0 do
3419- local trivial , frequency , repeatable -- (named, never the global "_": writing it taints)
3420- if GetAvailableQuestInfo then trivial , frequency , repeatable = GetAvailableQuestInfo (i ) end
3421- local key = (GetAvailableTitle and GetAvailableTitle (i )) or i
3422- if Wanted (repeatable , frequency ) and Fresh (key ) then
3423- return key , function () SelectAvailableQuest (i ) end
3424- end
3425- end
3426- end
3427- local function NextDoneGossip ()
3428- if not (C_GossipInfo and C_GossipInfo .GetActiveQuests and C_GossipInfo .SelectActiveQuest ) then return nil end
3429- for _ , quest in ipairs (C_GossipInfo .GetActiveQuests () or {}) do
3430- local key = " done " .. tostring (quest .questID or quest .title )
3431- if quest .isComplete and Fresh (key ) then
3432- return key , function () C_GossipInfo .SelectActiveQuest (quest .questID ) end
3433- end
3434- end
3435- end
3436- local function NextDoneGreeting ()
3437- if not (GetNumActiveQuests and GetActiveTitle and SelectActiveQuest ) then return nil end
3438- for i = 1 , GetNumActiveQuests () or 0 do
3439- local title , isComplete = GetActiveTitle (i )
3440- local key = " done " .. tostring (title or i )
3441- if isComplete and Fresh (key ) then
3442- return key , function () SelectActiveQuest (i ) end
3443- end
3444- end
3445- end
3446-
3447- -- Opens the next quest; false when there is none left.
3448- local function Step (nextQuest )
3449- local key , open = nextQuest ()
3450- if not key then return false end
3451- tried [key ] = GetTime ()
3452- open ()
3453- return true
3454- end
3455-
3456- local function HideButton () if button then button :Hide () end end
3457-
3458- -- "button" mode: the button sits in the top right corner of the NPC's window while it has
3459- -- quests left to accept. It is a child of that window, so it shows and hides with it: on some
3460- -- clients the window only opens a moment after GOSSIP_SHOW, so its state isn't checked here.
3461- local function UpdateButton (host , nextQuest )
3462- if not (PickupOn () and db .questPickupMode == " button" and host ) then HideButton () return end
3463- if not button then
3464- button = CreateFrame (" Button" , nil , UIParent , " UIPanelButtonTemplate" )
3465- button :SetSize (120 , 22 )
3466- button :SetScript (" OnClick" , function (self )
3467- self :Hide ()
3468- batch = true
3469- if not Step (self .nextQuest ) then batch = false end
3470- end )
3471- end
3472- button .nextQuest = nextQuest
3473- button :SetParent (host )
3474- button :ClearAllPoints ()
3475- button :SetPoint (" TOPRIGHT" , host , " TOPRIGHT" , - 32 , - 30 )
3476- button :SetFrameLevel (host :GetFrameLevel () + 20 )
3477- button :SetText (L .PICKUP_ACCEPT_ALL )
3478- button :SetShown (nextQuest () ~= nil )
3479- end
3480-
3481- local function AllClosed ()
3482- return not ((GossipFrame and GossipFrame :IsVisible ()) or (QuestFrame and QuestFrame :IsVisible ()))
3483- end
3484-
3485- local frame = CreateFrame (" Frame" )
3486- for _ , event in ipairs ({ " GOSSIP_SHOW" , " GOSSIP_CLOSED" , " QUEST_GREETING" , " QUEST_DETAIL" ,
3487- " QUEST_PROGRESS" , " QUEST_COMPLETE" , " QUEST_FINISHED" }) do
3488- pcall (frame .RegisterEvent , frame , event )
3489- end
3490- frame :SetScript (" OnEvent" , function (_ , event )
3491- if event == " GOSSIP_CLOSED" or event == " QUEST_FINISHED" then
3492- -- Between two quest windows everything is closed for a moment: wait before calling
3493- -- the talk over.
3494- C_Timer .After (0.5 , function ()
3495- if AllClosed () then paused , batch , sawList = false , false , false ; wipe (tried ); HideButton () end
3496- end )
3497- return
3498- end
3499- local acceptOn = PickupOn () and not questLog .OtherPickupAddon (" accept" )
3500- local turnInOn = TurnInOn () and not questLog .OtherPickupAddon (" turnin" )
3501- if not (acceptOn or turnInOn ) then HideButton () return end
3502-
3503- if event == " QUEST_PROGRESS" then
3504- -- Handing in, the "items needed" page: continue when the quest can be completed.
3505- if turnInOn and not paused and not IsShiftKeyDown () and FromNPC (QuestUnit ())
3506- and IsQuestCompletable and IsQuestCompletable () and CompleteQuest then
3507- CompleteQuest ()
3508- end
3509- return
3510- elseif event == " QUEST_COMPLETE" then
3511- -- The reward page: take it only when there is nothing to choose (0 or 1 reward).
3512- -- Two or more to choose from: left for the player, nothing done here.
3513- local choices = (GetNumQuestChoices and GetNumQuestChoices ()) or 0
3514- if turnInOn and not paused and not IsShiftKeyDown () and FromNPC (QuestUnit ())
3515- and choices <= 1 and GetQuestReward then
3516- GetQuestReward (choices )
3517- end
3518- return
3519- elseif event == " QUEST_DETAIL" then
3520- if not acceptOn or not FromNPC (QuestUnit ()) then return end
3521- if batch then AcceptQuest () return end
3522- -- "auto" accepts every quest it is shown; "button" only a quest the NPC opened
3523- -- straight away (it has just one, no list). A quest the player picked from a list
3524- -- in "button" mode is theirs to accept.
3525- if not paused and not IsShiftKeyDown () and (AutoMode () or not sawList ) then
3526- -- Same rule for repeatables as in the lists.
3527- local daily = (QuestIsDaily and QuestIsDaily ()) or (QuestIsWeekly and QuestIsWeekly ())
3528- if db .questPickupRepeatable or not daily then AcceptQuest () end
3529- end
3530- return
3531- end
3532-
3533- -- GOSSIP_SHOW or QUEST_GREETING: the NPC's window with its lists.
3534- local gossip = event == " GOSSIP_SHOW"
3535- sawList = true
3536- local host = gossip and GossipFrame or QuestFrame
3537- if IsShiftKeyDown () and not batch then paused = true end
3538- local fromNPC = FromNPC (" npc" )
3539- if turnInOn and not paused and fromNPC and Step (gossip and NextDoneGossip or NextDoneGreeting ) then
3540- HideButton ()
3541- return
3542- end
3543- if not acceptOn then HideButton () return end
3544- local nextQuest = gossip and NextGossip or NextGreeting
3545- if batch then
3546- if Step (nextQuest ) then return end
3547- batch = false
3548- elseif AutoMode () and not paused and fromNPC and Step (nextQuest ) then
3549- return
3550- end
3551- UpdateButton (host , nextQuest )
3552- end )
3553- end
3554-
35553276local events = CreateFrame (" Frame" )
35563277events :RegisterEvent (" ADDON_LOADED" )
35573278events :RegisterEvent (" PLAYER_LOGIN" )
0 commit comments