display only current realm characters

This commit is contained in:
Salikh Gurgenidze
2025-11-19 21:36:16 +04:00
parent 9eb88b24f2
commit 887d1c8f41
5 changed files with 33 additions and 28 deletions
+10 -6
View File
@@ -160,11 +160,13 @@ function DB:SaveMoney(copper)
end end
end end
-- Get all characters (optionally filter by faction) -- Get all characters (optionally filter by faction and/or realm)
function DB:GetAllCharacters(sameFactionOnly) function DB:GetAllCharacters(sameFactionOnly, currentRealmOnly)
local chars = {} local chars = {}
for fullName, data in pairs(Guda_DB.characters) do for fullName, data in pairs(Guda_DB.characters) do
if not sameFactionOnly or data.faction == playerFaction then local factionMatch = not sameFactionOnly or data.faction == playerFaction
local realmMatch = not currentRealmOnly or data.realm == playerRealm
if factionMatch and realmMatch then
table.insert(chars, { table.insert(chars, {
fullName = fullName, fullName = fullName,
name = data.name, name = data.name,
@@ -211,11 +213,13 @@ function DB:GetCharacterInfo(fullName)
return char and char.character or {} return char and char.character or {}
end end
-- Get total money across all characters -- Get total money across all characters (optionally filter by faction and/or realm)
function DB:GetTotalMoney(sameFactionOnly) function DB:GetTotalMoney(sameFactionOnly, currentRealmOnly)
local total = 0 local total = 0
for fullName, data in pairs(Guda_DB.characters) do for fullName, data in pairs(Guda_DB.characters) do
if not sameFactionOnly or data.faction == playerFaction then local factionMatch = not sameFactionOnly or data.faction == playerFaction
local realmMatch = not currentRealmOnly or data.realm == playerRealm
if factionMatch and realmMatch then
total = total + (data.money or 0) total = total + (data.money or 0)
end end
end end
+4 -3
View File
@@ -188,11 +188,12 @@ function Tooltip:AddInventoryInfo(tooltip, link)
local hasAnyItems = false local hasAnyItems = false
local currentPlayerName = addon.Modules.DB:GetPlayerFullName() local currentPlayerName = addon.Modules.DB:GetPlayerFullName()
local currentRealm = GetRealmName()
-- Count items across all characters with safety checks -- Count items across characters on current realm only
for charName, charData in pairs(Guda_DB.characters) do for charName, charData in pairs(Guda_DB.characters) do
-- Ensure charData is actually a table before processing -- Ensure charData is actually a table and on current realm
if type(charData) == "table" then if type(charData) == "table" and charData.realm == currentRealm then
local isCurrentChar = (charName == currentPlayerName) local isCurrentChar = (charName == currentPlayerName)
local bagCount, bankCount, equippedCount = CountItemsForCharacter(itemID, charData, isCurrentChar) local bagCount, bankCount, equippedCount = CountItemsForCharacter(itemID, charData, isCurrentChar)
+3 -3
View File
@@ -24,9 +24,9 @@ function MoneyTracker:GetCurrentMoney()
return GetMoney() return GetMoney()
end end
-- Get total money across all characters -- Get total money across all characters (optionally filter by faction and/or realm)
function MoneyTracker:GetTotalMoney(sameFactionOnly) function MoneyTracker:GetTotalMoney(sameFactionOnly, currentRealmOnly)
return addon.Modules.DB:GetTotalMoney(sameFactionOnly) return addon.Modules.DB:GetTotalMoney(sameFactionOnly, currentRealmOnly)
end end
-- Initialize money tracker -- Initialize money tracker
+9 -9
View File
@@ -659,13 +659,13 @@ function Guda_BagFrame_MoneyOnEnter(self)
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT", 0, 0) GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT", 0, 0)
GameTooltip:ClearLines() GameTooltip:ClearLines()
-- Get all characters and total -- Get all characters and total (faction + realm filtered)
local chars = addon.Modules.DB:GetAllCharacters(true) local chars = addon.Modules.DB:GetAllCharacters(true, true)
local totalMoney = addon.Modules.DB:GetTotalMoney(true) local totalMoney = addon.Modules.DB:GetTotalMoney(true, true)
-- Header with faction/realm total - use colored money -- Header with current realm total - use colored money
GameTooltip:AddLine( GameTooltip:AddLine(
"Faction/realm-wide gold: " .. addon.Modules.Utils:FormatMoney(totalMoney, false, true), "Current realm gold: " .. addon.Modules.Utils:FormatMoney(totalMoney, false, true),
1, 0.82, 0 1, 0.82, 0
) )
GameTooltip:AddLine(" ") GameTooltip:AddLine(" ")
@@ -732,8 +732,8 @@ function Guda_BagFrame_ToggleCharacterDropdown(button)
end end
characterDropdown.buttons = {} characterDropdown.buttons = {}
-- Get all characters -- Get all characters on current realm
local chars = addon.Modules.DB:GetAllCharacters(true) local chars = addon.Modules.DB:GetAllCharacters(true, true)
-- Add "Current Character" option at the top -- Add "Current Character" option at the top
local yOffset = -8 local yOffset = -8
@@ -900,8 +900,8 @@ function Guda_BagFrame_ToggleBankDropdown(button)
end end
bankDropdown.buttons = {} bankDropdown.buttons = {}
-- Get all characters -- Get all characters on current realm
local chars = addon.Modules.DB:GetAllCharacters(true) local chars = addon.Modules.DB:GetAllCharacters(true, true)
local yOffset = -8 local yOffset = -8
+7 -7
View File
@@ -382,13 +382,13 @@ function Guda_BankFrame_MoneyOnEnter(self)
GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT", 0, 0) GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT", 0, 0)
GameTooltip:ClearLines() GameTooltip:ClearLines()
-- Get all characters and total -- Get all characters and total (faction + realm filtered)
local chars = addon.Modules.DB:GetAllCharacters(true) local chars = addon.Modules.DB:GetAllCharacters(true, true)
local totalMoney = addon.Modules.DB:GetTotalMoney(true) local totalMoney = addon.Modules.DB:GetTotalMoney(true, true)
-- Header with faction/realm total - use colored money -- Header with current realm total - use colored money
GameTooltip:AddLine( GameTooltip:AddLine(
"Faction/realm-wide gold: " .. addon.Modules.Utils:FormatMoney(totalMoney, false, true), "Current realm gold: " .. addon.Modules.Utils:FormatMoney(totalMoney, false, true),
1, 0.82, 0 1, 0.82, 0
) )
GameTooltip:AddLine(" ") GameTooltip:AddLine(" ")
@@ -1215,8 +1215,8 @@ function Guda_BankFrame_ToggleBankDropdown(button)
end end
bankCharDropdown.buttons = {} bankCharDropdown.buttons = {}
-- Get all characters -- Get all characters on current realm
local chars = addon.Modules.DB:GetAllCharacters(true) local chars = addon.Modules.DB:GetAllCharacters(true, true)
local yOffset = -8 local yOffset = -8