I created a minimap button with LIbDBIcon-1.0 that also works. the position is saved, but it doesn't save, if you hide the button, it will be displayed again after the next login and must be deactivated again.
Lua Code:
local TestMMBicon = LibStub("LibDBIcon-1.0", true)
local TestMiniButton = LibStub("AceAddon-3.0"):NewAddon("TestMiniMapButton", "AceConsole-3.0")
Lua Code:
SLASH_MMBSHOW1, SLASH_MMBSHOW2 = "/mnb", "/MNB";
function SlashCmdList.MMBSHOW(msg, editbox)
TestMMBicon:Show("TestMiniMapButton")
end
SLASH_MMBHIDE1, SLASH_MMBHIDE2 = "/mnbh", "/MNBH";
function SlashCmdList.MMBHIDE(msg, editbox)
TestMMBicon:Hide("TestMiniMapButton")
end
Lua Code:
local miniButton = {
text = "TestMiniMapButton",
type = "data source",
icon = "Interface/Minimap/Vehicle-AllianceWarlockPortal",
OnTooltipShow = function(tooltip)
if not tooltip or not tooltip.AddLine then return end
tooltip:AddLine("|cffff0000Map|r|cff00ccffNotes|r")
end,
OnClick = function(self, button)
if button == "RightButton" then
LibStub("AceConfigDialog-3.0"):Close("TestMiniMapButton")
end
if button == "LeftButton" then
LibStub("AceConfigDialog-3.0"):Open("TestMiniMapButton")
end
if IsShiftKeyDown() and button == "RightButton" then
TestMMBicon:Hide("TestMiniMapButton")
end
end}
Lua Code:
function TestMiniButton:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("TestMiniMapButtonDB", { profile = { minimap = { hide = false, }, }, })
TestMMBicon:Register("TestMiniMapButton", miniButton, self.db.profile.minimap)
end
for the minimap button option inside the menu:
Lua Code:
function Addon:PLAYER_LOGIN()
local options = {
type = "group",
name = "Test",
childGroups = "tab",
desc = "test",
get = function(info) return db[info[#info]] end,
set = function(info, v) db[info[#info]] = v HandyNotes:SendMessage("HandyNotes_NotifyUpdate", "TestAddon") end,
args = {
GeneralTab = {
type = "group",
name = "General",
desc = "General settings that apply to Azeroth / Continent / Dungeon map at the same time",
order = 0,
args = {
hideMapNotesMMB = {
type = "header",
name = "-> MiniMapButton <-",
order = 1,
},
showMMB = {
type = "execute",
name = L["show"],
desc = L["Show the minimap button on the minimap"],
order = 1.1,
width = 1.89,
get = function() return db.show["ShowMMB"] end,
func = function() TestMMBicon:Show("TestMiniMapButton") end
},
hideMMB = {
type = "execute",
name = L["hide"],
desc = L["Hide the minimap button on the minimap"],
order = 1.2,
width = 1.89,
get = function() return db.show["HideMMB"] end,
func = function() TestMMBicon:Hide("TestMiniMapButton") end
},
}
}
}
}
HandyNotes:RegisterPluginDB("TestAddon", pluginHandler, options)
self.db = LibStub("AceDB-3.0"):New("HandyNotes_TestAddonDB", defaults, true)
db = self.db.profile
LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("TestMiniMapButton", options)
Addon:RegisterEvent("PLAYER_ENTERING_WORLD")
end