From fea85fe9d3be410c12880d6640327de16ec66ac2 Mon Sep 17 00:00:00 2001 From: Talyrius Date: Sat, 19 Jun 2021 15:14:18 -0700 Subject: [PATCH] Initial commit for proposed keyring support changes. --- core/Constants.lua | 4 ++-- widgets/ContainerFrame.lua | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/core/Constants.lua b/core/Constants.lua index 3cd75747..e31d9e64 100644 --- a/core/Constants.lua +++ b/core/Constants.lua @@ -32,8 +32,8 @@ local NUM_BANKBAGSLOTS = _G.NUM_BANKBAGSLOTS local pairs = _G.pairs --GLOBALS> --- Keyring, backpack, and bags -local BAGS = { [KEYRING_CONTAINER] = KEYRING_CONTAINER, [BACKPACK_CONTAINER] = BACKPACK_CONTAINER } +-- Backpack and bags +local BAGS = { [BACKPACK_CONTAINER] = BACKPACK_CONTAINER } for i = 1, NUM_BAG_SLOTS do BAGS[i] = i end -- Bank and bank bags diff --git a/widgets/ContainerFrame.lua b/widgets/ContainerFrame.lua index a74b865e..ca023a37 100644 --- a/widgets/ContainerFrame.lua +++ b/widgets/ContainerFrame.lua @@ -49,6 +49,7 @@ local NUM_BAG_SLOTS = _G.NUM_BAG_SLOTS local pairs = _G.pairs local PlaySound = _G.PlaySound local select = _G.select +local SOUNDKIT = _G.SOUNDKIT local strjoin = _G.strjoin local strsplit = _G.strsplit local tinsert = _G.tinsert @@ -79,6 +80,17 @@ local LSM = LibStub('LibSharedMedia-3.0') -- Widget scripts -------------------------------------------------------------------------------- +local function KeyringButton_OnClick(button) + PlaySound(button:GetChecked() and SOUNDKIT.KEY_RING_OPEN or SOUNDKIT.KEY_RING_CLOSE) + if button:GetChecked() then + BAG_IDS.BAGS[KEYRING_CONTAINER] = KEYRING_CONTAINER + -- TODO: Initialize/setup hooks, callbacks, and etc. for the keyring "bag." + else + BAG_IDS.BAGS[KEYRING_CONTAINER] = nil + -- TODO: Undo the above. + end +end + local function BagSlotButton_OnClick(button) button.panel:SetShown(button:GetChecked()) end @@ -174,6 +186,22 @@ function containerProto:OnCreate(name, isBank, bagObject) addon.SetupTooltip(closeButton, L["Close"]) closeButton:SetFrameLevel(frameLevel) + if not self.isBank then + local keyringButton = CreateFrame("CheckButton", nil, self) + keyringButton:SetNormalTexture([[Interface\Buttons\UI-Button-KeyRing]]) + keyringButton:SetCheckedTexture([[Interface\Buttons\UI-Button-KeyRing-Highlight]]) + keyringButton:GetCheckedTexture():SetBlendMode("ADD") + keyringButton:SetScript('OnClick', KeyringButton_OnClick) + keyringButton:SetWidth(15) + keyringButton:SetHeight(30) + self.keyringButton = keyringButton + addon.SetupTooltip(keyringButton, { + L["Keyring"], + L["Click to toggle the keyring."] + }, "ANCHOR_BOTTOMLEFT", -8, 0) + headerLeftRegion:AddWidget(keyringButton, 60, 8) + end + local bagSlotButton = CreateFrame("CheckButton", nil, self) bagSlotButton:SetNormalTexture([[Interface\Buttons\Button-Backpack-Up]]) bagSlotButton:SetCheckedTexture([[Interface\Buttons\CheckButtonHilight]])