215 lines
6.5 KiB
Lua
215 lines
6.5 KiB
Lua
local addonName, addon = ...
|
|
local childName = addon['childName']
|
|
local child = addon[childName]
|
|
local events = child['events']
|
|
local db
|
|
local rep = ERR_FRIEND_ONLINE_SS:gsub("%%s", "(.+)"):gsub("[%[%]]", "%%%1")
|
|
local rosterOfficer = {}
|
|
local rosterNotice = {}
|
|
local hooked = {}
|
|
local function guildRoster(nameC)
|
|
for i = 1, GetNumGuildMembers() do
|
|
local name, _, _, _, _, _, note, officernote = GetGuildRosterInfo(i)
|
|
-- local name, rank, rankIndex, level, classDisplayName, zone, note, officernote, isOnline, status, class, achievementPoints, achievementRank, isMobile, canSoR, repStanding = GetGuildRosterInfo(index)
|
|
local n = strsplit("-", name)
|
|
if(name == nameC or n == nameC) then
|
|
rosterOfficer[nameC] = officernote
|
|
rosterNotice[nameC] = note
|
|
return (rosterOfficer[nameC] and rosterOfficer[nameC] ~= "") and rosterOfficer[nameC] or (rosterNotice[nameC] or "")
|
|
else
|
|
--
|
|
end
|
|
end
|
|
for i = 1, C_FriendList.GetNumFriends() do
|
|
local name, _, _, _, _, _, note = C_FriendList.GetFriendInfo(i)
|
|
if(name == nameC) then
|
|
return note and note or ""
|
|
end
|
|
end
|
|
for i = 1, BNGetNumFriends() do
|
|
local _, characterName, messageText, noteText
|
|
if(BNGetFriendInfo) then
|
|
_, _, _, _, characterName, _, _, _, _, _, _, messageText, noteText = BNGetFriendInfo(i)
|
|
else
|
|
local res = C_BattleNet.GetFriendAccountInfo(i)
|
|
if(res and res['gameAccountInfo']) then
|
|
characterName, messageText, noteText = res['gameAccountInfo']['characterName'], res['customMessage'], res['note']
|
|
end
|
|
end
|
|
if(characterName == nameC) then
|
|
local line = ""
|
|
if(noteText) then
|
|
line = format("%s%s", line, noteText)
|
|
end
|
|
if(messageText) then
|
|
if(noteText) then
|
|
line = format("%s | ",line)
|
|
end
|
|
line = format("%s%s", line, messageText)
|
|
end
|
|
return line
|
|
end
|
|
end
|
|
print(format("Line 68-Debug zz_UI (%s)",nameC))
|
|
return ""
|
|
end
|
|
local function addNoticeR(link)
|
|
return guildRoster(select(2, strsplit(":", select(3, string.find(link, "^|H(.+)|h%[.*%]")))))
|
|
end
|
|
local function addNotice(self, event, msg, author, ...)
|
|
if(msg and rep and string.find(msg, rep)) then
|
|
return false, gsub(msg, " ", format(" (%s) ", addNoticeR(msg)) or " ", 1), author, ...
|
|
end
|
|
return false
|
|
end
|
|
local function chatHoverIn(cf, link, text)
|
|
local typ = string.match(link, "^(.-):")
|
|
-- print(typ,link)
|
|
--[[ print(typ,link)
|
|
local tbl = { strsplit(":", link) }
|
|
for k,v in pairs(tbl) do
|
|
print(v)
|
|
end
|
|
]]--
|
|
if(typ == "item" or typ == "enchant" or typ == "spell" or typ == "quest" or typ == "currency") then
|
|
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
|
|
GameTooltip:SetHyperlink(link)
|
|
ShowUIPanel(GameTooltip)
|
|
elseif(typ == "player") then
|
|
local typ, name = string.match(link, "^(.-):(.*):(.*):")
|
|
if(name) then
|
|
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
|
|
GameTooltip:SetUnit(name)
|
|
ShowUIPanel(GameTooltip)
|
|
end
|
|
end
|
|
end
|
|
local function chatHoverOut(cf, link, text)
|
|
HideUIPanel(GameTooltip)
|
|
end
|
|
local function focusToggle(self)
|
|
local name = self:GetName()
|
|
if(self:HasFocus()) then
|
|
_G[name..'Left']:Show()
|
|
_G[name..'Right']:Show()
|
|
_G[name..'Mid']:Show()
|
|
else
|
|
_G[name..'Left']:Hide()
|
|
_G[name..'Right']:Hide()
|
|
_G[name..'Mid']:Hide()
|
|
end
|
|
end
|
|
local garrisonMaps = {
|
|
[1152] = true, -- FW Horde Garrison Level 1
|
|
[1330] = true, -- FW Horde Garrison Level 2
|
|
[1153] = true, -- FW Horde Garrison Level 3
|
|
[1154] = true, -- FW Horde Garrison Level 4
|
|
[1158] = true, -- SMV Alliance Garrison Level 1
|
|
[1331] = true, -- SMV Alliance Garrison Level 2
|
|
[1159] = true, -- SMV Alliance Garrison Level 3
|
|
[1160] = true, -- SMV Alliance Garrison Level 4
|
|
}
|
|
local function InGarrison()
|
|
local name, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID, instanceGroupSize = GetInstanceInfo()
|
|
if(garrisonMaps[instanceMapID]) then
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
local function apply(eb)
|
|
local d = 'PARTY'
|
|
local i, t = IsInInstance()
|
|
if (t=='raid') then
|
|
d = 'RAID'
|
|
elseif ((t=='party' and not InGarrison()) or t=='pvp') then
|
|
d = 'INSTANCE_CHAT'
|
|
elseif (not i and GetNumGroupMembers()>0) then
|
|
d = 'PARTY'
|
|
elseif IsInGuild() then
|
|
d = 'GUILD'
|
|
end
|
|
eb:SetAttribute("chatType", d)
|
|
-- eb:SetAttribute("stickyType", d)
|
|
end
|
|
local function hookFrame(self)
|
|
if(not hooked[self]) then
|
|
self:HookScript("OnEditFocusGained",focusToggle)
|
|
self:HookScript("OnEditFocusLost",focusToggle)
|
|
hooked[self] = true
|
|
end
|
|
return
|
|
end
|
|
function events:UPDATE_CHAT_WINDOWS(_, event)
|
|
ChatFrame1:SetUserPlaced(true)
|
|
ChatFrame1:SetClampedToScreen(false)
|
|
ChatFrame1:ClearAllPoints()
|
|
ChatFrame1:SetWidth(353)
|
|
ChatFrame1:SetHeight(148)
|
|
ChatFrame1:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT",32,30)
|
|
local iname = "Friendlog"
|
|
local ifound = false
|
|
for i = 1, NUM_CHAT_WINDOWS do
|
|
local cfn = format('ChatFrame%i',i)
|
|
local cf = _G[cfn]
|
|
cf.oldAlpha = cf.oldAlpha or 0 -- Fix 'max-bug' in FCF.lua
|
|
cf:HookScript("OnHyperlinkEnter",chatHoverIn)
|
|
cf:HookScript("OnHyperlinkLeave",chatHoverOut)
|
|
local cfname, _, _, _, _, _, shown, _, _, _ = GetChatWindowInfo(i)
|
|
if(cfname == iname) then
|
|
ifound = true
|
|
end
|
|
if(db['UnClamp']) then
|
|
cf:SetClampedToScreen(false)
|
|
cf:Raise()
|
|
end
|
|
if(db['HideBorder']) then
|
|
local ef = _G[format('%sEditBox',cfn)]
|
|
focusToggle(ef)
|
|
hookFrame(ef)
|
|
end
|
|
end
|
|
if(not ifound) then
|
|
local frame = FCF_OpenNewWindow(iname)
|
|
FCF_CopyChatSettings(frame, DEFAULT_CHAT_FRAME)
|
|
FCF_DockUpdate()
|
|
end
|
|
child:UnregisterEvent(event)
|
|
end
|
|
function events:CHAT_MSG_SYSTEM(_, _, arg1)
|
|
if(arg1 and arg1 == IDLE_MESSAGE) then
|
|
ForceQuit()
|
|
end
|
|
end
|
|
function events:PLAYER_ENTERING_WORLD()
|
|
for i = 1, NUM_CHAT_WINDOWS do
|
|
if(db['NoSay']) then
|
|
local eb = _G[format('ChatFrame%iEditBox',i)]
|
|
apply(eb)
|
|
if(not hooked['NoSay']) then
|
|
hooked['NoSay'] = true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
local init = {
|
|
Setup = function(self)
|
|
db = child['db']
|
|
ChatFrame_AddMessageEventFilter("CHAT_MSG_SYSTEM", addNotice)
|
|
if(db['HideFriendButton']) then
|
|
local fb = _G['QuickJoinToastButton']
|
|
if(fb) then
|
|
fb:UnregisterAllEvents()
|
|
if(not hooked[fb]) then
|
|
fb:HookScript("OnShow", function(self) self:Hide() end)
|
|
hooked[fb] = true
|
|
end
|
|
fb:Hide()
|
|
end
|
|
end
|
|
if(db['Unsticky']) then
|
|
ChatTypeInfo['WHISPER']['sticky'] = 0
|
|
ChatTypeInfo['BN_WHISPER']['sticky'] = 0
|
|
end
|
|
end
|
|
}
|
|
addon.RegisterCallback(init, format("Init%s", childName), 'Setup') |