This fixes an issue affecting coordination with other addons.
I noticed that although the icon was being shown on the mini-map, addons that combined mini-map buttons would not display this addons icon. This version fixes that problem by adding libdatabroker to handle communication between this addon and others that may need to coordinate with it; including as examples; leatrix plus and titan panel.
This addon is using the four libraries: CallbackHandler-1.0, LibDataBroker-1.1, LibDBIcon-1.0 and LibStub.
Here is the MyAddonFrameExample.toc file:
Lua Code:
## Title: MyAddonFrameExample
## Interface: 100206
## Version: 2.0
## Author: Codger
## Notes: A simple WoW addon with a minimap button derived from LibDB-Icon
## OptionalDeps: LibDBIcon-1.0, LibDataBroker-1.1.lua
## IconTexture: Interface\\Icons\\inv_gizmo_bronzeframework_01
embeds.xml
core.lua
Here is the embeds.xml file:
Lua Code:
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="Libs\LibStub\LibStub.lua"/>
<Include file="Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml"/>
<Script file="Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
<Script file="Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>
</Ui>
Here is the core.lua file:
Lua Code:
local addon = LibStub("AceAddon-3.0"):NewAddon("MyAddonFrameExample")
local MyAddonFrameExampleLDB = LibStub("LibDataBroker-1.1"):NewDataObject("MyAddonFrameExample", {
type = "data source",
text = "MyAddonFrameExample!",
icon = "Interface\\Icons\\inv_gizmo_bronzeframework_01",
OnClick = function(self, button)
if button == "LeftButton" then
MyAddonFrameExample:SetShown(not MyAddonFrameExample:IsShown()) -- toggle show/hide
elseif button == "RightButton" then
ReloadUI()
end
end,
OnTooltipShow = function(tooltip)
tooltip:SetText("MyAddonFrameExample")
tooltip:AddLine("Left-click to open / close", 1, 1, 1)
tooltip:AddLine("Right-click to Reload Ui", 1, 1, 1)
end,
})
local icon = LibStub("LibDBIcon-1.0")
function addon:OnInitialize()
-- Assuming you have a ## SavedVariables: BunniesDB line in your TOC
self.db = LibStub("AceDB-3.0"):New("BunniesDB", {
profile = {
minimap = {
hide = false,
},
},
})
icon:Register("MyAddonFrameExample", MyAddonFrameExampleLDB, self.db.profile.minimap)
end
--Frame names are global and must be unique: 'MyAddonFrameExample'
local frame = CreateFrame("Frame", "MyAddonFrameExample", UIParent, "BackdropTemplate")
frame:SetBackdrop({
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border",
tile=1, tileSize=32, edgeSize=32,
insets={left=10, right=10, top=10, bottom=10}
})
frame:SetPoint("CENTER")
frame:SetSize(200, 200)
frame:EnableMouse(true)
frame:SetMovable(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
local fontStr = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
fontStr:SetPoint("CENTER")
fontStr:SetText("MyAddonFrameExample")
frame:Show()