feat: cross acount, cross realm character tracking

This commit is contained in:
Vati
2026-04-06 15:30:26 +04:00
parent e40ef41602
commit daca27ca5c
11 changed files with 3626 additions and 181 deletions
+2
View File
@@ -328,6 +328,8 @@ function DB:GetAllCharacters(sameFactionOnly, currentRealmOnly)
faction = data.faction, faction = data.faction,
money = data.money, money = data.money,
lastUpdate = data.lastUpdate, lastUpdate = data.lastUpdate,
account = data.account,
isShared = data.isShared,
}) })
end end
end end
+5
View File
@@ -15,6 +15,11 @@ function Main:Initialize()
-- Initialize database -- Initialize database
addon.Modules.DB:Initialize() addon.Modules.DB:Initialize()
-- Initialize cross-account sharing (optional, requires GudaIO DLL)
if addon.Modules.SharedData then
addon.Modules.SharedData:Initialize()
end
-- Initialize item detection (before scanners, as they may use it) -- Initialize item detection (before scanners, as they may use it)
if addon.Modules.ItemDetection then if addon.Modules.ItemDetection then
addon.Modules.ItemDetection:Initialize() addon.Modules.ItemDetection:Initialize()
+83
View File
@@ -0,0 +1,83 @@
-- Guda SharedData Module
-- Cross-account character data sharing via GudaIO DLL (optional)
-- The DLL merges all accounts' SavedVariables at startup into GudaShared.lua
-- which is loaded via .toc and sets Guda_SharedCharacters global.
-- No Lua hooking needed - pure file I/O at DLL load time.
local addon = Guda
local SharedData = {}
addon.Modules.SharedData = SharedData
-- Import shared characters from other accounts
function SharedData:Initialize()
if not Guda_SharedCharacters or type(Guda_SharedCharacters) ~= "table" then
return
end
-- Determine current account by checking which characters are ours
-- (characters in Guda_DB.characters that don't have isShared flag)
local myChars = {}
if Guda_DB and Guda_DB.characters then
for fullName, data in pairs(Guda_DB.characters) do
if not data.isShared then
myChars[fullName] = true
end
end
end
-- Find which account name belongs to us by checking overlap
local myAccount = nil
local accountChars = {} -- account -> { fullName -> true }
for fullName, charData in pairs(Guda_SharedCharacters) do
local acct = charData.account
if acct then
if not accountChars[acct] then accountChars[acct] = {} end
accountChars[acct][fullName] = true
end
end
for acct, chars in pairs(accountChars) do
for fullName in pairs(chars) do
if myChars[fullName] then
myAccount = acct
break
end
end
if myAccount then break end
end
-- Import characters from other accounts
local importCount = 0
for fullName, charData in pairs(Guda_SharedCharacters) do
if charData.account and charData.account ~= myAccount then
-- Don't overwrite our own characters
if not myChars[fullName] then
Guda_DB.characters[fullName] = {
name = charData.name,
realm = charData.realm,
faction = charData.faction,
class = charData.class,
classToken = charData.classToken,
level = charData.level,
money = charData.money,
bags = charData.bags,
bank = charData.bank,
mailbox = charData.mailbox,
equipped = charData.equipped,
lastUpdate = charData.lastUpdate,
account = charData.account,
isShared = true,
}
importCount = importCount + 1
end
end
end
if importCount > 0 then
addon:Print("Imported " .. importCount .. " character(s) from other accounts")
end
-- Clean up the global to free memory
Guda_SharedCharacters = nil
end
+8 -1
View File
@@ -303,6 +303,7 @@ function Tooltip:AddInventoryInfo(tooltip, link)
entry.mailCount = mailCount entry.mailCount = mailCount
entry.equippedCount = equippedCount entry.equippedCount = equippedCount
entry.isCurrent = isCurrentChar entry.isCurrent = isCurrentChar
entry.isShared = charData.isShared
end end
end end
-- If charData is not a table (string, number, etc.), just skip it -- If charData is not a table (string, number, etc.), just skip it
@@ -338,8 +339,9 @@ function Tooltip:AddInventoryInfo(tooltip, link)
end end
tooltip:AddDoubleLine(totalText, breakdownText, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0) tooltip:AddDoubleLine(totalText, breakdownText, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
-- Sort with current character first -- Sort: own chars first (current char at top), then shared
table.sort(characterCounts, function(a, b) table.sort(characterCounts, function(a, b)
if a.isShared ~= b.isShared then return not a.isShared end
if a.isCurrent and not b.isCurrent then return true end if a.isCurrent and not b.isCurrent then return true end
if not a.isCurrent and b.isCurrent then return false end if not a.isCurrent and b.isCurrent then return false end
return a.name < b.name return a.name < b.name
@@ -347,7 +349,12 @@ function Tooltip:AddInventoryInfo(tooltip, link)
-- Reuse module-level parts table for per-character breakdown -- Reuse module-level parts table for per-character breakdown
local parts = _charParts local parts = _charParts
local sharedSeparatorShown = false
for _, charInfo in ipairs(characterCounts) do for _, charInfo in ipairs(characterCounts) do
if charInfo.isShared and not sharedSeparatorShown then
tooltip:AddLine("|cFF80C0FFOther Accounts|r")
sharedSeparatorShown = true
end
local r, g, b = GetClassColor(charInfo.classToken) local r, g, b = GetClassColor(charInfo.classToken)
local pIndex = 0 local pIndex = 0
+2
View File
@@ -8,11 +8,13 @@
## OptionalDeps: pfUI ## OptionalDeps: pfUI
Localization.lua Localization.lua
GudaShared.lua
Core\Init.lua Core\Init.lua
Core\Theme.lua Core\Theme.lua
Core\Constants.lua Core\Constants.lua
Core\Database.lua Core\Database.lua
Core\SharedData.lua
DB\QuestItems.lua DB\QuestItems.lua
Core\Events.lua Core\Events.lua
Core\Utils.lua Core\Utils.lua
+3141
View File
File diff suppressed because it is too large Load Diff
+288 -132
View File
@@ -2250,73 +2250,68 @@ function Guda_MoneyTooltip_Show(anchor)
local allChars = addon.Modules.DB:GetAllCharacters(false, false) -- all realms local allChars = addon.Modules.DB:GetAllCharacters(false, false) -- all realms
local totalMoney = 0 local totalMoney = 0
-- Group non-blacklisted characters by realm -- Group non-blacklisted characters by account, then by realm
local realms = {} local accounts = {} -- account -> { realms = { realm -> { chars, money } }, money, order }
local realmOrder = {} local accountOrder = {}
local myAccountLabel = "Current Account"
for _, char in ipairs(allChars) do for _, char in ipairs(allChars) do
if not addon.Modules.DB:IsGoldBlacklisted(char.fullName) then if not addon.Modules.DB:IsGoldBlacklisted(char.fullName) then
local realm = char.realm or "Unknown" local acctKey = char.isShared and (char.account or "Other") or myAccountLabel
if not realms[realm] then if not accounts[acctKey] then
realms[realm] = { chars = {}, money = 0 } accounts[acctKey] = { realms = {}, realmOrder = {}, money = 0 }
table.insert(realmOrder, realm) table.insert(accountOrder, acctKey)
end end
table.insert(realms[realm].chars, char) local acct = accounts[acctKey]
realms[realm].money = realms[realm].money + (char.money or 0) local realm = char.realm or "Unknown"
if not acct.realms[realm] then
acct.realms[realm] = { chars = {}, money = 0 }
table.insert(acct.realmOrder, realm)
end
table.insert(acct.realms[realm].chars, char)
acct.realms[realm].money = acct.realms[realm].money + (char.money or 0)
acct.money = acct.money + (char.money or 0)
totalMoney = totalMoney + (char.money or 0) totalMoney = totalMoney + (char.money or 0)
end end
end end
table.sort(realmOrder)
-- Sort: own account first, then others alphabetically
table.sort(accountOrder, function(a, b)
if a == myAccountLabel then return true end
if b == myAccountLabel then return false end
return a < b
end)
for _, acct in pairs(accounts) do
table.sort(acct.realmOrder)
end
-- Update header money -- Update header money
moneyTooltip.header:SetText("Total gold") moneyTooltip.header:SetText("Total gold")
MoneyFrame_Update("Guda_MoneyTooltip_Total", totalMoney) MoneyFrame_Update("Guda_MoneyTooltip_Total", totalMoney)
FormatMoneyFrameWithCommas("Guda_MoneyTooltip_Total") FormatMoneyFrameWithCommas("Guda_MoneyTooltip_Total")
-- Layout rows: realm headers + character rows -- Layout rows
local rowHeight = 18 local rowHeight = 18
local padding = 10 local padding = 10
local yOffset = -10 - 20 - 14 -- top padding + header height + gap local yOffset = -10 - 20 - 14 -- top padding + header height + gap
local rowIndex = 0 local rowIndex = 0
local hasMultipleAccounts = table.getn(accountOrder) > 1
for _, realm in ipairs(realmOrder) do for _, acctKey in ipairs(accountOrder) do
local realmData = realms[realm] local acctData = accounts[acctKey]
-- Realm header row -- Account header (only show if multiple accounts exist)
rowIndex = rowIndex + 1 if hasMultipleAccounts then
local row = GetOrCreateMoneyRow(rowIndex)
row.label:SetTextColor(1, 0.82, 0) -- gold color for realm header
row.label:SetText(realm)
row.label:ClearAllPoints()
row.label:SetPoint("TOPLEFT", moneyTooltip, "TOPLEFT", padding, yOffset)
row.label:Show()
local frameName = "Guda_MoneyTooltip_Row" .. rowIndex
MoneyFrame_Update(frameName, realmData.money)
FormatMoneyFrameWithCommas(frameName)
row.money:ClearAllPoints()
row.money:SetPoint("TOPRIGHT", moneyTooltip, "TOPRIGHT", -padding, yOffset)
row.money:Show()
yOffset = yOffset - rowHeight
-- Character rows (indented)
for _, char in ipairs(realmData.chars) do
rowIndex = rowIndex + 1 rowIndex = rowIndex + 1
row = GetOrCreateMoneyRow(rowIndex) local row = GetOrCreateMoneyRow(rowIndex)
row.label:SetTextColor(0.5, 0.8, 1) -- light blue for account header
local classToken = char.classToken row.label:SetText(acctKey)
local classColor = classToken and (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[classToken]
local r, g, b = 0.7, 0.7, 0.7
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
row.label:SetTextColor(r, g, b)
row.label:SetText(" " .. char.name)
row.label:ClearAllPoints() row.label:ClearAllPoints()
row.label:SetPoint("TOPLEFT", moneyTooltip, "TOPLEFT", padding, yOffset) row.label:SetPoint("TOPLEFT", moneyTooltip, "TOPLEFT", padding, yOffset)
row.label:Show() row.label:Show()
frameName = "Guda_MoneyTooltip_Row" .. rowIndex local frameName = "Guda_MoneyTooltip_Row" .. rowIndex
MoneyFrame_Update(frameName, char.money or 0) MoneyFrame_Update(frameName, acctData.money)
FormatMoneyFrameWithCommas(frameName) FormatMoneyFrameWithCommas(frameName)
row.money:ClearAllPoints() row.money:ClearAllPoints()
row.money:SetPoint("TOPRIGHT", moneyTooltip, "TOPRIGHT", -padding, yOffset) row.money:SetPoint("TOPRIGHT", moneyTooltip, "TOPRIGHT", -padding, yOffset)
@@ -2324,6 +2319,56 @@ function Guda_MoneyTooltip_Show(anchor)
yOffset = yOffset - rowHeight yOffset = yOffset - rowHeight
end end
local indent = hasMultipleAccounts and " " or ""
for _, realm in ipairs(acctData.realmOrder) do
local realmData = acctData.realms[realm]
-- Realm header row
rowIndex = rowIndex + 1
local row = GetOrCreateMoneyRow(rowIndex)
row.label:SetTextColor(1, 0.82, 0) -- gold color for realm header
row.label:SetText(indent .. realm)
row.label:ClearAllPoints()
row.label:SetPoint("TOPLEFT", moneyTooltip, "TOPLEFT", padding, yOffset)
row.label:Show()
local frameName = "Guda_MoneyTooltip_Row" .. rowIndex
MoneyFrame_Update(frameName, realmData.money)
FormatMoneyFrameWithCommas(frameName)
row.money:ClearAllPoints()
row.money:SetPoint("TOPRIGHT", moneyTooltip, "TOPRIGHT", -padding, yOffset)
row.money:Show()
yOffset = yOffset - rowHeight
-- Character rows
for _, char in ipairs(realmData.chars) do
rowIndex = rowIndex + 1
row = GetOrCreateMoneyRow(rowIndex)
local classToken = char.classToken
local classColor = classToken and (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[classToken]
local r, g, b = 0.7, 0.7, 0.7
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
row.label:SetTextColor(r, g, b)
row.label:SetText(indent .. " " .. char.name)
row.label:ClearAllPoints()
row.label:SetPoint("TOPLEFT", moneyTooltip, "TOPLEFT", padding, yOffset)
row.label:Show()
frameName = "Guda_MoneyTooltip_Row" .. rowIndex
MoneyFrame_Update(frameName, char.money or 0)
FormatMoneyFrameWithCommas(frameName)
row.money:ClearAllPoints()
row.money:SetPoint("TOPRIGHT", moneyTooltip, "TOPRIGHT", -padding, yOffset)
row.money:Show()
yOffset = yOffset - rowHeight
end
end
end end
-- Hide unused rows -- Hide unused rows
@@ -2374,39 +2419,107 @@ function Guda_MoneyTooltip_Hide()
end end
end end
-- Gold tracking dropdown menu (grouped by realm) -- Gold tracking dropdown menu (grouped by account > realm > characters)
local function Guda_GoldTrackingMenu_Initialize() local function Guda_GoldTrackingMenu_Initialize()
local characters = addon.Modules.DB:GetAllCharacters(false, false) -- all realms local characters = addon.Modules.DB:GetAllCharacters(false, false) -- all realms
local myAccountLabel = "Current Account"
-- Group characters by realm -- Group by account, then realm
local realms = {} local accounts = {}
local realmOrder = {} local accountOrder = {}
for _, char in ipairs(characters) do for _, char in ipairs(characters) do
local realm = char.realm or "Unknown" local acctKey = char.isShared and (char.account or "Other") or myAccountLabel
if not realms[realm] then if not accounts[acctKey] then
realms[realm] = {} accounts[acctKey] = { realms = {}, realmOrder = {} }
table.insert(realmOrder, realm) table.insert(accountOrder, acctKey)
end end
table.insert(realms[realm], char) local acct = accounts[acctKey]
local realm = char.realm or "Unknown"
if not acct.realms[realm] then
acct.realms[realm] = {}
table.insert(acct.realmOrder, realm)
end
table.insert(acct.realms[realm], char)
end end
-- Sort realm names table.sort(accountOrder, function(a, b)
table.sort(realmOrder) if a == myAccountLabel then return true end
if b == myAccountLabel then return false end
return a < b
end)
for _, acct in pairs(accounts) do
table.sort(acct.realmOrder)
end
local level = UIDROPDOWNMENU_MENU_LEVEL or 1 local level = UIDROPDOWNMENU_MENU_LEVEL or 1
if level == 1 then if level == 1 then
for _, realm in ipairs(realmOrder) do -- Level 1: account names (or realm names if single account)
local info = {} if table.getn(accountOrder) == 1 then
info.text = realm local acct = accounts[accountOrder[1]]
info.notCheckable = 1 for _, realm in ipairs(acct.realmOrder) do
info.hasArrow = 1 local info = {}
info.value = realm info.text = realm
UIDropDownMenu_AddButton(info, 1) info.notCheckable = 1
info.hasArrow = 1
info.value = accountOrder[1] .. "|" .. realm
UIDropDownMenu_AddButton(info, 1)
end
else
for _, acctKey in ipairs(accountOrder) do
local info = {}
info.text = acctKey
info.notCheckable = 1
info.hasArrow = 1
info.value = acctKey
UIDropDownMenu_AddButton(info, 1)
end
end end
elseif level == 2 then elseif level == 2 then
local realm = UIDROPDOWNMENU_MENU_VALUE local parentValue = UIDROPDOWNMENU_MENU_VALUE
local chars = realms[realm] if table.getn(accountOrder) == 1 then
local _, _, acctKey, realm = string.find(parentValue, "^(.+)|(.+)$")
local acct = accounts[acctKey]
local chars = acct and acct.realms[realm]
if chars then
for _, char in ipairs(chars) do
local charFullName = char.fullName
local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
local r, g, b = 1, 1, 1
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
local info = {}
info.text = addon.Modules.Utils:ColorText(char.name, r, g, b)
info.checked = not addon.Modules.DB:IsGoldBlacklisted(charFullName)
info.keepShownOnClick = 1
info.func = function()
addon.Modules.DB:ToggleGoldBlacklist(charFullName)
if moneyTooltip and moneyTooltip:IsShown() and moneyTooltip.anchor then
Guda_MoneyTooltip_Show(moneyTooltip.anchor)
end
end
UIDropDownMenu_AddButton(info, 2)
end
end
else
local acct = accounts[parentValue]
if acct then
for _, realm in ipairs(acct.realmOrder) do
local info = {}
info.text = realm
info.notCheckable = 1
info.hasArrow = 1
info.value = parentValue .. "|" .. realm
UIDropDownMenu_AddButton(info, 2)
end
end
end
Guda_ScaleDropdownFonts(12)
elseif level == 3 then
local parentValue = UIDROPDOWNMENU_MENU_VALUE
local _, _, acctKey, realm = string.find(parentValue, "^(.+)|(.+)$")
local acct = accounts[acctKey]
local chars = acct and acct.realms[realm]
if chars then if chars then
for _, char in ipairs(chars) do for _, char in ipairs(chars) do
local charFullName = char.fullName local charFullName = char.fullName
@@ -2424,9 +2537,10 @@ local function Guda_GoldTrackingMenu_Initialize()
Guda_MoneyTooltip_Show(moneyTooltip.anchor) Guda_MoneyTooltip_Show(moneyTooltip.anchor)
end end
end end
UIDropDownMenu_AddButton(info, 2) UIDropDownMenu_AddButton(info, 3)
end end
end end
Guda_ScaleDropdownFonts(12)
end end
end end
@@ -2437,7 +2551,7 @@ function Guda_ShowGoldTrackingMenu(anchor)
end end
UIDropDownMenu_Initialize(menuFrame, Guda_GoldTrackingMenu_Initialize, "MENU") UIDropDownMenu_Initialize(menuFrame, Guda_GoldTrackingMenu_Initialize, "MENU")
ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0) ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0)
Guda_ScaleDropdownFonts(14) Guda_ScaleDropdownFonts(12)
end end
-- Money tooltip handler (BagFrame entry point) -- Money tooltip handler (BagFrame entry point)
@@ -2445,32 +2559,45 @@ function Guda_BagFrame_MoneyOnEnter(self)
Guda_MoneyTooltip_Show(self) Guda_MoneyTooltip_Show(self)
end end
-- Helper: split characters into own and shared, filtered by blacklist
local function GetSplitCharacters(currentRealmOnly)
local characters = addon.Modules.DB:GetAllCharacters(false, currentRealmOnly)
local currentPlayerFullName = addon.Modules.DB:GetPlayerFullName()
local own, shared = {}, {}
for _, char in ipairs(characters) do
if not addon.Modules.DB:IsGoldBlacklisted(char.fullName) or char.fullName == currentPlayerFullName then
if char.isShared then
table.insert(shared, char)
else
table.insert(own, char)
end
end
end
return own, shared, currentPlayerFullName
end
-- Helper: add account separator header to dropdown
local function AddAccountSeparator(label)
local info = {}
info.text = label
info.isTitle = 1
info.notCheckable = 1
UIDropDownMenu_AddButton(info)
end
-- Dropdown management -- Dropdown management
local function Guda_BagCharacterMenu_Initialize() local function Guda_BagCharacterMenu_Initialize()
local characters = addon.Modules.DB:GetAllCharacters(false, true) local own, shared, currentPlayerFullName = GetSplitCharacters(true)
local info
local currentPlayerFullName = addon.Modules.DB:GetPlayerFullName()
local currentViewChar = addon.Modules.BagFrame:GetCurrentViewChar() local currentViewChar = addon.Modules.BagFrame:GetCurrentViewChar()
for i, char in ipairs(characters) do for _, char in ipairs(own) do
if addon.Modules.DB:IsGoldBlacklisted(char.fullName) and char.fullName ~= currentPlayerFullName then
-- skip blacklisted characters (never hide current player)
else
local charFullName = char.fullName local charFullName = char.fullName
local charClassToken = char.classToken local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
-- Get class color
local classColor = charClassToken and RAID_CLASS_COLORS[charClassToken]
local r, g, b = 1, 1, 1 local r, g, b = 1, 1, 1
if classColor then if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
r, g, b = classColor.r, classColor.g, classColor.b
end
-- Create colored name local info = {}
local coloredName = addon.Modules.Utils:ColorText(char.name, r, g, b) info.text = addon.Modules.Utils:ColorText(char.name, r, g, b)
info = {}
info.text = coloredName
info.func = function() info.func = function()
if charFullName == currentPlayerFullName then if charFullName == currentPlayerFullName then
addon.Modules.BagFrame:ShowCurrentCharacter() addon.Modules.BagFrame:ShowCurrentCharacter()
@@ -2480,7 +2607,24 @@ local function Guda_BagCharacterMenu_Initialize()
end end
info.checked = (currentViewChar == charFullName or (not currentViewChar and charFullName == currentPlayerFullName)) info.checked = (currentViewChar == charFullName or (not currentViewChar and charFullName == currentPlayerFullName))
UIDropDownMenu_AddButton(info) UIDropDownMenu_AddButton(info)
end -- else end
if table.getn(shared) > 0 then
AddAccountSeparator("Other Accounts")
for _, char in ipairs(shared) do
local charFullName = char.fullName
local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
local r, g, b = 1, 1, 1
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
local info = {}
info.text = addon.Modules.Utils:ColorText(char.name, r, g, b)
info.func = function()
addon.Modules.BagFrame:ShowCharacter(charFullName)
end
info.checked = (currentViewChar == charFullName)
UIDropDownMenu_AddButton(info)
end
end end
end end
@@ -2492,44 +2636,51 @@ function Guda_BagFrame_ToggleCharacterDropdown(button)
end end
UIDropDownMenu_Initialize(menuFrame, Guda_BagCharacterMenu_Initialize, "MENU") UIDropDownMenu_Initialize(menuFrame, Guda_BagCharacterMenu_Initialize, "MENU")
ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0) ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0)
Guda_ScaleDropdownFonts(14) Guda_ScaleDropdownFonts(12)
end end
-- Mailbox character dropdown -- Mailbox character dropdown
local function Guda_BagMailboxMenu_Initialize() local function Guda_BagMailboxMenu_Initialize()
local characters = addon.Modules.DB:GetAllCharacters(false, true) local own, shared, currentPlayerFullName = GetSplitCharacters(true)
local info local mailboxViewChar = addon.Modules.MailboxFrame and addon.Modules.MailboxFrame.GetCurrentViewChar and addon.Modules.MailboxFrame:GetCurrentViewChar()
local currentPlayerFullName = addon.Modules.DB:GetPlayerFullName()
for i, char in ipairs(characters) do for _, char in ipairs(own) do
if addon.Modules.DB:IsGoldBlacklisted(char.fullName) and char.fullName ~= currentPlayerFullName then
-- skip blacklisted characters (never hide current player)
else
local charFullName = char.fullName local charFullName = char.fullName
local charClassToken = char.classToken local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
-- Get class color
local classColor = charClassToken and RAID_CLASS_COLORS[charClassToken]
local r, g, b = 1, 1, 1 local r, g, b = 1, 1, 1
if classColor then if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
r, g, b = classColor.r, classColor.g, classColor.b
end
-- Create colored name local info = {}
local coloredName = addon.Modules.Utils:ColorText(char.name, r, g, b) info.text = addon.Modules.Utils:ColorText(char.name, r, g, b)
info = {}
info.text = coloredName
info.func = function() info.func = function()
addon.Modules.MailboxFrame:ShowCharacter(charFullName) addon.Modules.MailboxFrame:ShowCharacter(charFullName)
if not Guda_MailboxFrame:IsShown() then if not Guda_MailboxFrame:IsShown() then
Guda_MailboxFrame:Show() Guda_MailboxFrame:Show()
end end
end end
local mailboxViewChar = addon.Modules.MailboxFrame:GetCurrentViewChar()
info.checked = (mailboxViewChar == charFullName or (not mailboxViewChar and charFullName == currentPlayerFullName)) info.checked = (mailboxViewChar == charFullName or (not mailboxViewChar and charFullName == currentPlayerFullName))
UIDropDownMenu_AddButton(info) UIDropDownMenu_AddButton(info)
end -- else end
if table.getn(shared) > 0 then
AddAccountSeparator("Other Accounts")
for _, char in ipairs(shared) do
local charFullName = char.fullName
local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
local r, g, b = 1, 1, 1
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
local info = {}
info.text = addon.Modules.Utils:ColorText(char.name, r, g, b)
info.func = function()
addon.Modules.MailboxFrame:ShowCharacter(charFullName)
if not Guda_MailboxFrame:IsShown() then
Guda_MailboxFrame:Show()
end
end
info.checked = (mailboxViewChar == charFullName)
UIDropDownMenu_AddButton(info)
end
end end
end end
@@ -2541,42 +2692,47 @@ function Guda_BagFrame_ToggleMailDropdown(button)
end end
UIDropDownMenu_Initialize(menuFrame, Guda_BagMailboxMenu_Initialize, "MENU") UIDropDownMenu_Initialize(menuFrame, Guda_BagMailboxMenu_Initialize, "MENU")
ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0) ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0)
Guda_ScaleDropdownFonts(14) Guda_ScaleDropdownFonts(12)
end end
-- Bank character dropdown -- Bank character dropdown
local function Guda_BagBankMenu_Initialize() local function Guda_BagBankMenu_Initialize()
local characters = addon.Modules.DB:GetAllCharacters(false, true) local own, shared, currentPlayerFullName = GetSplitCharacters(true)
local info local bankViewChar = addon.Modules.BankFrame:GetCurrentViewChar()
local currentPlayerFullName = addon.Modules.DB:GetPlayerFullName()
for i, char in ipairs(characters) do for _, char in ipairs(own) do
if addon.Modules.DB:IsGoldBlacklisted(char.fullName) and char.fullName ~= currentPlayerFullName then
-- skip blacklisted characters (never hide current player)
else
local charFullName = char.fullName 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 charName = char.name local charName = char.name
local coloredName = addon.Modules.Utils:ColorText(charName, r, g, b) local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
local r, g, b = 1, 1, 1
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
info = {} local info = {}
info.text = coloredName info.text = addon.Modules.Utils:ColorText(charName, r, g, b)
info.func = function() info.func = function()
Guda_BagFrame_ShowCharacterBank(charFullName, charName) Guda_BagFrame_ShowCharacterBank(charFullName, charName)
end end
local bankViewChar = addon.Modules.BankFrame:GetCurrentViewChar()
info.checked = (bankViewChar == charFullName or (not bankViewChar and charFullName == currentPlayerFullName)) info.checked = (bankViewChar == charFullName or (not bankViewChar and charFullName == currentPlayerFullName))
UIDropDownMenu_AddButton(info) UIDropDownMenu_AddButton(info)
end -- else end
if table.getn(shared) > 0 then
AddAccountSeparator("Other Accounts")
for _, char in ipairs(shared) do
local charFullName = char.fullName
local charName = char.name
local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
local r, g, b = 1, 1, 1
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
local info = {}
info.text = addon.Modules.Utils:ColorText(charName, r, g, b)
info.func = function()
Guda_BagFrame_ShowCharacterBank(charFullName, charName)
end
info.checked = (bankViewChar == charFullName)
UIDropDownMenu_AddButton(info)
end
end end
end end
@@ -2588,7 +2744,7 @@ function Guda_BagFrame_ToggleBankDropdown(button)
end end
UIDropDownMenu_Initialize(menuFrame, Guda_BagBankMenu_Initialize, "MENU") UIDropDownMenu_Initialize(menuFrame, Guda_BagBankMenu_Initialize, "MENU")
ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0) ToggleDropDownMenu(1, nil, menuFrame, "cursor", 0, 0)
Guda_ScaleDropdownFonts(14) Guda_ScaleDropdownFonts(12)
end end
-- Show character's bank -- Show character's bank
+43 -20
View File
@@ -2794,30 +2794,31 @@ end
-- Bank character dropdown (similar to BagFrame's bank dropdown) -- Bank character dropdown (similar to BagFrame's bank dropdown)
local function Guda_BankCharacterMenu_Initialize() local function Guda_BankCharacterMenu_Initialize()
local characters = addon.Modules.DB:GetAllCharacters(false, true) local DB = addon.Modules.DB
local info local currentPlayerFullName = DB:GetPlayerFullName()
local currentPlayerFullName = addon.Modules.DB:GetPlayerFullName()
local currentViewChar = addon.Modules.BankFrame:GetCurrentViewChar() local currentViewChar = addon.Modules.BankFrame:GetCurrentViewChar()
local characters = DB:GetAllCharacters(false, true)
for i, char in ipairs(characters) do -- Split into own and shared
if addon.Modules.DB:IsGoldBlacklisted(char.fullName) and char.fullName ~= currentPlayerFullName then local own, shared = {}, {}
-- skip blacklisted characters (never hide current player) for _, char in ipairs(characters) do
else if not DB:IsGoldBlacklisted(char.fullName) or char.fullName == currentPlayerFullName then
local charFullName = char.fullName if char.isShared then
local charClassToken = char.classToken table.insert(shared, char)
else
-- Get class color table.insert(own, char)
local classColor = charClassToken and RAID_CLASS_COLORS[charClassToken] end
local r, g, b = 1, 1, 1
if classColor then
r, g, b = classColor.r, classColor.g, classColor.b
end end
end
-- Create colored name for _, char in ipairs(own) do
local coloredName = addon.Modules.Utils:ColorText(char.name, r, g, b) local charFullName = char.fullName
local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
local r, g, b = 1, 1, 1
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
info = {} local info = {}
info.text = coloredName info.text = addon.Modules.Utils:ColorText(char.name, r, g, b)
info.func = function() info.func = function()
if charFullName == currentPlayerFullName then if charFullName == currentPlayerFullName then
addon.Modules.BankFrame:ShowCurrentCharacter() addon.Modules.BankFrame:ShowCurrentCharacter()
@@ -2827,7 +2828,29 @@ local function Guda_BankCharacterMenu_Initialize()
end end
info.checked = (currentViewChar == charFullName or (not currentViewChar and charFullName == currentPlayerFullName)) info.checked = (currentViewChar == charFullName or (not currentViewChar and charFullName == currentPlayerFullName))
UIDropDownMenu_AddButton(info) UIDropDownMenu_AddButton(info)
end -- else end
if table.getn(shared) > 0 then
local sep = {}
sep.text = "Other Accounts"
sep.isTitle = 1
sep.notCheckable = 1
UIDropDownMenu_AddButton(sep)
for _, char in ipairs(shared) do
local charFullName = char.fullName
local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
local r, g, b = 1, 1, 1
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
local info = {}
info.text = addon.Modules.Utils:ColorText(char.name, r, g, b)
info.func = function()
addon.Modules.BankFrame:ShowCharacter(charFullName)
end
info.checked = (currentViewChar == charFullName)
UIDropDownMenu_AddButton(info)
end
end end
end end
+6 -6
View File
@@ -260,12 +260,12 @@ end
-- Increase font size on Blizzard UIDropDownMenu buttons after ToggleDropDownMenu -- Increase font size on Blizzard UIDropDownMenu buttons after ToggleDropDownMenu
function Guda_ScaleDropdownFonts(size) function Guda_ScaleDropdownFonts(size)
local list = getglobal("DropDownList1") for level = 1, 3 do
if not list then return end local listName = "DropDownList" .. level
for i = 1, 20 do local list = getglobal(listName)
local btn = getglobal("DropDownList1Button" .. i) if not list then break end
if btn then for i = 1, 20 do
local ntxt = getglobal("DropDownList1Button" .. i .. "NormalText") local ntxt = getglobal(listName .. "Button" .. i .. "NormalText")
if ntxt then if ntxt then
local f, _, fl = ntxt:GetFont() local f, _, fl = ntxt:GetFont()
if f then ntxt:SetFont(f, size, fl) end if f then ntxt:SetFont(f, size, fl) end
+5 -1
View File
@@ -2321,7 +2321,11 @@ function Guda_ItemButton_OnEnter(self)
elseif self.otherChar or self.isReadOnly then elseif self.otherChar or self.isReadOnly then
GameTooltip.GudaViewedCharacter = self.otherChar GameTooltip.GudaViewedCharacter = self.otherChar
if self.itemData and self.itemData.link then if self.itemData and self.itemData.link then
GameTooltip:SetHyperlink(self.itemData.link) local ok = pcall(GameTooltip.SetHyperlink, GameTooltip, self.itemData.link)
if not ok then
GameTooltip:Hide()
return
end
else else
GameTooltip:Hide() GameTooltip:Hide()
return return
+43 -21
View File
@@ -355,33 +355,55 @@ end
-- Show character selection menu -- Show character selection menu
local function Guda_MailboxCharacterMenu_Initialize() local function Guda_MailboxCharacterMenu_Initialize()
local characters = addon.Modules.DB:GetAllCharacters(true, true) local DB = addon.Modules.DB
local info local currentPlayerFullName = DB:GetPlayerFullName()
local currentPlayerFullName = addon.Modules.DB:GetPlayerFullName() local characters = DB:GetAllCharacters(true, true)
for i, char in ipairs(characters) do local own, shared = {}, {}
if addon.Modules.DB:IsGoldBlacklisted(char.fullName) and char.fullName ~= currentPlayerFullName then for _, char in ipairs(characters) do
-- skip blacklisted characters (never hide current player) if not DB:IsGoldBlacklisted(char.fullName) or char.fullName == currentPlayerFullName then
else if char.isShared then
local charFullName = char.fullName table.insert(shared, char)
local charClassToken = char.classToken else
table.insert(own, char)
-- Get class color end
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 end
end
-- Create colored name for _, char in ipairs(own) do
local coloredName = addon.Modules.Utils:ColorText(char.name, r, g, b) local charFullName = char.fullName
local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
local r, g, b = 1, 1, 1
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
info = {} local info = {}
info.text = coloredName info.text = addon.Modules.Utils:ColorText(char.name, r, g, b)
info.func = function() MailboxFrame:ShowCharacter(charFullName) end info.func = function() MailboxFrame:ShowCharacter(charFullName) end
info.checked = (currentViewChar == char.fullName or (not currentViewChar and char.fullName == currentPlayerFullName)) local currentViewChar = MailboxFrame:GetCurrentViewChar and MailboxFrame:GetCurrentViewChar()
info.checked = (currentViewChar == charFullName or (not currentViewChar and charFullName == currentPlayerFullName))
UIDropDownMenu_AddButton(info) UIDropDownMenu_AddButton(info)
end -- else end
if table.getn(shared) > 0 then
local sep = {}
sep.text = "Other Accounts"
sep.isTitle = 1
sep.notCheckable = 1
UIDropDownMenu_AddButton(sep)
for _, char in ipairs(shared) do
local charFullName = char.fullName
local classColor = char.classToken and RAID_CLASS_COLORS[char.classToken]
local r, g, b = 1, 1, 1
if classColor then r, g, b = classColor.r, classColor.g, classColor.b end
local info = {}
info.text = addon.Modules.Utils:ColorText(char.name, r, g, b)
info.func = function() MailboxFrame:ShowCharacter(charFullName) end
local currentViewChar = MailboxFrame:GetCurrentViewChar and MailboxFrame:GetCurrentViewChar()
info.checked = (currentViewChar == charFullName)
UIDropDownMenu_AddButton(info)
end
end end
end end