Skip to content

Commit

Permalink
ensuring addon shows/hides correctly when setting battleground only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgdevx committed Oct 2, 2024
1 parent 39e000c commit 0984b38
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
35 changes: 24 additions & 11 deletions AutoBodyRes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ local DEAD_EVENTS = {
"PLAYER_SKINNED",
"CORPSE_IN_RANGE",
"RESURRECT_REQUEST",
"PLAYER_UNGHOST",
}

function AutoBodyRes:PlayerDeadEvents()
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion AutoBodyRes.toc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ NS.DefaultDatabase = {
resurrect = true,
text = true,
onlypvp = true,
fontsize = 40,
fontsize = 36,
font = "Friz Quadrata TT",
color = {
r = 176 / 255,
Expand Down
6 changes: 3 additions & 3 deletions options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ local DEAD_EVENTS = {
"PLAYER_SKINNED",
"CORPSE_IN_RANGE",
"RESURRECT_REQUEST",
"PLAYER_UNGHOST",
}

NS.AceConfig = {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0984b38

Please sign in to comment.