Skip to content

Commit 10808e8

Browse files
committed
Implemented support for the AddonCompartmentFrame.
1 parent 1961cbc commit 10808e8

11 files changed

+48
-8
lines changed

AdiBags.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
## Title: AdiBags
2323
## Notes: Adirelle's bag addon.
24+
## IconAtlas: bag-main
2425
## Author: Adirelle
2526
## Version: @project-version@
2627
## SavedVariables: AdiBagsDB

AdiBags_Cata.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
## Title: AdiBags
2323
## Notes: Adirelle's bag addon.
24+
## IconAtlas: bag-main
2425
## Author: Adirelle
2526
## Version: @project-version@
2627
## SavedVariables: AdiBagsDB

AdiBags_Config/AdiBags_Config.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Title: AdiBags Configuration
44
## Notes: Adirelle's bag addon.
5+
## IconAtlas: bag-main
56
## Author: Adirelle
67
## Version: @project-version@
78
## X-Date: @project-date-iso@

AdiBags_Config/AdiBags_Config_Cata.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Title: AdiBags Configuration
44
## Notes: Adirelle's bag addon.
5+
## IconAtlas: bag-main
56
## Author: Adirelle
67
## Version: @project-version@
78
## X-Date: @project-date-iso@

AdiBags_Config/AdiBags_Config_TBC.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Title: AdiBags Configuration
44
## Notes: Adirelle's bag addon.
5+
## IconAtlas: bag-main
56
## Author: Adirelle
67
## Version: @project-version@
78
## X-Date: @project-date-iso@

AdiBags_Config/AdiBags_Config_Vanilla.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Title: AdiBags Configuration
44
## Notes: Adirelle's bag addon.
5+
## IconAtlas: bag-main
56
## Author: Adirelle
67
## Version: @project-version@
78
## X-Date: @project-date-iso@

AdiBags_Config/AdiBags_Config_Wrath.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Title: AdiBags Configuration
44
## Notes: Adirelle's bag addon.
5+
## IconAtlas: bag-main
56
## Author: Adirelle
67
## Version: @project-version@
78
## X-Date: @project-date-iso@

AdiBags_TBC.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
## Title: AdiBags
2323
## Notes: Adirelle's bag addon.
24+
## IconAtlas: bag-main
2425
## Author: Adirelle
2526
## Version: @project-version@
2627
## SavedVariables: AdiBagsDB

AdiBags_Vanilla.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
## Title: AdiBags
2323
## Notes: Adirelle's bag addon.
24+
## IconAtlas: bag-main
2425
## Author: Adirelle
2526
## Version: @project-version@
2627
## SavedVariables: AdiBagsDB

AdiBags_Wrath.toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
## Title: AdiBags
2323
## Notes: Adirelle's bag addon.
24+
## IconAtlas: bag-main
2425
## Author: Adirelle
2526
## Version: @project-version@
2627
## SavedVariables: AdiBagsDB

modules/DataSource.lua

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ local L = addon.L
2424

2525
--<GLOBALS
2626
local _G = _G
27+
local AddonCompartmentFrame = _G.AddonCompartmentFrame
2728
local format = _G.format
29+
local GameTooltip = _G.GameTooltip
30+
local GetAddOnMetadata = _G.C_AddOns.GetAddOnMetadata
2831
local GetContainerNumFreeSlots = C_Container and _G.C_Container.GetContainerNumFreeSlots or _G.GetContainerNumFreeSlots
2932
local GetContainerNumSlots = C_Container and _G.C_Container.GetContainerNumSlots or _G.GetContainerNumSlots
3033
local ipairs = _G.ipairs
@@ -41,18 +44,31 @@ mod.uiName = L['LDB Plugin']
4144
mod.uiDesc = L['Provides a LDB data source to be displayed by LDB display addons.']
4245
mod.cannotDisable = true
4346

44-
local dataobj = {
45-
type = 'data source',
47+
local dataObject = {
48+
type = "data source",
4649
label = addonName,
4750
text = addonName,
4851
icon = [[Interface\Buttons\Button-Backpack-Up]],
49-
OnClick = function(_, button)
50-
if button == "RightButton" then
52+
OnClick = function(_, mouseButton)
53+
mouseButton = mouseButton.buttonName or mouseButton
54+
if mouseButton == "RightButton" then
5155
addon:OpenOptions()
5256
else
53-
addon:OpenAllBags()
57+
addon:ToggleBackpack()
5458
end
5559
end,
60+
OnEnter = function(self)
61+
local r, g, b = 0.2, 1, 0.2
62+
GameTooltip:SetOwner(self, "ANCHOR_LEFT")
63+
GameTooltip:AddDoubleLine(addonName, GetAddOnMetadata(addonName, "Version"))
64+
GameTooltip:AddLine(" ")
65+
GameTooltip:AddLine(L["|cFFEDA55FLeft-click|r to toggle bags."], r, g, b)
66+
GameTooltip:AddLine(L["|cFFEDA55FRight-click|r to toggle options."], r, g, b)
67+
GameTooltip:Show()
68+
end,
69+
OnLeave = function()
70+
GameTooltip:Hide()
71+
end,
5672
}
5773

5874
function mod:OnInitialize()
@@ -70,7 +86,21 @@ end
7086
local created = false
7187
function mod:OnEnable()
7288
if not created then
73-
LibStub('LibDataBroker-1.1'):NewDataObject(addonName, dataobj)
89+
-- Addon compartment:
90+
-- https://warcraft.wiki.gg/wiki/Addon_compartment
91+
if AddonCompartmentFrame then
92+
AddonCompartmentFrame:RegisterAddon({
93+
text = addonName,
94+
icon = dataObject.icon,
95+
func = dataObject.OnClick,
96+
funcOnEnter = dataObject.OnEnter,
97+
funcOnLeave = dataObject.OnLeave,
98+
registerForAnyClick = true,
99+
notCheckable = true,
100+
})
101+
end
102+
103+
LibStub('LibDataBroker-1.1'):NewDataObject(addonName, dataObject)
74104
created = true
75105
end
76106
self:RegisterBucketEvent('BAG_UPDATE', 0.5, "Update")
@@ -172,9 +202,9 @@ end
172202
function mod:Update(event)
173203
local bags = BuildSpaceString(addon.BAG_IDS.BAGS)
174204
if self.atBank and self.db.profile.showBank then
175-
dataobj.text = format("%s |cff7777ff%s|r", bags, BuildSpaceString(addon.BAG_IDS.BANK))
205+
dataObject.text = format("%s |cff7777ff%s|r", bags, BuildSpaceString(addon.BAG_IDS.BANK))
176206
else
177-
dataobj.text = bags
207+
dataObject.text = bags
178208
end
179209
end
180210

0 commit comments

Comments
 (0)