diff --git a/src/lua/cache/cache.lua b/src/lua/cache/cache.lua index 20834eb..9fce410 100644 --- a/src/lua/cache/cache.lua +++ b/src/lua/cache/cache.lua @@ -16,17 +16,17 @@ function cache:GetItem(bag, slot) end function cache:GetBagItemContainer(name) - self.bagContainers[name] = self.bagContainers[name] or ADDON.itemContainer(name, name ~= ADDON.utils.EMPTY_BAG_NAME, nil, name == ADDON.utils.EMPTY_BAG_NAME) + self.bagContainers[name] = self.bagContainers[name] or ADDON.itemContainer(name, nil, nil, name == EMPTY) return self.bagContainers[name] end function cache:GetBankItemContainer(name) - self.bankContainers[name] = self.bankContainers[name] or ADDON.itemContainer(name, name ~= ADDON.utils.EMPTY_BAG_NAME, nil, name == ADDON.utils.EMPTY_BAG_NAME) + self.bankContainers[name] = self.bankContainers[name] or ADDON.itemContainer(name, nil, nil, name == EMPTY) return self.bankContainers[name] end function cache:GetReagentItemContainer(name) - self.reagentContainers[name] = self.reagentContainers[name] or ADDON.itemContainer(name, name ~= ADDON.utils.EMPTY_BAG_NAME, nil, name == ADDON.utils.EMPTY_BAG_NAME) + self.reagentContainers[name] = self.reagentContainers[name] or ADDON.itemContainer(name, nil, nil, name == EMPTY) return self.reagentContainers[name] end diff --git a/src/lua/controllers/bag.lua b/src/lua/controllers/bag.lua index f4a076b..246bcba 100644 --- a/src/lua/controllers/bag.lua +++ b/src/lua/controllers/bag.lua @@ -22,6 +22,9 @@ function bag:Init() end) self.frame:HookScript('OnHide', function() self:UnRegister() + if ADDON.settings.auto.clearNewItems then + C_NewItems.ClearAll() + end end) ADDON.eventManager:AddEvent(self, 'MERCHANT_SHOW') diff --git a/src/lua/controllers/bank.lua b/src/lua/controllers/bank.lua index bbff954..dce5cb1 100644 --- a/src/lua/controllers/bank.lua +++ b/src/lua/controllers/bank.lua @@ -139,6 +139,7 @@ function bank:Register() ADDON.eventManager:AddEvent(self, 'PLAYERREAGENTBANKSLOTS_CHANGED') ADDON.eventManager:AddEvent(self, 'PLAYERBANKBAGSLOTS_CHANGED') ADDON.eventManager:AddEvent(self, 'REAGENTBANK_PURCHASED') + ADDON.eventManager:AddEvent(self, 'BAG_UPDATE_DELAYED') end function bank:UnRegister() @@ -150,12 +151,17 @@ function bank:UnRegister() ADDON.eventManager:RemoveEvent(self, 'PLAYERREAGENTBANKSLOTS_CHANGED') ADDON.eventManager:RemoveEvent(self, 'PLAYERBANKBAGSLOTS_CHANGED') ADDON.eventManager:RemoveEvent(self, 'REAGENTBANK_PURCHASED') + ADDON.eventManager:RemoveEvent(self, 'BAG_UPDATE_DELAYED') end function bank:PLAYERBANKBAGSLOTS_CHANGED() self:UpdateBags() end +function bank:BAG_UPDATE_DELAYED() + self:UpdateBags() +end + function bank:BAG_UPDATE(bag) if bag > NUM_BAG_SLOTS then self:UpdateAllItemsForBag(bag) @@ -290,7 +296,7 @@ end function bank:UpdateBags() local numBankslots, full = GetNumBankSlots() for bag = #self.bags+1, numBankslots do - local item = ADDON.bagItem('DJBagsBankBagItem' .. bag, bag, BankButtonIDToInvSlotID(bag, 1)) + local item = ADDON.bagItem('DJBagsBankBagItem' .. bag, NUM_BAG_SLOTS + bag, BankButtonIDToInvSlotID(bag, 1)) item:SetParent(self.frame) tinsert(self.bags, item) end diff --git a/src/lua/core.lua b/src/lua/core.lua index 812ae53..33f35bf 100644 --- a/src/lua/core.lua +++ b/src/lua/core.lua @@ -70,7 +70,6 @@ end SLASH_TDJBAGS1, SLASH_TDJBAGS2 = '/tt', '/ttt'; function SlashCmdList.TDJBAGS(msg, editbox) - end SLASH_RELOAD1 = '/rl' diff --git a/src/lua/elements/bagItem.lua b/src/lua/elements/bagItem.lua index be8f51e..90ebbd4 100644 --- a/src/lua/elements/bagItem.lua +++ b/src/lua/elements/bagItem.lua @@ -44,6 +44,13 @@ end function item:Update() PaperDollItemSlotButton_Update(self) + local slotcount = GetContainerNumSlots(self.slot) + if slotcount > 0 then + self.Count:SetText(tostring(slotcount)) + self.Count:Show() + else + self.Count:Hide() + end end function item:UpdateLock() diff --git a/src/lua/elements/categoryContainer.lua b/src/lua/elements/categoryContainer.lua index 42fe9b9..2ce72cf 100644 --- a/src/lua/elements/categoryContainer.lua +++ b/src/lua/elements/categoryContainer.lua @@ -27,6 +27,18 @@ function container:Init() self:SetScript("OnDragStart", self.StartMoving) self:SetScript("OnDragStop", self.StopMovingOrSizing) self.containers = {} + + self.closeBtn = CreateFrame('Button', self:GetName() .. 'CloseButton', self) + self.closeBtn:SetNormalTexture([[Interface\Buttons\UI-Panel-MinimizeButton-Disabled]]) + self.closeBtn:SetPushedTexture([[Interface\Buttons\UI-Panel-MinimizeButton-Down]]) + self.closeBtn:SetHighlightTexture([[Interface\Buttons\UI-Panel-MinimizeButton-Up]]) + self.closeBtn:SetScript('OnClick', function() + if self:GetParent() == UIParent then + self:Hide() + else + self:GetParent():Hide() + end + end) end function container:Setup() @@ -38,6 +50,13 @@ function container:Setup() self.spacing = settings.spacing self.sortFunction = ADDON.sorters.containers[settings.sortFunction] self.maxHeight = settings.maxHeight + if settings.closeVisible then + self.closeBtn:Show() + else + self.closeBtn:Hide() + end + self.closeBtn:SetPoint('Topright', self, 'TOPRIGHT', settings.closeSize / 5, settings.closeSize / 5) + self.closeBtn:SetSize(settings.closeSize, settings.closeSize) end function container:AddContainer(container) diff --git a/src/lua/elements/item.lua b/src/lua/elements/item.lua index a30346c..cfb2aaa 100644 --- a/src/lua/elements/item.lua +++ b/src/lua/elements/item.lua @@ -61,7 +61,6 @@ function item:Init() self.button:Show() self.button:HookScript('OnClick', self.OnClick) - self.button:SetScript('OnEnter', self.OnEnter) end function item:Setup() @@ -81,7 +80,7 @@ function item:OnEnter(...) end end -function item:OnEnterBag() +function ContainerFrameItemButton_OnEnter(self) GameTooltip:SetOwner(self, "ANCHOR_NONE") local newItemTexture = self.NewItemTexture diff --git a/src/lua/elements/itemContainer.lua b/src/lua/elements/itemContainer.lua index 791cacc..0514c3c 100644 --- a/src/lua/elements/itemContainer.lua +++ b/src/lua/elements/itemContainer.lua @@ -51,9 +51,7 @@ function container:Setup() end function container:AddItem(item) - if item:GetParent() ~= self then - self.items[item] = true - end + self.items[item] = true end function container:RemoveItem(item) diff --git a/src/lua/settings/defaults/auto.lua b/src/lua/settings/defaults/auto.lua index 6f5e4ef..d882405 100644 --- a/src/lua/settings/defaults/auto.lua +++ b/src/lua/settings/defaults/auto.lua @@ -5,4 +5,5 @@ ADDON.settings = ADDON.settings or {} ADDON.settings.auto = { depositReagents = false, sellJunk = false, + clearNewItems = false, } \ No newline at end of file diff --git a/src/lua/settings/defaults/categoryContainer.lua b/src/lua/settings/defaults/categoryContainer.lua index cd59d76..84915dd 100644 --- a/src/lua/settings/defaults/categoryContainer.lua +++ b/src/lua/settings/defaults/categoryContainer.lua @@ -7,5 +7,7 @@ ADDON.settings.categoryContainer = { spacing = 3, maxHeight = 450, sortFunction = 'default', + closeVisible = false, + closeSize = 25, } diff --git a/src/lua/settings/editor.lua b/src/lua/settings/editor.lua index 8f09d17..4e5a640 100644 --- a/src/lua/settings/editor.lua +++ b/src/lua/settings/editor.lua @@ -314,7 +314,13 @@ function settings:CreateCategoryContainerSettings() end) container.maxHeight:SetPoint('TOPLEFT', container.spacing, 'TOPRIGHT', 15, 0) - container:SetHeight(70) + local closeBtn = CreateCheckBox("Close Button visible", container, ADDON.settings.categoryContainer.closeVisible, function(value) + ADDON.settings.categoryContainer.closeVisible = value + ADDON.eventManager:FireEvent('SETTINGS_UPDATE', true) + end) + closeBtn:SetPoint('TOPLEFT', container.padding, 'BOTTOMLEFT', -10, -15) + + container:SetHeight(100) self:AddSettingsPanel(container) end @@ -438,6 +444,11 @@ function settings:CreateAutoSettings() ADDON.eventManager:FireEvent('SETTINGS_UPDATE', true) end) autoDeposit:SetPoint('LEFT', autoSellJunk, 'RIGHT', 75, 0) + local autoClearNewItems = CreateCheckBox("Clear New Items on close", container, ADDON.settings.auto.clearNewItems, function(value) + ADDON.settings.auto.clearNewItems = value + ADDON.eventManager:FireEvent('SETTINGS_UPDATE', true) + end) + autoClearNewItems:SetPoint('LEFT', autoDeposit, 'RIGHT', 115, 0) container:SetHeight(55) self:AddSettingsPanel(container) diff --git a/src/lua/sorters/containers.lua b/src/lua/sorters/containers.lua index fac5109..3681f47 100644 --- a/src/lua/sorters/containers.lua +++ b/src/lua/sorters/containers.lua @@ -4,9 +4,9 @@ ADDON.sorters = ADDON.sorters or {} ADDON.sorters.containers = { ['default'] = function(A, B) - if A.name == ADDON.utils.EMPTY_BAG_NAME then + if A.name == EMPTY then return true - elseif B.name == ADDON.utils.EMPTY_BAG_NAME then + elseif B.name == EMPTY then return false else return A.name > B.name diff --git a/src/lua/utils/utils.lua b/src/lua/utils/utils.lua index b590eb4..3ca6b57 100644 --- a/src/lua/utils/utils.lua +++ b/src/lua/utils/utils.lua @@ -64,7 +64,7 @@ function utils:GetItemContainerName(bag, slot) return className end - return self.EMPTY_BAG_NAME + return EMPTY end function utils:UpdateItemsForBag(frame, bag, arrangeList, containerFunc) @@ -74,6 +74,7 @@ function utils:UpdateItemsForBag(frame, bag, arrangeList, containerFunc) if item:GetParent() then local previousContainer = item:GetParent() previousContainer:RemoveItem(item) + item:SetParent(nil) arrangeList[previousContainer] = true item:Hide() end