Commit d4e12265 authored by Simpy's avatar Simpy 🐹
Browse files

support connected realms in gold datatext, this adds `E.serverID` which is...

support connected realms in gold datatext, this adds `E.serverID` which is used to check other realms with the same ID in gold saved vars
parent 810b009a
......@@ -4,7 +4,7 @@ local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, Profi
local _G = _G
local tonumber, pairs, ipairs, error, unpack, select, tostring = tonumber, pairs, ipairs, error, unpack, select, tostring
local strjoin, twipe, tinsert, tremove, tContains = strjoin, wipe, tinsert, tremove, tContains
local strsplit, strjoin, twipe, tinsert, tremove, tContains = strsplit, strjoin, wipe, tinsert, tremove, tContains
local format, find, strrep, strlen, sub, gsub = format, strfind, strrep, strlen, strsub, gsub
local assert, type, pcall, xpcall, next, print = assert, type, pcall, xpcall, next, print
local rawget, rawset, setmetatable = rawget, rawset, setmetatable
......@@ -1710,7 +1710,11 @@ function E:Initialize()
twipe(E.global)
twipe(E.private)
E.myguid = UnitGUID('player')
local playerGUID = UnitGUID('player')
local _, serverID = strsplit('-', playerGUID)
E.serverID = tonumber(serverID)
E.myguid = playerGUID
E.data = E.Libs.AceDB:New('ElvDB', E.DF, true)
E.data.RegisterCallback(E, 'OnProfileChanged', 'StaggeredUpdateAll')
E.data.RegisterCallback(E, 'OnProfileCopied', 'StaggeredUpdateAll')
......
......@@ -53,6 +53,10 @@ local function OnEvent(self)
ElvDB.faction[E.myrealm] = ElvDB.faction[E.myrealm] or {}
ElvDB.faction[E.myrealm][E.myname] = E.myfaction
ElvDB.serverID = ElvDB.serverID or {}
ElvDB.serverID[E.serverID] = ElvDB.serverID[E.serverID] or {}
ElvDB.serverID[E.serverID][E.myrealm] = true
--prevent an error possibly from really old profiles
local oldMoney = ElvDB.gold[E.myrealm][E.myname]
if oldMoney and type(oldMoney) ~= 'number' then
......@@ -125,27 +129,30 @@ local function OnEnter()
DT.tooltip:AddLine(L["Character: "])
wipe(myGold)
for k,_ in pairs(ElvDB.gold[E.myrealm]) do
if ElvDB.gold[E.myrealm][k] then
local color = E:ClassColor(ElvDB.class[E.myrealm][k]) or PRIEST_COLOR
tinsert(myGold,
{
name = k,
amount = ElvDB.gold[E.myrealm][k],
amountText = E:FormatMoney(ElvDB.gold[E.myrealm][k], E.db.datatexts.goldFormat or 'BLIZZARD', not E.db.datatexts.goldCoins),
faction = ElvDB.faction[E.myrealm][k] or '',
r = color.r, g = color.g, b = color.b,
}
)
end
for realm in pairs(ElvDB.serverID[E.serverID]) do
for k, _ in pairs(ElvDB.gold[realm]) do
if ElvDB.gold[realm][k] then
local color = E:ClassColor(ElvDB.class[realm][k]) or PRIEST_COLOR
tinsert(myGold,
{
name = k,
realm = realm,
amount = ElvDB.gold[realm][k],
amountText = E:FormatMoney(ElvDB.gold[realm][k], E.db.datatexts.goldFormat or 'BLIZZARD', not E.db.datatexts.goldCoins),
faction = ElvDB.faction[realm][k] or '',
r = color.r, g = color.g, b = color.b,
}
)
end
if ElvDB.faction[E.myrealm][k] == 'Alliance' then
totalAlliance = totalAlliance+ElvDB.gold[E.myrealm][k]
elseif ElvDB.faction[E.myrealm][k] == 'Horde' then
totalHorde = totalHorde+ElvDB.gold[E.myrealm][k]
end
if ElvDB.faction[realm][k] == 'Alliance' then
totalAlliance = totalAlliance+ElvDB.gold[realm][k]
elseif ElvDB.faction[realm][k] == 'Horde' then
totalHorde = totalHorde+ElvDB.gold[realm][k]
end
totalGold = totalGold+ElvDB.gold[E.myrealm][k]
totalGold = totalGold+ElvDB.gold[realm][k]
end
end
sort(myGold, sortFunction)
......@@ -156,9 +163,8 @@ local function OnEnter()
nameLine = format('|TInterface/FriendsFrame/PlusManz-%s:14|t ', g.faction)
end
nameLine = g.name == E.myname and nameLine..g.name..' |TInterface/COMMON/Indicator-Green:14|t' or nameLine..g.name
DT.tooltip:AddDoubleLine(nameLine, g.amountText, g.r, g.g, g.b, 1, 1, 1)
local toonName = format('%s%s%s', nameLine, g.name, (g.realm and g.realm ~= E.myrealm and ' - '..g.realm) or '')
DT.tooltip:AddDoubleLine((g.name == E.myname and toonName..' |TInterface/COMMON/Indicator-Green:14|t') or toonName, g.amountText, g.r, g.g, g.b, 1, 1, 1)
end
DT.tooltip:AddLine(' ')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment