I think you might want to do something like this:
Lua Code:
--This block of code will move our minimap addon icons to below the minimap in a custom frame
local btnblklist = { --these are the children of the minimap that we DON'T want to move to our button bar, that way when we look for other children, we only take addon icons
['MinimapMailFrame'] = true,
['MinimapBackdrop'] = true,
['GameTimeFrame'] = true,
['TimeManagerClockButton'] = true,
['MiniMapWorldMapButton'] = true,
['MiniMapTracking'] = true,
['MinimapZoomIn'] = true,
['MinimapZoomOut'] = true,
['QueueStatusMinimapButton'] = true,
['MinimapZoneTextButton'] = true
}
local ButtonHoldBarChildren = {ButtonHoldBar:GetChildren()}
local MiniMapChildren = {Minimap:GetChildren()}
local function moveMinimapButtons() --stolen from bdMinimap and changed to be more efficient
ButtonHoldBarChildren = {ButtonHoldBar:GetChildren()}
MiniMapChildren = {Minimap:GetChildren()}
for k, v in pairs(MiniMapChildren) do
if not btnblklist[v:GetName()] then --check against our table made above, only add things that we want in the bar
table.insert(ButtonHoldBarChildren, v)
end
end
local last = nil
for i = 1, #ButtonHoldBarChildren do
local f = ButtonHoldBarChildren[i]
local n = f:GetName() or ''
if ((f:GetName() and (strfind(n, 'LibDB') or strfind(n, 'Button') or strfind(n, 'Btn') or strfind(n,'AllTheThings')) and f:IsShown())) then
if not f.skinned then
f:SetParent(ButtonHoldBar)
local r = {f:GetRegions()}
for o = 1, #r do
if (r[o].GetTexture and r[o]:GetTexture()) then
local tex = r[o]:GetTexture()
r[o]:SetAllPoints(f)
if (hideTextures[tex]) then
r[o]:Hide()
elseif not strfind(tex, 'WHITE8x8') then
local coord = table.concat({r[o]:GetTexCoord()})
if coord == '00011011' then
r[o]:SetTexCoord(0.3, 0.7, 0.3, 0.7)
end
end
end
end
f.tbackground = f.tbackground or CreateFrame('frame', nil, f)
f.tbackground:SetAllPoints()
f.tbackground:SetFrameStrata('BACKGROUND')
f:SetHitRectInsets(0, 0, 0, 0)
f:HookScript('OnEnter', function(self)
local newlines = {}
for l = 1, 10 do
local line = _G['GameTooltipTextLeft'..l]
if (line and line:GetText()) then
newlines[line:GetText()] = true
end
end
GameTooltip:Hide()
GameTooltip:SetOwner(self, 'ANCHOR_TOPLEFT', 0, 6)
for k, v in pairs(newlines) do
GameTooltip:AddLine(k)
end
GameTooltip:Show()
end)
f.skinned = true
end
-- sometimes a frame can get in here twice, don't let it
f:ClearAllPoints()
f:SetSize(20, 20)
if last then
f:SetPoint('TOPLEFT', last, 'TOPRIGHT', 4, 0)
f:SetPoint('BOTTOMRIGHT', last, 'BOTTOMRIGHT', f:GetWidth()+4, 0)
else
f:SetPoint('TOPLEFT', ButtonHoldBar, 'TOPLEFT', 0, 0)
f:SetPoint('BOTTOMRIGHT', ButtonHoldBar, 'TOPLEFT', f:GetWidth(), -f:GetHeight())
end
last = f
end
end
end
--This block of code runs the moveMinimapButtons() once, about 1s after init
--because some addons handle their minimap icons slightly after loading
local g = CreateFrame('frame')
g.elapsed, g.counter = 0, 0
g:SetScript('OnUpdate', function(self, elapsed)
self.elapsed = self.elapsed + elapsed
while (self.elapsed > 1 and self.counter <= 1) do
moveMinimapButtons()
self.counter = self.counter + 1
self.elapsed = 0
end
if self.counter >= 2 then g:SetScript('OnUpdate', nil) end
end)
It probably isn't the most optimized code in the world, but it runs exactly twice on load in and shouldn't impact things after that. It should grab most buttons, but if for some reason you have an addon whose button doesn't, you could /fstack and get its name and add it to this line:
Lua Code:
if ((f:GetName() and (strfind(n, 'LibDB') or strfind(n, 'Button') or strfind(n, 'Btn') or strfind(n,'AllTheThings')) and f:IsShown())) then