mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
update Microbar
This commit is contained in:
@@ -4,10 +4,11 @@ local AB = E:GetModule("ActionBars");
|
|||||||
--Cache global variables
|
--Cache global variables
|
||||||
--Lua functions
|
--Lua functions
|
||||||
local _G = _G
|
local _G = _G
|
||||||
local getn = table.getn
|
local gsub, match = string.gsub, string.match
|
||||||
local mod = math.mod
|
|
||||||
--WoW API / Variables
|
--WoW API / Variables
|
||||||
local CreateFrame = CreateFrame
|
local CreateFrame = CreateFrame
|
||||||
|
local UIFrameFadeIn = UIFrameFadeIn
|
||||||
|
local UIFrameFadeOut = UIFrameFadeOut
|
||||||
|
|
||||||
local microBar = CreateFrame("Frame", "ElvUI_MicroBar", E.UIParent)
|
local microBar = CreateFrame("Frame", "ElvUI_MicroBar", E.UIParent)
|
||||||
microBar:SetFrameStrata("BACKGROUND")
|
microBar:SetFrameStrata("BACKGROUND")
|
||||||
@@ -23,15 +24,15 @@ local MICRO_BUTTONS = {
|
|||||||
"HelpMicroButton"
|
"HelpMicroButton"
|
||||||
}
|
}
|
||||||
|
|
||||||
local function Button_OnEnter()
|
local function onEnter()
|
||||||
if AB.db.microbar.mouseover then
|
if AB.db.microbar.mouseover then
|
||||||
UIFrameFadeIn(microBar, .2, microBar:GetAlpha(), AB.db.microbar.alpha)
|
UIFrameFadeIn(ElvUI_MicroBar, 0.2, ElvUI_MicroBar:GetAlpha(), AB.db.microbar.alpha)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Button_OnLeave()
|
local function onLeave()
|
||||||
if AB.db.microbar.mouseover then
|
if AB.db.microbar.mouseover then
|
||||||
UIFrameFadeOut(microBar, .2, microBar:GetAlpha(), 0)
|
UIFrameFadeOut(ElvUI_MicroBar, 0.2, ElvUI_MicroBar:GetAlpha(), 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -40,21 +41,19 @@ function AB:HandleMicroButton(button)
|
|||||||
local normal = button:GetNormalTexture()
|
local normal = button:GetNormalTexture()
|
||||||
local disabled = button:GetDisabledTexture()
|
local disabled = button:GetDisabledTexture()
|
||||||
|
|
||||||
button:SetParent(microBar)
|
|
||||||
button:Show()
|
|
||||||
button:SetAlpha(self.db.microbar.alpha)
|
|
||||||
|
|
||||||
E:Kill(button:GetHighlightTexture())
|
|
||||||
HookScript(button, "OnEnter", Button_OnEnter)
|
|
||||||
HookScript(button, "OnLeave", Button_OnLeave)
|
|
||||||
|
|
||||||
local f = CreateFrame("Frame", nil, button)
|
local f = CreateFrame("Frame", nil, button)
|
||||||
f:SetFrameLevel(1)
|
f:SetFrameLevel(button:GetFrameLevel() - 2)
|
||||||
E:Point(f, "BOTTOMLEFT", button, "BOTTOMLEFT", 2, 0)
|
|
||||||
E:Point(f, "TOPRIGHT", button, "TOPRIGHT", -2, -28)
|
|
||||||
E:SetTemplate(f, "Default", true)
|
E:SetTemplate(f, "Default", true)
|
||||||
|
E:SetOutside(f, button)
|
||||||
button.backdrop = f
|
button.backdrop = f
|
||||||
|
|
||||||
|
button:SetParent(ElvUI_MicroBar)
|
||||||
|
E:Kill(button:GetHighlightTexture())
|
||||||
|
HookScript(button, "OnEnter", onEnter)
|
||||||
|
HookScript(button, "OnLeave", onLeave)
|
||||||
|
button:SetHitRectInsets(0, 0, 0, 0)
|
||||||
|
button:Show()
|
||||||
|
|
||||||
pushed:SetTexCoord(0.17, 0.87, 0.5, 0.908)
|
pushed:SetTexCoord(0.17, 0.87, 0.5, 0.908)
|
||||||
E:SetInside(pushed, f)
|
E:SetInside(pushed, f)
|
||||||
|
|
||||||
@@ -68,50 +67,65 @@ function AB:HandleMicroButton(button)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function AB:UpdateMicroPositionDimensions()
|
function AB:UpdateMicroPositionDimensions()
|
||||||
if not microBar then return end
|
if not ElvUI_MicroBar then return end
|
||||||
|
|
||||||
local numRows = 1
|
local numRows = 1
|
||||||
local button, prevButton, lastColumnButton
|
local prevButton = ElvUI_MicroBar
|
||||||
for i = 1, getn(MICRO_BUTTONS) do
|
local offset = E:Scale(E.PixelMode and 1 or 3)
|
||||||
button = _G[MICRO_BUTTONS[i]]
|
local spacing = E:Scale(offset + self.db.microbar.buttonSpacing)
|
||||||
prevButton = _G[MICRO_BUTTONS[i-1]] or microBar
|
|
||||||
lastColumnButton = _G[MICRO_BUTTONS[i-self.db.microbar.buttonsPerRow]]
|
|
||||||
|
|
||||||
|
for i = 1, getn(MICRO_BUTTONS) do
|
||||||
|
local button = _G[MICRO_BUTTONS[i]]
|
||||||
|
local lastColumnButton = i - self.db.microbar.buttonsPerRow
|
||||||
|
lastColumnButton = _G[MICRO_BUTTONS[lastColumnButton]]
|
||||||
|
|
||||||
|
E:Size(button, self.db.microbar.buttonSize, self.db.microbar.buttonSize * 1.4)
|
||||||
button:ClearAllPoints()
|
button:ClearAllPoints()
|
||||||
|
|
||||||
if prevButton == microBar then
|
if prevButton == ElvUI_MicroBar then
|
||||||
E:Point(button, "TOPLEFT", prevButton, "TOPLEFT", -2 + E.Border, 28 - E.Border)
|
E:Point(button, "TOPLEFT", prevButton, "TOPLEFT", offset, -offset)
|
||||||
elseif mod((i - 1), self.db.microbar.buttonsPerRow) == 0 then
|
elseif mod((i - 1), self.db.microbar.buttonsPerRow) == 0 then
|
||||||
E:Point(button, "TOP", lastColumnButton, "BOTTOM", 0, 28 - self.db.microbar.yOffset)
|
E:Point(button, "TOP", lastColumnButton, "BOTTOM", 0, -spacing)
|
||||||
numRows = numRows + 1
|
numRows = numRows + 1
|
||||||
else
|
else
|
||||||
E:Point(button, "LEFT", prevButton, "RIGHT", - 4 + self.db.microbar.xOffset, 0)
|
E:Point(button, "LEFT", prevButton, "RIGHT", spacing, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
prevButton = button
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.db.microbar.mouseover then
|
if AB.db.microbar.mouseover and not MouseIsOver(ElvUI_MicroBar) then
|
||||||
microBar:SetAlpha(0)
|
ElvUI_MicroBar:SetAlpha(0)
|
||||||
else
|
else
|
||||||
microBar:SetAlpha(self.db.microbar.alpha)
|
ElvUI_MicroBar:SetAlpha(self.db.microbar.alpha)
|
||||||
end
|
end
|
||||||
|
|
||||||
E:Size(microBar, ((CharacterMicroButton:GetWidth() - 4) * self.db.microbar.buttonsPerRow) + (self.db.microbar.xOffset * (self.db.microbar.buttonsPerRow - 1)) + E.Border * 2, ((CharacterMicroButton:GetHeight() - 28) * numRows) + (self.db.microbar.yOffset * (numRows - 1)) + E.Border * 2)
|
AB.MicroWidth = (((_G["CharacterMicroButton"]:GetWidth() + spacing) * self.db.microbar.buttonsPerRow) - spacing) + (offset * 2)
|
||||||
|
AB.MicroHeight = (((_G["CharacterMicroButton"]:GetHeight() + spacing) * numRows) - spacing) + (offset * 2)
|
||||||
|
E:Size(ElvUI_MicroBar, AB.MicroWidth, AB.MicroHeight)
|
||||||
|
|
||||||
if self.db.microbar.enabled then
|
-- local visibility = self.db.microbar.visibility
|
||||||
microBar:Show()
|
-- if visibility and match(visibility, "[\n\r]") then
|
||||||
if microBar.mover then
|
-- visibility = gsub(visibility, "[\n\r]", "")
|
||||||
E:EnableMover(microBar.mover:GetName())
|
-- end
|
||||||
end
|
|
||||||
else
|
|
||||||
microBar:Hide()
|
if ElvUI_MicroBar.mover then
|
||||||
if microBar.mover then
|
if self.db.microbar.enabled then
|
||||||
E:DisableMover(microBar.mover:GetName())
|
ElvUI_MicroBar:Show()
|
||||||
|
E:EnableMover(ElvUI_MicroBar.mover:GetName())
|
||||||
|
else
|
||||||
|
ElvUI_MicroBar:Hide()
|
||||||
|
E:DisableMover(ElvUI_MicroBar.mover:GetName())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function AB:SetupMicroBar()
|
function AB:SetupMicroBar()
|
||||||
E:Point(microBar, "TOPLEFT", 4, -48)
|
E:Point(ElvUI_MicroBar, "TOPLEFT", E.UIParent, "TOPLEFT", 4, -48)
|
||||||
|
ElvUI_MicroBar:EnableMouse(true)
|
||||||
|
ElvUI_MicroBar:SetScript("OnEnter", onEnter)
|
||||||
|
ElvUI_MicroBar:SetScript("OnLeave", onLeave)
|
||||||
|
|
||||||
for i = 1, getn(MICRO_BUTTONS) do
|
for i = 1, getn(MICRO_BUTTONS) do
|
||||||
self:HandleMicroButton(_G[MICRO_BUTTONS[i]])
|
self:HandleMicroButton(_G[MICRO_BUTTONS[i]])
|
||||||
@@ -121,5 +135,7 @@ function AB:SetupMicroBar()
|
|||||||
|
|
||||||
self:UpdateMicroPositionDimensions()
|
self:UpdateMicroPositionDimensions()
|
||||||
|
|
||||||
E:CreateMover(microBar, "MicrobarMover", L["Micro Bar"], nil, nil, nil, "ALL,ACTIONBARS")
|
E:Kill(MainMenuBarPerformanceBarFrame)
|
||||||
|
|
||||||
|
E:CreateMover(ElvUI_MicroBar, 'MicrobarMover', L["Micro Bar"], nil, nil, nil, "ALL,ACTIONBARS", nil, "actionbar,microbar")
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user