diff --git a/Bindings.xml b/Bindings.xml new file mode 100644 index 00000000..9547622c --- /dev/null +++ b/Bindings.xml @@ -0,0 +1,72 @@ + + + + pfActionButton(13) + pfActionButton(14) + pfActionButton(15) + pfActionButton(16) + pfActionButton(17) + pfActionButton(18) + pfActionButton(19) + pfActionButton(20) + pfActionButton(21) + pfActionButton(22) + pfActionButton(23) + pfActionButton(24) + + + pfActionButton(73) + pfActionButton(74) + pfActionButton(75) + pfActionButton(76) + pfActionButton(77) + pfActionButton(78) + pfActionButton(79) + pfActionButton(80) + pfActionButton(81) + pfActionButton(82) + pfActionButton(83) + pfActionButton(84) + + + pfActionButton(85) + pfActionButton(86) + pfActionButton(87) + pfActionButton(88) + pfActionButton(89) + pfActionButton(90) + pfActionButton(91) + pfActionButton(92) + pfActionButton(93) + pfActionButton(94) + pfActionButton(95) + pfActionButton(96) + + + pfActionButton(97) + pfActionButton(98) + pfActionButton(99) + pfActionButton(100) + pfActionButton(101) + pfActionButton(102) + pfActionButton(103) + pfActionButton(104) + pfActionButton(105) + pfActionButton(106) + pfActionButton(107) + pfActionButton(108) + + + pfActionButton(109) + pfActionButton(110) + pfActionButton(111) + pfActionButton(112) + pfActionButton(113) + pfActionButton(114) + pfActionButton(115) + pfActionButton(116) + pfActionButton(117) + pfActionButton(118) + pfActionButton(119) + pfActionButton(120) + diff --git a/api/api.lua b/api/api.lua index cfd64666..4713e80e 100644 --- a/api/api.lua +++ b/api/api.lua @@ -814,11 +814,12 @@ function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor return button._anchor end --- [ Create Autohide ] -- +-- [ Enable Autohide ] -- -- 'frame' the frame that should be hidden -function pfUI.api.CreateAutohide(frame) +function pfUI.api.EnableAutohide(frame, timeout) if not frame then return end - frame.hover = CreateFrame("Frame", frame:GetName() .. "Autohide", frame) + + frame.hover = frame.hover or CreateFrame("Frame", frame:GetName() .. "Autohide", frame) frame.hover:SetParent(frame) frame.hover:SetAllPoints(frame) frame.hover.parent = frame @@ -828,20 +829,33 @@ function pfUI.api.CreateAutohide(frame) this:Hide() end) + local timeout = timeout frame.hover:SetScript("OnUpdate", function() if MouseIsOver(this, 10, -10, -10, 10) then - this.activeTo = GetTime() + tonumber(pfUI_config.bars.hide_time) + this.activeTo = GetTime() + timeout this.parent:SetAlpha(1) elseif this.activeTo then if this.activeTo < GetTime() and this.parent:GetAlpha() > 0 then this.parent:SetAlpha(this.parent:GetAlpha() - 0.1) end else - this.activeTo = GetTime() + tonumber(pfUI_config.bars.hide_time) + this.activeTo = GetTime() + timeout end end) end +-- [ Disable Autohide ] -- +-- 'frame' the frame that should get the autohide removed +function pfUI.api.DisableAutohide(frame) + if not frame then return end + if not frame.hover then return end + + frame.hover:UnregisterAllEvents() + frame.hover:SetScript("OnUpdate", nil) + frame.hover:Hide() + frame:SetAlpha(1) +end + -- [ GetColoredTime ] -- -- 'remaining' the time in seconds that should be converted -- return a colored string including a time unit (m/h/d) diff --git a/api/config.lua b/api/config.lua index 3404b019..512b2d81 100644 --- a/api/config.lua +++ b/api/config.lua @@ -668,32 +668,66 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "fallback", "hitindicatorsize", "15") pfUI:UpdateConfig("unitframes", "fallback", "hitindicatorfont", "Interface\\AddOns\\pfUI\\fonts\\Continuum.ttf") - pfUI:UpdateConfig("bars", nil, "icon_size", "20") - pfUI:UpdateConfig("bars", nil, "background", "1") + pfUI:UpdateConfig("bars", "bar1", "pageable", "1") + pfUI:UpdateConfig("bars", "bar2", "pageable", "1") + + pfUI:UpdateConfig("bars", "bar1", "enable", "1") + pfUI:UpdateConfig("bars", "bar3", "enable", "1") + pfUI:UpdateConfig("bars", "bar4", "enable", "1") + pfUI:UpdateConfig("bars", "bar5", "enable", "1") + pfUI:UpdateConfig("bars", "bar6", "enable", "1") + pfUI:UpdateConfig("bars", "bar11", "enable", "1") + pfUI:UpdateConfig("bars", "bar12", "enable", "1") + + pfUI:UpdateConfig("bars", "bar3", "formfactor", "6 x 2") + pfUI:UpdateConfig("bars", "bar5", "formfactor", "6 x 2") + pfUI:UpdateConfig("bars", "bar4", "formfactor", "1 x 12") + pfUI:UpdateConfig("bars", "bar11", "formfactor", "10 x 1") + pfUI:UpdateConfig("bars", "bar12", "formfactor", "10 x 1") + + pfUI:UpdateConfig("bars", "bar11", "icon_size", "18") + pfUI:UpdateConfig("bars", "bar12", "icon_size", "18") + + for i=1,12 do + pfUI:UpdateConfig("bars", "bar"..i, "enable", "0") + pfUI:UpdateConfig("bars", "bar"..i, "pageable", "0") + pfUI:UpdateConfig("bars", "bar"..i, "icon_size", "20") + pfUI:UpdateConfig("bars", "bar"..i, "formfactor", "12 x 1") + pfUI:UpdateConfig("bars", "bar"..i, "background", "1") + pfUI:UpdateConfig("bars", "bar"..i, "showempty", "1") + pfUI:UpdateConfig("bars", "bar"..i, "showmacro", "1") + pfUI:UpdateConfig("bars", "bar"..i, "showkeybind", "1") + pfUI:UpdateConfig("bars", "bar"..i, "showcount", "1") + pfUI:UpdateConfig("bars", "bar"..i, "autohide", "0") + pfUI:UpdateConfig("bars", "bar"..i, "hide_time", "3") + if i ~= 11 and i ~= 12 then + pfUI:UpdateConfig("bars", "bar"..i, "buttons", "12") + end + end + + pfUI:UpdateConfig("bars", nil, "keydown", "0") + pfUI:UpdateConfig("bars", nil, "altself", "0") + pfUI:UpdateConfig("bars", nil, "animation", "zoomfade") + pfUI:UpdateConfig("bars", nil, "hunterbar", "0") + pfUI:UpdateConfig("bars", nil, "pagemaster", "0") + pfUI:UpdateConfig("bars", nil, "showcastable", "1") pfUI:UpdateConfig("bars", nil, "glowrange", "1") pfUI:UpdateConfig("bars", nil, "rangecolor", "1,0.1,0.1,1") - pfUI:UpdateConfig("bars", nil, "showmacro", "1") - pfUI:UpdateConfig("bars", nil, "showkeybind", "1") + pfUI:UpdateConfig("bars", nil, "showoom", "1") + pfUI:UpdateConfig("bars", nil, "oomcolor", ".2,.2,1,1") + pfUI:UpdateConfig("bars", nil, "showna", "1") + pfUI:UpdateConfig("bars", nil, "nacolor", ".3,.3,.3,1") pfUI:UpdateConfig("bars", nil, "showequipped", "1") - pfUI:UpdateConfig("bars", nil, "hunterbar", "0") - pfUI:UpdateConfig("bars", nil, "keydown", "0") - pfUI:UpdateConfig("bars", nil, "pagemaster", "0") - pfUI:UpdateConfig("bars", nil, "showcastable", "0") - pfUI:UpdateConfig("bars", nil, "hide_time", "1") - pfUI:UpdateConfig("bars", nil, "hide_actionmain", "0") - pfUI:UpdateConfig("bars", nil, "hide_bottomleft", "0") - pfUI:UpdateConfig("bars", nil, "hide_bottomright", "0") - pfUI:UpdateConfig("bars", nil, "hide_right", "0") - pfUI:UpdateConfig("bars", nil, "hide_tworight", "0") - pfUI:UpdateConfig("bars", nil, "hide_shapeshift", "0") - pfUI:UpdateConfig("bars", nil, "hide_pet", "0") - pfUI:UpdateConfig("bars", "actionmain", "formfactor", "12 x 1") - pfUI:UpdateConfig("bars", "bottomleft", "formfactor", "12 x 1") - pfUI:UpdateConfig("bars", "bottomright", "formfactor", "6 x 2") - pfUI:UpdateConfig("bars", "right", "formfactor", "6 x 2") - pfUI:UpdateConfig("bars", "tworight", "formfactor", "1 x 12") - pfUI:UpdateConfig("bars", "shapeshift", "formfactor", "10 x 1") - pfUI:UpdateConfig("bars", "pet", "formfactor", "10 x 1") + pfUI:UpdateConfig("bars", nil, "eqcolor", ".2,.8,.2,.2") + + pfUI:UpdateConfig("bars", nil, "font", "Interface\\AddOns\\pfUI\\fonts\\BigNoodleTitling.ttf") + pfUI:UpdateConfig("bars", nil, "font_offset", "0") + pfUI:UpdateConfig("bars", nil, "macro_size", "9") + pfUI:UpdateConfig("bars", nil, "macro_color", "1,1,1,1") + pfUI:UpdateConfig("bars", nil, "count_size", "11") + pfUI:UpdateConfig("bars", nil, "count_color", ".2,1,.8,1") + pfUI:UpdateConfig("bars", nil, "bind_size", "9") + pfUI:UpdateConfig("bars", nil, "bind_color", "1,1,0,1") pfUI:UpdateConfig("panel", nil, "use_unitfonts", "0") pfUI:UpdateConfig("panel", nil, "hide_leftchat", "0") @@ -797,6 +831,8 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("thirdparty", "sortbags", "enable", "1") pfUI:UpdateConfig("thirdparty", "mrplow", "enable", "1") pfUI:UpdateConfig("thirdparty", "flightmap", "enable", "1") + pfUI:UpdateConfig("thirdparty", "theorycraft", "enable", "1") + pfUI:UpdateConfig("thirdparty", "supermacro", "enable", "1") pfUI:UpdateConfig("thirdparty", "atlasloot", "enable", "1") pfUI:UpdateConfig("thirdparty", "myroleplay", "enable", "1") pfUI:UpdateConfig("thirdparty", "druidmana", "enable", "1") @@ -1028,5 +1064,126 @@ function pfUI:MigrateConfig() end end + -- migrating actionbar settings (> 3.18) + if checkversion(3, 18, 0) then + + local migratebars = { + ["pfBarActionMain"] = "pfActionBarMain", + ["pfBarBottomLeft"] = "pfActionBarTop", + ["pfBarBottomRight"] = "pfActionBarLeft", + ["pfBarTwoRight"] = "pfActionBarVertical", + ["pfBarRight"] = "pfActionBarRight", + ["pfBarShapeshift"] = "pfActionBarStances", + ["pfBarPet"] = "pfActionBarPet", + } + + -- migrate bar positions and scaling + for oldname, newname in pairs(migratebars) do + if pfUI_config.position[oldname] then + pfUI_config.position[newname] = pfUI.api.CopyTable(pfUI_config.position[oldname]) + pfUI_config.position[oldname] = nil + end + end + + -- migrate global settings to bar specifics + for i=1,12 do + if pfUI_config.bars.icon_size then + pfUI_config.bars["bar"..i].icon_size = pfUI_config.bars.icon_size + end + + if pfUI_config.bars.background then + pfUI_config.bars["bar"..i].background = pfUI_config.bars.background + end + + if pfUI_config.bars.showmacro then + pfUI_config.bars["bar"..i].showmacro = pfUI_config.bars.showmacro + end + + if pfUI_config.bars.showkeybind then + pfUI_config.bars["bar"..i].showkeybind = pfUI_config.bars.showkeybind + end + + if pfUI_config.bars.hide_time then + pfUI_config.bars["bar"..i].hide_time = pfUI_config.bars.hide_time + end + end + + pfUI_config.bars.icon_size = nil + pfUI_config.bars.background = nil + pfUI_config.bars.showmacro = nil + pfUI_config.bars.showkeybind = nil + pfUI_config.bars.hide_time = nil + + if pfUI_config.bars.hide_actionmain then + pfUI_config.bars.bar1.autohide = pfUI_config.bars.hide_actionmain + pfUI_config.bars.hide_actionmain = nil + end + + if pfUI_config.bars.hide_bottomleft then + pfUI_config.bars.bar6.autohide = pfUI_config.bars.hide_bottomleft + pfUI_config.bars.hide_bottomleft = nil + end + + if pfUI_config.bars.hide_bottomright then + pfUI_config.bars.bar5.autohide = pfUI_config.bars.hide_bottomright + pfUI_config.bars.hide_bottomright = nil + end + + if pfUI_config.bars.hide_right then + pfUI_config.bars.bar3.autohide = pfUI_config.bars.hide_right + pfUI_config.bars.hide_right = nil + end + + if pfUI_config.bars.hide_tworight then + pfUI_config.bars.bar4.autohide = pfUI_config.bars.hide_tworight + pfUI_config.bars.hide_tworight = nil + end + + if pfUI_config.bars.hide_shapeshift then + pfUI_config.bars.bar11.autohide = pfUI_config.bars.hide_shapeshift + pfUI_config.bars.hide_shapeshift = nil + end + + if pfUI_config.bars.hide_pet then + pfUI_config.bars.bar12.autohide = pfUI_config.bars.hide_pet + pfUI_config.bars.hide_pet = nil + end + + if pfUI_config.bars.actionmain and pfUI_config.bars.actionmain.formfactor then + pfUI_config.bars.bar1.formfactor = pfUI_config.bars.actionmain.formfactor + pfUI_config.bars.actionmain.formfactor = nil + end + + if pfUI_config.bars.bottomleft and pfUI_config.bars.bottomleft.formfactor then + pfUI_config.bars.bar6.formfactor = pfUI_config.bars.bottomleft.formfactor + pfUI_config.bars.bottomleft.formfactor = nil + end + + if pfUI_config.bars.bottomright and pfUI_config.bars.bottomright.formfactor then + pfUI_config.bars.bar5.formfactor = pfUI_config.bars.bottomright.formfactor + pfUI_config.bars.bottomright.formfactor = nil + end + + if pfUI_config.bars.right and pfUI_config.bars.right.formfactor then + pfUI_config.bars.bar3.formfactor = pfUI_config.bars.right.formfactor + pfUI_config.bars.right.formfactor = nil + end + + if pfUI_config.bars.tworight and pfUI_config.bars.tworight.formfactor then + pfUI_config.bars.bar4.formfactor = pfUI_config.bars.tworight.formfactor + pfUI_config.bars.tworight.formfactor = nil + end + + if pfUI_config.bars.shapeshift and pfUI_config.bars.shapeshift.formfactor then + pfUI_config.bars.bar11.formfactor = pfUI_config.bars.shapeshift.formfactor + pfUI_config.bars.shapeshift.formfactor = nil + end + + if pfUI_config.bars.pet and pfUI_config.bars.pet.formfactor then + pfUI_config.bars.bar12.formfactor = pfUI_config.bars.pet.formfactor + pfUI_config.bars.pet.formfactor = nil + end + end + pfUI_config.version = pfUI.version.string end diff --git a/modules/actionbar.lua b/modules/actionbar.lua index 1ed4fa3b..1bb511f5 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -1,52 +1,1043 @@ pfUI:RegisterModule("actionbar", function () - local default_border = C.appearance.border.default - if C.appearance.border.actionbars ~= "-1" then - default_border = C.appearance.border.actionbars + local _, class = UnitClass("player") + local color = RAID_CLASS_COLORS[class] + local cr, cg, cb = color.r , color.g, color.b + + local backdrop_highlight = { edgeFile = "Interface\\AddOns\\pfUI\\img\\glow", edgeSize = 8 } + local showgrid = 0 + + -- hide blizzard bars + local function kill(f, killshow) + if f.Show and killshow then f.Show = function() return end end + if f.UnregisterAllEvents then f:UnregisterAllEvents() end + if f.Hide then f:Hide() end + for i,v in ipairs({f:GetChildren()}) do kill(v) end end - hooksecurefunc("MultiActionBar_ShowAllGrids", function() - MultiActionBar_UpdateGrid("BonusAction", 1) - MultiActionBar_UpdateGrid("Action", 1) - end) + kill(MainMenuBar) - hooksecurefunc("MultiActionBar_HideAllGrids", function() - MultiActionBar_UpdateGrid("BonusAction") - MultiActionBar_UpdateGrid("Action") - end) - - hooksecurefunc("ShowBonusActionBar", function() - if pfActionBar then pfActionBar:Hide() end - if pfBonusBar then pfBonusBar:Show() end - end) - - hooksecurefunc("HideBonusActionBar", function() - if pfActionBar then pfActionBar:Show() end - if pfBonusBar then pfBonusBar:Hide() end - end) - - if C.bars.keydown == "1" then - hooksecurefunc("ActionButtonDown", function(id) - ActionButtonUp(id) - end, true) - - hooksecurefunc("MultiActionButtonDown", function(bar, id) - MultiActionButtonUp(bar, id) - end, true) + local blizzard_elements = { MultiBarBottomLeft, + MultiBarBottomRight, MultiBarLeft, MultiBarRight } + for _, f in pairs(blizzard_elements) do + kill(f, true) end + local bars = { } + local buttontypes = { + -- blizzard keybinds + [3] = "MULTIACTIONBAR3BUTTON", + [4] = "MULTIACTIONBAR4BUTTON", + [5] = "MULTIACTIONBAR2BUTTON", + [6] = "MULTIACTIONBAR1BUTTON", + [11] = "SHAPESHIFTBUTTON", + [12] = "BONUSACTIONBUTTON", + -- additional keybinds + [2] = "PFPAGING", + [7] = "PFSPECIAL", + [8] = "PFSTANCEONE", + [9] = "PFSTANCETWO", + [10] = "PFSTANCETHREE", + } + + local blizzbarmapping = { + ["MultiBarRight"] = 3, + ["MultiBarLeft"] = 4, + ["MultiBarBottomRight"] = 5, + ["MultiBarBottomLeft"] = 6, + ["ShapeShiftBar"] = 11, + ["BonusActionBar"] = 12, + } + + local barnames = { + [1] = "Main", + [2] = "Paging", + [3] = "Right", + [4] = "Vertical", + [5] = "Left", + [6] = "Top", + [7] = "Special", + [8] = "StancePaging1", + [9] = "StancePaging2", + [10] = "StancePaging3", + [11] = "Stances", + [12] = "Pet", + } + + local button_animations = { + ["none"] = function() + this.active = nil + this:Hide() + end, + ["zoomfade"] = function() + if this.active == 0 then + -- init animation + this:SetWidth(this.parent:GetWidth()) + this:SetHeight(this.parent:GetHeight()) + this:SetScale(this.parent:GetScale()) + this.tex:SetTexture(this.parent.icon:GetTexture()) + this.tex:SetVertexColor(this.parent.icon:GetVertexColor()) + this:SetAlpha(1) + this.active = 1 + return + elseif this.active == 1 then + -- run animation + local fade = 30/GetFramerate()*0.05 + this:SetAlpha(this:GetAlpha() - fade) + this:SetScale(this:GetScale() + fade) + if this:GetAlpha() > 0 then return end + end + + -- stop animation + this.active = nil + this:Hide() + end, + ["shrinkreturn"] = function() + if this.active == 0 then + -- init animation + this:SetWidth(this.parent:GetWidth()) + this:SetHeight(this.parent:GetHeight()) + this:SetScale(this.parent:GetScale()) + this.tex:SetTexture(this.parent.icon:GetTexture()) + this.tex:SetVertexColor(this.parent.icon:GetVertexColor()) + this:SetAlpha(1) + this.parent.icon:Hide() + this.active = 1 + this.time = 0 + return + elseif this.active == 1 then + -- run animation + this.time = this.time + 30/GetFramerate()*0.1 + local fade = 1 -math.exp(-this.time)*math.sin(this.time*math.pi) + this:SetAlpha(fade) + this:SetScale(fade) + if this.time < 1 then return end + end + + -- stop animation + this.active = nil + this:Hide() + this.parent.icon:Show() + end, + ["elasticzoom"] = function() + if this.active == 0 then + -- init animation + this:SetWidth(this.parent:GetWidth()) + this:SetHeight(this.parent:GetHeight()) + this:SetScale(this.parent:GetScale()) + this.tex:SetTexture(this.parent.icon:GetTexture()) + this.tex:SetVertexColor(this.parent.icon:GetVertexColor()) + this:SetAlpha(1) + this.parent.icon:Hide() + this.active = 1 + this.time = 0 + return + elseif this.active == 1 then + -- run animation + this.time = this.time + 30/GetFramerate()*0.03 + local fade = 1 -math.exp(-this.time*6)*math.sin(this.time*4*math.pi) + this:SetAlpha(fade) + this:SetScale(fade) + if this.time < 1 then return end + end + + -- stop animation + this.active = nil + this:Hide() + this.parent.icon:Show() + end, + ["wobblezoom"] = function() + if this.active == 0 then + -- init animation + this:SetWidth(this.parent:GetWidth()) + this:SetHeight(this.parent:GetHeight()) + this:SetScale(this.parent:GetScale()) + this.tex:SetTexture(this.parent.icon:GetTexture()) + this.tex:SetVertexColor(this.parent.icon:GetVertexColor()) + this:SetAlpha(1) + this.parent.icon:Hide() + this.active = 1 + this.time = 0 + return + elseif this.active == 1 then + -- run animation + this.time = this.time + 30/GetFramerate()*0.02 + local fade = 1 -math.exp(-this.time*6)*math.sin(this.time*10*math.pi) + this:SetAlpha(fade) + this:SetScale(fade) + if this.time < 1 then return end + end + + -- stop animation + this.active = nil + this:Hide() + this.parent.icon:Show() + end, + } + + local function GetActiveBar() + if CURRENT_ACTIONBAR_PAGE == 1 and GetBonusBarOffset() ~= 0 then + return NUM_ACTIONBAR_PAGES + GetBonusBarOffset() + else + return CURRENT_ACTIONBAR_PAGE + end + end + + local function SwitchBar(bar) + if _G.CURRENT_ACTIONBAR_PAGE ~= bar then + _G.CURRENT_ACTIONBAR_PAGE = bar + ChangeActionBarPage() + end + end + + local function ButtonRefresh(self) + local self = self or this + local id, bar, active, texture + local sid = self:GetID() -- 1 to 120 + + local usable, oom + local start, duration, enable + local castable, autocast + + if self.bar == 11 then + -- stance button + id = sid + bar = self.bar + texture, _, active, usable = GetShapeshiftFormInfo(id) + oom = nil + start, duration, enable = GetShapeshiftFormCooldown(sid) + elseif self.bar == 12 then + -- pet button + local token + id = sid + _, _, texture, token, active, castable, autocast = GetPetActionInfo(id) + texture = token and _G[texture] or texture + usable, oom = true, nil + start, duration, enable = GetPetActionCooldown(sid) + else + active = IsCurrentAction(sid) + texture = GetActionTexture(sid) + id = sid - (self.bar-1)*12 + bar = GetActiveBar() + usable, oom = IsUsableAction(sid) + start, duration, enable = GetActionCooldown(sid) + end + + + if not self.showempty and self.backdrop and not texture and showgrid == 0 then + self.backdrop:Hide() + else + self.backdrop:Show() + end + + -- update cooldown + CooldownFrame_SetTimer(self.cd, start, duration, enable) + + -- don't go further on those events + if event == "ACTIONBAR_UPDATE_COOLDOWN" then return end + + if self.bar ~= 11 and self.bar ~= 12 then + -- update consumables + if IsConsumableAction(sid) then + self.count:SetText(GetActionCount(sid)) + elseif IsReagentAction and IsReagentAction(sid) then + self.count:SetText(GetReagentCount(sid)) + else + self.count:SetText(nil) + end + + -- equipped item + if IsEquippedAction(sid) and C.bars.showequipped == "1" then + self.equipped:Show() + else + self.equipped:Hide() + end + + -- update macro text + self.macro:SetText(GetActionText(sid)) + end + + -- update usable + if self.outofrange and C.bars.glowrange == "1" then + self.icon:SetVertexColor(self.rangeColor[1], self.rangeColor[2], self.rangeColor[3], self.rangeColor[4]) + elseif oom and C.bars.showoom == "1" then + self.icon:SetVertexColor(self.oomColor[1], self.oomColor[2], self.oomColor[3], self.oomColor[4]) + elseif not usable and C.bars.showna == "1" then + self.icon:SetVertexColor(self.naColor[1], self.naColor[2], self.naColor[3], self.naColor[4]) + else + self.icon:SetVertexColor(1, 1, 1, 1) + end + + -- don't go further on those events + if event == "ACTIONBAR_UPDATE_USABLE" or event == "UPDATE_INVENTORY_ALERTS" then return end + + -- icon + if texture ~= self.texture then + self.icon:SetTexture(texture) + self.texture = texture + end + + -- handle pet bar quirks + if self.bar == 12 then + -- desaturate disabled petbar + self.icon:SetDesaturated(not GetPetActionsUsable()) + + -- display autocast + if autocast then + self.autocast:Show() + else + self.autocast:Hide() + end + + if castable and C.bars.showcastable == "1" then + self.autocastable:Show() + else + self.autocastable:Hide() + end + end + + -- active border + if active then + self.backdrop:SetBackdropBorderColor(cr,cg,cb,1) + else + CreateBackdrop(self) + end + + -- keybinds + if self.bar == bar and self.bar ~= 11 and self.bar ~= 12 then + self.keybind:SetText(GetBindingText(GetBindingKey("ACTIONBUTTON"..id), "KEY_", 1)) + elseif buttontypes[self.bar] then + self.keybind:SetText(GetBindingText(GetBindingKey(buttontypes[self.bar]..id), "KEY_", 1)) + else + self.keybind:SetText("") + end + end + + local function ButtonUpdate(self) + local self = self or this + + -- trigger update + if self.forceupdate then + self.forceupdate = nil + self:GetScript("OnEvent")() + end + + -- throttle to run once per .1 seconds + if ( self.tick or 1) > GetTime() then return else self.tick = GetTime() + .1 end + + local sid = self:GetID() + + -- update range display + if C.bars.glowrange == "1" and self.bar ~= 11 and self.bar ~= 12 and HasAction(sid) and ActionHasRange(sid) and IsActionInRange(sid) == 0 then + if not self.outofrange then + self.outofrange = true + self.forceupdate = true + end + elseif self.outofrange then + self.outofrange = nil + self.forceupdate = true + end + end + + local function ButtonDrag(self) + local self = self or this + + if _G.LOCK_ACTIONBAR == "1" and not IsShiftKeyDown() then return end + + if self.bar == 12 then + PickupPetAction(self:GetID()) + else + PickupAction(self:GetID()) + end + end + + local function ButtonDragStop(self) + local self = self or this + + if self.bar == 12 then + PickupPetAction(self:GetID()) + else + PlaceAction(self:GetID()) + end + end + + local function ButtonClick(self) + local self = self or this + + -- trigger effect + self.animation.active = 0 + self.animation:Show() + + if self.bar == 11 then + CastShapeshiftForm(self:GetID()) + elseif showgrid == 1 then + PickupAction(self:GetID()) + elseif self.bar == 12 then + if arg1 == "LeftButton" then + if IsPetAttackActive(self:GetID()) then + PetStopAttack() + else + CastPetAction(self:GetID()) + end + else + TogglePetAutocast(self:GetID()) + end + else + UseAction(self:GetID()) + end + end + + local function ButtonEnter(self) + local self = self or this + + GameTooltip:ClearLines() + GameTooltip_SetDefaultAnchor(GameTooltip, self) + + if self.bar == 11 then + GameTooltip:SetShapeshift(self:GetID()) + elseif self.bar == 12 then + local name, _, _, token = GetPetActionInfo(self:GetID()) + if token then + GameTooltip:AddLine(_G[name]) + else + GameTooltip:SetPetAction(self:GetID()) + end + else + GameTooltip:SetAction(self:GetID()) + end + + self.highlight:Show() + GameTooltip:Show() + end + + local function ButtonLeave(self) + local self = self or this + + self.highlight:Hide() + GameTooltip:Hide() + end + + local function CreateActionButton(parent, bar, button) + -- load config + local size = C.bars["bar"..bar].icon_size + local font = C.bars.font + local font_offset = tonumber(C.bars.font_offset) + + local macro_size = tonumber(C.bars.macro_size) + local macro_color = { strsplit(",", C.bars.macro_color) } + + local count_size = tonumber(C.bars.count_size) + local count_color = { strsplit(",", C.bars.count_color) } + + local bind_size = tonumber(C.bars.bind_size) + local bind_color = { strsplit(",", C.bars.bind_color) } + + local showempty = C.bars["bar"..bar].showempty + local showmacro = C.bars["bar"..bar].showmacro + local showkybind = C.bars["bar"..bar].showkeybind + local showcount = C.bars["bar"..bar].showcount + + -- sanitize font sizes + if macro_size == 0 then macro_size = 1 end + if count_size == 0 then macro_size = 1 end + if bind_size == 0 then macro_size = 1 end + + local button_name = "pfActionBar" .. barnames[bar] .. "Button" .. button + + local id = (bar-1)*12+button + local exists = _G[button_name] and true or nil + local f = _G[button_name] or CreateFrame("Button", button_name, parent) + + if not exists then + -- no button available, create a new one + f:RegisterForClicks("LeftButtonUp", "RightButtonUp") + + -- slot/button updates + f:RegisterEvent("PLAYER_ENTERING_WORLD") + f:RegisterEvent("ACTIONBAR_SLOT_CHANGED") + f:RegisterEvent("UPDATE_BINDINGS") + f:RegisterEvent("ACTIONBAR_PAGE_CHANGED") + f:RegisterEvent("ACTIONBAR_UPDATE_STATE") + f:RegisterEvent("UPDATE_BONUS_ACTIONBAR") + f:RegisterEvent("CRAFT_SHOW") + f:RegisterEvent("CRAFT_CLOSE") + f:RegisterEvent("TRADE_SKILL_SHOW") + f:RegisterEvent("TRADE_SKILL_CLOSE") + f:RegisterEvent("PLAYER_ENTER_COMBAT") + f:RegisterEvent("PLAYER_LEAVE_COMBAT") + + -- cooldown updates + f:RegisterEvent("ACTIONBAR_UPDATE_USABLE") + f:RegisterEvent("UPDATE_INVENTORY_ALERTS") + f:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN") + f:RegisterEvent("UNIT_INVENTORY_CHANGED") + + -- show/hide grid + f:RegisterEvent("ACTIONBAR_SHOWGRID") + f:RegisterEvent("ACTIONBAR_HIDEGRID") + + if bar ~= 11 then + f:RegisterForDrag("LeftButton", "RightButton") + f:SetScript("OnDragStart", ButtonDrag) + f:SetScript("OnReceiveDrag", ButtonDragStop) + end + + if bar == 11 then + f:RegisterEvent("PLAYER_AURAS_CHANGED") + end + + if bar == 12 then + f:RegisterEvent("PLAYER_CONTROL_LOST") + f:RegisterEvent("PLAYER_CONTROL_GAINED") + f:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED") + f:RegisterEvent("UNIT_PET") + f:RegisterEvent("UNIT_FLAGS") + f:RegisterEvent("UNIT_AURA") + f:RegisterEvent("PET_BAR_UPDATE") + f:RegisterEvent("PET_BAR_UPDATE_COOLDOWN") + end + + f:SetScript("OnEvent", ButtonRefresh) + f:SetScript("OnClick", ButtonClick) + f:SetScript("OnEnter", ButtonEnter) + f:SetScript("OnLeave", ButtonLeave) + f:SetScript("OnUpdate", ButtonUpdate) + + f:SetID(id) + + -- cooldown + f.cd = CreateFrame(COOLDOWN_FRAME_TYPE, f:GetName() .. "Cooldown", f, "CooldownFrameTemplate") + f.cd.pfCooldownType = "NOGCD" + + -- icon + f.icon = f:CreateTexture(button_name .. "Icon", "BACKGROUND") + f.icon:SetTexCoord(.08, .92, .08, .92) + f.icon:SetAllPoints() + + -- animation + f.animation = CreateFrame("Frame", button_name .. "Animation", f) + f.animation.parent = f + f.animation:SetPoint("CENTER", 0, 0) + f.animation:Hide() + f.animation.tex = f.animation:CreateTexture(button_name .. "AnimationTexture", "BACKGROUND") + f.animation.tex:SetTexCoord(.08, .92, .08, .92) + f.animation.tex:SetAllPoints() + + if bar ~= 11 and bar ~= 12 then + -- equipped item + f.equipped = f:CreateTexture(nil, "BORDER") + f.equipped:SetAllPoints() + f.equipped:Hide() + elseif bar == 12 then + f.autocast = CreateFrame("Model", nil, f) + f.autocast:SetAllPoints() + f.autocast:SetModel("Interface\\Buttons\\UI-AutoCastButton.mdx") + f.autocast:SetSequence(0) + f.autocast:SetSequenceTime(0, 0) + f.autocast:Hide() + + f.autocastable = f:CreateTexture(nil, "BORDER") + f.autocastable:SetAllPoints() + f.autocastable:SetTexture("Interface\\Buttons\\UI-AutoCastableOverlay") + f.autocastable:SetTexCoord(.25, .75, .25, .75) + end + + -- macro + f.macro = f:CreateFontString(button_name .. "Name", "LOW", "GameFontNormal") + + -- keybind + f.keybind = f:CreateFontString(nil, "LOW", "GameFontNormal") + + -- itemcount + f.count = f:CreateFontString(button_name .. "Count", "LOW", "GameFontNormal") + + -- highlight + f.highlight = CreateFrame("Frame", nil, f) + f.highlight:SetBackdrop(backdrop_highlight) + f.highlight:SetBackdropBorderColor(1,1,1,.8) + f.highlight:SetAllPoints() + f.highlight:Hide() + end + + -- set animation + f.animation:SetScript("OnUpdate", button_animations[C.bars.animation]) + + -- pet autocast + if bar == 12 then + f.autocast:SetScale(C.bars["bar"..bar].icon_size / 25) + f.autocast:SetAlpha(.05) + end + + -- macro options + if showmacro == "1" then f.macro:Show() else f.macro:Hide() end + SetAllPointsOffset(f.macro, f, font_offset, -font_offset) + f.macro:SetFont(font, macro_size, "OUTLINE") + f.macro:SetTextColor(unpack(macro_color)) + f.macro:SetJustifyH("LEFT") + f.macro:SetJustifyV("BOTTOM") + + -- keybind options + if showkybind == "1" then f.keybind:Show() else f.keybind:Hide() end + SetAllPointsOffset(f.keybind, f, font_offset, -font_offset) + f.keybind:SetFont(font, bind_size, "OUTLINE") + f.keybind:SetTextColor(unpack(bind_color)) + f.keybind:SetJustifyH("RIGHT") + f.keybind:SetJustifyV("TOP") + + -- item count options + if showcount == "1" then f.count:Show() else f.count:Hide() end + SetAllPointsOffset(f.count, f, font_offset, -font_offset) + f.count:SetFont(font, count_size, "OUTLINE") + f.count:SetTextColor(unpack(count_color)) + f.count:SetJustifyH("RIGHT") + f.count:SetJustifyV("BOTTOM") + + -- range glow color + f.rangeColor = { strsplit(",", C.bars.rangecolor) } + + -- out of mana color + f.oomColor = { strsplit(",", C.bars.oomcolor) } + + -- not usable color + f.naColor = { strsplit(",", C.bars.nacolor) } + + -- equipped color + if f.equipped then + f.equipped:SetTexture(strsplit(",", C.bars.eqcolor)) + end + + -- general appearance + f.showempty = showempty == "1" and true or nil + f:SetHeight(size) + f:SetWidth(size) + CreateBackdrop(f) + + return f + end + + local function CreateActionBar(i) + -- load config + local buttonbasename = "pfActionBar" .. barnames[i] .. "Button" + local enable = C.bars["bar"..i].enable + local size = C.bars["bar"..i].icon_size + local background = C.bars["bar"..i].background + local formfactor = C.bars["bar"..i].formfactor + local autohide = C.bars["bar"..i].autohide + local hide_time = C.bars["bar"..i].hide_time + + local buttons = tonumber(C.bars["bar"..i].buttons) or 12 + if i == 11 and bars[i] then -- shapeshift buttons + buttons = GetNumShapeshiftForms() + elseif i == 12 and bars[i] then -- pet buttons + buttons = NUM_PET_ACTION_SLOTS + elseif i == 12 or i == 11 then + -- Fallback to 10 buttons on shapeshift and petbar during initialization. + -- This lets us load bars that aren't yet available for your class or level. + buttons = 10 + end + + -- don't process empty bars + if buttons == 0 then + bars[i]:Hide() + return + end + + local border = C.appearance.border.default + if C.appearance.border.actionbars ~= "-1" then + border = C.appearance.border.actionbars + end + + local font = pfUI.font_unit + local font_size = C.global.font_unit_size + + local realsize = size+border*2 + + -- create frame + bars[i] = bars[i] or CreateFrame("Frame", "pfActionBar" .. barnames[i], UIParent) + bars[i]:SetID(i) + + -- autohide + if autohide == "1" then + EnableAutohide(bars[i], tonumber(hide_time)) + else + DisableAutohide(bars[i]) + end + + -- apply visible settings + if enable == "1" then + -- handle pet bar + if i == 12 then + -- only show when pet actions exists + if PetHasActionBar() then + bars[i]:Show() + else + bars[i]:Hide() + end + + -- show/hide petbar on petbar updates + bars[i]:RegisterEvent("PET_BAR_UPDATE") + bars[i]:SetScript("OnEvent", function() + -- hide obsolete buttons + for i=1, NUM_PET_ACTION_SLOTS do + if not PetHasActionBar() and bars[12][i] then + bars[12][i]:Hide() + end + end + -- refresh layout + CreateActionBar(12) + end) + + -- handle shapeshift bar + elseif i == 11 then + -- only show when shapeshifts exist + if GetNumShapeshiftForms() > 0 then + bars[i]:Show() + else + bars[i]:Hide() + end + + -- update shapeshift bar when amount of spells changes + bars[i]:RegisterEvent("UPDATE_BONUS_ACTIONBAR") + bars[i]:SetScript("OnEvent", function() + local count = GetNumShapeshiftForms() + if count ~= this.lastCount then + this.lastCount = count + + -- hide obsolete buttons + for i=1, NUM_SHAPESHIFT_SLOTS do + if i > GetNumShapeshiftForms() and bars[11][i] then + bars[11][i]:Hide() + end + end + + -- create new buttons and refresh layout + CreateActionBar(11) + end + end) + + -- regular bars + else + bars[i]:Show() + end + + elseif enable == "0" then + bars[i]:UnregisterAllEvents() + bars[i]:Hide() + end + + -- create action buttons + local maxbuttons = (i == 11 or i == 12) and 10 or 12 + for j=1,maxbuttons do + bars[i][j] = CreateActionButton(bars[i], i, j) + bars[i][j].bar = i + + BarButtonAnchor(bars[i][j], buttonbasename, j, buttons, formfactor, size, border) + bars[i][j]:ClearAllPoints() + bars[i][j]:SetPoint(unpack(bars[i][j]._anchor)) + bars[i][j]:Show() + + if i > 10 then + bars[i][j]:SetID(j) + end + + -- refresh button + bars[i][j].forceupdate = true + end + + for j=buttons+1,12 do + if bars[i][j] then + bars[i][j]:Hide() + end + end + + -- adjust actionbar size + BarLayoutSize(bars[i], buttons, formfactor, size, border) + bars[i]:SetWidth(bars[i]._size[1]) + bars[i]:SetHeight(bars[i]._size[2]) + bars[i]:ClearAllPoints() + if i == 1 then -- main + bars[i]:SetPoint("BOTTOM", 0, 2*border) + elseif i == 3 then -- left + bars[i]:SetPoint("BOTTOMLEFT", bars[1], "BOTTOMRIGHT", 3*border, 0) + elseif i == 4 then -- vertical + bars[i]:SetPoint("RIGHT", -3*border, 0) + elseif i == 5 then -- right + bars[i]:SetPoint("BOTTOMRIGHT", bars[1], "BOTTOMLEFT", -3*border, 0) + elseif i == 6 then -- top + bars[i]:SetPoint("BOTTOM", bars[1], "TOP", 0, border) + elseif i == 11 then -- stances + bars[i]:SetPoint("BOTTOM", bars[6], "TOP", 0, 3*border) + elseif i == 12 then -- pet + bars[i]:SetPoint("BOTTOM", bars[6], "TOP", 0, 3*border) + else -- others + bars[i]:SetPoint("TOP", 0, -i*50) + end + + UpdateMovable(bars[i]) + + -- apply backdrop settings + if background == "1" then + CreateBackdrop(bars[i]) + bars[i].backdrop:Show() + + -- share backdrop of main and top actionbar + if i == 6 then + bars[6].OnMove = bars[6].OnMove or function() + local _, a, _ = bars[6]:GetPoint() + if a == bars[1] and C.bars.bar1.enable == "1" + and C.bars.bar1.background == "1" and C.bars.bar6.background == "1" + and C.bars.bar1.autohide == "0" and C.bars.bar6.autohide == "0" + and C.bars.bar1.icon_size == C.bars.bar6.icon_size + and C.bars.bar1.formfactor == C.bars.bar6.formfactor + and C.bars.bar1.buttons == C.bars.bar6.buttons + then + bars[1].backdrop:ClearAllPoints() + bars[1].backdrop:SetPoint("BOTTOMRIGHT", bars[1], "BOTTOMRIGHT", border-1, -border+1) + bars[1].backdrop:SetPoint("TOPLEFT", bars[6].backdrop, "TOPLEFT", 0, 0) + bars[6].backdrop:Hide() + else + if C.bars.bar1.background == "1" then + -- create/reset bar1 backdrop if required + CreateBackdrop(bars[1]) + bars[1].backdrop:ClearAllPoints() + bars[1].backdrop:SetPoint("BOTTOMRIGHT", bars[1], "BOTTOMRIGHT", border-1, -border+1) + bars[1].backdrop:SetPoint("TOPLEFT", bars[1], "TOPLEFT", -border+1, border-1) + end + + if C.bars.bar6.background == "1" then + bars[6].backdrop:Show() + end + end + end + + bars[i].OnMove() + end + else + if bars[i].backdrop then + bars[i].backdrop:Hide() + end + + if bars[i].shadow then + bars[i].shadow:Hide() + end + end + end + + -- create actionbars + pfUI.bars = bars + + function pfUI.bars:UpdateConfig() + for i=1,12 do + CreateActionBar(i) + end + end + pfUI.bars:UpdateConfig() + + -- helper function to update by slot + local function RefreshSlot(slot) + local bar, button = ceil(slot/12), mod(slot, 12) + button = button == 0 and 12 or button + bars[bar][button].forceupdate = true + end + + -- custom pagings + local function pagelimits() + local min, max = 10, 1 + for i=1, 10 do + if C.bars["bar"..i] and C.bars["bar"..i].pageable == "1" then + min = min > i and i or min + max = max < i and i or max + end + end + + return min, max + end + + -- Localize custom keybinds for additional actionbars (see Bindings.xml) + local names = { + ["PAGING"] = "Paging", + ["SPECIAL"] = "Special", + ["STANCEONE"] = "Stance 1", + ["STANCETWO"] = "Stance 2", + ["STANCETHREE"] = "Stance 3", + } + + for name, loc in pairs(names) do + _G["BINDING_HEADER_PFBAR"..name] = T["Action Bar"] .. " " .. loc + for i=1,12 do + _G["BINDING_NAME_PF" .. name .. i] = loc .. " " .. T["Button"] .. " " .. i + end + end + + -- combined button trigger + function _G.pfActionButton(slot, slf, opt) + local bar, button = 1, slot + + local slf = C.bars.altself == "1" and IsAltKeyDown() and true or slf + + -- determine the proper bar and button + if opt and blizzbarmapping[opt] then + bar = blizzbarmapping[opt] + elseif slot > 12 then + bar, button = ceil(slot/12), mod(slot, 12) + button = button == 0 and 12 or button + end + + local frame = bars[bar][button] + if not frame then return end + local action = frame:GetID() + + if ( pfUI_config.bars.keydown == "1" and keystate == "down" ) or (pfUI_config.bars.keydown == "0" and keystate == "up" ) or bar == 11 then + -- trigger animation + frame.animation.active = 0 + frame.animation:Show() + + -- clear highlight + if not MouseIsOver(frame) then frame.highlight:Hide() end + + -- trigger action + if bar == 12 then + CastPetAction(action) + elseif bar == 11 then + CastShapeshiftForm(action) + else + UseAction(action, nil, slf) + end + elseif keystate == "down" then + -- show highlight + frame.highlight:Show() + end + end + + -- In order to be able to reuse already defined keybinds, we need to remap + -- existing button functions to pfUI (does it break other addon hooks? maybe.) + -- But we need to get rid of the blizzard calls to avoid having them call + -- unnecessary texture changes and errors due to missing buttons and such + _G.ActionButtonDown = pfActionButton + _G.ActionButtonUp = pfActionButton + _G.BonusActionButtonDown = function(slot) pfActionButton(slot, nil, "BonusActionBar") end + _G.BonusActionButtonUp = function(slot) pfActionButton(slot, nil, "BonusActionBar") end + _G.MultiActionButtonDown = function(bar, slot, slf) pfActionButton(slot, slf, bar) end + _G.MultiActionButtonUp = function(bar, slot, slf) pfActionButton(slot, slf, bar) end + _G.ShapeshiftBar_ChangeForm = function(slot) pfActionButton(slot, nil, "ShapeShiftBar") end + + function _G.ActionBar_PageUp() + local min, max = pagelimits() + local bar = _G.CURRENT_ACTIONBAR_PAGE + 1 + if bar > max then bar = min end + + for newbar=bar, 10, 1 do + if C.bars["bar"..newbar] and C.bars["bar"..newbar].pageable == "1" then + SwitchBar(newbar) + return + end + end + end + + function _G.ActionBar_PageDown() + local min, max = pagelimits() + local bar = _G.CURRENT_ACTIONBAR_PAGE - 1 + if bar < min then bar = max end + + for newbar=bar, 1, -1 do + if C.bars["bar"..newbar] and C.bars["bar"..newbar].pageable == "1" then + SwitchBar(newbar) + return + end + end + end + + -- enable paging on the first actionbar + local pager = CreateFrame("Frame") + pager:RegisterEvent("PLAYER_ENTERING_WORLD") + pager:RegisterEvent("UPDATE_BONUS_ACTIONBAR") + pager:RegisterEvent("ACTIONBAR_PAGE_CHANGED") + pager:SetScript("OnEvent", function() + bar = GetActiveBar() + + for i=1,12 do + id = i + (bar-1)*12 + bars[1][i].bar = bar + bars[1][i]:SetID(id) + bars[1][i].forceupdate = true + end + end) + + -- handle drag-drop grid + local grid = CreateFrame("Frame") + grid:RegisterEvent("ACTIONBAR_SHOWGRID") + grid:RegisterEvent("ACTIONBAR_HIDEGRID") + grid:SetScript("OnEvent", function() + if event == "ACTIONBAR_SHOWGRID" then + showgrid = 1 + else + showgrid = 0 + end + end) + + -- reagent counter + local reagent_slots = { } + local reagent_counts = { } + local reagent_capture = SPELL_REAGENTS.."(.+)" + local scanner = libtipscan:GetScanner("actionbar") + local reagentcounter = CreateFrame("Frame", "pfReagentCounter", UIParent) + reagentcounter:RegisterEvent("PLAYER_ENTERING_WORLD") + reagentcounter:RegisterEvent("ACTIONBAR_SLOT_CHANGED") + reagentcounter:RegisterEvent("BAG_UPDATE") + reagentcounter:SetScript("OnEvent", function() + if event == "BAG_UPDATE" then + this.event = true + else + for slot = 1, 120 do + -- clear cached reagent slots on SLOT_CHANGED + local hadslot = reagent_slots[slot] + reagent_slots[slot] = nil + if HasAction(slot) then + scanner:SetAction(slot) + local _, reagents = scanner:Find(reagent_capture) + if reagents then + reagent_slots[slot] = reagents + reagent_counts[reagents] = reagent_counts[reagents] or 0 + end + end + + if reagent_slots[slot] or hadslot then + RefreshSlot(slot) + end + end + end + end) + + -- limit bag events to one per second + reagentcounter:SetScript("OnUpdate", function() + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end + + if this.event then + for item in pairs(reagent_counts) do + reagent_counts[item] = GetItemCount(item) + end + for slot in pairs(reagent_slots) do + RefreshSlot(slot) + end + + this.event = nil + end + end) + + function IsReagentAction(slot) + return reagent_slots[slot] and true or nil + end + + function GetReagentCount(slot) + return reagent_counts[reagent_slots[slot]] + end + + -- pagemaster / meta page switch if C.bars.pagemaster == "1" then local modifier = { "ALT", "SHIFT", "CTRL" } local buttons = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "+", "=", "ยด" } local shift, ctrl, alt, default = 6, 5, 3, 1 local current = CURRENT_ACTIONBAR_PAGE - local function SwitchBar(bar) - if CURRENT_ACTIONBAR_PAGE ~= bar then - CURRENT_ACTIONBAR_PAGE = bar - ChangeActionBarPage() - end - end - local pagemaster = CreateFrame("Frame", "pfPageMaster", UIParent) pagemaster:RegisterEvent("PLAYER_ENTERING_WORLD") pagemaster:SetScript("OnEvent", function() @@ -69,609 +1060,4 @@ pfUI:RegisterModule("actionbar", function () end end) end - - -- reagent counter - local reagentslots = { } - local reagentbuttons = { } - local reagent_capture = SPELL_REAGENTS.."(.+)" - local scanner = libtipscan:GetScanner("actionbar") - local reagentcounter = CreateFrame("Frame", "pfReagentCounter", UIParent) - reagentcounter:RegisterEvent("PLAYER_ENTERING_WORLD") - reagentcounter:RegisterEvent("ACTIONBAR_SLOT_CHANGED") - reagentcounter:RegisterEvent("BAG_UPDATE") - reagentcounter:SetScript("OnEvent", function() - for slot = 1, 120 do - -- update reagent names per slot - if event == "PLAYER_ENTERING_WORLD" or event == "ACTIONBAR_SLOT_CHANGED" then - reagentslots[slot] = nil - scanner:SetAction(slot) - local _, reagents = scanner:Find(reagent_capture) - if reagents then - reagentslots[slot] = reagents - end - end - - -- update buttons - if reagentbuttons[slot] then - _G.this = reagentbuttons[slot] - ActionButton_Update() - end - end - end) - - local oldIsConsumableAction = IsConsumableAction - _G.IsConsumableAction = function(slot) - if oldIsConsumableAction(slot) then return true end - if this and this.GetParent and ActionButton_GetPagedID(this) == slot then - reagentbuttons[slot] = reagentbuttons[slot] or this - return reagentslots[slot] and true - end - end - - local oldGetActionCount = GetActionCount - _G.GetActionCount = function(slot) - if reagentslots[slot] then - return GetItemCount(reagentslots[slot]) - end - - if oldGetActionCount(slot) then - return oldGetActionCount(slot) - end - end - - if C.bars.glowrange == "1" then - - function _G.ActionButton_UpdateUsable() - if pfScanActive then return end - - local icon = getglobal(this:GetName().."Icon"); - local normalTexture = getglobal(this:GetName().."NormalTexture"); - local isUsable, notEnoughMana = IsUsableAction(ActionButton_GetPagedID(this)); - if ( isUsable ) then - icon:SetVertexColor(1.0, 1.0, 1.0); - normalTexture:SetVertexColor(1.0, 1.0, 1.0); - elseif ( notEnoughMana ) then - icon:SetVertexColor(0.5, 0.5, 1.0); - normalTexture:SetVertexColor(0.5, 0.5, 1.0); - else - icon:SetVertexColor(0.4, 0.4, 0.4); - normalTexture:SetVertexColor(1.0, 1.0, 1.0); - end - end - - hooksecurefunc("ActionButton_OnUpdate", function(elapsed) - -- Handle range indicator - if ( this.rangeTimer ) then - this.rangeTimer = this.rangeTimer - elapsed - if ( this.rangeTimer <= 0.1 ) then - if ( IsActionInRange( ActionButton_GetPagedID(this)) == 0 ) then - if not this.a then - this.r,this.g,this.b,this.a = strsplit(",", C.bars.rangecolor) - end - _G[this:GetName() .. 'Icon']:SetVertexColor(this.r, this.g, this.b, this.a) - elseif IsUsableAction(ActionButton_GetPagedID(this)) then - _G[this:GetName() .. 'Icon']:SetVertexColor(1, 1, 1, 1) - end - this.rangeTimer = TOOLTIP_UPDATE_TIME - end - end - end) - end - - function _G.ActionButton_GetPagedID(button) - if ( button.isBonus and CURRENT_ACTIONBAR_PAGE == 1 ) then - local offset = GetBonusBarOffset() - if ( offset == 0 and BonusActionBarFrame and BonusActionBarFrame.lastBonusBar ) then - offset = BonusActionBarFrame.lastBonusBar - end - return (button:GetID() + ((NUM_ACTIONBAR_PAGES + offset - 1) * NUM_ACTIONBAR_BUTTONS)) - end - - local parentName = button:GetParent():GetName() - if ( parentName == "pfMultiBarBottomLeft" or parentName == "MultiBarBottomLeft" ) then - return (button:GetID() + ((BOTTOMLEFT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS)) - elseif ( parentName == "pfMultiBarBottomRight" or parentName == "MultiBarBottomRight" ) then - return (button:GetID() + ((BOTTOMRIGHT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS)) - elseif ( parentName == "pfMultiBarLeft" or parentName == "MultiBarLeft" ) then - return (button:GetID() + ((LEFT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS)) - elseif ( parentName == "pfMultiBarRight" or parentName == "MultiBarRight" ) then - return (button:GetID() + ((RIGHT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS)) - else - return (button:GetID() + ((CURRENT_ACTIONBAR_PAGE - 1) * NUM_ACTIONBAR_BUTTONS)) - end - end - - -- hide default blizz - MainMenuBar:Hide() - BonusActionBarTexture0:Hide() - BonusActionBarTexture1:Hide() - - -- hide background texture of petactionbar - SlidingActionBarTexture0:Hide() - SlidingActionBarTexture0.Show = function () return end - - SlidingActionBarTexture1:Hide() - SlidingActionBarTexture1.Show = function () return end - - -- create action bar frame - pfUI.bars = CreateFrame("Frame", nil, UIParent) - pfUI.bars:RegisterEvent("PLAYER_ENTERING_WORLD") - pfUI.bars:RegisterEvent("CVAR_UPDATE") - pfUI.bars:RegisterEvent("PET_BAR_UPDATE") - pfUI.bars:RegisterEvent("PLAYER_CONTROL_GAINED") - pfUI.bars:RegisterEvent("PLAYER_CONTROL_LOST") - pfUI.bars:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED") - pfUI.bars:RegisterEvent("UPDATE_SHAPESHIFT_FORMS") - - 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) - - pfUI.bars:SetScript("OnEvent", function() - MultiActionBar_Update() - UIParent_ManageFramePositions() - MultiActionBar_Update() - UpdateMicroButtons() - - BarLayoutSize(pfUI.bars.actionmain, NUM_ACTIONBAR_BUTTONS, C.bars.actionmain.formfactor, C.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() - - this.pet:ClearAllPoints() - this.pet:SetPoint("BOTTOM", this.bottomleft:IsShown() and this.bottomleft or this.actionmain, "TOP", 0, default_border * 3) - UpdateMovable(this.pet, true) - - BarLayoutSize(pfUI.bars.pet, NUM_PET_ACTION_SLOTS, C.bars.pet.formfactor, C.bars.icon_size, default_border) - pfUI.bars.pet:SetWidth(pfUI.bars.pet._size[1]) - pfUI.bars.pet:SetHeight(pfUI.bars.pet._size[2]) - if C.bars.background == "1" then CreateBackdrop(pfUI.bars.pet, default_border) end - - PetActionBarFrame:ClearAllPoints() - PetActionBarFrame:Hide() - - for i=1, NUM_PET_ACTION_SLOTS do - local b = _G["PetActionButton"..i] - b:ClearAllPoints() - b:SetFrameLevel(pfUI.bars.pet:GetFrameLevel() + 1) - b:SetParent(pfUI.bars.pet) - CreateBackdrop(b, default_border) - BarButtonAnchor(b, "PetActionButton", i, NUM_PET_ACTION_SLOTS, C.bars.pet.formfactor, C.bars.icon_size, default_border) - b:SetPoint(unpack(b._anchor)) - end - else - pfUI.bars.pet:Hide() - end - - local shapeshiftbuttons = 0 - if ShapeshiftButton1:IsShown() then - ShapeshiftBarFrame:ClearAllPoints() - ShapeshiftBarFrame:SetAllPoints(pfUI.bars.shapeshift) - - for i=1, NUM_SHAPESHIFT_SLOTS do - local b = _G["ShapeshiftButton"..i] - b:ClearAllPoints() - b:SetParent(pfUI.bars.shapeshift) - CreateBackdrop(b, default_border) - BarButtonAnchor(b, "ShapeshiftButton", i, NUM_SHAPESHIFT_SLOTS, C.bars.shapeshift.formfactor, C.bars.icon_size, default_border) - b:SetPoint(unpack(b._anchor)) - if b:IsShown() then shapeshiftbuttons = shapeshiftbuttons + 1 end - end - - this.shapeshift:ClearAllPoints() - this.shapeshift:SetPoint("BOTTOM", this.bottomleft:IsShown() and this.bottomleft or this.pet:IsShown() and this.pet or this.actionmain, "TOP", 0, default_border * 3) - UpdateMovable(this.shapeshift, true) - - if C.bars.background == "1" then CreateBackdrop(pfUI.bars.shapeshift, default_border) end - BarLayoutSize(pfUI.bars.shapeshift, NUM_SHAPESHIFT_SLOTS, C.bars.shapeshift.formfactor, C.bars.icon_size, default_border,shapeshiftbuttons) - pfUI.bars.shapeshift:SetWidth(pfUI.bars.shapeshift._size[1]) - pfUI.bars.shapeshift:SetHeight(pfUI.bars.shapeshift._size[2]) - pfUI.bars.shapeshift:Show() - else - pfUI.bars.shapeshift:Hide() - end - - if SHOW_MULTI_ACTIONBAR_1 then - pfUI.bars.bottomleft:Show() - pfUI.bars.bottomleft:SetFrameStrata("LOW") - pfUI.bars.bottomleft:ClearAllPoints() - pfUI.bars.bottomleft:SetPoint("BOTTOM", pfUI.bars.actionmain, "TOP", 0, default_border) - UpdateMovable(pfUI.bars.bottomleft) - - BarLayoutSize(pfUI.bars.bottomleft, NUM_ACTIONBAR_BUTTONS, C.bars.bottomleft.formfactor, C.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", "pfMultiBarBottomLeft", UIParent ) - tf:SetParent(pfUI.bars.bottomleft) - tf:SetAllPoints(pfUI.bars.bottomleft) - - for i=1, NUM_ACTIONBAR_BUTTONS do - local b = _G["MultiBarBottomLeftButton"..i] - b:ClearAllPoints() - b:SetParent(tf) - CreateBackdrop(b, default_border) - BarButtonAnchor(b, "MultiBarBottomLeftButton", i, NUM_ACTIONBAR_BUTTONS, C.bars.bottomleft.formfactor, C.bars.icon_size, default_border) - b:SetPoint(unpack(b._anchor)) - end - end - else - pfUI.bars.bottomleft:Hide() - end - - 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("BOTTOMRIGHT", pfUI.bars.actionmain, "BOTTOMLEFT", -default_border*3, 0) - UpdateMovable(pfUI.bars.bottomright) - if C.bars.background == "1" then CreateBackdrop(pfUI.bars.bottomright, default_border) end - - BarLayoutSize(pfUI.bars.bottomright, NUM_ACTIONBAR_BUTTONS, C.bars.bottomright.formfactor, C.bars.icon_size, default_border) - pfUI.bars.bottomright:SetWidth(pfUI.bars.bottomright._size[1]) - pfUI.bars.bottomright:SetHeight(pfUI.bars.bottomright._size[2]) - - 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", "pfMultiBarBottomRight", UIParent ) - tf:SetParent(pfUI.bars.bottomright) - tf:SetAllPoints(pfUI.bars.bottomright) - - for i=1, NUM_ACTIONBAR_BUTTONS do - local b = _G["MultiBarBottomRightButton"..i] - b:ClearAllPoints() - b:SetParent(tf) - CreateBackdrop(b, default_border) - BarButtonAnchor(b, "MultiBarBottomRightButton", i, NUM_ACTIONBAR_BUTTONS, C.bars.bottomright.formfactor, C.bars.icon_size, default_border) - b:SetPoint(unpack(b._anchor)) - end - end - else - pfUI.bars.bottomright:Hide() - end - - 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*3, 0) - UpdateMovable(pfUI.bars.right) - if C.bars.background == "1" then CreateBackdrop(pfUI.bars.right, default_border) end - - BarLayoutSize(pfUI.bars.right, NUM_ACTIONBAR_BUTTONS, C.bars.right.formfactor, C.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.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, NUM_ACTIONBAR_BUTTONS do - local b = _G["MultiBarRightButton"..i] - b:ClearAllPoints() - b:SetParent(tf) - CreateBackdrop(b, default_border) - BarButtonAnchor(b, "MultiBarRightButton", i, NUM_ACTIONBAR_BUTTONS, C.bars.right.formfactor, C.bars.icon_size, default_border) - b:SetPoint(unpack(b._anchor)) - end - end - else - pfUI.bars.right:Hide() - end - - if SHOW_MULTI_ACTIONBAR_4 then - pfUI.bars.tworight:Show() - for i=1, NUM_ACTIONBAR_BUTTONS do - _G["MultiBarLeftButton"..i]:Show() - end - - pfUI.bars.tworight:SetFrameStrata("LOW") - pfUI.bars.tworight:ClearAllPoints() - pfUI.bars.tworight:SetPoint("RIGHT", UIParent, "RIGHT", -5, 0) - UpdateMovable(pfUI.bars.tworight) - if C.bars.background == "1" then CreateBackdrop(pfUI.bars.tworight, default_border) end - BarLayoutSize(pfUI.bars.tworight, NUM_ACTIONBAR_BUTTONS, C.bars.tworight.formfactor, C.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 = _G["MultiBarLeftButton"..i] - b:ClearAllPoints() - b:SetParent(tf) - CreateBackdrop(b, default_border) - BarButtonAnchor(b, "MultiBarLeftButton", i, NUM_ACTIONBAR_BUTTONS, C.bars.tworight.formfactor, C.bars.icon_size, default_border) - b:SetPoint(unpack(b._anchor)) - end - end - else - pfUI.bars.tworight:Hide() - end - 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 C.bars.background == "1" then 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 C.bars.background == "1" then CreateBackdrop(pfUI.bars.actionmain, default_border) end - if C.bars.background == "1" then CreateBackdrop(pfUI.bars.bottomleft, default_border) end - end - - -- refresh all grids - MultiActionBar_ShowAllGrids() - MultiActionBar_HideAllGrids() - end) - - pfUI.bars.autohide = CreateFrame("Frame", nil, UIParent) - pfUI.bars.autohide:RegisterEvent("PLAYER_ENTERING_WORLD") - pfUI.bars.autohide:SetScript("OnEvent", function() - if C.bars.hide_actionmain == "1" then - CreateAutohide(pfUI.bars.actionmain) - end - if C.bars.hide_bottomleft == "1" then - CreateAutohide(pfUI.bars.bottomleft) - end - if C.bars.hide_bottomright == "1" then - CreateAutohide(pfUI.bars.bottomright) - end - if C.bars.hide_right == "1" then - CreateAutohide(pfUI.bars.right) - end - if C.bars.hide_tworight == "1" then - CreateAutohide(pfUI.bars.tworight) - end - if C.bars.hide_shapeshift == "1" then - CreateAutohide(pfUI.bars.shapeshift) - end - if C.bars.hide_pet == "1" then - CreateAutohide(pfUI.bars.pet) - end - end) - - -- create main action bar frame - pfUI.bars.actionmain:SetFrameStrata("LOW") - UpdateMovable(pfUI.bars.actionmain) - - 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 C.bars.background == "1" then CreateBackdrop(pfUI.bars.actionmain, default_border) end - if C.bars.background == "1" then CreateBackdrop(pfUI.bars.bottomleft, default_border) end - if pfUI.bars.actionmain.share then pfUI.bars.actionmain.share:Hide() end - end - end - - -- 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 = _G["ActionButton"..i] - b:ClearAllPoints() - b:SetParent(tf) - CreateBackdrop(b, default_border) - BarButtonAnchor(b, "ActionButton", i, NUM_ACTIONBAR_BUTTONS, C.bars.actionmain.formfactor, C.bars.icon_size, default_border) - b:SetPoint(unpack(b._anchor)) - end - end - - BonusActionBarFrame:ClearAllPoints() - BonusActionBarFrame:SetParent(pfUI.bars.actionmain) - BonusActionBarFrame:SetAllPoints(pfUI.bars.actionmain) - BonusActionBarFrame:EnableMouse(0) - - local tf = _G["pfBonusBar"] or CreateFrame("Frame","pfBonusBar", UIParent) - tf:SetParent(pfUI.bars.actionmain) - tf:SetAllPoints(pfUI.bars.actionmain) - tf:SetFrameLevel(pfActionBar:GetFrameLevel() + 1) - for i=1, NUM_BONUS_ACTION_SLOTS do - local b = _G["BonusActionButton"..i] - b:ClearAllPoints() - b:SetParent(tf) - CreateBackdrop(b, default_border) - BarButtonAnchor(b, "BonusActionButton", i, NUM_BONUS_ACTION_SLOTS, C.bars.actionmain.formfactor, C.bars.icon_size, default_border) - b:SetPoint(unpack(b._anchor)) - end - - for i = 1, NUM_SHAPESHIFT_SLOTS do - local button = _G["ShapeshiftButton"..i] - button:SetWidth(C.bars.icon_size) - button:SetHeight(C.bars.icon_size) - - local cooldown = _G["ShapeshiftButton"..i..'Cooldown'] - cooldown.pfCooldownType = "NOGCD" - - local icon = _G["ShapeshiftButton"..i..'Icon'] - icon:SetParent(button) - icon:SetAllPoints(button) - icon:SetTexCoord(.08, .92, .08, .92) - - local pushed = button:GetPushedTexture() - pushed:SetAllPoints(button) - pushed:SetTexCoord(.08,.92,.08,.92) - button.SetPushedTexture = function() return end - - local checked = button:GetCheckedTexture() - checked:SetAllPoints(button) - checked:SetTexCoord(.08,.92,.08,.92) - button.SetCheckedTexture = function() return end - - local texture = _G["ShapeshiftButton"..i..'NormalTexture'] - texture:SetAlpha(0) - - local border = _G["ShapeshiftButton"..i..'Border'] - border:SetAlpha(0) - - local hotkey = _G["ShapeshiftButton"..i..'HotKey'] - hotkey:SetAllPoints(button) - hotkey:SetFont(pfUI.font_unit, C.global.font_unit_size -2, "OUTLINE") - hotkey:SetJustifyH("RIGHT") - hotkey:SetJustifyV("TOP") - end - - PetActionBarFrame:SetParent(pfUI.bars.pet) - for i = 1, NUM_PET_ACTION_SLOTS do - local button = _G["PetActionButton"..i] - button:SetWidth(C.bars.icon_size) - button:SetHeight(C.bars.icon_size) - button:Show() - - local cooldown = _G["PetActionButton"..i..'Cooldown'] - cooldown.pfCooldownType = "NOGCD" - - local icon = _G["PetActionButton"..i..'Icon'] - icon:SetAllPoints(button) - icon:SetParent(button) - icon:SetTexCoord(.08, .92, .08, .92) - - local pushed = button:GetPushedTexture() - pushed:SetAllPoints(button) - pushed:SetTexCoord(.08,.92,.08,.92) - button.SetPushedTexture = function() return end - - local checked = button:GetCheckedTexture() - checked:SetAllPoints(button) - checked:SetTexCoord(.08,.92,.08,.92) - button.SetCheckedTexture = function() return end - - local texture = _G["PetActionButton"..i..'NormalTexture2'] - texture:SetAlpha(0) - - local castable = _G["PetActionButton"..i..'AutoCastable'] - if C.bars.showcastable == "1" then - castable:SetWidth(C.bars.icon_size*1.5) - castable:SetHeight(C.bars.icon_size*1.5) - castable:SetParent(button) - castable:SetTexCoord(.08, .9, .08, .9) - else - castable:SetAlpha(0) - end - - local border = _G["PetActionButton"..i..'Border'] - border:SetAlpha(0) - - local autocast = _G["PetActionButton"..i..'AutoCast'] - autocast:SetScale(C.bars.icon_size / 30) - autocast:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0) - autocast:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", 1, -1) - autocast:SetAlpha(.1) - end - - -- theme all actionbars (spacing, size, border, text position and style) - local actionbars = { "ActionButton", "MultiBarLeftButton", "MultiBarRightButton", - "MultiBarBottomLeftButton", "MultiBarBottomRightButton", "BonusActionButton", } - - for i = 1, NUM_ACTIONBAR_BUTTONS do - for _, actionbutton in pairs(actionbars) do - local button = _G[actionbutton..i] - button:SetWidth(C.bars.icon_size) - button:SetHeight(C.bars.icon_size) - button:Show() - - button:SetNormalTexture("") - button.SetNormalTexture = function() return end - - local cooldown = _G[actionbutton..i..'Cooldown'] - cooldown.pfCooldownType = "NOGCD" - - local icon = _G[actionbutton..i..'Icon'] - icon:SetAllPoints(button) - icon:SetTexCoord(.08, .92, .08, .92) - - local pushed = button:GetPushedTexture() - pushed:SetAllPoints(button) - pushed:SetTexCoord(.08,.92,.08,.92) - button.SetPushedTexture = function() return end - - local checked = button:GetCheckedTexture() - checked:SetAllPoints(button) - checked:SetTexCoord(.08,.92,.08,.92) - button.SetCheckedTexture = function() return end - - local border = _G[actionbutton..i..'Border'] - if C.bars.showequipped == "1" then - border:SetAllPoints(button) - border:SetTexture(0,1,0,.75) - else - border:SetTexture(0,0,0,0) - end - - local hotkey = _G[actionbutton..i..'HotKey'] - if C.bars.showkeybind == "1" then - hotkey:SetAllPoints(button) - hotkey:SetFont(pfUI.font_unit, C.global.font_unit_size -2, "OUTLINE") - hotkey:SetJustifyH("RIGHT") - hotkey:SetJustifyV("TOP") - else - hotkey:SetAlpha(0) - end - - local count = _G[actionbutton..i..'Count'] - count:SetAllPoints(button) - count:SetFont(pfUI.font_unit, C.global.font_unit_size, "OUTLINE") - count:SetJustifyH("RIGHT") - count:SetJustifyV("BOTTOM") - - local name = _G[actionbutton..i..'Name'] - if C.bars.showmacro == "1" then - name:SetAllPoints(button) - name:SetFont(pfUI.font_unit, C.global.font_unit_size -2, "OUTLINE") - name:SetJustifyH("CENTER") - name:SetJustifyV("BOTTOM") - else - name:SetAlpha(0) - end - end - end end) diff --git a/modules/chat.lua b/modules/chat.lua index 5bc44c6a..adfc3749 100644 --- a/modules/chat.lua +++ b/modules/chat.lua @@ -671,30 +671,32 @@ pfUI:RegisterModule("chat", function () end end - -- to make sure SHOW_MULTI_ACTIONBAR_1 is set to the real value, we need to wait. + -- to make sure the bars are set up properly, 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 + if pfUI.bars and pfUI.bars[6]:IsShown() then + anchor = pfUI.bars[6] + elseif pfUI.bars and pfUI.bars[1]:IsShown() then + anchor = pfUI.bars[1] end - pfUI.chat.editbox:SetPoint("BOTTOMLEFT", anchor, "TOPLEFT", 0, default_border*3) - pfUI.chat.editbox:SetPoint("BOTTOMRIGHT", anchor, "TOPRIGHT", 0, default_border*3) + if C.chat.text.input_width ~= "0" then + pfUI.chat.editbox:SetPoint("BOTTOM", anchor, "TOP", 0, default_border*3) + pfUI.chat.editbox:SetWidth(C.chat.text.input_width) + else + pfUI.chat.editbox:SetWidth(anchor:GetWidth()) + pfUI.chat.editbox:SetPoint("BOTTOMLEFT", anchor, "TOPLEFT", 0, default_border*3) + pfUI.chat.editbox:SetPoint("BOTTOMRIGHT", anchor, "TOPRIGHT", 0, default_border*3) + end UpdateMovable(pfUI.chat.editbox) end) - if C.chat.text.input_width == "0" then - pfUI.chat.editbox:SetWidth(default_border*3 + C.bars.icon_size * 12 + default_border * 12) -- actionbar size - else - pfUI.chat.editbox:SetWidth(C.chat.text.input_width) - end ChatFrameEditBox:SetParent(pfUI.chat.editbox) ChatFrameEditBox:SetAllPoints(pfUI.chat.editbox) diff --git a/modules/gui.lua b/modules/gui.lua index 9094d33d..afa98223 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -87,6 +87,20 @@ pfUI:RegisterModule("gui", function () end end + if category == "UVAR" then + category = {} + category[config] = _G[config] + + local update = ufunc + + ufunc = function() + _G[config] = this:GetChecked() and "1" or "0" + if update then + update() + end + end + end + frame.category = category frame.config = config @@ -717,9 +731,17 @@ pfUI:RegisterModule("gui", function () "BOTTOMRIGHT:" .. T["Bottom Right"], } - pfUI.gui.dropdowns.num_actionbar_buttons = BarLayoutOptions(NUM_ACTIONBAR_BUTTONS) - pfUI.gui.dropdowns.num_shapeshift_slots = BarLayoutOptions(NUM_SHAPESHIFT_SLOTS) - pfUI.gui.dropdowns.num_pet_action_slots = BarLayoutOptions(NUM_PET_ACTION_SLOTS) + pfUI.gui.dropdowns.actionbuttonanimations = { + "none:" .. T["None"], + "zoomfade:" .. T["Zoom & Fade"], + "shrinkreturn:" .. T["Shrink & Return"], + "elasticzoom:" .. T["Elastic Zoom"], + "wobblezoom:" .. T["Wobble Zoom"], + } + + pfUI.gui.dropdowns.actionbarbuttons = { + "1","2","3","4","5","6","7","8","9","10","11","12" + } pfUI.gui.dropdowns.loot_rarity = {} for i=0, getn(_G.ITEM_QUALITY_COLORS)-2 do @@ -1236,59 +1258,80 @@ pfUI:RegisterModule("gui", function () pfUI.gui.tabs.actionbar = pfUI.gui.tabs:CreateTabChild(T["Actionbar"], nil, nil, nil, true) pfUI.gui.tabs.actionbar.tabs = CreateTabFrame(pfUI.gui.tabs.actionbar, "TOP", true) + local barnames = { {11, "Stance/Shapeshift Bar"}, {12, "Pet Actionbar"}, {1, "Main Actionbar"}, + {6, "Top Actionbar"}, {5, "Left Actionbar"}, {3, "Right Actionbar"}, {4, "Vertical Actionbar"}, + {2, "Paging Actionbar"}, {7, "Special Actionbar"}, {8, "Stance Bar 1"}, {9, "Stance Bar 2"}, {10, "Stance Bar 3"} } + -- >> General pfUI.gui.tabs.actionbar.tabs.general = pfUI.gui.tabs.actionbar.tabs:CreateTabChild(T["General"], true) pfUI.gui.tabs.actionbar.tabs.general:SetScript("OnShow", function() if not this.setup then - CreateConfig(nil, this, T["Icon Size"], C.bars, "icon_size") - CreateConfig(nil, this, T["Enable Action Bar Backgrounds"], C.bars, "background", "checkbox") - CreateConfig(MultiActionBar_UpdateGridVisibility, this, T["Always Show Action Bar Buttons"], "GVAR", "ALWAYS_SHOW_MULTIBARS", "checkbox") - CreateConfig(nil, this, T["Enable Range Display On Hotkeys"], C.bars, "glowrange", "checkbox") - CreateConfig(nil, this, T["Range Display Color"], C.bars, "rangecolor", "color") - CreateConfig(nil, this, T["Show Macro Text"], C.bars, "showmacro", "checkbox") - CreateConfig(nil, this, T["Show Hotkey Text"], C.bars, "showkeybind", "checkbox") - CreateConfig(nil, this, T["Show Equipped Items"], C.bars, "showequipped", "checkbox") - CreateConfig(nil, this, T["Enable Range Based Auto Paging (Hunter)"], C.bars, "hunterbar", "checkbox") - CreateConfig(nil, this, T["Enable Action On Key Down"], C.bars, "keydown", "checkbox") - CreateConfig(nil, this, T["Switch Bar On Meta Key Press"], C.bars, "pagemaster", "checkbox") - CreateConfig(nil, this, T["Show Indicator For Castable Pet Actions"], C.bars, "showcastable", "checkbox") + CreateConfig(update["bars"], this, T["Trigger Actions On Key Down"], C.bars, "keydown", "checkbox") + CreateConfig(update["bars"], this, T["Alt Self Cast For All Hotkeys"], C.bars, "altself", "checkbox") + CreateConfig(update["bars"], this, T["Button Animation"], C.bars, "animation", "dropdown", pfUI.gui.dropdowns.actionbuttonanimations) + CreateConfig(update["bars"], this, T["Highlight Equipped Items"], C.bars, "showequipped", "checkbox") + CreateConfig(update["bars"], this, T["Equipped Item Color"], C.bars, "eqcolor", "color") + CreateConfig(update["bars"], this, T["Highlight Out Of Range Spells"], C.bars, "glowrange", "checkbox") + CreateConfig(update["bars"], this, T["Out Of Range Color"], C.bars, "rangecolor", "color") + CreateConfig(update["bars"], this, T["Highlight Out Of Mana Spells"], C.bars, "showoom", "checkbox") + CreateConfig(update["bars"], this, T["Out Of Mana Color"], C.bars, "oomcolor", "color") + CreateConfig(update["bars"], this, T["Highlight Not Usable Spells"], C.bars, "showna", "checkbox") + CreateConfig(update["bars"], this, T["Not Usable Color"], C.bars, "nacolor", "color") + CreateConfig(update["bars"], this, T["Lock Actionbars"], "UVAR", "LOCK_ACTIONBAR", "checkbox") + + CreateConfig(nil, this, "Font Options", nil, nil, "header") + CreateConfig(update["bars"], this, T["Font"], C.bars, "font", "dropdown", pfUI.gui.dropdowns.fonts) + CreateConfig(update["bars"], this, T["Font Padding"], C.bars, "font_offset") + CreateConfig(update["bars"], this, T["Macro Text Size"], C.bars, "macro_size") + CreateConfig(update["bars"], this, T["Macro Text Color"], C.bars, "macro_color", "color") + CreateConfig(update["bars"], this, T["Item Count Text Size"], C.bars, "count_size") + CreateConfig(update["bars"], this, T["Item Count Text Color"], C.bars, "count_color", "color") + CreateConfig(update["bars"], this, T["Keybind Text Size"], C.bars, "bind_size") + CreateConfig(update["bars"], this, T["Keybind Text Color"], C.bars, "bind_color", "color") + + CreateConfig(nil, this, "Auto Paging", nil, nil, "header") + CreateConfig(nil, this, T["Switch Pages On Meta Key Press"], C.bars, "pagemaster", "checkbox") + CreateConfig(nil, this, T["Range Based Hunter Paging"], C.bars, "hunterbar", "checkbox") this.setup = true end end) - -- >> Layout - pfUI.gui.tabs.actionbar.tabs.layout = pfUI.gui.tabs.actionbar.tabs:CreateTabChild(T["Layout"], true) - pfUI.gui.tabs.actionbar.tabs.layout:SetScript("OnShow", function() + pfUI.gui.tabs.actionbar.tabs.bars = pfUI.gui.tabs.actionbar.tabs:CreateTabChild("Bars", true) + pfUI.gui.tabs.actionbar.tabs.bars:SetScript("OnShow", function() if not this.setup then - CreateConfig(UIParent_ManageFramePositions, this, T["Enable Second Actionbar (BottomLeft)"], "GVAR", "SHOW_MULTI_ACTIONBAR_1", "checkbox") - CreateConfig(UIParent_ManageFramePositions, this, T["Enable Left Actionbar (BottomRight)"], "GVAR", "SHOW_MULTI_ACTIONBAR_2", "checkbox") - CreateConfig(UIParent_ManageFramePositions, this, T["Enable Right Actionbar (Right)"], "GVAR", "SHOW_MULTI_ACTIONBAR_3", "checkbox") - CreateConfig(UIParent_ManageFramePositions, this, T["Enable Vertical Actionbar (TwoRight)"], "GVAR", "SHOW_MULTI_ACTIONBAR_4", "checkbox") + for _, data in pairs(barnames) do + local id, caption = data[1], data[2] + local formfactors = BarLayoutOptions(id < 11 and NUM_ACTIONBAR_BUTTONS or id > 11 and NUM_SHAPESHIFT_SLOTS or NUM_PET_ACTION_SLOTS) + CreateConfig(update[c], this, caption, nil, nil, "header") + CreateConfig(update["bars"], this, T["Enable"], C.bars["bar"..id], "enable", "checkbox") - CreateConfig(update[c], this, T["Form Factor"], nil, nil, "header") - CreateConfig(nil, this, T["Main Actionbar (ActionMain)"], C.bars.actionmain, "formfactor", "dropdown", pfUI.gui.dropdowns.num_actionbar_buttons) - CreateConfig(nil, this, T["Second Actionbar (BottomLeft)"], C.bars.bottomleft, "formfactor", "dropdown", pfUI.gui.dropdowns.num_actionbar_buttons) - CreateConfig(nil, this, T["Left Actionbar (BottomRight)"], C.bars.bottomright, "formfactor", "dropdown", pfUI.gui.dropdowns.num_actionbar_buttons) - CreateConfig(nil, this, T["Right Actionbar (Right)"], C.bars.right, "formfactor", "dropdown", pfUI.gui.dropdowns.num_actionbar_buttons) - CreateConfig(nil, this, T["Vertical Actionbar (TwoRight)"], C.bars.tworight, "formfactor", "dropdown", pfUI.gui.dropdowns.num_actionbar_buttons) - CreateConfig(nil, this, T["Shapeshift Bar (BarShapeShift)"], C.bars.shapeshift, "formfactor", "dropdown", pfUI.gui.dropdowns.num_shapeshift_slots) - CreateConfig(nil, this, T["Pet Bar (BarPet)"], C.bars.pet, "formfactor", "dropdown", pfUI.gui.dropdowns.num_pet_action_slots) - this.setup = true - end - end) + if id ~= 11 and id ~= 12 then + CreateConfig(update["bars"], this, T["Buttons"], C.bars["bar"..id], "buttons", "dropdown", pfUI.gui.dropdowns.actionbarbuttons) - -- >> Autohide - pfUI.gui.tabs.actionbar.tabs.autohide = pfUI.gui.tabs.actionbar.tabs:CreateTabChild(T["Autohide"], true) - pfUI.gui.tabs.actionbar.tabs.autohide:SetScript("OnShow", function() - if not this.setup then - CreateConfig(nil, this, T["Seconds Until Action Bars Autohide"], C.bars, "hide_time") - CreateConfig(nil, this, T["Enable Autohide For BarActionMain"], C.bars, "hide_actionmain", "checkbox") - CreateConfig(nil, this, T["Enable Autohide For BarBottomLeft"], C.bars, "hide_bottomleft", "checkbox") - CreateConfig(nil, this, T["Enable Autohide For BarBottomRight"], C.bars, "hide_bottomright", "checkbox") - CreateConfig(nil, this, T["Enable Autohide For BarRight"], C.bars, "hide_right", "checkbox") - CreateConfig(nil, this, T["Enable Autohide For BarTwoRight"], C.bars, "hide_tworight", "checkbox") - CreateConfig(nil, this, T["Enable Autohide For BarShapeShift"], C.bars, "hide_shapeshift", "checkbox") - CreateConfig(nil, this, T["Enable Autohide For BarPet"], C.bars, "hide_pet", "checkbox") + if id ~= 1 then + CreateConfig(update["bars"], this, T["Pageable"], C.bars["bar"..id], "pageable", "checkbox") + end + end + + if id == 12 then + CreateConfig(update["bars"], this, T["Auto-Castable Action Indicator"], C.bars, "showcastable", "checkbox") + end + + CreateConfig(update["bars"], this, T["Icon Size"], C.bars["bar"..id], "icon_size") + CreateConfig(update["bars"], this, T["Layout"], C.bars["bar"..id], "formfactor", "dropdown", formfactors) + CreateConfig(update["bars"], this, T["Bar Background"], C.bars["bar"..id], "background", "checkbox") + CreateConfig(update["bars"], this, T["Show Hotkey Text"], C.bars["bar"..id], "showkeybind", "checkbox") + + if id ~= 11 and id ~= 12 then + CreateConfig(update["bars"], this, T["Show Macro Text"], C.bars["bar"..id], "showmacro", "checkbox") + CreateConfig(update["bars"], this, T["Show Item Count Text"], C.bars["bar"..id], "showcount", "checkbox") + elseif id ~= 11 then + CreateConfig(update["bars"], this, T["Show Empty Buttons"], C.bars["bar"..id], "showempty", "checkbox") + end + + CreateConfig(update["bars"], this, T["Enable Autohide"], C.bars["bar"..id], "autohide", "checkbox") + CreateConfig(update["bars"], this, T["Autohide Timeout"], C.bars["bar"..id], "hide_time") + end this.setup = true end end) @@ -1477,6 +1520,8 @@ pfUI:RegisterModule("gui", function () CreateConfig(nil, this, "SortBags", C.thirdparty.sortbags, "enable", "checkbox") CreateConfig(nil, this, "MrPlow", C.thirdparty.mrplow, "enable", "checkbox") CreateConfig(nil, this, "FlightMap", C.thirdparty.flightmap, "enable", "checkbox") + CreateConfig(nil, this, "TheoryCraft", C.thirdparty.theorycraft, "enable", "checkbox") + CreateConfig(nil, this, "SuperMacro", C.thirdparty.supermacro, "enable", "checkbox") CreateConfig(nil, this, "AtlasLoot", C.thirdparty.atlasloot, "enable", "checkbox") CreateConfig(nil, this, "MyRolePlay", C.thirdparty.myroleplay, "enable", "checkbox") CreateConfig(nil, this, "DruidManaBar", C.thirdparty.druidmana, "enable", "checkbox") diff --git a/modules/hoverbind.lua b/modules/hoverbind.lua index ab7ba6dd..176dedaf 100644 --- a/modules/hoverbind.lua +++ b/modules/hoverbind.lua @@ -1,14 +1,23 @@ pfUI:RegisterModule("hoverbind", function () local default_border = C.appearance.border.default local keymap = { - ["BonusActionButton"] = "ACTIONBUTTON", - ["MultiBarBottomLeftButton"] = "MULTIACTIONBAR1BUTTON", - ["MultiBarBottomRightButton"] = "MULTIACTIONBAR2BUTTON", - ["MultiBarRightButton"] = "MULTIACTIONBAR3BUTTON", - ["MultiBarLeftButton"] = "MULTIACTIONBAR4BUTTON", - ["ShapeshiftButton"] = "SHAPESHIFTBUTTON", - ["PetActionButton"] = "BONUSACTIONBUTTON", + -- buttons to binding association + ["pfActionBarMainButton"] = "ACTIONBUTTON", + ["pfActionBarTopButton"] = "MULTIACTIONBAR1BUTTON", + ["pfActionBarLeftButton"] = "MULTIACTIONBAR2BUTTON", + ["pfActionBarRightButton"] = "MULTIACTIONBAR3BUTTON", + ["pfActionBarVerticalButton"] = "MULTIACTIONBAR4BUTTON", + ["pfActionBarStancesButton"] = "SHAPESHIFTBUTTON", + ["pfActionBarPetButton"] = "BONUSACTIONBUTTON", + + -- special buttons + ["pfActionBarPagingButton"] = "PFPAGING", + ["pfActionBarSpecialButton"] = "PFSPECIAL", + ["pfActionBarStancePaging1Button"] = "PFSTANCEONE", + ["pfActionBarStancePaging2Button"] = "PFSTANCETWO", + ["pfActionBarStancePaging3Button"] = "PFSTANCETHREE", } + local modifiers = { ["ALT"] = "ALT-", ["CTRL"] = "CTRL-", @@ -54,7 +63,9 @@ pfUI:RegisterModule("hoverbind", function () local hovername = (frame and frame.GetName) and (frame:GetName()) or "" local binding = pfUI.hoverbind:GetBinding(hovername) if arg1 == "ESCAPE" and not binding then pfUI.hoverbind:Hide() return end - if (binding) then + if binding == "NOBIND" then + UIErrorsFrame:AddMessage(T["Keybinding failed due to client restrictions."], 1, .2, .2) + elseif binding then if arg1 == "ESCAPE" then local key = (GetBindingKey(binding)) if (key) then @@ -77,7 +88,9 @@ pfUI:RegisterModule("hoverbind", function () function pfUI.hoverbind:GetBinding(button_name) local found,_,buttontype,buttonindex = string.find(button_name,"^(%a+)(%d+)$") if found then - if keymap[buttontype] then + if keymap[buttontype] and keymap[buttontype] == "NOBIND" then + return "NOBIND" + elseif keymap[buttontype] then return string.format("%s%d",keymap[buttontype],buttonindex) elseif buttontype == "ActionButton" then return string.format("ACTIONBUTTON%d",buttonindex) diff --git a/modules/panel.lua b/modules/panel.lua index 34e475d6..ae6e2cd0 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -715,16 +715,16 @@ pfUI:RegisterModule("panel", function() pfUI.panel.autohide:RegisterEvent("PLAYER_ENTERING_WORLD") pfUI.panel.autohide:SetScript("OnEvent", function() if C.panel.hide_leftchat == "1" then - CreateAutohide(pfUI.panel.left) + EnableAutohide(pfUI.panel.left, 2) end if C.panel.hide_rightchat == "1" then - CreateAutohide(pfUI.panel.right) + EnableAutohide(pfUI.panel.right, 2) end if C.panel.hide_minimap == "1" then - CreateAutohide(pfUI.panel.minimap) + EnableAutohide(pfUI.panel.minimap, 2) end if C.panel.hide_microbar == "1" then - CreateAutohide(pfUI.panel.microbutton) + EnableAutohide(pfUI.panel.microbutton, 2) end end) end) diff --git a/modules/thirdparty.lua b/modules/thirdparty.lua index ef56dd37..5e9a07ff 100644 --- a/modules/thirdparty.lua +++ b/modules/thirdparty.lua @@ -666,6 +666,72 @@ pfUI:RegisterModule("thirdparty", function () FlightMapTimesText:SetFont(pfUI.font_default, 12, "OUTLINE") end) + HookAddonOrVariable("TheoryCraft_SetUpButton", function() + if C.thirdparty.theorycraft.enable == "0" then return end + + -- set pfUI bar font + if TheoryCraft_Settings then + TheoryCraft_Settings["FontPath"] = C.bars.font + end + + if not pfUI.bars then return end + + -- make theorycraft aware of pfUI bars + for i=1,10 do + for j=1,10 do + TheoryCraft_SetUpButton(pfUI.bars[i][j]:GetName(), "Normal") + end + end + end) + + HookAddonOrVariable("SM_GetActionSpell", function() + if C.thirdparty.supermacro.enable == "0" then return end + if not pfUI.bars then return end + + -- refresh super macro texture + local function SMRefresh() + local slot = this:GetID() + local text = GetActionText(slot) + + if text then + if _G.SM_ACTION_SPELL and _G.SM_ACTION_SPELL["regular"] and _G.SM_ACTION_SPELL["regular"][text] then + this.icon:SetTexture(_G.SM_ACTION_SPELL["regular"][text].texture) + end + end + end + + -- hook events to include SuperMacro refreshs + local ButtonEvent = pfUI.bars[1][1]:GetScript("OnEvent") + local function NewButtonEvent() + ButtonEvent() + SMRefresh() + end + + -- hook events to include SuperMacro refreshs + local ButtonEnter = pfUI.bars[1][1]:GetScript("OnEnter") + local function NewButtonEnter() + ButtonEnter() + SM_ActionButton_SetTooltip() + end + + -- reassign the new event handler + for i=1,10 do + for j=1,12 do + pfUI.bars[i][j]:SetScript("OnEvent", NewButtonEvent) + pfUI.bars[i][j]:SetScript("OnEnter", NewButtonEnter) + end + end + + -- trigger the event whenever SuperMacro got an update + hooksecurefunc("SM_UpdateActionSpell", function() + for i=1,10 do + for j=1,12 do + pfUI.bars[i][j].forceupdate = true + end + end + end) + end) + HookAddonOrVariable("AtlasLoot", function() if C.thirdparty.atlasloot.enable == "0" then return end diff --git a/pfUI.toc b/pfUI.toc index 7838173d..3ba49a31 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -2,7 +2,7 @@ ## Title: |cff33ffccpf|cffffffffUI ## Author: Shagu ## Notes: A complete user interface replacement. -## Version: 3.18 +## Version: 3.19 ## SavedVariables: pfUI_profiles, pfUI_addon_profiles, pfUI_cache ## SavedVariablesPerCharacter: pfUI_config, pfUI_init, pfUI_playerDB