Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 32 additions & 19 deletions Modules/ReplaceRealNames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,23 @@ for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do classTokens[v] = k end
for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do classTokens[v] = k end

local bnetNames = setmetatable({}, { __index = function(bnetNames, bnetIDAccount)
-- bnetIDAccount, accountName, battleTag, isBattleTag, characterName, bnetIDGameAccount, client, isOnline, lastOnline, isAFK, isDND, messageText, noteText, isRIDFriend, messageTime, canSoR, isReferAFriend, canSummonFriend
local _, accountName, battleTag, isBattleTag, characterName, bnetIDGameAccount, client, isOnline, _, _, _, _, _, isRIDFriend = BNGetFriendInfoByID(bnetIDAccount)
local bnetAccount = C_BattleNet.GetAccountInfoByID(bnetIDAccount)
local accountName = bnetAccount.accountName
local battleTag = bnetAccount.battleTag
local isBattleTag = bnetAccount.isBattleTagFriend
local characterName = bnetAccount.gameAccountInfo.characterName
local bnetIDGameAccount = bnetAccount.gameAccountInfo.gameAccountID
local client = bnetAccount.gameAccountInfo.clientProgram ~= "" and bnetAccount.gameAccountInfo.clientProgram or nil;
local isOnline = bnetAccount.gameAccountInfo.isOnline
local isRIDFriend = bnetAccount.isFriend
if not accountName then return end -- not initialized yet
-- print(bnetIDAccount, accountName, isRIDFriend, battleTag, isBattleTag, isOnline, client, bnetIDGameAccount, characterName)

local classColor
if isOnline and bnetIDGameAccount and client == BNET_CLIENT_WOW and PhanxChat.db.ShowClassColors then
-- print("Online in WoW")
local _, _, _, realmName, _, _, _, className = BNGetGameAccountInfo(bnetIDGameAccount)
local realmName = bnetAccount.gameAccountInfo.realmName
local className = bnetAccount.gameAccountInfo.className
realmName = realmName and realmName ~= "" and realmName ~= playerRealm and gsub(realmName, "%s", "")
characterName = realmName and format("%s-%s", characterName, realmName) or characterName

Expand Down Expand Up @@ -112,9 +120,7 @@ table.insert(PhanxChat.RunOnLoad, PhanxChat.SetReplaceRealNames)
------------------------------------------------------------------------

local BN_WHO_LIST_FORMAT = gsub(WHO_LIST_FORMAT, "|Hplayer:", "|H")
local BN_WHO_LIST_GUILD_FORMAT = gsub(WHO_LIST_GUILD_FORMAT, "|Hplayer:", "|H")
local BN_WHO_LIST_REALM_FORMAT = BN_WHO_LIST_FORMAT .. " (%s)"
local BN_WHO_LIST_GUILD_REALM_FORMAT = BN_WHO_LIST_GUILD_FORMAT .. " (%s)"

hooksecurefunc("ChatFrame_OnHyperlinkShow", function(frame, link, text, button)
if strsub(link, 1, 8) == "BNplayer" then
Expand All @@ -128,7 +134,16 @@ hooksecurefunc("ChatFrame_OnHyperlinkShow", function(frame, link, text, button)
end
end

local _, accountName, battleTag, isBattleTag, characterName, bnetIDGameAccount, client, isOnline, _, _, _, _, note, isRIDFriend = BNGetFriendInfoByID(bnetIDAccount)
local bnetAccount = C_BattleNet.GetAccountInfoByID(bnetIDAccount)
local accountName = bnetAccount.accountName
local battleTag = bnetAccount.battleTag
local isBattleTag = bnetAccount.isBattleTagFriend
local characterName = bnetAccount.gameAccountInfo.characterName
local bnetIDGameAccount = bnetAccount.gameAccountInfo.gameAccountID
local client = bnetAccount.gameAccountInfo.clientProgram ~= "" and bnetAccount.gameAccountInfo.clientProgram or nil;
local isOnline = bnetAccount.gameAccountInfo.isOnline
local note = bnetAccount.note
local isRIDFriend = bnetAccount.isFriend
if not accountName then return end

local color = ChatTypeInfo.SYSTEM
Expand All @@ -138,7 +153,15 @@ hooksecurefunc("ChatFrame_OnHyperlinkShow", function(frame, link, text, button)
color.r, color.g, color.b)
end

local hasFocus, characterName, _, realmName, _, faction, race, class, guild, zoneName, level, gameText = BNGetGameAccountInfo(bnetIDGameAccount)
local hasFocus = bnetAccount.gameAccountInfo.hasFocus
local characterName = bnetAccount.gameAccountInfo.gameAccountInfo.characterName or ""
local realmName = bnetAccount.gameAccountInfo.realmName or ""
local faction = bnetAccount.gameAccountInfo.factionName or ""
local race = bnetAccount.gameAccountInfo.raceName or ""
local class = bnetAccount.gameAccountInfo.className or ""
local zoneName = bnetAccount.gameAccountInfo.gameAccountInfo.areaName or ""
local level = bnetAccount.gameAccountInfo.gameAccountInfo.characterLevel or ""
local gameText = bnetAccount.gameAccountInfo.gameAccountInfo.richPresence or ""
if client ~= BNET_CLIENT_WOW then
gameText = BNET_CLIENT_TEXT[client]
if gameText then
Expand All @@ -149,18 +172,8 @@ hooksecurefunc("ChatFrame_OnHyperlinkShow", function(frame, link, text, button)
color.r, color.g, color.b)
end
elseif realm == GetRealmName() then -- #TODO: Check in the future if Blizz fixes zone being nil
if guild and guild ~= "" then
return DEFAULT_CHAT_FRAME:AddMessage(gsub(format(BN_WHO_LIST_GUILD_FORMAT,
link, characterName, level, race, class, guild, zoneName or ""), " ", " "),
color.r, color.g, color.b)
else
return DEFAULT_CHAT_FRAME:AddMessage(gsub(format(BN_WHO_LIST_FORMAT,
link, characterName, level, race, class, zoneName or ""), " ", " "),
color.r, color.g, color.b)
end
elseif guild and guild ~= "" then
return DEFAULT_CHAT_FRAME:AddMessage(gsub(format(BN_WHO_LIST_GUILD_REALM_FORMAT,
link, characterName, level, race, class, guild, zoneName or "", realmName), " ", " "),
return DEFAULT_CHAT_FRAME:AddMessage(gsub(format(BN_WHO_LIST_FORMAT,
link, characterName, level, race, class, zoneName or ""), " ", " "),
color.r, color.g, color.b)
else
return DEFAULT_CHAT_FRAME:AddMessage(gsub(format(BN_WHO_LIST_REALM_FORMAT,
Expand Down