Skip to content

Commit

Permalink
added animation effect for first time bag users
Browse files Browse the repository at this point in the history
  • Loading branch information
Cidan committed Dec 2, 2023
1 parent 99c9854 commit c5b29e5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 10 deletions.
1 change: 1 addition & 0 deletions core/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const.TRADESKILL_MAP = {
---@class databaseOptions
const.DATABASE_DEFAULTS = {
profile = {
firstTimeMenu = true,
enabled = true,
showBagButton = true,
itemLevel = {
Expand Down
8 changes: 8 additions & 0 deletions core/database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
50 changes: 40 additions & 10 deletions frames/bag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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."))
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c5b29e5

Please sign in to comment.