From 9c186cab6f9ff358be2ca1f773a48ee3651d9c96 Mon Sep 17 00:00:00 2001 From: Antonio Lobato Date: Sun, 1 Sep 2024 16:14:51 -0700 Subject: [PATCH] Event Context and Bug Fix (#660) * Fixed a few bugs. --- .gitignore | 5 ++++- annotations.lua | 14 +++++++++++--- config/bags.lua | 31 ++++++++++++++++--------------- config/classic/bags.lua | 30 +++++++++++++++--------------- config/config.lua | 8 ++++---- config/era/bags.lua | 30 +++++++++++++++--------------- config/era/config.lua | 5 ++++- core/async.lua | 4 ++-- core/events.lua | 16 ++++++++-------- core/hooks.lua | 16 ++++++++-------- core/init.lua | 8 ++++---- data/categories.lua | 18 +++++++++--------- data/items.lua | 17 ++++++++++++----- data/refresh.lua | 19 +++++++++++++------ frames/bag.lua | 14 +++++++------- frames/bagbutton.lua | 4 ++-- frames/bagslots.lua | 4 ++-- frames/classic/bag.lua | 2 +- frames/classic/contextmenu.lua | 6 +++--- frames/contextmenu.lua | 6 +++--- frames/debug.lua | 6 +++--- frames/era/bag.lua | 2 +- frames/era/bagbutton.lua | 4 ++-- frames/era/bagslots.lua | 4 ++-- frames/era/contextmenu.lua | 6 +++--- frames/era/item.lua | 6 +++--- frames/era/itemrow.lua | 2 +- frames/grid.lua | 2 +- frames/item.lua | 6 +++--- frames/itemrow.lua | 4 ++-- frames/overlay.lua | 4 ++-- frames/searchcategory.lua | 2 +- frames/section.lua | 2 +- frames/sectionconfig.lua | 8 ++++---- frames/sectionitemlist.lua | 4 ++-- themes/themes.lua | 8 ++++---- views/bagview.lua | 17 ----------------- 37 files changed, 178 insertions(+), 166 deletions(-) diff --git a/.gitignore b/.gitignore index 790ab6e2..d5535975 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ /libs/** -/includes/** \ No newline at end of file +/includes/** +# Bugfix for Cursor editor. +cpp-ghost-text-preview-widget-anysphere://* +cpp-ghost-text-preview-widget-anysphere://** \ No newline at end of file diff --git a/annotations.lua b/annotations.lua index 9fd1646d..6e15a69f 100644 --- a/annotations.lua +++ b/annotations.lua @@ -432,7 +432,10 @@ AccountBankPanel = {} AccountBankPanel.PurchasePrompt = {} AccountBankPanel.PurchasePrompt.TabCostFrame = {} ---@type Button -AccountBankPanel.PurchasePrompt.TabCostFrame.PurchaseButton = {} +AccountBankPanel.PurchasePrompt.TabCostFrame.PurchaseButton = { + BattlepayItemTexture = {}, + isSkinned = true, +} ACCOUNT_BANK_PANEL_TITLE = "" @@ -469,13 +472,18 @@ function AceItemList:SetList(values) end function ContainerFrame_UpdateCooldown(id, button) end ---@type Frame -GameMenuFrame = {} +GameMenuFrame = { + scrollable = true, +} ---@type CheckButton KeyRingButton = {} ---@type Button -CharacterReagentBag0Slot = {} +CharacterReagentBag0Slot = { + BattlepayItemTexture = {}, + isSkinned = true, +} ---@class MainMenuBagButton: Button ---@field SlotHighlightTexture Texture diff --git a/config/bags.lua b/config/bags.lua index cbcb6c43..dc8ac5ba 100644 --- a/config/bags.lua +++ b/config/bags.lua @@ -37,6 +37,7 @@ local context = addon:GetModule('Context') ---@param kind BagKind ---@return AceConfig.OptionsTable function config:GetCustomCategoryOptions(kind) + _ = kind return { type = "group", name = L:G("Custom Categories"), @@ -77,7 +78,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetCategoryFilter(kind, value, not DB:GetCategoryFilter(kind, value)) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = { ["RecentItems"] = L:G("Recent Items"), @@ -105,7 +106,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetSectionSortType(kind, DB:GetBagView(kind), value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = { [const.SECTION_SORT_TYPE.ALPHABETICALLY] = L:G("Alphabetically"), @@ -126,7 +127,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetItemSortType(kind, DB:GetBagView(kind), value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = { [const.ITEM_SORT_TYPE.QUALITY_THEN_ALPHABETICALLY] = L:G("Quality, then Alphabetically"), @@ -183,7 +184,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetMergeItems(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, mergeUnstackable = { @@ -197,7 +198,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetMergeUnstackable(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, unmergeAtShop = { @@ -211,7 +212,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetUnmergeAtShop(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, dontMergePartial = { @@ -225,7 +226,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetDontMergePartial(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, dontMergeTransmog = { @@ -239,7 +240,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetDontMergeTransmog(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, } @@ -261,7 +262,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetItemLevelEnabled(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, color = { @@ -275,7 +276,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetItemLevelColorEnabled(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, } @@ -298,7 +299,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetShowFullSectionNames(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, showAllFreeSpace = { @@ -313,7 +314,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetShowAllFreeSpace(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, showExtraGlowyButtons = { @@ -328,7 +329,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetExtraGlowyButtons(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, itemsPerRow = { @@ -346,7 +347,7 @@ function config:GetBagOptions(kind) DB:SetBagViewSizeItems(kind, DB:GetBagView(kind), value) bucket:Later("setItemsPerRow", 0.2, function() local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end) end, }, @@ -381,7 +382,7 @@ function config:GetBagOptions(kind) DB:SetBagViewSizeColumn(kind, DB:GetBagView(kind), value) bucket:Later("setSectionsPerRow", 0.2, function() local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end) end, }, diff --git a/config/classic/bags.lua b/config/classic/bags.lua index 7a747094..051151fb 100644 --- a/config/classic/bags.lua +++ b/config/classic/bags.lua @@ -64,7 +64,7 @@ function config:GetCustomCategoryOptions(kind) set = function(_, value) categories:SetCategoryState(kind, value, not categories:IsCategoryEnabled(kind, value)) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = {} } @@ -103,7 +103,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetCategoryFilter(kind, value, not DB:GetCategoryFilter(kind, value)) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = { ["RecentItems"] = L:G("Recent Items"), @@ -128,7 +128,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetSectionSortType(kind, DB:GetBagView(kind), value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = { [const.SECTION_SORT_TYPE.ALPHABETICALLY] = L:G("Alphabetically"), @@ -149,7 +149,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetItemSortType(kind, DB:GetBagView(kind), value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = { [const.ITEM_SORT_TYPE.QUALITY_THEN_ALPHABETICALLY] = L:G("Quality, then Alphabetically"), @@ -174,7 +174,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetMergeItems(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, mergeUnstackable = { @@ -188,7 +188,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetMergeUnstackable(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, unmergeAtShop = { @@ -202,7 +202,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetUnmergeAtShop(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, dontMergePartial = { @@ -216,7 +216,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetDontMergePartial(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, } @@ -238,7 +238,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetItemLevelEnabled(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, color = { @@ -252,7 +252,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetItemLevelColorEnabled(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, } @@ -275,7 +275,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetShowFullSectionNames(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, showAllFreeSpace = { @@ -290,7 +290,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetShowAllFreeSpace(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, showExtraGlowyButtons = { @@ -305,7 +305,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetExtraGlowyButtons(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, itemsPerRow = { @@ -323,7 +323,7 @@ function config:GetBagOptions(kind) DB:SetBagViewSizeItems(kind, DB:GetBagView(kind), value) bucket:Later("setItemsPerRow", 0.2, function() local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end) end, }, @@ -358,7 +358,7 @@ function config:GetBagOptions(kind) DB:SetBagViewSizeColumn(kind, DB:GetBagView(kind), value) bucket:Later("setSectionsPerRow", 0.2, function() local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end) end, }, diff --git a/config/config.lua b/config/config.lua index f8bebd21..f2fad64c 100644 --- a/config/config.lua +++ b/config/config.lua @@ -77,7 +77,7 @@ function config:GetGeneralOptions() end, set = function(_, value) DB:SetInBagSearch(value) - events:SendMessage('search/SetInFrame', value) + events:SendMessage(context:New('OnClick_InBagSearch'), 'search/SetInFrame', value) end, }, enableEnterToMakeCategory = { @@ -139,7 +139,7 @@ function config:GetGeneralOptions() set = function(_, value) DB:SetUpgradeIconProvider(value) local ctx = context:New('on_click') - events:SendMessage('bag/RedrawIcons', ctx) + events:SendMessage(ctx, 'bag/RedrawIcons') end, }, newItemTime = { @@ -224,7 +224,7 @@ end function config:Open() LibStub("AceConfigDialog-3.0"):Open(addonName) local ctx = context:New('on_click') - events:SendMessage('config/Opened', ctx) + events:SendMessage(ctx, 'config/Opened') end function config:OnEnable() @@ -255,7 +255,7 @@ function config:OnEnable() LibStub('AceConsole-3.0'):RegisterChatCommand("bbdb", function() DB:SetDebugMode(not DB:GetDebugMode()) local ctx = context:New('on_click') - events:SendMessage('config/DebugMode', ctx, DB:GetDebugMode()) + events:SendMessage(ctx, 'config/DebugMode', DB:GetDebugMode()) end) end diff --git a/config/era/bags.lua b/config/era/bags.lua index c9a6b0c5..9d3e6432 100644 --- a/config/era/bags.lua +++ b/config/era/bags.lua @@ -64,7 +64,7 @@ function config:GetCustomCategoryOptions(kind) set = function(_, value) categories:SetCategoryState(kind, value, not categories:IsCategoryEnabled(kind, value)) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = {} } @@ -103,7 +103,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetCategoryFilter(kind, value, not DB:GetCategoryFilter(kind, value)) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = { ["RecentItems"] = L:G("Recent Items"), @@ -128,7 +128,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetSectionSortType(kind, DB:GetBagView(kind), value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = { [const.SECTION_SORT_TYPE.ALPHABETICALLY] = L:G("Alphabetically"), @@ -149,7 +149,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetItemSortType(kind, DB:GetBagView(kind), value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, values = { [const.ITEM_SORT_TYPE.QUALITY_THEN_ALPHABETICALLY] = L:G("Quality, then Alphabetically"), @@ -174,7 +174,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetMergeItems(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, mergeUnstackable = { @@ -188,7 +188,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetMergeUnstackable(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, unmergeAtShop = { @@ -202,7 +202,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetUnmergeAtShop(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, dontMergePartial = { @@ -216,7 +216,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetDontMergePartial(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, } @@ -238,7 +238,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetItemLevelEnabled(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, color = { @@ -252,7 +252,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetItemLevelColorEnabled(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, } @@ -275,7 +275,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetShowFullSectionNames(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, showAllFreeSpace = { @@ -290,7 +290,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetShowAllFreeSpace(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, showExtraGlowyButtons = { @@ -305,7 +305,7 @@ function config:GetBagOptions(kind) set = function(_, value) DB:SetExtraGlowyButtons(kind, value) local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end, }, itemsPerRow = { @@ -323,7 +323,7 @@ function config:GetBagOptions(kind) DB:SetBagViewSizeItems(kind, DB:GetBagView(kind), value) bucket:Later("setItemsPerRow", 0.2, function() local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end) end, }, @@ -358,7 +358,7 @@ function config:GetBagOptions(kind) DB:SetBagViewSizeColumn(kind, DB:GetBagView(kind), value) bucket:Later("setSectionsPerRow", 0.2, function() local ctx = context:New('on_click') - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end) end, }, diff --git a/config/era/config.lua b/config/era/config.lua index 28b3ad58..bf1e5ee1 100644 --- a/config/era/config.lua +++ b/config/era/config.lua @@ -19,6 +19,9 @@ local config = addon:GetModule('Config') ---@class Events: AceModule local events = addon:GetModule('Events') +---@class Context: AceModule +local context = addon:GetModule('Context') + ---@return AceConfig.OptionsTable function config:GetGeneralOptions() ---@type AceConfig.OptionsTable @@ -38,7 +41,7 @@ function config:GetGeneralOptions() end, set = function(_, value) DB:SetInBagSearch(value) - events:SendMessage('search/SetInFrame', value) + events:SendMessage(context:New('OnClick_InBagSearch'), 'search/SetInFrame', value) end, }, categorySell = { diff --git a/core/async.lua b/core/async.lua index db93a68e..bb29b341 100644 --- a/core/async.lua +++ b/core/async.lua @@ -54,7 +54,7 @@ function async:DoWithDelay(ctx, delay, fn, event) if type(task.event) == 'function' then task.event(task.ctx) elseif type(task.event) == 'string' then - events:SendMessage(task.event --[[@as string]], task.ctx) + events:SendMessage(task.ctx, task.event --[[@as string]]) end end return @@ -180,7 +180,7 @@ function async:Chain(ctx, event, ...) end ) elseif event ~= nil then - events:SendMessage(event, ctx) + events:SendMessage(ctx, event) end end executeNext() diff --git a/core/events.lua b/core/events.lua index aa306524..69bfcbae 100644 --- a/core/events.lua +++ b/core/events.lua @@ -188,10 +188,10 @@ function events:GroupBucketEvent(groupEvents, groupMessages, callback) table.insert(self._bucketCallbacks[joinedEvents], callback) end ----@param event string ---@param ctx Context +---@param event string ---@param ... any -function events:SendMessage(event, ctx, ...) +function events:SendMessage(ctx, event, ...) if type(ctx) ~= 'table' or not ctx.Event then error('ctx must be passed into SendMessage and must be a Context object: ' .. event) end @@ -204,22 +204,22 @@ function events:SendMessage(event, ctx, ...) self._eventHandler:SendMessage(event, unpack(args)) end ----@param event? string ---@param ctx Context +---@param event? string ---@param ... any -function events:SendMessageIf(event, ctx, ...) +function events:SendMessageIf(ctx, event,...) if event then - self:SendMessage(event, ctx, ...) + self:SendMessage(ctx, event, ...) end end ----@param event string ---@param ctx Context +---@param event string ---@param ... any -function events:SendMessageLater(event, ctx, ...) +function events:SendMessageLater(ctx, event, ...) local args = {...} C_Timer.After(0, function() - self:SendMessage(event, ctx, unpack(args)) + self:SendMessage(ctx, event, unpack(args)) end) end diff --git a/core/hooks.lua b/core/hooks.lua index 8fb72286..f04c9ee4 100644 --- a/core/hooks.lua +++ b/core/hooks.lua @@ -56,7 +56,7 @@ function addon.OnUpdate(ctx) addon.Bags.Backpack:Show(ctx) addon:UpdateButtonHighlight() if addon.atInteracting then - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end elseif addon.backpackShouldClose then debug:Log('Hooks', 'OnUpdate', addon.backpackShouldOpen, addon.backpackShouldClose) @@ -79,7 +79,7 @@ function addon.OpenInteractionWindow(ctx, _, interactionType) end addon.atInteracting = true addon.backpackShouldOpen = true - events:SendMessageLater('bags/OpenClose', ctx) + events:SendMessageLater(ctx, 'bags/OpenClose') end ---@param ctx Context @@ -90,8 +90,8 @@ function addon.CloseInteractionWindow(ctx, _, interactionType) addon.atInteracting = false addon.atWarbank = false addon.backpackShouldClose = true - events:SendMessage('bags/FullRefreshAll', ctx) - events:SendMessageLater('bags/OpenClose', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') + events:SendMessageLater(ctx, 'bags/OpenClose') end ---@param ctx Context @@ -105,7 +105,7 @@ function addon:ToggleAllBags(ctx, interactingFrame) else addon.backpackShouldOpen = true end - events:SendMessage('bags/OpenClose', ctx) + events:SendMessage(ctx, 'bags/OpenClose') end ---@param interactingFrame Frame @@ -122,13 +122,13 @@ function addon:CloseSpecialWindows(interactingFrame) addon.Bags.Bank:Hide(ectx) addon.Bags.Bank:SwitchToBankAndWipe(ectx) end) - events:SendMessage('addon/CloseSpecialWindows', ctx) + events:SendMessage(ctx, 'addon/CloseSpecialWindows') if C_Bank then C_Bank.CloseBankFrame() else CloseBankFrame() end - events:SendMessageLater('bags/OpenClose', ctx) + events:SendMessageLater(ctx, 'bags/OpenClose') end ---@param ctx Context @@ -138,5 +138,5 @@ function addon.CloseBank(ctx, _, interactingFrame) if interactingFrame ~= nil then return end addon.Bags.Bank:Hide(ctx) addon.Bags.Bank:SwitchToBankAndWipe(ctx) - events:SendMessage('bags/BankClosed', ctx) + events:SendMessage(ctx, 'bags/BankClosed') end diff --git a/core/init.lua b/core/init.lua index 0af2ccee..5760214d 100644 --- a/core/init.lua +++ b/core/init.lua @@ -272,10 +272,10 @@ function addon:OnEnable() ---@cast slotInfo +SlotInfo debug:Log("init/OnInitialize/items", "Drawing bag") addon.Bags.Backpack:Draw(ctx, slotInfo, function() - events:SendMessage('bags/Draw/Backpack/Done', ctx) + events:SendMessage(ctx, 'bags/Draw/Backpack/Done') if not addon.Bags.Backpack.loaded then addon.Bags.Backpack.loaded = true - events:SendMessage('bags/Draw/Backpack/Loaded', ctx) + events:SendMessage(ctx, 'bags/Draw/Backpack/Loaded') end end) end) @@ -287,10 +287,10 @@ function addon:OnEnable() addon.Bags.Bank:Show(ctx) end addon.Bags.Bank:Draw(ctx, slotInfo, function() - events:SendMessage('bags/Draw/Bank/Done', ctx) + events:SendMessage(ctx, 'bags/Draw/Bank/Done') if not addon.Bags.Bank.loaded then addon.Bags.Bank.loaded = true - events:SendMessage('bags/Draw/Bank/Loaded', ctx) + events:SendMessage(ctx, 'bags/Draw/Bank/Loaded') end end) end) diff --git a/data/categories.lua b/data/categories.lua index a674b677..d23d7603 100644 --- a/data/categories.lua +++ b/data/categories.lua @@ -201,7 +201,7 @@ function categories:WipeCategory(ctx, category) end wipe(self.ephemeralCategories[category].itemList) end - events:SendMessage('categories/Changed', ctx) + events:SendMessage(ctx, 'categories/Changed') end -- IsCategoryEnabled returns whether or not a custom category is enabled. @@ -317,7 +317,7 @@ function categories:CreateCategory(ctx, category) end database:CreateOrUpdateCategory(category) end - events:SendMessage('categories/Changed', ctx) + events:SendMessage(ctx, 'categories/Changed') end ---@param name string @@ -377,8 +377,8 @@ function categories:DeleteCategory(ctx, category) end database:DeleteItemCategory(category) - events:SendMessage('categories/Changed', ctx) - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'categories/Changed') + events:SendMessage(ctx, 'bags/FullRefreshAll') end ---@param ctx Context @@ -391,7 +391,7 @@ function categories:HideCategory(ctx, category) ctx = context:New('HideCategory') end database:GetCategoryOptions(category).shown = false - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end ---@param ctx Context @@ -404,7 +404,7 @@ function categories:ShowCategory(ctx, category) ctx = context:New('ShowCategory') end database:GetCategoryOptions(category).shown = true - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end ---@param category string @@ -430,7 +430,7 @@ function categories:ToggleCategoryShown(ctx, category) end local options = database:GetCategoryOptions(category) options.shown = not options.shown - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end -- GetCustomCategory returns the custom category for an item, or nil if it doesn't have one. @@ -474,7 +474,7 @@ function categories:GetCustomCategory(ctx, kind, data) self:AddItemToCategory(ctx, itemID, category) if not found then self.categoryCount = self.categoryCount + 1 - events:SendMessage('categories/Changed', ctx) + events:SendMessage(ctx, 'categories/Changed') end if self:IsCategoryEnabled(kind, category) then return category @@ -515,5 +515,5 @@ end ---@param ctx Context function categories:ReprocessAllItems(ctx) wipe(self.itemsWithNoCategory) - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end diff --git a/data/items.lua b/data/items.lua index 63d7a959..66db3704 100644 --- a/data/items.lua +++ b/data/items.lua @@ -161,7 +161,7 @@ end ---@param ctx Context function items:RefreshAll(ctx) - events:SendMessage('bags/RefreshAll', ctx) + events:SendMessage(ctx, 'bags/RefreshAll') end ---@private @@ -240,6 +240,7 @@ end ---@param targets table ---@param movePairs table function items:findBestFit(ctx, item, stackInfo, targets, movePairs) + _ = ctx -- Collect all the possible targets for this item. ---@type MoveTargetData[] local possibleTargets = {} @@ -329,6 +330,11 @@ end ---@param movePairs table ---@param takenEmptySlots table function items:fitForMoveClassic(ctx, item, targets, movePairs, takenEmptySlots) + _ = ctx + _ = targets + _ = movePairs + _ = takenEmptySlots + _ = item end ---@private @@ -396,6 +402,7 @@ function items:Restack(ctx, kind, callback) ctx:Set('moved', true) end async:Until(ctx, function(ectx) + _ = ectx for _, movePair in ipairs(movePairs) do if not movePair.done then if movePair.partial and movePair.partial > 0 then @@ -778,7 +785,7 @@ function items:ProcessContainer(ctx, kind, container) self:LoadItems(ectx, kind, container:GetDataCache(), container:GetEquipmentDataCache(), function(ictx) local ev = kind == const.BAG_KIND.BANK and 'items/RefreshBank/Done' or 'items/RefreshBackpack/Done' - events:SendMessageLater(ev, ictx, self.slotInfo[kind]) + events:SendMessageLater(ictx, ev, self.slotInfo[kind]) if kind == const.BAG_KIND.BACKPACK then debug:EndProfile('Backpack Data Pipeline') end @@ -956,7 +963,7 @@ end ---@return string function items:GenerateItemHash(data) local stackOpts = database:GetStackingOptions(data.kind) - local hash = format("%d%s%s%s%s%s%s%s%s%s%s%s%s%d%d%d", + local hash = format("%d%s%s%s%s%s%s%s%s%s%s%s%d%d%d", data.itemLinkInfo.itemID, data.itemLinkInfo.enchantID, data.itemLinkInfo.gemID1, @@ -964,7 +971,7 @@ function items:GenerateItemHash(data) data.itemLinkInfo.gemID3, data.itemLinkInfo.suffixID, table.concat(data.itemLinkInfo.bonusIDs, ","), - table.concat(data.itemLinkInfo.modifierIDs, ","), + --table.concat(data.itemLinkInfo.modifierIDs, ","), table.concat(data.itemLinkInfo.relic1BonusIDs, ","), table.concat(data.itemLinkInfo.relic2BonusIDs, ","), table.concat(data.itemLinkInfo.relic3BonusIDs, ","), @@ -1292,7 +1299,7 @@ function items:GetBagKindFromSlotKey(slotkey) return self:GetBagKindFromBagID(bagid) end ----@param bagid number +---@param bagid number|string ---@return BagKind function items:GetBagKindFromBagID(bagid) if const.BANK_BAGS[tonumber(bagid)] or const.REAGENTBANK_BAGS[tonumber(bagid)] or const.ACCOUNT_BANK_BAGS[tonumber(bagid)] then diff --git a/data/refresh.lua b/data/refresh.lua index 0a162efa..e9d85023 100644 --- a/data/refresh.lua +++ b/data/refresh.lua @@ -37,7 +37,7 @@ function refresh:RedrawBackpack(ctx) debug:Log('RedrawBackpack', 'Redrawing backpack') ctx:Set('redraw', true) addon.Bags.Backpack:Draw(ctx, items:GetAllSlotInfo()[const.BAG_KIND.BACKPACK], function() - events:SendMessage('bags/Draw/Backpack/Done', ctx) + events:SendMessage(ctx, 'bags/Draw/Backpack/Done') end) end @@ -45,11 +45,18 @@ function refresh:AfterSort(ctx) self.isSorting = false -- TODO(lobato): Detect if only new items were moved, -- and only refresh the backpack if that's the case. - if ctx:GetBool('moved') then - events:SendMessage('bags/FullRefreshAll', ctx) - else - events:SendMessage('bags/FullRefreshAll', ctx) - end + -- After moving an item, the client state does not update right + -- away, and there is a delay. This delay will prevent issues + -- with drawing. + C_Timer.After(0.2, function() + events:SendMessage(ctx, 'bags/FullRefreshAll') + end) + + --if ctx:GetBool('moved') then + -- events:SendMessage(ctx, 'bags/FullRefreshAll') + --else + -- events:SendMessage(ctx, 'bags/FullRefreshAll') + --end end -- StartUpdate will start the bag update process if it's not already running. diff --git a/frames/bag.lua b/frames/bag.lua index 291ca029..6e7b4421 100644 --- a/frames/bag.lua +++ b/frames/bag.lua @@ -251,7 +251,7 @@ end function bagFrame.bagProto:Sort(ctx) if self.kind ~= const.BAG_KIND.BACKPACK then return end PlaySound(SOUNDKIT.UI_BAG_SORTING_01) - events:SendMessage('bags/SortBackpack', ctx) + events:SendMessage(ctx, 'bags/SortBackpack') end -- Wipe will wipe the contents of the bag and release all cells. @@ -272,9 +272,9 @@ end ---@param ctx Context function bagFrame.bagProto:Refresh(ctx) if self.kind == const.BAG_KIND.BACKPACK then - events:SendMessage('bags/RefreshBackpack', ctx) + events:SendMessage(ctx, 'bags/RefreshBackpack') else - events:SendMessage('bags/RefreshBank', ctx) + events:SendMessage(ctx, 'bags/RefreshBank') end end @@ -327,8 +327,8 @@ function bagFrame.bagProto:Draw(ctx, slotInfo, callback) self.slots:Draw(ctx) self.slots:Show() end - events:SendMessage('bag/RedrawIcons', ctx, self) - events:SendMessage('bag/Rendered', ctx, self, slotInfo) + events:SendMessage(ctx, 'bag/RedrawIcons', self) + events:SendMessage(ctx, 'bag/Rendered', self, slotInfo) callback() end) end @@ -490,7 +490,7 @@ function bagFrame.bagProto:CreateCategoryForItemInCursor(ctx) itemList = {[itemID] = true}, save = true, }) - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end) GameTooltip:Hide() ClearCursor() @@ -697,7 +697,7 @@ function bagFrame:Create(ctx, kind) events:BucketEvent('BAG_UPDATE_COOLDOWN',function(ectx) b:OnCooldown(ectx) end) end - events:RegisterMessage('search/SetInFrame', function (ectx, _, shown) + events:RegisterMessage('search/SetInFrame', function (ectx, shown) themes:SetSearchState(ectx, b.frame, shown) end) diff --git a/frames/bagbutton.lua b/frames/bagbutton.lua index b898e923..8e49a4e8 100644 --- a/frames/bagbutton.lua +++ b/frames/bagbutton.lua @@ -90,12 +90,12 @@ function BagButtonFrame.bagButtonProto:SetBag(ctx, bag) SetItemButtonTexture(self.frame, icon) SetItemButtonQuality(self.frame, GetInventoryItemQuality("player", self.invID)) SetItemButtonCount(self.frame, 1) - events:SendMessage('bagbutton/Updated', ctx, self) + events:SendMessage(ctx, 'bagbutton/Updated', self) end ---@param ctx Context function BagButtonFrame.bagButtonProto:ClearBag(ctx) - events:SendMessage('bagbutton/Clearing', ctx, self) + events:SendMessage(ctx, 'bagbutton/Clearing', self) self.masqueGroup = nil self.invID = nil self.bag = nil diff --git a/frames/bagslots.lua b/frames/bagslots.lua index ce91c5d6..8c7c4f95 100644 --- a/frames/bagslots.lua +++ b/frames/bagslots.lua @@ -136,12 +136,12 @@ function BagSlots:CreatePanel(ctx, kind) end database:SetPreviousView(kind, database:GetBagView(kind)) database:SetBagView(kind, const.BAG_VIEW.SECTION_ALL_BAGS) - events:SendMessage('bags/FullRefreshAll', ectx) + events:SendMessage(ectx, 'bags/FullRefreshAll') end) addon.HookScript(b.fadeOutGroup, "OnFinished", function(ectx) database:SetBagView(kind, database:GetPreviousView(kind)) - events:SendMessage('bags/FullRefreshAll', ectx) + events:SendMessage(ectx, 'bags/FullRefreshAll') end) events:RegisterEvent('BAG_CONTAINER_UPDATE', function(ectx) b:Draw(ectx) end) diff --git a/frames/classic/bag.lua b/frames/classic/bag.lua index 50508105..06204bf1 100644 --- a/frames/classic/bag.lua +++ b/frames/classic/bag.lua @@ -228,7 +228,7 @@ function bagFrame:Create(ctx, kind) b:OnUnlock(ectx, bagid, slotid) end) - events:RegisterMessage('search/SetInFrame', function (ectx, _, shown) + events:RegisterMessage('search/SetInFrame', function (ectx, shown) themes:SetSearchState(ectx, b.frame, shown) end) diff --git a/frames/classic/contextmenu.lua b/frames/classic/contextmenu.lua index 35461dbc..c99359c8 100644 --- a/frames/classic/contextmenu.lua +++ b/frames/classic/contextmenu.lua @@ -65,13 +65,13 @@ end ---@param menuList MenuList[] function contextMenu:Show(ctx, menuList) LibDD:EasyMenu(menuList, self.frame, 'cursor', 0, 0, 'MENU') - events:SendMessage('context/show', ctx) + events:SendMessage(ctx, 'context/show') end ---@param ctx Context function contextMenu:Hide(ctx) LibDD:HideDropDownMenu(1) - events:SendMessage('context/hide', ctx) + events:SendMessage(ctx, 'context/hide') end function contextMenu:AddDivider(menuList) @@ -269,7 +269,7 @@ function contextMenu:CreateContextMenu(bag) func = function() local ctx = context:New('OpenOptions') contextMenu:Hide(ctx) - events:SendMessage('config/Open', ctx) + events:SendMessage(ctx, 'config/Open') end }) diff --git a/frames/contextmenu.lua b/frames/contextmenu.lua index 982acbd9..c7499d49 100644 --- a/frames/contextmenu.lua +++ b/frames/contextmenu.lua @@ -65,13 +65,13 @@ end ---@param menuList MenuList[] function contextMenu:Show(ctx, menuList) LibDD:EasyMenu(menuList, self.frame, 'cursor', 0, 0, 'MENU') - events:SendMessage('context/show', ctx) + events:SendMessage(ctx, 'context/show') end ---@param ctx Context function contextMenu:Hide(ctx) LibDD:HideDropDownMenu(1) - events:SendMessage('context/hide', ctx) + events:SendMessage(ctx, 'context/hide') end function contextMenu:AddDivider(menuList) @@ -330,7 +330,7 @@ function contextMenu:CreateContextMenu(bag) func = function() local ctx = context:New('OpenOptions') contextMenu:Hide(ctx) - events:SendMessage('config/Open', ctx) + events:SendMessage(ctx, 'config/Open') end }) diff --git a/frames/debug.lua b/frames/debug.lua index 45ff50fa..45ed462b 100644 --- a/frames/debug.lua +++ b/frames/debug.lua @@ -81,9 +81,9 @@ function debugWindow:Create(ctx) local ectx = context:New('DebugFrameCloseClick') if e == "LeftButton" then database:SetDebugMode(false) - events:SendMessage('config/DebugMode', ectx, false) + events:SendMessage(ectx, 'config/DebugMode', false) elseif e == "RightButton" then - events:SendMessage('debug/ClearLog', ectx) + events:SendMessage(ectx, 'debug/ClearLog') end end) @@ -128,7 +128,7 @@ function debugWindow:AddLogLine(ctx, title, message) message=message }) self.rows = self.rows + 1 - events:SendMessage('debug/LogAdded', ctx) + events:SendMessage(ctx, 'debug/LogAdded') end ---CreateDebugLogFrame creates the frame for the debug log tab. diff --git a/frames/era/bag.lua b/frames/era/bag.lua index b466eff2..3fb6c8ef 100644 --- a/frames/era/bag.lua +++ b/frames/era/bag.lua @@ -322,7 +322,7 @@ function bagFrame:Create(ctx, kind) b:OnUnlock(ectx, bagid, slotid) end) - events:RegisterMessage('search/SetInFrame', function (ectx, _, shown) + events:RegisterMessage('search/SetInFrame', function (ectx, shown) themes:SetSearchState(ectx, b.frame, shown) end) diff --git a/frames/era/bagbutton.lua b/frames/era/bagbutton.lua index 1e9dafe4..9fcd1f83 100644 --- a/frames/era/bagbutton.lua +++ b/frames/era/bagbutton.lua @@ -58,7 +58,7 @@ function BagButtonFrame.bagButtonProto:SetBag(ctx, bag) --self.frame.ItemSlotBackground:Show() self.empty = true end - events:SendMessage('bagbutton/Updated', ctx, self) + events:SendMessage(ctx, 'bagbutton/Updated', self) --SetItemButtonTexture(self.frame, icon) --SetItemButtonQuality(self.frame, GetInventoryItemQuality("player", self.invID)) --SetItemButtonCount(self.frame, 1) @@ -66,7 +66,7 @@ end ---@param ctx Context function BagButtonFrame.bagButtonProto:ClearBag(ctx) - events:SendMessage('bagbutton/Clearing', ctx, self) + events:SendMessage(ctx, 'bagbutton/Clearing', self) self.masqueGroup = nil self.invID = nil self.bag = nil diff --git a/frames/era/bagslots.lua b/frames/era/bagslots.lua index 4c6e02f3..a0694a4a 100644 --- a/frames/era/bagslots.lua +++ b/frames/era/bagslots.lua @@ -81,12 +81,12 @@ function BagSlots:CreatePanel(ctx, kind) end database:SetPreviousView(kind, database:GetBagView(kind)) database:SetBagView(kind, const.BAG_VIEW.SECTION_ALL_BAGS) - events:SendMessage('bags/FullRefreshAll', ectx) + events:SendMessage(ectx, 'bags/FullRefreshAll') end) b.fadeOutGroup:HookScript("OnFinished", function() local ectx = context:New('bag_slots_fade_out_finished') database:SetBagView(kind, database:GetPreviousView(kind)) - events:SendMessage('bags/FullRefreshAll', ectx) + events:SendMessage(ectx, 'bags/FullRefreshAll') end) events:RegisterEvent("BAG_CONTAINER_UPDATE", function(ectx) b:Draw(ectx) end) b.kind = kind diff --git a/frames/era/contextmenu.lua b/frames/era/contextmenu.lua index 4e2320cc..933a1de9 100644 --- a/frames/era/contextmenu.lua +++ b/frames/era/contextmenu.lua @@ -65,13 +65,13 @@ end ---@param menuList MenuList[] function contextMenu:Show(ctx, menuList) LibDD:EasyMenu(menuList, self.frame, 'cursor', 0, 0, 'MENU') - events:SendMessage('context/show', ctx) + events:SendMessage(ctx, 'context/show') end ---@param ctx Context function contextMenu:Hide(ctx) LibDD:HideDropDownMenu(1) - events:SendMessage('context/hide', ctx) + events:SendMessage(ctx, 'context/hide') end function contextMenu:AddDivider(menuList) @@ -257,7 +257,7 @@ function contextMenu:CreateContextMenu(bag) func = function() local ctx = context:New('OpenOptionsScreen') contextMenu:Hide(ctx) - events:SendMessage('config/Open', ctx) + events:SendMessage(ctx, 'config/Open') end }) diff --git a/frames/era/item.lua b/frames/era/item.lua index 02ee708a..b32b7652 100644 --- a/frames/era/item.lua +++ b/frames/era/item.lua @@ -167,7 +167,7 @@ function itemFrame.itemProto:SetItemFromData(ctx, data) self.isFreeSlot = nil self:SetAlpha(1) if self.slotkey ~= nil then - events:SendMessage('item/Updated', ctx, self, decoration) + events:SendMessage(ctx, 'item/Updated', self, decoration) end self:UpdateUpgrade(ctx) self.frame:Show() @@ -222,7 +222,7 @@ function itemFrame.itemProto:SetFreeSlots(ctx, bagid, slotid, count) decoration.IconBorder:SetBlendMode("BLEND") self.frame:SetAlpha(1) - events:SendMessage('item/Updated', ctx, self, decoration) + events:SendMessage(ctx, 'item/Updated', self, decoration) self.frame:Show() self.button:Show() end @@ -230,7 +230,7 @@ end ---@param ctx Context function itemFrame.itemProto:ClearItem(ctx) local decoration = themes:GetItemButton(ctx, self) - events:SendMessage('item/Clearing', ctx, self, decoration) + events:SendMessage(ctx, 'item/Clearing', self, decoration) self.kind = nil self.frame:ClearAllPoints() self.frame:SetParent(nil) diff --git a/frames/era/itemrow.lua b/frames/era/itemrow.lua index bc9d789c..4ad96a8b 100644 --- a/frames/era/itemrow.lua +++ b/frames/era/itemrow.lua @@ -67,7 +67,7 @@ function item.itemRowProto:SetItemFromData(ctx, data, static) end) if self.slotkey ~= nil then - events:SendMessage('item/UpdatedRow', ctx, self) + events:SendMessage(ctx, 'item/UpdatedRow', self) end self.frame:Show() self.rowButton:Show() diff --git a/frames/grid.lua b/frames/grid.lua index ff597394..da569d75 100644 --- a/frames/grid.lua +++ b/frames/grid.lua @@ -188,7 +188,7 @@ function gridProto:DislocateCell(id) end ---@type string, ScriptRegion, string, number, number - local point, relativeTo, relativePoint, offsetX, offsetY = cell.frame:GetPoint(1) + local _, relativeTo, relativePoint, _, offsetY = cell.frame:GetPoint(1) ---@type string, ScriptRegion, string, number, number local _, _, rightRelativePoint, _, _ if rightCell then diff --git a/frames/item.lua b/frames/item.lua index c9badbef..c3ce1754 100644 --- a/frames/item.lua +++ b/frames/item.lua @@ -383,7 +383,7 @@ function itemFrame.itemProto:SetItemFromData(ctx, data) self.isFreeSlot = nil self:SetAlpha(1) if self.slotkey ~= nil then - events:SendMessage('item/Updated', ctx, self, decoration) + events:SendMessage(ctx, 'item/Updated', self, decoration) end decoration:SetFrameLevel(self.button:GetFrameLevel() - 1) self:UpdateUpgrade(ctx) @@ -559,7 +559,7 @@ function itemFrame.itemProto:SetFreeSlots(ctx, bagid, slotid, count, nocount) self.isFreeSlot = true decoration.ItemSlotBackground:Show() self.frame:SetAlpha(1) - events:SendMessage('item/Updated', ctx, self, decoration) + events:SendMessage(ctx, 'item/Updated', self, decoration) self.frame:Show() self.button:Show() end @@ -606,7 +606,7 @@ end ---@param ctx Context function itemFrame.itemProto:ClearItem(ctx) local decoration = themes:GetItemButton(ctx, self) - events:SendMessage('item/Clearing', ctx, self, decoration) + events:SendMessage(ctx, 'item/Clearing', self, decoration) self.kind = nil self.frame:ClearAllPoints() self.frame:SetParent(nil) diff --git a/frames/itemrow.lua b/frames/itemrow.lua index a26574c9..0dbeb250 100644 --- a/frames/itemrow.lua +++ b/frames/itemrow.lua @@ -119,7 +119,7 @@ function item.itemRowProto:SetItemFromData(ctx, data, static) end) if self.slotkey ~= nil then - events:SendMessage('item/UpdatedRow', ctx, self) + events:SendMessage(ctx, 'item/UpdatedRow', self) end self.frame:Show() self.rowButton:Show() @@ -133,7 +133,7 @@ end ---@param ctx Context function item.itemRowProto:ClearItem(ctx) - events:SendMessage('item/ClearingRow', ctx, self) + events:SendMessage(ctx, 'item/ClearingRow', self) self.button:ClearItem(ctx) self.rowButton:SetID(0) diff --git a/frames/overlay.lua b/frames/overlay.lua index 4ab715c6..07aa6464 100644 --- a/frames/overlay.lua +++ b/frames/overlay.lua @@ -26,7 +26,7 @@ function overlayFrame:Show(ctx, event) self.frame:Show() self.frame:SetAlpha(1) if event then - events:SendMessage(event, ctx) + events:SendMessage(ctx, event) end end self.fadeIn:Play() @@ -38,7 +38,7 @@ function overlayFrame:Hide(ctx, event) self.fadeOut.callback = function() self.fadeOut.callback = nil if event then - events:SendMessage(event, ctx) + events:SendMessage(ctx, event) end end self.fadeOut:Play() diff --git a/frames/searchcategory.lua b/frames/searchcategory.lua index 791264ef..980e155d 100644 --- a/frames/searchcategory.lua +++ b/frames/searchcategory.lua @@ -139,7 +139,7 @@ function searchCategoryConfig:OnEnable() categories:DeleteCategory(ctx, self.openedName) end self.openedName = nil - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') self.fadeOutGroup:Play() end) diff --git a/frames/section.lua b/frames/section.lua index 7e621b57..99ccc1e3 100644 --- a/frames/section.lua +++ b/frames/section.lua @@ -261,7 +261,7 @@ function sectionFrame:OnTitleClickOrDrop(ctx, section) local category = section.title:GetText() categories:AddPermanentItemToCategory(ctx, itemID, category) ClearCursor() - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end ---@param section Section diff --git a/frames/sectionconfig.lua b/frames/sectionconfig.lua index 03b93abf..87010ff2 100644 --- a/frames/sectionconfig.lua +++ b/frames/sectionconfig.lua @@ -90,7 +90,7 @@ function sectionConfigFrame:OnReceiveDrag(ctx, category) ClearCursor() local itemid = tonumber(id) --[[@as number]] categories:AddPermanentItemToCategory(ctx, itemid, category) - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') return true end @@ -312,7 +312,7 @@ function sectionConfigFrame:initSectionItem(button, elementData) button:SetBackdropColor(1, 1, 0, .2) end end - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end end) end @@ -451,7 +451,7 @@ function sectionConfig:Create(kind, parent) sc.content.dragBehavior:SetFinalizeDrop(function(_) local ctx = context:New('SectionConfigFrame_FinalizeDrop') sc:UpdatePinnedItems() - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end) sc.content:SetCanReorder(true) @@ -473,7 +473,7 @@ function sectionConfig:Create(kind, parent) end sc:UpdatePinnedItems() - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end) end sc.content:AddToStart({ title = "Pinned", header = true }) diff --git a/frames/sectionitemlist.lua b/frames/sectionitemlist.lua index 54c529ac..61c44f12 100644 --- a/frames/sectionitemlist.lua +++ b/frames/sectionitemlist.lua @@ -91,7 +91,7 @@ function sectionItemListFrame:OnReceiveDrag(ctx) ClearCursor() local itemid = tonumber(id) --[[@as number]] categories:AddPermanentItemToCategory(ctx, itemid, self.currentCategory) - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end ---@param ctx Context @@ -109,7 +109,7 @@ function sectionItemListFrame:OnItemClick(ctx, b, elementData) hasArrow = false, func = function() database:DeleteItemFromCategory(elementData.data.itemInfo.itemID, elementData.category) - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end }}) end diff --git a/themes/themes.lua b/themes/themes.lua index 73e9056a..28b4be5e 100644 --- a/themes/themes.lua +++ b/themes/themes.lua @@ -171,7 +171,7 @@ function themes:ApplyTheme(ctx, key) --TODO(lobato): Create a new message just for redrawing items. - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end -- SetSearchState will show or hide the search bar for the given frame. @@ -181,7 +181,7 @@ end function themes:SetSearchState(ctx, frame, shown) local theme = self.themes[db:GetTheme()] theme.ToggleSearch(frame, shown) - events:SendMessage('bags/FullRefreshAll', ctx) + events:SendMessage(ctx, 'bags/FullRefreshAll') end -- RegisterPortraitWindow is used to register a protrait window frame to be themed by themes. @@ -286,11 +286,11 @@ function themes:GetItemButton(ctx, item) local button = self.itemButtons[buttonName] if button then button:Show() - events:SendMessage('item/NewButton', ctx, item, button) + events:SendMessage(ctx, 'item/NewButton', item, button) return button end button = themes.CreateBlankItemButtonDecoration(item.frame, "default", buttonName) - events:SendMessage('item/NewButton', ctx, item, button) + events:SendMessage(ctx, 'item/NewButton', item, button) self.itemButtons[buttonName] = button return button end diff --git a/views/bagview.lua b/views/bagview.lua index aa44a16a..4063da9d 100644 --- a/views/bagview.lua +++ b/views/bagview.lua @@ -77,23 +77,6 @@ local function ClearButton(ctx, view, item) addon:GetBagFromBagID(bagid).drawOnClose = true end --- UpdateDeletedSlot updates the slot key of a deleted slot, while maintaining the --- button position and section to prevent a sort from happening. ----@param ctx Context ----@param view View ----@param oldSlotKey string ----@param newSlotKey string -local function UpdateDeletedSlot(ctx, view, oldSlotKey, newSlotKey) - local oldSlotCell = view.itemsByBagAndSlot[oldSlotKey] - local oldSlotSection = view:GetSlotSection(oldSlotKey) - oldSlotSection:RekeyCell(oldSlotKey, newSlotKey) - oldSlotCell:SetItem(ctx, newSlotKey) - view.itemsByBagAndSlot[newSlotKey] = oldSlotCell - view.itemsByBagAndSlot[oldSlotKey] = nil - view:SetSlotSection(newSlotKey, oldSlotSection) - view:RemoveSlotSection(oldSlotKey) -end - -- CreateButton creates a button for an item and adds it to the view. ---@param ctx Context ---@param view View