diff --git a/HealerInRange.lua b/HealerInRange.lua index 1897430..3dbcbe0 100644 --- a/HealerInRange.lua +++ b/HealerInRange.lua @@ -3,6 +3,7 @@ local _, NS = ... local Interface = NS.Interface local CreateFrame = CreateFrame +local IsInInstance = IsInInstance ---@type HIR local HIR = NS.HIR @@ -95,13 +96,21 @@ local DEAD_EVENTS = { function HIR:PLAYER_ENTERING_WORLD() FrameUtil.RegisterFrameForEvents(HIRFrame, DEAD_EVENTS) - if NS.isInGroup() then - if NS.isDead() then - Interface.textFrame:SetAlpha(0) - else - if NS.db.global.healer then - if NS.isHealer("player") then - Interface.textFrame:SetAlpha(0) + if IsInInstance() then + if NS.isInGroup() then + if NS.isDead() then + Interface.textFrame:SetAlpha(0) + else + if NS.db.global.healer then + if NS.isHealer("player") then + Interface.textFrame:SetAlpha(0) + else + if NS.noHealersInGroup() then + Interface.textFrame:SetAlpha(0) + else + Interface.textFrame:SetAlpha(1) + end + end else if NS.noHealersInGroup() then Interface.textFrame:SetAlpha(0) @@ -109,11 +118,31 @@ function HIR:PLAYER_ENTERING_WORLD() Interface.textFrame:SetAlpha(1) end end - else - if NS.noHealersInGroup() then + end + end + else + if NS.db.global.showOutside then + if NS.isInGroup() then + if NS.isDead() then Interface.textFrame:SetAlpha(0) else - Interface.textFrame:SetAlpha(1) + if NS.db.global.healer then + if NS.isHealer("player") then + Interface.textFrame:SetAlpha(0) + else + if NS.noHealersInGroup() then + Interface.textFrame:SetAlpha(0) + else + Interface.textFrame:SetAlpha(1) + end + end + else + if NS.noHealersInGroup() then + Interface.textFrame:SetAlpha(0) + else + Interface.textFrame:SetAlpha(1) + end + end end end end diff --git a/config.lua b/config.lua index 5eb6adf..73be8c9 100644 --- a/config.lua +++ b/config.lua @@ -19,6 +19,7 @@ local CreateFrame = CreateFrame ---@field test boolean ---@field reverse boolean ---@field healer boolean +---@field showOutside boolean ---@field fontsize number ---@field font string ---@field color ColorArray @@ -58,6 +59,7 @@ NS.DefaultDatabase = { test = true, reverse = false, healer = true, + showOutside = false, fontsize = 30, font = "Friz Quadrata TT", color = { diff --git a/helpers.lua b/helpers.lua index 3d4cb0d..0111eb6 100644 --- a/helpers.lua +++ b/helpers.lua @@ -13,6 +13,8 @@ local type = type local next = next local setmetatable = setmetatable local getmetatable = getmetatable +local print = print +local IsInInstance = IsInInstance local wipe = table.wipe local sformat = string.format @@ -94,17 +96,35 @@ NS.UpdateFont = function(frame) end NS.ToggleVisibility = function(inRange, reverse) - if inRange then - if reverse then - NS.Interface:ShowText(false) + if IsInInstance() then + if inRange then + if reverse then + NS.Interface:ShowText(false) + else + NS.Interface:ShowText(true) + end else - NS.Interface:ShowText(true) + if reverse then + NS.Interface:ShowText(true) + else + NS.Interface:ShowText(false) + end end else - if reverse then - NS.Interface:ShowText(true) - else - NS.Interface:ShowText(false) + if NS.db.global.showOutside then + if inRange then + if reverse then + NS.Interface:ShowText(false) + else + NS.Interface:ShowText(true) + end + else + if reverse then + NS.Interface:ShowText(true) + else + NS.Interface:ShowText(false) + end + end end end end diff --git a/interface.lua b/interface.lua index 0182b8b..3cc9933 100644 --- a/interface.lua +++ b/interface.lua @@ -2,6 +2,7 @@ local AddonName, NS = ... local CreateFrame = CreateFrame local LibStub = LibStub +local IsInInstance = IsInInstance local AceConfigDialog = LibStub("AceConfigDialog-3.0") @@ -96,13 +97,21 @@ function Interface:CreateInterface() TextFrame:SetWidth(Text:GetStringWidth()) TextFrame:SetHeight(Text:GetStringHeight()) - if NS.isInGroup() then - if NS.isDead() then - TextFrame:Hide() - else - if NS.db.global.healer then - if NS.isHealer("player") then - TextFrame:Hide() + if IsInInstance() then + if NS.isInGroup() then + 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() @@ -110,19 +119,53 @@ function Interface:CreateInterface() TextFrame:Show() end end + end + else + if NS.db.global.test then + TextFrame:Show() else - if NS.noHealersInGroup() then - TextFrame:Hide() - else - TextFrame:Show() - end + TextFrame:Hide() end end else if NS.db.global.test then TextFrame:Show() else - TextFrame:Hide() + if NS.db.global.test then + TextFrame:Show() + else + if NS.db.global.showOutside then + if NS.isInGroup() then + 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 + end + end end end end @@ -132,13 +175,27 @@ function Interface:ShowText(value) if NS.isInGroup() then if value then Interface.textFrame:Show() + if IsInInstance() then + if NS.isInGroup() then + if value then + Interface.textFrame:Show() - if NS.isDead() then - Interface.textFrame:SetAlpha(0) else if NS.db.global.healer then if NS.isHealer("player") then - Interface.textFrame:SetAlpha(0) + if NS.isDead() then + Interface.textFrame:SetAlpha(0) + else + if NS.db.global.healer then + if NS.isHealer("player") then + Interface.textFrame:SetAlpha(0) + else + if NS.noHealersInGroup() then + Interface.textFrame:SetAlpha(0) + else + Interface.textFrame:SetAlpha(1) + end + end else if NS.noHealersInGroup() then Interface.textFrame:SetAlpha(0) @@ -146,23 +203,60 @@ function Interface:ShowText(value) Interface.textFrame:SetAlpha(1) end end - else - if NS.noHealersInGroup() then - Interface.textFrame:SetAlpha(0) - else - Interface.textFrame:SetAlpha(1) - end end + else + Interface.textFrame:Hide() end else - Interface.textFrame:Hide() + if NS.db.global.test then + Interface.textFrame:Show() + Interface.textFrame:SetAlpha(1) + else + Interface.textFrame:Hide() + end end else if NS.db.global.test then Interface.textFrame:Show() - Interface.textFrame:SetAlpha(1) else - Interface.textFrame:Hide() + if NS.db.global.showOutside then + if NS.isInGroup() then + if value then + Interface.textFrame:Show() + + if NS.isDead() then + Interface.textFrame:SetAlpha(0) + else + if NS.db.global.healer then + if NS.isHealer("player") then + Interface.textFrame:SetAlpha(0) + else + if NS.noHealersInGroup() then + Interface.textFrame:SetAlpha(0) + else + Interface.textFrame:SetAlpha(1) + end + end + else + if NS.noHealersInGroup() then + Interface.textFrame:SetAlpha(0) + else + Interface.textFrame:SetAlpha(1) + end + end + end + else + Interface.textFrame:Hide() + end + else + if NS.db.global.test then + Interface.textFrame:Show() + Interface.textFrame:SetAlpha(1) + else + Interface.textFrame:Hide() + end + end + end end end end diff --git a/options.lua b/options.lua index 1c7e4d7..bb411a2 100644 --- a/options.lua +++ b/options.lua @@ -3,7 +3,10 @@ local AddonName, NS = ... local CopyTable = CopyTable local next = next local LibStub = LibStub +local IsInInstance = IsInInstance +local AceConfig = LibStub("AceConfig-3.0") +local AceConfigDialog = LibStub("AceConfigDialog-3.0") local SharedMedia = LibStub("LibSharedMedia-3.0") ---@type HIR @@ -90,11 +93,31 @@ NS.AceConfig = { return NS.db.global.healer end, }, + showOutside = { + name = "Show outside of instances", + type = "toggle", + width = "double", + order = 5, + set = function(_, val) + NS.db.global.showOutside = val + if not IsInInstance() then + if val then + local inRange = NS.isHealerInRange() + NS.ToggleVisibility(inRange, val) + else + NS.Interface.textFrame:SetAlpha(0) + end + end + end, + get = function(_) + return NS.db.global.showOutside + end, + }, fontsize = { type = "range", name = "Font Size", width = "double", - order = 5, + order = 6, min = 2, max = 64, step = 1, @@ -112,7 +135,7 @@ NS.AceConfig = { type = "select", name = "Font", width = "double", - order = 6, + order = 7, dialogControl = "LSM30_Font", values = SharedMedia:HashTable("font"), set = function(_, val) @@ -129,7 +152,7 @@ NS.AceConfig = { type = "color", name = "Color", width = "double", - order = 7, + order = 8, hasAlpha = true, set = function(_, val1, val2, val3, val4) NS.db.global.color.r = val1 @@ -142,19 +165,6 @@ NS.AceConfig = { return NS.db.global.color.r, NS.db.global.color.g, NS.db.global.color.b, NS.db.global.color.a end, }, - debug = { - name = "Toggle debug mode", - desc = "Turning this feature on prints debug messages to the chat window.", - type = "toggle", - width = "full", - order = 99, - set = function(_, val) - NS.db.global.debug = val - end, - get = function(_) - return NS.db.global.debug - end, - }, reset = { name = "Reset Everything", type = "execute", @@ -176,13 +186,13 @@ function Options:SlashCommands(message) NS.db.global.lock = false end else - LibStub("AceConfigDialog-3.0"):Open(AddonName) + AceConfigDialog:Open(AddonName) end end function Options:Setup() - LibStub("AceConfig-3.0"):RegisterOptionsTable(AddonName, NS.AceConfig) - LibStub("AceConfigDialog-3.0"):AddToBlizOptions(AddonName, AddonName) + AceConfig:RegisterOptionsTable(AddonName, NS.AceConfig) + AceConfigDialog:AddToBlizOptions(AddonName, AddonName) SLASH_HIR1 = AddonName SLASH_HIR2 = "/hir"