mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
update guild datatext
This commit is contained in:
@@ -197,7 +197,7 @@ function DT:AssignPanelToDataText(panel, data)
|
||||
|
||||
if data["eventFunc"] then
|
||||
panel:SetScript("OnEvent", function()
|
||||
data["eventFunc"](this, event)
|
||||
data["eventFunc"](this, event, arg1, arg2, arg3)
|
||||
end)
|
||||
data["eventFunc"](panel, "ELVUI_FORCE_RUN")
|
||||
end
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
local E, L, V, P, G = unpack(ElvUI)
|
||||
local DT = E:GetModule("DataTexts")
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local select, unpack = select, unpack
|
||||
local format, find, join, upper = string.format, string.find, string.join, string.upper
|
||||
local unpack = unpack
|
||||
local format, join = string.format, string.join
|
||||
local getn, tinsert, sort, wipe = table.getn, table.insert, table.sort, table.wipe
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
local GetGuildInfo = GetGuildInfo
|
||||
local GetGuildRosterInfo = GetGuildRosterInfo
|
||||
local GetGuildRosterMOTD = GetGuildRosterMOTD
|
||||
@@ -19,15 +18,15 @@ local GuildRoster = GuildRoster
|
||||
local InviteByName = InviteByName
|
||||
local IsInGuild = IsInGuild
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local L_EasyMenu = L_EasyMenu
|
||||
local SetItemRef = SetItemRef
|
||||
local ToggleFriendsFrame = ToggleFriendsFrame
|
||||
local LOCALIZED_CLASS_NAMES_MALE = LOCALIZED_CLASS_NAMES_MALE
|
||||
local LOCALIZED_CLASS_NAMES_FEMALE = LOCALIZED_CLASS_NAMES_FEMALE
|
||||
local CHAT_MSG_WHISPER_INFORM, GUILD, GUILD_MOTD, GUILD_ONLINE_LABEL, GUILD_RANK1_DESC = CHAT_MSG_WHISPER_INFORM, GUILD, GUILD_MOTD, GUILD_ONLINE_LABEL, GUILD_RANK1_DESC
|
||||
local LABEL_NOTE, OPTIONS_MENU, PARTY_INVITE = LABEL_NOTE, OPTIONS_MENU, PARTY_INVITE
|
||||
|
||||
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
|
||||
local GUILD = GUILD
|
||||
local GUILD_MOTD = GUILD_MOTD
|
||||
local LOCALIZED_CLASS_NAMES_FEMALE = LOCALIZED_CLASS_NAMES_FEMALE
|
||||
local LOCALIZED_CLASS_NAMES_MALE = LOCALIZED_CLASS_NAMES_MALE
|
||||
|
||||
local L_EasyMenu = L_EasyMenu
|
||||
|
||||
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}
|
||||
@@ -73,7 +72,7 @@ local function BuildGuildTable()
|
||||
local totalMembers = GetNumGuildMembers()
|
||||
for i = 1, totalMembers do
|
||||
name, rank, rankIndex, level, class, zone, note, officernote, online = GetGuildRosterInfo(i)
|
||||
if not name then break end
|
||||
if not name then return end
|
||||
|
||||
if online then
|
||||
for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if class == v then class = k end end
|
||||
@@ -83,17 +82,20 @@ local function BuildGuildTable()
|
||||
end
|
||||
end
|
||||
|
||||
local function UpdateGuildMessage()
|
||||
guildMotD = GetGuildRosterMOTD()
|
||||
end
|
||||
|
||||
local eventHandlers = {
|
||||
-- when we enter the world and guildframe is not available then
|
||||
-- load guild frame, update guild message
|
||||
["PLAYER_ENTERING_WORLD"] = function()
|
||||
guildMotD = GetGuildRosterMOTD()
|
||||
GuildRoster()
|
||||
end,
|
||||
-- Guild Roster updated, so rebuild the guild table
|
||||
["GUILD_ROSTER_UPDATE"] = function(self)
|
||||
GuildRoster()
|
||||
BuildGuildTable()
|
||||
guildMotD = GetGuildRosterMOTD()
|
||||
UpdateGuildMessage()
|
||||
|
||||
if GetMouseFocus() == self then
|
||||
self:GetScript("OnEnter")(self, nil, true)
|
||||
@@ -101,18 +103,20 @@ local eventHandlers = {
|
||||
end,
|
||||
["PLAYER_GUILD_UPDATE"] = GuildRoster,
|
||||
-- our guild message of the day changed
|
||||
["GUILD_MOTD"] = function()
|
||||
["GUILD_MOTD"] = function(self, arg1)
|
||||
guildMotD = arg1
|
||||
end,
|
||||
["ELVUI_FORCE_RUN"] = GuildRoster,
|
||||
["ELVUI_FORCE_RUN"] = function()
|
||||
GuildRoster()
|
||||
end, -- Temporarily
|
||||
["ELVUI_COLOR_UPDATE"] = E.noop,
|
||||
}
|
||||
|
||||
local function OnEvent(self, event, ...)
|
||||
local function OnEvent(self, event, arg1)
|
||||
lastPanel = self
|
||||
|
||||
if IsInGuild() then
|
||||
eventHandlers[event](self, unpack(arg))
|
||||
eventHandlers[event](self, arg1)
|
||||
|
||||
self.text:SetText(format(displayString, getn(guildTable)))
|
||||
else
|
||||
@@ -142,8 +146,6 @@ local function OnClick()
|
||||
DT.tooltip:Hide()
|
||||
|
||||
local classc, levelc, info
|
||||
local menuCountWhispers = 0
|
||||
local menuCountInvites = 0
|
||||
|
||||
menuList[2].menuList = {}
|
||||
menuList[3].menuList = {}
|
||||
@@ -151,13 +153,10 @@ local function OnClick()
|
||||
for i = 1, getn(guildTable) do
|
||||
info = guildTable[i]
|
||||
if info[7] and info[1] ~= E.myname then
|
||||
classc, levelc = (CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[8]], GetQuestDifficultyColor(info[3])
|
||||
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[8]], GetQuestDifficultyColor(info[3])
|
||||
|
||||
menuCountInvites = menuCountInvites + 1
|
||||
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}
|
||||
|
||||
menuCountWhispers = menuCountWhispers + 1
|
||||
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}
|
||||
tinsert(menuList[2].menuList, {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})
|
||||
tinsert(menuList[3].menuList, {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})
|
||||
end
|
||||
end
|
||||
|
||||
@@ -173,8 +172,8 @@ local function OnEnter(self, _, noUpdate)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local online, total = 0, GetNumGuildMembers(true)
|
||||
for i = 0, total do if select(9, GetGuildRosterInfo(i)) then online = online + 1 end end
|
||||
if getn(guildTable) == 0 then BuildGuildTable() end
|
||||
for i = 0, total do local _, _, _, _, _, _, _, _, connected = GetGuildRosterInfo(i) if connected then online = online + 1 end end
|
||||
if not guildTable[1] then BuildGuildTable() end
|
||||
|
||||
SortGuildTable(IsShiftKeyDown())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user