Repository navigation
Expand file tree
/
Copy pathGuild-View-Extended.lua
More file actions
2535 lines (2308 loc) · 96.5 KB
/
Copy pathGuild-View-Extended.lua
File metadata and controls
2535 lines (2308 loc) · 96.5 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---------------------------------------------------------------------------
-- Guild-View-Extended
-- Erweitertes Gildenfenster fuer World of Warcraft 3.3.5a (Build 12340)
-- Oeffnen: /gve oder /guildview (oder die eigene Gildentaste)
---------------------------------------------------------------------------
local GVE = {}
_G["GVE"] = GVE
---------------------------------------------------------------------------
-- Log-System: /gve log oeffnet ein Fenster mit kopierbarem Text.
-- Kritische Pfade laufen in pcall -- Fehler landen im Log statt das
-- Addon zu toeten.
---------------------------------------------------------------------------
local LOG_MAX = 200
GVE.log = {}
local CSV_MAX_NAMES = 5000
local CSV_TEXT = GetLocale() == "deDE" and {
button = "CSV exportieren",
loading = "Roster wird geladen ...",
title = "CSV-Export",
copyHint = "Drücke Strg+C, um die CSV zu kopieren.",
count = "%d Charaktere exportiert",
close = "Schließen",
tooMany = "CSV-Export abgebrochen: Mehr als %d eindeutige Charaktere gefunden.",
} or {
button = "Export CSV",
loading = "Loading roster ...",
title = "CSV Export",
copyHint = "Press Ctrl+C to copy the CSV.",
count = "%d characters exported",
close = CLOSE or "Close",
tooMany = "CSV export cancelled: More than %d unique characters were found.",
}
local ACTION_TEXT = GetLocale() == "deDE" and {
inviteGroup = "Invite GRP",
leaveGuild = "Gilde verlassen",
leaveConfirm = "Möchtest du die Gilde wirklich verlassen?",
} or {
inviteGroup = "Invite GRP",
leaveGuild = "Leave Guild",
leaveConfirm = "Are you sure you want to leave the guild?",
}
local function Log(msg)
local t = GVE.log
t[#t+1] = date("%H:%M:%S").." "..tostring(msg)
if #t > LOG_MAX then table.remove(t, 1) end
end
-- Auch optionale GuildView-Module schreiben in denselben kopierbaren Log.
function GVE:AddLog(msg)
Log(msg)
end
local function Guard(label, fn, ...)
local ok, err = pcall(fn, ...)
if not ok then
Log("FEHLER in "..label..": "..tostring(err))
if not GVE.errorNotified then
GVE.errorNotified = true
print("|cffff3333[Guild-View-Extended]|r Fehler aufgetreten -- |cffffcc00/gve log|r")
end
end
return ok
end
-- Log-Fenster mit markierbarem Text (Strg+C zum Kopieren)
local logFrame
local function ShowLogWindow()
if not logFrame then
local w = CreateFrame("Frame", "GVELogWindow", UIParent)
w:SetWidth(560); w:SetHeight(360)
w:SetPoint("CENTER")
w:SetMovable(true); w:EnableMouse(true)
w:RegisterForDrag("LeftButton")
w:SetScript("OnDragStart", w.StartMoving)
w:SetScript("OnDragStop", w.StopMovingOrSizing)
w:SetFrameStrata("DIALOG")
w:SetBackdrop({
bgFile="Interface\\ChatFrame\\ChatFrameBackground",
edgeFile="Interface\\Tooltips\\UI-Tooltip-Border",
tile=true, tileSize=16, edgeSize=12,
insets={left=3,right=3,top=3,bottom=3},
})
w:SetBackdropColor(0, 0, 0, 0.95)
tinsert(UISpecialFrames, "GVELogWindow")
local title = w:CreateFontString(nil, "OVERLAY", "GameFontNormal")
title:SetPoint("TOP", w, "TOP", 0, -8)
title:SetText("|cff33aaffGuild-View-Extended|r - Log (Strg+C kopiert Markiertes)")
local xb = CreateFrame("Button", nil, w, "UIPanelCloseButton")
xb:SetPoint("TOPRIGHT", w, "TOPRIGHT", 2, 2)
local sf = CreateFrame("ScrollFrame", "GVELogWindowScroll", w, "UIPanelScrollFrameTemplate")
sf:SetPoint("TOPLEFT", w, "TOPLEFT", 10, -28)
sf:SetPoint("BOTTOMRIGHT", w, "BOTTOMRIGHT", -30, 10)
local eb = CreateFrame("EditBox", nil, sf)
eb:SetMultiLine(true)
eb:SetFontObject(ChatFontNormal)
eb:SetWidth(500)
eb:SetAutoFocus(false)
eb:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
sf:SetScrollChild(eb)
w.editBox = eb
logFrame = w
end
logFrame.editBox:SetText(table.concat(GVE.log, "\n"))
logFrame:Show()
logFrame.editBox:HighlightText() -- alles vormarkiert -> direkt Strg+C
end
---------------------------------------------------------------------------
-- Layout-Konstanten
---------------------------------------------------------------------------
local W, H = 1080, 640
local PAD = 12
local TITLE_H = 48
local FILTER_H = 56
local COL_H = 22
local ROW_H = 32
local BOTTOM_H = 122
local ROSTER_REFRESH_SECONDS = 5
local ROSTER_W = W - PAD * 2
-- Platz fuer die komplette FauxScrollFrame-Scrollbar innerhalb des Fensters.
local LIST_W = ROSTER_W - 24
local ROSTER_H = H - PAD - TITLE_H - 6 - FILTER_H - 4 - COL_H - 2 - BOTTOM_H - PAD - 10
local NUM_ROWS = math.floor(ROSTER_H / ROW_H)
---------------------------------------------------------------------------
-- Klassen-Farben. Nichts hard-coden: der Client befuellt
-- RAID_CLASS_COLORS. Die Filterliste entsteht dynamisch aus dem Roster.
---------------------------------------------------------------------------
local function ClassColor(token)
local c = token and ((CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS or {})[token])
if c then return c.r, c.g, c.b end
return 0.8, 0.8, 0.8
end
---------------------------------------------------------------------------
-- Spalten
---------------------------------------------------------------------------
local COLS = {
{key=nil, label="", w=36, icon=true},
{key="name", label=NAME or "Name", w=155},
{key="level", label=(LEVEL or "Level").." & "..(CLASS or "Class"), w=170},
{key="zone", label=ZONE or "Zone", w=180},
{key="rank", label=RANK or "Rank", w=150},
{key="note", label=LABEL_NOTE or "Note", w=0},
}
do
local used = 0
for _, c in ipairs(COLS) do used = used + c.w end
COLS[#COLS].w = LIST_W - used - (#COLS - 1)
end
---------------------------------------------------------------------------
-- Zustand
---------------------------------------------------------------------------
local members = {}
local filtered = {}
local ranks = {} -- {[rankName]=true}
local classes = {} -- {[classKey]=Anzeigename}, dynamisch aus Roster
local sortKey = "name"
local sortAsc = true
local searchStr = ""
-- Filter: leeres Set = kein Filter (alle sichtbar)
local filterClasses = {}
local filterRanks = {}
local filterOnline = false
-- Lua 5.1 lower() behandelt UTF-8 je nach Client nur eingeschraenkt.
-- Die in WoW-Namen ueblichen lateinischen Grossbuchstaben werden deshalb
-- vor dem ASCII-lower() explizit gefaltet. Der Originalname bleibt unveraendert.
local UTF8_CASE_PAIRS = {
{"À","à"}, {"Á","á"}, {"Â","â"}, {"Ã","ã"}, {"Ä","ä"}, {"Å","å"},
{"Æ","æ"}, {"Ç","ç"}, {"È","è"}, {"É","é"}, {"Ê","ê"}, {"Ë","ë"},
{"Ì","ì"}, {"Í","í"}, {"Î","î"}, {"Ï","ï"}, {"Ð","ð"}, {"Ñ","ñ"},
{"Ò","ò"}, {"Ó","ó"}, {"Ô","ô"}, {"Õ","õ"}, {"Ö","ö"}, {"Ø","ø"},
{"Ù","ù"}, {"Ú","ú"}, {"Û","û"}, {"Ü","ü"}, {"Ý","ý"}, {"Þ","þ"},
{"Ā","ā"}, {"Ă","ă"}, {"Ą","ą"}, {"Ć","ć"}, {"Ĉ","ĉ"}, {"Ċ","ċ"},
{"Č","č"}, {"Ď","ď"}, {"Đ","đ"}, {"Ē","ē"}, {"Ĕ","ĕ"}, {"Ė","ė"},
{"Ę","ę"}, {"Ě","ě"}, {"Ĝ","ĝ"}, {"Ğ","ğ"}, {"Ġ","ġ"}, {"Ģ","ģ"},
{"Ĥ","ĥ"}, {"Ħ","ħ"}, {"Ĩ","ĩ"}, {"Ī","ī"}, {"Ĭ","ĭ"}, {"Į","į"},
{"İ","i"}, {"IJ","ij"}, {"Ĵ","ĵ"}, {"Ķ","ķ"}, {"Ĺ","ĺ"}, {"Ļ","ļ"},
{"Ľ","ľ"}, {"Ŀ","ŀ"}, {"Ł","ł"}, {"Ń","ń"}, {"Ņ","ņ"}, {"Ň","ň"},
{"Ŋ","ŋ"}, {"Ō","ō"}, {"Ŏ","ŏ"}, {"Ő","ő"}, {"Œ","œ"}, {"Ŕ","ŕ"},
{"Ŗ","ŗ"}, {"Ř","ř"}, {"Ś","ś"}, {"Ŝ","ŝ"}, {"Ş","ş"}, {"Š","š"},
{"Ţ","ţ"}, {"Ť","ť"}, {"Ŧ","ŧ"}, {"Ũ","ũ"}, {"Ū","ū"}, {"Ŭ","ŭ"},
{"Ů","ů"}, {"Ű","ű"}, {"Ų","ų"}, {"Ŵ","ŵ"}, {"Ŷ","ŷ"}, {"Ÿ","ÿ"},
{"Ź","ź"}, {"Ż","ż"}, {"Ž","ž"}, {"ẞ","ß"},
}
local function CaseFoldName(value)
local folded = value
for _, pair in ipairs(UTF8_CASE_PAIRS) do
folded = folded:gsub(pair[1], pair[2])
end
return folded:lower()
end
function GVE:CaseFoldName(value)
return CaseFoldName(tostring(value or ""))
end
local function CleanCharacterName(value)
if type(value) ~= "string" then return nil end
local name = value:gsub("[\r\n]", "")
name = name:gsub("%-.*$", "")
name = name:gsub("^%s+", ""):gsub("%s+$", "")
if name == "" or name:find("%c") then return nil end
return name
end
local function IsPlayerCharacterName(value)
local playerName = UnitName("player")
local name = CleanCharacterName(value)
if not playerName or not name then return false end
return CaseFoldName(name) == CaseFoldName(playerName)
end
local function EscapeCSVValue(value)
if value:find('[,"\r\n]') then
return '"'..value:gsub('"', '""')..'"'
end
return value
end
-- Reine Hilfsfunktion, damit die CSV-Regeln ausserhalb des WoW-Clients
-- automatisiert getestet werden koennen. Bei Namensduplikaten bleiben
-- Schreibweise und Gildenrang des ersten Eintrags erhalten.
function GVE:BuildCSVFromMembers(rawMembers)
local unique, names = {}, {}
for _, rawMember in ipairs(rawMembers or {}) do
local rawName = type(rawMember) == "table" and rawMember.name or rawMember
local rank = type(rawMember) == "table" and rawMember.rank or ""
if type(rank) ~= "string" then rank = "" end
rank = rank:gsub("[\r\n]", "")
local name = CleanCharacterName(rawName)
if name then
local key = CaseFoldName(name)
if not unique[key] then
unique[key] = true
names[#names+1] = {name=name, rank=rank, key=key}
if #names > CSV_MAX_NAMES then
return nil, nil, format(CSV_TEXT.tooMany, CSV_MAX_NAMES)
end
end
end
end
table.sort(names, function(a, b)
if a.key == b.key then return a.name < b.name end
return a.key < b.key
end)
local lines = {"character_name,guild_rank"}
for _, entry in ipairs(names) do
lines[#lines+1] = EscapeCSVValue(entry.name)..","..EscapeCSVValue(entry.rank)
end
return table.concat(lines, "\n"), #names
end
-- "Zuletzt Online" ist nur fuer Gildenmeister und Offiziere gedacht;
-- als Offizier-Merkmal dient das Recht, Offiziersnotizen zu sehen.
local function CanSeeLastOnline()
return IsGuildLeader() or CanViewOfficerNote()
end
---------------------------------------------------------------------------
-- Backdrop-Definitionen
---------------------------------------------------------------------------
local MAIN_BD = {
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border",
tile=true, tileSize=32, edgeSize=32,
insets={left=11,right=12,top=12,bottom=11},
}
local PANEL_BD = {
bgFile="Interface\\ChatFrame\\ChatFrameBackground",
edgeFile="Interface\\Tooltips\\UI-Tooltip-Border",
tile=true, tileSize=16, edgeSize=12,
insets={left=3,right=3,top=3,bottom=3},
}
-- Flache, client-neutrale Gestaltung fuer die GuildView-eigenen Buttons.
-- Das 3.3.5a-UIPanelButtonTemplate kann je nach Client-Skin sehr dominant
-- (zum Beispiel rot) erscheinen. Blizzards eigene Dialoge bleiben davon
-- unberuehrt.
local UI_COLOR = {
window = {0.035, 0.047, 0.078, 0.98},
panel = {0.063, 0.086, 0.129, 0.96},
panelAlt = {0.082, 0.114, 0.165, 0.96},
hover = {0.105, 0.170, 0.235, 0.98},
pressed = {0.050, 0.145, 0.220, 0.98},
selected = {0.075, 0.205, 0.305, 0.98},
line = {0.153, 0.204, 0.278, 0.90},
accent = {0.200, 0.667, 1.000, 1.00},
text = {0.933, 0.957, 0.984, 1.00},
muted = {0.573, 0.635, 0.710, 1.00},
disabled = {0.250, 0.290, 0.340, 0.90},
}
local function SetRGBA(target, method, color)
target[method](target, color[1], color[2], color[3], color[4])
end
local function RefreshFlatButton(button)
local background, border
if not button:IsEnabled() then
background, border = UI_COLOR.window, UI_COLOR.disabled
elseif button.flatPressed then
background, border = UI_COLOR.pressed, UI_COLOR.accent
elseif button.flatSelected then
background, border = UI_COLOR.selected, UI_COLOR.accent
elseif button.flatHovered then
background, border = UI_COLOR.hover, UI_COLOR.accent
elseif button.flatPrimary then
background, border = UI_COLOR.selected, UI_COLOR.accent
else
background, border = UI_COLOR.panelAlt, UI_COLOR.line
end
SetRGBA(button, "SetBackdropColor", background)
SetRGBA(button, "SetBackdropBorderColor", border)
end
local function MakeFlatButton(parent, width, height, text, primary)
local button = CreateFrame("Button", nil, parent)
button:SetSize(width, height)
button:SetBackdrop(PANEL_BD)
button:SetNormalFontObject(GameFontNormalSmall)
button:SetHighlightFontObject(GameFontHighlightSmall)
button:SetDisabledFontObject(GameFontDisableSmall)
button:SetText(text or "")
button.flatPrimary = primary and true or false
button:SetScript("OnEnter", function(self)
self.flatHovered = true
RefreshFlatButton(self)
end)
button:SetScript("OnLeave", function(self)
self.flatHovered = nil
self.flatPressed = nil
RefreshFlatButton(self)
end)
button:SetScript("OnMouseDown", function(self)
if self:IsEnabled() then self.flatPressed = true; RefreshFlatButton(self) end
end)
button:SetScript("OnMouseUp", function(self)
self.flatPressed = nil
RefreshFlatButton(self)
end)
button:SetScript("OnEnable", RefreshFlatButton)
button:SetScript("OnDisable", RefreshFlatButton)
RefreshFlatButton(button)
return button
end
local function StyleFlatEditBox(editBox)
editBox:SetBackdrop(PANEL_BD)
SetRGBA(editBox, "SetBackdropColor", UI_COLOR.window)
SetRGBA(editBox, "SetBackdropBorderColor", UI_COLOR.line)
editBox:SetFontObject(GameFontHighlightSmall)
editBox:SetTextColor(UI_COLOR.text[1], UI_COLOR.text[2], UI_COLOR.text[3])
if editBox.SetTextInsets then editBox:SetTextInsets(7, 7, 0, 0) end
end
-- Ausschliesslich Texturen, die im originalen 3.3.5a-Client vorhanden sind.
local function AddButtonIcon(button, texturePath)
local icon = button:CreateTexture(nil, "ARTWORK")
icon:SetSize(15, 15)
icon:SetPoint("LEFT", button, "LEFT", 7, 0)
icon:SetTexture(texturePath or "Interface\\Icons\\INV_Misc_QuestionMark")
local label = button:GetFontString()
if label then
label:ClearAllPoints()
label:SetPoint("CENTER", button, "CENTER", 8, 0)
end
button.icon = icon
return icon
end
-- Die urspruenglichen, einzeln vorhandenen Klassenmotive des 3.3.5a-Clients.
-- Bewusst kein Atlas: angepasste Clients koennen dessen Inhalt oder globale
-- Koordinatentabellen ersetzen und dadurch alle Klassen falsch darstellen.
local CLASS_ICON_TEXTURES_335 = {
WARRIOR = "Interface\\Icons\\INV_Sword_27",
PALADIN = "Interface\\Icons\\INV_Hammer_01",
HUNTER = "Interface\\Icons\\INV_Weapon_Bow_07",
ROGUE = "Interface\\Icons\\INV_ThrowingKnife_04",
PRIEST = "Interface\\Icons\\INV_Staff_30",
DEATHKNIGHT = "Interface\\Icons\\Spell_Deathknight_ClassIcon",
SHAMAN = "Interface\\Icons\\INV_Jewelry_Talisman_04",
MAGE = "Interface\\Icons\\INV_Staff_13",
WARLOCK = "Interface\\Icons\\Spell_Nature_Drowsy",
DRUID = "Interface\\Icons\\INV_Misc_MonsterClaw_04",
}
local function ResolveClassToken(classKey)
local raw = tostring(classKey or ""):gsub("^%s+", ""):gsub("%s+$", "")
local token = raw:upper():gsub("[%s_%-]", "")
if CLASS_ICON_TEXTURES_335[token] then return token end
for english, localized in pairs(LOCALIZED_CLASS_NAMES_MALE or {}) do
if tostring(localized or ""):lower() == raw:lower() then
return english:upper():gsub("[%s_%-]", "")
end
end
for english, localized in pairs(LOCALIZED_CLASS_NAMES_FEMALE or {}) do
if tostring(localized or ""):lower() == raw:lower() then
return english:upper():gsub("[%s_%-]", "")
end
end
return token
end
local function SetClassIcon(texture, classKey, online)
local token = ResolveClassToken(classKey)
texture:SetTexture(CLASS_ICON_TEXTURES_335[token]
or "Interface\\Icons\\INV_Misc_QuestionMark")
texture:SetTexCoord(0, 1, 0, 1)
texture:SetVertexColor(1, 1, 1)
texture:SetAlpha(online and 1 or 0.42)
end
local function StyleGuildControlPopup(popup)
if popup.gveFlatStyled then return end
popup.gveFlatStyled = true
-- Das globale Blizzard-Fenster selbst bleibt unangetastet. Eine flache
-- Huelle dahinter gibt ihm GVE-Kontrast, ohne seine Originaltexturen oder
-- eine spaetere Verwendung im Standardfenster dauerhaft zu veraendern.
local shell = CreateFrame("Frame", nil, popup)
shell:SetPoint("TOPLEFT", popup, "TOPLEFT", -5, 5)
shell:SetPoint("BOTTOMRIGHT", popup, "BOTTOMRIGHT", 5, -5)
shell:SetFrameLevel(math.max(0, popup:GetFrameLevel() - 1))
shell:SetBackdrop(PANEL_BD)
SetRGBA(shell, "SetBackdropColor", UI_COLOR.window)
SetRGBA(shell, "SetBackdropBorderColor", UI_COLOR.line)
popup.gveFlatShell = shell
end
---------------------------------------------------------------------------
-- Hilfsfunktion: einfache Checkbox ohne globalen Namen
---------------------------------------------------------------------------
local function MakeCheckbox(parent)
local cb = CreateFrame("CheckButton", nil, parent)
cb:SetSize(16, 16)
cb:SetNormalTexture("Interface\\Buttons\\UI-CheckBox-Up")
cb:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check")
cb:SetHighlightTexture("Interface\\Buttons\\UI-CheckBox-Highlight", "ADD")
cb:SetDisabledTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled")
local lbl = cb:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
lbl:SetPoint("LEFT", cb, "RIGHT", 3, 0)
cb.lbl = lbl
-- Label mit anklickbar machen: Trefferflaeche nach rechts erweitern
cb.SetLabel = function(self, text)
self.lbl:SetText(text)
self:SetHitRectInsets(0, -(self.lbl:GetStringWidth() + 6), 0, 0)
end
return cb
end
---------------------------------------------------------------------------
-- Daten laden
---------------------------------------------------------------------------
function GVE:LoadRoster()
wipe(members)
wipe(ranks)
wipe(classes)
-- 3.3.5a: GetNumGuildMembers() liefert nur EINEN Wert (sichtbare Eintraege);
-- Online-Zaehler gibt es erst ab Cataclysm -> selbst zaehlen.
local total = GetNumGuildMembers()
local online = 0
for i = 1, total do
local name, rank, rankIndex, level, class, zone,
note, onote, isOnline, status, cf = GetGuildRosterInfo(i)
if name then
-- Bei fehlender Lokalisierung auf den classFile-Token
-- zurueckfallen (und umgekehrt).
local disp = (class and class ~= "" and class) or cf or ""
local displayToken = ResolveClassToken(disp)
local fileToken = ResolveClassToken(cf)
-- Der kanonische classFile-Token ist in 3.3.5a die Primaerquelle;
-- der lokalisierte Anzeigename bleibt ein unabhaengiger Fallback.
local key
if CLASS_ICON_TEXTURES_335[fileToken] then
key = fileToken
elseif CLASS_ICON_TEXTURES_335[displayToken] then
key = displayToken
else
key = (cf and cf ~= "" and cf) or disp
end
-- Zuletzt online (in Stunden) + Kurztext
local lastH, lastText
if isOnline then
lastH, lastText = 0, "|cff33ff33"..(FRIENDS_LIST_ONLINE or "Online").."|r"
else
local yy, mo, dd, hh = GetGuildRosterLastOnline(i)
yy, mo, dd, hh = yy or 0, mo or 0, dd or 0, hh or 0
lastH = ((yy * 12 + mo) * 30 + dd) * 24 + hh
if yy > 0 then lastText = yy.." J."
elseif mo > 0 then lastText = mo.." Mon."
elseif dd > 0 then lastText = dd.." Tage"
else lastText = hh.." Std." end
end
members[#members+1] = {
name=name, rank=rank or "", rankIndex=rankIndex or 0,
level=level or 0, class=disp, classKey=key,
zone=zone or "", note=note or "", officerNote=onote or "",
online=isOnline, status=status or 0,
index=i, -- Roster-Index fuer Notiz-APIs
lastOnline=lastH, lastOnlineText=lastText,
}
if isOnline then online = online + 1 end
if rank and rank ~= "" then ranks[rank] = true end
if key and key ~= "" then classes[key] = disp end
end
end
if self.memberCount then
local gname = GetGuildInfo("player") or GUILD or "Guild"
self.memberCount:SetText(
"|cffffff00"..gname.."|r "..
"|cff33aaff"..(online or 0).."|r"..
"|cff888888/"..(total or 0).." online|r"
)
end
self:UpdateRankCheckboxes()
self:UpdateClassCheckboxes()
self:ApplyFilter()
if type(self.rosterListener) == "function" then
Guard("RosterListener", self.rosterListener, self)
end
end
-- Schmale, nur-lesende Schnittstelle fuer optionale GuildView-Module.
-- Die Tabelle darf von Verbrauchern nicht veraendert werden.
function GVE:GetMembers()
return members
end
function GVE:SetRosterListener(listener)
self.rosterListener = listener
end
function GVE:ApplyFilter()
wipe(filtered)
local s = CaseFoldName(searchStr)
local hcf = next(filterClasses) ~= nil
local hrf = next(filterRanks) ~= nil
for _, m in ipairs(members) do
if (not hcf or filterClasses[m.classKey])
and (not hrf or filterRanks[m.rank])
and (not filterOnline or m.online)
and (s == "" or CaseFoldName(table.concat({
m.name or "", m.class or "", m.zone or "", m.rank or "", m.note or ""
}, " ")):find(s, 1, true))
then
filtered[#filtered+1] = m
end
end
local sk, asc = sortKey, sortAsc
-- WICHTIG: bei Gleichheit false liefern, sonst ist der Comparator
-- ungueltig und table.sort wirft "invalid order function".
table.sort(filtered, function(a, b)
local va, vb = a[sk], b[sk]
if type(va) ~= "number" then
va, vb = tostring(va or ""):lower(), tostring(vb or ""):lower()
end
if va == vb then
local an, bn = CaseFoldName(a.name or ""), CaseFoldName(b.name or "")
if an == bn then return (a.name or "") < (b.name or "") end
return an < bn
end
if asc then return va < vb else return va > vb end
end)
self:RefreshRoster()
self:RefreshColHeaders()
self:RefreshFilterButton()
end
---------------------------------------------------------------------------
-- Hauptrahmen
---------------------------------------------------------------------------
function GVE:Build()
local f = CreateFrame("Frame", "GVEMainFrame", UIParent)
f:SetSize(W, H)
f:SetPoint("CENTER")
f:SetMovable(true)
f:SetClampedToScreen(true)
f:EnableMouse(true)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", f.StartMoving)
f:SetScript("OnDragStop", f.StopMovingOrSizing)
f:SetFrameStrata("HIGH")
f:SetBackdrop(PANEL_BD)
SetRGBA(f, "SetBackdropColor", UI_COLOR.window)
SetRGBA(f, "SetBackdropBorderColor", UI_COLOR.line)
f:Hide()
self.f = f
-- ESC schliesst das Fenster. Hat die Suchleiste den Fokus, faengt ihr
-- OnEscapePressed das ESC ab -> nur Fokus verlassen, Fenster bleibt.
tinsert(UISpecialFrames, "GVEMainFrame")
-- ESC ruft f:Hide() direkt auf (nicht GVE:Close) -> Aufraeumen hier
f:SetScript("OnHide", function()
GVE:CloseFilterPanel()
if GVE.lastOnlineWin then GVE.lastOnlineWin:Hide() end
if GVE.logPanel then GVE.logPanel:Hide() end
if GVE.detail then GVE.detail:Hide() end
if GuildControlPopupFrame and GuildControlPopupFrame:IsShown() then
GuildControlPopupFrame:Hide()
end
end)
f:SetScript("OnShow", function(self)
self.rosterRefreshElapsed = 0
end)
-- 3.3.5a sendet fremde Notiz-/Roster-Aenderungen nicht in jeder
-- Situation ungefragt an den Client. Solange GuildView sichtbar ist,
-- fragen wir deshalb moderat nach und lassen GUILD_ROSTER_UPDATE die
-- bestehenden Listen und ein offenes Detailfenster aktualisieren.
f:SetScript("OnUpdate", function(self, elapsed)
GVE:OnRosterRefreshUpdate(self, elapsed)
end)
local title = f:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("TOP", f, "TOP", 0, -10)
title:SetText("|cff33aaffGuild-View-Extended|r")
local mc = f:CreateFontString(nil, "OVERLAY", "GameFontNormal")
mc:SetPoint("TOP", f, "TOP", 0, -27)
mc:SetTextColor(UI_COLOR.muted[1], UI_COLOR.muted[2], UI_COLOR.muted[3])
self.memberCount = mc
local xb = CreateFrame("Button", nil, f, "UIPanelCloseButton")
xb:SetPoint("TOPRIGHT", f, "TOPRIGHT", 0, 0)
self:BuildFilterBar()
self:BuildFilterPanel() -- vor ColHeaders, damit filterPanel referenzierbar
self:BuildColHeaders()
self:BuildRosterRows()
self:BuildBottomPanels()
self:BuildLogPanel()
end
function GVE:OnRosterRefreshUpdate(frame, elapsed)
frame.rosterRefreshElapsed = (frame.rosterRefreshElapsed or 0) + elapsed
if frame.rosterRefreshElapsed >= ROSTER_REFRESH_SECONDS then
frame.rosterRefreshElapsed = 0
SetGuildRosterShowOffline(true)
GuildRoster()
end
end
---------------------------------------------------------------------------
-- CSV-Export: Charakternamen + Gildenrang, kein automatischer Clipboard-Zugriff.
-- Das Fenster ist nicht modal und verwendet dasselbe Dialog-Design wie die
-- vorhandenen Log-, Detail- und Texteditor-Fenster.
---------------------------------------------------------------------------
StaticPopupDialogs["GVE_CSV_ERROR"] = {
text = "%s",
button1 = OKAY or "OK",
timeout = 0, whileDead = 1, hideOnEscape = 1,
}
StaticPopupDialogs["GVE_LEAVE_GUILD"] = {
text = ACTION_TEXT.leaveConfirm,
button1 = YES or "Yes",
button2 = CANCEL or "Cancel",
OnAccept = function()
GuildLeave()
Log("Gilde verlassen angefordert")
end,
showAlert = 1,
timeout = 0, whileDead = 1, hideOnEscape = 1,
}
function GVE:BuildCSVWindow()
local w = CreateFrame("Frame", "GVECSVWindow", UIParent)
w:SetWidth(600); w:SetHeight(430)
w:SetPoint("CENTER")
w:SetMovable(true); w:EnableMouse(true)
w:RegisterForDrag("LeftButton")
w:SetScript("OnDragStart", w.StartMoving)
w:SetScript("OnDragStop", w.StopMovingOrSizing)
w:SetFrameStrata("DIALOG")
w:SetBackdrop(MAIN_BD)
w:SetBackdropColor(0, 0, 0, 0.97)
w:Hide()
tinsert(UISpecialFrames, "GVECSVWindow")
self.csvWindow = w
local title = w:CreateFontString(nil, "OVERLAY", "GameFontNormal")
title:SetPoint("TOP", w, "TOP", 0, -12)
title:SetText("|cff33aaff"..CSV_TEXT.title.."|r")
local xb = CreateFrame("Button", nil, w, "UIPanelCloseButton")
xb:SetPoint("TOPRIGHT", w, "TOPRIGHT", 0, 0)
local hint = w:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
hint:SetPoint("TOPLEFT", w, "TOPLEFT", 16, -36)
hint:SetText(CSV_TEXT.copyHint)
w.countText = w:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
w.countText:SetPoint("TOPRIGHT", w, "TOPRIGHT", -18, -38)
w.countText:SetTextColor(0.65, 0.65, 0.65)
local bg = CreateFrame("Frame", nil, w)
bg:SetPoint("TOPLEFT", w, "TOPLEFT", 14, -58)
bg:SetPoint("BOTTOMRIGHT", w, "BOTTOMRIGHT", -14, 48)
bg:SetBackdrop(PANEL_BD)
bg:SetBackdropColor(0.02, 0.02, 0.04, 0.95)
local sf = CreateFrame("ScrollFrame", "GVECSVScroll", bg, "UIPanelScrollFrameTemplate")
sf:SetPoint("TOPLEFT", bg, "TOPLEFT", 8, -7)
sf:SetPoint("BOTTOMRIGHT", bg, "BOTTOMRIGHT", -28, 7)
w.scroll = sf
local eb = CreateFrame("EditBox", nil, sf)
eb:SetMultiLine(true)
eb:SetFontObject(ChatFontNormal)
eb:SetWidth(520)
eb:SetAutoFocus(false)
eb:SetMaxLetters(0)
eb:SetScript("OnEscapePressed", function(self)
self:ClearFocus()
w:Hide()
end)
sf:SetScrollChild(eb)
w.editBox = eb
w:SetScript("OnHide", function() eb:ClearFocus() end)
local close = CreateFrame("Button", nil, w, "UIPanelButtonTemplate")
close:SetWidth(110); close:SetHeight(22)
close:SetPoint("BOTTOMRIGHT", w, "BOTTOMRIGHT", -16, 16)
close:SetText(CSV_TEXT.close)
close:SetScript("OnClick", function() w:Hide() end)
end
function GVE:ShowCSVWindow(csv, count)
if not self.csvWindow then self:BuildCSVWindow() end
local w = self.csvWindow
w.editBox:SetText(csv)
w.countText:SetText(format(CSV_TEXT.count, count))
w.scroll:SetVerticalScroll(0)
w:Show()
w.editBox:SetFocus()
w.editBox:HighlightText()
end
function GVE:CreateCSVExport()
local csv, count, err = self:BuildCSVFromMembers(members)
if not csv then
Log(err)
print("|cffff3333[Guild-View-Extended]|r "..err)
StaticPopup_Show("GVE_CSV_ERROR", err)
return
end
Log("CSV-Export erstellt: "..count.." Charaktere")
self:ShowCSVWindow(csv, count)
end
function GVE:UpdateCSVButton()
if not self.csvButton then return end
if self.csvPending then
self.csvButton:SetText(CSV_TEXT.loading)
self.csvButton:Disable()
else
self.csvButton:SetText(CSV_TEXT.button)
self.csvButton:Enable()
end
end
function GVE:RequestCSVExport()
if self.rosterLoaded then
self:CreateCSVExport()
return
end
if self.csvPending then return end
self.csvPending = true
self:UpdateCSVButton()
Log("CSV-Export wartet auf GUILD_ROSTER_UPDATE")
-- 3.3.5a-API: Offline-Mitglieder vor der asynchronen Abfrage einschalten.
SetGuildRosterShowOffline(true)
GuildRoster()
end
---------------------------------------------------------------------------
-- Filterleiste: nur Suchfeld + Filter-Button
---------------------------------------------------------------------------
function GVE:BuildFilterBar()
local f = self.f
local yOff = -(PAD + TITLE_H + 2)
local sbox = CreateFrame("EditBox", "GVESearchBox", f)
sbox:SetSize(225, 26)
sbox:SetPoint("TOPLEFT", f, "TOPLEFT", PAD, yOff)
StyleFlatEditBox(sbox)
sbox:SetAutoFocus(false)
sbox:SetMaxLetters(40)
sbox:SetScript("OnTextChanged", function(self)
searchStr = self:GetText()
GVE:ApplyFilter()
end)
sbox:SetScript("OnEscapePressed", sbox.ClearFocus)
self.searchBox = sbox
local placeholder = sbox:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
placeholder:SetPoint("LEFT", sbox, "LEFT", 8, 0)
placeholder:SetText((SEARCH or "Search").." …")
sbox:SetScript("OnEditFocusGained", function() placeholder:Hide() end)
sbox:SetScript("OnEditFocusLost", function(self) if self:GetText() == "" then placeholder:Show() end end)
local oldChanged = sbox:GetScript("OnTextChanged")
sbox:SetScript("OnTextChanged", function(self)
if self:GetText() == "" and not self:HasFocus() then placeholder:Show() else placeholder:Hide() end
oldChanged(self)
end)
local fbtn = MakeFlatButton(f, 88, 26, FILTER or "Filter")
fbtn:SetPoint("LEFT", sbox, "RIGHT", 8, 0)
AddButtonIcon(fbtn, "Interface\\Icons\\INV_Misc_Spyglass_03")
fbtn:SetScript("OnClick", function() GVE:ToggleFilterPanel() end)
self.filterBtn = fbtn
-- "Nur Online" direkt in der Leiste, nicht im Filter-Panel
local olCB = MakeCheckbox(f)
olCB:SetPoint("LEFT", fbtn, "RIGHT", 10, 0)
olCB:SetLabel(FRIENDS_LIST_ONLINE or "Online")
olCB.lbl:SetTextColor(0.8, 0.8, 0.8)
olCB:SetScript("OnClick", function(self)
filterOnline = self:GetChecked() and true or false
GVE:ApplyFilter()
end)
self.onlineCB = olCB
local fl = f:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
fl:SetPoint("LEFT", olCB.lbl, "RIGHT", 12, 0)
fl:SetTextColor(0.6, 0.9, 0.6)
self.filterLabel = fl
-- Gildenoptionen (Blizzards GuildControlPopupFrame) -- nur fuer den
-- Gildenmeister aktiv, wie beim Standard-Gildenfenster.
local gcb = MakeFlatButton(f, 126, 26, GUILDCONTROL or "Guild Controls")
gcb:SetPoint("TOPRIGHT", f, "TOPRIGHT", -PAD, yOff)
AddButtonIcon(gcb, "Interface\\Icons\\INV_Gizmo_02")
gcb:SetScript("OnClick", function()
local p = GuildControlPopupFrame
if not p then
Log("GuildControl: GuildControlPopupFrame existiert nicht!")
return
end
if p:IsShown() then
p:Hide()
return
end
GVE:CloseFilterPanel()
if GVE.lastOnlineWin then GVE.lastOnlineWin:Hide() end
if GVE.logPanel then GVE.logPanel:Hide() end
if GVE.detail then GVE.detail:Hide() end
GuildRoster() -- Rangdaten anfordern
GVE.guildControlOwned = true
-- Blizzard verankert das Popup am FriendsFrame; an unser Fenster haengen
p:ClearAllPoints()
p:SetPoint("CENTER", f, "CENTER", 0, 0)
p:SetFrameStrata("DIALOG")
StyleGuildControlPopup(p)
p:Show()
-- WICHTIG: Erst die Initialisierung befuellt Raenge + Haken.
-- Blizzards Funktionsname enthaelt in 3.3.5a einen Tippfehler
-- (kleines "f") -- beide Schreibweisen probieren.
local init = _G["GuildControlPopupframe_Initialize"]
or _G["GuildControlPopupFrame_Initialize"]
if init then
Guard("GuildControlInit", init)
Log("GuildControl: initialisiert")
else
Log("GuildControl: keine Initialize-Funktion gefunden!")
end
end)
self.guildControlBtn = gcb
-- Mitglied einladen: Blizzards Standard-Dialog (ADD_GUILDMEMBER),
-- nur aktiv mit Einladerecht -- wie beim Standard-Gildenfenster.
local amb = MakeFlatButton(f, 112, 26, ADD_GUILDMEMBER or "Add Member", true)
amb:SetPoint("RIGHT", gcb, "LEFT", -6, 0)
AddButtonIcon(amb, "Interface\\Icons\\INV_Misc_GroupLooking")
amb:SetScript("OnClick", function()
StaticPopup_Show("ADD_GUILDMEMBER")
end)
self.addMemberBtn = amb
-- "Zuletzt Online": nur fuer Gildenmeister/Offiziere (siehe
-- UpdateGuildControlButton). Oeffnet Panel mit Sortierung + Zeitfilter.
local lob = MakeFlatButton(f, 112, 26, LASTONLINE or "Zuletzt Online")
lob:SetPoint("RIGHT", amb, "LEFT", -6, 0)
AddButtonIcon(lob, "Interface\\Icons\\INV_Misc_PocketWatch_01")
lob:SetScript("OnClick", function() GVE:ToggleLastOnlineWindow() end)
lob:Hide()
self.lastOnlineBtn = lob
local logb = MakeFlatButton(f, 96, 26, GUILD_EVENT_LOG_TITLE or "Guild Log")
logb:SetPoint("RIGHT", lob, "LEFT", -6, 0)
AddButtonIcon(logb, "Interface\\Icons\\INV_Scroll_03")
logb:SetScript("OnClick", function() GVE:ToggleGuildLogWindow() end)
self.guildLogBtn = logb
local csvButton = MakeFlatButton(f, 120, 26, CSV_TEXT.button, true)
csvButton:SetPoint("RIGHT", logb, "LEFT", -6, 0)
AddButtonIcon(csvButton, "Interface\\Icons\\INV_Misc_Note_01")
csvButton:SetScript("OnClick", function()
Guard("CSVExportRequest", function() GVE:RequestCSVExport() end)
end)
self.csvButton = csvButton
-- Trefferzahl unterhalb der Werkzeugleiste; der Titel bleibt im gemeinsamen Header.
self.memberCount:ClearAllPoints()
self.memberCount:SetPoint("TOPLEFT", sbox, "BOTTOMLEFT", 1, -7)
self.filterLabel:ClearAllPoints()
self.filterLabel:SetPoint("LEFT", self.memberCount, "RIGHT", 14, 0)
end
---------------------------------------------------------------------------
-- "Zuletzt Online"-Fenster (nur GM/Offiziere): eigene Liste aller
-- Mitglieder mit letzter Online-Zeit, auf-/absteigend sortierbar und
-- nach eigener Zeitspanne filterbar (X Tage / Wochen / Monate offline).
-- Im Hauptfenster wird "zuletzt online" bewusst NICHT angezeigt.
---------------------------------------------------------------------------
local LO_ROWS = 11
local LO_ROW_H = 36
local loSortAsc = false -- Standard: laengste Offline-Zeit zuerst
local loFilterHours = nil
local loSearchStr = ""
local LO_TEXT = GetLocale() == "deDE" and {
searchLabel = "Spieler suchen:",
clearSearch = "Löschen",
offlineFor = "Offline seit mindestens:",
days = "Tage",
weeks = "Wochen",
months = "Monate",
name = "Name",
rank = "Rang",
empty = "Keine Gildenmitglieder verfügbar.",
noResults = "Keine Treffer für aktuelle Suche und Filter.",
count = "%d von %d Mitgliedern",
} or {
searchLabel = "Search player:",
clearSearch = "Clear",
offlineFor = "Offline for at least:",
days = "Days",
weeks = "Weeks",
months = "Months",
name = "Name",
rank = "Rank",
empty = "No guild members available.",
noResults = "No matches for the current search and filters.",
count = "%d of %d members",
}
function GVE:BuildLastOnlineList(sourceMembers, searchText, filterHours, ascending)
local list = {}
local search = CaseFoldName(searchText or "")
for _, m in ipairs(sourceMembers or {}) do
local matchesSearch = search == ""
or CaseFoldName(m.name or ""):find(search, 1, true) ~= nil
or CaseFoldName(m.rank or ""):find(search, 1, true) ~= nil
local matchesTime = not filterHours
or (m.lastOnline or 0) >= filterHours
if matchesSearch and matchesTime then list[#list+1] = m end
end
table.sort(list, function(a, b)
local va, vb = a.lastOnline or 0, b.lastOnline or 0
if va == vb then
local an, bn = CaseFoldName(a.name or ""), CaseFoldName(b.name or "")
if an == bn then return (a.name or "") < (b.name or "") end
return an < bn
end
if ascending then return va < vb else return va > vb end
end)
return list
end
function GVE:ResetLastOnlineScroll()
local w = self.lastOnlineWin
if not (w and w.scroll) then return end
w.scroll:SetVerticalScroll(0)
FauxScrollFrame_SetOffset(w.scroll, 0)
end