I mean't that in your original code wherever you had
Code:
TestMMBicon:Hide("TestMiniMapButton")
you needed to add
Code:
self.db.show = false
and wherever you had
Code:
TestMMBicon:Show("TestMiniMapButton")
you needed to add
Code:
self.db.show = true
Probably a bit more like:
Lua Code:
local TestMMBicon = LibStub("LibDBIcon-1.0", true)
local TestMiniButton = LibStub("AceAddon-3.0"):NewAddon("TestMiniMapButton", "AceConsole-3.0")
SLASH_MMBSHOW1, SLASH_MMBSHOW2 = "/mnb", "/MNB";
function SlashCmdList.MMBSHOW(msg, editbox)
TestMMBicon:Show("TestMiniMapButton")
TestMiniButton.db.show = true -- Added
end
SLASH_MMBHIDE1, SLASH_MMBHIDE2 = "/mnbh", "/MNBH";
function SlashCmdList.MMBHIDE(msg, editbox)
TestMMBicon:Hide("TestMiniMapButton")
TestMiniButton.db.show = false -- Added
end
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}
function TestMiniButton:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("TestMiniMapButtonDB", { profile = { minimap = { hide = false, }, }, })
TestMMBicon:Register("TestMiniMapButton", miniButton, self.db.profile.minimap)
end
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")
TestMiniButton.db.show = true -- Added
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")
TestMiniButton.db.show = false -- Added
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
EDIT: Because Ace doesn't have a
SetShown method.
At PLAYER_LOGIN you would add:
Code:
if not db.show then
TestMMBicon:Hide("TestMiniMapButton")
end
to set the initial state of the button when the user logs in to what was last saved in the db.