mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 16:34:45 +00:00
add MicroBar
This commit is contained in:
@@ -4,7 +4,7 @@ local LSM = LibStub("LibSharedMedia-3.0");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local _G = getfenv()
|
||||
local _G = _G
|
||||
local gsub, split = string.gsub, string.split
|
||||
local ceil = math.ceil
|
||||
local mod = math.mod
|
||||
@@ -422,7 +422,7 @@ function AB:Initialize()
|
||||
--self:LoadKeyBinder()
|
||||
|
||||
self:SecureHook("ActionButton_Update")
|
||||
--self:SecureHook("PetActionBar_Update", "UpdatePet")
|
||||
-- self:SecureHook("PetActionBar_Update", "UpdatePet")
|
||||
end
|
||||
|
||||
local function InitializeCallback()
|
||||
|
||||
@@ -3,12 +3,15 @@ local AB = E:GetModule("ActionBars");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local _G = getfenv()
|
||||
local _G = _G
|
||||
local getn = table.getn
|
||||
local mod = math.mod
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
|
||||
local microBar = CreateFrame("Frame", "microBar", E.UIParent)
|
||||
microBar:SetFrameStrata("BACKGROUND")
|
||||
|
||||
local MICRO_BUTTONS = {
|
||||
"CharacterMicroButton",
|
||||
"SpellbookMicroButton",
|
||||
@@ -22,13 +25,13 @@ local MICRO_BUTTONS = {
|
||||
|
||||
local function Button_OnEnter()
|
||||
if AB.db.microbar.mouseover then
|
||||
UIFrameFadeIn(ElvUI_MicroBar, .2, ElvUI_MicroBar:GetAlpha(), AB.db.microbar.alpha)
|
||||
UIFrameFadeIn(microBar, .2, microBar:GetAlpha(), AB.db.microbar.alpha)
|
||||
end
|
||||
end
|
||||
|
||||
local function Button_OnLeave()
|
||||
if AB.db.microbar.mouseover then
|
||||
UIFrameFadeOut(ElvUI_MicroBar, .2, ElvUI_MicroBar:GetAlpha(), 0)
|
||||
UIFrameFadeOut(microBar, .2, microBar:GetAlpha(), 0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +40,9 @@ function AB:HandleMicroButton(button)
|
||||
local normal = button:GetNormalTexture()
|
||||
local disabled = button:GetDisabledTexture()
|
||||
|
||||
--button:SetParent(ElvUI_MicroBar)
|
||||
button:SetParent(microBar)
|
||||
button:Show()
|
||||
button:SetAlpha(self.db.microbar.alpha)
|
||||
|
||||
E:Kill(button:GetHighlightTexture())
|
||||
HookScript(button, "OnEnter", Button_OnEnter)
|
||||
@@ -45,7 +50,6 @@ function AB:HandleMicroButton(button)
|
||||
|
||||
local f = CreateFrame("Frame", nil, button)
|
||||
f:SetFrameLevel(1)
|
||||
f:SetFrameStrata("BACKGROUND")
|
||||
f:SetPoint("BOTTOMLEFT", button, "BOTTOMLEFT", 2, 0)
|
||||
f:SetPoint("TOPRIGHT", button, "TOPRIGHT", -2, -28)
|
||||
E:SetTemplate(f, "Default", true)
|
||||
@@ -63,28 +67,19 @@ function AB:HandleMicroButton(button)
|
||||
end
|
||||
end
|
||||
|
||||
function AB:UpdateMicroButtonsParent()
|
||||
if CharacterMicroButton:GetParent() == ElvUI_MicroBar then return end
|
||||
|
||||
for i = 1, getn(MICRO_BUTTONS) do
|
||||
-- _G[MICRO_BUTTONS[i]]:SetParent(ElvUI_MicroBar)
|
||||
end
|
||||
|
||||
AB:UpdateMicroPositionDimensions()
|
||||
end
|
||||
|
||||
function AB:UpdateMicroPositionDimensions()
|
||||
if not ElvUI_MicroBar then return; end
|
||||
if not microBar then return end
|
||||
|
||||
local numRows = 1
|
||||
local button, prevButton, lastColumnButton
|
||||
for i = 1, getn(MICRO_BUTTONS) do
|
||||
local button = _G[MICRO_BUTTONS[i]]
|
||||
local prevButton = _G[MICRO_BUTTONS[i-1]] or ElvUI_MicroBar
|
||||
local lastColumnButton = _G[MICRO_BUTTONS[i-self.db.microbar.buttonsPerRow]]
|
||||
button = _G[MICRO_BUTTONS[i]]
|
||||
prevButton = _G[MICRO_BUTTONS[i-1]] or microBar
|
||||
lastColumnButton = _G[MICRO_BUTTONS[i-self.db.microbar.buttonsPerRow]]
|
||||
|
||||
button:ClearAllPoints()
|
||||
|
||||
if prevButton == ElvUI_MicroBar then
|
||||
if prevButton == microBar then
|
||||
button:SetPoint("TOPLEFT", prevButton, "TOPLEFT", -2 + E.Border, 28 - E.Border)
|
||||
elseif mod((i - 1), self.db.microbar.buttonsPerRow) == 0 then
|
||||
button:SetPoint("TOP", lastColumnButton, "BOTTOM", 0, 28 - self.db.microbar.yOffset)
|
||||
@@ -94,41 +89,38 @@ function AB:UpdateMicroPositionDimensions()
|
||||
end
|
||||
end
|
||||
|
||||
if AB.db.microbar.mouseover then
|
||||
ElvUI_MicroBar:SetAlpha(0)
|
||||
if self.db.microbar.mouseover then
|
||||
microBar:SetAlpha(0)
|
||||
else
|
||||
ElvUI_MicroBar:SetAlpha(self.db.microbar.alpha)
|
||||
microBar:SetAlpha(self.db.microbar.alpha)
|
||||
end
|
||||
|
||||
AB.MicroWidth = ((_G["CharacterMicroButton"]:GetWidth() - 4) * self.db.microbar.buttonsPerRow) + (self.db.microbar.xOffset * (self.db.microbar.buttonsPerRow - 1)) + E.Border * 2
|
||||
AB.MicroHeight = ((_G["CharacterMicroButton"]:GetHeight() - 28) * numRows) + (self.db.microbar.yOffset * (numRows - 1)) + E.Border * 2
|
||||
ElvUI_MicroBar:SetWidth(AB.MicroWidth)
|
||||
ElvUI_MicroBar:SetHeight(AB.MicroHeight)
|
||||
microBar:SetWidth(((CharacterMicroButton:GetWidth() - 4) * self.db.microbar.buttonsPerRow) + (self.db.microbar.xOffset * (self.db.microbar.buttonsPerRow - 1)) + E.Border * 2)
|
||||
microBar:SetHeight(((CharacterMicroButton:GetHeight() - 28) * numRows) + (self.db.microbar.yOffset * (numRows - 1)) + E.Border * 2)
|
||||
|
||||
if self.db.microbar.enabled then
|
||||
ElvUI_MicroBar:Show()
|
||||
if ElvUI_MicroBar.mover then
|
||||
E:EnableMover(ElvUI_MicroBar.mover:GetName())
|
||||
microBar:Show()
|
||||
if microBar.mover then
|
||||
E:EnableMover(microBar.mover:GetName())
|
||||
end
|
||||
else
|
||||
ElvUI_MicroBar:Hide()
|
||||
if ElvUI_MicroBar.mover then
|
||||
E:DisableMover(ElvUI_MicroBar.mover:GetName())
|
||||
microBar:Hide()
|
||||
if microBar.mover then
|
||||
E:DisableMover(microBar.mover:GetName())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function AB:SetupMicroBar()
|
||||
local microBar = CreateFrame("Frame", "ElvUI_MicroBar", E.UIParent)
|
||||
microBar:SetPoint("TOPLEFT", E.UIParent, "TOPLEFT", 4, -48)
|
||||
microBar:SetPoint("TOPLEFT", 4, -48)
|
||||
|
||||
for i = 1, getn(MICRO_BUTTONS) do
|
||||
self:HandleMicroButton(_G[MICRO_BUTTONS[i]])
|
||||
end
|
||||
|
||||
E:SetInside(MicroButtonPortrait, CharacterMicroButton.backdrop)
|
||||
|
||||
self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateMicroButtonsParent")
|
||||
|
||||
self:UpdateMicroPositionDimensions()
|
||||
|
||||
E:CreateMover(microBar, "MicrobarMover", L["Micro Bar"], nil, nil, nil, "ALL,ACTIONBARS")
|
||||
end
|
||||
Reference in New Issue
Block a user