From e0cfa50e615baca6ab270b72c7134f50fab1e2ff Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Sun, 28 Jul 2024 18:55:50 -0300 Subject: [PATCH] Fixed an issue with the tracker not being responsible when completing a world quest --- WorldQuestTracker_Tracker.lua | 52 ++++++++++++++++++++++++----------- libs/DF/definitions.lua | 1 + libs/DF/fw.lua | 10 +++++-- libs/DF/schedules.lua | 22 +++++++++++++++ luaserver.lua | 19 ++++++++++++- 5 files changed, 85 insertions(+), 19 deletions(-) diff --git a/WorldQuestTracker_Tracker.lua b/WorldQuestTracker_Tracker.lua index f81498e2..4b2db64a 100644 --- a/WorldQuestTracker_Tracker.lua +++ b/WorldQuestTracker_Tracker.lua @@ -1464,20 +1464,6 @@ function WorldQuestTracker.UpdateQuestsInArea() end ---ao completar uma world quest remover a quest do tracker e da refresh nos widgets -hooksecurefunc(BonusObjectiveTracker, "OnQuestTurnedIn", function(self, questID) - for i = #WorldQuestTracker.QuestTrackList, 1, -1 do - if (WorldQuestTracker.QuestTrackList[i].questID == questID) then - tremove (WorldQuestTracker.QuestTrackList, i) - WorldQuestTracker.RefreshTrackerWidgets() - break - end - end -end) - - - - -- ~blizzard objective tracker function WorldQuestTracker.IsQuestOnObjectiveTracker (quest) local tracker = ObjectiveTrackerFrame @@ -1521,11 +1507,12 @@ local onObjectiveTrackerChanges = function() --this will be called several times local objectiveTrackerHeight = 0 for moduleFrame in pairs (ObjectiveTrackerManager.moduleToContainerMap) do - if (type(moduleFrame) == "table" and moduleFrame.GetObjectType and moduleFrame:GetObjectType() == "Frame") then + if (type(moduleFrame) == "table" and moduleFrame.GetObjectType and moduleFrame:GetObjectType() == "Frame" and moduleFrame:IsShown()) then objectiveTrackerHeight = objectiveTrackerHeight + moduleFrame:GetHeight() end end - WorldQuestTracker.TrackerHeight = objectiveTrackerHeight + 10 + WorldQuestTracker.TrackerHeight = objectiveTrackerHeight + 50 + WorldQuestTracker.RefreshTrackerAnchor() --need to refresh again on next tick due to some modules being updated after the tracker @@ -1563,6 +1550,39 @@ else end) end +--ao completar uma world quest remover a quest do tracker e da refresh nos widgets +hooksecurefunc(BonusObjectiveTracker, "OnQuestTurnedIn", function(self, questID) + for i = #WorldQuestTracker.QuestTrackList, 1, -1 do + if (WorldQuestTracker.QuestTrackList[i].questID == questID) then + local questRemoved = tremove(WorldQuestTracker.QuestTrackList, i) + WorldQuestTracker.RefreshTrackerWidgets() + onObjectiveTrackerChanges() + break + end + end +end) + +local questEventFrame = CreateFrame("frame") +questEventFrame:RegisterEvent("QUEST_TURNED_IN") +questEventFrame:SetScript("OnEvent", function(self, event, ...) + C_Timer.After(0, onObjectiveTrackerChanges) +end) + +hooksecurefunc(C_SuperTrack, "SetSuperTrackedQuestID", function() + C_Timer.After(0, onObjectiveTrackerChanges) +end) + +hooksecurefunc(QuestUtil, "TrackWorldQuest", function() + C_Timer.After(0, onObjectiveTrackerChanges) +end) + +hooksecurefunc(QuestUtil, "UntrackWorldQuest", function() + C_Timer.After(0, onObjectiveTrackerChanges) +end) + + + + --[=[ ["1"] = "ReleaseFrame", ["2"] = "ShowRewardsToast", diff --git a/libs/DF/definitions.lua b/libs/DF/definitions.lua index 489e2a21..0c9ad3fe 100644 --- a/libs/DF/definitions.lua +++ b/libs/DF/definitions.lua @@ -167,6 +167,7 @@ ---@field UnitGroupRolesAssigned fun(unitId: unit, bUseSupport:boolean?, specId: specializationid?) : string there's no self here ---@field IsDragonflight fun():boolean ---@field IsDragonflightAndBeyond fun():boolean +---@field IsDragonflightOrBelow fun():boolean ---@field IsTimewalkWoW fun():boolean ---@field IsClassicWow fun():boolean ---@field IsTBCWow fun():boolean diff --git a/libs/DF/fw.lua b/libs/DF/fw.lua index a2ff0618..85d438ce 100644 --- a/libs/DF/fw.lua +++ b/libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 551 +local dversion = 552 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary(major, minor) @@ -113,7 +113,13 @@ end ---return if the wow version the player is playing is dragonflight or an expansion after it ---@return boolean function DF.IsDragonflightAndBeyond() - return select(4, GetBuildInfo()) >= 100000 + return 110000 >= 100000 +end + +---return true if the wow version is Dragonflight or below +---@return boolean +function DF.IsDragonflightOrBelow() + return 110000 < 110000 end ---return if the wow version the player is playing is a classic version of wow diff --git a/libs/DF/schedules.lua b/libs/DF/schedules.lua index 8666ec2d..20cc8e11 100644 --- a/libs/DF/schedules.lua +++ b/libs/DF/schedules.lua @@ -268,6 +268,28 @@ function detailsFramework.Schedules.AfterById(time, callback, id, ...) return newTimer end +--Schedules a callback function to be executed after a specified time delay. +--It uniquely identifies each scheduled task by an ID, if another schedule with the same id is made, it will be ignore until the previous one is finished. +function detailsFramework.Schedules.AfterByIdNoCancel(time, callback, id, ...) + if (not detailsFramework.Schedules.ExecuteTimerTableNoCancel) then + detailsFramework.Schedules.ExecuteTimerTableNoCancel = {} + end + + local alreadyHaveTimer = detailsFramework.Schedules.ExecuteTimerTableNoCancel[id] + if (alreadyHaveTimer) then + return + end + + local newTimer = detailsFramework.Schedules.NewTimer(time, callback, ...) + detailsFramework.Schedules.ExecuteTimerTableNoCancel[id] = newTimer + + C_Timer.After(time, function() + detailsFramework.Schedules.ExecuteTimerTableNoCancel[id] = nil + end) + + return newTimer +end + --schedule a function to be called after 'time' --prompt example: create a schedule that runs the function 'variable name' after 'time' amount of seconds function detailsFramework.Schedules.After(time, callback) diff --git a/luaserver.lua b/luaserver.lua index 08b01c0a..72cfa2a8 100644 --- a/luaserver.lua +++ b/luaserver.lua @@ -278,6 +278,13 @@ function LibStub:IterateLibraries()end ---@field spellID number ---@field originalIconID number +---@class spellchargeinfo +---@field currentCharges number +---@field maxCharges number +---@field cooldownStartTime number +---@field cooldownDuration number +---@field chargeModRate number + ---@class privateaura_anchor : table ---@field unitToken unit ---@field auraIndex number @@ -1719,6 +1726,15 @@ function bit.ror(x, y) return 0 end ---@return number function GetServerTime() return 0 end +C_Spell = {} + +---@param spellID number +---@return spellinfo +function C_Spell.GetSpellInfo(spellID) return {} end + +---@param spellID number +---@return spellchargeinfo +function C_Spell.GetSpellCharges(spellID) return {} end C_Timer = {} ---@param delay number @@ -5294,8 +5310,9 @@ IsAttackSpell = function(spellId) return true end IsAutoRepeatSpell = function(spellId) return true end ---@param spellId number +---@param spellBank string ---@return boolean -IsPassiveSpell = function(spellId) return true end +IsPassiveSpell = function(spellId, spellBank) return true end ---@param spellName string ---@param target string