Skip to content

Commit

Permalink
Classic: Added an option to update threat status more frequent (ticke…
Browse files Browse the repository at this point in the history
…t #1033)
  • Loading branch information
michaelnpsp committed Aug 18, 2021
1 parent 9f24768 commit be7a6b2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Options/modules/statuses/StatusThreat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ Grid2Options:RegisterStatusOptions("threat", "combat", function(self, status, op
status:UpdateDB()
end,
}
if Grid2.isClassic then
options.frequentUpdates = {
type = "toggle",
name = L["Frequent updates"],
desc = L["Update threat status more frequent."],
width = "full",
order = 34,
get = function () return status.dbx.frequentUpdates end,
set = function (_, v)
local enabled = status.enabled
if enabled then status:OnDisable() end
status.dbx.frequentUpdates = v or nil
if enabled then status:OnEnable() end
end,
}
end
end, {
color1 = L["Not Tanking"],
colorDesc1 = L["Higher threat than tank."],
Expand Down
11 changes: 10 additions & 1 deletion modules/StatusThreat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ local Grid2 = Grid2
local UnitExists = UnitExists
local UnitThreatSituation = UnitThreatSituation

local unit_is_valid = Grid2.roster_guids

local colors
local activeValue

function Threat:UpdateUnit(_, unit)
if unit then -- unit can be nil which is so wtf
if unit_is_valid[unit or 0] then -- unit can be nil which is so wtf
self:UpdateIndicators(unit)
end
end
Expand All @@ -17,11 +19,18 @@ function Threat:OnEnable()
self:UpdateDB()
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", "UpdateUnit")
self:RegisterEvent("ZONE_CHANGED_NEW_AREA", "UpdateAllUnits")
if Grid2.isClassic and self.dbx.frequentUpdates then
self:RegisterEvent("UNIT_HEALTH_FREQUENT", "UpdateUnit")
end

end

function Threat:OnDisable()
self:UnregisterEvent("UNIT_THREAT_SITUATION_UPDATE")
self:UnregisterEvent("ZONE_CHANGED_NEW_AREA")
if Grid2.isClassic and self.dbx.frequentUpdates then
self:UnregisterEvent("UNIT_HEALTH_FREQUENT")
end
end

function Threat:UpdateDB()
Expand Down

0 comments on commit be7a6b2

Please sign in to comment.