View Single Post
12-10-23, 10:20 AM   #3
Ssesmar
A Deviate Faerie Dragon
Join Date: Oct 2023
Posts: 15
i changed the code from
Lua Code:
  1. function TestMiniButton:OnInitialize()
  2.       self.db = LibStub("AceDB-3.0"):New("TestMiniMapButtonDB", { profile = { minimap = { hide = false, }, }, })
  3.       TestMMBicon:Register("TestMiniMapButton", miniButton, self.db.profile.minimap)
  4.     end
to

Lua Code:
  1. function TestMiniButton:OnInitialize()
  2.       self.db = LibStub("AceDB-3.0"):New("TestMiniMapButtonDB", { profile = { minimap = { hide = false, }, }, })
  3.       TestMMBicon:Register("TestMiniMapButton", miniButton, self.db.profile.minimap)
  4.     end
  5.  
  6.     TestMMBicon:Hide("TestMiniMapButton")
  7.     self.db.show = false
  8.      
  9.     TestMMBicon:Show("TestMiniMapButton")
  10.     self.db.show = true

the file is written in the order as stated above, so:

Lua Code:
  1. local TestMMBicon = LibStub("LibDBIcon-1.0", true)
  2. local TestMiniButton = LibStub("AceAddon-3.0"):NewAddon("TestMiniMapButton", "AceConsole-3.0")
  3.  
  4.  
  5. SLASH_MMBSHOW1, SLASH_MMBSHOW2 = "/mnb", "/MNB";
  6. function SlashCmdList.MMBSHOW(msg, editbox)
  7.   TestMMBicon:Show("TestMiniMapButton")
  8. end
  9.  
  10.  
  11. SLASH_MMBHIDE1, SLASH_MMBHIDE2 = "/mnbh", "/MNBH";
  12. function SlashCmdList.MMBHIDE(msg, editbox)
  13.   TestMMBicon:Hide("TestMiniMapButton")
  14. end
  15.  
  16.  
  17. local miniButton = {
  18.   text = "TestMiniMapButton",
  19.   type = "data source",
  20.   icon = "Interface/Minimap/Vehicle-AllianceWarlockPortal",
  21.   OnTooltipShow = function(tooltip)
  22.   if not tooltip or not tooltip.AddLine then return end
  23.   tooltip:AddLine("|cffff0000Map|r|cff00ccffNotes|r")
  24.   end,
  25.   OnClick = function(self, button)
  26.     if button == "RightButton" then
  27.       LibStub("AceConfigDialog-3.0"):Close("TestMiniMapButton")
  28.     end
  29.     if button == "LeftButton" then
  30.       LibStub("AceConfigDialog-3.0"):Open("TestMiniMapButton")
  31.     end
  32.     if IsShiftKeyDown() and button == "RightButton" then
  33.       TestMMBicon:Hide("TestMiniMapButton")
  34.     end
  35. end}
  36.  
  37.  
  38. function TestMiniButton:OnInitialize()
  39.   self.db = LibStub("AceDB-3.0"):New("TestMiniMapButtonDB", { profile = { minimap = { hide = false, }, }, })
  40.   TestMMBicon:Register("TestMiniMapButton", miniButton, self.db.profile.minimap)
  41. end
  42.  
  43.  
  44. function Addon:PLAYER_LOGIN()
  45. local options = {
  46.   type = "group",
  47.   name = "Test",
  48.   childGroups = "tab",
  49.   desc = "test",
  50.   get = function(info) return db[info[#info]] end,
  51.   set = function(info, v) db[info[#info]] = v HandyNotes:SendMessage("HandyNotes_NotifyUpdate", "TestAddon") end,
  52.   args = {  
  53.     GeneralTab = {
  54.       type = "group",
  55.       name = "General",
  56.       desc = "General settings that apply to Azeroth / Continent / Dungeon map at the same time",
  57.       order = 0,
  58.       args = {
  59.         hideMapNotesMMB = {
  60.           type = "header",
  61.           name = "-> MiniMapButton <-",
  62.           order = 1,
  63.           },
  64.         showMMB = {
  65.           type = "execute",
  66.           name = L["show"],
  67.           desc = L["Show the minimap button on the minimap"],
  68.           order = 1.1,
  69.           width = 1.89,
  70.           get = function() return db.show["ShowMMB"] end,
  71.           func = function() TestMMBicon:Show("TestMiniMapButton") end
  72.           },  
  73.         hideMMB = {
  74.           type = "execute",
  75.           name = L["hide"],
  76.           desc = L["Hide the minimap button on the minimap"],
  77.           order = 1.2,
  78.           width = 1.89,
  79.           get = function() return db.show["HideMMB"] end,
  80.           func = function() TestMMBicon:Hide("TestMiniMapButton") end
  81.           },
  82.       }
  83.     }
  84.   }
  85. }
  86.  
  87.   HandyNotes:RegisterPluginDB("TestAddon", pluginHandler, options)
  88.   self.db = LibStub("AceDB-3.0"):New("HandyNotes_TestAddonDB", defaults, true)
  89.   db = self.db.profile
  90.   LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("TestMiniMapButton", options)
  91.   Addon:RegisterEvent("PLAYER_ENTERING_WORLD")
  92. end

that's right?
  Reply With Quote