Go to most recent revision | Show entire file | Details | Blame | View Log
Rev 7 | Rev 8 |
---|---|
Line 1... | Line 1... |
local name, addon = ... |
local name, addon = ... |
local childName = name |
|
local defaults = {} |
local defaults = {} |
local options, db |
local options, db |
local _,class = UnitClass('player') |
local _,class = UnitClass('player') |
local _G = _G |
local _G = _G |
local buttons = {} |
local xoffset, yoffset = 8,0 |
local defBars = { |
|
'Action', |
|
'BonusAction', |
|
'MultiBarRight', |
|
'MultiBarLeft', |
|
'MultiBarBottomRight', |
|
'MultiBarBottomLeft', |
|
'Shapeshift', |
|
'PetAction', |
|
} |
|
local privFrame = { |
local function createBar(bid,id) |
['Action'] = true, |
local f = CreateFrame("Frame", "zzABar"..bid, UIParent, "SecureHandlerStateTemplate",id) |
['MultiBarRight'] = true, |
f:SetWidth(1) |
['BonusAction'] = "BonusActionBarFrame", |
f:SetHeight(1) |
['Shapeshift'] = "ShapeshiftBarFrame", |
f:SetPoint("CENTER") |
} |
f:SetAttribute('_onstate-page', [[ |
self:SetAttribute('actionpage', newstate) |
|
local bagButtons = { |
control:ChildUpdate('actionpage', newstate) |
'CharacterBag3Slot', |
]]) |
'CharacterBag2Slot', |
if(class == "WARRIOR") then |
'CharacterBag1Slot', |
RegisterStateDriver(f, "page", "[bonusbar:1] 7;[bonusbar:2] 8;[bonusbar:3] 9;1") |
'CharacterBag0Slot', |
elseif(class == "DRUID") then |
'MainMenuBarBackpackButton', |
RegisterStateDriver(f, "page", "[stance:1] 9;[stance:3,stealth] 8;[stance:3] 7;[stance:5] 10;1") -- 1 bear/ 3 cat/ 5 moonkin |
} |
elseif(class == "ROGUE") then |
addon['MSQ'] = LibStub("Masque",true) |
RegisterStateDriver(f, "page", "[stance:1] 7;[stance:3] 8; 1") -- 1 stealth/ 3 shadow dance |
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 addDrag(self) |
|
if(not hooked[self]) then |
|
local bname = self:GetName() |
|
self:SetParent(UIParent) |
|
self:SetWidth(1) |
|
self:SetHeight(1) |
|
self:SetPoint("CENTER") |
|
if(not _G[bname.."drag"]) then |
|
db['bars'][bname] = db['bars'][bname] or { |
|
['rows'] = 1, |
|
['scale'] = 1, |
|
} |
|
self['db'] = db['bars'][bname] |
|
self['dragAble'] = dragAble |
|
self:SetScale(self['db']['scale']) |
|
addon['AddDrag'](self,"BOX",{ |
|
['width'] = 64, |
|
['height'] = 64, |
|
['anchor'] = "TOPLEFT", |
|
['parentanchor'] = "TOPLEFT", |
|
['xOffset'] = 16, |
|
['yOffset'] = 16, |
|
['offset'] = 16, |
|
}) |
|
end |
|
hooked[self] = true |
|
else |
|
self:SetScale(self['db']['scale']) |
|
end |
|
end |
|
local function getBarname(bname) |
|
return (_G[bname] and privFrame[bname] == nil) and bname or ( type(privFrame[bname]) == 'string' and privFrame[bname] or name..bname.."Bar") |
|
end |
end |
local lastbutton = f |
|
local function resizeDrag(self, lastbutton) |
|
local width = (addon['round'](12/self['db']['rows'],0) + .5) * lastbutton:GetWidth() |
|
local height = (self['db']['rows'] + .5) * lastbutton:GetHeight() |
|
_G[self:GetName().."drag"]:ClearAllPoints() |
|
_G[self:GetName().."drag"]:SetWidth(width) |
|
_G[self:GetName().."drag"]:SetHeight(height) |
|
_G[self:GetName().."drag"]:SetPoint("TOPLEFT", _G[self:GetName().."drag"]:GetParent(), "TOPLEFT", - lastbutton:GetWidth()/4,lastbutton:GetHeight()/4) |
|
end |
|
local function localButtons() |
|
-- wipe(buttons) |
|
local lastbutton |
|
for b = 1, #defBars do |
|
local barname = getBarname(defBars[b]) |
|
local f = _G[barname] or CreateFrame("Frame", barname, UIParent, "SecureHandlerStateTemplate") |
|
UIPARENT_MANAGED_FRAME_POSITIONS[barname] = nil |
|
if(f) then |
|
if(defBars[b]=='Action' and not hooked[f]) then |
|
f:SetAttribute("actionpage",b) |
|
elseif(defBars[b]=='MultiBarRight' and not hooked[f]) then |
|
f:SetAttribute("actionpage",b) |
|
end |
|
f:SetFrameStrata("MEDIUM") |
|
f:SetParent(UIParent) |
|
if(defBars[b] == 'BonusAction' and not hooked[f]) then |
|
f:HookScript("OnShow", function(self,...) |
|
for i = 1, 12 do |
for i = 1, 12 do |
_G["ActionButton"..i]:SetAlpha(0) |
local b = CreateFrame("CheckButton", "$PARENTActionButton"..i, f, "ActionButtonTemplate ActionBarButtonCodeTemplate",i) |
_G["ActionButton"..i]:EnableMouse(false) |
-- b:SetWidth(32) |
end |
-- b:SetHeight(32) |
end) |
b:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT", xoffset, yoffset) |
f:HookScript("OnHide", function(self,...) |
lastbutton = b |
for i = 1, 12 do |
b:SetAttribute('action--base',i) |
_G["ActionButton"..i]:SetAlpha(1) |
b:SetAttribute('showgrid', 1) |
_G["ActionButton"..i]:EnableMouse(true) |
b:SetAttribute('_childupdate-actionpage', [[ |
end |
self:SetAttribute('action', self:GetAttribute('action--base')) |
end) |
]]) |
end |
b:SetAttribute('action', i) |
addDrag(f) |
|
local i,y = 1,1 |
|
local row = 0 |
|
local spr = 12/f['db']['rows'] |
|
lastbutton = f |
|
while(_G[defBars[b]..'Button'..i]) do |
|
local button = _G[defBars[b]..'Button'..i] |
|
UIPARENT_MANAGED_FRAME_POSITIONS[button:GetName()] = nil |
|
button:SetParent(f) |
|
if(defBars[b] == 'Action') then |
|
button:SetID(i) |
|
else |
|
-- button:SetID(0) |
|
end |
|
if(addon['MSQ'] and addon['MSQGroup'] and not buttons[button]) then |
|
buttons[button] = true |
|
addon['MSQGroup']:AddButton(button) |
|
end |
|
button:ClearAllPoints() |
|
if(y == 1) then |
|
button:SetPoint("TOPLEFT", f, "TOPLEFT",0 , -row * button:GetHeight()) |
|
else |
|
button:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT") |
|
end |
|
lastbutton = button |
|
i = i + 1 |
|
y = y + 1 |
|
if(y > spr) then |
|
y = 1 |
|
row = row + 1 |
|
end |
|
end |
|
end |
|
resizeDrag(f, lastbutton) |
|
end |
|
local f = _G[name.."MicroMenu"] or CreateFrame("Frame", name.."MicroMenu", UIParent) |
|
addDrag(f) |
|
local spr = 12/db['bars'][f:GetName()]['rows'] |
|
lastbutton = f |
|
local y,row = 1,0 |
|
for _, bname in pairs(MICRO_BUTTONS) do |
|
local btn = _G[bname] |
|
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 |
|
resizeDrag(f, lastbutton) |
|
f = _G[name.."BagBar"] or CreateFrame("Frame", name.."BagBar", UIParent) |
|
addDrag(f) |
|
local spr = 12/db['bars'][f:GetName()]['rows'] |
|
lastbutton = f |
|
local y,row = 1,0 |
|
for i = 1, #bagButtons do |
|
local btn = _G[bagButtons[i]] |
|
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 |
|
if(addon['MSQ'] and addon['MSQGroup'] and not buttons[btn]) then |
|
buttons[btn] = true |
|
addon['MSQGroup']:AddButton(btn) |
|
end |
end |
lastbutton = btn |
|
if(y > spr) then |
|
y = 1 |
|
row = row + 1 |
|
end |
|
end |
|
end |
|
resizeDrag(f, lastbutton) |
|
if(BonusActionBarFrame:IsVisible()) then |
|
for i = 1, 12 do |
|
_G["ActionButton"..i]:SetAlpha(class == 'WARRIOR' and 1 or 0) |
|
_G["ActionButton"..i]:EnableMouse(class=='WARRIOR') |
|
end |
|
end |
|
end |
|
local function getBarPref(pref) |
|
return db['bars'][pref[#pref-1]][pref[#pref]] |
|
end |
|
local function setBarPref(pref,value) |
|
db['bars'][pref[#pref-1]][pref[#pref]] = value |
|
localButtons() |
|
end |
|
local function resetCenter(pref) |
|
_G[pref[#pref-1]]:center() |
|
end |
|
local function buildPrefs() |
|
for b = 1, #defBars do |
|
local bname = getBarname(defBars[b]) |
|
local o = addon['AddConfigMenu'](addon, { |
|
['name'] = bname, |
|
['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) |
|
addon['AddConfigEntry'](addon, name, 'execute', 'center', 'Center', 'Reset position', 2,resetCenter,nil,nil,nil,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) |
|
return db[pref[#pref]] |
|
end |
end |
local function setPref(pref,value) |
local function init(self, event, ...) |
db[pref[#pref]] = value |
_,class = UnitClass('player') |
end |
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 |
addon['preloads'][#addon['preloads'] + 1] = function(self,event,...) |
frame:SetTexture(""); |
createBar(1,1) |
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 togglePriv(show) |
|
for k,v in pairs(privFrame) do |
|
if(type(v) == 'boolean') then |
|
_G[name..k.."Bar"]:SetAlpha(show and 1 or 0) |
|
end |
|
end |
|
end |
|
local function init() |
|
options = addon['InitConfig'](addon, childName, true, { |
|
['type'] = "launcher", |
|
}, getPref, setPref) |
|
db = addon['db']['profile'][childName] |
|
db['bars'] = db['bars'] or {} |
|
localButtons() |
|
addon['AddConfigEntry'](addon, name, 'toggle', 'dragAble', 'Unlocked', 'Use alt+click to move your bars', 0) |
|
buildPrefs() |
|
addon['RegisterFunc']({"UNIT_EXITED_VEHICLE","UNIT_ENTERING_VEHICLE"}, "OnEvent", function(self, event,arg1,...) |
|
if(arg1 ~= 'player') then return end |
|
if(event == "UNIT_EXITED_VEHICLE") then |
|
togglePriv(true) |
|
elseif(event == "UNIT_ENTERING_VEHICLE") then |
|
togglePriv(false) |
|
end |
|
end) |
|
MoveMicroButtons = function() end |
|
VehicleMenuBar_MoveMicroButtons = function() end |
|
end |
end |
addon['startup'](addon, name, childName, init, true, defaults) |
|
No newline at end of file |
No newline at end of file |
addon['startup'](addon, name, name, init, true, defaults) |
|
No newline at end of file |
No newline at end of file |