Skip to content

Commit

Permalink
settings overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgdevx committed Nov 4, 2024
1 parent 6f56692 commit fa4096d
Show file tree
Hide file tree
Showing 7 changed files with 1,032 additions and 242 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
98 changes: 66 additions & 32 deletions AutoBodyRes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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()
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: 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
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
97 changes: 92 additions & 5 deletions config.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local _, NS = ...
local AddonName, NS = ...

local CreateFrame = CreateFrame

Expand All @@ -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
Expand Down Expand Up @@ -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, ...)
Expand All @@ -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,
Expand All @@ -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
--]]
Loading

0 comments on commit fa4096d

Please sign in to comment.