From 0984b38a7e41e4dfbf4e51221797b02bfcf9cc9c Mon Sep 17 00:00:00 2001 From: RBG DEV <149433862+rbgdevx@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:23:04 -0400 Subject: [PATCH] ensuring addon shows/hides correctly when setting battleground only mode --- .vscode/settings.json | 4 +--- AutoBodyRes.lua | 35 ++++++++++++++++++++++++----------- AutoBodyRes.toc | 2 +- CHANGELOG.md | 8 ++++++++ config.lua | 2 +- options.lua | 6 +++--- 6 files changed, 38 insertions(+), 19 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8d577c8..fdafe11 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -50,7 +50,5 @@ "table": "disable", "utf8": "disable" }, - "Lua.workspace.library": [ - "~\\.vscode\\extensions\\ketho.wow-api-0.17.6\\Annotations" - ] + "Lua.workspace.library": ["c:\\Users\\17186\\.cursor\\extensions\\ketho.wow-api-0.17.6\\Annotations"] } diff --git a/AutoBodyRes.lua b/AutoBodyRes.lua index 971d8b5..05f2505 100644 --- a/AutoBodyRes.lua +++ b/AutoBodyRes.lua @@ -104,6 +104,7 @@ local DEAD_EVENTS = { "PLAYER_SKINNED", "CORPSE_IN_RANGE", "RESURRECT_REQUEST", + "PLAYER_UNGHOST", } function AutoBodyRes:PlayerDeadEvents() @@ -113,16 +114,16 @@ function AutoBodyRes:PlayerDeadEvents() end function AutoBodyRes:PLAYER_ENTERING_WORLD() - AutoBodyResFrame:RegisterEvent("PLAYER_UNGHOST") - if NS.db.global.onlypvp then - local inInstance = IsInInstance() + After(0, function() -- Some info isn't available until 1 frame after loading is done + local inInstance = IsInInstance() - if inInstance then - After(0, function() -- Some info isn't available until 1 frame after loading is done + if inInstance then local _, instanceType = GetInstanceInfo() + local isBattleground = C_PvP.IsBattleground() + local isBlitz = C_PvP.IsSoloRBG() - if instanceType == "pvp" then + if instanceType == "pvp" or isBattleground or isBlitz then if NS.isDead() then local resTime = GetCorpseRecoveryDelay() Interface:Start(Interface, resTime + 0.5) @@ -132,10 +133,20 @@ function AutoBodyRes:PLAYER_ENTERING_WORLD() end AutoBodyRes:PlayerDeadEvents() + else + Interface:Stop(Interface, Interface.timerAnimationGroup) + Interface:Stop(Interface, Interface.flashAnimationGroup) + + if ResTicker then + ResTicker:Cancel() + end + + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) end - end) - else - After(0, function() -- Some info isn't available until 1 frame after loading is done + 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) @@ -145,8 +156,10 @@ function AutoBodyRes:PLAYER_ENTERING_WORLD() if ResTicker then ResTicker:Cancel() end - end) - end + + FrameUtil.UnregisterFrameForEvents(AutoBodyResFrame, DEAD_EVENTS) + end + end) else if NS.isDead() then local resTime = GetCorpseRecoveryDelay() diff --git a/AutoBodyRes.toc b/AutoBodyRes.toc index 359e6d1..a2e8ca4 100644 --- a/AutoBodyRes.toc +++ b/AutoBodyRes.toc @@ -1,6 +1,6 @@ ## Interface: 110002 ## Title: AutoBodyRes -## Version: 1.1.2 +## Version: 1.1.3 ## 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 4abbebf..7bf9107 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Auto Body Res +## [v1.1.3](https://github.com/rbgdevx/auto-body-res/releases/tag/v1.1.3) (2024-10-02) + +- Double ensures that if you toggle battleground only mode it wont load in arena and even if it did it hides any previous death text +- adds a check in the start of a message being shown as well to ensure you're in a battleground if that option is enabled +- showing/hiding the text if changing the battleground only setting while dead +- unregisters events at appropriate times so no accidental triggers run and hides at the same time as well +- reduces the default text size a little + ## [v1.1.2](https://github.com/rbgdevx/auto-body-res/releases/tag/v1.1.2) (2024-09-03) - Adding new setting to turn off body res text diff --git a/config.lua b/config.lua index 50d8a84..529b2a3 100644 --- a/config.lua +++ b/config.lua @@ -65,7 +65,7 @@ NS.DefaultDatabase = { resurrect = true, text = true, onlypvp = true, - fontsize = 40, + fontsize = 36, font = "Friz Quadrata TT", color = { r = 176 / 255, diff --git a/options.lua b/options.lua index 8b2d5e5..7ca2bdc 100644 --- a/options.lua +++ b/options.lua @@ -17,6 +17,7 @@ local DEAD_EVENTS = { "PLAYER_SKINNED", "CORPSE_IN_RANGE", "RESURRECT_REQUEST", + "PLAYER_UNGHOST", } NS.AceConfig = { @@ -54,9 +55,6 @@ NS.AceConfig = { NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text) NS.Interface.textFrame:Show() else - NS.Interface.text:SetText("") - NS.Interface.textFrame:SetWidth(0) - NS.Interface.textFrame:SetHeight(0) NS.Interface.textFrame:Hide() end end @@ -121,8 +119,10 @@ NS.AceConfig = { 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