-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReputationPanel.lua
More file actions
760 lines (660 loc) · 27 KB
/
ReputationPanel.lua
File metadata and controls
760 lines (660 loc) · 27 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
local addonName, ns = ...
local container = ns.repContent
local BAR_COLORS = {
[1] = { r = 0.80, g = 0.13, b = 0.13 },
[2] = { r = 0.80, g = 0.13, b = 0.13 },
[3] = { r = 0.93, g = 0.40, b = 0.13 },
[4] = { r = 0.93, g = 0.80, b = 0.13 },
[5] = { r = 0.13, g = 0.80, b = 0.13 },
[6] = { r = 0.13, g = 0.80, b = 0.13 },
[7] = { r = 0.13, g = 0.80, b = 0.13 },
[8] = { r = 0.13, g = 0.80, b = 0.13 },
}
local RENOWN_COLOR = { r = 0.24, g = 0.54, b = 1.0 }
local HEADER_HEIGHT = 26
local ENTRY_HEIGHT = 28
local INDENT = 20
local BAR_HEIGHT = 22
local searchBox = CreateFrame("EditBox", nil, container, "SearchBoxTemplate")
searchBox:SetSize(220, 20)
searchBox:SetPoint("TOP", container, "TOP", 6, -6)
searchBox:SetAutoFocus(false)
local searchFilter = ""
searchBox:SetScript("OnTextChanged", function(self)
SearchBoxTemplate_OnTextChanged(self)
local text = strtrim(self:GetText() or "")
searchFilter = strlower(text)
ns:UpdateReputation()
end)
local _, _, repFilterOpts = ns:CreateFilterDropdown(container, searchBox)
local playerName = UnitName("player") or ""
local SORT_NONE = Enum.ReputationSortType and Enum.ReputationSortType.None or 0
local SORT_ACCOUNT = Enum.ReputationSortType and Enum.ReputationSortType.Account or 1
local SORT_CHARACTER = Enum.ReputationSortType and Enum.ReputationSortType.Character or 2
repFilterOpts.addRadio(
REPUTATION_SORT_TYPE_SHOW_ALL or "Show All",
function() return C_Reputation.GetReputationSortType() == SORT_NONE end,
function()
C_Reputation.SetReputationSortType(SORT_NONE)
ns:UpdateReputation()
end)
repFilterOpts.addRadio(
REPUTATION_SORT_TYPE_ACCOUNT or "Account-Wide",
function() return C_Reputation.GetReputationSortType() == SORT_ACCOUNT end,
function()
C_Reputation.SetReputationSortType(SORT_ACCOUNT)
ns:UpdateReputation()
end)
repFilterOpts.addRadio(
playerName,
function() return C_Reputation.GetReputationSortType() == SORT_CHARACTER end,
function()
C_Reputation.SetReputationSortType(SORT_CHARACTER)
ns:UpdateReputation()
end)
repFilterOpts.addDivider()
if C_Reputation.AreLegacyReputationsShown then
repFilterOpts.addCheckbox(
REPUTATION_CHECKBOX_SHOW_LEGACY_REPUTATIONS or "Show Legacy Reputations",
function() return C_Reputation.AreLegacyReputationsShown() end,
function(checked)
C_Reputation.SetLegacyReputationsShown(checked)
ns:UpdateReputation()
end)
repFilterOpts.addDivider()
end
repFilterOpts.addAction(
EXPAND_ALL or "Expand All",
function()
C_Reputation.ExpandAllFactionHeaders()
ns:UpdateReputation()
end)
repFilterOpts.addAction(
COLLAPSE_ALL or "Collapse All",
function()
C_Reputation.CollapseAllFactionHeaders()
ns:UpdateReputation()
end)
--- Simple fuzzy match: every character in the query must appear in order
--- within the subject string.
local function FuzzyMatch(subject, query)
if query == "" then return true end
local si = 1
for qi = 1, #query do
local qc = query:sub(qi, qi)
local found = subject:find(qc, si, true)
if not found then return false end
si = found + 1
end
return true
end
local scrollFrame = CreateFrame("ScrollFrame", nil, container,
"UIPanelScrollFrameTemplate")
scrollFrame:SetPoint("TOPLEFT", 8, -34)
scrollFrame:SetPoint("BOTTOMRIGHT", -30, 0)
local content = CreateFrame("Frame", nil, scrollFrame)
content:SetWidth(scrollFrame:GetWidth() or 880)
scrollFrame:SetScrollChild(content)
container:SetScript("OnSizeChanged", function(self)
local w = self:GetWidth() - 34
content:SetWidth(w > 0 and w or 880)
end)
local entries = {}
ns.repEntries = entries
local function CreateEntry()
local entry = CreateFrame("Button", nil, content)
entry:SetHeight(ENTRY_HEIGHT)
local arrowBtn = CreateFrame("Button", nil, entry)
arrowBtn:SetSize(20, 20)
arrowBtn:SetPoint("LEFT", 0, 0)
arrowBtn:SetFrameLevel(entry:GetFrameLevel() + 20)
arrowBtn:Hide()
local arrowTex = arrowBtn:CreateTexture(nil, "ARTWORK")
arrowTex:SetSize(14, 14)
arrowTex:SetPoint("CENTER")
arrowBtn.tex = arrowTex
arrowBtn:SetScript("OnClick", function()
local fd = entry.factionData
if fd and fd.isHeader then
if fd.isCollapsed then
C_Reputation.ExpandFactionHeader(fd.factionIndex)
else
C_Reputation.CollapseFactionHeader(fd.factionIndex)
end
ns:UpdateReputation()
end
end)
entry.arrow = arrowBtn
entry.arrowTex = arrowTex
local star = entry:CreateTexture(nil, "OVERLAY")
star:SetSize(12, 12)
star:SetAtlas("auctionhouse-icon-favorite")
star:Hide()
entry.star = star
local spacer = CreateFrame("Frame", nil, entry)
spacer:SetSize(1, 1)
spacer:SetPoint("LEFT", entry, "LEFT", 0, 0)
entry.spacer = spacer
local repFontSize = (ns.db and ns.db.global and ns.db.global.repFontSize) or 12
local barFontSize = max(repFontSize - 1, 8)
-- Full-width progress bar
local bar = CreateFrame("StatusBar", nil, entry)
bar:SetHeight(BAR_HEIGHT)
bar:SetPoint("LEFT", entry, "LEFT", 2, 0)
bar:SetPoint("RIGHT", entry, "RIGHT", -2, 0)
bar:SetStatusBarTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill")
bar:GetStatusBarTexture():SetHorizTile(false)
bar:SetMinMaxValues(0, 1)
bar:SetValue(0)
bar:EnableMouse(false)
bar:Hide()
entry.bar = bar
entry.barContainer = bar
local barBg = bar:CreateTexture(nil, "BACKGROUND")
barBg:SetAllPoints()
barBg:SetColorTexture(0.08, 0.08, 0.10, 0.85)
local barBorderTop = bar:CreateTexture(nil, "OVERLAY", nil, -1)
barBorderTop:SetHeight(1)
barBorderTop:SetPoint("TOPLEFT", -1, 1)
barBorderTop:SetPoint("TOPRIGHT", 1, 1)
barBorderTop:SetColorTexture(0.3, 0.3, 0.3, 0.6)
local barBorderBot = bar:CreateTexture(nil, "OVERLAY", nil, -1)
barBorderBot:SetHeight(1)
barBorderBot:SetPoint("BOTTOMLEFT", -1, -1)
barBorderBot:SetPoint("BOTTOMRIGHT", 1, -1)
barBorderBot:SetColorTexture(0.3, 0.3, 0.3, 0.6)
local barBorderLeft = bar:CreateTexture(nil, "OVERLAY", nil, -1)
barBorderLeft:SetWidth(1)
barBorderLeft:SetPoint("TOPLEFT", -1, 1)
barBorderLeft:SetPoint("BOTTOMLEFT", -1, -1)
barBorderLeft:SetColorTexture(0.3, 0.3, 0.3, 0.6)
local barBorderRight = bar:CreateTexture(nil, "OVERLAY", nil, -1)
barBorderRight:SetWidth(1)
barBorderRight:SetPoint("TOPRIGHT", 1, 1)
barBorderRight:SetPoint("BOTTOMRIGHT", 1, -1)
barBorderRight:SetColorTexture(0.3, 0.3, 0.3, 0.6)
-- Text frame above the fill
local textFrame = CreateFrame("Frame", nil, bar)
textFrame:SetAllPoints()
textFrame:SetFrameLevel(bar:GetFrameLevel() + 10)
textFrame:EnableMouse(false)
entry.barTextFrame = textFrame
-- Left: Faction name
local name = textFrame:CreateFontString(nil, "OVERLAY")
name:SetFont(STANDARD_TEXT_FONT, repFontSize, "OUTLINE")
name:SetPoint("LEFT", 8, 0)
name:SetPoint("RIGHT", textFrame, "CENTER", -10, 0)
name:SetJustifyH("LEFT")
name:SetWordWrap(false)
entry.name = name
-- Center: Progress numbers
local barText = textFrame:CreateFontString(nil, "OVERLAY")
barText:SetFont(STANDARD_TEXT_FONT, barFontSize, "OUTLINE")
barText:SetPoint("CENTER", 0, 0)
barText:SetJustifyH("CENTER")
barText:SetTextColor(0.9, 0.9, 0.9, 1)
entry.barText = barText
-- Right: Standing text
local standing = textFrame:CreateFontString(nil, "OVERLAY")
standing:SetFont(STANDARD_TEXT_FONT, barFontSize, "OUTLINE")
standing:SetPoint("RIGHT", -8, 0)
standing:SetJustifyH("RIGHT")
standing:SetTextColor(1, 1, 1, 0.9)
entry.standing = standing
local paragonGlow = entry:CreateTexture(nil, "OVERLAY")
paragonGlow:SetSize(16, 16)
paragonGlow:SetPoint("LEFT", bar, "LEFT", -18, 0)
paragonGlow:SetAtlas("ParagonReputation_Bag")
paragonGlow:Hide()
entry.paragonGlow = paragonGlow
local hl = entry:CreateTexture(nil, "HIGHLIGHT")
hl:SetAllPoints()
hl:SetColorTexture(1, 1, 1, 0.05)
local stripe = entry:CreateTexture(nil, "BACKGROUND", nil, 1)
stripe:SetAllPoints()
stripe:SetColorTexture(1, 1, 1, 0.03)
stripe:Hide()
entry.stripe = stripe
local selBar = entry:CreateTexture(nil, "BACKGROUND", nil, 2)
selBar:SetAllPoints()
selBar:SetColorTexture(0.35, 0.30, 0.10, 0.35)
selBar:Hide()
entry.selBar = selBar
entry:SetScript("OnEnter", function(self)
if not self.factionData then return end
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
local fd = self.factionData
GameTooltip:SetText(fd.name, HIGHLIGHT_FONT_COLOR.r,
HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
if fd.description and fd.description ~= "" then
GameTooltip:AddLine(fd.description, NORMAL_FONT_COLOR.r,
NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, true)
end
if self.hasParagonReward then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(QUEST_COMPLETE or "Reward available!",
GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g,
GREEN_FONT_COLOR.b)
end
GameTooltip:Show()
end)
entry:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
entry:SetScript("OnClick", function(self, button)
local fd = self.factionData
if not fd then return end
if fd.isHeader and not fd.isHeaderWithRep then
-- Pure headers: toggle collapse (arrow button also handles this)
if fd.isCollapsed then
C_Reputation.ExpandFactionHeader(fd.factionIndex)
else
C_Reputation.CollapseFactionHeader(fd.factionIndex)
end
ns:UpdateReputation()
else
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
C_Reputation.SetSelectedFaction(fd.factionIndex)
ns:RefreshReputationDetail()
ns:UpdateReputation()
end
end)
return entry
end
local function GetFriendshipData(factionID)
if not C_GossipInfo or not C_GossipInfo.GetFriendshipReputation then return nil end
local info = C_GossipInfo.GetFriendshipReputation(factionID)
if info and info.friendshipFactionID and info.friendshipFactionID > 0 then
return info
end
return nil
end
local function IsMajorFaction(factionID)
return C_Reputation.IsMajorFaction and C_Reputation.IsMajorFaction(factionID)
end
function ns:UpdateReputation()
if not container:IsShown() then return end
for _, e in ipairs(entries) do e:Hide() end
local numFactions = C_Reputation.GetNumFactions()
local filtering = (searchFilter ~= "")
-- Pre-pass: figure out which indices match the search so we can keep
-- headers that have at least one visible child.
local matchSet = {}
if filtering then
local headerStack = {} -- indices of headers above the current entry
for i = 1, numFactions do
local fd = C_Reputation.GetFactionDataByIndex(i)
if not fd then break end
if fd.isHeader and not fd.isHeaderWithRep then
-- Track header depth; pop deeper/equal headers from stack
while #headerStack > 0 do
local prev = C_Reputation.GetFactionDataByIndex(headerStack[#headerStack])
if prev and not fd.isChild and prev.isChild then break end
if prev and fd.isChild and not prev.isChild then break end
table.remove(headerStack)
end
table.insert(headerStack, i)
else
if FuzzyMatch(strlower(fd.name or ""), searchFilter) then
matchSet[i] = true
-- Mark all parent headers as visible too
for _, hi in ipairs(headerStack) do
matchSet[hi] = true
end
end
end
end
end
local y = 0
local idx = 0
local headerDepth = 0
local visibleIdx = 0
for i = 1, numFactions do
local fd = C_Reputation.GetFactionDataByIndex(i)
if not fd then break end
fd.factionIndex = i
-- Skip entries that don't match the search filter
if filtering and not matchSet[i] then
-- skip
else -- visible entry
local isPureHeader = fd.isHeader and not fd.isHeaderWithRep
idx = idx + 1
local entry = entries[idx]
if not entry then
entry = CreateEntry()
entries[idx] = entry
end
if fd.isHeader and not fd.isChild then
headerDepth = 0
elseif fd.isHeader and fd.isChild then
headerDepth = 1
end
local indent = 0
if fd.isHeader and fd.isChild then
indent = INDENT
end
local h = isPureHeader and HEADER_HEIGHT or ENTRY_HEIGHT
entry:SetHeight(h)
entry:ClearAllPoints()
entry:SetPoint("TOPLEFT", content, "TOPLEFT", indent, -y)
entry:SetPoint("TOPRIGHT", content, "TOPRIGHT", 0, -y)
entry.factionData = fd
entry.hasParagonReward = false
if fd.isHeader then
entry.arrow:Show()
entry.arrowTex:SetAtlas(fd.isCollapsed
and "campaign_headericon_closed"
or "campaign_headericon_open")
else
entry.arrow:Hide()
end
entry.bar:ClearAllPoints()
entry.bar:SetHeight(BAR_HEIGHT)
if fd.isHeader then
entry.spacer:SetWidth(1)
entry.spacer:ClearAllPoints()
entry.spacer:SetPoint("LEFT", entry, "LEFT", 0, 0)
entry.bar:SetPoint("LEFT", entry.arrow, "RIGHT", 4, 0)
else
local spacerWidth = (headerDepth + 2) * INDENT
entry.spacer:SetWidth(spacerWidth)
entry.spacer:ClearAllPoints()
entry.spacer:SetPoint("LEFT", entry, "LEFT", 0, 0)
entry.bar:SetPoint("LEFT", entry.spacer, "RIGHT", 4, 0)
end
entry.bar:SetPoint("RIGHT", entry, "RIGHT", -2, 0)
entry.name:ClearAllPoints()
if fd.isHeader and not fd.isHeaderWithRep then
entry.name:SetParent(entry)
entry.name:SetPoint("LEFT", entry.arrow, "RIGHT", 4, 0)
entry.name:SetPoint("RIGHT", entry, "RIGHT", -4, 0)
else
-- Inside the bar's text frame so it renders above the fill
entry.name:SetParent(entry.barTextFrame)
entry.name:SetPoint("LEFT", entry.barContainer, "LEFT", 8, 0)
entry.name:SetPoint("RIGHT", entry.barContainer, "CENTER", -10, 0)
end
entry.name:SetText(fd.name or "")
entry.star:SetShown(fd.isWatched and not isPureHeader)
if fd.isWatched and not isPureHeader then
entry.star:SetPoint("LEFT", entry.bar, "LEFT", -16, 0)
end
if isPureHeader then
local headerFontSize = (ns.db and ns.db.global and ns.db.global.repHeaderFontSize) or 20
entry.name:SetFont(STANDARD_TEXT_FONT, headerFontSize, "")
entry.name:SetTextColor(1, 0.82, 0, 1)
entry.bar:Hide()
entry.standing:SetText("")
entry.barText:SetText("")
entry.paragonGlow:Hide()
entry.stripe:Hide()
else
visibleIdx = visibleIdx + 1
entry.stripe:SetShown(visibleIdx % 2 == 0)
local repFontSize = (ns.db and ns.db.global and ns.db.global.repFontSize) or 16
entry.name:SetFont(STANDARD_TEXT_FONT, repFontSize, "OUTLINE")
entry.name:SetTextColor(1, 1, 1, 1)
local minVal, maxVal, curVal = 0, 1, 0
local standingText = ""
local barColor = BAR_COLORS[4]
local isCapped = false
local friendship = GetFriendshipData(fd.factionID)
local isMajor = IsMajorFaction(fd.factionID)
if isMajor then
local mjd = C_MajorFactions and
C_MajorFactions.GetMajorFactionData(fd.factionID)
if mjd then
local isMax = C_MajorFactions.HasMaximumRenown(fd.factionID)
if isMax then
minVal, maxVal, curVal = 0, 1, 1
isCapped = true
else
minVal = 0
maxVal = mjd.renownLevelThreshold
curVal = mjd.renownReputationEarned
end
standingText = format(RENOWN_LEVEL_LABEL or "Renown %d",
mjd.renownLevel)
barColor = RENOWN_COLOR
end
elseif friendship then
local isMax = (friendship.nextThreshold == nil)
if isMax then
minVal, maxVal, curVal = 0, 1, 1
isCapped = true
else
minVal = friendship.reactionThreshold or 0
maxVal = friendship.nextThreshold or 1
curVal = friendship.standing or 0
end
standingText = friendship.reaction or ""
barColor = BAR_COLORS[5]
else
isCapped = (fd.reaction == (MAX_REPUTATION_REACTION or 8))
if isCapped then
minVal, maxVal, curVal = 0, 1, 1
else
minVal = fd.currentReactionThreshold or 0
maxVal = fd.nextReactionThreshold or 1
curVal = fd.currentStanding or 0
end
local gender = UnitSex("player")
standingText = GetText(
"FACTION_STANDING_LABEL" .. (fd.reaction or 4),
gender) or ""
barColor = BAR_COLORS[fd.reaction or 4] or BAR_COLORS[4]
end
local range = maxVal - minVal
local fill = (range > 0) and ((curVal - minVal) / range)
or (isCapped and 1 or 0)
fill = max(0, min(1, fill))
entry.bar:SetMinMaxValues(0, 1)
entry.bar:SetValue(fill)
entry.bar:SetStatusBarColor(barColor.r, barColor.g, barColor.b, 0.85)
entry.bar:Show()
if isCapped then
entry.barText:SetText("")
entry.standing:SetText(standingText)
else
local cur = curVal - minVal
local total = maxVal - minVal
entry.barText:SetText(
BreakUpLargeNumbers(cur) .. " / " ..
BreakUpLargeNumbers(total))
entry.standing:SetText(standingText)
end
entry.standing:SetTextColor(1, 1, 1, 0.9)
-- Paragon: override the capped bar with paragon progress
local showParagon = false
-- Only show paragon progress for factions at Exalted standing
if fd.reaction == (MAX_REPUTATION_REACTION or 8)
and C_Reputation.IsFactionParagon
and C_Reputation.IsFactionParagon(fd.factionID) then
local parVal, parThreshold, _, hasReward =
C_Reputation.GetFactionParagonInfo(fd.factionID)
if parVal and parThreshold and parThreshold > 0 then
entry.bar:SetStatusBarColor(0.26, 0.42, 0.88, 0.85)
entry.bar:SetValue((parVal % parThreshold) / parThreshold)
entry.bar:Show()
entry.barText:SetText(
BreakUpLargeNumbers(parVal % parThreshold) .. " / " ..
BreakUpLargeNumbers(parThreshold))
if hasReward then
showParagon = true
entry.hasParagonReward = true
entry.standing:SetText("|cff00ff00Reward!|r")
else
entry.standing:SetText("Paragon")
entry.standing:SetTextColor(0.26, 0.42, 0.88)
end
end
end
entry.paragonGlow:SetShown(showParagon)
local selIdx = C_Reputation.GetSelectedFaction()
entry.selBar:SetShown(selIdx == fd.factionIndex)
end
entry:Show()
y = y + (isPureHeader and HEADER_HEIGHT or ENTRY_HEIGHT)
end -- else (visible entry)
end
content:SetHeight(max(y, 1))
end
local DETAIL_WIDTH = 260
local detail = CreateFrame("Frame", nil, container, "BackdropTemplate")
detail:SetWidth(DETAIL_WIDTH)
detail:SetPoint("TOPRIGHT", container, "TOPRIGHT", -4, -30)
detail:SetPoint("BOTTOMRIGHT", container, "BOTTOMRIGHT", -4, 8)
detail:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8x8",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 16,
insets = { left = 4, right = 4, top = 4, bottom = 4 },
})
detail:SetBackdropColor(0.06, 0.06, 0.08, 0.97)
detail:SetBackdropBorderColor(0.35, 0.35, 0.35, 0.9)
detail:SetFrameLevel(container:GetFrameLevel() + 10)
detail:Hide()
local detailClose = CreateFrame("Button", nil, detail, "UIPanelCloseButton")
detailClose:SetPoint("TOPRIGHT", -2, -2)
detailClose:SetScript("OnClick", function()
C_Reputation.SetSelectedFaction(0)
detail:Hide()
ns:UpdateReputation()
end)
local detailTitle = detail:CreateFontString(nil, "OVERLAY", "GameFontNormal")
detailTitle:SetPoint("TOPLEFT", 14, -14)
detailTitle:SetPoint("TOPRIGHT", detailClose, "TOPLEFT", -4, 0)
detailTitle:SetJustifyH("LEFT")
detailTitle:SetTextColor(1, 0.82, 0, 1)
local descScroll = CreateFrame("ScrollFrame", nil, detail,
"UIPanelScrollFrameTemplate")
descScroll:SetPoint("TOPLEFT", detailTitle, "BOTTOMLEFT", 0, -6)
descScroll:SetPoint("RIGHT", detail, "RIGHT", -26, 0)
descScroll:SetHeight(120)
local descText = CreateFrame("Frame", nil, descScroll)
descText:SetWidth(DETAIL_WIDTH - 40)
descScroll:SetScrollChild(descText)
local descString = descText:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
descString:SetPoint("TOPLEFT")
descString:SetWidth(DETAIL_WIDTH - 40)
descString:SetJustifyH("LEFT")
descString:SetTextColor(0.8, 0.8, 0.8, 1)
descString:SetSpacing(2)
local detailDivider = detail:CreateTexture(nil, "ARTWORK")
detailDivider:SetHeight(1)
detailDivider:SetPoint("LEFT", detail, "LEFT", 10, 0)
detailDivider:SetPoint("RIGHT", detail, "RIGHT", -10, 0)
detailDivider:SetPoint("TOP", descScroll, "BOTTOM", 0, -6)
detailDivider:SetColorTexture(0.45, 0.40, 0.25, 0.4)
local function CreateDetailCheckbox(parent, labelText, anchor, yOff)
local cb = CreateFrame("CheckButton", nil, parent, "UICheckButtonTemplate")
cb:SetSize(22, 22)
cb:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, yOff)
cb.text:SetFontObject("GameFontHighlightSmall")
cb.text:SetText(labelText)
return cb
end
local watchCheck = CreateDetailCheckbox(detail,
SHOW_FACTION_ON_MAINSCREEN or "Show as Experience Bar",
detailDivider, -8)
watchCheck:SetScript("OnClick", function(self)
local idx = C_Reputation.GetSelectedFaction()
if self:GetChecked() then
C_Reputation.SetWatchedFactionByIndex(idx)
else
C_Reputation.SetWatchedFactionByIndex(0)
end
if StatusTrackingBarManager then
StatusTrackingBarManager:UpdateBarsShown()
end
PlaySound(self:GetChecked() and SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
or SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
ns:UpdateReputation()
end)
local atWarCheck = CreateDetailCheckbox(detail,
AT_WAR or "At War",
watchCheck, -2)
atWarCheck:SetScript("OnClick", function(self)
C_Reputation.ToggleFactionAtWar(C_Reputation.GetSelectedFaction())
PlaySound(self:GetChecked() and SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
or SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
ns:UpdateReputation()
ns:RefreshReputationDetail()
end)
local inactiveCheck = CreateDetailCheckbox(detail,
MOVE_TO_INACTIVE or "Move to Inactive",
atWarCheck, -2)
inactiveCheck:SetScript("OnClick", function(self)
local shouldBeActive = not self:GetChecked()
C_Reputation.SetFactionActive(C_Reputation.GetSelectedFaction(), shouldBeActive)
PlaySound(self:GetChecked() and SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON
or SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
ns:UpdateReputation()
end)
local viewRenownBtn = CreateFrame("Button", nil, detail, "UIPanelButtonTemplate")
viewRenownBtn:SetSize(140, 22)
viewRenownBtn:SetPoint("BOTTOM", detail, "BOTTOM", 0, 14)
viewRenownBtn:SetText(VIEW_RENOWN_BUTTON_LABEL or "View Renown")
viewRenownBtn:Hide()
viewRenownBtn:SetScript("OnClick", function(self)
if not self.factionID then return end
if EncounterJournal_LoadUI then
if not EncounterJournal then EncounterJournal_LoadUI() end
if EncounterJournal and not EncounterJournal:IsShown() then
ShowUIPanel(EncounterJournal)
end
if EJ_ContentTab_Select and EncounterJournal and EncounterJournal.JourneysTab then
EJ_ContentTab_Select(EncounterJournal.JourneysTab:GetID())
end
if EncounterJournalJourneysFrame and EncounterJournalJourneysFrame.ResetView then
EncounterJournalJourneysFrame:ResetView(nil, self.factionID)
end
end
end)
function ns:RefreshReputationDetail()
local selIdx = C_Reputation.GetSelectedFaction()
if not selIdx or selIdx == 0 then
detail:Hide()
return
end
local fd = C_Reputation.GetFactionDataByIndex(selIdx)
if not fd or not fd.factionID or fd.factionID == 0 then
detail:Hide()
return
end
detailTitle:SetText(fd.name or "")
descString:SetText(fd.description or "")
descText:SetHeight(descString:GetStringHeight() + 4)
watchCheck:SetChecked(fd.isWatched)
local canWar = fd.canToggleAtWar and not fd.isHeader
atWarCheck:SetEnabled(canWar)
atWarCheck:SetChecked(fd.atWarWith)
if canWar then
atWarCheck.text:SetTextColor(RED_FONT_COLOR.r, RED_FONT_COLOR.g,
RED_FONT_COLOR.b)
else
atWarCheck.text:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g,
GRAY_FONT_COLOR.b)
end
local canInactive = fd.canSetInactive
inactiveCheck:SetEnabled(canInactive)
inactiveCheck:SetChecked(not C_Reputation.IsFactionActive(selIdx))
if canInactive then
inactiveCheck.text:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g,
NORMAL_FONT_COLOR.b)
else
inactiveCheck.text:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g,
GRAY_FONT_COLOR.b)
end
local isMajor = IsMajorFaction(fd.factionID)
if isMajor then
viewRenownBtn.factionID = fd.factionID
local mjd = C_MajorFactions and
C_MajorFactions.GetMajorFactionData(fd.factionID)
viewRenownBtn:SetEnabled(mjd and mjd.isUnlocked or false)
viewRenownBtn:Show()
else
viewRenownBtn:Hide()
end
detail:Show()
end