diff --git a/modules/actionbar.lua b/modules/actionbar.lua index 16ed0643..11e13897 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -13,7 +13,7 @@ pfUI:RegisterModule("actionbar", function () end function ShowBonusActionBar() - for i=1, 12 do getglobal("ActionButton" .. i):SetAlpha(0) end + for i=1, NUM_ACTIONBAR_BUTTONS do getglobal("ActionButton" .. i):Hide() end Hook_ShowBonusActionBar() end @@ -22,7 +22,7 @@ pfUI:RegisterModule("actionbar", function () end function HideBonusActionBar() - for i=1, 12 do getglobal("ActionButton" .. i):SetAlpha(1) end + for i=1, NUM_ACTIONBAR_BUTTONS do getglobal("ActionButton" .. i):Show() end Hook_HideBonusActionBar() end @@ -98,45 +98,45 @@ pfUI:RegisterModule("actionbar", function () pfUI.bars:RegisterEvent("PET_BAR_SHOWGRID") pfUI.bars:RegisterEvent("PET_BAR_HIDEGRID") - pfUI.bars.bottom = CreateFrame("Frame", "pfBarBottom", UIParent) - pfUI.bars.shapeshift = CreateFrame("Frame", "pfBarShapeshift", UIParent) - pfUI.bars.bottomleft = CreateFrame("Frame", "pfBarBottomLeft", UIParent) - pfUI.bars.bottomright = CreateFrame("Frame", "pfBarBottomRight", UIParent) - pfUI.bars.vertical = CreateFrame("Frame", "pfBarVertical", UIParent) - pfUI.bars.pet = CreateFrame("Frame", "pfBarPet", UIParent) + pfUI.bars.actionmain = CreateFrame("Frame", "pfBarActionMain", UIParent) + pfUI.bars.shapeshift = CreateFrame("Frame", "pfBarShapeshift", UIParent) + pfUI.bars.bottomleft = CreateFrame("Frame", "pfBarBottomLeft", UIParent) + pfUI.bars.bottomright = CreateFrame("Frame", "pfBarBottomRight", UIParent) + pfUI.bars.right = CreateFrame("Frame", "pfBarRight", UIParent) + pfUI.bars.tworight = CreateFrame("Frame", "pfBarTwoRight", UIParent) + pfUI.bars.pet = CreateFrame("Frame", "pfBarPet", UIParent) PetActionBarFrame:SetParent(pfUI.bars.pet) pfUI.bars:SetScript("OnEvent", function() - local bpc = 1; if MultiBarBottomLeft:IsShown() then bpc = bpc + 1 end -- bottom panel count - pfUI.bars.bottom:SetWidth((pfUI_config.bars.icon_size + default_border*3) * 12 - default_border) - pfUI.bars.bottom:SetHeight((pfUI_config.bars.icon_size + default_border*3) * bpc - default_border) + pfUI.api:BarLayoutSize(pfUI.bars.actionmain, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.actionmain.formfactor, pfUI_config.bars.icon_size, default_border) + pfUI.bars.actionmain:SetWidth(pfUI.bars.actionmain._size[1]) + pfUI.bars.actionmain:SetHeight(pfUI.bars.actionmain._size[2]) if (PetHasActionBar()) then PetActionBar_Update() pfUI.bars.pet:Show() - pfUI.bars.pet:SetFrameStrata("LOW") - pfUI.bars.pet:SetPoint("BOTTOM", pfUI.bars.bottom, "TOP", 0, default_border * 5) + local anchor = pfUI.bars.actionmain + if pfUI.bars.bottomleft:IsShown() then + anchor = pfUI.bars.bottomleft + end + pfUI.bars.pet:SetPoint("BOTTOM", anchor, "TOP", 0, default_border * 5) pfUI.api:UpdateMovable(pfUI.bars.pet) + pfUI.api:BarLayoutSize(pfUI.bars.pet, NUM_PET_ACTION_SLOTS, pfUI_config.bars.pet.formfactor, pfUI_config.bars.icon_size, default_border) + pfUI.bars.pet:SetWidth(pfUI.bars.pet._size[1]) + pfUI.bars.pet:SetHeight(pfUI.bars.pet._size[2]) if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.pet, default_border) end - pfUI.bars.pet:SetWidth((pfUI_config.bars.icon_size + default_border*3) * 10 - default_border) - pfUI.bars.pet:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 1 - default_border) PetActionBarFrame:ClearAllPoints() PetActionBarFrame:Hide() - for i=1, 10 do + for i=1, NUM_PET_ACTION_SLOTS do local b = getglobal("PetActionButton"..i) - local b2 = getglobal("PetActionButton"..i-1) or b b:ClearAllPoints() b:SetParent(pfUI.bars.pet) pfUI.api:CreateBackdrop(b, default_border) - - if i == 1 then - b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) - else - b:SetPoint("LEFT", b2, "RIGHT", default_border*3, 0) - end + pfUI.api:BarButtonAnchor(b, "PetActionButton", i, NUM_PET_ACTION_SLOTS, pfUI_config.bars.pet.formfactor, pfUI_config.bars.icon_size, default_border) + b:SetPoint(unpack(b._anchor)) end else pfUI.bars.pet:Hide() @@ -145,250 +145,265 @@ pfUI:RegisterModule("actionbar", function () local shapeshiftbuttons = 0 if ShapeshiftButton1:IsShown() then pfUI.bars.shapeshift:Show() + ShapeshiftBarFrame:ClearAllPoints() + ShapeshiftBarFrame:SetAllPoints(pfUI.bars.shapeshift) + + for i=1, NUM_SHAPESHIFT_SLOTS do + local b = getglobal("ShapeshiftButton"..i) + b:ClearAllPoints() + b:SetParent(pfUI.bars.shapeshift) + pfUI.api:CreateBackdrop(b, default_border) + pfUI.api:BarButtonAnchor(b, "ShapeshiftButton", i, NUM_SHAPESHIFT_SLOTS, pfUI_config.bars.shapeshift.formfactor, pfUI_config.bars.icon_size, default_border) + b:SetPoint(unpack(b._anchor)) + if b:IsShown() then shapeshiftbuttons = shapeshiftbuttons + 1 end + end + + local anchor = pfUI.bars.actionmain + if pfUI.bars.bottomleft:IsShown() then + anchor = pfUI.bars.bottomleft + end + pfUI.bars.shapeshift:SetPoint("BOTTOM", anchor, "TOP", 0, default_border * 5) + pfUI.api:UpdateMovable(pfUI.bars.shapeshift) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.shapeshift, default_border) end + pfUI.api:BarLayoutSize(pfUI.bars.shapeshift, shapeshiftbuttons, pfUI_config.bars.shapeshift.formfactor, pfUI_config.bars.icon_size, default_border) + pfUI.bars.shapeshift:SetWidth(pfUI.bars.shapeshift._size[1]) + pfUI.bars.shapeshift:SetHeight(pfUI.bars.shapeshift._size[2]) else pfUI.bars.shapeshift:Hide() end - ShapeshiftBarFrame:ClearAllPoints() - ShapeshiftBarFrame:SetAllPoints(pfUI.bars.shapeshift) - - for i=1, 10 do - local b = getglobal("ShapeshiftButton"..i) - local b2 = getglobal("ShapeshiftButton"..i-1) or b - b:ClearAllPoints() - b:SetParent(pfUI.bars.shapeshift) - pfUI.api:CreateBackdrop(b, default_border) - - if i == 1 then - b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) - else - b:SetPoint("LEFT", b2, "RIGHT", default_border*3, 0) - end - if b:IsShown() then shapeshiftbuttons = shapeshiftbuttons + 1 end - end - - --pfUI.bars.shapeshift:SetFrameStrata("LOW") - pfUI.bars.shapeshift:SetPoint("BOTTOM", pfUI.bars.bottom, "TOP", 0, default_border * 5) - pfUI.api:UpdateMovable(pfUI.bars.shapeshift) - if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.shapeshift, default_border) end - pfUI.bars.shapeshift:SetWidth((pfUI_config.bars.icon_size + default_border*3) * shapeshiftbuttons - default_border) - pfUI.bars.shapeshift:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 1 - default_border) - if SHOW_MULTI_ACTIONBAR_1 then - MultiBarBottomLeft:SetParent(pfUI.bars.bottom) - MultiBarBottomLeft:ClearAllPoints() - MultiBarBottomLeft:SetAllPoints(pfUI.bars.bottom) - - -- create temp frame to give a named parent to the buttons - if not pfUI.bars.bottom.setuptf then - pfUI.bars.bottom.setuptf = true - local tf = CreateFrame("Frame", "pfMultiBarBottomLeft", UIParent ) - tf:SetParent(pfUI.bars.bottom) - tf:SetAllPoints(pfUI.bars.bottom) - - for i=1, 12 do - local b = getglobal("MultiBarBottomLeftButton"..i) - local b2 = getglobal("MultiBarBottomLeftButton"..i-1) or b - b:ClearAllPoints() - b:SetParent(tf) - pfUI.api:CreateBackdrop(b, default_border) - - if i == 1 then - b:SetPoint("TOPLEFT", tonumber(default_border), -tonumber(default_border)) - else - b:SetPoint("LEFT", b2, "RIGHT", default_border*3, 0) - end - end - end - end - - if SHOW_MULTI_ACTIONBAR_2 then pfUI.bars.bottomleft:Show() pfUI.bars.bottomleft:SetFrameStrata("LOW") - pfUI.bars.bottomleft:SetPoint("BOTTOMRIGHT", pfUI.bars.bottom, "BOTTOMLEFT", -default_border*5, 0) + pfUI.bars.bottomleft:ClearAllPoints() + pfUI.bars.bottomleft:SetPoint("BOTTOM", pfUI.bars.actionmain, "TOP", 0, default_border) pfUI.api:UpdateMovable(pfUI.bars.bottomleft) - if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.bottomleft, default_border) end - pfUI.bars.bottomleft:SetWidth((pfUI_config.bars.icon_size + default_border*3) * 6 - default_border) - pfUI.bars.bottomleft:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 2 - default_border) - MultiBarBottomRight:SetParent(pfUI.bars.bottomleft) - MultiBarBottomRight:ClearAllPoints() - MultiBarBottomRight:SetAllPoints(pfUI.bars.bottomleft) + pfUI.api:BarLayoutSize(pfUI.bars.bottomleft, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.bottomleft.formfactor, pfUI_config.bars.icon_size, default_border) + pfUI.bars.bottomleft:SetWidth(pfUI.bars.bottomleft._size[1]) + pfUI.bars.bottomleft:SetHeight(pfUI.bars.bottomleft._size[2]) + + MultiBarBottomLeft:SetParent(pfUI.bars.bottomleft) + MultiBarBottomLeft:ClearAllPoints() + MultiBarBottomLeft:SetAllPoints(pfUI.bars.bottomleft) -- create temp frame to give a named parent to the buttons if not pfUI.bars.bottomleft.setuptf then pfUI.bars.bottomleft.setuptf = true - local tf = CreateFrame("Frame", "pfMultiBarBottomRight", UIParent ) + local tf = CreateFrame("Frame", "pfMultiBarBottomLeft", UIParent ) tf:SetParent(pfUI.bars.bottomleft) tf:SetAllPoints(pfUI.bars.bottomleft) - for i=1, 6 do - local b = getglobal("MultiBarBottomRightButton"..i) - local b2 = getglobal("MultiBarBottomRightButton"..i-1) or b + for i=1, NUM_ACTIONBAR_BUTTONS do + local b = getglobal("MultiBarBottomLeftButton"..i) b:ClearAllPoints() b:SetParent(tf) pfUI.api:CreateBackdrop(b, default_border) - - if i == 1 then - b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) - else - b:SetPoint("LEFT", b2, "RIGHT", default_border*3, 0) - end - end - for i=7, 12 do - local b = getglobal("MultiBarBottomRightButton"..i) - local b2 = getglobal("MultiBarBottomRightButton"..i-6) - b:ClearAllPoints() - b:SetParent(tf) - pfUI.api:CreateBackdrop(b, default_border) - - b:SetPoint("LEFT", b2, "RIGHT", -pfUI_config.bars.icon_size, pfUI_config.bars.icon_size + default_border*3) + pfUI.api:BarButtonAnchor(b, "MultiBarBottomLeftButton", i, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.bottomleft.formfactor, pfUI_config.bars.icon_size, default_border) + b:SetPoint(unpack(b._anchor)) end end else pfUI.bars.bottomleft:Hide() end - if SHOW_MULTI_ACTIONBAR_3 then + pfUI.bars.actionmain:ClearAllPoints() + pfUI.bars.actionmain:SetPoint("BOTTOM", UIParent ,"BOTTOM",0,5) + + if SHOW_MULTI_ACTIONBAR_2 then pfUI.bars.bottomright:Show() pfUI.bars.bottomright:SetFrameStrata("LOW") - pfUI.bars.bottomright:SetPoint("BOTTOMLEFT", pfUI.bars.bottom, "BOTTOMRIGHT", default_border*5, 0) + pfUI.bars.bottomright:SetPoint("BOTTOMRIGHT", pfUI.bars.actionmain, "BOTTOMLEFT", -default_border*5, 0) pfUI.api:UpdateMovable(pfUI.bars.bottomright) if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.bottomright, default_border) end - pfUI.bars.bottomright:SetWidth((pfUI_config.bars.icon_size + default_border*3) * 6 - default_border) - pfUI.bars.bottomright:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 2 - default_border) + pfUI.api:BarLayoutSize(pfUI.bars.bottomright, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.bottomright.formfactor, pfUI_config.bars.icon_size, default_border) + pfUI.bars.bottomright:SetWidth(pfUI.bars.bottomright._size[1]) + pfUI.bars.bottomright:SetHeight(pfUI.bars.bottomright._size[2]) - MultiBarRight:SetParent(pfUI.bars.bottomright) - MultiBarRight:ClearAllPoints() - MultiBarRight:SetAllPoints(pfUI.bars.bottomright) + MultiBarBottomRight:SetParent(pfUI.bars.bottomright) + MultiBarBottomRight:ClearAllPoints() + MultiBarBottomRight:SetAllPoints(pfUI.bars.bottomright) -- create temp frame to give a named parent to the buttons if not pfUI.bars.bottomright.setuptf then pfUI.bars.bottomright.setuptf = true - local tf = CreateFrame("Frame", "pfMultiBarRight", UIParent ) + local tf = CreateFrame("Frame", "pfMultiBarBottomRight", UIParent ) tf:SetParent(pfUI.bars.bottomright) tf:SetAllPoints(pfUI.bars.bottomright) - for i=1, 6 do - local b = getglobal("MultiBarRightButton"..i) - local b2 = getglobal("MultiBarRightButton"..i-1) or b + for i=1, NUM_ACTIONBAR_BUTTONS do + local b = getglobal("MultiBarBottomRightButton"..i) b:ClearAllPoints() b:SetParent(tf) pfUI.api:CreateBackdrop(b, default_border) - - if i == 1 then - b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) - else - b:SetPoint("LEFT", b2, "RIGHT", default_border*3, 0) - end - end - for i=7, 12 do - local b = getglobal("MultiBarRightButton"..i) - local b2 = getglobal("MultiBarRightButton"..i-6) - b:ClearAllPoints() - b:SetParent(tf) - pfUI.api:CreateBackdrop(b, default_border) - - b:SetPoint("LEFT", b2, "RIGHT", -pfUI_config.bars.icon_size, pfUI_config.bars.icon_size + default_border*3) + pfUI.api:BarButtonAnchor(b, "MultiBarBottomRightButton", i, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.bottomright.formfactor, pfUI_config.bars.icon_size, default_border) + b:SetPoint(unpack(b._anchor)) end end else pfUI.bars.bottomright:Hide() end - if SHOW_MULTI_ACTIONBAR_4 and SHOW_MULTI_ACTIONBAR_3 then - pfUI.bars.vertical:Show() - pfUI.bars.vertical:SetFrameStrata("LOW") - pfUI.bars.vertical:SetPoint("RIGHT", -5, 0) - pfUI.api:UpdateMovable(pfUI.bars.vertical) - if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.vertical, default_border) end - pfUI.bars.vertical:SetWidth((pfUI_config.bars.icon_size + default_border*3) * 1 - default_border) - pfUI.bars.vertical:SetHeight((pfUI_config.bars.icon_size + default_border*3) * 12 - default_border) + if SHOW_MULTI_ACTIONBAR_3 then + pfUI.bars.right:Show() + pfUI.bars.right:SetFrameStrata("LOW") + pfUI.bars.right:SetPoint("BOTTOMLEFT", pfUI.bars.actionmain, "BOTTOMRIGHT", default_border*5, 0) + pfUI.api:UpdateMovable(pfUI.bars.right) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.right, default_border) end - MultiBarLeft:SetParent(pfUI.bars.vertical) - MultiBarLeft:ClearAllPoints() - MultiBarLeft:SetAllPoints(pfUI.bars.vertical) + pfUI.api:BarLayoutSize(pfUI.bars.right, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.right.formfactor, pfUI_config.bars.icon_size, default_border) + pfUI.bars.right:SetWidth(pfUI.bars.right._size[1]) + pfUI.bars.right:SetHeight(pfUI.bars.right._size[2]) + + MultiBarRight:SetParent(pfUI.bars.right) + MultiBarRight:ClearAllPoints() + MultiBarRight:SetAllPoints(pfUI.bars.right) -- create temp frame to give a named parent to the buttons - if not pfUI.bars.vertical.setuptf then - pfUI.bars.vertical.setuptf = true - local tf = CreateFrame("Frame", "pfMultiBarLeft", UIParent ) - tf:SetParent(pfUI.bars.vertical) - tf:SetAllPoints(pfUI.bars.vertical) + if not pfUI.bars.right.setuptf then + pfUI.bars.right.setuptf = true + local tf = CreateFrame("Frame", "pfMultiBarRight", UIParent ) + tf:SetParent(pfUI.bars.right) + tf:SetAllPoints(pfUI.bars.right) - for i=1, 12 do - local b = getglobal("MultiBarLeftButton"..i) - local b2 = getglobal("MultiBarLeftButton"..i-1) or b + for i=1, NUM_ACTIONBAR_BUTTONS do + local b = getglobal("MultiBarRightButton"..i) b:ClearAllPoints() b:SetParent(tf) pfUI.api:CreateBackdrop(b, default_border) - - if i == 1 then - b:SetPoint("TOPLEFT", tonumber(default_border), -tonumber(default_border)) - else - b:SetPoint("TOP", b2, "BOTTOM", 0, -default_border*3) - end + pfUI.api:BarButtonAnchor(b, "MultiBarRightButton", i, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.right.formfactor, pfUI_config.bars.icon_size, default_border) + b:SetPoint(unpack(b._anchor)) end end else - pfUI.bars.vertical:Hide() + pfUI.bars.right:Hide() + end + + if SHOW_MULTI_ACTIONBAR_4 and SHOW_MULTI_ACTIONBAR_3 then + pfUI.bars.tworight:Show() + pfUI.bars.tworight:SetFrameStrata("LOW") + pfUI.bars.tworight:ClearAllPoints() + pfUI.bars.tworight:SetPoint("RIGHT", UIParent, "RIGHT", -5, 0) + pfUI.api:UpdateMovable(pfUI.bars.tworight) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.tworight, default_border) end + pfUI.api:BarLayoutSize(pfUI.bars.tworight, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.tworight.formfactor, pfUI_config.bars.icon_size, default_border) + pfUI.bars.tworight:SetWidth(pfUI.bars.tworight._size[1]) + pfUI.bars.tworight:SetHeight(pfUI.bars.tworight._size[2]) + + MultiBarLeft:SetParent(pfUI.bars.tworight) + MultiBarLeft:ClearAllPoints() + MultiBarLeft:SetAllPoints(pfUI.bars.tworight) + + -- create temp frame to give a named parent to the buttons + if not pfUI.bars.tworight.setuptf then + pfUI.bars.tworight.setuptf = true + local tf = CreateFrame("Frame", "pfMultiBarLeft", UIParent ) + tf:SetParent(pfUI.bars.tworight) + tf:SetAllPoints(pfUI.bars.tworight) + + for i=1, NUM_ACTIONBAR_BUTTONS do + local b = getglobal("MultiBarLeftButton"..i) + b:ClearAllPoints() + b:SetParent(tf) + pfUI.api:CreateBackdrop(b, default_border) + pfUI.api:BarButtonAnchor(b, "MultiBarLeftButton", i, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.tworight.formfactor, pfUI_config.bars.icon_size, default_border) + b:SetPoint(unpack(b._anchor)) + end + end + else + pfUI.bars.tworight:Hide() + end + pfUI.api:UpdateMovable(pfUI.bars.actionmain) + + local _, a, _ = pfUI.bars.bottomleft:GetPoint() + if a and a == pfUI.bars.actionmain and pfUI.bars.bottomleft:IsShown() and pfUI.bars.bottomleft:GetWidth() == a:GetWidth() and pfUI.bars.bottomleft:GetScale() == a:GetScale() then + -- share one backdrop + if not pfUI.bars.actionmain.share then + pfUI.bars.actionmain.share = CreateFrame("Frame", "pfBottomBackdrop", UIParent) + pfUI.bars.actionmain.share:SetFrameStrata("LOW") + pfUI.bars.actionmain.share:SetPoint("TOPLEFT", pfUI.bars.bottomleft, "TOPLEFT", 0, 0) + pfUI.bars.actionmain.share:SetPoint("BOTTOMLEFT", pfUI.bars.actionmain, "BOTTOMLEFT", 0, 0) + pfUI.bars.actionmain.share:SetPoint("TOPRIGHT", pfUI.bars.bottomleft, "TOPRIGHT", 0, 0) + pfUI.bars.actionmain.share:SetPoint("BOTTOMRIGHT", pfUI.bars.actionmain, "BOTTOMRIGHT", 0, 0) + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.actionmain.share, default_border) end + end + else + -- give both their own backdrop + if pfUI.bars.actionmain.share then pfUI.bars.actionmain.share:Hide() end + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.actionmain, default_border) end + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.bottomleft, default_border) end end end) - -- create bottom bar frame - pfUI.bars.bottom:SetFrameStrata("LOW") - pfUI.bars.bottom:SetPoint("BOTTOM", 0, 5) - pfUI.api:UpdateMovable(pfUI.bars.bottom) - if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.bottom, default_border) end + -- create main action bar frame + pfUI.bars.actionmain:SetFrameStrata("LOW") + pfUI.api:UpdateMovable(pfUI.bars.actionmain) - for i=1, 12 do - local b = getglobal("ActionButton"..i) - local b2 = getglobal("ActionButton"..i-1) or b - b:ClearAllPoints() - b:SetParent(pfUI.bars.bottom) - pfUI.api:CreateBackdrop(b, default_border) + function pfUI.bars.bottomleft:OnMove() + local _, a, _ = pfUI.bars.bottomleft:GetPoint() + if a ~= pfUI.bars.actionmain or not pfUI.bars.bottomleft:IsShown() or pfUI.bars.bottomleft:GetWidth() ~= a:GetWidth() or pfUI.bars.bottomleft:GetScale() ~= a:GetScale() then + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.actionmain, default_border) end + if pfUI_config.bars.background == "1" then pfUI.api:CreateBackdrop(pfUI.bars.bottomleft, default_border) end + if pfUI.bars.actionmain.share then pfUI.bars.actionmain.share:Hide() end + end + end - if i == 1 then - b:SetPoint("BOTTOMLEFT", tonumber(default_border), tonumber(default_border)) - else - b:SetPoint("LEFT", b2, "RIGHT", default_border*3, 0) + -- create temp frame to give a named parent to the buttons + if not pfUI.bars.actionmain.setuptf then + pfUI.bars.actionmain.setuptf = true + local tf = CreateFrame("Frame","pfActionBar", UIParent) + tf:SetParent(pfUI.bars.actionmain) + tf:SetAllPoints(pfUI.bars.actionmain) + + for i=1, NUM_ACTIONBAR_BUTTONS do + local b = getglobal("ActionButton"..i) + b:ClearAllPoints() + b:SetParent(tf) + pfUI.api:CreateBackdrop(b, default_border) + pfUI.api:BarButtonAnchor(b, "ActionButton", i, NUM_ACTIONBAR_BUTTONS, pfUI_config.bars.actionmain.formfactor, pfUI_config.bars.icon_size, default_border) + b:SetPoint(unpack(b._anchor)) end end BonusActionBarFrame:ClearAllPoints() - BonusActionBarFrame:SetParent(pfUI.bars.bottom) - BonusActionBarFrame:SetAllPoints(pfUI.bars.bottom) + BonusActionBarFrame:SetParent(pfUI.bars.actionmain) + BonusActionBarFrame:SetAllPoints(pfUI.bars.actionmain) BonusActionBarFrame:EnableMouse(0) - for i=1, 12 do - local b = getglobal("BonusActionButton"..i) - local b2 = getglobal("BonusActionButton"..i-1) or b - b:ClearAllPoints() - b:SetParent(BonusActionBarFrame) - pfUI.api:CreateBackdrop(b, default_border) - - if i == 1 then - b:SetPoint("BOTTOMLEFT", tonumber(default_border) - 4, tonumber(default_border)) - else - b:SetPoint("LEFT", b2, "RIGHT", default_border*3, 0) + do + local tf = getglobal("pfBonusBar") or CreateFrame("Frame","pfBonusBar", UIParent) + tf:SetParent(pfUI.bars.actionmain) + tf:SetAllPoints(pfUI.bars.actionmain) + for i=1, NUM_BONUS_ACTION_SLOTS do + local b = getglobal("BonusActionButton"..i) + b:ClearAllPoints() + b:SetParent(tf) + pfUI.api:CreateBackdrop(b, default_border) + pfUI.api:BarButtonAnchor(b, "BonusActionButton", i, NUM_BONUS_ACTION_SLOTS, pfUI_config.bars.actionmain.formfactor, pfUI_config.bars.icon_size, default_border) + b:SetPoint(unpack(b._anchor)) end end - for i = 1, 10 do + for i = 1, NUM_SHAPESHIFT_SLOTS do getglobal("ShapeshiftButton"..i):SetWidth(pfUI_config.bars.icon_size) getglobal("ShapeshiftButton"..i):SetHeight(pfUI_config.bars.icon_size) getglobal("ShapeshiftButton"..i).showgrid = 1 - getglobal("ShapeshiftButton"..i..'Icon'):SetParent(getglobal("ShapeshiftButton"..i)) + getglobal("ShapeshiftButton"..i..'Icon'):SetParent(getglobal("ShapeshiftButton"..i)) getglobal("ShapeshiftButton"..i..'Icon'):SetAllPoints(getglobal("ShapeshiftButton"..i)) getglobal("ShapeshiftButton"..i..'Icon'):SetTexCoord(.08, .92, .08, .92) getglobal("ShapeshiftButton"..i..'NormalTexture'):SetAlpha(0) getglobal("ShapeshiftButton"..i..'Border'):SetAlpha(0) + + getglobal("ShapeshiftButton"..i..'HotKey'):SetAllPoints(getglobal("ShapeshiftButton"..i)) + getglobal("ShapeshiftButton"..i..'HotKey'):SetFont(pfUI.font_square, pfUI_config.global.font_size -2, "OUTLINE") + getglobal("ShapeshiftButton"..i..'HotKey'):SetJustifyH("RIGHT") + getglobal("ShapeshiftButton"..i..'HotKey'):SetJustifyV("TOP") end - for i = 1, 10 do + for i = 1, NUM_PET_ACTION_SLOTS do getglobal("PetActionButton"..i):SetWidth(pfUI_config.bars.icon_size) getglobal("PetActionButton"..i):SetHeight(pfUI_config.bars.icon_size) getglobal("PetActionButton"..i):Show() @@ -411,7 +426,7 @@ pfUI:RegisterModule("actionbar", function () local actionbars = { "ActionButton", "MultiBarLeftButton", "MultiBarRightButton", "MultiBarBottomLeftButton", "MultiBarBottomRightButton", "BonusActionButton", } - for i = 1, 12 do + for i = 1, NUM_ACTIONBAR_BUTTONS do for _, button in pairs(actionbars) do getglobal(button..i..'NormalTexture'):SetAlpha(0) getglobal(button..i):SetWidth(pfUI_config.bars.icon_size) @@ -489,8 +504,8 @@ pfUI:RegisterModule("actionbar", function () end -- configure autohiding frames - if pfUI_config.bars.hide_bottom == "1" then - pfEnableAutohide(pfUI.bars.bottom) + if pfUI_config.bars.hide_actionmain == "1" then + pfEnableAutohide(pfUI.bars.actionmain) end if pfUI_config.bars.hide_bottomleft == "1" then @@ -501,8 +516,12 @@ pfUI:RegisterModule("actionbar", function () pfEnableAutohide(pfUI.bars.bottomright) end - if pfUI_config.bars.hide_vertical == "1" then - pfEnableAutohide(pfUI.bars.vertical) + if pfUI_config.bars.hide_right == "1" then + pfEnableAutohide(pfUI.bars.right) + end + + if pfUI_config.bars.hide_tworight == "1" then + pfEnableAutohide(pfUI.bars.tworight) end if pfUI_config.bars.hide_shapeshift == "1" then diff --git a/modules/chat.lua b/modules/chat.lua index 15a14ccb..1369ce17 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -475,15 +475,24 @@ pfUI:RegisterModule("chat", function () pfUI.chat.editbox:SetHeight(pfUI_config.chat.text.input_height) end - pfUI.chat.editbox:ClearAllPoints() - local anchor - if pfUI.bars then - anchor = pfUI.bars.bottom - else - anchor = pfUI.chat.left - end - pfUI.chat.editbox:SetPoint("BOTTOM", anchor, "TOP", 0, default_border*4) - pfUI.api:UpdateMovable(pfUI.chat.editbox) + -- to make sure SHOW_MULTI_ACTIONBAR_1 is set to the real value, we need to wait. + local pfChatArrangeFrame = CreateFrame("Frame", "pfChatArrange", UIParent) + pfChatArrangeFrame:RegisterEvent("CVAR_UPDATE") + pfChatArrangeFrame:RegisterEvent("PLAYER_ENTERING_WORLD") + pfChatArrangeFrame:SetScript("OnEvent", function() + pfUI.chat.editbox:ClearAllPoints() + local anchor = pfUI.chat.left + if pfUI.bars and SHOW_MULTI_ACTIONBAR_1 then + anchor = pfUI.bars.bottomleft + elseif pfUI.bars and pfUI.bars.actionmain:IsShown() then + anchor = pfUI.bars.actionmain + end + + pfUI.chat.editbox:SetPoint("BOTTOMLEFT", anchor, "TOPLEFT", 0, default_border*4) + pfUI.chat.editbox:SetPoint("BOTTOMRIGHT", anchor, "TOPRIGHT", 0, default_border*4) + + pfUI.api:UpdateMovable(pfUI.chat.editbox) + end) if pfUI_config.chat.text.input_width == "0" then pfUI.chat.editbox:SetWidth(default_border*3 + pfUI_config.bars.icon_size * 12 + default_border * 12) -- actionbar size diff --git a/modules/gui.lua b/modules/gui.lua index 5befcf43..6f398738 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -88,6 +88,13 @@ pfUI:RegisterModule("gui", function () pfUI.gui.reloadDialog:Hide() end) + function pfUI.gui.HoverBind() + pfUI.gui:Hide() + if pfUI.hoverbind then + pfUI.hoverbind:Show() + end + end + function pfUI.gui.UnlockFrames() if not pfUI.gitter then pfUI.gitter = CreateFrame("Button", nil, UIParent) @@ -176,7 +183,11 @@ pfUI:RegisterModule("gui", function () frame.drag.text:SetAllPoints(frame.drag) frame.drag.text:SetPoint("CENTER", 0, 0) frame.drag.text:SetFontObject(GameFontWhite) - frame.drag.text:SetText(strsub(frame:GetName(),3)) + local label = (strsub(frame:GetName(),3)) + if frame.drag:GetHeight() > (2 * frame.drag:GetWidth()) then + label = pfUI.api.strvertical(label) + end + frame.drag.text:SetText(label) frame.drag:SetAlpha(1) frame.drag:SetScript("OnMouseWheel", function() @@ -202,8 +213,12 @@ pfUI:RegisterModule("gui", function () end -- repaint hackfix for panels - pfUI.panel.left:SetScale(pfUI.chat.left:GetScale()) - pfUI.panel.right:SetScale(pfUI.chat.right:GetScale()) + if pfUI.panel and pfUI.chat then + pfUI.panel.left:SetScale(pfUI.chat.left:GetScale()) + pfUI.panel.right:SetScale(pfUI.chat.right:GetScale()) + end + + if frame.OnMove then frame:OnMove() end end) end @@ -240,6 +255,7 @@ pfUI:RegisterModule("gui", function () end frame.drag.backdrop:SetBackdropBorderColor(1,1,1,1) frame:StartMoving() + if frame.OnMove then frame:OnMove() end end) frame.drag:SetScript("OnMouseUp",function() @@ -919,13 +935,26 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.bar, "Use colored icon as range indicator", pfUI_config.bars, "glowrange", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.bar, "Range indicator Color", pfUI_config.bars, "rangecolor", "color") pfUI.gui:CreateConfig(pfUI.gui.bar, "Seconds to wait until hide bars", pfUI_config.bars, "hide_time") - pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide bottom actionbar", pfUI_config.bars, "hide_bottom", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide main actionbar", pfUI_config.bars, "hide_actionmain", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide bottomleft actionbar", pfUI_config.bars, "hide_bottomleft", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide bottomright actionbar", pfUI_config.bars, "hide_bottomright", "checkbox") - pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide vertical actionbar", pfUI_config.bars, "hide_vertical", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide right actionbar", pfUI_config.bars, "hide_right", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide 2nd right actionbar", pfUI_config.bars, "hide_tworight", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide shapeshift actionbar", pfUI_config.bars, "hide_shapeshift", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.bar, "Autohide pet actionbar", pfUI_config.bars, "hide_pet", "checkbox") + pfUI.gui:CreateConfig(pfUI.gui.bar, "Bar Layouts", nil, nil, "header") + local values = pfUI.api:BarLayoutOptions(NUM_ACTIONBAR_BUTTONS) + pfUI.gui:CreateConfig(pfUI.gui.bar, "Default Actionbar [ActionMain]", pfUI_config.bars.actionmain, "formfactor", "dropdown", values) + pfUI.gui:CreateConfig(pfUI.gui.bar, "Second Actionbar [BottomLeft]", pfUI_config.bars.bottomleft, "formfactor", "dropdown", values) + pfUI.gui:CreateConfig(pfUI.gui.bar, "Left Actionbar [BottomRight]", pfUI_config.bars.bottomright, "formfactor", "dropdown", values) + pfUI.gui:CreateConfig(pfUI.gui.bar, "Right Actionbar [Right]", pfUI_config.bars.right, "formfactor", "dropdown", values) + pfUI.gui:CreateConfig(pfUI.gui.bar, "Vertical Actionbar [TwoRight]", pfUI_config.bars.tworight, "formfactor", "dropdown", values) + local values = pfUI.api:BarLayoutOptions(NUM_SHAPESHIFT_SLOTS) + pfUI.gui:CreateConfig(pfUI.gui.bar, "Shapeshift Bar", pfUI_config.bars.shapeshift, "formfactor", "dropdown", values) + local values = pfUI.api:BarLayoutOptions(NUM_PET_ACTION_SLOTS) + pfUI.gui:CreateConfig(pfUI.gui.bar, "Pet Bar", pfUI_config.bars.pet, "formfactor", "dropdown", values) + -- panels pfUI.gui.panel = pfUI.gui:CreateConfigTab("Panel") local values = { "time", "fps", "exp", "gold", "friends", "guild", "durability", "zone", "combat", "none" } @@ -1007,6 +1036,11 @@ pfUI:RegisterModule("gui", function () pfUI.gui.reloadDialog:Show() end) + -- Hoverbind + pfUI.gui.hoverBind = pfUI.gui:CreateConfigTab("Hover Bind", "bottom", function() + pfUI.gui.HoverBind() + end) + -- Reset Chat pfUI.gui.resetChat = pfUI.gui:CreateConfigTab("Reset Chat", "bottom", function() pfUI_init["chat"] = nil