-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.lua
More file actions
272 lines (240 loc) · 8.95 KB
/
Copy pathUI.lua
File metadata and controls
272 lines (240 loc) · 8.95 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
local ADDON_NAME, ns = ...
local UI = {}
ns.UI = UI
local Theme = ns.Theme
local deDE = GetLocale() == "deDE"
local ROW_HEIGHT = 18
local MAX_ROWS = 25 -- TBC raids cap at 25 players (minus yourself), so the list never needs to scroll
local WIDTH = 320
local frame, scroll, rows, header
-- Status indicators use the built-in ready-check textures (the default font lacks
-- the ○ ✓ ⚠ glyphs, so they'd render as empty boxes).
local TEX_READY = "Interface\\RaidFrame\\ReadyCheck-Ready"
local TEX_NOTREADY = "Interface\\RaidFrame\\ReadyCheck-NotReady"
local TEX_WAITING = "Interface\\RaidFrame\\ReadyCheck-Waiting"
local STATUS_STYLE = {
[ns.Roster.UNCHECKED] = { tex = TEX_WAITING, info = deDE and "nicht geprüft" or "unchecked" },
[ns.Roster.STALE] = { tex = TEX_WAITING, info = deDE and "veraltet" or "stale" },
[ns.Roster.CLEAN] = { tex = TEX_READY, info = deDE and "in Ordnung" or "ok" },
[ns.Roster.FLAGGED] = { tex = TEX_NOTREADY, info = nil },
}
local function classColor(classFile)
return Theme:ClassColor(classFile)
end
-- Flat dark button (ElvUI look): solid fill, 1px black border, hover lift.
local function flatButton(parent, w, h, label)
local b = CreateFrame("Button", nil, parent, "BackdropTemplate")
if w then
b:SetSize(w, h)
end
b:SetBackdrop({ bgFile = Theme.WHITE, edgeFile = Theme.WHITE, edgeSize = 1 })
b:SetBackdropColor(unpack(Theme.btnBg))
b:SetBackdropBorderColor(unpack(Theme.border))
b.text = b:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
b.text:SetPoint("CENTER")
b.text:SetText(label)
b.text:SetTextColor(unpack(Theme.text))
b:SetScript("OnEnter", function(s)
s:SetBackdropColor(unpack(Theme.btnHover))
end)
b:SetScript("OnLeave", function(s)
s:SetBackdropColor(unpack(Theme.btnBg))
end)
return b
end
local function createRow(parent, index)
local row = CreateFrame("Button", "ScryRow" .. index, parent, "SecureActionButtonTemplate")
row:SetHeight(ROW_HEIGHT)
row:RegisterForClicks("AnyUp")
row:SetAttribute("type", "macro")
row.bg = row:CreateTexture(nil, "BACKGROUND")
row.bg:SetAllPoints()
row.icon = row:CreateTexture(nil, "OVERLAY")
row.icon:SetSize(14, 14)
row.icon:SetPoint("LEFT", 5, 0)
row.name = row:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
row.name:SetPoint("LEFT", row.icon, "RIGHT", 5, 0)
row.name:SetJustifyH("LEFT")
row.name:SetWidth(90)
row.name:SetWordWrap(false)
row.info = row:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
row.info:SetPoint("LEFT", row.name, "RIGHT", 4, 0)
row.info:SetPoint("RIGHT", -2, 0)
row.info:SetJustifyH("LEFT")
row.info:SetWordWrap(false)
-- Per-row whisper button: only shown for flagged, not-yet-whispered players.
row.whisper = flatButton(row, 64, 14, deDE and "Flüstern" or "Whisper")
row.whisper:SetPoint("RIGHT", -2, 0)
row.whisper:SetScript("OnClick", function(self)
ns.Roster:Whisper(self:GetParent().entry)
UI.Refresh()
end)
row.whisper:Hide()
local hl = row:CreateTexture(nil, "HIGHLIGHT")
hl:SetAllPoints()
hl:SetColorTexture(unpack(Theme.hover))
row:SetScript("OnEnter", function(self)
local e = self.entry
if not e then
return
end
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:AddLine(e.name, classColor(e.class))
if e.spec then
GameTooltip:AddLine((deDE and "Talente: %s" or "Talents: %s"):format(e.spec), 0.8, 0.8, 0.8)
end
if e.problems and #e.problems > 0 then
GameTooltip:AddLine(" ")
for _, p in ipairs(e.problems) do
GameTooltip:AddLine("|cffff5555-|r " .. p, 1, 0.5, 0.5)
end
elseif e.record then
GameTooltip:AddLine(deDE and "Keine Mängel gefunden." or "No issues found.", 0.4, 0.85, 0.45)
else
GameTooltip:AddLine(deDE and "Noch nicht inspiziert." or "Not inspected yet.", 0.6, 0.6, 0.6)
end
if e.time then
local mins = math.floor((time() - e.time) / 60)
GameTooltip:AddLine((deDE and "geprüft vor %d min" or "checked %d min ago"):format(mins), 0.5, 0.5, 0.5)
end
GameTooltip:AddLine(deDE and "Klick: anvisieren, dann manuell inspizieren" or "Click: target, then inspect manually", 0.4, 0.6, 1.0)
GameTooltip:Show()
end)
row:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
return row
end
local function Refresh()
if not frame or not frame:IsShown() then
return
end
local entries = ns.Roster:Build()
local checked, total, flagged = ns.Roster:Summary(entries)
header:SetText((deDE and "%d/%d geprüft — %d auffällig" or "%d/%d checked — %d flagged"):format(checked, total, flagged))
local offset = FauxScrollFrame_GetOffset(scroll)
FauxScrollFrame_Update(scroll, #entries, MAX_ROWS, ROW_HEIGHT)
for i = 1, MAX_ROWS do
local row = rows[i]
local e = entries[i + offset]
if e then
local style = STATUS_STYLE[e.status]
row.entry = e
-- faint zebra stripe
if (i + offset) % 2 == 0 then
row.bg:SetColorTexture(unpack(Theme.rowAlt))
else
row.bg:SetColorTexture(0, 0, 0, 0)
end
row.icon:SetTexture(style.tex)
row.name:SetText(e.name)
row.name:SetTextColor(classColor(e.class))
if e.status == ns.Roster.FLAGGED and e.problems then
-- Keep the row concise; the full list lives in the hover tooltip.
row.info:SetTextColor(unpack(Theme.bad))
if e.whispered then
row.info:SetText((deDE and "%d Mängel · geflüstert" or "%d issue(s) · whispered"):format(#e.problems))
row.whisper:Hide()
else
row.info:SetText((deDE and "%d Mängel" or "%d issue(s)"):format(#e.problems))
row.whisper:Show()
end
else
-- For checked/clean rows, show the talent spec if we have it; else the status word.
row.info:SetText(e.spec or style.info or "")
row.info:SetTextColor(unpack(Theme.dim))
row.whisper:Hide()
end
-- Secure click-to-target so you can then inspect manually. Skipped in combat (locked).
if not InCombatLockdown() then
row:SetAttribute("macrotext", "/target " .. e.name)
end
row:Show()
else
row:Hide()
end
end
end
UI.Refresh = Refresh
local function CreateWindow()
frame = CreateFrame("Frame", "ScryFrame", UIParent, "BackdropTemplate")
frame:SetSize(WIDTH, ROW_HEIGHT * MAX_ROWS + 90)
frame:SetPoint("CENTER")
frame:SetBackdrop({
bgFile = Theme.WHITE,
edgeFile = Theme.WHITE,
edgeSize = 1,
insets = { left = 1, right = 1, top = 1, bottom = 1 },
})
frame:SetBackdropColor(unpack(Theme.bg))
frame:SetBackdropBorderColor(unpack(Theme.border))
frame:SetMovable(true)
frame:EnableMouse(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", frame.StartMoving)
frame:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
local point, _, relPoint, x, y = self:GetPoint()
ns.db.profile.window.point = { point, relPoint, x, y }
end)
if ns.db.profile.window.point then
local p = ns.db.profile.window.point
frame:ClearAllPoints()
frame:SetPoint(p[1], UIParent, p[2], p[3], p[4])
end
-- ESC closes the window.
tinsert(UISpecialFrames, "ScryFrame")
local title = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
title:SetPoint("TOP", 0, -10)
title:SetText("Scry")
title:SetTextColor(Theme:Accent())
local close = flatButton(frame, 20, 18, "X")
close:SetPoint("TOPRIGHT", -6, -8)
close:SetScript("OnClick", function()
frame:Hide()
end)
header = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
header:SetPoint("TOP", title, "BOTTOM", 0, -4)
header:SetTextColor(unpack(Theme.dim))
-- Scrolling list. FauxScrollFrame supplies only the scrollbar + offset; the
-- visible rows are regular children of the frame (the canonical FauxScroll pattern).
scroll = CreateFrame("ScrollFrame", "ScryScroll", frame, "FauxScrollFrameTemplate")
scroll:SetPoint("TOPLEFT", 12, -46)
scroll:SetPoint("BOTTOMRIGHT", -30, 38)
scroll:SetScript("OnVerticalScroll", function(self, off)
FauxScrollFrame_OnVerticalScroll(self, off, ROW_HEIGHT, Refresh)
end)
rows = {}
for i = 1, MAX_ROWS do
local row = createRow(frame, i)
if i == 1 then
row:SetPoint("TOPLEFT", scroll, "TOPLEFT", 0, 0)
else
row:SetPoint("TOPLEFT", rows[i - 1], "BOTTOMLEFT", 0, 0)
end
row:SetPoint("RIGHT", scroll, "RIGHT", -4, 0)
rows[i] = row
end
-- Footer: reset (whispering is per-row, so no extra hint needed)
local reset = flatButton(frame, 80, 20, deDE and "Reset" or "Reset")
reset:SetPoint("BOTTOM", 0, 10)
reset:SetScript("OnClick", function()
wipe(ns.db.global.cache)
wipe(ns.db.global.whispered)
Refresh()
end)
-- Swap everything to the Expressway/outline look.
Theme:ApplyFontToFrame(frame)
frame:SetScript("OnShow", Refresh)
frame:Hide() -- CreateFrame shows by default; start hidden so the first Toggle opens it
end
function UI:Toggle()
if not frame then
CreateWindow()
end
if frame:IsShown() then
frame:Hide()
else
frame:Show()
end
end