@@ -255,6 +255,101 @@ local function BuildQuestIdsText(questIds)
255255 return table.concat (values , " , " )
256256end
257257
258+ local function FormatQuestMoneyReward (copper )
259+ copper = tonumber (copper ) or 0
260+ if GetMoneyString then
261+ return GetMoneyString (copper , true )
262+ end
263+
264+ return string.format (" %dg" , math.floor (copper / 10000 ))
265+ end
266+
267+ local function HasLoadedQuestRewardData (questId )
268+ if HaveQuestRewardData then
269+ local ok , loaded = pcall (HaveQuestRewardData , questId )
270+ if ok then
271+ return loaded == true
272+ end
273+ end
274+
275+ if C_QuestLog and C_QuestLog .HasQuestRewardData then
276+ local ok , loaded = pcall (C_QuestLog .HasQuestRewardData , questId )
277+ if ok then
278+ return loaded == true
279+ end
280+ end
281+
282+ return true
283+ end
284+
285+ local function RequestQuestRewardData (questId )
286+ if C_TaskQuest and C_TaskQuest .RequestPreloadRewardData then
287+ pcall (C_TaskQuest .RequestPreloadRewardData , questId )
288+ end
289+
290+ if C_QuestLog and C_QuestLog .RequestLoadQuestByID then
291+ pcall (C_QuestLog .RequestLoadQuestByID , questId )
292+ end
293+ end
294+
295+ local function QueueRewardRefresh ()
296+ if not (MR and MR .ScheduleTimer ) or MR ._customTaskRewardRefreshTimer then
297+ return
298+ end
299+
300+ MR ._customTaskRewardRefreshTimer = MR :ScheduleTimer (function ()
301+ MR ._customTaskRewardRefreshTimer = nil
302+ if MR .RefreshCustomTasksModule then
303+ MR :RefreshCustomTasksModule ()
304+ end
305+ if MR .RefreshUI then
306+ MR :RefreshUI ()
307+ end
308+ end , 1.5 )
309+ end
310+
311+ local function GetQuestMoneyReward (questId )
312+ if GetQuestLogRewardMoney then
313+ local ok , money = pcall (GetQuestLogRewardMoney , questId )
314+ if ok and type (money ) == " number" and money > 0 then
315+ return money
316+ end
317+ end
318+
319+ if C_QuestLog and C_QuestLog .GetQuestRewardMoney then
320+ local ok , money = pcall (C_QuestLog .GetQuestRewardMoney , questId )
321+ if ok and type (money ) == " number" and money > 0 then
322+ return money
323+ end
324+ end
325+
326+ return 0
327+ end
328+
329+ local function GetQuestRewardSummary (questIds )
330+ if type (questIds ) ~= " table" or # questIds == 0 then
331+ return 0 , false
332+ end
333+
334+ local totalMoney = 0
335+ local pending = false
336+
337+ for _ , questId in ipairs (questIds ) do
338+ if not HasLoadedQuestRewardData (questId ) then
339+ pending = true
340+ RequestQuestRewardData (questId )
341+ else
342+ totalMoney = totalMoney + GetQuestMoneyReward (questId )
343+ end
344+ end
345+
346+ if pending then
347+ QueueRewardRefresh ()
348+ end
349+
350+ return totalMoney , pending
351+ end
352+
258353local function NormalizeBoolean (value )
259354 return value == true
260355end
@@ -395,6 +490,8 @@ local function BuildSectionRows(rows, tasks, resetType, headerKey, addKey, heade
395490 or (L [" CustomTasks_ResetWeekly" ] or " Weekly reset" )
396491 local questIds = NormalizeQuestIds (task .questIds )
397492 local questIdText = BuildQuestIdsText (questIds )
493+ local rewardCopper = GetQuestRewardSummary (questIds )
494+ local rewardText = rewardCopper and rewardCopper > 0 and FormatQuestMoneyReward (rewardCopper ) or nil
398495 local encounterIds = NormalizeEncounterIds (task .encounterIds )
399496 local encounterIdText = BuildEncounterIdsText (encounterIds )
400497 local noteText
@@ -409,14 +506,18 @@ local function BuildSectionRows(rows, tasks, resetType, headerKey, addKey, heade
409506 )
410507 )
411508 elseif questIds then
509+ local questNote = string.format (
510+ L [" CustomTasks_QuestNote" ] or " Auto-tracks quest completion for quest ID%s %s. Shift-left-click to edit. Shift-right-click to delete." ,
511+ (# questIds == 1 ) and " " or " s" ,
512+ questIdText or " "
513+ )
514+ if rewardText then
515+ questNote = string.format (" %s\n Gold reward: %s" , questNote , rewardText )
516+ end
412517 noteText = string.format (
413518 " %s\n %s" ,
414519 resetLabel ,
415- string.format (
416- L [" CustomTasks_QuestNote" ] or " Auto-tracks quest completion for quest ID%s %s. Shift-left-click to edit. Shift-right-click to delete." ,
417- (# questIds == 1 ) and " " or " s" ,
418- questIdText or " "
419- )
520+ questNote
420521 )
421522 else
422523 noteText = string.format (
@@ -432,9 +533,11 @@ local function BuildSectionRows(rows, tasks, resetType, headerKey, addKey, heade
432533 if diffCount >= 2 then effectiveMax = diffCount end
433534 rows [# rows + 1 ] = {
434535 key = rowKey ,
435- label = task .label ,
536+ label = rewardText and ( " |cffffd36a " .. task . label .. " |r " ) or task .label ,
436537 max = effectiveMax ,
437538 note = noteText ,
539+ countText = rewardText ,
540+ countColor = rewardText and { 1.00 , 0.82 , 0.30 } or nil ,
438541 toggleStatus = (task .max <= 1 ) and ((not questIds ) or task .allowManualQuestClicks ) and (not encounterIds ),
439542 questIds = questIds ,
440543 encounterIds = encounterIds ,
@@ -464,6 +567,9 @@ local function BuildSectionRows(rows, tasks, resetType, headerKey, addKey, heade
464567 ),
465568 0.70 , 0.90 , 0.70 , true
466569 )
570+ if rewardText then
571+ tip :AddLine (" Gold reward: " .. rewardText , 1.00 , 0.82 , 0.30 , true )
572+ end
467573 if task .allowManualQuestClicks then
468574 tip :AddLine (L [" CustomTasks_QuestManualHint" ] or " Manual clicking is enabled for this quest task." , 0.95 , 0.82 , 0.50 , true )
469575 end
0 commit comments