Repository navigation
Expand file tree
/
Copy pathWCS_ClanPanel.lua
More file actions
227 lines (186 loc) · 7.94 KB
/
Copy pathWCS_ClanPanel.lua
File metadata and controls
227 lines (186 loc) · 7.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
--[[
WCS_ClanPanel.lua
Panel de Miembros del Clan para "El Séquito del Terror"
CORRECCIONES (Lua 5.0, Layout):
- Eliminado SetWidth(760) en statsFrame → ahora relativo (TOPRIGHT)
- Corregido table.sort con booleano directo (crash Lua 5.0)
- scrollFrame ahora usa BOTTOMRIGHT relativo en lugar de coordenadas fijas
]]--
if WCS_Brain and WCS_Brain.ENABLED == false then return end
WCS_ClanPanel = WCS_ClanPanel or {}
local panel = nil
local memberList = {}
local scrollFrame = nil
function WCS_ClanPanel:Initialize()
if panel then return end
panel = CreateFrame("Frame", "WCS_ClanPanelFrame", WCS_ClanUI.MainFrame.content)
panel:SetAllPoints(WCS_ClanUI.MainFrame.content)
panel:Hide()
-- Título
local title = panel:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("TOP", 0, -10)
title:SetText("|cff00ff00Miembros del Séquito|r")
title:SetFont("Fonts\\FRIZQT__.TTF", 16, "OUTLINE")
-- Estadísticas rápidas — relativas al padre
local statsFrame = CreateFrame("Frame", nil, panel)
statsFrame:SetPoint("TOPLEFT", 10, -40)
statsFrame:SetPoint("TOPRIGHT", -10, -40) -- no más SetWidth(760)
statsFrame:SetHeight(60)
statsFrame:SetBackdrop({
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = {left = 4, right = 4, top = 4, bottom = 4}
})
statsFrame:SetBackdropColor(0.1, 0.0, 0.15, 0.8)
statsFrame:SetBackdropBorderColor(0.2, 1.0, 0.2, 0.5)
-- Total de miembros
local totalText = statsFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
totalText:SetPoint("TOPLEFT", 10, -10)
totalText:SetText("|cff00ff00Total:|r 0")
panel.totalText = totalText
-- Miembros online
local onlineText = statsFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
onlineText:SetPoint("TOPLEFT", 10, -30)
onlineText:SetText("|cff00ff00Online:|r 0")
panel.onlineText = onlineText
-- Nivel promedio
local avgLevelText = statsFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
avgLevelText:SetPoint("LEFT", statsFrame, "LEFT", 200, 10)
avgLevelText:SetText("|cff00ff00Nivel Promedio:|r 0")
panel.avgLevelText = avgLevelText
-- Brujos en el clan
local warlocksText = statsFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
warlocksText:SetPoint("LEFT", statsFrame, "LEFT", 200, -10)
warlocksText:SetText("|cff00ff00Brujos:|r 0")
panel.warlocksText = warlocksText
-- Botón de actualizar
local refreshBtn = CreateFrame("Button", nil, statsFrame, "UIPanelButtonTemplate")
refreshBtn:SetWidth(100)
refreshBtn:SetHeight(25)
refreshBtn:SetPoint("RIGHT", -10, 0)
refreshBtn:SetText("Actualizar")
refreshBtn:SetScript("OnClick", function()
WCS_ClanPanel:UpdateMemberList()
end)
-- Scroll frame para lista de miembros — relativo al padre
scrollFrame = CreateFrame("ScrollFrame", "WCS_ClanPanel_ScrollFrame", panel, "UIPanelScrollFrameTemplate")
scrollFrame:SetPoint("TOPLEFT", 10, -110)
scrollFrame:SetPoint("BOTTOMRIGHT", -30, 10)
local scrollChild = CreateFrame("Frame", nil, scrollFrame)
scrollChild:SetWidth(600)
scrollChild:SetHeight(1)
scrollFrame:SetScrollChild(scrollChild)
panel.scrollChild = scrollChild
self.panel = panel
self:UpdateMemberList()
end
function WCS_ClanPanel:UpdateMemberList()
if not self.panel then return end
-- Recrear el scroll child (Lua 5.0: no podemos DestroyFrame)
if scrollFrame then
local scrollChild = CreateFrame("Frame", nil, scrollFrame)
scrollChild:SetWidth(600)
scrollChild:SetHeight(1)
scrollFrame:SetScrollChild(scrollChild)
self.panel.scrollChild = scrollChild
end
GuildRoster()
local numTotal, numOnline = GetNumGuildMembers()
numTotal = numTotal or 0
numOnline = numOnline or 0
if numTotal == 0 then
local noGuildText = self.panel.scrollChild:CreateFontString(nil, "OVERLAY", "GameFontNormal")
noGuildText:SetPoint("TOP", 0, -20)
noGuildText:SetText("|cffff0000No estás en un clan o el roster no está cargado.|r")
return
end
self.panel.totalText:SetText("|cff00ff00Total:|r " .. numTotal)
self.panel.onlineText:SetText("|cff00ff00Online:|r " .. numOnline)
local totalLevel = 0
local numWarlocks = 0
local yOffset = -5
memberList = {}
for i = 1, numTotal do
local name, rank, rankIndex, level, class, zone, note, officernote, online = GetGuildRosterInfo(i)
if name then
level = level or 1
class = class or "Unknown"
rank = rank or "Member"
zone = zone or "Unknown"
online = online or false
totalLevel = totalLevel + level
local classUpper = string.upper(class)
if classUpper == "WARLOCK" then
numWarlocks = numWarlocks + 1
end
table.insert(memberList, {
name = name,
rank = rank,
level = level,
class = class,
zone = zone,
online = online
})
end
end
local avgLevel = math.floor(totalLevel / numTotal)
self.panel.avgLevelText:SetText("|cff00ff00Nivel Promedio:|r " .. avgLevel)
self.panel.warlocksText:SetText("|cff00ff00Brujos:|r " .. numWarlocks)
-- CORRECCIÓN: table.sort con booleano → Lua 5.0 crash si return a.online
-- Usar comparación numérica explícita
table.sort(memberList, function(a, b)
local ao = a.online and 1 or 0
local bo = b.online and 1 or 0
if ao ~= bo then
return ao > bo -- online primero
end
return a.level > b.level
end)
for i = 1, table.getn(memberList) do
local member = memberList[i]
local entry = CreateFrame("Frame", nil, self.panel.scrollChild)
entry:SetWidth(590)
entry:SetHeight(30)
entry:SetPoint("TOPLEFT", 5, yOffset)
local bg = entry:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints(entry)
if math.mod(i, 2) == 0 then
bg:SetTexture(0.1, 0.1, 0.1, 0.5)
else
bg:SetTexture(0.15, 0.15, 0.15, 0.5)
end
local nameColor = member.online and "|cff00ff00" or "|cff888888"
local nameText = entry:CreateFontString(nil, "OVERLAY", "GameFontNormal")
nameText:SetPoint("LEFT", 10, 0)
nameText:SetText(nameColor .. member.name .. "|r")
local levelText = entry:CreateFontString(nil, "OVERLAY", "GameFontNormal")
levelText:SetPoint("LEFT", 180, 0)
levelText:SetText(nameColor .. "Nv " .. member.level .. "|r")
local classText = entry:CreateFontString(nil, "OVERLAY", "GameFontNormal")
classText:SetPoint("LEFT", 240, 0)
-- RAID_CLASS_COLORS usa claves en mayúsculas
local classKey = string.upper(member.class or "")
local classColor = (RAID_CLASS_COLORS and RAID_CLASS_COLORS[classKey]) or {r=1, g=1, b=1}
classText:SetTextColor(classColor.r, classColor.g, classColor.b)
classText:SetText(member.class or "Unknown")
local rankText = entry:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
rankText:SetPoint("LEFT", 340, 0)
rankText:SetText(nameColor .. member.rank .. "|r")
local zoneText = entry:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
zoneText:SetPoint("LEFT", 460, 0)
zoneText:SetText(nameColor .. (member.zone or "?") .. "|r")
yOffset = yOffset - 30
end
self.panel.scrollChild:SetHeight(math.abs(yOffset) + 10)
end
function WCS_ClanPanel:Show()
if self.panel then
self.panel:Show()
self:UpdateMemberList()
end
end
function WCS_ClanPanel:Hide()
if self.panel then self.panel:Hide() end
end
_G["WCS_ClanPanel"] = WCS_ClanPanel