fix: dropdown
This commit is contained in:
+61
-196
@@ -112,6 +112,9 @@ end
|
|||||||
|
|
||||||
-- OnHide
|
-- OnHide
|
||||||
function Guda_BagFrame_OnHide(self)
|
function Guda_BagFrame_OnHide(self)
|
||||||
|
-- Close any open dropdown menus when the bag frame is hidden
|
||||||
|
CloseDropDownMenus()
|
||||||
|
|
||||||
-- Clean up all buttons when frame is hidden (safe since we're not displaying)
|
-- Clean up all buttons when frame is hidden (safe since we're not displaying)
|
||||||
for _, bagParent in pairs(bagParents) do
|
for _, bagParent in pairs(bagParents) do
|
||||||
if bagParent then
|
if bagParent then
|
||||||
@@ -1452,71 +1455,58 @@ function Guda_BagFrame_ToggleCharacterDropdown(button)
|
|||||||
ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0)
|
ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Hide dropdown when clicking elsewhere
|
-- Mailbox character dropdown
|
||||||
local function HideCharacterDropdown()
|
local function Guda_BagMailboxMenu_Initialize()
|
||||||
-- Handled by UIDropDownMenu system
|
local characters = addon.Modules.DB:GetAllCharacters(false, true)
|
||||||
|
local info
|
||||||
|
|
||||||
|
for i, char in ipairs(characters) do
|
||||||
|
local charFullName = char.fullName
|
||||||
|
local charClassToken = char.classToken
|
||||||
|
|
||||||
|
-- Get class color
|
||||||
|
local classColor = charClassToken and RAID_CLASS_COLORS[charClassToken]
|
||||||
|
local r, g, b = 1, 1, 1
|
||||||
|
if classColor then
|
||||||
|
r, g, b = classColor.r, classColor.g, classColor.b
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Create colored name
|
||||||
|
local coloredName = addon.Modules.Utils:ColorText(char.name, r, g, b)
|
||||||
|
|
||||||
|
info = {}
|
||||||
|
info.text = coloredName
|
||||||
|
info.func = function()
|
||||||
|
addon.Modules.MailboxFrame:ShowCharacter(charFullName)
|
||||||
|
if not Guda_MailboxFrame:IsShown() then
|
||||||
|
Guda_MailboxFrame:Show()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local mailboxViewChar = addon.Modules.MailboxFrame:GetCurrentViewChar()
|
||||||
|
info.checked = (mailboxViewChar == charFullName or (not mailboxViewChar and charFullName == addon.Modules.DB:GetPlayerFullName()))
|
||||||
|
UIDropDownMenu_AddButton(info)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Toggle mail dropdown
|
-- Toggle mail dropdown
|
||||||
function Guda_BagFrame_ToggleMailDropdown(button)
|
function Guda_BagFrame_ToggleMailDropdown(button)
|
||||||
if mailDropdown and mailDropdown:IsShown() then
|
local menuFrame = getglobal("Guda_BagMailboxMenu")
|
||||||
mailDropdown:Hide()
|
if not menuFrame then
|
||||||
return
|
menuFrame = CreateFrame("Frame", "Guda_BagMailboxMenu", UIParent, "UIDropDownMenuTemplate")
|
||||||
end
|
end
|
||||||
|
UIDropDownMenu_Initialize(menuFrame, Guda_BagMailboxMenu_Initialize, "MENU")
|
||||||
|
ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0)
|
||||||
|
end
|
||||||
|
|
||||||
if not mailDropdown then
|
-- Bank character dropdown
|
||||||
-- Create dropdown frame
|
local function Guda_BagBankMenu_Initialize()
|
||||||
mailDropdown = CreateFrame("Frame", "Guda_MailDropdown", UIParent)
|
local characters = addon.Modules.DB:GetAllCharacters(false, true)
|
||||||
mailDropdown:SetFrameStrata("DIALOG")
|
local info
|
||||||
mailDropdown:SetWidth(200)
|
|
||||||
mailDropdown:SetBackdrop({
|
|
||||||
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
|
|
||||||
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
|
|
||||||
tile = true,
|
|
||||||
tileSize = 16,
|
|
||||||
edgeSize = 16,
|
|
||||||
insets = { left = 4, right = 4, top = 4, bottom = 4 }
|
|
||||||
})
|
|
||||||
mailDropdown:SetBackdropColor(0, 0, 0, 0.95)
|
|
||||||
mailDropdown:EnableMouse(true)
|
|
||||||
mailDropdown:Hide()
|
|
||||||
|
|
||||||
mailDropdown.buttons = {}
|
for i, char in ipairs(characters) do
|
||||||
end
|
|
||||||
|
|
||||||
-- Position dropdown below the button
|
|
||||||
mailDropdown:ClearAllPoints()
|
|
||||||
mailDropdown:SetPoint("TOPLEFT", button, "BOTTOMLEFT", 0, -2)
|
|
||||||
-- Clear existing buttons
|
|
||||||
for _, btn in ipairs(mailDropdown.buttons) do
|
|
||||||
btn:Hide()
|
|
||||||
end
|
|
||||||
mailDropdown.buttons = {}
|
|
||||||
|
|
||||||
-- Get all characters on current realm
|
|
||||||
local chars = addon.Modules.DB:GetAllCharacters(false, true)
|
|
||||||
|
|
||||||
local yOffset = -8
|
|
||||||
|
|
||||||
-- Add character buttons
|
|
||||||
for _, char in ipairs(chars) do
|
|
||||||
-- Capture variables in local scope for closure
|
|
||||||
local charFullName = char.fullName
|
local charFullName = char.fullName
|
||||||
local charName = char.name
|
|
||||||
local charClassToken = char.classToken
|
local charClassToken = char.classToken
|
||||||
|
|
||||||
local charButton = CreateFrame("Button", nil, mailDropdown)
|
|
||||||
charButton:SetWidth(188)
|
|
||||||
charButton:SetHeight(20)
|
|
||||||
charButton:SetPoint("TOP", mailDropdown, "TOP", 0, yOffset)
|
|
||||||
|
|
||||||
-- Button background on hover
|
|
||||||
local charBg = charButton:CreateTexture(nil, "BACKGROUND")
|
|
||||||
charBg:SetAllPoints()
|
|
||||||
charBg:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
|
|
||||||
charBg:SetBlendMode("ADD")
|
|
||||||
charBg:SetAlpha(0)
|
|
||||||
|
|
||||||
-- Get class color
|
-- Get class color
|
||||||
local classColor = charClassToken and RAID_CLASS_COLORS[charClassToken]
|
local classColor = charClassToken and RAID_CLASS_COLORS[charClassToken]
|
||||||
local r, g, b = 1, 1, 1
|
local r, g, b = 1, 1, 1
|
||||||
@@ -1524,154 +1514,29 @@ function Guda_BagFrame_ToggleMailDropdown(button)
|
|||||||
r, g, b = classColor.r, classColor.g, classColor.b
|
r, g, b = classColor.r, classColor.g, classColor.b
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Button text
|
-- Create colored name
|
||||||
local charText = charButton:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
|
local charName = char.name
|
||||||
charText:SetPoint("LEFT", charButton, "LEFT", 8, 0)
|
local coloredName = addon.Modules.Utils:ColorText(charName, r, g, b)
|
||||||
charText:SetText(charName)
|
|
||||||
charText:SetTextColor(r, g, b)
|
|
||||||
|
|
||||||
-- Button scripts
|
info = {}
|
||||||
charButton:SetScript("OnEnter", function()
|
info.text = coloredName
|
||||||
charBg:SetAlpha(0.3)
|
info.func = function()
|
||||||
end)
|
Guda_BagFrame_ShowCharacterBank(charFullName, charName)
|
||||||
charButton:SetScript("OnLeave", function()
|
end
|
||||||
charBg:SetAlpha(0)
|
local bankViewChar = addon.Modules.BankFrame:GetCurrentViewChar()
|
||||||
end)
|
info.checked = (bankViewChar == charFullName or (not bankViewChar and charFullName == addon.Modules.DB:GetPlayerFullName()))
|
||||||
charButton:SetScript("OnClick", function()
|
UIDropDownMenu_AddButton(info)
|
||||||
if charFullName then
|
|
||||||
-- Show mailbox for this character
|
|
||||||
addon.Modules.MailboxFrame:ShowCharacter(charFullName)
|
|
||||||
if not Guda_MailboxFrame:IsShown() then
|
|
||||||
Guda_MailboxFrame:Show()
|
|
||||||
end
|
|
||||||
mailDropdown:Hide()
|
|
||||||
else
|
|
||||||
addon:Print("Error: Character fullName is nil")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
table.insert(mailDropdown.buttons, charButton)
|
|
||||||
yOffset = yOffset - 20
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set dropdown height based on content
|
|
||||||
mailDropdown:SetHeight(math.abs(yOffset) + 8)
|
|
||||||
|
|
||||||
-- Show dropdown
|
|
||||||
mailDropdown:Show()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Toggle bank dropdown
|
-- Toggle bank dropdown
|
||||||
function Guda_BagFrame_ToggleBankDropdown(button)
|
function Guda_BagFrame_ToggleBankDropdown(button)
|
||||||
-- Hide character dropdown if it's shown
|
local menuFrame = getglobal("Guda_BagBankMenu")
|
||||||
if characterDropdown and characterDropdown:IsShown() then
|
if not menuFrame then
|
||||||
characterDropdown:Hide()
|
menuFrame = CreateFrame("Frame", "Guda_BagBankMenu", UIParent, "UIDropDownMenuTemplate")
|
||||||
end
|
end
|
||||||
|
UIDropDownMenu_Initialize(menuFrame, Guda_BagBankMenu_Initialize, "MENU")
|
||||||
if bankDropdown and bankDropdown:IsShown() then
|
ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0)
|
||||||
bankDropdown:Hide()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if not bankDropdown then
|
|
||||||
-- Create dropdown frame
|
|
||||||
bankDropdown = CreateFrame("Frame", "Guda_BankDropdown", UIParent)
|
|
||||||
bankDropdown:SetFrameStrata("DIALOG")
|
|
||||||
bankDropdown:SetWidth(200)
|
|
||||||
bankDropdown:SetBackdrop({
|
|
||||||
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
|
|
||||||
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
|
|
||||||
tile = true,
|
|
||||||
tileSize = 16,
|
|
||||||
edgeSize = 16,
|
|
||||||
insets = { left = 4, right = 4, top = 4, bottom = 4 }
|
|
||||||
})
|
|
||||||
bankDropdown:SetBackdropColor(0, 0, 0, 0.95)
|
|
||||||
bankDropdown:EnableMouse(true)
|
|
||||||
bankDropdown:Hide()
|
|
||||||
|
|
||||||
bankDropdown.buttons = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Position dropdown below the button
|
|
||||||
bankDropdown:ClearAllPoints()
|
|
||||||
bankDropdown:SetPoint("TOPLEFT", button, "BOTTOMLEFT", 0, -2)
|
|
||||||
-- Clear existing buttons
|
|
||||||
for _, btn in ipairs(bankDropdown.buttons) do
|
|
||||||
btn:Hide()
|
|
||||||
end
|
|
||||||
bankDropdown.buttons = {}
|
|
||||||
|
|
||||||
-- Get all characters on current realm
|
|
||||||
local chars = addon.Modules.DB:GetAllCharacters(false, true)
|
|
||||||
|
|
||||||
local yOffset = -8
|
|
||||||
|
|
||||||
-- Add character buttons
|
|
||||||
for _, char in ipairs(chars) do
|
|
||||||
-- Capture variables in local scope for closure
|
|
||||||
local charFullName = char.fullName
|
|
||||||
local charName = char.name
|
|
||||||
local charMoney = char.money or 0
|
|
||||||
local charClassToken = char.classToken
|
|
||||||
|
|
||||||
local charButton = CreateFrame("Button", nil, bankDropdown)
|
|
||||||
charButton:SetWidth(188)
|
|
||||||
charButton:SetHeight(20)
|
|
||||||
charButton:SetPoint("TOP", bankDropdown, "TOP", 0, yOffset)
|
|
||||||
|
|
||||||
-- Button background on hover
|
|
||||||
local charBg = charButton:CreateTexture(nil, "BACKGROUND")
|
|
||||||
charBg:SetAllPoints()
|
|
||||||
charBg:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
|
|
||||||
charBg:SetBlendMode("ADD")
|
|
||||||
charBg:SetAlpha(0)
|
|
||||||
|
|
||||||
-- Get class color
|
|
||||||
local classColor = charClassToken and RAID_CLASS_COLORS[charClassToken]
|
|
||||||
local r, g, b = 1, 1, 1
|
|
||||||
if classColor then
|
|
||||||
r, g, b = classColor.r, classColor.g, classColor.b
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Button text
|
|
||||||
local charText = charButton:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
|
|
||||||
charText:SetPoint("LEFT", charButton, "LEFT", 8, 0)
|
|
||||||
charText:SetText(charName)
|
|
||||||
charText:SetTextColor(r, g, b)
|
|
||||||
|
|
||||||
-- Money text
|
|
||||||
local moneyText = charButton:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
|
|
||||||
moneyText:SetPoint("RIGHT", charButton, "RIGHT", -8, 0)
|
|
||||||
moneyText:SetText(addon.Modules.Utils:FormatMoney(charMoney))
|
|
||||||
moneyText:SetTextColor(0.7, 0.7, 0.7)
|
|
||||||
|
|
||||||
-- Button scripts
|
|
||||||
charButton:SetScript("OnEnter", function()
|
|
||||||
charBg:SetAlpha(0.3)
|
|
||||||
end)
|
|
||||||
charButton:SetScript("OnLeave", function()
|
|
||||||
charBg:SetAlpha(0)
|
|
||||||
end)
|
|
||||||
charButton:SetScript("OnClick", function()
|
|
||||||
if charFullName then
|
|
||||||
-- Show bank for this character
|
|
||||||
Guda_BagFrame_ShowCharacterBank(charFullName, charName)
|
|
||||||
bankDropdown:Hide()
|
|
||||||
else
|
|
||||||
addon:Print("Error: Character fullName is nil")
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
table.insert(bankDropdown.buttons, charButton)
|
|
||||||
yOffset = yOffset - 20
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set dropdown height based on content
|
|
||||||
bankDropdown:SetHeight(math.abs(yOffset) + 8)
|
|
||||||
|
|
||||||
-- Show dropdown
|
|
||||||
bankDropdown:Show()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Show character's bank
|
-- Show character's bank
|
||||||
|
|||||||
@@ -81,6 +81,18 @@ function Guda_BankFrame_OnShow(self)
|
|||||||
BankFrame:Update()
|
BankFrame:Update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- OnHide
|
||||||
|
function Guda_BankFrame_OnHide(self)
|
||||||
|
-- Close any open dropdown menus when the bank frame is hidden
|
||||||
|
CloseDropDownMenus()
|
||||||
|
|
||||||
|
-- Close the actual Blizzard bank too
|
||||||
|
local blizzardBankFrame = getglobal("BankFrame")
|
||||||
|
if blizzardBankFrame and blizzardBankFrame:IsShown() then
|
||||||
|
CloseBankFrame()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Toggle visibility
|
-- Toggle visibility
|
||||||
function BankFrame:Toggle()
|
function BankFrame:Toggle()
|
||||||
if Guda_BankFrame:IsShown() then
|
if Guda_BankFrame:IsShown() then
|
||||||
|
|||||||
+1
-5
@@ -648,11 +648,7 @@
|
|||||||
Guda_BankFrame_OnShow(this)
|
Guda_BankFrame_OnShow(this)
|
||||||
</OnShow>
|
</OnShow>
|
||||||
<OnHide>
|
<OnHide>
|
||||||
Guda_BankFrame:Hide()
|
Guda_BankFrame_OnHide(this)
|
||||||
-- Close the actual Blizzard bank too
|
|
||||||
if BankFrame and BankFrame:IsShown() then
|
|
||||||
CloseBankFrame()
|
|
||||||
end
|
|
||||||
</OnHide>
|
</OnHide>
|
||||||
<OnMouseDown>
|
<OnMouseDown>
|
||||||
-- Clear search box focus when clicking on bank frame
|
-- Clear search box focus when clicking on bank frame
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ function Guda_MailboxFrame_OnShow(self)
|
|||||||
MailboxFrame:Update()
|
MailboxFrame:Update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- OnHide
|
||||||
|
function Guda_MailboxFrame_OnHide(self)
|
||||||
|
-- Close any open dropdown menus when the mailbox frame is hidden
|
||||||
|
CloseDropDownMenus()
|
||||||
|
end
|
||||||
|
|
||||||
-- Toggle visibility
|
-- Toggle visibility
|
||||||
function MailboxFrame:Toggle()
|
function MailboxFrame:Toggle()
|
||||||
if Guda_MailboxFrame:IsShown() then
|
if Guda_MailboxFrame:IsShown() then
|
||||||
@@ -71,6 +77,10 @@ function MailboxFrame:Toggle()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Show specific character's mailbox
|
-- Show specific character's mailbox
|
||||||
|
function MailboxFrame:GetCurrentViewChar()
|
||||||
|
return currentViewChar
|
||||||
|
end
|
||||||
|
|
||||||
function MailboxFrame:ShowCharacter(fullName)
|
function MailboxFrame:ShowCharacter(fullName)
|
||||||
currentViewChar = fullName
|
currentViewChar = fullName
|
||||||
currentPage = 1
|
currentPage = 1
|
||||||
|
|||||||
@@ -325,6 +325,9 @@
|
|||||||
<OnShow>
|
<OnShow>
|
||||||
Guda_MailboxFrame_OnShow(this)
|
Guda_MailboxFrame_OnShow(this)
|
||||||
</OnShow>
|
</OnShow>
|
||||||
|
<OnHide>
|
||||||
|
Guda_MailboxFrame_OnHide(this)
|
||||||
|
</OnHide>
|
||||||
<OnMouseDown>
|
<OnMouseDown>
|
||||||
this:StartMoving()
|
this:StartMoving()
|
||||||
</OnMouseDown>
|
</OnMouseDown>
|
||||||
|
|||||||
Reference in New Issue
Block a user