Repository navigation
Expand file tree
/
Copy pathCheckMate.lua
More file actions
470 lines (390 loc) · 15.9 KB
/
Copy pathCheckMate.lua
File metadata and controls
470 lines (390 loc) · 15.9 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
local addonName, ns = ...
ns.dragIndex = nil
ns.isDragging = false
local defaults = {
tasks = {},
locked = false,
scale = 1.0,
pos = { point = "CENTER", x = 0, y = 0 },
iconPos = { point = "CENTER", x = -200, y = 0 },
size = { w = 250, h = 300 },
showCompleted = false
}
-- 1. Main Frame (Damage Meter Aesthetic)
local frame = CreateFrame("Frame", "CheckMateFrame", UIParent, "BackdropTemplate")
frame:SetFrameStrata("DIALOG")
frame:Hide()
frame:SetMovable(true)
frame:SetResizable(true)
frame:SetResizeBounds(180, 100, 800, 1000)
frame:EnableMouse(true)
frame:RegisterForDrag("LeftButton")
frame:SetBackdrop({
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\Buttons\\WHITE8X8",
tile = false, edgeSize = 1,
insets = { left = 1, right = 1, top = 1, bottom = 1 }
})
frame:SetBackdropColor(0, 0, 0, 0.7)
frame:SetBackdropBorderColor(0, 0, 0, 1)
frame:SetScript("OnDragStart", function(self)
if not ns.db.locked then self:StartMoving() end
end)
frame:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
local point, _, _, x, y = self:GetPoint()
if point then ns.db.pos = { point = point, x = x, y = y } end
end)
-- 2. Header Bar (Sleek Dark Gradient with perfectly scaled Skurri font)
local headerBg = frame:CreateTexture(nil, "BACKGROUND", nil, 1)
headerBg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
headerBg:SetGradient("VERTICAL", CreateColor(0, 0, 0, 0.8), CreateColor(0.15, 0.15, 0.15, 0.9))
headerBg:SetPoint("TOPLEFT", 1, -1)
headerBg:SetPoint("TOPRIGHT", -1, -1)
headerBg:SetHeight(24) -- Reverted to standard sleek height
local title = frame:CreateFontString(nil, "OVERLAY")
title:SetFont("Fonts\\FRIZQT__.TTF", 14, "OUTLINE") -- Custom size 14 (tasks are usually 12)
title:SetPoint("LEFT", headerBg, "LEFT", 12, 0)
title:SetText("CheckMate")
title:SetTextColor(1, 0.82, 0)
title:SetShadowColor(0, 0, 0, 1)
title:SetShadowOffset(1, -1)
local closeBtn = CreateFrame("Button", nil, frame, "UIPanelCloseButton")
closeBtn:SetPoint("RIGHT", headerBg, "RIGHT", 4, 0)
closeBtn:SetSize(24, 24)
local clearBtn = CreateFrame("Button", nil, frame)
clearBtn:SetSize(40, 20)
clearBtn:SetPoint("RIGHT", closeBtn, "LEFT", -2, 0)
local clearText = clearBtn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
clearText:SetPoint("CENTER")
clearText:SetText("Clear")
clearText:SetTextColor(0.8, 0.2, 0.2)
clearBtn:SetFontString(clearText)
clearBtn:SetScript("OnEnter", function(self) clearText:SetTextColor(1, 0.2, 0.2) end)
clearBtn:SetScript("OnLeave", function(self) clearText:SetTextColor(0.8, 0.2, 0.2) end)
local addBtn = CreateFrame("Button", nil, frame)
addBtn:SetSize(18, 18)
addBtn:SetPoint("RIGHT", clearBtn, "LEFT", -4, 0)
local addIcon = addBtn:CreateTexture(nil, "ARTWORK")
addIcon:SetTexture("Interface\\Buttons\\UI-PlusButton-Up")
addIcon:SetAllPoints()
addBtn:SetScript("OnMouseDown", function() addIcon:SetTexture("Interface\\Buttons\\UI-PlusButton-Down") end)
addBtn:SetScript("OnMouseUp", function() addIcon:SetTexture("Interface\\Buttons\\UI-PlusButton-Up") end)
-- 3. Inline Edit Box
local inputFrame = CreateFrame("Frame", nil, frame)
inputFrame:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -25) -- Adjusted offset for 24px header
inputFrame:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -1, -25)
inputFrame:SetHeight(28)
inputFrame:Hide()
local inputBg = inputFrame:CreateTexture(nil, "BACKGROUND")
inputBg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
inputBg:SetAllPoints()
inputBg:SetVertexColor(0.1, 0.1, 0.1, 0.95)
local inputBox = CreateFrame("EditBox", nil, inputFrame, "InputBoxTemplate")
inputBox:SetPoint("LEFT", 10, 0)
inputBox:SetPoint("RIGHT", -10, 0)
inputBox:SetHeight(20)
inputBox:SetAutoFocus(false)
inputBox:SetMaxLetters(50)
-- Collapsible "Completed" Header
local completedHeader = CreateFrame("Button", nil, frame)
completedHeader:SetHeight(22)
completedHeader:Hide()
completedHeader.bg = completedHeader:CreateTexture(nil, "BACKGROUND")
completedHeader.bg:SetAllPoints()
completedHeader.bg:SetColorTexture(1, 1, 1, 0)
completedHeader:SetScript("OnEnter", function(self) self.bg:SetColorTexture(1, 1, 1, 0.08) end)
completedHeader:SetScript("OnLeave", function(self) self.bg:SetColorTexture(1, 1, 1, 0) end)
completedHeader.text = completedHeader:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
completedHeader.text:SetPoint("LEFT", 22, 0)
completedHeader.text:SetTextColor(0.6, 0.6, 0.6)
completedHeader.icon = completedHeader:CreateTexture(nil, "ARTWORK")
completedHeader.icon:SetSize(14, 14)
completedHeader.icon:SetPoint("LEFT", 4, 0)
local taskButtons = {}
local function EnforceGroupedSort()
local active, done = {}, {}
for _, t in ipairs(ns.db.tasks) do
if t.done then table.insert(done, t) else table.insert(active, t) end
end
ns.db.tasks = {}
for _, t in ipairs(active) do table.insert(ns.db.tasks, t) end
for _, t in ipairs(done) do table.insert(ns.db.tasks, t) end
end
local function RefreshList()
EnforceGroupedSort()
for _, btn in pairs(taskButtons) do
btn:Hide()
end
completedHeader:Hide()
local yOffset = inputFrame:IsShown() and -54 or -26 -- Adjusted offsets for 24px header
local listWidth = frame:GetWidth() - 2
local numDone = 0
for _, t in ipairs(ns.db.tasks) do
if t.done then numDone = numDone + 1 end
end
completedHeader:SetScript("OnClick", function()
ns.db.showCompleted = not ns.db.showCompleted
RefreshList()
end)
local headerShown = false
for i, task in ipairs(ns.db.tasks) do
if task.done and not headerShown then
completedHeader:SetPoint("TOPLEFT", 1, yOffset - 4)
completedHeader:SetWidth(listWidth)
completedHeader.text:SetText(numDone .. " Completed")
if ns.db.showCompleted then
completedHeader.icon:SetTexture("Interface\\Buttons\\UI-MinusButton-Up")
else
completedHeader.icon:SetTexture("Interface\\Buttons\\UI-PlusButton-Up")
end
completedHeader:Show()
yOffset = yOffset - 30
headerShown = true
end
local btn = taskButtons[i]
if not btn then
btn = CreateFrame("Button", nil, frame)
btn:SetHeight(22)
btn:RegisterForDrag("LeftButton")
btn:SetMovable(true)
btn.bg = btn:CreateTexture(nil, "BACKGROUND")
btn.bg:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
btn.bg:SetAllPoints()
btn.bg:SetVertexColor(1, 1, 1, 0)
btn.checkbox = btn:CreateTexture(nil, "ARTWORK")
btn.checkbox:SetTexture("Interface\\Buttons\\UI-CheckBox-Up")
btn.checkbox:SetSize(24, 24)
btn.checkbox:SetPoint("LEFT", 4, 0)
btn.check = btn:CreateTexture(nil, "OVERLAY")
btn.check:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
btn.check:SetSize(24, 24)
btn.check:SetPoint("CENTER", btn.checkbox, "CENTER", 0, 0)
btn.text = btn:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
btn.text:SetPoint("LEFT", btn.checkbox, "RIGHT", 2, 0)
btn.text:SetPoint("RIGHT", -8, 0)
btn.text:SetJustifyH("LEFT")
btn.text:SetShadowColor(0, 0, 0, 1)
btn.text:SetShadowOffset(1, -1)
btn.strikethrough = btn:CreateTexture(nil, "OVERLAY")
btn.strikethrough:SetColorTexture(0.5, 0.5, 0.5, 1)
btn.strikethrough:SetHeight(1)
btn.strikethrough:SetPoint("LEFT", btn.text, "LEFT", 0, 0)
btn.strikethrough:Hide()
btn:SetScript("OnEnter", function(self)
if not ns.isDragging then self.bg:SetVertexColor(1, 1, 1, 0.05) end
end)
btn:SetScript("OnLeave", function(self)
self.bg:SetVertexColor(1, 1, 1, 0)
end)
btn:SetScript("OnClick", function(self)
if ns.isDragging then return end
ns.db.tasks[self.index].done = not ns.db.tasks[self.index].done
self:SetScript("OnLeave", function(s) s.bg:SetVertexColor(1, 1, 1, 0) end)
RefreshList()
end)
btn:SetScript("OnDragStart", function(self)
ns.dragIndex = self.index
ns.isDragging = true
self:SetFrameLevel(50)
self.bg:SetVertexColor(1, 1, 1, 0.1)
self:StartMoving()
end)
btn:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
self:SetFrameLevel(frame:GetFrameLevel() + 1)
self.bg:SetVertexColor(1, 1, 1, 0)
C_Timer.After(0.05, function() ns.isDragging = false end)
if not ns.dragIndex then return end
local _, y = GetCursorPosition()
local scale = self:GetEffectiveScale()
local cursorY = y / scale
local dropIndex = #ns.db.tasks
for j = 1, #ns.db.tasks do
local tBtn = taskButtons[j]
if tBtn and tBtn:IsShown() and j ~= ns.dragIndex then
local mid = tBtn:GetBottom() + (tBtn:GetHeight() / 2)
if cursorY > mid then
dropIndex = j
break
end
end
end
if ns.dragIndex ~= dropIndex then
local movedTask = table.remove(ns.db.tasks, ns.dragIndex)
table.insert(ns.db.tasks, dropIndex, movedTask)
end
ns.dragIndex = nil
RefreshList()
end)
taskButtons[i] = btn
end
btn.index = i
btn:SetWidth(listWidth)
btn:ClearAllPoints()
btn.text:SetText(task.text)
if task.done then
btn.text:SetTextColor(0.5, 0.5, 0.5)
btn.checkbox:SetVertexColor(0.5, 0.5, 0.5, 0.5)
btn.check:SetVertexColor(0.6, 0.6, 0.6, 1)
btn.check:Show()
btn.strikethrough:SetWidth(btn.text:GetStringWidth())
btn.strikethrough:Show()
if ns.db.showCompleted then
btn:SetPoint("TOPLEFT", 1, yOffset)
btn:Show()
yOffset = yOffset - 23
else
btn:Hide()
end
else
btn.text:SetTextColor(1, 1, 1)
btn.checkbox:SetVertexColor(1, 1, 1, 1)
btn.check:Hide()
btn.strikethrough:Hide()
btn:SetPoint("TOPLEFT", 1, yOffset)
btn:Show()
yOffset = yOffset - 23
end
end
end
addBtn:SetScript("OnClick", function()
if inputFrame:IsShown() then
inputFrame:Hide()
else
inputFrame:Show()
inputBox:SetFocus()
end
RefreshList()
end)
inputBox:SetScript("OnEnterPressed", function()
local text = inputBox:GetText()
if text and text ~= "" then
table.insert(ns.db.tasks, { text = text, done = false })
inputBox:SetText("")
end
inputFrame:Hide()
RefreshList()
end)
inputBox:SetScript("OnEscapePressed", function()
inputBox:SetText("")
inputBox:ClearFocus()
inputFrame:Hide()
RefreshList()
end)
clearBtn:SetScript("OnClick", function()
local remaining = {}
for _, task in ipairs(ns.db.tasks) do
if not task.done then table.insert(remaining, task) end
end
ns.db.tasks = remaining
RefreshList()
end)
local sizer = CreateFrame("Button", nil, frame)
sizer:SetSize(16, 16)
sizer:SetPoint("BOTTOMRIGHT", -2, 2)
sizer:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
sizer:SetHighlightTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
sizer:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
sizer:SetScript("OnMouseDown", function(self, button)
if button == "LeftButton" and not ns.db.locked then frame:StartSizing("BOTTOMRIGHT") end
end)
sizer:SetScript("OnMouseUp", function(self, button)
frame:StopMovingOrSizing()
local width, height = frame:GetSize()
ns.db.size = { w = width, h = height }
end)
frame:SetScript("OnSizeChanged", function()
if ns.optionsBuilt then RefreshList() end
end)
local function BuildOptions()
if ns.optionsBuilt then return end
local ok, category = pcall(Settings.RegisterVerticalLayoutCategory, "CheckMate")
if not ok then return end
local lockedSetting = Settings.RegisterAddOnSetting(
category, "CheckMate_Locked", "locked", ns.db,
"boolean", "Lock Frame Position", false
)
Settings.CreateCheckbox(category, lockedSetting, "Prevents dragging the checklist frame and icon.")
pcall(Settings.RegisterAddOnCategory, category)
ns.optionsBuilt = true
end
_G.CheckMate_Toggle = function()
frame:SetShown(not frame:IsShown())
end
-- 4. Floating Movable Icon
local floatingIcon = CreateFrame("Button", "CheckMateFloatingIcon", UIParent)
floatingIcon:SetSize(36, 36)
floatingIcon:SetFrameStrata("MEDIUM")
local iconTex = floatingIcon:CreateTexture(nil, "BACKGROUND")
iconTex:SetTexture("Interface\\Icons\\inv_misc_note_06")
iconTex:SetAllPoints()
floatingIcon:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square")
floatingIcon:SetMovable(true)
floatingIcon:EnableMouse(true)
floatingIcon:RegisterForDrag("LeftButton")
floatingIcon:RegisterForClicks("RightButtonUp")
floatingIcon:SetScript("OnDragStart", function(self)
if not ns.db.locked then self:StartMoving() end
end)
floatingIcon:SetScript("OnDragStop", function(self)
self:StopMovingOrSizing()
local point, _, _, x, y = self:GetPoint()
if point then ns.db.iconPos = { point = point, x = x, y = y } end
end)
floatingIcon:SetScript("OnClick", function(self, button)
if button == "RightButton" then
_G.CheckMate_Toggle()
end
end)
floatingIcon:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText("CheckMate")
GameTooltip:AddLine("Left-Click and hold to drag", 1, 1, 1)
GameTooltip:AddLine("Right-Click to open checklist", 1, 1, 1)
GameTooltip:Show()
end)
floatingIcon:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
local events = {}
function events:ADDON_LOADED(loaded)
if loaded ~= addonName then return end
CheckMateDB = CheckMateDB or {}
for key, value in pairs(defaults) do
if CheckMateDB[key] == nil then
CheckMateDB[key] = value
end
end
ns.db = CheckMateDB
frame:ClearAllPoints()
if ns.db.pos and ns.db.pos.point then
frame:SetPoint(ns.db.pos.point, UIParent, ns.db.pos.point, ns.db.pos.x, ns.db.pos.y)
else
frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
end
if ns.db.size then
frame:SetSize(ns.db.size.w, ns.db.size.h)
else
frame:SetSize(250, 300)
end
frame:SetScale(ns.db.scale)
floatingIcon:ClearAllPoints()
if ns.db.iconPos and ns.db.iconPos.point then
floatingIcon:SetPoint(ns.db.iconPos.point, UIParent, ns.db.iconPos.point, ns.db.iconPos.x, ns.db.iconPos.y)
else
floatingIcon:SetPoint("CENTER", UIParent, "CENTER", -200, 0)
end
BuildOptions()
RefreshList()
self:UnregisterEvent("ADDON_LOADED")
end
local eventFrame = CreateFrame("Frame")
eventFrame:SetScript("OnEvent", function(self, event, ...)
if events[event] then events[event](self, ...) end
end)
eventFrame:RegisterEvent("ADDON_LOADED")
SLASH_CHECKMATE1 = "/checkmate"
SLASH_CHECKMATE2 = "/cm"
SlashCmdList["CHECKMATE"] = _G.CheckMate_Toggle
print("|cffd4a85a[CheckMate]|r loaded successfully.")