Skip to content

Commit

Permalink
Masque Integration Update (#221)
Browse files Browse the repository at this point in the history
* Masque integration is now evented instead of in-line.

* Item frame resizing now resizes all properties manually.
  • Loading branch information
Cidan authored Feb 24, 2024
1 parent 279f172 commit 511e722
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 100 deletions.
3 changes: 1 addition & 2 deletions BetterBags.toc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ core\constants.lua
core\database.lua
core\hooks.lua

theme\masque.lua

data\equipmentsets.lua
data\items.lua
data\categories.lua
Expand Down Expand Up @@ -82,5 +80,6 @@ config\customcat.lua

integrations\consoleport.lua
integrations\pawn.lua
integrations\masque.lua

core\init.lua
3 changes: 1 addition & 2 deletions BetterBags_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ core\classic\constants.lua
core\database.lua
core\hooks.lua

theme\masque.lua

data\equipmentsets.lua
data\items.lua
data\categories.lua
Expand Down Expand Up @@ -92,6 +90,7 @@ config\customcat.lua

integrations\consoleport.lua
integrations\pawn.lua
integrations\masque.lua

core\init.lua
core\classic\init.lua
3 changes: 1 addition & 2 deletions BetterBags_Wrath.toc
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ core\classic\constants.lua
core\database.lua
core\hooks.lua

theme\masque.lua

data\equipmentsets.lua
data\items.lua
data\categories.lua
Expand Down Expand Up @@ -91,6 +89,7 @@ config\customcat.lua

integrations\consoleport.lua
integrations\pawn.lua
integrations\masque.lua

core\init.lua
core\classic\init.lua
18 changes: 4 additions & 14 deletions frames/bagbutton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ local addon = LibStub('AceAddon-3.0'):GetAddon(addonName)
---@class Constants: AceModule
local const = addon:GetModule('Constants')

---@class MasqueTheme: AceModule
local masque = addon:GetModule('Masque')
---@class Events: AceModule
local events = addon:GetModule('Events')

---@class Localization: AceModule
local L = addon:GetModule('Localization')
Expand Down Expand Up @@ -84,10 +84,11 @@ function BagButtonFrame.bagButtonProto:SetBag(bag)
SetItemButtonTexture(self.frame, icon)
SetItemButtonQuality(self.frame, GetInventoryItemQuality("player", self.invID))
SetItemButtonCount(self.frame, 1)
events:SendMessage('bagbutton/Updated', self)
end

function BagButtonFrame.bagButtonProto:ClearBag()
masque:RemoveButtonFromGroup(self.masqueGroup, self.frame)
events:SendMessage('bagbutton/Clearing', self)
self.masqueGroup = nil
self.invID = nil
self.bag = nil
Expand All @@ -100,17 +101,6 @@ function BagButtonFrame.bagButtonProto:ClearBag()
SetItemButtonQuality(self.frame, nil)
end

---@param kind BagKind
function BagButtonFrame.bagButtonProto:AddToMasqueGroup(kind)
if kind == const.BAG_KIND.BANK then
self.masqueGroup = "Bank"
masque:AddButtonToGroup(self.masqueGroup, self.frame)
else
self.masqueGroup = "Backpack"
masque:AddButtonToGroup(self.masqueGroup, self.frame)
end
end

function BagButtonFrame.bagButtonProto:OnEnter()
if self.empty and self.kind == const.BAG_KIND.BANK and self.canBuy then
GameTooltip:SetOwner(self.frame, "ANCHOR_LEFT")
Expand Down
1 change: 0 additions & 1 deletion frames/bagslots.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ function BagSlots:CreatePanel(kind)
for i, bag in pairs(bags) do
local iframe = bagButton:Create()
iframe:SetBag(bag)
iframe:AddToMasqueGroup(kind)
b.content:AddCell(tostring(i), iframe)
end

Expand Down
1 change: 0 additions & 1 deletion frames/classic/bagslots.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ function BagSlots:CreatePanel(kind)
for i, bag in pairs(bags) do
local iframe = bagButton:Create()
iframe:SetBag(bag)
iframe:AddToMasqueGroup(kind)
b.content:AddCell(tostring(i), iframe)
end

Expand Down
6 changes: 0 additions & 6 deletions frames/classic/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ local addon = LibStub('AceAddon-3.0'):GetAddon(addonName)
---@class Constants: AceModule
local const = addon:GetModule('Constants')

---@class MasqueTheme: AceModule
local masque = addon:GetModule('Masque')

---@class ItemFrame: AceModule
local itemFrame = addon:GetModule('ItemFrame')

Expand Down Expand Up @@ -128,7 +125,6 @@ function itemFrame.itemProto:SetItem(data)
self.button:CheckUpdateTooltip(tooltipOwner)
self.button:SetMatchesSearch(not isFiltered)
--]]
self:AddToMasqueGroup()
self:SetAlpha(1)
events:SendMessage('item/Updated', self)
self.frame:Show()
Expand Down Expand Up @@ -175,7 +171,6 @@ function itemFrame.itemProto:SetFreeSlots(bagid, slotid, count, reagent)
SetItemButtonQuality(self.button, Enum.ItemQuality.Artifact, nil, false, false)
end

