Skip to content

Commit 2e9efeb

Browse files
committed
Quest ID tracking updated / Mainframe Fix
* Fixed how the main frame was stuttering * Added auto detection to work better for quest IDS
1 parent 614ae7a commit 2e9efeb

3 files changed

Lines changed: 128 additions & 14 deletions

File tree

Modules/CustomTasks.lua

Lines changed: 112 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,101 @@ local function BuildQuestIdsText(questIds)
255255
return table.concat(values, ", ")
256256
end
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+
258353
local function NormalizeBoolean(value)
259354
return value == true
260355
end
@@ -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\nGold 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

Theme.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ local SCRIPT_FONTS = {
7676
}
7777

7878
local SCRIPT_RANGES = {
79-
{ 0x0400, 0x04FF, "ruRU" },
80-
{ 0x1100, 0x11FF, "koKR" },
81-
{ 0x3130, 0x318F, "koKR" },
82-
{ 0x3400, 0x4DBF, nil },
83-
{ 0x4E00, 0x9FFF, nil },
84-
{ 0xAC00, 0xD7AF, "koKR" },
85-
{ 0xF900, 0xFAFF, nil },
79+
{ 0x0400, 0x04FF, "ruRU" },
80+
{ 0x1100, 0x11FF, "koKR" },
81+
{ 0x3130, 0x318F, "koKR" },
82+
{ 0x3400, 0x4DBF, nil },
83+
{ 0x4E00, 0x9FFF, nil },
84+
{ 0xAC00, 0xD7AF, "koKR" },
85+
{ 0xF900, 0xFAFF, nil },
8686
}
8787

8888
local function DetectScriptFont(text)

UI.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4585,6 +4585,10 @@ local function ApplyMainFrameAnchor(frame, anchorMode, preserveScreenPosition)
45854585
return
45864586
end
45874587

4588+
if MR and MR._mainFrameDragging then
4589+
return
4590+
end
4591+
45884592
local pos = preserveScreenPosition and CaptureMainFrameAnchor(frame, anchorMode) or GetStoredMainFrameActiveAnchor()
45894593
if not pos or not pos.point then
45904594
frame:ClearAllPoints()
@@ -4786,7 +4790,10 @@ function MR:BuildUI()
47864790
titleBar:EnableMouse(true)
47874791
titleBar:RegisterForDrag("LeftButton")
47884792
titleBar:SetScript("OnDragStart", function()
4789-
if not MR.db.profile.locked then f:StartMoving() end
4793+
if not MR.db.profile.locked then
4794+
MR._mainFrameDragging = true
4795+
f:StartMoving()
4796+
end
47904797
end)
47914798
titleBar:SetScript("OnDragStop", function()
47924799
f:StopMovingOrSizing()
@@ -4797,6 +4804,7 @@ function MR:BuildUI()
47974804
MR._mainFrameMovedSinceExpand = true
47984805
end
47994806
end
4807+
MR._mainFrameDragging = false
48004808
end)
48014809
if MR.ApplyPanelHeaderAutoHide then MR:ApplyPanelHeaderAutoHide(f, titleBar) end
48024810

0 commit comments

Comments
 (0)