Skip to content

Commit

Permalink
new check for no healer in group and added multi healer tracking support
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgdevx committed Oct 16, 2024
1 parent 205c936 commit c6c35ae
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 41 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@
"table": "disable",
"utf8": "disable"
},
"Lua.workspace.library": ["~\\.vscode\\extensions\\ketho.wow-api-0.17.6\\Annotations"]
"Lua.workspace.library": [
"~\\.vscode\\extensions\\ketho.wow-api-0.17.6\\Annotations"
]
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Healer In Range

## [v1.1.1](https://github.com/rbgdevx/healer-in-range/releases/tag/v1.1.1) (2024-10-16)

- Adding check for if there is no healer in the group
- Bugfix for tracking multiple healers in group, would only track against the first healer found in the group unfortunately until now
- Updated checks to reduce ran code when not necessary and based on new logic
- Fixes reset everything db reference

## [v1.1.0](https://github.com/rbgdevx/healer-in-range/releases/tag/v1.1.0) (2024-09-06)

- Adding new setting to turn off if you are a healer or healer role in group
- Adding death support, hides while dead
- Refactor lib usage to match what im doing on BGWC addon to reduce needed libs and global db issues
- Made it so you can't open the settings when locked and right clicking the text
- Minor random changes based on learning from BGWC
Expand Down
54 changes: 37 additions & 17 deletions HealerInRange.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,34 @@ do
end

function HIR:CheckForHealerInRange()
local inRange = NS.isHealerInRange()
if NS.isInGroup() then
if NS.noHealersInGroup() then
NS.ToggleVisibility(false, false)

if not healerInRangeFrame then
healerInRangeFrame = CreateFrame("Frame")
--- @cast healerInRangeFrame HealerInRangeFrame
healerInRangeFrame.inRange = inRange
Interface.inRange = inRange
end
if healerInRangeFrame then
---@type HealerInRangeFrame
healerInRangeFrame:SetScript("OnUpdate", nil)
end
else
local inRange = NS.isHealerInRange()

if not healerInRangeFrame then
healerInRangeFrame = CreateFrame("Frame")
--- @cast healerInRangeFrame HealerInRangeFrame
healerInRangeFrame.inRange = inRange
Interface.inRange = inRange
end

NS.ToggleVisibility(inRange, NS.db.global.reverse)
NS.ToggleVisibility(inRange, NS.db.global.reverse)

if NS.isInGroup() then
---@type HealerInRangeFrame
healerInRangeFrame:SetScript("OnUpdate", InRangeChecker)
---@type HealerInRangeFrame
healerInRangeFrame:SetScript("OnUpdate", InRangeChecker)
end
else
---@type HealerInRangeFrame
healerInRangeFrame:SetScript("OnUpdate", nil)
if healerInRangeFrame then
---@type HealerInRangeFrame
healerInRangeFrame:SetScript("OnUpdate", nil)
end

if NS.db.global.test then
Interface.textFrame:Show()
Expand All @@ -63,6 +74,7 @@ do
end

function HIR:GROUP_ROSTER_UPDATE()
NS.Debug("GROUP_ROSTER_UPDATE")
self:CheckForHealerInRange()
end
end
Expand Down Expand Up @@ -91,16 +103,24 @@ function HIR:PLAYER_ENTERING_WORLD()
if NS.isHealer("player") then
Interface.textFrame:SetAlpha(0)
else
Interface.textFrame:SetAlpha(1)
if NS.noHealersInGroup() then
Interface.textFrame:SetAlpha(0)
else
Interface.textFrame:SetAlpha(1)
end
end
else
Interface.textFrame:SetAlpha(1)
if NS.noHealersInGroup() then
Interface.textFrame:SetAlpha(0)
else
Interface.textFrame:SetAlpha(1)
end
end
end

self:CheckForHealerInRange()
end

self:CheckForHealerInRange()

HIRFrame:RegisterEvent("GROUP_ROSTER_UPDATE")
end

Expand Down
34 changes: 26 additions & 8 deletions helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ local sformat = string.format

local LSM = LibStub("LibSharedMedia-3.0")

NS.Debug = function(...)
if NS.db.global.debug then
print(...)
end
end

NS.isDead = function()
return UnitIsDeadOrGhost("player")
end
Expand Down Expand Up @@ -52,17 +58,29 @@ NS.isHealerInRange = function()
if NS.isHealer("player") then
return true
else
local count = 0
for unit in NS.IterateGroupMembers() do
if unit then
if NS.isHealer(unit) then
if UnitInRange(unit) then
return true
else
return false
end
end
if unit and NS.isHealer(unit) and UnitInRange(unit) then
count = count + 1
end
end
if count > 0 then
return true
end
return false
end
end

NS.noHealersInGroup = function()
if NS.isHealer("player") then
return false
else
for unit in NS.IterateGroupMembers() do
if unit and NS.isHealer(unit) then
return false
end
end
return true
end
end

Expand Down
45 changes: 31 additions & 14 deletions interface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,34 @@ function Interface:CreateInterface()
TextFrame:SetHeight(Text:GetStringHeight())

if NS.isInGroup() then
local inRange = NS.isHealerInRange()
NS.ToggleVisibility(inRange, NS.db.global.reverse)
if NS.isDead() then
TextFrame:Hide()
else
if NS.db.global.healer then
if NS.isHealer("player") then
TextFrame:Hide()
else
if NS.noHealersInGroup() then
TextFrame:Hide()
else
TextFrame:Show()
end
end
else
if NS.noHealersInGroup() then
TextFrame:Hide()
else
TextFrame:Show()
end
end
end
else
if NS.db.global.test then
TextFrame:Show()
else
TextFrame:Hide()
end
end

if NS.db.global.healer then
if NS.isInGroup() and NS.isHealer("player") then
TextFrame:SetAlpha(0)
else
TextFrame:SetAlpha(1)
end
else
TextFrame:SetAlpha(1)
end
end
end

Expand All @@ -121,10 +130,18 @@ function Interface:ShowText(value)
if NS.isHealer("player") then
Interface.textFrame:SetAlpha(0)
else
Interface.textFrame:SetAlpha(1)
if NS.noHealersInGroup() then
Interface.textFrame:SetAlpha(0)
else
Interface.textFrame:SetAlpha(1)
end
end
else
Interface.textFrame:SetAlpha(1)
if NS.noHealersInGroup() then
Interface.textFrame:SetAlpha(0)
else
Interface.textFrame:SetAlpha(1)
end
end
end
else
Expand Down
3 changes: 2 additions & 1 deletion options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ NS.AceConfig = {
if NS.isInGroup() == false then
if val then
NS.Interface.textFrame:Show()
NS.Interface.textFrame:SetAlpha(1)
else
NS.Interface.textFrame:Hide()
end
Expand Down Expand Up @@ -158,7 +159,7 @@ NS.AceConfig = {
width = "normal",
order = 100,
func = function()
BattlegroundWinConditionsDB = CopyTable(NS.DefaultDatabase)
HIRDB = CopyTable(NS.DefaultDatabase)
NS.db = CopyTable(NS.DefaultDatabase)
end,
},
Expand Down

0 comments on commit c6c35ae

Please sign in to comment.