self:AddToMasqueGroup()
self.button.IconBorder:SetBlendMode("BLEND")
self.frame:SetAlpha(1)
events:SendMessage('item/Updated', self)
Expand All @@ -186,7 +181,6 @@ end

function itemFrame.itemProto:ClearItem()
events:SendMessage('item/Clearing', self)
self:RemoveFromMasqueGroup()
self.kind = nil
self.frame:ClearAllPoints()
self.frame:SetParent(nil)
Expand Down
37 changes: 10 additions & 27 deletions frames/item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ local addon = LibStub('AceAddon-3.0'):GetAddon(addonName)
---@class Constants: AceModule
local const = addon:GetModule('Constants')

---@class MasqueTheme: AceModule
local masque = addon:GetModule('Masque')

---@class ItemFrame: AceModule
local itemFrame = addon:NewModule('ItemFrame')

Expand Down Expand Up @@ -52,11 +49,12 @@ local debug = addon:GetModule('Debug')
---@field IconQuestTexture Texture
---@field NormalTexture Texture
---@field NewItemTexture Texture
---@field IconOverlay2 Texture
---@field IconOverlay Texture
---@field ItemContextOverlay Texture
---@field Cooldown Cooldown
---@field UpdateTooltip function
---@field LockTexture Texture
---@field IconQuestTexture Texture
itemFrame.itemProto = {}

local buttonCount = 0
Expand All @@ -69,7 +67,6 @@ local children = {
"Cooldown",
"NormalTexture",
"NewItemTexture",
"IconOverlay2",
"ItemContextOverlay",
"UpgradeIcon"
}
Expand Down Expand Up @@ -272,8 +269,6 @@ function itemFrame.itemProto:SetItem(data)
self.button:CheckUpdateTooltip(tooltipOwner)
self.button:SetMatchesSearch(not isFiltered)

self:AddToMasqueGroup()
self.button.IconBorder:SetBlendMode("BLEND")
self:SetAlpha(1)
events:SendMessage('item/Updated', self)
self.frame:Show()
Expand All @@ -283,6 +278,11 @@ end
function itemFrame.itemProto:SetSize(width, height)
self.frame:SetSize(width, height)
self.button:SetSize(width, height)
self.button.IconBorder:SetSize(width, height)
self.button.NormalTexture:SetSize(width, height)
self.IconQuestTexture:SetSize(width, height)
self.IconTexture:SetSize(width, height)
self.IconOverlay:SetSize(width, height)
end

-- SetFreeSlots will set the item button to a free slot.
Expand Down Expand Up @@ -327,9 +327,6 @@ function itemFrame.itemProto:SetFreeSlots(bagid, slotid, count, reagent)
SetItemButtonQuality(self.button, Enum.ItemQuality.Common, nil, false, false)
end

self:AddToMasqueGroup()
self.button.IconBorder:SetBlendMode("BLEND")

self.isFreeSlot = true
self.button.ItemSlotBackground:Show()
self.frame:SetAlpha(1)
Expand Down Expand Up @@ -461,7 +458,6 @@ end

function itemFrame.itemProto:ClearItem()
events:SendMessage('item/Clearing', self)
self:RemoveFromMasqueGroup()
self.kind = nil
self.frame:ClearAllPoints()
self.frame:SetParent(nil)
Expand Down Expand Up @@ -491,22 +487,6 @@ function itemFrame.itemProto:ClearItem()
self.button.UpgradeIcon:SetShown(false)
end

