Repository navigation
Expand file tree
/
Copy pathUI.lua
More file actions
1780 lines (1659 loc) · 72.7 KB
/
Copy pathUI.lua
File metadata and controls
1780 lines (1659 loc) · 72.7 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
-- SpawnCamp window. Always on screen:
--
-- [icon] SpawnCamp [gear] [x]
-- Key [ F ] [Clear] works on your target below
-- [ type or paste a mob name ] [Add] [My Target] [Nearby] [Recent] [Quest]
-- TARGET
-- (portrait) Mechanized Sentry [Attack] [Talk] [Clear]
-- dead 2:05, due in 2:55
-- RECENT
-- (p) Other Mob up, seen 0:12 ago [x]
--
-- The key works on the selected target only; with none it does nothing.
-- Attack / Talk are a pressed/raised pair; right-click either for its options.
-- Click a Recent mob to make it the target, right-click it (or click the
-- target's name) for its respawn log, which opens beside the window. The gear
-- holds general settings.
local ADDON, SC = ...
local F
local ui = {}
local recentOffset, histOffset = 0, 0
local RECENT_ROWS, HIST_ROWS = 14, 14
local RECENT_H = 22
local W = 520
local PANEL_H = { settings = 192 }
local capturing -- { settings = table with .key, button = key button } while setting a key
-- The game's sword and chat cursors, tinted gold on the buttons.
local SWORD = "Interface\\CURSOR\\Attack"
local BUBBLE = "Interface\\CURSOR\\Speak"
------------------------------------------------------------------------------
-- Widget helpers
------------------------------------------------------------------------------
local function Text(parent, text, x, y, font)
local fs = parent:CreateFontString(nil, "OVERLAY", font or "GameFontHighlightSmall")
fs:SetPoint("TOPLEFT", x, y)
fs:SetJustifyH("LEFT")
fs:SetText(text or "")
return fs
end
local function Tip(frame, title, body)
frame:SetScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(title)
if body then GameTooltip:AddLine(body, 1, 1, 1, true) end
GameTooltip:Show()
end)
frame:SetScript("OnLeave", GameTooltip_Hide)
end
-- The mob's tooltip: the game's own when it's in view (target, nameplate,
-- mouseover), else the copy from when it was last seen, else what's known.
function SC.ShowMobTip(owner, name, click)
GameTooltip:SetOwner(owner, "ANCHOR_RIGHT")
if not name then
GameTooltip:SetText("Any quest mob")
local w = SC.QuestWanted()
GameTooltip:AddLine(#w > 0 and table.concat(w, ", ") or "No quest mobs needed right now.", 1, 1, 1, true)
GameTooltip:Show()
return
end
local u = SC.UnitFor(name)
local tip = not u and SC.TipFor(name)
if u then
GameTooltip:SetUnit(u)
elseif tip then
for i, e in ipairs(tip.lines) do
if e[5] then
GameTooltip:AddDoubleLine(e[1], e[5], e[2], e[3], e[4], e[6], e[7], e[8])
else
GameTooltip:AddLine(e[1], e[2], e[3], e[4], i > 1)
end
end
GameTooltip:AddLine("Not in view. Last seen " .. SC.Clock(GetServerTime() - tip.t) .. " ago.", 0.6, 0.6, 0.6)
else
local info = SC.nearby[name]
local m = SC.char.mobs[name]
GameTooltip:AddLine(name, 1, 0.82, 0)
local level = info and info.level
local ctype = (info and info.ctype) or (m and m.ctype)
local cls = info and info.class
local parts = {}
if type(level) == "number" then parts[#parts + 1] = "Level " .. (level < 0 and "??" or level) end
if ctype then parts[#parts + 1] = ctype end
if cls and cls ~= "normal" and cls ~= "minus" then parts[#parts + 1] = "(" .. cls:gsub("elite", " Elite"):gsub("^%s+", ""):gsub("^%l", string.upper) .. ")" end
if #parts > 0 then GameTooltip:AddLine(table.concat(parts, " "), 1, 1, 1) end
GameTooltip:AddLine("Not in view. Its full tooltip shows here once you've seen it.", 0.6, 0.6, 0.6, true)
end
if click then GameTooltip:AddLine("Click to target it.", 0.25, 1, 0.25) end
GameTooltip:Show()
end
local function Safe(fn)
return function(...)
local ok, err = pcall(fn, ...)
if not ok then SC.Print("|cffff4040error|r " .. tostring(err)) end
end
end
local function Btn(parent, text, w, x, y, onClick)
local b = CreateFrame("Button", nil, parent, "UIPanelButtonTemplate")
b:SetSize(w, 22)
b:SetPoint("TOPLEFT", x, y)
b:SetText(text)
b:SetScript("OnClick", Safe(onClick))
return b
end
local function Check(parent, label, x, y, get, set, tip)
local cb = CreateFrame("CheckButton", nil, parent, "UICheckButtonTemplate")
cb:SetSize(24, 24)
cb:SetPoint("TOPLEFT", x, y)
local fs = cb:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
fs:SetPoint("LEFT", cb, "RIGHT", 2, 0)
fs:SetText(label)
cb.label = fs
cb:SetScript("OnClick", Safe(function(self)
set(self:GetChecked() and true or false)
SC.ApplyBindings()
SC.Refresh()
end))
if tip then Tip(cb, label, tip) end
cb.get = get
table.insert(ui.checks, cb)
return cb
end
-- Saves on Enter, on focus lost and while typing (OnTextChanged's userInput flag
-- isn't reliable on Forever, so HasFocus decides).
local function Edit(parent, w, x, y, onSave, numeric)
local e = CreateFrame("EditBox", nil, parent, "InputBoxTemplate")
e:SetSize(w, 20)
e:SetPoint("TOPLEFT", x + 6, y)
e:SetAutoFocus(false)
if numeric then e:SetNumeric(true) end
local function save(self) onSave(self:GetText() or "") end
e:SetScript("OnEnterPressed", function(self) save(self); self:ClearFocus(); SC.Refresh() end)
e:SetScript("OnEscapePressed", function(self) self:ClearFocus(); SC.Refresh() end)
e:SetScript("OnEditFocusLost", function(self) save(self); SC.Refresh() end)
e:SetScript("OnTextChanged", function(self) if self:HasFocus() then save(self) end end)
return e
end
local function Backdrop(f, a)
f:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8X8",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 12, insets = { left = 3, right = 3, top = 3, bottom = 3 },
})
f:SetBackdropColor(0.05, 0.05, 0.07, a or 0.9)
f:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
end
local function BigEdit(parent, w, h, x, y, maxLetters, onSave)
local e = CreateFrame("EditBox", nil, parent, "BackdropTemplate")
e:SetPoint("TOPLEFT", x, y)
e:SetSize(w, h)
e:SetMultiLine(true)
e:SetAutoFocus(false)
e:SetFontObject(ChatFontNormal)
e:SetTextInsets(6, 6, 4, 4)
e:SetMaxLetters(maxLetters)
Backdrop(e, 0.8)
local function save(self) onSave(self:GetText() or "") end
e:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
e:SetScript("OnEditFocusLost", function(self) save(self); SC.ApplyBindings(); SC.Refresh() end)
e:SetScript("OnTextChanged", function(self) if self:HasFocus() then save(self) end end)
e:SetScript("OnMouseDown", function(self) self:SetFocus() end)
return e
end
local function SetEditText(e, text)
if not e:HasFocus() then e:SetText(text or "") end
end
local function Header(parent, text, y)
local fs = Text(parent, text, 8, y, "GameFontNormal")
local line = parent:CreateTexture(nil, "ARTWORK")
line:SetColorTexture(1, 0.82, 0, 0.25)
line:SetHeight(1)
line:SetPoint("LEFT", fs, "RIGHT", 6, 0)
line:SetPoint("RIGHT", parent, "RIGHT", -8, 0)
return fs
end
local function Popup(name, w, h, title)
local p = CreateFrame("Frame", name, UIParent, "BackdropTemplate")
p:SetSize(w, h)
p:SetFrameStrata("DIALOG")
p:EnableMouse(true)
Backdrop(p, 0.95)
Text(p, title, 10, -10, "GameFontNormal")
local close = CreateFrame("Button", nil, p, "UIPanelCloseButton")
close:SetSize(22, 22)
close:SetPoint("TOPRIGHT", -1, -1)
p:Hide()
tinsert(UISpecialFrames, name)
return p
end
------------------------------------------------------------------------------
-- Spell field
------------------------------------------------------------------------------
local function SpellInfo(name)
if not name or name == "" then return nil end
if C_Spell and C_Spell.GetSpellInfo then
local ok, info = pcall(C_Spell.GetSpellInfo, name)
if ok and info then return info.name, info.castTime end
elseif GetSpellInfo then
local n, _, _, castTime = GetSpellInfo(name)
return n, castTime
end
return nil
end
local function TakeDroppedSpell()
local kind, a, _, c = GetCursorInfo()
if kind ~= "spell" then return end
local id = c or a
local n
if C_Spell and C_Spell.GetSpellName then n = C_Spell.GetSpellName(id) end
if not n and GetSpellInfo then n = GetSpellInfo(id) end
if not n then return end
ClearCursor()
SC.char.attack.spell = n
ui.spell:ClearFocus()
ui.spell:SetText(n)
SC.ApplyBindings()
SC.Refresh()
end
------------------------------------------------------------------------------
-- Key capture
------------------------------------------------------------------------------
local MOUSE_KEYS = { MiddleButton = "BUTTON3", Button4 = "BUTTON4", Button5 = "BUTTON5" }
local MODIFIERS = { LSHIFT = 1, RSHIFT = 1, LCTRL = 1, RCTRL = 1, LALT = 1, RALT = 1, LMETA = 1, RMETA = 1 }
local function StopCapture()
if capturing and capturing.button then capturing.button:EnableKeyboard(false) end
capturing = nil
SC.Refresh()
end
local function SetKey(key)
if not capturing then return end
local mods = (IsAltKeyDown() and "ALT-" or "") .. (IsControlKeyDown() and "CTRL-" or "")
.. (IsShiftKeyDown() and "SHIFT-" or "")
capturing.settings.key = mods .. key
SC.ApplyBindings()
StopCapture()
end
local function KeyButton(parent, x, y, settings)
local b = CreateFrame("Button", nil, parent, "UIPanelButtonTemplate")
b:SetSize(150, 22)
b:SetPoint("TOPLEFT", x, y)
b:RegisterForClicks("AnyUp")
b.settings = settings
b:SetScript("OnClick", function(self, button)
if capturing then
if capturing.button == self and MOUSE_KEYS[button] then SetKey(MOUSE_KEYS[button]) else StopCapture() end
return
end
if InCombatLockdown() then SC.Print("set the key out of combat"); return end
capturing = { settings = settings, button = self }
self:SetText("|cffffd100Press a key or wheel...|r")
self:EnableKeyboard(true)
if self.SetPropagateKeyboardInput then self:SetPropagateKeyboardInput(false) end
end)
b:SetScript("OnKeyDown", function(self, key)
if not capturing or capturing.button ~= self then return end
if key == "ESCAPE" then StopCapture(); return end
if MODIFIERS[key] then return end
SetKey(key)
end)
b:EnableKeyboard(false)
-- The mouse wheel can be the key too (with modifiers), while waiting for a press.
b:EnableMouseWheel(true)
b:SetScript("OnMouseWheel", function(self, delta)
if not capturing or capturing.button ~= self then return end
SetKey(delta > 0 and "MOUSEWHEELUP" or "MOUSEWHEELDOWN")
end)
b:SetScript("OnHide", function(self) if capturing and capturing.button == self then StopCapture() end end)
Tip(b, "SpawnCamp key", "Click, then press a key, roll the mouse wheel, or press mouse button 3-5. Shift/Ctrl/Alt combos work. Escape cancels. It only takes over while you have a target selected.")
table.insert(ui.keys, b)
return b
end
------------------------------------------------------------------------------
-- Status colours
------------------------------------------------------------------------------
local function StatusColor(state)
if state == "up" then return "|cff40ff40" end
if state == "window" then return "|cffffd100" end
if state == "late" then return "|cffff8040" end
return "|cffcccccc"
end
SC.StatusColor = StatusColor
local BAR = {
up = { 0.2, 0.8, 0.2 }, window = { 0.9, 0.7, 0.1 }, late = { 0.9, 0.4, 0.1 },
waiting = { 0.3, 0.45, 0.8 }, dead = { 0.4, 0.4, 0.4 }, none = { 0.25, 0.25, 0.25 },
}
------------------------------------------------------------------------------
-- Portraits: the game draws a unit's portrait only while the unit exists, so
-- each mob's is captured whenever it's seen (target, nameplate, mouseover) and
-- kept for the session. Until then a question mark.
------------------------------------------------------------------------------
local portraits = {} -- mob name -> frame
-- Until a real portrait is captured: an icon for the creature type (saved the
-- first time the mob is seen), else one for its action.
local TYPE_ICON = {
Beast = "Ability_Hunter_Pet_Wolf",
Humanoid = "INV_Misc_Head_Human_01",
Undead = "INV_Misc_Bone_HumanSkull_01",
Demon = "Spell_Shadow_SummonFelHunter",
Elemental = "Spell_Nature_EarthElemental_Totem",
Dragonkin = "INV_Misc_Head_Dragon_01",
Giant = "Ability_Warrior_BattleShout",
Mechanical = "INV_Gizmo_02",
Critter = "Ability_Hunter_Pet_Rat",
Aberration = "Spell_Shadow_UnholyFrenzy",
}
local QUEST_ICON = "Interface\\GossipFrame\\AvailableQuestIcon"
local QUEST_KEY = "|quest|" -- portrait cache key for "Any quest mob"
local function DefaultIcon(name)
if name == nil or name == QUEST_KEY then return QUEST_ICON end
local m = SC.char.mobs[name]
local near = SC.nearby and SC.nearby[name]
local icon = (m and m.ctype and TYPE_ICON[m.ctype]) or (near and near.ctype and TYPE_ICON[near.ctype])
if not icon then icon = (m and m.mode == "interact") and "INV_Scroll_03" or "INV_Sword_04" end
return "Interface\\Icons\\" .. icon
end
local function Portrait(name)
local p = portraits[name]
if p then return p end
p = CreateFrame("Frame", nil, F)
p.tex = p:CreateTexture(nil, "ARTWORK")
p.tex:SetAllPoints()
p.tex:SetTexture(DefaultIcon(name))
pcall(function()
local mask = p:CreateMaskTexture()
mask:SetTexture("Interface\\CharacterFrame\\TempPortraitAlphaMask", "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE")
mask:SetAllPoints(p.tex)
p.tex:AddMaskTexture(mask)
end)
portraits[name] = p
return p
end
function SC.CapturePortrait(name, unit)
local m = SC.char.mobs[name]
if not m and not (SC.char.anyQuest and SC.IsQuestWanted(name)) then return end
local ok, ctype = pcall(UnitCreatureType, unit)
ctype = ok and SC.Plain(ctype)
if ctype and m then m.ctype = ctype end
if not F then return end
local p = Portrait(name)
local now = GetTime()
if p.at and now - p.at < 15 then return end
if pcall(SetPortraitTexture, p.tex, unit) then p.at = now end
end
local function PlacePortrait(name, holder)
local p = Portrait(name)
if not p.at then p.tex:SetTexture(DefaultIcon(name)) end
p:SetParent(holder)
p:ClearAllPoints()
p:SetAllPoints(holder)
p:Show()
holder.portrait = p
end
------------------------------------------------------------------------------
-- Attack / Talk buttons: big square icon-only buttons. A pressed/raised pair:
-- pressed = bright red, thick gold border, gold glow, shaded top, gold icon
-- nudged down; raised = dark grey, grey border, light top band, grey icon.
-- Clicking the pressed one does nothing. Right-click opens its options.
------------------------------------------------------------------------------
local MODE_SIZE = 46
local function Gradient(tex, top, bottom)
tex:SetColorTexture(1, 1, 1, 1)
local ok = CreateColor and pcall(tex.SetGradient, tex, "VERTICAL",
CreateColor(bottom[1], bottom[2], bottom[3], 1), CreateColor(top[1], top[2], top[3], 1))
if not ok then tex:SetColorTexture(top[1], top[2], top[3], 1) end
end
local function ModeButton(parent, icon, onLeft, onRight, title, body)
local b = CreateFrame("Button", nil, parent, "BackdropTemplate")
b:SetSize(MODE_SIZE, MODE_SIZE)
b:RegisterForClicks("LeftButtonUp", "RightButtonUp")
b:SetBackdrop({ edgeFile = "Interface\\Buttons\\WHITE8X8", edgeSize = 3 })
-- Gold glow around the pressed one.
b.glow = b:CreateTexture(nil, "BACKGROUND", nil, -8)
b.glow:SetPoint("TOPLEFT", -10, 10)
b.glow:SetPoint("BOTTOMRIGHT", 10, -10)
b.glow:SetTexture("Interface\\Buttons\\UI-ActionButton-Border")
b.glow:SetBlendMode("ADD")
b.glow:SetVertexColor(1, 0.8, 0.2, 0.9)
b.fill = b:CreateTexture(nil, "BACKGROUND")
b.fill:SetPoint("TOPLEFT", 3, -3)
b.fill:SetPoint("BOTTOMRIGHT", -3, 3)
-- Raised: light band on top. Pressed: dark band on top (pushed in).
b.shine = b:CreateTexture(nil, "BORDER")
b.shine:SetPoint("TOPLEFT", 3, -3)
b.shine:SetPoint("TOPRIGHT", -3, -3)
b.shine:SetHeight(MODE_SIZE * 0.4)
b.shine:SetColorTexture(1, 1, 1, 0.10)
b.inset = b:CreateTexture(nil, "BORDER")
b.inset:SetPoint("TOPLEFT", 3, -3)
b.inset:SetPoint("TOPRIGHT", -3, -3)
b.inset:SetHeight(8)
b.inset:SetColorTexture(0, 0, 0, 0.45)
b:SetHighlightTexture("Interface\\Buttons\\WHITE8X8", "ADD")
b:GetHighlightTexture():SetVertexColor(1, 0.8, 0.3, 0.12)
b.icon = b:CreateTexture(nil, "ARTWORK")
b.icon:SetSize(MODE_SIZE - 14, MODE_SIZE - 14)
b.icon:SetTexture(icon)
b.icon:SetDesaturated(true)
b:SetScript("OnClick", Safe(function(self, button)
if button == "RightButton" then onRight(self) else onLeft(self) end
end))
Tip(b, title, body)
return b
end
local function SetPressed(b, pressed)
b.icon:ClearAllPoints()
b.icon:SetDesaturated(true)
b.icon:SetAlpha(1)
if pressed then
Gradient(b.fill, { 0.55, 0.05, 0.03 }, { 0.9, 0.15, 0.06 })
b:SetBackdropBorderColor(1, 0.82, 0.1, 1)
b.glow:Show()
b.shine:Hide()
b.inset:Show()
b.icon:SetPoint("CENTER", 1, -2)
b.icon:SetVertexColor(1, 0.86, 0.15)
else
Gradient(b.fill, { 0.3, 0.3, 0.32 }, { 0.13, 0.13, 0.14 })
b:SetBackdropBorderColor(0.38, 0.38, 0.4, 1)
b.glow:Hide()
b.shine:Show()
b.inset:Hide()
b.icon:SetPoint("CENTER", 0, 1)
b.icon:SetVertexColor(0.72, 0.72, 0.72)
end
end
local function SetMode(mode, slot)
local mob = SC.Active(slot)
if not mob or mob.mode == mode then return end
mob.mode = mode
SC.ApplyBindings()
SC.Refresh()
end
------------------------------------------------------------------------------
-- Attack and Talk options (right-click popups)
------------------------------------------------------------------------------
local AP, TP, N, RP, Q, AQ
local function HideSidePanels(except)
for _, p in ipairs({ AP, TP, N, RP, Q, AQ }) do
if p and p ~= except then p:Hide() end
end
end
-- Opens an options popup beside the window, or closes it if it's open. A
-- click outside an open popup (including on the other button) only closes it.
local closedAt = 0
local function ShowBeside(p, opener)
if (p == AP or p == TP) and GetTime() - closedAt < 0.2 then return end
local wasShown = p:IsShown()
HideSidePanels()
if not wasShown then
p.opener = opener
p:ClearAllPoints()
local beside = (SC.char.logRight and ui.log and ui.log:IsShown()) and ui.log or F
p:SetPoint("TOPLEFT", beside, "TOPRIGHT", 2, 0)
p:Show()
end
SC.Refresh()
end
-- Clicks that shouldn't close the options: in the spellbook (to drag a spell
-- onto the Spell box), on the action bars, or while holding something.
local KEEP_OPEN = { "SpellBookFrame", "PlayerSpellsFrame", "ProfessionsBookFrame", "MainMenuBar",
"MultiBarBottomLeft", "MultiBarBottomRight", "MultiBarRight", "MultiBarLeft" }
local function ClickKeepsOpen()
if GetCursorInfo and GetCursorInfo() then return true end
for _, name in ipairs(KEEP_OPEN) do
local frame = _G[name]
if frame and frame.IsShown and frame:IsShown() and frame:IsMouseOver() then return true end
end
return false
end
SC.On("GLOBAL_MOUSE_DOWN", function()
if ClickKeepsOpen() then return end
for _, p in ipairs({ AP, TP }) do
if p and p:IsShown() and not p:IsMouseOver() and not (p.opener and p.opener:IsMouseOver()) then
p:Hide()
closedAt = GetTime()
end
end
end)
local function Wrapped(parent, text, x, y, w)
local fs = Text(parent, text, x, y)
fs:SetWidth(w)
fs:SetWordWrap(true)
return fs
end
local function BuildAttackPopup()
local A = SC.char.attack
AP = Popup("SpawnCampAttackOptions", 380, 212, "Attack |T" .. SWORD .. ":14|t")
Text(AP, "Spell", 12, -40)
ui.spell = Edit(AP, 200, 46, -36, function(t)
A.spell = strtrim(t)
SC.ApplyBindings()
end)
ui.spell:SetScript("OnReceiveDrag", TakeDroppedSpell)
ui.spell:HookScript("OnMouseDown", TakeDroppedSpell)
Wrapped(AP, "Drag a spell here from your spellbook, or type its name. Empty = auto attack only.", 12, -62, 356)
ui.spellNote = Text(AP, "", 12, -90)
Wrapped(AP, "Or your own macro lines. They replace the spell and run after the mob is targeted.", 12, -110, 356)
ui.macroEdit = BigEdit(AP, 356, 62, 12, -138, 800, function(t) A.macro = t end)
end
local function BuildTalkPopup()
local I = SC.char.interact
TP = Popup("SpawnCampTalkOptions", 380, 250, "Talk |T" .. BUBBLE .. ":14|t")
Check(TP, "Hand in and accept quests (follow-ups too)", 8, -30,
function() return I.autoQuest end, function(v) I.autoQuest = v end)
Check(TP, "Click through chat", 8, -52,
function() return I.gossip end, function(v) I.gossip = v end,
"Picks a chat option for you: one matching the list below if there is one, otherwise the first option.")
Wrapped(TP, "Prefer chat options containing (one per line, optional). Otherwise the first option is picked.", 12, -82, 356)
ui.prefer = BigEdit(TP, 356, 46, 12, -110, 600, function(t) I.prefer = t end)
Text(TP, "Quest reward", 12, -168)
ui.reward = Edit(TP, 30, 92, -164, function(t) I.reward = tonumber(t) or 0 end, true)
Wrapped(TP, "When a quest offers a choice of rewards: 1 = first, 2 = second, and so on. Empty = you pick.", 12, -190, 356)
Text(TP, "Hold Shift while talking to do a window yourself.", 12, -224, "GameFontDisableSmall")
end
------------------------------------------------------------------------------
-- Build: header, key row, add row, target, recent
------------------------------------------------------------------------------
local function SavePos()
local p, _, rp, x, y = F:GetPoint()
SC.char.framePos = { p, rp, x, y }
end
local function BuildTop()
local icon = F:CreateTexture(nil, "ARTWORK")
icon:SetSize(16, 16)
icon:SetPoint("TOPLEFT", 6, -5)
icon:SetTexture(SC.ICON)
Text(F, "SpawnCamp", 26, -7, "GameFontNormal")
local close = CreateFrame("Button", nil, F, "UIPanelCloseButton")
close:SetSize(22, 22)
close:SetPoint("TOPRIGHT", -1, -1)
close:SetScript("OnClick", function()
SC.char.shown = false
HideSidePanels()
SC.Print("hidden. /spawncamp (or the minimap button) brings it back.")
SC.Refresh()
end)
local gear = CreateFrame("Button", nil, F)
gear:SetSize(16, 16)
gear:SetPoint("RIGHT", close, "LEFT", -2, 0)
gear:SetNormalTexture("Interface\\Buttons\\UI-OptionsButton")
gear:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square", "ADD")
gear:SetScript("OnClick", function()
SC.char.panel = SC.char.panel ~= "settings" and "settings" or nil
SC.Refresh()
end)
Tip(gear, "Settings", "Sharing, alerts, sound, the list and the log side.")
ui.logToggle = CreateFrame("Button", nil, F, "UIPanelButtonTemplate")
ui.logToggle:SetSize(52, 18)
ui.logToggle:SetPoint("RIGHT", gear, "LEFT", -6, 0)
ui.logToggle:SetScript("OnClick", function()
SC.char.logOpen = not SC.char.logOpen
SC.Refresh()
end)
Tip(ui.logToggle, "Log", "Opens or closes the target's log: respawn times and every sighting.")
-- Recent: a quiet text link in the header.
local recent = CreateFrame("Button", nil, F)
recent:SetSize(46, 16)
recent:SetPoint("RIGHT", ui.logToggle, "LEFT", -8, 0)
recent:SetNormalFontObject("GameFontDisableSmall")
recent:SetHighlightFontObject("GameFontHighlightSmall")
recent:SetText("Recent")
recent:SetScript("OnClick", function() SC.ToggleRecent() end)
Tip(recent, "Recent", "Every mob you've targeted before. Pick one again or remove it.")
-- Key row
KeyButton(F, 8, -29, SC.char)
local clearKey = Btn(F, "Unassign", 70, 162, -29, function()
SC.char.key = ""
SC.ApplyBindings()
SC.Refresh()
end)
Tip(clearKey, "Unassign", "Removes the key. Your normal binding for it comes back.")
ui.keyNote = Text(F, "", 240, -34)
ui.keyNote:SetWidth(220)
end
local BOX_H = 64 -- height of a target box (and the picker)
-- The picker: a blank target box with the ways to add one. Shown when you have
-- no targets (and Auto Quest is off), or after "+ Add another target".
-- New target [ type or paste a mob name ] [Add] [x]
-- [My Target] [Nearby] [Quest] [Auto Quest]
local function BuildPicker()
local T = CreateFrame("Frame", nil, F, "BackdropTemplate")
T:SetHeight(BOX_H)
Backdrop(T, 0.6)
T:SetBackdropBorderColor(1, 0.82, 0, 0.6)
ui.picker = T
Text(T, "New target", 10, -11, "GameFontNormal")
ui.addName = Edit(T, 230, 84, -8, function() end)
local hint = ui.addName:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
hint:SetPoint("LEFT", 2, 0)
hint:SetText("type or paste a mob name")
local function showHint()
hint:SetShown(not ui.addName:HasFocus() and (ui.addName:GetText() or "") == "")
end
ui.addName:HookScript("OnEditFocusGained", showHint)
ui.addName:HookScript("OnEditFocusLost", showHint)
ui.addName:HookScript("OnTextChanged", showHint)
local function addTyped()
local n = strtrim(ui.addName:GetText() or "")
if n ~= "" then SC.AddTyped(n) end
ui.addName:SetText("")
ui.addName:ClearFocus()
SC.Refresh()
end
ui.addName:SetScript("OnEnterPressed", addTyped)
ui.addName:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
Tip(Btn(T, "Add", 44, 326, -8, addTyped), "Add", "Adds the typed name to your targets. Part of a name works too: it becomes a search, and every mob seen with that in its name is added as its own target. Clear a wrong one and the search skips it from then on.")
Tip(Btn(T, "My Target", 84, 8, -36, function() SC.AddTarget(); SC.Refresh() end),
"My Target", "Adds the mob you have targeted in game to your targets: Attack if hostile, Talk if friendly.")
Tip(Btn(T, "Nearby", 64, 94, -36, function() SC.ToggleNearby() end),
"Nearby", "Lists mobs around you, with a button to use each one.")
Tip(Btn(T, "Quest", 56, 160, -36, function() SC.ToggleQuests() end),
"Quest", "Mobs your current quests want: kill objectives from your quest log, plus mobs nearby that your quests need (item drops too).")
ui.autoQuest = Btn(T, "Auto Quest", 92, 218, -36, function() SC.SetAnyQuest(not SC.char.anyQuest) end)
Tip(ui.autoQuest, "Auto Quest", "On, your key goes for any mob your quests still need, alive and not tagged by someone else, after your own targets. Finished objectives drop off by themselves.")
ui.pickCancel = CreateFrame("Button", nil, T, "UIPanelCloseButton")
ui.pickCancel:SetSize(22, 22)
ui.pickCancel:SetPoint("TOPRIGHT", -2, -2)
ui.pickCancel:SetScript("OnClick", function()
ui.picking = false
if ui.addName then ui.addName:ClearFocus() end
SC.Refresh()
end)
Tip(ui.pickCancel, "Cancel", "Closes this without adding a target.")
end
-- Target boxes, one per slot, left to right:
-- [portrait] Name ETA 0:15 [sword] [bubble] [Clear]
-- dead 0:05, ... Avg respawn 0:20 Keep [x]
-- quest = the Auto Quest box: same look, but the key picks the mob.
local function BuildTargetBox(slot, quest)
local bx = { quest = quest }
local T = CreateFrame("Frame", nil, F, "BackdropTemplate")
T:SetHeight(BOX_H)
Backdrop(T, 0.6)
T:SetBackdropBorderColor(1, 0.82, 0, 0.6)
bx.frame = T
bx.portrait = CreateFrame("Frame", nil, T)
bx.portrait:SetSize(52, 52)
bx.portrait:SetPoint("LEFT", 30, 0)
bx.portrait:EnableMouse(true)
bx.portrait:SetScript("OnEnter", function(self) SC.ShowMobTip(self, bx.tipName) end)
bx.portrait:SetScript("OnLeave", GameTooltip_Hide)
-- Right column: Clear, with Keep under it.
bx.clear = Btn(T, "Clear", 58, 0, 0, function()
if quest then SC.SetAnyQuest(false) else SC.SetActive(nil, slot) end
end)
bx.clear:ClearAllPoints()
bx.clear:SetPoint("TOPRIGHT", -6, -8)
bx.clear:SetHeight(20)
if quest then
Tip(bx.clear, "Clear", "Turns Auto Quest off.")
else
Tip(bx.clear, "Clear target", "Takes this mob off your key. It stays in Recent.")
end
bx.keep = Check(T, "Keep", 0, 0,
function() local m = SC.Active(slot); return m and m.keep end,
function(v) local m = SC.Active(slot); if m then m.keep = v end end,
"Ticked, this mob stays your target after you get the kill, until you press Clear. Unticked, getting the kill clears it.")
bx.keep:ClearAllPoints()
bx.keep:SetSize(20, 20)
bx.keep:SetPoint("TOPRIGHT", bx.clear, "BOTTOMRIGHT", 0, -4)
bx.keep.label:ClearAllPoints()
bx.keep.label:SetPoint("RIGHT", bx.keep, "LEFT", -1, 0)
-- The two big buttons.
bx.talk = ModeButton(T, BUBBLE, function() HideSidePanels(); SetMode("interact", slot) end, function(self) ShowBeside(TP, self) end,
"Talk", "Your key talks to this NPC: chat, quest hand-ins, new and follow-up quests.\n|cffffd100Right-click|r for the chat and quest options.")
bx.talk:SetPoint("RIGHT", T, "RIGHT", -74, 0)
bx.attack = ModeButton(T, SWORD, function() HideSidePanels(); if not quest then SetMode("attack", slot) end end, function(self) ShowBeside(AP, self) end,
"Attack", quest and "Your key targets the quest mob and casts your attack spell.\n|cffffd100Right-click|r to set the spell or macro."
or "Your key targets this mob and casts your attack spell.\n|cffffd100Right-click|r to set the spell or macro.")
bx.attack:SetPoint("RIGHT", bx.talk, "LEFT", -6, 0)
-- ETA column.
local eta = CreateFrame("Frame", nil, T)
eta:SetSize(92, 52)
eta:SetPoint("RIGHT", bx.attack, "LEFT", -8, 0)
bx.eta = eta:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
bx.eta:SetPoint("TOP", 0, -6)
bx.avg = eta:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall")
bx.avg:SetPoint("BOTTOM", 0, 8)
eta:EnableMouse(true)
if quest then
Tip(eta, "Quest progress", "Kills (or items) done out of how many the quest needs. With several quest mobs, how many kinds are still needed.")
else
Tip(eta, "Respawn ETA", "Avg respawn: how long this mob usually takes to come back after it dies (from the log). ETA counts down to that from its last death. At zero you get a soft ding, whether or not it has shown.")
end
bx.etaBox = eta
-- Name and status, taking the rest.
local nameArea = CreateFrame("Frame", nil, T)
nameArea:SetPoint("TOPLEFT", bx.portrait, "TOPRIGHT", 8, 0)
nameArea:SetPoint("BOTTOMRIGHT", eta, "BOTTOMLEFT", -6, 0)
bx.name = nameArea:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
bx.name:SetPoint("TOPLEFT", 0, -6)
bx.name:SetPoint("RIGHT", 0, 0)
bx.name:SetJustifyH("LEFT")
bx.name:SetWordWrap(false)
bx.status = nameArea:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
bx.status:SetPoint("BOTTOMLEFT", 0, 8)
bx.status:SetPoint("RIGHT", 0, 0)
bx.status:SetJustifyH("LEFT")
bx.status:SetWordWrap(false)
bx.nameArea = nameArea
if not quest then
-- On a mob a search found: keep it and drop the search.
bx.lock = Btn(T, "Lock in", 64, 0, 0, function() local m = SC.Active(slot); if m then SC.LockIn(m.name) end end)
bx.lock:ClearAllPoints()
bx.lock:SetPoint("BOTTOMRIGHT", nameArea, "BOTTOMRIGHT", 0, 3)
bx.lock:SetHeight(20)
Tip(bx.lock, "Lock in", "This is the one. Keeps this mob and removes the search that found it, along with anything else that search added.")
bx.lock:Hide()
end
if not quest then
-- Priority arrows at the left edge. Higher in the list = higher priority.
local function Arrow(dir, delta, tip)
local a = CreateFrame("Button", nil, T)
a:SetSize(26, 26)
a:SetNormalTexture("Interface\\Buttons\\Arrow-" .. dir .. "-Up")
a:SetPushedTexture("Interface\\Buttons\\Arrow-" .. dir .. "-Down")
a:SetDisabledTexture("Interface\\Buttons\\Arrow-" .. dir .. "-Up")
a:GetDisabledTexture():SetDesaturated(true)
a:GetDisabledTexture():SetAlpha(0.3)
a:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD")
a:SetScript("OnClick", function() SC.MoveTarget(slot, delta) end)
Tip(a, "Priority", tip)
return a
end
bx.up = Arrow("Up", -1, "Higher priority. With several targets in view, the key goes for the highest one.")
bx.up:SetPoint("TOPLEFT", T, "TOPLEFT", 2, -4)
bx.down = Arrow("Down", 1, "Lower priority. With several targets in view, the key goes for the highest one.")
bx.down:SetPoint("BOTTOMLEFT", T, "BOTTOMLEFT", 2, 4)
end
if quest then
bx.talk:Hide()
bx.keep:Hide()
bx.show = Btn(T, "Show targets", 92, 0, 0, function() SC.ToggleAutoTargets() end)
bx.show:ClearAllPoints()
bx.show:SetPoint("TOPRIGHT", bx.clear, "BOTTOMRIGHT", 0, -4)
bx.show:SetHeight(20)
Tip(bx.show, "Show targets", "Lists the quest mobs Auto Quest is looking for.")
-- Gold "!" on the portrait: this box's mob is picked by the key.
bx.badge = T:CreateTexture(nil, "OVERLAY", nil, 7)
bx.badge:SetSize(20, 20)
bx.badge:SetPoint("BOTTOMRIGHT", bx.portrait, "BOTTOMRIGHT", 4, -4)
bx.badge:SetTexture(QUEST_ICON)
end
return bx
end
local function BuildTarget()
ui.boxes = {}
for slot = 1, SC.MAX_TARGETS do ui.boxes[slot] = BuildTargetBox(slot) end
ui.questBox = BuildTargetBox(SC.MAX_TARGETS + 1, true)
-- Under the last target: add another.
ui.addAnother = Btn(F, "+ Add another target", 160, 0, 0, function()
ui.picking = true
SC.Refresh()
if ui.addName then ui.addName:SetFocus() end
end)
Tip(ui.addAnother, "Another target", "Your key goes for the highest target in the list that's in view, alive and untagged (the arrows on each box's left edge change the order); each keeps its own Attack/Talk. Up to " .. SC.MAX_TARGETS .. ".")
end
-- Clicking a target's name or portrait targets that mob in game. Targeting is
-- protected, so a secure button sits over each. They're parented to UIParent and
-- placed by screen position (a protected frame anchored to the window would
-- make the window itself protected), and only moved or changed out of combat.
local nameSecure, portSecure = {}, {}
local function NewTargetButton(name)
local b = CreateFrame("Button", name, UIParent, "SecureActionButtonTemplate")
b:RegisterForClicks("LeftButtonUp", "LeftButtonDown")
b:SetAttribute("type", "macro")
b:SetAttribute("macrotext", "")
b:SetFrameStrata("MEDIUM")
b:SetHighlightTexture("Interface\\Buttons\\WHITE8X8", "ADD")
b:GetHighlightTexture():SetVertexColor(1, 0.82, 0, 0.15)
b:SetScript("OnEnter", function(self) SC.ShowMobTip(self, self.mobName, true) end)
b:SetScript("OnLeave", GameTooltip_Hide)
b:Hide()
return b
end
-- Puts b over region (screen coords), or hides it.
local function Cover(b, region, name, w, h, dy)
local l, bottom = region:GetLeft(), region:GetBottom()
if not (name and l and bottom and region:IsVisible()) then b:Hide(); return end
b:SetAttribute("macrotext", SC.TargetCmd(name) .. name)
b.mobName = name
local s = region:GetEffectiveScale() / UIParent:GetEffectiveScale()
b:ClearAllPoints()
b:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", l * s, (bottom + (dy or 0)) * s)
b:SetSize(w * s, h * s)
b:SetFrameLevel(F:GetFrameLevel() + 30)
b:Show()
end
local function BuildNameSecure()
for slot = 1, SC.MAX_TARGETS + 1 do
portSecure[slot] = NewTargetButton("SpawnCampTargetPortrait" .. slot)
local b = CreateFrame("Button", "SpawnCampTargetName" .. slot, UIParent, "SecureActionButtonTemplate")
b:RegisterForClicks("LeftButtonUp", "LeftButtonDown")
b:SetAttribute("type", "macro")
b:SetAttribute("macrotext", "")
b:SetFrameStrata("MEDIUM")
b:SetHighlightTexture("Interface\\Buttons\\WHITE8X8", "ADD")
b:GetHighlightTexture():SetVertexColor(1, 0.82, 0, 0.15)
b:SetScript("OnEnter", function(self) SC.ShowMobTip(self, self.mobName, true) end)
b:SetScript("OnLeave", GameTooltip_Hide)
b:Hide()
nameSecure[slot] = b
end
end
local function PlaceNameSecure()
if InCombatLockdown() then return end
for slot = 1, SC.MAX_TARGETS + 1 do
local b, bx = nameSecure[slot], ui.boxes[slot] or ui.questBox
local m = SC.Active(slot)
if bx.quest then
local name = SC.QuestShown()
m = name and { name = name } or nil
end
local fs = bx.name
local l, bottom = fs:GetLeft(), fs:GetBottom()
local pb = portSecure[slot]
if pb then
if m and F:IsShown() and bx.frame:IsShown() then
Cover(pb, bx.portrait, m.name, bx.portrait:GetWidth(), bx.portrait:GetHeight())
else
pb:Hide()
end
end
if not (b and m and F:IsShown() and bx.frame:IsShown() and fs:IsVisible() and l and bottom) then
if b then b:Hide() end
else
b:SetAttribute("macrotext", SC.TargetCmd(m.name) .. m.name)
b.mobName = m.name
local s = fs:GetEffectiveScale() / UIParent:GetEffectiveScale()
local w = math.max(fs:GetStringWidth() or 0, 40)
b:ClearAllPoints()
b:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", l * s, bottom * s - 2)
b:SetSize(w * s, fs:GetHeight() * s + 4)
b:SetFrameLevel(F:GetFrameLevel() + 30)
b:Show()
end
end
end
-- Recent targets: a pop-out beside the window listing every mob you've
-- targeted, newest first, with Use and remove.
local function BuildRecent()
RP = Popup("SpawnCampRecent", 380, 60 + RECENT_ROWS * RECENT_H, "Recent targets")
ui.recentEmpty = Text(RP, "Mobs you've targeted show up here.", 12, -36, "GameFontDisableSmall")
ui.recentCount = Text(RP, "", 12, -40 - RECENT_ROWS * RECENT_H, "GameFontDisableSmall")
ui.recent = {}
for i = 1, RECENT_ROWS do
local r = CreateFrame("Frame", nil, RP)
r:SetHeight(RECENT_H - 2)
r:SetPoint("TOPLEFT", 8, -32 - (i - 1) * RECENT_H)
r:SetPoint("RIGHT", RP, "RIGHT", -8, 0)
r.bar = CreateFrame("StatusBar", nil, r)
r.bar:SetPoint("TOPLEFT", RECENT_H, 0)
r.bar:SetPoint("BOTTOMRIGHT", -70, 0)
r.bar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
r.bar:SetMinMaxValues(0, 1)
r.holder = CreateFrame("Frame", nil, r)
r.holder:SetSize(RECENT_H - 4, RECENT_H - 4)
r.holder:SetPoint("LEFT", 1, 0)
r.name = r.bar:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
r.name:SetPoint("LEFT", 4, 0)
r.name:SetWidth(130)
r.name:SetJustifyH("LEFT")
r.name:SetWordWrap(false)
r.status = r.bar:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
r.status:SetPoint("LEFT", r.name, "RIGHT", 4, 0)
r.status:SetPoint("RIGHT", -4, 0)
r.status:SetJustifyH("LEFT")
r.status:SetWordWrap(false)
r.x = CreateFrame("Button", nil, r)
r.x:SetSize(18, 18)
r.x:SetPoint("RIGHT", -2, 0)
r.x:SetNormalFontObject("GameFontRed")
r.x:SetText("x")
r.x:SetScript("OnClick", Safe(function() SC.RemoveMob(r.mobName) end))
Tip(r.x, "Remove", "Takes it off the list. Its sighting history is kept.")
r.use = CreateFrame("Button", nil, r, "UIPanelButtonTemplate")
r.use:SetSize(44, 18)
r.use:SetPoint("RIGHT", r.x, "LEFT", -4, 0)
r.use:SetText("Use")
r.use:SetScript("OnClick", Safe(function() SC.SetActive(r.mobName) end))
Tip(r.use, "Use", "Adds it to your targets.")
r.current = r:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
r.current:SetPoint("RIGHT", r.x, "LEFT", -6, 0)
r.current:SetText("target")
r:EnableMouseWheel(true)
r:SetScript("OnMouseWheel", function(_, d)
recentOffset = math.max(0, recentOffset - d)
SC.Refresh()
end)
ui.recent[i] = r
end
end
function SC.ToggleRecent()
if not F then return end
ShowBeside(RP)
end
-- The log describes one target: the first, or the second when switched.
local function Sel()
return SC.Active(SC.char.logSlot or 1) or SC.Active(1)
end
local LOG_W = 380
local LOG_H = 138 + HIST_ROWS * 16
-- A drawer beside the window (left by default; right in the settings).
local function BuildLog()
local P = CreateFrame("Frame", "SpawnCampLog", F, "BackdropTemplate")
P:SetSize(LOG_W, LOG_H)
Backdrop(P, 0.9)
P:EnableMouse(true)
ui.log = P
local titleBtn = CreateFrame("Button", nil, P)
titleBtn:SetPoint("TOPLEFT", 8, -6)
titleBtn:SetSize(340, 18)
ui.logTitle = titleBtn:CreateFontString(nil, "OVERLAY", "GameFontNormal")
ui.logTitle:SetPoint("LEFT", 2, 0)
ui.logTitle:SetWidth(336)
ui.logTitle:SetJustifyH("LEFT")
ui.logTitle:SetWordWrap(false)
titleBtn:SetScript("OnClick", function()
local count = #SC.Actives()