I'm sad that Leatrix, who postetd the code, deleted his entry herre.
Lua Code:
-- Create minimap button
local minibtn = CreateFrame("Button", nil, Minimap)
minibtn:SetFrameLevel(8)
minibtn:SetSize(32,32)
minibtn:SetMovable(true)
-- minibtn:SetNormalTexture("Interface/AddOns/AutoSell/Leatrix_Plus_Up.blp")
-- minibtn:SetPushedTexture("Interface/AddOns/AutoSell/Leatrix_Plus_Up.blp")
-- minibtn:SetHighlightTexture("Interface/AddOns/AutoSell/Leatrix_Plus_Up.blp")
minibtn:SetNormalTexture("Interface/COMMON/Indicator-Yellow.png")
minibtn:SetPushedTexture("Interface/COMMON/Indicator-Yellow.png")
minibtn:SetHighlightTexture("Interface/COMMON/Indicator-Yellow.png")
local myIconPos = 0
-- Control movement
local function UpdateMapBtn()
local Xpoa, Ypoa = GetCursorPosition()
local Xmin, Ymin = Minimap:GetLeft(), Minimap:GetBottom()
Xpoa = Xmin - Xpoa / Minimap:GetEffectiveScale() + 70
Ypoa = Ypoa / Minimap:GetEffectiveScale() - Ymin - 70
myIconPos = math.deg(math.atan2(Ypoa, Xpoa))
minibtn:ClearAllPoints()
minibtn:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 52 - (80 * cos(myIconPos)), (80 * sin(myIconPos)) - 52)
end
minibtn:RegisterForDrag("LeftButton")
minibtn:SetScript("OnDragStart", function()
minibtn:StartMoving()
minibtn:SetScript("OnUpdate", UpdateMapBtn)
end)
minibtn:SetScript("OnDragStop", function()
minibtn:StopMovingOrSizing();
minibtn:SetScript("OnUpdate", nil)
UpdateMapBtn();
end)
-- Set position
minibtn:ClearAllPoints();
minibtn:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 52 - (80 * cos(myIconPos)),(80 * sin(myIconPos)) - 52)
-- Control clicks
minibtn:SetScript("OnClick", function()
print("You clicked me!")
end)
I had added this code, but not seen the Minimap button. I think there has to something else. Anybody knows what is wrong or missing ?
I have tried to use an icon in my directory like the Path that is greyd out, and has still no effect.
I believe SetNormalTexture("Interface/COMMON/Indicator-Yellow.png") , that is a real dircectory path you can find under your installed WOW start directory.
EDIT: After I deleted the old ADDON similar to this i got it to work, but the Button is smaller than normal with no border like the other.
Alternative I try the solution of Rilgamon though there I will will dependenced to the upgrades of the code.
I bind the code into my script.
Lua Code:
local addon = LibStub("AceAddon-3.0"):NewAddon("Bunnies", "AceConsole-3.0")
local bunnyLDB = LibStub("LibDataBroker-1.1"):NewDataObject("Bunnies!", {
type = "data source",
text = "Bunnies!",
icon = "Interface\\Icons\\INV_Chest_Cloth_17",
OnClick = function() print("BUNNIES ARE TAKING OVER THE WORLD") end,
})
local icon = LibStub("LibDBIcon-1.0")
function addon:OnInitialize()
-- Obviously you'll need a ## SavedVariables: BunniesDB line in your TOC, duh!
self.db = LibStub("AceDB-3.0"):New("BunniesDB", {
profile = {
minimap = {
hide = false,
},
},
})
icon:Register("Bunnies!", bunnyLDB, self.db.profile.minimap)
self:RegisterChatCommand("bunnies", "CommandTheBunnies")
end
function addon:CommandTheBunnies()
self.db.profile.minimap.hide = not self.db.profile.minimap.hide
if self.db.profile.minimap.hide then
icon:Hide("Bunnies!")
else
icon:Show("Bunnies!")
end
end
What else do i need to do to get this working ?
1. I see this line
SavedVariables: BunniesDB line in your TOC, and did that
2. icon = "Interface\\Icons\\INV_Chest_Cloth_17",
do I have to change something to get work this ? and how would i be able to use own Icons
3. what else is to do ?
EDIT: I got it to work, it was simpler than i thought. But how can i Implement own Icons ? (Point 2)