diff --git a/.vscode/settings.json b/.vscode/settings.json index 68cabda..925bc87 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -51,5 +51,5 @@ "table": "disable", "utf8": "disable" }, - "Lua.workspace.library": ["c:\\Users\\17186\\.cursor\\extensions\\ketho.wow-api-0.17.6\\Annotations"] + "Lua.workspace.library": ["~\\.vscode\\extensions\\ketho.wow-api-0.17.6\\Annotations"] } diff --git a/AutoBodyRes.lua b/AutoBodyRes.lua index 05f2505..0a658cb 100644 --- a/AutoBodyRes.lua +++ b/AutoBodyRes.lua @@ -9,6 +9,10 @@ local GetCorpseRecoveryDelay = GetCorpseRecoveryDelay -- Time left before a play local After = C_Timer.After local Ticker = C_Timer.NewTicker +local IsBattleground = C_PvP.IsBattleground +local IsRatedSoloRBG = C_PvP.IsRatedSoloRBG +local IsRatedBattleground = C_PvP.IsRatedBattleground +local IsInBrawl = C_PvP.IsInBrawl ---@type AutoBodyRes local AutoBodyRes = NS.AutoBodyRes @@ -114,26 +118,27 @@ function AutoBodyRes:PlayerDeadEvents() end function AutoBodyRes:PLAYER_ENTERING_WORLD() - if NS.db.global.onlypvp then - After(0, function() -- Some info isn't available until 1 frame after loading is done - local inInstance = IsInInstance() + After(0, function() -- Some info isn't available until 1 frame after loading is done + local inInstance, instanceType = IsInInstance() - if inInstance then - local _, instanceType = GetInstanceInfo() - local isBattleground = C_PvP.IsBattleground() - local isBlitz = C_PvP.IsSoloRBG() + if inInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() - if instanceType == "pvp" or isBattleground or isBlitz then - if NS.isDead() then - local resTime = GetCorpseRecoveryDelay() - Interface:Start(Interface, resTime + 0.5) - else - Interface:Stop(Interface, Interface.timerAnimationGroup) - Interface:Stop(Interface, Interface.flashAnimationGroup) - end + if isBattleground then + local name = GetInstanceInfo() - AutoBodyRes:PlayerDeadEvents() - else + local isBlitz = IsRatedSoloRBG() + local isRated = IsRatedBattleground() + local isBrawl = IsInBrawl() + local isEpic = NS.IsEpicBattleground(name) + + local dontShowInBlitz = isBlitz and NS.db.global.disableblitz + local dontShowInRated = isRated and isBlitz == false and NS.db.global.disablerated + local dontShowInRandom = isBlitz == false and isRated == false and NS.db.global.disablerandom + local dontShowInBrawl = isBrawl and NS.db.global.disablebrawl + local dontShowInEpic = isEpic and NS.db.global.disableepic + + if dontShowInBlitz or dontShowInRated or dontShowInRandom or dontShowInBrawl or dontShowInEpic then Interface:Stop(Interface, Interface.timerAnimationGroup) Interface:Stop(Interface, Interface.flashAnimationGroup) @@ -142,35 +147,64 @@ function AutoBodyRes:PLAYER_ENTERING_WORLD() end FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + return + end + + local mapNotInList = NS.isMapAllowed(name) == nil + local isMapAllowed = mapNotInList and true or NS.isMapAllowed(name) + + if mapNotInList then + NS.write( + "This map is not being tracked, please report this to the addon author to track the following map name: " + .. name + ) + end + + if NS.db.global.allmaps or isMapAllowed then + if NS.isDead() then + local resTime = GetCorpseRecoveryDelay() + Interface:Start(Interface, resTime + 0.5) + else + Interface:Stop(Interface, Interface.timerAnimationGroup) + Interface:Stop(Interface, Interface.flashAnimationGroup) + end + + AutoBodyRes:PlayerDeadEvents() end else Interface:Stop(Interface, Interface.timerAnimationGroup) Interface:Stop(Interface, Interface.flashAnimationGroup) - if NS.db.global.test then - NS.Interface.text:SetText("Placeholder") - NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text) - NS.Interface.textFrame:Show() + if ResTicker then + ResTicker:Cancel() end + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + else + if not NS.db.global.outside then + Interface:Stop(Interface, Interface.timerAnimationGroup) + Interface:Stop(Interface, Interface.flashAnimationGroup) + if ResTicker then ResTicker:Cancel() end FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + return end - end) - else - if NS.isDead() then - local resTime = GetCorpseRecoveryDelay() - Interface:Start(Interface, resTime + 0.5) - else - Interface:Stop(Interface, Interface.timerAnimationGroup) - Interface:Stop(Interface, Interface.flashAnimationGroup) - end - self:PlayerDeadEvents() - end + if NS.isDead() then + local resTime = GetCorpseRecoveryDelay() + Interface:Start(Interface, resTime + 0.5) + else + Interface:Stop(Interface, Interface.timerAnimationGroup) + Interface:Stop(Interface, Interface.flashAnimationGroup) + end + + AutoBodyRes:PlayerDeadEvents() + end + end) end function AutoBodyRes:PLAYER_LOGIN() diff --git a/AutoBodyRes.toc b/AutoBodyRes.toc index 4d5b52f..5304f1e 100644 --- a/AutoBodyRes.toc +++ b/AutoBodyRes.toc @@ -1,6 +1,6 @@ ## Interface: 110005 ## Title: AutoBodyRes -## Version: 1.1.4 +## Version: 1.1.5 ## Author: RBGDEV ## Notes: Shows text if someone took your body or not after you died in a battleground, preventing you from being able to body res. ## OptionalDeps: Ace3, LibStub, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets diff --git a/CHANGELOG.md b/CHANGELOG.md index 994271a..064af13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Auto Body Res +## [v1.1.5](https://github.com/rbgdevx/auto-body-res/releases/tag/v1.1.5) (2024-11-04) + +- Creating all new settings to control which battleground modes to disable in +- Creating all new settings to control which battleground map to disable in +- Updating other setting labels to be more clear on what they do + ## [v1.1.4](https://github.com/rbgdevx/auto-body-res/releases/tag/v1.1.4) (2024-10-27) - Update toc diff --git a/config.lua b/config.lua index 529b2a3..2698c17 100644 --- a/config.lua +++ b/config.lua @@ -1,4 +1,4 @@ -local _, NS = ... +local AddonName, NS = ... local CreateFrame = CreateFrame @@ -19,7 +19,7 @@ local CreateFrame = CreateFrame ---@field test boolean ---@field release boolean ---@field text boolean ----@field onlypvp boolean +---@field outside boolean ---@field fontsize number ---@field font string ---@field color ColorArray @@ -49,7 +49,7 @@ local CreateFrame = CreateFrame local AutoBodyRes = {} NS.AutoBodyRes = AutoBodyRes -local AutoBodyResFrame = CreateFrame("Frame", "AutoBodyResFrame") +local AutoBodyResFrame = CreateFrame("Frame", AddonName .. "Frame") AutoBodyResFrame:SetScript("OnEvent", function(_, event, ...) if AutoBodyRes[event] then AutoBodyRes[event](AutoBodyRes, ...) @@ -64,9 +64,15 @@ NS.DefaultDatabase = { release = true, resurrect = true, text = true, - onlypvp = true, + outside = false, + disableblitz = false, + disablerated = false, + disablerandom = false, + disableepic = false, + disablebrawl = false, fontsize = 36, font = "Friz Quadrata TT", + debug = false, color = { r = 176 / 255, g = 43 / 255, @@ -79,6 +85,87 @@ NS.DefaultDatabase = { 0, 0, }, - debug = false, + allmaps = true, + -- battlegrounds + arathibasin = true, + deephaulravine = true, + deepwindgorge = true, + eyeofthestorm = true, + seethingshore = true, + silvershardmines = true, + thebattleforgilneas = true, + templeofkotmogu = true, + twinpeaks = true, + warsonggulch = true, + -- epic battlegrounds + alteracvalley = true, + ashran = true, + battleforwintergrasp = true, + isleofconquest = true, + -- brawl battlegrounds + arathiblizzard = true, + korraksrevenge = true, }, } + +--[[ +-- Warsong Gulch -- +-- Instance ID: 2106 +-- Zone ID: 1339 + +-- Arathi Basin -- +-- Instance ID: 2107, 2177, 1681 +-- Zone ID: 1366, nil, 837 + +-- Deephaul Ravine -- +-- Instance ID: 2656 +-- Zone ID: 2345 + +-- Alterac Valley -- +-- Instance ID: 30 +-- Zone ID: 91 + +-- Eye of the Storm -- +-- Instance ID: 566, 968 +-- Zone ID: 112 + +-- Isle of Conquest -- +-- Instance ID: 628 +-- Zone ID: 169 + +-- The Battle for Gilneas -- +-- Instance ID: 761 +-- Zone ID: 275 + +-- Battle for Wintergrasp -- +-- Instance ID: 2118 +-- Zone ID: 1334 + +-- Ashran -- +-- Instance ID: 1191 +-- Zone ID: 1478 + +-- Twin Peaks -- +-- Instance ID: 726 +-- Zone ID: 206 + +-- Silvershard Mines -- +-- Instance ID: 727 +-- Zone ID: 423 + +-- Temple of Kotmogu -- +-- Instance ID: 998 +-- Zone ID: 417 + +-- Seething Shore -- +-- Instance ID: 1803 +-- Zone ID: 907 + +-- Deepwind Gorge -- +-- Instance ID: 2245 +-- Zone ID: 1576 + +-- Korrak's Revenge -- +-- Instance ID: 2197 +-- Zone ID: 1537 +--]] diff --git a/helpers.lua b/helpers.lua index dc6a234..1206647 100644 --- a/helpers.lua +++ b/helpers.lua @@ -10,6 +10,10 @@ local setmetatable = setmetatable local RetrieveCorpse = RetrieveCorpse -- Resurrects when the player is standing near its corpse. local UnitIsDeadOrGhost = UnitIsDeadOrGhost local format = format +local select = select +local UnitClass = UnitClass +local GetClassColor = GetClassColor +local print = print local mfloor = math.floor local mmax = math.max @@ -18,6 +22,12 @@ local After = C_Timer.After local LSM = LibStub("LibSharedMedia-3.0") +NS.write = function(...) + local playerClass = select(2, UnitClass("player")) + local playerClassHexColor = "|c" .. select(4, GetClassColor(playerClass)) + print(playerClassHexColor .. "AutoBodyRes|r: ", ...) +end + NS.isDead = function() return UnitIsDeadOrGhost("player") end @@ -89,25 +99,39 @@ NS.RetrieveBody = function() end) end --- Copies table values from src to dst if they don't exist in dst -NS.CopyDefaults = function(src, dst) - if type(src) ~= "table" then - return {} - end - - if type(dst) ~= "table" then - dst = {} - end - - for k, v in pairs(src) do - if type(v) == "table" then - dst[k] = NS.CopyDefaults(v, dst[k]) - elseif type(v) ~= type(dst[k]) then - dst[k] = v - end - end +NS.IsEpicBattleground = function(instanceName) + local EPIC_BATTLEGROUNDS = { + ["Alterac Valley"] = true, + ["Ashran"] = true, + ["Isle of Conquest"] = true, + ["Battle for Wintergrasp"] = true, + } + return EPIC_BATTLEGROUNDS[instanceName] +end - return dst +NS.isMapAllowed = function(instanceName) + local MAPS = { + -- battlegrounds + ["Arathi Basin"] = NS.db.global.arathibasin, + ["Deephaul Ravine"] = NS.db.global.deephaulravine, + ["Deepwind Gorge"] = NS.db.global.deepwindgorge, + ["Eye of the Storm"] = NS.db.global.eyeofthestorm, + ["Seething Shore"] = NS.db.global.seethingshore, + ["Silvershard Mines"] = NS.db.global.silvershardmines, + ["The Battle for Gilneas"] = NS.db.global.thebattleforgilneas, + ["Temple of Kotmogu"] = NS.db.global.templeofkotmogu, + ["Twin Peaks"] = NS.db.global.twinpeaks, + ["Warsong Gulch"] = NS.db.global.warsonggulch, + -- epic battlegrounds + ["Alterac Valley"] = NS.db.global.alteracvalley, + ["Ashran"] = NS.db.global.ashran, + ["Battle for Wintergrasp"] = NS.db.global.battleforwintergrasp, + ["Isle of Conquest"] = NS.db.global.isleofconquest, + -- brawl battlegrounds + ["Arathi Basin Winter"] = NS.db.global.arathiblizzard, + ["Korrak's Revenge"] = NS.db.global.korraksrevenge, + } + return MAPS[instanceName] end NS.CopyTable = function(src, dest) @@ -132,20 +156,34 @@ NS.CopyTable = function(src, dest) return setmetatable(res, getmetatable(src)) end +-- Copies table values from src to dst if they don't exist in dst +NS.CopyDefaults = function(src, dst) + if type(src) ~= "table" then + return {} + end + if type(dst) ~= "table" then + dst = {} + end + for k, v in pairs(src) do + if type(v) == "table" then + dst[k] = NS.CopyDefaults(v, dst[k]) + elseif type(v) ~= type(dst[k]) then + dst[k] = v + end + end + return dst +end + -- Cleanup savedvariables by removing table values in src that no longer -- exists in table dst (default settings) NS.CleanupDB = function(src, dst) for key, value in pairs(src) do if dst[key] == nil then - -- HACK: offsetsXY are not set in DEFAULT_SETTINGS but sat on demand instead to save memory, - -- which causes nil comparison to always be true here, so always ignore these for now - if key ~= "offsetsX" and key ~= "offsetsY" and key ~= "version" then + if key ~= "version" then src[key] = nil end elseif type(value) == "table" then - if key ~= "disabledCategories" and key ~= "categoryTextures" then -- also sat on demand - dst[key] = NS.CleanupDB(value, dst[key]) - end + dst[key] = NS.CleanupDB(value, dst[key]) end end return dst diff --git a/options.lua b/options.lua index 7ca2bdc..fd67f6f 100644 --- a/options.lua +++ b/options.lua @@ -4,6 +4,12 @@ local LibStub = LibStub local CopyTable = CopyTable local next = next local IsInInstance = IsInInstance +local GetInstanceInfo = GetInstanceInfo + +local IsBattleground = C_PvP.IsBattleground +local IsRatedSoloRBG = C_PvP.IsRatedSoloRBG +local IsRatedBattleground = C_PvP.IsRatedBattleground +local IsInBrawl = C_PvP.IsInBrawl ---@type AutoBodyRes local AutoBodyRes = NS.AutoBodyRes @@ -23,188 +29,807 @@ local DEAD_EVENTS = { NS.AceConfig = { name = AddonName, type = "group", + childGroups = "tab", args = { - lock = { - name = "Lock the text into place", - type = "toggle", - width = "double", - order = 1, - set = function(_, val) - NS.db.global.lock = val - if val then - NS.Interface:Lock(NS.Interface.textFrame) - else - NS.Interface:Unlock(NS.Interface.textFrame) - end - end, - get = function(_) - return NS.db.global.lock - end, - }, - test = { - name = "Toggle on placeholder text to test settings", - desc = "Only works outside of an instance.", - type = "toggle", - width = "double", - order = 2, - set = function(_, val) - NS.db.global.test = val - if IsInInstance() == false then - if val then - NS.Interface.text:SetText("CAN BODY RES NOW") + general = { + name = "General", + type = "group", + args = { + lock = { + name = "Lock the text into place", + type = "toggle", + width = "double", + order = 1, + set = function(_, val) + NS.db.global.lock = val + if val then + NS.Interface:Lock(NS.Interface.textFrame) + else + NS.Interface:Unlock(NS.Interface.textFrame) + end + end, + get = function(_) + return NS.db.global.lock + end, + }, + test = { + name = "Turn on placeholder text to test settings", + desc = "Only works outside of an instance.", + type = "toggle", + width = "double", + order = 2, + set = function(_, val) + NS.db.global.test = val + + local isInInstance = IsInInstance() + if isInInstance == false then + if val then + NS.Interface.text:SetText("CAN BODY RES NOW") + NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text) + NS.Interface.textFrame:Show() + else + NS.Interface.textFrame:Hide() + end + end + end, + get = function(_) + return NS.db.global.test + end, + }, + release = { + name = "Enable auto-release", + desc = "Auto releases your body upon death.", + type = "toggle", + width = "double", + order = 3, + set = function(_, val) + NS.db.global.release = val + end, + get = function(_) + return NS.db.global.release + end, + }, + resurrect = { + name = "Enable auto-resurrect", + desc = "Auto accepts resurrection from a friend, spell, or your from being in-range of your body.", + type = "toggle", + width = "double", + order = 4, + set = function(_, val) + NS.db.global.resurrect = val + end, + get = function(_) + return NS.db.global.resurrect + end, + }, + text = { + name = "Enable body res timer text", + desc = "Toggles on/off the text that displays the time remaining to resurrect your body.", + type = "toggle", + width = "double", + order = 5, + set = function(_, val) + NS.db.global.text = val + + if val then + NS.Interface.textFrame:SetAlpha(1) + else + NS.Interface.textFrame:SetAlpha(0) + end + end, + get = function(_) + return NS.db.global.text + end, + }, + outside = { + name = "Enable outside of battlegrounds", + desc = "Toggling this feature on will make it only work outside of battlegrounds.", + type = "toggle", + width = "double", + order = 6, + set = function(_, val) + NS.db.global.outside = val + + local isInInstance = IsInInstance() + if isInInstance == false then + if val then + NS.Interface.textFrame:Show() + FrameUtil.RegisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + else + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end, + get = function(_) + return NS.db.global.outside + end, + }, + disablegroup = { + name = "Choose what content this should not load in", + type = "group", + inline = true, + order = 7, + args = { + disableblitz = { + name = "Disable in 8v8 Rated Blitz", + desc = "Toggling this feature on will disable in rated blitz.", + type = "toggle", + width = "double", + order = 1, + set = function(_, val) + NS.db.global.disableblitz = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local isBlitz = IsRatedSoloRBG() + local dontShowInBlitz = isBlitz and val + if dontShowInBlitz then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.disableblitz + end, + }, + disablerated = { + name = "Disable in 10v10 Rated Battlegrounds", + desc = "Toggling this feature on will disable in non-blitz rated bgs.", + type = "toggle", + width = "double", + order = 2, + set = function(_, val) + NS.db.global.disablerated = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local isBlitz = IsRatedSoloRBG() + local isRated = IsRatedBattleground() + local dontShowInRated = isRated and isBlitz == false and val + if dontShowInRated then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.disablerated + end, + }, + disablerandom = { + name = "Disable in Random Battlegrounds", + desc = "Toggling this feature on will disable in random bgs.", + type = "toggle", + width = "double", + order = 3, + set = function(_, val) + NS.db.global.disablerandom = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local isBlitz = IsRatedSoloRBG() + local isRated = IsRatedBattleground() + local dontShowInRandom = isBlitz == false and isRated == false and val + if dontShowInRandom then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.disablerandom + end, + }, + disableepic = { + name = "Disable in Epic Battlegrounds", + desc = "Toggling this feature on will disable in epic bgs.", + type = "toggle", + width = "double", + order = 4, + set = function(_, val) + NS.db.global.disableepic = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isEpic = NS.isEpicBattleground(name) + local dontShowInEpic = isEpic and val + if dontShowInEpic then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.disableepic + end, + }, + disablebrawl = { + name = "Disable in Brawls", + desc = "Toggling this feature on will disable in pvp brawls.", + type = "toggle", + width = "double", + order = 5, + set = function(_, val) + NS.db.global.disablebrawl = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local isBrawl = IsInBrawl() + local dontShowInBrawl = isBrawl and val + if dontShowInBrawl then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.disablebrawl + end, + }, + }, + }, + fontsize = { + type = "range", + name = "Font Size", + width = "double", + order = 8, + min = 1, + max = 500, + step = 1, + set = function(_, val) + NS.db.global.fontsize = val + NS.UpdateFont(NS.Interface.text) NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text) - NS.Interface.textFrame:Show() - else - NS.Interface.textFrame:Hide() - end - end - end, - get = function(_) - return NS.db.global.test - end, - }, - release = { - name = "Toggle auto-release", - desc = "Auto releases your body upon death.", - type = "toggle", - width = "double", - order = 3, - set = function(_, val) - NS.db.global.release = val - end, - get = function(_) - return NS.db.global.release - end, - }, - resurrect = { - name = "Toggle auto-resurrect", - desc = "Auto accepts resurrection from a friend, spell, or your from being in-range of your body.", - type = "toggle", - width = "double", - order = 4, - set = function(_, val) - NS.db.global.resurrect = val - end, - get = function(_) - return NS.db.global.resurrect - end, - }, - text = { - name = "Toggle body res timer text", - desc = "Toggles on/off the text that displays the time remaining to resurrect your body.", - type = "toggle", - width = "double", - order = 5, - set = function(_, val) - NS.db.global.text = val - - if val then - NS.Interface.textFrame:SetAlpha(1) - else - NS.Interface.textFrame:SetAlpha(0) - end - end, - get = function(_) - return NS.db.global.text - end, - }, - onlypvp = { - name = "Toggle on this addon only in battlegrounds", - desc = "Toggling this feature off will make it work outside of battlegrounds", - type = "toggle", - width = "double", - order = 6, - set = function(_, val) - NS.db.global.onlypvp = val - - if IsInInstance() == false then - if val == false then - NS.Interface.textFrame:Show() - FrameUtil.RegisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) - else - NS.Interface.textFrame:Hide() - FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) - end - end - end, - get = function(_) - return NS.db.global.onlypvp - end, - }, - fontsize = { - type = "range", - name = "Font Size", - width = "double", - order = 7, - min = 1, - max = 500, - step = 1, - set = function(_, val) - NS.db.global.fontsize = val - NS.UpdateFont(NS.Interface.text) - NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text) - end, - get = function(_) - return NS.db.global.fontsize - end, - }, - font = { - type = "select", - name = "Font", - width = "double", - order = 8, - dialogControl = "LSM30_Font", - values = AceGUIWidgetLSMlists.font, - set = function(_, val) - NS.db.global.font = val - NS.UpdateFont(NS.Interface.text) - NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text) - end, - get = function(_) - return NS.db.global.font - end, - }, - color = { - type = "color", - name = "Color", - width = "double", - order = 9, - hasAlpha = true, - set = function(_, val1, val2, val3, val4) - NS.db.global.color.r = val1 - NS.db.global.color.g = val2 - NS.db.global.color.b = val3 - NS.db.global.color.a = val4 - NS.Interface.text:SetTextColor(val1, val2, val3, val4) - end, - get = function(_) - 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, + end, + get = function(_) + return NS.db.global.fontsize + end, + }, + font = { + type = "select", + name = "Font", + width = "double", + order = 9, + dialogControl = "LSM30_Font", + values = AceGUIWidgetLSMlists.font, + set = function(_, val) + NS.db.global.font = val + NS.UpdateFont(NS.Interface.text) + NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text) + end, + get = function(_) + return NS.db.global.font + end, + }, + color = { + type = "color", + name = "Color", + width = "full", + order = 10, + hasAlpha = true, + set = function(_, val1, val2, val3, val4) + NS.db.global.color.r = val1 + NS.db.global.color.g = val2 + NS.db.global.color.b = val3 + NS.db.global.color.a = val4 + NS.Interface.text:SetTextColor(val1, val2, val3, val4) + end, + get = function(_) + return NS.db.global.color.r, NS.db.global.color.g, NS.db.global.color.b, NS.db.global.color.a + end, + }, + reset = { + name = "Reset Everything", + type = "execute", + width = "normal", + order = 100, + func = function() + AutoBodyResDB = CopyTable(NS.DefaultDatabase) + NS.db = CopyTable(NS.DefaultDatabase) + NS.UpdateFont(NS.Interface.text) + NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text) + end, + }, + }, }, - reset = { - name = "Reset Everything", - type = "execute", - width = "normal", - order = 100, - func = function() - AutoBodyResDB = CopyTable(NS.DefaultDatabase) - NS.db = CopyTable(NS.DefaultDatabase) - NS.UpdateFont(NS.Interface.text) - NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text) - end, + maps = { + name = "Maps", + desc = "Enable/Disable for specific maps.", + type = "group", + args = { + description = { + name = "These settings only matter if you have the matching game mode enabled in the general settings.", + type = "description", + fontSize = "medium", + width = "double", + order = 1, + }, + spacing1 = { type = "description", order = 2, name = " " }, + allmaps = { + name = "Enable for all maps", + desc = "Toggling this feature on will enable in all battleground maps.", + type = "toggle", + width = "double", + order = 3, + set = function(_, val) + NS.db.global.allmaps = val + end, + get = function(_) + return NS.db.global.allmaps + end, + }, + normalgroup = { + name = "Battlegrounds", + type = "group", + inline = true, + order = 4, + disabled = function(info) + return info[3] + and ( + (NS.db.global.disableblitz and NS.db.global.disablerated and NS.db.global.disablerandom) + or NS.db.global.allmaps + ) + end, + args = { + arathibasin = { + name = "Arathi Basin", + desc = "Turn on for Arathi Basin.", + type = "toggle", + width = "full", + order = 1, + set = function(_, val) + NS.db.global.arathibasin = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Arathi Basin" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.arathibasin + end, + }, + deephaulravine = { + name = "Deephaul Ravine", + desc = "Turn on for Deephaul Ravine.", + type = "toggle", + width = "full", + order = 2, + set = function(_, val) + NS.db.global.deephaulravine = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Deephaul Ravine" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.deephaulravine + end, + }, + deepwindgorge = { + name = "Deepwind Gorge", + desc = "Turn on for Deepwind Gorge.", + type = "toggle", + width = "full", + order = 3, + set = function(_, val) + NS.db.global.deepwindgorge = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Deepwind Gorge" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.deepwindgorge + end, + }, + eyeofthestorm = { + name = "Eye of the Storm", + desc = "Turn on for Eye of the Storm.", + type = "toggle", + width = "full", + order = 4, + set = function(_, val) + NS.db.global.eyeofthestorm = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Eye of the Storm" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.eyeofthestorm + end, + }, + seethingshore = { + name = "Seething Shore", + desc = "Turn on for Seething Shore.", + type = "toggle", + width = "full", + order = 5, + set = function(_, val) + NS.db.global.seethingshore = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Seething Shore" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.seethingshore + end, + }, + silvershardmines = { + name = "Silvershard Mines", + desc = "Turn on for Silvershard Mines.", + type = "toggle", + width = "full", + order = 6, + set = function(_, val) + NS.db.global.silvershardmines = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Silvershard Mines" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.silvershardmines + end, + }, + thebattleforgilneas = { + name = "The Battle for Gilneas", + desc = "Turn on for The Battle for Gilneas.", + type = "toggle", + width = "full", + order = 7, + set = function(_, val) + NS.db.global.thebattleforgilneas = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "The Battle for Gilneas" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.thebattleforgilneas + end, + }, + templeofkotmogu = { + name = "Temple of Kotmogu", + desc = "Turn on for Temple of Kotmogu.", + type = "toggle", + width = "full", + order = 8, + set = function(_, val) + NS.db.global.templeofkotmogu = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Temple of Kotmogu" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.templeofkotmogu + end, + }, + twinpeaks = { + name = "Twin Peaks", + desc = "Turn on for Twin Peaks.", + type = "toggle", + width = "full", + order = 9, + set = function(_, val) + NS.db.global.twinpeaks = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Twin Peaks" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.twinpeaks + end, + }, + warsonggulch = { + name = "Warsong Gulch", + desc = "Turn on for Warsong Gulch.", + type = "toggle", + width = "full", + order = 10, + set = function(_, val) + NS.db.global.warsonggulch = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Warsong Gulch" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.warsonggulch + end, + }, + }, + }, + epicgroup = { + name = "Epic Battlegrounds", + type = "group", + inline = true, + order = 5, + disabled = function(info) + return info[3] and (NS.db.global.disableepic or NS.db.global.allmaps) + end, + args = { + alteracvalley = { + name = "Alterac Valley", + desc = "Turn on for Alterac Valley.", + type = "toggle", + width = "full", + order = 1, + set = function(_, val) + NS.db.global.alteracvalley = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Alterac Valley" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.alteracvalley + end, + }, + ashran = { + name = "Ashran", + desc = "Turn on for Ashran.", + type = "toggle", + width = "full", + order = 2, + set = function(_, val) + NS.db.global.ashran = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Ashran" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.ashran + end, + }, + battleforwintergrasp = { + name = "Battle for Wintergrasp", + desc = "Turn on for Battle for Wintergrasp.", + type = "toggle", + width = "full", + order = 3, + set = function(_, val) + NS.db.global.battleforwintergrasp = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Battle for Wintergrasp" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.battleforwintergrasp + end, + }, + isleofconquest = { + name = "Isle of Conquest", + desc = "Turn on for Isle of Conquest.", + type = "toggle", + width = "full", + order = 4, + set = function(_, val) + NS.db.global.isleofconquest = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Isle of Conquest" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.isleofconquest + end, + }, + }, + }, + brawlgroup = { + name = "Brawl Battlegrounds", + type = "group", + inline = true, + order = 6, + disabled = function(info) + return info[3] and (NS.db.global.disablebrawl or NS.db.global.allmaps) + end, + args = { + arathiblizzard = { + name = "Arathi Blizzard", + desc = "Turn on for Arathi Blizzard.", + type = "toggle", + width = "full", + order = 1, + set = function(_, val) + NS.db.global.korraksrevenge = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Arathi Basin Winter" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.korraksrevenge + end, + }, + korraksrevenge = { + name = "Korrak's Revenge", + desc = "Turn on for Korrak's Revenge.", + type = "toggle", + width = "full", + order = 2, + set = function(_, val) + NS.db.global.korraksrevenge = val + + local isInInstance, instanceType = IsInInstance() + if isInInstance then + local isBattleground = instanceType == "pvp" or IsBattleground() + if isBattleground then + local name = GetInstanceInfo() + local isMapAllowed = name == "Korrak's Revenge" and val + if not isMapAllowed then + NS.Interface.textFrame:Hide() + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end + end + end, + get = function(_) + return NS.db.global.korraksrevenge + end, + }, + }, + }, + }, }, }, }