Allow invidivudal bag visibility to be toggled
TSedlar opened this issue ยท 3 comments
I come from a different programming background, but essentially, each of the bag buttons:
Should toggle the visibility of the slots contained within the bag, probably within only the live view would be fine.
I've attempted to work on this by adding the following to MainView.lua#L223
bb:SetScript("OnClick", function()
Baganator.CallbackRegistry:TriggerEvent("BagClicked", index)
end)
As well as adding the event to Constants.lua
within the Events
constant:
Baganator.Constants.Events = {
"SettingChangedEarly",
"SettingChanged",
"CharacterDeleted",
"BagCacheUpdate",
"MailCacheUpdate",
"CurrencyCacheUpdate",
"GuildCacheUpdate",
"EquippedCacheUpdate",
"SearchTextChanged",
"BagShow",
"BagHide",
"CharacterSelect",
"ShowCustomise",
"ResetFramePositions",
"HighlightSimilarItems",
"HighlightBagItems",
"ClearHighlightBag",
"ContentRefreshRequired",
"BagClicked",
}
This then prompted me to add to BaganatorLiveBagLayoutMixin:OnLoad()
, starting on L223:
self.bagVisibilityStates = {true, true, true, true, true}
if not Baganator.Config.IsValidOption("bagVisibilityStates") then
Baganator.Config.Create("bagVisibilityStates", "bagVisibilityStates", self.bagVisibilityStates)
else
self.bagVisibilityStates = Baganator.Config.Get("bagVisibilityStates")
end
Baganator.CallbackRegistry:RegisterCallback("BagClicked", function(_, bagID)
self.bagVisibilityStates[bagID] = not self.bagVisibilityStates[bagID]
Baganator.Config.Set("bagVisibilityStates", self.bagVisibilityStates)
for _, btn in pairs(self.buttonsByBag[bagID]) do
btn:SetShown(self.bagVisibilityStates[bagID])
end
BaganatorLiveBagLayoutMixin:RequestContentRefresh()
end)
And lastly, within BaganatorLiveBagLayoutMixin:RebuildLayout(indexes, indexesToUse, rowWidth)
I added the following after b:Show()
:
if bagID > 0 and not self.bagVisibilityStates[bagID] then
b:Hide()
end
This does allow the bags to be toggleable, but it does not change the bag view's height, and does not reinstate the bag visibility upon reload.
Seeing this POC be fleshed out and added to the addon would be fantastic.
I typically like to hide a bag that I use to be filled with ammo or dedicated to offspec gear.