/trunk
local _G = _G |
local buttons = {} |
local defBars = { |
'Action','MultiBarBottomLeft','MultiBarBottomRight','MultiBarLeft','MultiBarRight' |
'Action','MultiBarBottomLeft','MultiBarBottomRight','MultiBarLeft','MultiBarRight','Shapeshift','PetAction' ,'BonusAction' |
} |
local micro = { |
'Character', |
'Spellbook', |
'Talent', |
'Achievement', |
'QuestLog', |
'Guild', |
'PVP', |
'LFD', |
'Raid', |
'EJ', |
'MainMenu', |
'Help', |
} |
local privFrame = { |
['Action'] = "MainMenuBar", |
['BonusAction'] = "BonusActionBarFrame", |
['Shapeshift'] = "ShapeshiftBarFrame", |
} |
addon['MSQ'] = LibStub("Masque",true) |
if(addon['MSQ']) then addon['MSQGroup'] = addon['MSQ']:Group(name,name) end |
local function dragAble() |
return db['dragAble'] |
end |
local hooked = {} |
local dummy = function() end |
local function localButtons() |
wipe(buttons) |
local lastbutton |
for b = 1, #defBars do |
local f |
if(defBars[b] == 'Action') then |
f = _G[name.."ActionBar"] or CreateFrame("Frame", name.."ActionBar", UIParent) |
f:SetWidth(1) |
f:SetHeight(1) |
f:SetPoint("CENTER") |
else |
f = _G[defBars[b]] |
end |
local barname = _G[defBars[b]] and defBars[b] or ( type(privFrame[defBars[b]]) == 'string' and privFrame[defBars[b]] or name..defBars[b].."Bar") |
local f = _G[barname] or CreateFrame("Frame", barname, UIParent, "SecureHandlerStateTemplate") |
UIPARENT_MANAGED_FRAME_POSITIONS[barname] = nil |
if(f) then |
f:SetFrameStrata("MEDIUM") |
if(defBars[b] == 'BonusAction' and not hooked['BonusAction']) then |
f:HookScript("OnShow", function(self,...) |
for i = 1, 12 do |
_G["ActionButton"..i]:SetAlpha(0) |
_G["ActionButton"..i]:EnableMouse(false) |
end |
end) |
f:HookScript("OnHide", function(self,...) |
for i = 1, 12 do |
_G["ActionButton"..i]:SetAlpha(1) |
_G["ActionButton"..i]:EnableMouse(true) |
end |
end) |
hooked['BonusAction'] = true |
f:ClearAllPoints() |
f:SetWidth(1) |
f:SetHeight(1) |
f:SetPoint("CENTER") |
end |
db['bars'][defBars[b]] = db['bars'][defBars[b]] or { |
['rows'] = 1, |
['scale'] = 1, |
} |
f:SetParent(UIParent) |
f:SetScale(db['bars'][defBars[b]]['scale']) |
f['db'] = db['bars'][defBars[b]] |
f['dragAble'] = dragAble |
addon['AddDrag'](f,"BOX",{ |
['width'] = 64, |
['height'] = 64, |
['anchor'] = "TOPLEFT", |
['parentanchor'] = "TOPLEFT", |
['xOffset'] = 16, |
['yOffset'] = 16, |
['offset'] = 16, |
}) |
if(not _G[barname.."drag"]) then |
addon['AddDrag'](f,"BOX",{ |
['width'] = 64, |
['height'] = 64, |
['anchor'] = "TOPLEFT", |
['parentanchor'] = "TOPLEFT", |
['xOffset'] = 16, |
['yOffset'] = 16, |
['offset'] = 16, |
}) |
end |
local i,y = 1,1 |
local row = 0 |
local spr = 12/db['bars'][defBars[b]]['rows'] |
while(_G[defBars[b]..'Button'..i]) do |
local button = _G[defBars[b]..'Button'..i] |
UIPARENT_MANAGED_FRAME_POSITIONS[button:GetName()] = nil |
button:SetParent(f) |
buttons[#buttons + 1] = button |
if(addon['MSQ'] and addon['MSQGroup']) then |
end |
end |
end |
local f = _G[name.."MicroMenu"] or CreateFrame("Frame", name.."MicroMenu", UIParent) |
if(not hooked[f]) then |
f:SetWidth(1) |
f:SetHeight(1) |
f:SetPoint("CENTER") |
if(not _G[name.."MicroMenu".."drag"]) then |
db['bars'][name.."MicroMenu"] = db['bars'][name.."MicroMenu"] or { |
['rows'] = 1, |
['scale'] = 1, |
} |
f['db'] = db['bars'][name.."MicroMenu"] |
f['dragAble'] = dragAble |
addon['AddDrag'](f,"BOX",{ |
['width'] = 64, |
['height'] = 64, |
['anchor'] = "TOPLEFT", |
['parentanchor'] = "TOPLEFT", |
['xOffset'] = 16, |
['yOffset'] = 16, |
['offset'] = 16, |
}) |
end |
hooked[f] = true |
end |
local spr = 12/db['bars'][name.."MicroMenu"]['rows'] |
lastbutton = f |
local y,row = 1,0 |
for i = 1, #micro do |
local btn = _G[micro[i].."MicroButton"] |
if(btn) then |
UIPARENT_MANAGED_FRAME_POSITIONS[btn:GetName()] = nil |
btn:SetParent(f) |
btn:ClearAllPoints() |
if(y == 1) then |
btn:SetPoint("TOPLEFT", f, "TOPLEFT",0 , -row * 34) |
else |
btn:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT") |
end |
y = y + 1 |
lastbutton = btn |
if(y > spr) then |
y = 1 |
row = row + 1 |
end |
end |
end |
f.SetPoint = dummy |
end |
local function getBarPref(pref) |
addon['AddConfigEntry'](addon, name, 'range', 'rows', 'Rows', 'Number of rows', 0,1,12,1,false,o) |
addon['AddConfigEntry'](addon, name, 'range', 'scale', 'Scale', 'Scale of this bar', 1,0.1,3,0.1,true,o) |
end |
local o = addon['AddConfigMenu'](addon, { |
['name'] = name.."MicroMenu", |
['menuGet'] = getBarPref, |
['menuSet'] = setBarPref, |
}, addon['options']['args'][childName]) |
addon['AddConfigEntry'](addon, name, 'range', 'rows', 'Rows', 'Number of rows', 0,1,12,1,false,o) |
addon['AddConfigEntry'](addon, name, 'range', 'scale', 'Scale', 'Scale of this bar', 1,0.1,3,0.1,true,o) |
end |
local function getPref(pref) |
local function setPref(pref,value) |
db[pref[#pref]] = value |
end |
do |
-- Copied from HBar |
local textures = { -- Table with textures we wish to remove |
ReputationWatchBarTexture0, |
ReputationWatchBarTexture1, |
ReputationWatchBarTexture2, |
ReputationWatchBarTexture3, |
ReputationXPBarTexture0, |
ReputationXPBarTexture1, |
ReputationXPBarTexture2, |
ReputationXPBarTexture3, |
MainMenuXPBarTexture0, |
MainMenuXPBarTexture1, |
MainMenuXPBarTexture2, |
MainMenuXPBarTexture3, |
MainMenuMaxLevelBar0, |
MainMenuMaxLevelBar1, |
MainMenuMaxLevelBar2, |
MainMenuMaxLevelBar3, |
MainMenuBarTexture0, |
MainMenuBarTexture1, |
MainMenuBarTexture2, |
MainMenuBarTexture3, |
SlidingActionBarTexture0, |
SlidingActionBarTexture1, |
BonusActionBarTexture0, |
BonusActionBarTexture1, |
} |
local hide = { |
MainMenuBarLeftEndCap, |
MainMenuBarRightEndCap, |
ReputationWatchBar, |
MainMenuExpBar, |
ActionBarUpButton, |
ActionBarDownButton, |
MainMenuBarPageNumber, |
BonusActionBarFrameTexture1, |
BonusActionBarFrameTexture2, |
BonusActionBarFrameTexture3, |
BonusActionBarFrameTexture4, |
} |
for _, frame in pairs(textures) do -- Set the textures of the items in "textures" to nil |
frame:SetTexture(""); |
frame.SetTexture = function() end |
end |
for _, frame in pairs(hide) do -- Set the textures of the items in "textures" to nil |
frame:Hide() |
frame.Show = frame.Hide |
end |
MainMenuBar:SetFrameStrata("BACKGROUND") |
end |
local function init() |
options = addon['InitConfig'](addon, childName, true, { |
['type'] = "launcher", |
localButtons() |
addon['AddConfigEntry'](addon, name, 'toggle', 'dragAble', 'Unlocked', 'Use alt+click to move your bars', 0) |
buildPrefs() |
addon['RegisterFunc']({"UNIT_EXITED_VEHICLE"}, "OnEvent", function(self, event,arg1,...) |
if(arg1 ~= 'player') then return end |
for b = 1, #defBars do |
local barname = _G[defBars[b]] and defBars[b] or ( type(privFrame[defBars[b]]) == 'string' and privFrame[defBars[b]] or name..defBars[b].."Bar") |
local f = _G[barname] or CreateFrame("Frame", barname, UIParent, "SecureHandlerStateTemplate") |
print(f, barname) |
if(f) then |
-- addon['LoadFrame'](f) |
localButtons() |
end |
end |
end) |
end |
addon['startup'](addon, name, childName, init, true, defaults) |