Skip to content

Commit

Permalink
Merge pull request #2 from rbgdevx/no-settings-while-locked
Browse files Browse the repository at this point in the history
Refactor + enhancements
  • Loading branch information
rbgdevx authored Sep 3, 2024
2 parents c44ffb8 + 8bd1e2b commit 0f49dbd
Show file tree
Hide file tree
Showing 29 changed files with 699 additions and 2,389 deletions.
24 changes: 22 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@
"RESURRECT_REQUEST",
"Add",
"SlashCmdList",
"hash_SlashCmdList"
]
"hash_SlashCmdList",
"ButtonFrameTemplate_HidePortrait",
"FrameUtil",
"SECONDS_PER_MIN",
"SECONDS_PER_DAY",
"SECONDS_PER_HOUR",
"HOURS_MINUTES_SECONDS",
"MINUTES_SECONDS"
],
"Lua.runtime.version": "Lua 5.1",
"Lua.runtime.builtin": {
"basic": "disable",
"debug": "disable",
"io": "disable",
"math": "disable",
"os": "disable",
"package": "disable",
"string": "disable",
"table": "disable",
"utf8": "disable"
},
"Lua.workspace.library": ["~\\.vscode\\extensions\\ketho.wow-api-0.17.6\\Annotations"]
}
58 changes: 28 additions & 30 deletions AutoBodyRes.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
local AddonName, NS = ...
local _, NS = ...

local Interface = NS.Interface

local LibStub = LibStub
local GetInstanceInfo = GetInstanceInfo
local IsInInstance = IsInInstance
local GetCorpseRecoveryDelay = GetCorpseRecoveryDelay -- Time left before a player can accept a resurrection.
Expand All @@ -11,7 +10,9 @@ local GetCorpseRecoveryDelay = GetCorpseRecoveryDelay -- Time left before a play
local After = C_Timer.After
local Ticker = C_Timer.NewTicker

AutoBodyRes = LibStub("AceAddon-3.0"):NewAddon(AddonName, "AceEvent-3.0", "AceConsole-3.0")
---@type AutoBodyRes
local AutoBodyRes = NS.AutoBodyRes
local AutoBodyResFrame = NS.AutoBodyRes.frame

local ResTicker

Expand All @@ -22,7 +23,7 @@ do
local GetSelfResurrectOptions = C_DeathInfo.GetSelfResurrectOptions -- Returns self resurrect options for your character, including from soulstones.

function AutoBodyRes:CORPSE_IN_RANGE()
if AutoBodyRes.db.global.resurrect then
if NS.db.global.resurrect then
NS.RetrieveBody()
local resTime = GetCorpseRecoveryDelay()
if resTime then
Expand All @@ -36,7 +37,7 @@ do
end