function itemFrame.itemProto:AddToMasqueGroup()
if self.masqueGroup ~= nil then return end
if self.kind == const.BAG_KIND.BANK then
self.masqueGroup = "Bank"
masque:AddButtonToGroup(self.masqueGroup, self.button)
else
self.masqueGroup = "Backpack"
masque:AddButtonToGroup(self.masqueGroup, self.button)
end
end

function itemFrame.itemProto:RemoveFromMasqueGroup()
masque:RemoveButtonFromGroup(self.masqueGroup, self.button)
self.masqueGroup = nil
end

function itemFrame:OnInitialize()
self._pool = CreateObjectPool(self._DoCreate, self._DoReset)
self._pool:SetResetDisallowedIfNew()
Expand Down Expand Up @@ -549,6 +529,9 @@ function itemFrame:_DoCreate()
i[child] = _G[name..child] ---@type texture
end

-- Small fix for missing texture
i.IconOverlay = button['IconOverlay']

p:SetSize(37, 37)
button:SetSize(37, 37)
button:RegisterForDrag("LeftButton")
Expand Down
8 changes: 0 additions & 8 deletions frames/itemrow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ local addon = LibStub('AceAddon-3.0'):GetAddon(addonName)
---@class Constants: AceModule
local const = addon:GetModule('Constants')

---@class MasqueTheme: AceModule
local masque = addon:GetModule('Masque')

---@class Events: AceModule
local events = addon:GetModule('Events')

Expand Down Expand Up @@ -126,11 +123,6 @@ function item.itemRowProto:IsNewItem()
return self.button:IsNewItem()
end

function item.itemRowProto:AddToMasqueGroup()
--TODO(lobato): Style the individual row frame, maybe?
self.button:AddToMasqueGroup()
end

---@return string
function item.itemRowProto:GetGUID()
return self.data.itemInfo.itemGUID
Expand Down
68 changes: 68 additions & 0 deletions integrations/masque.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
local addonName = ... ---@type string

---@class BetterBags: AceAddon
local addon = LibStub('AceAddon-3.0'):GetAddon(addonName)

---@class Events: AceModule
local events = addon:GetModule('Events')

---@class MasqueTheme: AceModule
---@field groups table<string, MasqueGroup>
local masque = addon:NewModule('Masque')

---@class Masque: AceAddon
local Masque = LibStub('Masque', true)

---@private
function masque:AddButtonToGroup(group, button)
if not Masque then
return
end
self.groups[group]:AddButton(button)
end

---@private
function masque:RemoveButtonFromGroup(group, button)
if not Masque then
return
end
if group == nil then
return
end
self.groups[group]:RemoveButton(button)
end

function masque:OnEnable()
if not Masque then return end
self.groups = {}
self.groups["Backpack"] = Masque:Group('BetterBags', 'Backpack')
self.groups["Bank"] = Masque:Group('BetterBags', 'Bank')

events:RegisterMessage('item/Updated', function(_, item)
---@cast item Item
local group = item.kind == 'Bank' and self.groups["Bank"] or self.groups["Backpack"]
group:AddButton(item.button)
item.button.IconBorder:SetBlendMode("BLEND")
end)

events:RegisterMessage('item/Clearing', function(_, item)
---@cast item Item
local group = item.kind == 'Bank' and self.groups["Bank"] or self.groups["Backpack"]
group:RemoveButton(item.button)
end)

events:RegisterMessage('bagbutton/Updated', function(_, bag)
---@cast bag BagButton
local group = bag.kind == 'Bank' and self.groups["Bank"] or self.groups["Backpack"]
group:AddButton(bag.frame)
bag.frame.IconBorder:SetBlendMode("BLEND")
end)

events:RegisterMessage('bagbutton/Clearing', function(_, bag)
---@cast bag BagButton
local group = bag.kind == 'Bank' and self.groups["Bank"] or self.groups["Backpack"]
group:RemoveButton(bag.frame)
end)

print("BetterBags: Masque integration enabled.")
end
37 changes: 0 additions & 37 deletions theme/masque.lua

This file was deleted.

0 comments on commit 511e722

Please sign in to comment.