Thread Tools Display Modes
Prev Previous Post   Next Post Next
12-10-23, 01:35 AM   #1
Ssesmar
A Deviate Faerie Dragon
Join Date: Oct 2023
Posts: 15
minimap button created with LibDBIcon need help

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:
  1. local TestMMBicon = LibStub("LibDBIcon-1.0", true)
  2. local TestMiniButton = LibStub("AceAddon-3.0"):NewAddon("TestMiniMapButton", "AceConsole-3.0")

Lua Code:
  1. SLASH_MMBSHOW1, SLASH_MMBSHOW2 = "/mnb", "/MNB";
  2. function SlashCmdList.MMBSHOW(msg, editbox)
  3.   TestMMBicon:Show("TestMiniMapButton")
  4. end
  5.  
  6. SLASH_MMBHIDE1, SLASH_MMBHIDE2 = "/mnbh", "/MNBH";
  7. function SlashCmdList.MMBHIDE(msg, editbox)
  8.   TestMMBicon:Hide("TestMiniMapButton")
  9. end

Lua Code:
  1. local miniButton = {
  2.   text = "TestMiniMapButton",
  3.   type = "data source",
  4.   icon = "Interface/Minimap/Vehicle-AllianceWarlockPortal",
  5.   OnTooltipShow = function(tooltip)
  6.   if not tooltip or not tooltip.AddLine then return end
  7.   tooltip:AddLine("|cffff0000Map|r|cff00ccffNotes|r")
  8.   end,
  9.   OnClick = function(self, button)
  10.     if button == "RightButton" then
  11.       LibStub("AceConfigDialog-3.0"):Close("TestMiniMapButton")
  12.     end
  13.     if button == "LeftButton" then
  14.       LibStub("AceConfigDialog-3.0"):Open("TestMiniMapButton")
  15.     end
  16.     if IsShiftKeyDown() and button == "RightButton" then
  17.       TestMMBicon:Hide("TestMiniMapButton")
  18.     end
  19. end}

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

for the minimap button option inside the menu:

Lua Code:
  1. function Addon:PLAYER_LOGIN()
  2. local options = {
  3.   type = "group",
  4.   name = "Test",
  5.   childGroups = "tab",
  6.   desc = "test",
  7.   get = function(info) return db[info[#info]] end,
  8.   set = function(info, v) db[info[#info]] = v HandyNotes:SendMessage("HandyNotes_NotifyUpdate", "TestAddon") end,
  9.   args = {  
  10.     GeneralTab = {
  11.       type = "group",
  12.       name = "General",
  13.       desc = "General settings that apply to Azeroth / Continent / Dungeon map at the same time",
  14.       order = 0,
  15.       args = {
  16.         hideMapNotesMMB = {
  17.           type = "header",
  18.           name = "-> MiniMapButton <-",
  19.           order = 1,
  20.           },
  21.         showMMB = {
  22.           type = "execute",
  23.           name = L["show"],
  24.           desc = L["Show the minimap button on the minimap"],
  25.           order = 1.1,
  26.           width = 1.89,
  27.           get = function() return db.show["ShowMMB"] end,
  28.           func = function() TestMMBicon:Show("TestMiniMapButton") end
  29.           },  
  30.         hideMMB = {
  31.           type = "execute",
  32.           name = L["hide"],
  33.           desc = L["Hide the minimap button on the minimap"],
  34.           order = 1.2,
  35.           width = 1.89,
  36.           get = function() return db.show["HideMMB"] end,
  37.           func = function() TestMMBicon:Hide("TestMiniMapButton") end
  38.           },
  39.       }
  40.     }
  41.   }
  42. }
  43.  
  44.   HandyNotes:RegisterPluginDB("TestAddon", pluginHandler, options)
  45.   self.db = LibStub("AceDB-3.0"):New("HandyNotes_TestAddonDB", defaults, true)
  46.   db = self.db.profile
  47.   LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("TestMiniMapButton", options)
  48.   Addon:RegisterEvent("PLAYER_ENTERING_WORLD")
  49. end
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » minimap button created with LibDBIcon need help


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off