From c5b29e565a1740372285b0b92320065c4ac61b04 Mon Sep 17 00:00:00 2001 From: Antonio Lobato Date: Fri, 1 Dec 2023 21:33:49 -0800 Subject: [PATCH] added animation effect for first time bag users --- core/constants.lua | 1 + core/database.lua | 8 ++++++++ frames/bag.lua | 50 ++++++++++++++++++++++++++++++++++++---------- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/core/constants.lua b/core/constants.lua index 428e6df3..36a97f4c 100644 --- a/core/constants.lua +++ b/core/constants.lua @@ -189,6 +189,7 @@ const.TRADESKILL_MAP = { ---@class databaseOptions const.DATABASE_DEFAULTS = { profile = { + firstTimeMenu = true, enabled = true, showBagButton = true, itemLevel = { diff --git a/core/database.lua b/core/database.lua index d7b2192e..7c868265 100644 --- a/core/database.lua +++ b/core/database.lua @@ -117,4 +117,12 @@ function DB:SetItemLevelColorEnabled(kind, enabled) DB.data.profile.itemLevel[kind].color = enabled end +function DB:GetFirstTimeMenu() + return DB.data.profile.firstTimeMenu +end + +function DB:SetFirstTimeMenu(value) + DB.data.profile.firstTimeMenu = value +end + DB:Enable() diff --git a/frames/bag.lua b/frames/bag.lua index fea89d8b..282e82e3 100644 --- a/frames/bag.lua +++ b/frames/bag.lua @@ -309,15 +309,37 @@ function bagFrame:Create(kind) b.moneyFrame = moneyFrame end + -- Setup the context menu. + local contextMenu = context:CreateContextMenu(b) + -- Create the invisible menu button. local bagButton = CreateFrame("Button") bagButton:EnableMouse(true) bagButton:SetParent(b.frame.PortraitContainer) - bagButton:SetHighlightTexture([[Interface\AddOns\BetterBags\Textures\glow.png]]) + --bagButton:SetHighlightTexture([[Interface\AddOns\BetterBags\Textures\glow.png]]) bagButton:SetWidth(40) bagButton:SetHeight(40) bagButton:SetPoint("TOPLEFT", b.frame.PortraitContainer, "TOPLEFT", -6, 2) + local highlightTex = bagButton:CreateTexture("BetterBagsBagButtonTextureHighlight", "BACKGROUND") + highlightTex:SetTexture([[Interface\AddOns\BetterBags\Textures\glow.png]]) + highlightTex:SetAllPoints() + highlightTex:SetAlpha(0) + local anig = highlightTex:CreateAnimationGroup("BetterBagsBagButtonTextureHighlightAnim") + local ani = anig:CreateAnimation("Alpha") + ani:SetFromAlpha(0) + ani:SetToAlpha(1) + ani:SetDuration(0.2) + ani:SetSmoothing("IN") + if database:GetFirstTimeMenu() then + ani:SetDuration(0.4) + anig:SetLooping("BOUNCE") + anig:Play() + end bagButton:SetScript("OnEnter", function() + if not database:GetFirstTimeMenu() then + highlightTex:SetAlpha(1) + anig:Restart() + end GameTooltip:SetOwner(bagButton, "ANCHOR_LEFT") if kind == const.BAG_KIND.BACKPACK then GameTooltip:SetText(L:G("Left Click to open the menu.")) @@ -328,8 +350,25 @@ function bagFrame:Create(kind) end) bagButton:SetScript("OnLeave", function() GameTooltip:Hide() + if not database:GetFirstTimeMenu() then + highlightTex:SetAlpha(0) + anig:Restart(true) + end end) bagButton:RegisterForClicks("LeftButtonUp", "RightButtonUp") + bagButton:SetScript("OnClick", function(_, e) + if e == "LeftButton" then + if database:GetFirstTimeMenu() then + database:SetFirstTimeMenu(false) + highlightTex:SetAlpha(1) + anig:SetLooping("NONE") + anig:Restart() + end + context:Show(contextMenu) + else + b:ToggleReagentBank() + end + end) -- Create the bag content frame. local content = grid:Create(b.frame) @@ -413,15 +452,6 @@ function bagFrame:Create(kind) -- Load the bag position from settings. Window.RestorePosition(b.frame) - -- Setup the context menu. - local contextMenu = context:CreateContextMenu(b) - bagButton:SetScript("OnClick", function(_, e) - if e == "LeftButton" then - context:Show(contextMenu) - else - b:ToggleReagentBank() - end - end) b.resizeHandle = resize:MakeResizable(b.frame, function() local fw, fh = b.frame:GetSize() database:SetBagViewFrameSize(b.kind, database:GetBagView(b.kind), fw, fh)