From 0ece85d9a8cc0b21a0b53e9bc2b56e065834dc6c Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 19 Mar 2025 17:05:55 +0100 Subject: [PATCH] reduced-actionbar-bags: add module to show bags --- ShaguTweaks-extras.toc | 1 + mods/reduced-actionbar-bags.lua | 86 +++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 mods/reduced-actionbar-bags.lua diff --git a/ShaguTweaks-extras.toc b/ShaguTweaks-extras.toc index afeca8b..6f20088 100644 --- a/ShaguTweaks-extras.toc +++ b/ShaguTweaks-extras.toc @@ -24,3 +24,4 @@ mods\chat-history.lua mods\macro-icons.lua mods\macro-tweaks.lua mods\worldmap-reveal.lua +mods\reduced-actionbar-bags.lua diff --git a/mods/reduced-actionbar-bags.lua b/mods/reduced-actionbar-bags.lua new file mode 100644 index 0000000..2cc2ed4 --- /dev/null +++ b/mods/reduced-actionbar-bags.lua @@ -0,0 +1,86 @@ +local _G = ShaguTweaks.GetGlobalEnv() +local T = ShaguTweaks.T + +local module = ShaguTweaks:register({ + title = T["Reduced Actionbar Bags"], + description = T["Shows bag and keyring buttons when using the reduced actionbar layout. Hold Ctrl+Shift to move the bag bar."], + expansions = { ["vanilla"] = true, ["tbc"] = nil }, + maintainer = "@shagu (GitHub)", + enabled = nil, +}) + +module.enable = function(self) + -- only run if reduced actionbar is enabled + if not ShaguTweaks_config[T["Reduced Actionbar Size"]] == 1 then return end + + local frames = { + KeyRingButton, CharacterBag3Slot, CharacterBag2Slot, CharacterBag1Slot, + CharacterBag0Slot, MainMenuBarBackpackButton, + } + + local bagframe = CreateFrame("Button", "ShaguTweaksReducedActionBarBags", UIParent) + bagframe:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -8, 8) + bagframe:SetWidth(225) + bagframe:SetHeight(50) + + bagframe:SetFrameStrata("MEDIUM") + bagframe:SetBackdrop({ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + tile = true, tileSize = 8, edgeSize = 16, + insets = { left = 3, right = 3, top = 3, bottom = 3 } + }) + + bagframe:SetBackdropBorderColor(.9,.8,.5,1) + bagframe:SetBackdropColor(.4,.4,.4,1) + + bagframe:SetClampedToScreen(true) + bagframe:SetMovable(true) + bagframe:EnableMouse(true) + bagframe:RegisterForDrag("LeftButton") + + bagframe:SetUserPlaced(true) + + bagframe:RegisterEvent("PLAYER_ENTERING_WORLD") + + bagframe:SetScript("OnDragStart", function() + if not IsShiftKeyDown() or not IsControlKeyDown() then return end + this:StartMoving() + end) + + bagframe:SetScript("OnDragStop", function() + this:StopMovingOrSizing() + end) + + bagframe:SetScript("OnUpdate", function() + if MouseIsOver(this) and IsShiftKeyDown() and IsControlKeyDown() then + if not this.mousedisabled then + -- disable mouse events on all frames + this.mousedisabled = true + for _, frame in pairs(frames) do + frame:EnableMouse(0) + end + end + else + if this.mousedisabled then + -- enable all mouse events again + this.mousedisabled = false + for _, frame in pairs(frames) do + frame:EnableMouse(1) + end + end + end + end) + + bagframe:SetScript("OnEvent", function() + ShaguTweaks.DarkenFrame(bagframe) + + for id, frame in pairs(frames) do + local anchor = frames[id-1] or bagframe + frame:SetPoint("LEFT", anchor, id == 1 and "LEFT" or "RIGHT", id == 1 and 5 or 2, 0) + frame:SetParent(bagframe) + frame.Show = frame:Show() + frame:Show() + end + end) +end