So I must have been lucky enough in my previous testing to have had another addon installed that loaded AceDB-3.0. A new Wow install due to a computer crash revealed the bug due to the missing library. I also added a saved variable for the database and renamed it from BunniesDB to MyAddonFrameExampleDB and included it in the .toc file.
This addon is using the five libraries: CallbackHandler-1.0, LibDataBroker-1.1, AceDB-3.0, 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
## SavedVariables: MyAddonFrameExampleDB
embeds.xml
core.lua
Here is the embeds.xml file with the added library. The order of the libraries is important/:
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"/>
<Include file="Libs\AceDB-3.0\AceDB-3.0.xml"/>
<Script file="Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
<Script file="Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>
</Ui>
And 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()
self.db = LibStub("AceDB-3.0"):New("MyAddonFrameExampleDB", {
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()