mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
add MicroBar
This commit is contained in:
@@ -825,7 +825,7 @@ function E:UpdateAll(ignoreInstall)
|
|||||||
local AB = self:GetModule("ActionBars")
|
local AB = self:GetModule("ActionBars")
|
||||||
AB.db = self.db.actionbar
|
AB.db = self.db.actionbar
|
||||||
AB:UpdateButtonSettings()
|
AB:UpdateButtonSettings()
|
||||||
-- AB:UpdateMicroPositionDimensions()
|
AB:UpdateMicroPositionDimensions()
|
||||||
|
|
||||||
local bags = E:GetModule("Bags")
|
local bags = E:GetModule("Bags")
|
||||||
bags.db = self.db.bags
|
bags.db = self.db.bags
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ local LSM = LibStub("LibSharedMedia-3.0");
|
|||||||
|
|
||||||
--Cache global variables
|
--Cache global variables
|
||||||
--Lua functions
|
--Lua functions
|
||||||
local _G = getfenv()
|
local _G = _G
|
||||||
local gsub, split = string.gsub, string.split
|
local gsub, split = string.gsub, string.split
|
||||||
local ceil = math.ceil
|
local ceil = math.ceil
|
||||||
local mod = math.mod
|
local mod = math.mod
|
||||||
@@ -422,7 +422,7 @@ function AB:Initialize()
|
|||||||
--self:LoadKeyBinder()
|
--self:LoadKeyBinder()
|
||||||
|
|
||||||
self:SecureHook("ActionButton_Update")
|
self:SecureHook("ActionButton_Update")
|
||||||
--self:SecureHook("PetActionBar_Update", "UpdatePet")
|
-- self:SecureHook("PetActionBar_Update", "UpdatePet")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function InitializeCallback()
|
local function InitializeCallback()
|
||||||
|
|||||||
@@ -3,12 +3,15 @@ local AB = E:GetModule("ActionBars");
|
|||||||
|
|
||||||
--Cache global variables
|
--Cache global variables
|
||||||
--Lua functions
|
--Lua functions
|
||||||
local _G = getfenv()
|
local _G = _G
|
||||||
local getn = table.getn
|
local getn = table.getn
|
||||||
local mod = math.mod
|
local mod = math.mod
|
||||||
--WoW API / Variables
|
--WoW API / Variables
|
||||||
local CreateFrame = CreateFrame
|
local CreateFrame = CreateFrame
|
||||||
|
|
||||||
|
local microBar = CreateFrame("Frame", "microBar", E.UIParent)
|
||||||
|
microBar:SetFrameStrata("BACKGROUND")
|
||||||
|
|
||||||
local MICRO_BUTTONS = {
|
local MICRO_BUTTONS = {
|
||||||
"CharacterMicroButton",
|
"CharacterMicroButton",
|
||||||
"SpellbookMicroButton",
|
"SpellbookMicroButton",
|
||||||
@@ -22,13 +25,13 @@ local MICRO_BUTTONS = {
|
|||||||
|
|
||||||
local function Button_OnEnter()
|
local function Button_OnEnter()
|
||||||
if AB.db.microbar.mouseover then
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
local function Button_OnLeave()
|
local function Button_OnLeave()
|
||||||
if AB.db.microbar.mouseover then
|
if AB.db.microbar.mouseover then
|
||||||
UIFrameFadeOut(ElvUI_MicroBar, .2, ElvUI_MicroBar:GetAlpha(), 0)
|
UIFrameFadeOut(microBar, .2, microBar:GetAlpha(), 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -37,7 +40,9 @@ function AB:HandleMicroButton(button)
|
|||||||
local normal = button:GetNormalTexture()
|
local normal = button:GetNormalTexture()
|
||||||
local disabled = button:GetDisabledTexture()
|
local disabled = button:GetDisabledTexture()
|
||||||
|
|
||||||
--button:SetParent(ElvUI_MicroBar)
|
button:SetParent(microBar)
|
||||||
|
button:Show()
|
||||||
|
button:SetAlpha(self.db.microbar.alpha)
|
||||||
|
|
||||||
E:Kill(button:GetHighlightTexture())
|
E:Kill(button:GetHighlightTexture())
|
||||||
HookScript(button, "OnEnter", Button_OnEnter)
|
HookScript(button, "OnEnter", Button_OnEnter)
|
||||||
@@ -45,7 +50,6 @@ function AB:HandleMicroButton(button)
|
|||||||
|
|
||||||
local f = CreateFrame("Frame", nil, button)
|
local f = CreateFrame("Frame", nil, button)
|
||||||
f:SetFrameLevel(1)
|
f:SetFrameLevel(1)
|
||||||
f:SetFrameStrata("BACKGROUND")
|
|
||||||
f:SetPoint("BOTTOMLEFT", button, "BOTTOMLEFT", 2, 0)
|
f:SetPoint("BOTTOMLEFT", button, "BOTTOMLEFT", 2, 0)
|
||||||
f:SetPoint("TOPRIGHT", button, "TOPRIGHT", -2, -28)
|
f:SetPoint("TOPRIGHT", button, "TOPRIGHT", -2, -28)
|
||||||
E:SetTemplate(f, "Default", true)
|
E:SetTemplate(f, "Default", true)
|
||||||
@@ -63,28 +67,19 @@ function AB:HandleMicroButton(button)
|
|||||||
end
|
end
|
||||||
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()
|
function AB:UpdateMicroPositionDimensions()
|
||||||
if not ElvUI_MicroBar then return; end
|
if not microBar then return end
|
||||||
|
|
||||||
local numRows = 1
|
local numRows = 1
|
||||||
|
local button, prevButton, lastColumnButton
|
||||||
for i = 1, getn(MICRO_BUTTONS) do
|
for i = 1, getn(MICRO_BUTTONS) do
|
||||||
local button = _G[MICRO_BUTTONS[i]]
|
button = _G[MICRO_BUTTONS[i]]
|
||||||
local prevButton = _G[MICRO_BUTTONS[i-1]] or ElvUI_MicroBar
|
prevButton = _G[MICRO_BUTTONS[i-1]] or microBar
|
||||||
local lastColumnButton = _G[MICRO_BUTTONS[i-self.db.microbar.buttonsPerRow]]
|
lastColumnButton = _G[MICRO_BUTTONS[i-self.db.microbar.buttonsPerRow]]
|
||||||
|
|
||||||
button:ClearAllPoints()
|
button:ClearAllPoints()
|
||||||
|
|
||||||
if prevButton == ElvUI_MicroBar then
|
if prevButton == microBar then
|
||||||
button:SetPoint("TOPLEFT", prevButton, "TOPLEFT", -2 + E.Border, 28 - E.Border)
|
button:SetPoint("TOPLEFT", prevButton, "TOPLEFT", -2 + E.Border, 28 - E.Border)
|
||||||
elseif mod((i - 1), self.db.microbar.buttonsPerRow) == 0 then
|
elseif mod((i - 1), self.db.microbar.buttonsPerRow) == 0 then
|
||||||
button:SetPoint("TOP", lastColumnButton, "BOTTOM", 0, 28 - self.db.microbar.yOffset)
|
button:SetPoint("TOP", lastColumnButton, "BOTTOM", 0, 28 - self.db.microbar.yOffset)
|
||||||
@@ -94,41 +89,38 @@ function AB:UpdateMicroPositionDimensions()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if AB.db.microbar.mouseover then
|
if self.db.microbar.mouseover then
|
||||||
ElvUI_MicroBar:SetAlpha(0)
|
microBar:SetAlpha(0)
|
||||||
else
|
else
|
||||||
ElvUI_MicroBar:SetAlpha(self.db.microbar.alpha)
|
microBar:SetAlpha(self.db.microbar.alpha)
|
||||||
end
|
end
|
||||||
|
|
||||||
AB.MicroWidth = ((_G["CharacterMicroButton"]:GetWidth() - 4) * self.db.microbar.buttonsPerRow) + (self.db.microbar.xOffset * (self.db.microbar.buttonsPerRow - 1)) + E.Border * 2
|
microBar:SetWidth(((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
|
microBar:SetHeight(((CharacterMicroButton:GetHeight() - 28) * numRows) + (self.db.microbar.yOffset * (numRows - 1)) + E.Border * 2)
|
||||||
ElvUI_MicroBar:SetWidth(AB.MicroWidth)
|
|
||||||
ElvUI_MicroBar:SetHeight(AB.MicroHeight)
|
|
||||||
|
|
||||||
if self.db.microbar.enabled then
|
if self.db.microbar.enabled then
|
||||||
ElvUI_MicroBar:Show()
|
microBar:Show()
|
||||||
if ElvUI_MicroBar.mover then
|
if microBar.mover then
|
||||||
E:EnableMover(ElvUI_MicroBar.mover:GetName())
|
E:EnableMover(microBar.mover:GetName())
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ElvUI_MicroBar:Hide()
|
microBar:Hide()
|
||||||
if ElvUI_MicroBar.mover then
|
if microBar.mover then
|
||||||
E:DisableMover(ElvUI_MicroBar.mover:GetName())
|
E:DisableMover(microBar.mover:GetName())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function AB:SetupMicroBar()
|
function AB:SetupMicroBar()
|
||||||
local microBar = CreateFrame("Frame", "ElvUI_MicroBar", E.UIParent)
|
microBar:SetPoint("TOPLEFT", 4, -48)
|
||||||
microBar:SetPoint("TOPLEFT", E.UIParent, "TOPLEFT", 4, -48)
|
|
||||||
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]])
|
||||||
end
|
end
|
||||||
|
|
||||||
E:SetInside(MicroButtonPortrait, CharacterMicroButton.backdrop)
|
E:SetInside(MicroButtonPortrait, CharacterMicroButton.backdrop)
|
||||||
|
|
||||||
self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateMicroButtonsParent")
|
|
||||||
|
|
||||||
self:UpdateMicroPositionDimensions()
|
self:UpdateMicroPositionDimensions()
|
||||||
|
|
||||||
E:CreateMover(microBar, "MicrobarMover", L["Micro Bar"], nil, nil, nil, "ALL,ACTIONBARS")
|
E:CreateMover(microBar, "MicrobarMover", L["Micro Bar"], nil, nil, nil, "ALL,ACTIONBARS")
|
||||||
end
|
end
|
||||||
@@ -203,6 +203,77 @@ local function BuildABConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
group["microbar"] = {
|
||||||
|
order = 4,
|
||||||
|
type = "group",
|
||||||
|
name = L["Micro Bar"],
|
||||||
|
get = function(info) return E.db.actionbar.microbar[ info[getn(info)] ] end,
|
||||||
|
set = function(info, value) E.db.actionbar.microbar[ info[getn(info)] ] = value AB:UpdateMicroPositionDimensions() end,
|
||||||
|
disabled = function() return not E.private.actionbar.enable end,
|
||||||
|
args = {
|
||||||
|
info = {
|
||||||
|
order = 1,
|
||||||
|
type = "header",
|
||||||
|
name = L["Micro Bar"]
|
||||||
|
},
|
||||||
|
enabled = {
|
||||||
|
order = 2,
|
||||||
|
type = "toggle",
|
||||||
|
name = L["Enable"]
|
||||||
|
},
|
||||||
|
restorePosition = {
|
||||||
|
order = 3,
|
||||||
|
type = "execute",
|
||||||
|
name = L["Restore Bar"],
|
||||||
|
desc = L["Restore the actionbars default settings"],
|
||||||
|
func = function() E:CopyTable(E.db.actionbar["microbar"], P.actionbar["microbar"]) E:ResetMovers(L["Micro Bar"]) AB:UpdateMicroPositionDimensions() end,
|
||||||
|
disabled = function() return not E.db.actionbar.microbar.enabled end
|
||||||
|
},
|
||||||
|
spacer = {
|
||||||
|
order = 4,
|
||||||
|
type = "description",
|
||||||
|
name = " "
|
||||||
|
},
|
||||||
|
buttonsPerRow = {
|
||||||
|
order = 5,
|
||||||
|
type = "range",
|
||||||
|
name = L["Buttons Per Row"],
|
||||||
|
desc = L["The amount of buttons to display per row."],
|
||||||
|
min = 1, max = 8, step = 1,
|
||||||
|
disabled = function() return not E.db.actionbar.microbar.enabled end
|
||||||
|
},
|
||||||
|
xOffset = {
|
||||||
|
order = 6,
|
||||||
|
type = "range",
|
||||||
|
name = L["xOffset"],
|
||||||
|
min = -1, max = 10, step = 1,
|
||||||
|
disabled = function() return not E.db.actionbar.microbar.enabled end
|
||||||
|
},
|
||||||
|
yOffset = {
|
||||||
|
order = 7,
|
||||||
|
type = "range",
|
||||||
|
name = L["yOffset"],
|
||||||
|
min = -1, max = 10, step = 1,
|
||||||
|
disabled = function() return not E.db.actionbar.microbar.enabled end
|
||||||
|
},
|
||||||
|
alpha = {
|
||||||
|
order = 8,
|
||||||
|
type = "range",
|
||||||
|
isPercent = true,
|
||||||
|
name = L["Alpha"],
|
||||||
|
desc = L["Change the alpha level of the frame."],
|
||||||
|
min = 0, max = 1, step = 0.1,
|
||||||
|
disabled = function() return not E.db.actionbar.microbar.enabled end
|
||||||
|
},
|
||||||
|
mouseover = {
|
||||||
|
order = 9,
|
||||||
|
type = "toggle",
|
||||||
|
name = L["Mouse Over"],
|
||||||
|
desc = L["The frame is not shown unless you mouse over the frame."],
|
||||||
|
disabled = function() return not E.db.actionbar.microbar.enabled end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function BuildBarConfig(i)
|
local function BuildBarConfig(i)
|
||||||
@@ -418,7 +489,7 @@ E.Options.args.actionbar = {
|
|||||||
order = 9,
|
order = 9,
|
||||||
type = "execute",
|
type = "execute",
|
||||||
name = L["Micro Bar"],
|
name = L["Micro Bar"],
|
||||||
--buttonElvUI = true,
|
-- buttonElvUI = true,
|
||||||
func = function() ACD:SelectGroup("ElvUI", "actionbar", "microbar") end,
|
func = function() ACD:SelectGroup("ElvUI", "actionbar", "microbar") end,
|
||||||
disabled = function() return not E.private.actionbar.enable end
|
disabled = function() return not E.private.actionbar.enable end
|
||||||
},
|
},
|
||||||
@@ -426,7 +497,7 @@ E.Options.args.actionbar = {
|
|||||||
order = 10,
|
order = 10,
|
||||||
type = "execute",
|
type = "execute",
|
||||||
name = L["Bar "]..1,
|
name = L["Bar "]..1,
|
||||||
--buttonElvUI = true,
|
-- buttonElvUI = true,
|
||||||
func = function() ACD:SelectGroup("ElvUI", "actionbar", "bar1") end,
|
func = function() ACD:SelectGroup("ElvUI", "actionbar", "bar1") end,
|
||||||
disabled = function() return not E.private.actionbar.enable end
|
disabled = function() return not E.private.actionbar.enable end
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user