SHOW:
|
|
- or go back to the newest paste.
| 1 | local Core = LibStub("AceAddon-3.0"):GetAddon("BasicUI")
| |
| 2 | local Module = Core:NewModule("Actionbars", "AceEvent-3.0")
| |
| 3 | ||
| 4 | - | --------------- |
| 4 | + | local db, classColor |
| 5 | ||
| 6 | - | --------------- |
| 6 | + | ---------------- |
| 7 | -- Actionbars -- | |
| 8 | - | ------------------------------------------------------------------------ |
| 8 | + | ---------------- |
| 9 | - | -- Local functions |
| 9 | + | |
| 10 | function Module:OnInitialize() | |
| 11 | - | local function EnableHotKeys() |
| 11 | + | db = Core.db.profile |
| 12 | - | |
| 12 | + | |
| 13 | - | local db = Core.db.profile |
| 13 | + | local _, class = UnitClass("player")
|
| 14 | - | |
| 14 | + | classColor = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class] |
| 15 | - | if db.actionbars.showHotKeys ~= false then return end |
| 15 | + | |
| 16 | - | |
| 16 | + | |
| 17 | - | for i=1, 12 do |
| 17 | + | |
| 18 | - | _G["ActionButton"..i.."HotKey"]:SetAlpha(0) -- main bar |
| 18 | + | |
| 19 | - | _G["MultiBarBottomRightButton"..i.."HotKey"]:SetAlpha(0) -- bottom right bar |
| 19 | + | |
| 20 | - | _G["MultiBarBottomLeftButton"..i.."HotKey"]:SetAlpha(0) -- bottom left bar |
| 20 | + | |
| 21 | - | _G["MultiBarRightButton"..i.."HotKey"]:SetAlpha(0) -- right bar |
| 21 | + | |
| 22 | - | _G["MultiBarLeftButton"..i.."HotKey"]:SetAlpha(0) -- left bar |
| 22 | + | |
| 23 | if self.SetupHooks then | |
| 24 | self:SetupHooks() | |
| 25 | end | |
| 26 | - | local function EnableMacroNames() |
| 26 | + | |
| 27 | if enabled or not db.actionbars.enable then return end | |
| 28 | - | local db = Core.db.profile |
| 28 | + | |
| 29 | - | |
| 29 | + | |
| 30 | - | if db.actionbars.showMacronames ~= false then return end |
| 30 | + | local hotkeyAlpha = db.actionbars.showHotKeys and 1 or 0 |
| 31 | for i = 1, 12 do | |
| 32 | - | for i=1, 12 do |
| 32 | + | _G["ActionButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- main bar |
| 33 | - | _G["ActionButton"..i.."Name"]:SetAlpha(0) -- main bar |
| 33 | + | _G["MultiBarBottomRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom right bar |
| 34 | - | _G["MultiBarBottomRightButton"..i.."Name"]:SetAlpha(0) -- bottom right bar |
| 34 | + | _G["MultiBarBottomLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- bottom left bar |
| 35 | - | _G["MultiBarBottomLeftButton"..i.."Name"]:SetAlpha(0) -- bottom left bar |
| 35 | + | _G["MultiBarRightButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- right bar |
| 36 | - | _G["MultiBarRightButton"..i.."Name"]:SetAlpha(0) -- right bar |
| 36 | + | _G["MultiBarLeftButton"..i.."HotKey"]:SetAlpha(hotkeyAlpha) -- left bar |
| 37 | - | _G["MultiBarLeftButton"..i.."Name"]:SetAlpha(0) -- left bar |
| 37 | + | |
| 38 | ||
| 39 | local macroAlpha = db.actionbars.showMacronames and 1 or 0 | |
| 40 | for i = 1, 12 do | |
| 41 | - | ------------------------------------------------------------------------ |
| 41 | + | _G["ActionButton"..i.."Name"]:SetAlpha(macroAlpha) -- main bar |
| 42 | - | -- Module functions |
| 42 | + | _G["MultiBarBottomRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom right bar |
| 43 | _G["MultiBarBottomLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- bottom left bar | |
| 44 | _G["MultiBarRightButton"..i.."Name"]:SetAlpha(macroAlpha) -- right bar | |
| 45 | _G["MultiBarLeftButton"..i.."Name"]:SetAlpha(macroAlpha) -- left bar | |
| 46 | end | |
| 47 | end | |
| 48 | ||
| 49 | function Module:SetupHooks() | |
| 50 | - | local db = Core.db.profile |
| 50 | + | |
| 51 | -- By Aprikot - http://aprikot.wowinterface.com | |
| 52 | -- Based upon functions within nMainbar by Neal, and thek: Buttonskin by thek | |
| 53 | ||
| 54 | - | |
| 54 | + | local function AddRegionKeys(self) |
| 55 | - | EnableHotKeys() |
| 55 | + | local name = self:GetName() |
| 56 | - | EnableMacroNames() |
| 56 | + | self.__name = _G[name.."Name"] |
| 57 | - | |
| 57 | + | self.__count = _G[name.."Count"] |
| 58 | - | local ccolor = RAID_CLASS_COLORS[select(2, UnitClass("player"))]
|
| 58 | + | self.__hotkey = _G[name.."HotKey"] |
| 59 | self.__border = _G[name.."Border"] | |
| 60 | self.__flash = _G[name.."Flash"] | |
| 61 | - | hooksecurefunc('ActionButton_UpdateUsable', function(self)
|
| 61 | + | self.__normalTexture = _G[name.."NormalTexture"] |
| 62 | - | if (IsAddOnLoaded('RedRange') or IsAddOnLoaded('GreenRange') or IsAddOnLoaded('tullaRange') or IsAddOnLoaded('RangeColors')) then
|
| 62 | + | self.__normalTexture2 = _G[name.."NormalTexture2"] |
| 63 | - | return |
| 63 | + | self.__pushedTexture = self:GetPushedTexture() |
| 64 | - | end |
| 64 | + | self.__highlightTexture = self:GetHighlightTexture() |
| 65 | - | |
| 65 | + | self.__checkedTexture = self:GetCheckedTexture() |
| 66 | - | local isUsable, notEnoughMana = IsUsableAction(self.action) |
| 66 | + | return name |
| 67 | - | if (isUsable) then |
| 67 | + | |
| 68 | - | _G[self:GetName()..'Icon']:SetVertexColor(1, 1, 1) |
| 68 | + | |
| 69 | - | elseif (notEnoughMana) then |
| 69 | + | local function ColorButton(texture) |
| 70 | - | _G[self:GetName()..'Icon']:SetVertexColor(db.actionbars.color.OutOfMana.r, db.actionbars.color.OutOfMana.g, db.actionbars.color.OutOfMana.b) |
| 70 | + | if db.misc.classcolor then |
| 71 | texture:SetVertexColor(classColor.r * 1.2, classColor.g * 1.2, classColor.b * 1.2) | |
| 72 | - | _G[self:GetName()..'Icon']:SetVertexColor(db.actionbars.color.NotUsable.r, db.actionbars.color.NotUsable.g, db.actionbars.color.NotUsable.b) |
| 72 | + | |
| 73 | local color = db.actionbars.color | |
| 74 | texture:SetVertexColor(color.r, color.g, color.b) | |
| 75 | end | |
| 76 | end | |
| 77 | ||
| 78 | local extraActionButtons = setmetatable({}, { __index = function(t, self)
| |
| 79 | local name = AddRegionKeys(self) | |
| 80 | - | -- Functions |
| 80 | + | local v = not not strmatch(name, "ExtraActionButton") |
| 81 | t[f] = v | |
| 82 | - | if self:GetName():match("ExtraActionButton") then return end
|
| 82 | + | return v |
| 83 | - | local bu = _G[self:GetName()] |
| 83 | + | end }) |
| 84 | - | local ic = _G[self:GetName().."Icon"] |
| 84 | + | |
| 85 | - | local bo = _G[self:GetName().."NormalTexture"] |
| 85 | + | |
| 86 | - | bu:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
|
| 86 | + | if extraActionButtons[self] then return end |
| 87 | - | ic:SetTexCoord(.05, .95, .05, .95); |
| 87 | + | |
| 88 | - | ic:SetPoint("TOPLEFT", bu, 0, 0);
|
| 88 | + | self:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
|
| 89 | - | ic:SetPoint("BOTTOMRIGHT", bu, 0, 0);
|
| 89 | + | |
| 90 | - | bo:ClearAllPoints() |
| 90 | + | local icon = self.icon |
| 91 | - | bo:SetPoint("TOPLEFT", bu, -14, 14)
|
| 91 | + | icon:SetTexCoord(.05, .95, .05, .95) |
| 92 | - | bo:SetPoint("BOTTOMRIGHT", bu, 14, -14)
|
| 92 | + | icon:ClearAllPoints() |
| 93 | - | if db.misc.classcolor ~= true then |
| 93 | + | icon:SetPoint("TOPLEFT")
|
| 94 | - | bo:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b) |
| 94 | + | icon:SetPoint("BOTTOMRIGHT")
|
| 95 | ||
| 96 | - | bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2)) |
| 96 | + | local normalTexture = self.__normalTexture |
| 97 | - | end |
| 97 | + | normalTexture:ClearAllPoints() |
| 98 | - | end); |
| 98 | + | normalTexture:SetPoint("TOPLEFT", -14, 14)
|
| 99 | normalTexture:SetPoint("BOTTOMRIGHT", 14, -14)
| |
| 100 | ColorButton(normalTexture) | |
| 101 | - | if self:GetName():match("ExtraActionButton") then return end
|
| 101 | + | |
| 102 | - | if db.misc.classcolor ~= true then |
| 102 | + | |
| 103 | - | (_G[self:GetName().."NormalTexture"]):SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b) |
| 103 | + | |
| 104 | if extraActionButtons[self] then return end | |
| 105 | - | (_G[self:GetName().."NormalTexture"]):SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2)) |
| 105 | + | ColorButton(self.__normalTexture) |
| 106 | - | end |
| 106 | + | |
| 107 | - | end); |
| 107 | + | |
| 108 | hooksecurefunc("ActionButton_ShowGrid", function(self)
| |
| 109 | if extraActionButtons[self] then return end | |
| 110 | - | if self:GetName():match("ExtraActionButton") then return end
|
| 110 | + | ColorButton(self.__normalTexture) |
| 111 | - | if db.misc.classcolor ~= true then |
| 111 | + | |
| 112 | - | (_G[self:GetName().."NormalTexture"]):SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b) |
| 112 | + | |
| 113 | local petButtons = { "PetActionButton", "PossessButton", "ShapeshiftButton" }
| |
| 114 | - | (_G[self:GetName().."NormalTexture"]):SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2)) |
| 114 | + | |
| 115 | - | end |
| 115 | + | for i = 1, #petButtons do |
| 116 | - | end); |
| 116 | + | for j = 1, 12 do |
| 117 | local button = _G[petButtons[i]..j] | |
| 118 | button:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
| |
| 119 | - | for i, v in pairs({"PetActionButton", "ShapeshiftButton", "PossessButton"}) do
|
| 119 | + | |
| 120 | - | for i = 1, 12 do |
| 120 | + | AddRegionKeys(button) |
| 121 | - | local bu = _G[v..i] |
| 121 | + | |
| 122 | - | if bu then |
| 122 | + | local icon = button.icon |
| 123 | - | bu:SetNormalTexture("Interface\\BUTTONS\\UI-Quickslot2")
|
| 123 | + | icon:SetTexCoord(.05, .95, .05, .95) |
| 124 | - | local ic = _G[v..i.."Icon"]; |
| 124 | + | icon:ClearAllPoints() |
| 125 | - | ic:SetTexCoord(.05, .95, .05, .95); |
| 125 | + | icon:SetPoint("TOPLEFT", -1, 1)
|
| 126 | - | ic:SetPoint("TOPLEFT", bu, -1, 1);
|
| 126 | + | icon:SetPoint("BOTTOMRIGHT", 1, -1)
|
| 127 | - | ic:SetPoint("BOTTOMRIGHT", bu, 1, -1);
|
| 127 | + | |
| 128 | - | local bo = _G[v..i.."NormalTexture2"] or _G[v..i.."NormalTexture"] |
| 128 | + | local normalTexture = button.__normalTexture2 or button.__normalTexture |
| 129 | - | bo:ClearAllPoints() |
| 129 | + | normalTexture:ClearAllPoints() |
| 130 | - | bo:SetPoint("TOPLEFT", bu, -15, 15)
|
| 130 | + | normalTexture:SetPoint("TOPLEFT", -15, 15)
|
| 131 | - | bo:SetPoint("BOTTOMRIGHT", bu, 15, -15)
|
| 131 | + | normalTexture:SetPoint("BOTTOMRIGHT",15, -15)
|
| 132 | - | if db.misc.classcolor ~= true then |
| 132 | + | |
| 133 | - | bo:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b) |
| 133 | + | ColorButton(normalTexture) |
| 134 | - | else |
| 134 | + | |
| 135 | - | bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2)) |
| 135 | + | |
| 136 | - | end |
| 136 | + | |
| 137 | ||
| 138 | hooksecurefunc("AuraButton_Update", function(buttonName, index, filter)
| |
| 139 | if not db.actionbars.auraborder then return end | |
| 140 | - | end); |
| 140 | + | |
| 141 | local buffName = buttonName..index | |
| 142 | - | hooksecurefunc("AuraButton_Update", function(self, index)
|
| 142 | + | local self = _G[buffName] |
| 143 | - | if db.actionbars.auraborder then |
| 143 | + | if not self.__border then AddRegionKeys(self) end |
| 144 | - | local bu = _G[self..index] |
| 144 | + | |
| 145 | - | local ic = _G[self..index.."Icon"] |
| 145 | + | local icon = self.icon |
| 146 | - | local bo = _G[self..index.."Border"] |
| 146 | + | if icon then |
| 147 | - | if ic then |
| 147 | + | icon:SetTexCoord(.07, .93, .07, .93) |
| 148 | - | ic:SetTexCoord(.07, .93, .07, .93); |
| 148 | + | |
| 149 | ||
| 150 | - | if bo then |
| 150 | + | local border = self.__border |
| 151 | - | bo:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
|
| 151 | + | if not border then |
| 152 | - | bo:ClearAllPoints() |
| 152 | + | border = self:CreateTexture("$parentOverlay", "ARTWORK")
|
| 153 | - | bo:SetPoint("TOPLEFT", bu, -12, 12)
|
| 153 | + | self.__border = border |
| 154 | - | bo:SetPoint("BOTTOMRIGHT", bu, 12, -12)
|
| 154 | + | |
| 155 | - | bo:SetTexCoord(0, 1, 0, 1) |
| 155 | + | border:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
|
| 156 | - | if db.misc.classcolor ~= true then |
| 156 | + | border:ClearAllPoints() |
| 157 | - | bo:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b) |
| 157 | + | border:SetPoint("TOPLEFT", bu, -12, 12)
|
| 158 | - | else |
| 158 | + | border:SetPoint("BOTTOMRIGHT", bu, 12, -12)
|
| 159 | - | bo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2)) |
| 159 | + | border:SetTexCoord(0, 1, 0, 1) |
| 160 | - | end |
| 160 | + | ColorButton(border) |
| 161 | end) | |
| 162 | - | if bu and not bo then |
| 162 | + | |
| 163 | - | nbo = bu:CreateTexture("$parentOverlay", "ARTWORK")
|
| 163 | + | --------------------------------------------------------------------- |
| 164 | - | nbo:SetParent(bu) |
| 164 | + | |
| 165 | - | nbo:SetTexture("Interface\\BUTTONS\\UI-Quickslot2")
|
| 165 | + | local rangeAddons = {
|
| 166 | - | nbo:SetPoint("TOPLEFT", bu, -12, 12)
|
| 166 | + | "GreenRange", |
| 167 | - | nbo:SetPoint("BOTTOMRIGHT", bu, 12, -12)
|
| 167 | + | "RangeColors", |
| 168 | - | if db.misc.classcolor ~= true then |
| 168 | + | "RedRange", |
| 169 | - | nbo:SetVertexColor(db.actionbars.color.r, db.actionbars.color.g, db.actionbars.color.b) |
| 169 | + | "tullaRange", |
| 170 | - | else |
| 170 | + | } |
| 171 | - | nbo:SetVertexColor((ccolor.r * 1.2), (ccolor.g * 1.2), (ccolor.b * 1.2)) |
| 171 | + | for i = 1, #rangeAddons do |
| 172 | local _, _, _, enabled = GetAddOnInfo(rangeAddons[i]) | |
| 173 | if enabled then | |
| 174 | rangeAddons = nil | |
| 175 | - | end); |
| 175 | + | break |
| 176 | - | |
| 176 | + | |
| 177 | - | function ActionButton_OnUpdate(self, elapsed) |
| 177 | + | |
| 178 | - | if (IsAddOnLoaded('RedRange') or IsAddOnLoaded('GreenRange') or IsAddOnLoaded('tullaRange') or IsAddOnLoaded('RangeColors')) then
|
| 178 | + | |
| 179 | - | return |
| 179 | + | if rangeAddons then |
| 180 | - | end |
| 180 | + | hooksecurefunc("ActionButton_UpdateUsable", function(self)
|
| 181 | local isUsable, notEnoughMana = IsUsableAction(self.action) | |
| 182 | - | if (ActionButton_IsFlashing(self)) then |
| 182 | + | if isUsable then |
| 183 | - | local flashtime = self.flashtime |
| 183 | + | self.icon:SetVertexColor(1, 1, 1) |
| 184 | - | flashtime = flashtime - elapsed |
| 184 | + | elseif notEnoughMana then |
| 185 | local color = db.actionbars.color.OutOfMana | |
| 186 | - | if (flashtime <= 0) then |
| 186 | + | self.icon:SetVertexColor(color.r, color.g, color.b) |
| 187 | - | local overtime = - flashtime |
| 187 | + | else |
| 188 | - | if (overtime >= ATTACK_BUTTON_FLASH_TIME) then |
| 188 | + | local color = db.actionbars.color.NotUsable |
| 189 | - | overtime = 0 |
| 189 | + | self.icon:SetVertexColor(color.r, color.g, color.b) |
| 190 | end | |
| 191 | end) | |
| 192 | - | flashtime = ATTACK_BUTTON_FLASH_TIME - overtime |
| 192 | + | |
| 193 | hooksecurefunc("ActionButton_OnUpdate", function(self, elapsed)
| |
| 194 | - | local flashTexture = _G[self:GetName()..'Flash'] |
| 194 | + | local rangeTimer = self.rangeTimer2 or 0 |
| 195 | - | if (flashTexture:IsShown()) then |
| 195 | + | |
| 196 | - | flashTexture:Hide() |
| 196 | + | if rangeTimer <= 0 then |
| 197 | - | else |
| 197 | + | if IsActionInRange(self.action) == 0 then |
| 198 | - | flashTexture:Show() |
| 198 | + | local color = db.actionbars.color.OutOfRange |
| 199 | self.icon:SetVertexColor(color.r, color.g, color.b) | |
| 200 | end | |
| 201 | rangeTimer = TOOLTIP_UPDATE_TIME | |
| 202 | - | self.flashtime = flashtime |
| 202 | + | |
| 203 | self.rangeTimer2 = rangeTimer | |
| 204 | end) | |
| 205 | - | local rangeTimer = self.rangeTimer |
| 205 | + | |
| 206 | - | if (rangeTimer) then |
| 206 | + | |
| 207 | self.SetupHooks = nil | |
| 208 | - | if (rangeTimer <= 0.1) then |
| 208 | + |