Skip to content

Commit

Permalink
Add option to hide during pet battles, by request
Browse files Browse the repository at this point in the history
  • Loading branch information
parnic committed Jun 15, 2021
1 parent 4c4f48d commit abfc519
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
34 changes: 34 additions & 0 deletions Breakables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ function Breakables:OnInitialize()
hideEqManagerItems = true,
hide = false,
hideInCombat = false,
hideInPetBattle = true,
buttonScale = 1,
fontSize = 11,
growDirection = 2,
Expand Down Expand Up @@ -390,6 +391,11 @@ function Breakables:RegisterEvents()
if CanPickLock then
self:RegisterEvent("CHAT_MSG_OPENING", "OnBagItemLockPicked")
end

if UnitCanPetBattle then
self:RegisterEvent("PET_BATTLE_OPENING_START", "PetBattleStarted")
self:RegisterEvent("PET_BATTLE_OVER", "PetBattleEnded")
end
end

function Breakables:OnModifierChanged()
Expand Down Expand Up @@ -458,6 +464,16 @@ function Breakables:OnBagItemLockPicked()
self:FindBreakables()
end

function Breakables:PetBattleStarted()
if self.settings.hideInPetBattle then
self:ToggleButtonFrameVisibility(false)
end
end

function Breakables:PetBattleEnded()
self:ToggleButtonFrameVisibility(true)
end

function Breakables:FindLevelOfProfessionIndex(idx)
if idx ~= nil then
local name, texture, rank, maxRank, numSpells, spelloffset, skillLine = GetProfessionInfo(idx)
Expand Down Expand Up @@ -761,6 +777,24 @@ function Breakables:GetOptions()
end
end

if UnitCanPetBattle then
opts.args.hideInPetBattle = {
type = "toggle",
name = L["Hide during pet battles"],
desc = L["Whether or not to hide the breakables bar when you enter a pet battle."],
get = function(info)
return self.settings.hideInPetBattle
end,
set = function(info, v)
self.settings.hideInPetBattle = v
if info.uiType == "cmd" then
print("|cff33ff99Breakables|r: set |cffffff78hideInPetBattle|r to " .. tostring(self.settings.hideInPetBattle))
end
end,
order = 3.5,
}
end

return opts
end

Expand Down
3 changes: 2 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
vNext:
v1.8.0:
- Classic-BC support
- Added option to hide during pet battles, by request.

v1.7.4:
- Fix an issue when IsArtifactRelicItem is not defined
Expand Down

0 comments on commit abfc519

Please sign in to comment.