mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 16:34:45 +00:00
update Guild datatext
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
local E, L, V, P, G = unpack(ElvUI)
|
||||||
local DT = E:GetModule("DataTexts");
|
local DT = E:GetModule("DataTexts")
|
||||||
|
|
||||||
--Cache global variables
|
--Cache global variables
|
||||||
--Lua functions
|
--Lua functions
|
||||||
local unpack = unpack
|
local select, unpack = select, unpack
|
||||||
local format, join = string.format, string.join
|
local format, find, join, upper = string.format, string.find, string.join, string.upper
|
||||||
local sort, wipe = table.sort, wipe
|
local getn, sort, wipe = table.getn, table.sort, table.wipe
|
||||||
--WoW API / Variables
|
--WoW API / Variables
|
||||||
local EasyMenu = EasyMenu
|
local CreateFrame = CreateFrame
|
||||||
local GetGuildInfo = GetGuildInfo
|
local GetGuildInfo = GetGuildInfo
|
||||||
local GetGuildRosterInfo = GetGuildRosterInfo
|
local GetGuildRosterInfo = GetGuildRosterInfo
|
||||||
local GetGuildRosterMOTD = GetGuildRosterMOTD
|
local GetGuildRosterMOTD = GetGuildRosterMOTD
|
||||||
@@ -16,94 +16,90 @@ local GetNumGuildMembers = GetNumGuildMembers
|
|||||||
local GetQuestDifficultyColor = GetQuestDifficultyColor
|
local GetQuestDifficultyColor = GetQuestDifficultyColor
|
||||||
local GetRealZoneText = GetRealZoneText
|
local GetRealZoneText = GetRealZoneText
|
||||||
local GuildRoster = GuildRoster
|
local GuildRoster = GuildRoster
|
||||||
local InviteUnit = InviteUnit
|
local InviteByName = InviteByName
|
||||||
local IsInGuild = IsInGuild
|
local IsInGuild = IsInGuild
|
||||||
local IsShiftKeyDown = IsShiftKeyDown
|
local IsShiftKeyDown = IsShiftKeyDown
|
||||||
local LoadAddOn = LoadAddOn
|
local L_EasyMenu = L_EasyMenu
|
||||||
local SetItemRef = SetItemRef
|
local SetItemRef = SetItemRef
|
||||||
local ToggleFriendsFrame = ToggleFriendsFrame
|
local ToggleFriendsFrame = ToggleFriendsFrame
|
||||||
local UnitInParty = UnitInParty
|
|
||||||
local UnitInRaid = UnitInRaid
|
|
||||||
local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS
|
|
||||||
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
|
|
||||||
local MOTD_COLON = MOTD_COLON
|
|
||||||
|
|
||||||
local FRIENDS_LIST_ONLINE = "FRIENDS_LIST_ONLINE"
|
local CHAT_MSG_WHISPER_INFORM, GUILD, GUILD_MOTD, GUILD_ONLINE_LABEL, GUILD_RANK1_DESC, LABEL_NOTE, OPTIONS_MENU, PARTY_INVITE = CHAT_MSG_WHISPER_INFORM, GUILD, GUILD_MOTD, GUILD_ONLINE_LABEL, GUILD_RANK1_DESC, LABEL_NOTE, OPTIONS_MENU, PARTY_INVITE
|
||||||
|
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
|
||||||
|
|
||||||
local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
|
local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
|
||||||
local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
|
local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
|
||||||
|
local groupedTable = { "|cffaaaaaa*|r", "" }
|
||||||
local displayString = ""
|
local displayString = ""
|
||||||
local noGuildString = ""
|
local noGuildString = ""
|
||||||
local guildInfoString = "%s"
|
local guildInfoString = "%s"
|
||||||
local guildInfoString2 = join("", GUILD, ": %d/%d")
|
local guildInfoString2 = join("", GUILD, ": %d/%d")
|
||||||
local guildMotDString = "%s |cffaaaaaa |cffffffff%s"
|
local guildMotDString = "%s |cffaaaaaa- |cffffffff%s"
|
||||||
local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s"
|
local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s"
|
||||||
local levelNameStatusString = "|cff%02x%02x%02x%d|r %s "
|
local levelNameStatusString = "|cff%02x%02x%02x%d|r %s"
|
||||||
local nameRankString = "%s |cff999999-|cffffffff %s"
|
local nameRankString = "%s |cff999999-|cffffffff %s"
|
||||||
local moreMembersOnlineString = join("", "+ %d ", FRIENDS_LIST_ONLINE, "...")
|
local moreMembersOnlineString = join("", "+ %d ", GUILD_ONLINE_LABEL, "...")
|
||||||
local noteString = join("", "|cff999999 ", LABEL_NOTE, ":|r %s")
|
local noteString = join("", "|cff999999 ", LABEL_NOTE, ":|r %s")
|
||||||
local officerNoteString = join("", "|cff999999 ", GUILD_RANK1_DESC, ":|r %s")
|
local officerNoteString = join("", "|cff999999 ", GUILD_RANK1_DESC, ":|r %s")
|
||||||
local guildTable, guildMotD = {}, ""
|
local guildTable, guildMotD = {}, ""
|
||||||
local lastPanel
|
local lastPanel
|
||||||
|
|
||||||
|
local function sortByRank(a, b)
|
||||||
|
if a and b then
|
||||||
|
return a[9] < b[9]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function sortByName(a, b)
|
||||||
|
if a and b then
|
||||||
|
return a[1] < b[1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function SortGuildTable(shift)
|
local function SortGuildTable(shift)
|
||||||
sort(guildTable, function(a, b)
|
if shift then
|
||||||
if a and b then
|
sort(guildTable, sortByRank)
|
||||||
if shift then
|
else
|
||||||
return a[9] < b[9]
|
sort(guildTable, sortByName)
|
||||||
else
|
end
|
||||||
return a[1] < b[1]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function BuildGuildTable()
|
local function BuildGuildTable()
|
||||||
wipe(guildTable)
|
wipe(guildTable)
|
||||||
local _, name, rank, level, zone, note, officernote, connected, status, class
|
local name, rank, rankIndex, level, class, zone, note, officernote, online
|
||||||
|
|
||||||
local totalMembers = GetNumGuildMembers()
|
local totalMembers = GetNumGuildMembers()
|
||||||
for i = 1, totalMembers do
|
for i = 1, totalMembers do
|
||||||
name, rank, _, level, class, zone, note, officernote, connected, status = GetGuildRosterInfo(i)
|
name, rank, rankIndex, level, class, zone, note, officernote, online = GetGuildRosterInfo(i)
|
||||||
|
if not name then break end
|
||||||
|
|
||||||
if connected then
|
if online then
|
||||||
guildTable[getn(guildTable) + 1] = {name, rank, level, zone, note, officernote, connected, status, string.upper(class)}
|
guildTable[getn(guildTable) + 1] = {name, rank, level, zone, note, officernote, online, upper(class), rankIndex}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function UpdateGuildMessage()
|
|
||||||
guildMotD = GetGuildRosterMOTD()
|
|
||||||
end
|
|
||||||
|
|
||||||
local eventHandlers = {
|
local eventHandlers = {
|
||||||
["CHAT_MSG_SYSTEM"] = function()
|
|
||||||
GuildRoster()
|
|
||||||
end,
|
|
||||||
-- when we enter the world and guildframe is not available then
|
-- when we enter the world and guildframe is not available then
|
||||||
-- load guild frame, update guild message and guild xp
|
-- load guild frame, update guild message
|
||||||
["PLAYER_ENTERING_WORLD"] = function()
|
["PLAYER_ENTERING_WORLD"] = function()
|
||||||
if IsInGuild() then
|
guildMotD = GetGuildRosterMOTD()
|
||||||
GuildRoster()
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
-- Guild Roster updated, so rebuild the guild table
|
-- Guild Roster updated, so rebuild the guild table
|
||||||
["GUILD_ROSTER_UPDATE"] = function(self)
|
["GUILD_ROSTER_UPDATE"] = function(self)
|
||||||
GuildRoster()
|
GuildRoster()
|
||||||
BuildGuildTable()
|
BuildGuildTable()
|
||||||
UpdateGuildMessage()
|
guildMotD = GetGuildRosterMOTD()
|
||||||
|
|
||||||
if GetMouseFocus() == self then
|
if GetMouseFocus() == self then
|
||||||
self:GetScript("OnEnter")(self, nil, true)
|
self:GetScript("OnEnter")(self, nil, true)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
["PLAYER_GUILD_UPDATE"] = function()
|
["PLAYER_GUILD_UPDATE"] = GuildRoster,
|
||||||
GuildRoster()
|
|
||||||
end,
|
|
||||||
-- our guild message of the day changed
|
-- our guild message of the day changed
|
||||||
["GUILD_MOTD"] = function(_, arg1)
|
["GUILD_MOTD"] = function()
|
||||||
guildMotD = arg1
|
guildMotD = arg1
|
||||||
end,
|
end,
|
||||||
["ELVUI_FORCE_RUN"] = E.noop,
|
["ELVUI_FORCE_RUN"] = GuildRoster,
|
||||||
["ELVUI_COLOR_UPDATE"] = E.noop,
|
["ELVUI_COLOR_UPDATE"] = E.noop,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +108,7 @@ local function OnEvent(self, event, ...)
|
|||||||
|
|
||||||
if IsInGuild() then
|
if IsInGuild() then
|
||||||
eventHandlers[event](self, unpack(arg))
|
eventHandlers[event](self, unpack(arg))
|
||||||
|
|
||||||
self.text:SetText(format(displayString, getn(guildTable)))
|
self.text:SetText(format(displayString, getn(guildTable)))
|
||||||
else
|
else
|
||||||
self.text:SetText(noGuildString)
|
self.text:SetText(noGuildString)
|
||||||
@@ -120,26 +117,26 @@ end
|
|||||||
|
|
||||||
local menuFrame = CreateFrame("Frame", "GuildDatatTextRightClickMenu", E.UIParent, "L_UIDropDownMenuTemplate")
|
local menuFrame = CreateFrame("Frame", "GuildDatatTextRightClickMenu", E.UIParent, "L_UIDropDownMenuTemplate")
|
||||||
local menuList = {
|
local menuList = {
|
||||||
{ text = OPTIONS_MENU, isTitle = true, notCheckable = true},
|
{text = OPTIONS_MENU, isTitle = true, notCheckable = true},
|
||||||
{ text = INVITE, hasArrow = true, notCheckable = true,},
|
{text = PARTY_INVITE, hasArrow = true, notCheckable = true},
|
||||||
{ text = CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable=true,}
|
{text = CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable = true}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function inviteClick(_, playerName)
|
local function inviteClick(playerName)
|
||||||
menuFrame:Hide()
|
menuFrame:Hide()
|
||||||
InviteUnit(playerName)
|
InviteByName(playerName)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function whisperClick(_, playerName)
|
local function whisperClick(playerName)
|
||||||
menuFrame:Hide()
|
menuFrame:Hide()
|
||||||
SetItemRef("player:"..playerName, ("|Hplayer:%1$s|h[%1$s]|h"):format(playerName), "LeftButton")
|
SetItemRef("player:"..playerName, format("|Hplayer:%1$s|h[%1$s]|h", playerName), "LeftButton")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function OnClick(_, btn)
|
local function OnClick()
|
||||||
if btn == "RightButton" and IsInGuild() then
|
if arg1 == "RightButton" and IsInGuild() then
|
||||||
DT.tooltip:Hide()
|
DT.tooltip:Hide()
|
||||||
|
|
||||||
local classc, levelc, grouped, info
|
local classc, levelc, info
|
||||||
local menuCountWhispers = 0
|
local menuCountWhispers = 0
|
||||||
local menuCountInvites = 0
|
local menuCountInvites = 0
|
||||||
|
|
||||||
@@ -149,17 +146,13 @@ local function OnClick(_, btn)
|
|||||||
for i = 1, getn(guildTable) do
|
for i = 1, getn(guildTable) do
|
||||||
info = guildTable[i]
|
info = guildTable[i]
|
||||||
if info[7] and info[1] ~= E.myname then
|
if info[7] and info[1] ~= E.myname then
|
||||||
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[9]], GetQuestDifficultyColor(info[3])
|
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[8]], GetQuestDifficultyColor(info[3])
|
||||||
--if UnitInParty(info[1]) or UnitInRaid(info[1]) then
|
|
||||||
-- grouped = "|cffaaaaaa*|r"
|
menuCountInvites = menuCountInvites + 1
|
||||||
--elseif not info[11] then
|
menuList[2].menuList[menuCountInvites] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info[3], classc.r*255,classc.g*255,classc.b*255, info[1], ""), arg1 = info[1],notCheckable=true, func = inviteClick}
|
||||||
menuCountInvites = menuCountInvites + 1
|
|
||||||
grouped = ""
|
|
||||||
menuList[2].menuList[menuCountInvites] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info[3], classc.r*255,classc.g*255,classc.b*255, info[1], ""), arg1 = info[1],notCheckable=true, func = inviteClick}
|
|
||||||
--end
|
|
||||||
menuCountWhispers = menuCountWhispers + 1
|
menuCountWhispers = menuCountWhispers + 1
|
||||||
if not grouped then grouped = "" end
|
menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info[3], classc.r*255,classc.g*255,classc.b*255, info[1], ""), arg1 = info[1],notCheckable=true, func = whisperClick}
|
||||||
menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info[3], classc.r*255,classc.g*255,classc.b*255, info[1], grouped), arg1 = info[1],notCheckable=true, func = whisperClick}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -175,12 +168,7 @@ local function OnEnter(self, _, noUpdate)
|
|||||||
DT:SetupTooltip(self)
|
DT:SetupTooltip(self)
|
||||||
|
|
||||||
local online, total = 0, GetNumGuildMembers(true)
|
local online, total = 0, GetNumGuildMembers(true)
|
||||||
for i = 0, total do
|
for i = 0, total do if select(9, GetGuildRosterInfo(i)) then online = online + 1 end end
|
||||||
local _, _, _, _, _, _, _, _, _, status = GetGuildRosterInfo(i)
|
|
||||||
if status then
|
|
||||||
online = online + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if getn(guildTable) == 0 then BuildGuildTable() end
|
if getn(guildTable) == 0 then BuildGuildTable() end
|
||||||
|
|
||||||
SortGuildTable(IsShiftKeyDown())
|
SortGuildTable(IsShiftKeyDown())
|
||||||
@@ -194,7 +182,7 @@ local function OnEnter(self, _, noUpdate)
|
|||||||
|
|
||||||
if guildMotD ~= "" then
|
if guildMotD ~= "" then
|
||||||
DT.tooltip:AddLine(" ")
|
DT.tooltip:AddLine(" ")
|
||||||
DT.tooltip:AddLine(format(guildMotDString, GUILD_MOTD_LABEL, guildMotD), ttsubh.r, ttsubh.g, ttsubh.b, 1)
|
DT.tooltip:AddLine(format(guildMotDString, GUILD_MOTD, guildMotD), ttsubh.r, ttsubh.g, ttsubh.b, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
local zonec, classc, levelc, info
|
local zonec, classc, levelc, info
|
||||||
@@ -210,15 +198,14 @@ local function OnEnter(self, _, noUpdate)
|
|||||||
|
|
||||||
info = guildTable[i]
|
info = guildTable[i]
|
||||||
if GetRealZoneText() == info[4] then zonec = activezone else zonec = inactivezone end
|
if GetRealZoneText() == info[4] then zonec = activezone else zonec = inactivezone end
|
||||||
|
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[8]], GetQuestDifficultyColor(info[3])
|
||||||
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[9]], GetQuestDifficultyColor(info[3])
|
|
||||||
|
|
||||||
if IsShiftKeyDown() then
|
if IsShiftKeyDown() then
|
||||||
DT.tooltip:AddDoubleLine(format(nameRankString, info[1], info[2]), info[4], classc.r, classc.g, classc.b, zonec.r, zonec.g, zonec.b)
|
DT.tooltip:AddDoubleLine(format(nameRankString, info[1], info[2]), info[4], classc.r, classc.g, classc.b, zonec.r, zonec.g, zonec.b)
|
||||||
if info[5] ~= "" then DT.tooltip:AddLine(format(noteString, info[5]), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
|
if info[5] ~= "" then DT.tooltip:AddLine(format(noteString, info[5]), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
|
||||||
if info[6] ~= "" then DT.tooltip:AddLine(format(officerNoteString, info[6]), ttoff.r, ttoff.g, ttoff.b, 1) end
|
if info[6] ~= "" then DT.tooltip:AddLine(format(officerNoteString, info[6]), ttoff.r, ttoff.g, ttoff.b, 1) end
|
||||||
else
|
else
|
||||||
DT.tooltip:AddDoubleLine(format(levelNameStatusString, levelc.r*255, levelc.g*255, levelc.b*255, info[3], info[1], info[4]), info[4], classc.r,classc.g,classc.b, zonec.r,zonec.g,zonec.b)
|
DT.tooltip:AddDoubleLine(format(levelNameStatusString, levelc.r*255, levelc.g*255, levelc.b*255, info[3], info[1], info[2], info[8]), info[4], classc.r,classc.g,classc.b, zonec.r,zonec.g,zonec.b)
|
||||||
end
|
end
|
||||||
shown = shown + 1
|
shown = shown + 1
|
||||||
end
|
end
|
||||||
@@ -240,4 +227,4 @@ local function ValueColorUpdate(hex)
|
|||||||
end
|
end
|
||||||
E["valueColorUpdateFuncs"][ValueColorUpdate] = true
|
E["valueColorUpdateFuncs"][ValueColorUpdate] = true
|
||||||
|
|
||||||
DT:RegisterDatatext("Guild", {"PLAYER_ENTERING_WORLD", "CHAT_MSG_SYSTEM", "GUILD_ROSTER_UPDATE", "PLAYER_GUILD_UPDATE", "GUILD_MOTD"}, OnEvent, nil, OnClick, OnEnter, nil, GUILD)
|
DT:RegisterDatatext("Guild", {"PLAYER_ENTERING_WORLD", "GUILD_ROSTER_UPDATE", "PLAYER_GUILD_UPDATE", "GUILD_MOTD"}, OnEvent, nil, OnClick, OnEnter, nil, GUILD)
|
||||||
Reference in New Issue
Block a user