@@ -34,6 +34,7 @@ local DEFAULTS = {
3434 progressColor = " white" , -- "white", "gold", "green", "kind" (same colour as the icon) or "progress" (red to green)
3535 progressFormat = " slash" , -- "slash" 8/12, "spaced" 8 / 12, "both" 8/12 (67%), "percent" 67%, "left" 4 left
3636 progressShadow = false , -- drop shadow behind the text
37+ progressPulse = true , -- the count pulses when it goes up and turns gold with one left
3738 progressX = 36 , -- its X
3839 progressY = 0 , -- its Y
3940 bounce = true , -- floating up/down animation
@@ -50,6 +51,9 @@ local DEFAULTS = {
5051 minimap = true , -- minimap button
5152 minimapAngle = 220 , -- its position around the minimap (degrees)
5253 sound = true , -- play a sound when a quest objective completes
54+ doneCheck = true , -- an icon that stops being needed turns into a check mark, then fades
55+ readyAlert = true , -- chat line when every objective of a quest is done
56+ minimapSummary = true , -- the minimap button's tooltip lists the open objectives
5357 soundChoice = " coins" , -- key in QUEST_SOUNDS
5458}
5559-- Saved layout: CSCoderQuestIndicatorDB = { version, language, profiles = { name = settings },
324328
325329-- Unfinished objectives from the quest log, rebuilt on QUEST_LOG_UPDATE.
326330local objectiveTexts = {} -- { text = lower case objective, kind = quest kind }
331+ -- What the last quest log scan found: unfinished objectives per quest (the minimap tooltip
332+ -- summary) and when an objective last finished (icons that stop being needed right after show
333+ -- the check mark).
334+ local questLog = { summary = {}, completedAt = - 100 }
327335
328336-- A name found in an unfinished objective ("Kobold Vermin slain: 3/10", "Crate of Supplies:
329337-- 1/4"): its quest kind and progress.
@@ -441,6 +449,11 @@ local function StyleIcon(f)
441449 color = ProgressColor (fraction )
442450 end
443451 color = color or TEXT_COLORS .white
452+ -- One left: gold, whatever the colour setting (with "Animate the count").
453+ if db .progressPulse then
454+ local have , need = tostring (f .progressValue ):match (" (%d+)%s*/%s*(%d+)" )
455+ if have and tonumber (need ) - tonumber (have ) == 1 then color = TEXT_COLORS .gold end
456+ end
444457 label :SetTextColor (color [1 ], color [2 ], color [3 ])
445458 label :SetText (shown )
446459 text :SetScale (1 / scale )
@@ -537,16 +550,50 @@ local function CreateIcon()
537550 grow :SetDuration (0.18 )
538551 grow :SetSmoothing (" OUT" )
539552 f .pop = pop
553+
554+ -- Done: the check mark swells a little and fades out; then the icon goes back to the pool.
555+ local done = f :CreateAnimationGroup ()
556+ local swell = done :CreateAnimation (" Scale" )
557+ swell :SetScaleFrom (1 , 1 )
558+ swell :SetScaleTo (1.35 , 1.35 )
559+ swell :SetDuration (0.25 )
560+ swell :SetSmoothing (" OUT" )
561+ local fadeOut = done :CreateAnimation (" Alpha" )
562+ fadeOut :SetFromAlpha (1 )
563+ fadeOut :SetToAlpha (0 )
564+ fadeOut :SetStartDelay (0.6 )
565+ fadeOut :SetDuration (0.5 )
566+ done :SetScript (" OnFinished" , function () if f .onDone then f .onDone (f ) end end )
567+ f .done = done
568+
569+ -- The count's pulse when it goes up: out to 1.4x and back.
570+ local textPop = text :CreateAnimationGroup ()
571+ local out = textPop :CreateAnimation (" Scale" )
572+ out :SetScale (1.4 , 1.4 )
573+ out :SetDuration (0.12 )
574+ out :SetOrder (1 )
575+ local back = textPop :CreateAnimation (" Scale" )
576+ back :SetScale (1 / 1.4 , 1 / 1.4 )
577+ back :SetDuration (0.18 )
578+ back :SetOrder (2 )
579+ f .textPop = textPop
540580 return f
541581end
542582
543583local function ShowIcon (unit , plate , kind , progress )
544584 kind = kind or " normal"
545585 local f = icons [unit ]
546586 if f then
587+ if f .completing then return end
547588 if f .kind ~= kind or f .progressValue ~= progress then
589+ local before = tonumber (tostring (f .progressValue ):match (" %d+" ))
590+ local now = tonumber (tostring (progress ):match (" %d+" ))
548591 f .kind , f .progressValue = kind , progress
549592 StyleIcon (f )
593+ if db .progressPulse and before and now and now > before and f .text :IsShown () then
594+ f .textPop :Stop ()
595+ f .textPop :Play ()
596+ end
550597 end
551598 return
552599 end
@@ -566,13 +613,34 @@ local function HideIcon(unit)
566613 if not f then return end
567614 icons [unit ] = nil
568615 f .pulse :Stop ()
616+ f .done :Stop ()
617+ f .completing , f .onDone = nil , nil
569618 f :Hide ()
570619 f :SetParent (UIParent )
571620 f .unit , f .progressValue = nil , nil
572621 f .text :Hide ()
573622 table.insert (pool , f )
574623end
575624
625+ -- An icon that stops being needed right after an objective finished turns into a green check
626+ -- mark, then fades; otherwise it just goes.
627+ local function HideOrComplete (unit )
628+ local f = icons [unit ]
629+ if not f or f .completing then return end
630+ if not (db .doneCheck and GetTime () - questLog .completedAt < 3 ) then -- 3 s after an objective finished
631+ HideIcon (unit )
632+ return
633+ end
634+ f .completing = true
635+ f .icon :SetTexture (" Interface\\ RaidFrame\\ ReadyCheck-Ready" )
636+ f .icon :SetVertexColor (1 , 1 , 1 )
637+ f .glow :SetVertexColor (0.3 , 1 , 0.3 , 0.9 )
638+ f .glow :Show ()
639+ f .text :Hide ()
640+ f .onDone = function (self ) if icons [unit ] == self then HideIcon (unit ) end end
641+ f .done :Play ()
642+ end
643+
576644local function UpdateCombatAlpha ()
577645 local alpha = CombatAlpha ()
578646 for _ , f in pairs (icons ) do f :SetAlpha (alpha ) end
@@ -583,6 +651,7 @@ local function Refresh(unit)
583651 if db .active and db .enabled and plate then
584652 local needed , kind , progress = IsQuestMob (unit )
585653 if needed then ShowIcon (unit , plate , kind , progress ) return end
654+ if not UnitIsDead (unit ) then HideOrComplete (unit ) return end
586655 end
587656 HideIcon (unit )
588657end
@@ -628,12 +697,25 @@ local function PlayQuestSound()
628697 if PlaySound then pcall (PlaySound , id , " Master" ) end
629698end
630699
631- local function RebuildObjectiveTexts ()
700+ local RebuildObjectiveTexts
701+ do -- (own block: the main chunk is near Lua's 200-locals limit)
702+ local function QuestTitle (questID , logIndex )
703+ local title = C_QuestLog .GetTitleForQuestID and C_QuestLog .GetTitleForQuestID (questID )
704+ if not title and C_QuestLog .GetInfo then
705+ local info = C_QuestLog .GetInfo (logIndex )
706+ title = info and info .title
707+ end
708+ if not title and GetQuestLogTitle then title = GetQuestLogTitle (logIndex ) end
709+ return title or " ?"
710+ end
711+
712+ function RebuildObjectiveTexts ()
632713 wipe (objectiveTexts )
633714 if not (C_QuestLog and C_QuestLog .GetQuestObjectives ) then return end
634715 -- An objective that was unfinished on the last scan and is finished now plays the sound
635- -- (once per scan). Quests seen for the first time (login, just accepted) stay silent.
636- local states , completed = {}, false
716+ -- (once per scan); a quest whose last objective just finished is announced as ready.
717+ -- Quests seen for the first time (login, just accepted) stay silent.
718+ local states , completed , ready , summary = {}, false , {}, {}
637719 local count = (C_QuestLog .GetNumQuestLogEntries and C_QuestLog .GetNumQuestLogEntries ()) or 0
638720 for i = 1 , count do
639721 local questID = C_QuestLog .GetQuestIDForLogIndex and C_QuestLog .GetQuestIDForLogIndex (i )
@@ -642,19 +724,37 @@ local function RebuildObjectiveTexts()
642724 questID = info and not info .isHeader and info .questID
643725 end
644726 local objectives = questID and C_QuestLog .GetQuestObjectives (questID )
727+ local before = objectiveStates [questID ]
728+ local allDone , wasAllDone , open = # (objectives or {}) > 0 , true , nil
645729 for index , objective in ipairs (objectives or {}) do
646- if objective .text and not objective .finished then
730+ local finished = objective .finished and true or false
731+ if objective .text and not finished then
647732 objectiveTexts [# objectiveTexts + 1 ] = { text = objective .text :lower (), kind = kindByQuestID [questID ] or " normal" }
733+ open = open or {}
734+ open [# open + 1 ] = objective .text
648735 end
649- local finished = objective .finished and true or false
650736 states [questID ] = states [questID ] or {}
651737 states [questID ][index ] = finished
652- local before = objectiveStates [questID ] and objectiveStates [questID ][index ]
653- if finished and before == false then completed = true end
738+ if not finished then allDone = false end
739+ if before and before [index ] == false then
740+ wasAllDone = false
741+ if finished then completed = true end
742+ end
654743 end
744+ if open then summary [# summary + 1 ] = { title = QuestTitle (questID , i ), lines = open } end
745+ if before and allDone and not wasAllDone then ready [# ready + 1 ] = QuestTitle (questID , i ) end
655746 end
656747 objectiveStates = states
657- if completed and db .active and db .sound then PlayQuestSound () end
748+ questLog .summary = summary
749+ if completed then questLog .completedAt = GetTime () end
750+ if not db .active then return end
751+ if completed and db .sound then PlayQuestSound () end
752+ if db .readyAlert then
753+ for _ , title in ipairs (ready ) do
754+ print (string.format (" |cffffd200%s|r " .. L .READY_TO_TURN_IN , TITLE , " |cff00ff00" .. title .. " |r" ))
755+ end
756+ end
757+ end
658758end
659759
660760-- Returns: still needed?, quest kind, progress text.
@@ -1073,7 +1173,7 @@ local DROPDOWN_MAX_ROWS = 16 -- longer lists wrap into more columns
10731173local openList -- the dropdown list currently open, if any
10741174local dropdownHost -- window that holds new dropdown lists (default: the options panel)
10751175
1076- local function AddDropdown (parent , labelKey , options , labelFor , get , set , x , y , width , fontFor )
1176+ local function AddDropdown (parent , labelKey , options , labelFor , get , set , x , y , width , fontFor , preview )
10771177 width = width or 240
10781178 local heading = AddHeading (parent , labelKey , x , y )
10791179 local backdrop = BackdropTemplateMixin and " BackdropTemplate" or nil
@@ -1124,6 +1224,17 @@ local function AddDropdown(parent, labelKey, options, labelFor, get, set, x, y,
11241224 row .text :SetPoint (" RIGHT" , - 4 , 0 )
11251225 row .text :SetJustifyH (" LEFT" )
11261226 row :SetHighlightTexture (" Interface\\ QuestFrame\\ UI-QuestTitleHighlight" , " ADD" )
1227+ -- preview(option), when given, adds a play button to each row (the sound menu).
1228+ if preview then
1229+ row .text :SetPoint (" RIGHT" , - 22 , 0 )
1230+ local play = CreateFrame (" Button" , nil , row )
1231+ play :SetSize (16 , 16 )
1232+ play :SetPoint (" RIGHT" , - 2 , 0 )
1233+ play :SetNormalTexture (" Interface\\ Buttons\\ UI-SpellbookIcon-NextPage-Up" )
1234+ play :SetPushedTexture (" Interface\\ Buttons\\ UI-SpellbookIcon-NextPage-Down" )
1235+ play :SetHighlightTexture (" Interface\\ Buttons\\ UI-Common-MouseHilight" , " ADD" )
1236+ play :SetScript (" OnClick" , function () preview (row .option ) end )
1237+ end
11271238 row :SetScript (" OnClick" , function (self )
11281239 list :Hide ()
11291240 set (self .option )
@@ -1558,6 +1669,19 @@ local function CreateMinimapButton()
15581669 GameTooltip :AddLine (L .TIP_LEFT , 1 , 1 , 1 )
15591670 GameTooltip :AddLine (L .TIP_RIGHT , 1 , 1 , 1 )
15601671 GameTooltip :AddLine (L .TIP_DRAG , 0.7 , 0.7 , 0.7 )
1672+ -- What's left, per quest (up to 8 quests).
1673+ if db .minimapSummary and # questLog .summary > 0 then
1674+ GameTooltip :AddLine (" " )
1675+ GameTooltip :AddLine (L .SUMMARY_TITLE , 1 , 0.82 , 0 )
1676+ for i , quest in ipairs (questLog .summary ) do
1677+ if i > 8 then
1678+ GameTooltip :AddLine (string.format (L .SUMMARY_MORE , # questLog .summary - 8 ), 0.7 , 0.7 , 0.7 )
1679+ break
1680+ end
1681+ GameTooltip :AddLine (quest .title , 1 , 0.82 , 0 )
1682+ for _ , line in ipairs (quest .lines ) do GameTooltip :AddLine (" " .. line , 1 , 1 , 1 ) end
1683+ end
1684+ end
15611685 GameTooltip :Show ()
15621686 end )
15631687 b :SetScript (" OnLeave" , function () GameTooltip :Hide () end )
@@ -1590,9 +1714,10 @@ local DISPLAY_KEYS = { "active", "enabled", "objects", "anchor", "scale", "offse
15901714 " objectAnchor" , " objectScale" , " objectOffsetX" , " objectOffset" }
15911715local ICON_KEYS = { " style" , " bounce" , " bounceHeight" , " bounceSpeed" , " glow" , " glowAlpha" ,
15921716 " objectOwnLook" , " objectStyle" , " objectBounce" , " objectGlow" }
1593- local PROGRESS_KEYS = { " progress" , " objectProgress" , " progressAttach" , " progressFloat" , " progressSize" , " progressFont" ,
1717+ local PROGRESS_KEYS = { " progress" , " objectProgress" , " progressPulse " , " progressAttach" , " progressFloat" , " progressSize" , " progressFont" ,
15941718 " progressOutline" , " progressColor" , " progressFormat" , " progressShadow" , " progressX" , " progressY" }
1595- local BEHAVIOR_KEYS = { " colorByType" , " combat" , " minimap" , " minimapAngle" , " sound" , " soundChoice" }
1719+ local BEHAVIOR_KEYS = { " colorByType" , " combat" , " minimap" , " minimapAngle" , " sound" , " soundChoice" ,
1720+ " doneCheck" , " readyAlert" , " minimapSummary" }
15961721
15971722local function ResetKeys (keys )
15981723 for _ , key in ipairs (keys ) do db [key ] = DEFAULTS [key ] end
@@ -1699,6 +1824,7 @@ local function BuildProgressTab(tab)
16991824 function (value ) return L [" COLOR_" .. value ] end , Choice (" progressColor" ), SetChoice (" progressColor" ),
17001825 COL2 + 4 , TOP - 162 , COLUMN_DROPDOWN ))
17011826 GateCheck (ProgressOn , AddCheck (tab , " TEXT_SHADOW" , " TEXT_SHADOW_TIP" , " progressShadow" , COL1 , TOP - 244 ))
1827+ GateCheck (ProgressOn , AddCheck (tab , " PROGRESS_PULSE" , " PROGRESS_PULSE_TIP" , " progressPulse" , COL2 , TOP - 244 ))
17021828
17031829 -- Attached, the text is glued to the icon: X/Y only apply when it stands on its own.
17041830 local function FreeTextOn () return ProgressOn () and not db .progressAttach end
@@ -1707,9 +1833,22 @@ local function BuildProgressTab(tab)
17071833end
17081834
17091835local function BuildIconTab (tab )
1836+ -- Quick themes: one click sets size, float, glow and text size (the icon itself stays).
1837+ local THEMES = {
1838+ classic = { scale = 1.5 , objectScale = 1.5 , bounce = true , bounceHeight = 7 , bounceSpeed = 0.9 , glow = false , glowAlpha = 0.55 , progressSize = 13 },
1839+ subtle = { scale = 1.0 , objectScale = 1.0 , bounce = false , glow = false , progressSize = 11 },
1840+ flashy = { scale = 2.0 , objectScale = 2.0 , bounce = true , bounceHeight = 12 , bounceSpeed = 0.7 , glow = true , glowAlpha = 0.85 , progressSize = 15 },
1841+ }
1842+ local THEME_ORDER = { " classic" , " subtle" , " flashy" }
17101843 AddResetTabButton (tab , function () ResetKeys (ICON_KEYS ) end )
17111844 Gate (AnyIconOn , AddHeading (tab , " ICON_STYLE" , COL1 , TOP ))
17121845 Gate (AnyIconOn , AddIconPicker (tab , COL1 + 4 , TOP - 18 ))
1846+ Gate (AnyIconOn , AddDropdown (tab , " QUICK_THEME" , THEME_ORDER , function (value ) return L [" THEME_" .. value ] end ,
1847+ function () return nil end ,
1848+ function (value )
1849+ for key , v in pairs (THEMES [value ]) do db [key ] = v end
1850+ AfterReset ()
1851+ end , COL2 + 4 , TOP , COLUMN_DROPDOWN ))
17131852
17141853 local y = TOP - 82
17151854 GateCheck (AnyIconOn , AddSectionCheck (tab , " FLOAT" , " bounce" , COL1 , y ))
@@ -1764,13 +1903,19 @@ local function BuildBehaviorTab(tab)
17641903 function (value ) return L [" SOUND_" .. value ] end ,
17651904 function () return db .soundChoice end ,
17661905 function (value ) db .soundChoice = value ; PlayQuestSound () end ,
1767- COL2 + 4 , TOP - 104 , 140 ))
1906+ COL2 + 4 , TOP - 104 , 140 , nil ,
1907+ function (value ) if PlaySound then pcall (PlaySound , QUEST_SOUNDS [value ], " Master" ) end end ))
17681908 local test = CreateFrame (" Button" , nil , tab , " UIPanelButtonTemplate" )
17691909 test :SetSize (70 , 22 )
17701910 test :SetPoint (" TOPLEFT" , COL2 + 152 , TOP - 123 )
17711911 Loc (test , " SOUND_TEST" )
17721912 test :SetScript (" OnClick" , PlayQuestSound )
17731913 Gate (SoundOn , test )
1914+
1915+ GateCheck (AnyIconOn , AddCheck (tab , " DONE_CHECK" , " DONE_CHECK_TIP" , " doneCheck" , COL1 , TOP - 160 ))
1916+ GateCheck (AddonOn , AddCheck (tab , " READY_ALERT" , " READY_ALERT_TIP" , " readyAlert" , COL1 , TOP - 208 ))
1917+ GateCheck (function () return db .minimap end ,
1918+ AddCheck (tab , " MINIMAP_SUMMARY" , " MINIMAP_SUMMARY_TIP" , " minimapSummary" , COL2 , TOP - 160 ))
17741919end
17751920
17761921-- Profiles tab in the Ace3 layout players know from RareScanner and many others: intro, reset,
@@ -1992,7 +2137,7 @@ local SETTINGS_SECTIONS = {
19922137 { key = " TAB_DISPLAY" , build = BuildDisplayTab , height = 258 },
19932138 { key = " TAB_ICON" , build = BuildIconTab , height = 312 },
19942139 { key = " TAB_PROGRESS" , build = BuildProgressTab , height = 340 },
1995- { key = " TAB_BEHAVIOR" , build = BuildBehaviorTab , height = 152 },
2140+ { key = " TAB_BEHAVIOR" , build = BuildBehaviorTab , height = 262 },
19962141}
19972142local SECTION_GAP = 18
19982143local CONTENT_WIDTH = 600 -- until the scroll frame reports its real width
0 commit comments