function AutoBodyRes:RESURRECT_REQUEST()
if AutoBodyRes.db.global.resurrect then
if NS.db.global.resurrect then
AcceptResurrect()
After(0, function()
if NS.isDead() then
Expand All @@ -54,7 +55,7 @@ do
end

function AutoBodyRes:PlayerDead()
if AutoBodyRes.db.global.release then
if NS.db.global.release then
local options = GetSelfResurrectOptions()
if options and #options == 0 then
RepopMe()
Expand All @@ -66,7 +67,7 @@ do
self:PlayerDead()

local resTime = GetCorpseRecoveryDelay()
Interface:Start(Interface, resTime + 1)
Interface:Start(Interface, resTime + 0.5)
end
end

Expand All @@ -90,27 +91,31 @@ function AutoBodyRes:PLAYER_SKINNED()
Interface.textFrame:Show()
Interface.flashAnimationGroup:Play()

-- Protect Action, only available to the Blizzard UI
-- Protected Action, only available to the Blizzard UI
-- PortGraveyard()

After(5, function()
Interface.flashAnimationGroup:Stop()
end)
end

local DEAD_EVENTS = {
"PLAYER_DEAD",
"PLAYER_SKINNED",
"CORPSE_IN_RANGE",
"RESURRECT_REQUEST",
}

function AutoBodyRes:PlayerDeadEvents()
self:RegisterEvent("PLAYER_DEAD")
self:RegisterEvent("PLAYER_SKINNED")
self:RegisterEvent("CORPSE_IN_RANGE")
self:RegisterEvent("RESURRECT_REQUEST")
FrameUtil.RegisterFrameForEvents(self, DEAD_EVENTS)

self:PlayerDead()
end

function AutoBodyRes:PLAYER_ENTERING_WORLD()
self:RegisterEvent("PLAYER_UNGHOST")
AutoBodyResFrame:RegisterEvent("PLAYER_UNGHOST")

if AutoBodyRes.db.global.onlypvp then
if NS.db.global.onlypvp then
local inInstance = IsInInstance()

if inInstance then
Expand All @@ -120,7 +125,7 @@ function AutoBodyRes:PLAYER_ENTERING_WORLD()
if instanceType == "pvp" then
if NS.isDead() then
local resTime = GetCorpseRecoveryDelay()
Interface:Start(Interface, resTime + 1)
Interface:Start(Interface, resTime + 0.5)
else
Interface:Stop(Interface, Interface.timerAnimationGroup)
Interface:Stop(Interface, Interface.flashAnimationGroup)
Expand All @@ -131,7 +136,7 @@ function AutoBodyRes:PLAYER_ENTERING_WORLD()
end)
else
After(0, function() -- Some info isn't available until 1 frame after loading is done
if AutoBodyRes.db.global.test then
if NS.db.global.test then
NS.Interface.text:SetText("Placeholder")
NS.UpdateSize(NS.Interface.textFrame, NS.Interface.text)
NS.Interface.textFrame:Show()
Expand All @@ -145,28 +150,21 @@ function AutoBodyRes:PLAYER_ENTERING_WORLD()
else
if NS.isDead() then
local resTime = GetCorpseRecoveryDelay()
Interface:Start(Interface, resTime + 1)
Interface:Start(Interface, resTime + 0.5)
else
Interface:Stop(Interface, Interface.timerAnimationGroup)
Interface:Stop(Interface, Interface.flashAnimationGroup)
end

AutoBodyRes:PlayerDeadEvents()
self:PlayerDeadEvents()
end
end

function AutoBodyRes:SlashCommands(_)
LibStub("AceConfigDialog-3.0"):Open(AddonName)
end
function AutoBodyRes:PLAYER_LOGIN()
AutoBodyResFrame:UnregisterEvent("PLAYER_LOGIN")

function AutoBodyRes:OnInitialize()
self.db = LibStub("AceDB-3.0"):New(AddonName .. "DB", NS.DefaultDatabase, true)
self:SetupOptions()
self:RegisterChatCommand(AddonName, "SlashCommands")
self:RegisterChatCommand("abr", "SlashCommands")
end

function AutoBodyRes:OnEnable()
Interface:CreateInterface()
self:RegisterEvent("PLAYER_ENTERING_WORLD")

AutoBodyResFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
end
AutoBodyResFrame:RegisterEvent("PLAYER_LOGIN")
9 changes: 4 additions & 5 deletions AutoBodyRes.toc
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
## Interface: 100207
## Title: Auto Body Res
## Version: 1.0.8
## Author: Ajax
## Interface: 110002
## Title: AutoBodyRes
## Version: 1.1.0
## 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
## IconTexture: Interface\AddOns\AutoBodyRes\logo.tga
## DefaultState: Enabled
## SavedVariables: AutoBodyResDB
## X-Category: Battlegrounds/PvP
## X-Credits: Ajax
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Auto Body Res

## [v1.1.0](https://github.com/rbgdevx/auto-body-res/releases/tag/v1.1.0) (2024-09-02)

- Refactor lib usage to match what im doing on BGWC addon to reduce needed libs and global db issues
- Made it so you can't open the settings when locked and right clicking the text
- Minor random changes based on learning from BGWC

## [v1.0.8](https://github.com/rbgdevx/auto-body-res/releases/tag/v1.0.8) (2024-05-08)

- Fixing 10.2.7 bugs for incorrect setting of text justification
- Unregistering events from pvp if toggled off

## [v1.0.7](https://github.com/rbgdevx/auto-body-res/releases/tag/v1.0.7) (2024-01-09)

Expand Down
Loading

0 comments on commit 0f49dbd

Please sign in to comment.