Repository navigation
Expand file tree
/
Copy pathSparkleWindow.lua
More file actions
3133 lines (2984 loc) · 142 KB
/
Copy pathSparkleWindow.lua
File metadata and controls
3133 lines (2984 loc) · 142 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
-- The sparkle window: a list on the left with each kind of node and the settings for all
-- of them (and the addon's own pages, if it adds any), the styles as tiles with a small
-- preview each (None turns the kind off), the look's settings, and the node in 3D with
-- its sparkles on it, as in the world.
--
-- Sections: Nodes to preview, Changing the look, Building the window, Sparkle Maker,
-- Showing a page, Interact Key turned off.
local ADDON_NAME, ns = ...
local ipairs, floor, format = ipairs, math.floor, string.format
local sqrt, sin, cos, tan, max = math.sqrt, math.sin, math.cos, math.tan, math.max
---------------------------------------------------------------------------
-- Nodes to preview
---------------------------------------------------------------------------
-- Name, model file (world/skillactivated/..., and world/goober/..., the game's objects you click),
-- the scale the world draws it at (1 if not given) and how much nearer the camera goes.
local NODES = {
herbs = {
{ "Peacebloom", 219481, 0.5 }, { "Silverleaf", 219487, 0.6, 0.55 }, { "Bruiseweed", 219440, 0.7 },
{ "Stranglekelp", 219495, 0.5 }, { "Black Lotus", 219437 },
},
ore = {
{ "Copper Vein", 219514, 0.5 }, { "Tin Vein", 219568, 0.5 }, { "Iron Deposit", 219532, 0.5 }, { "Gold Vein", 219524, 0.5 },
{ "Mithril Deposit", 219541, 0.5 }, { "Truesilver Deposit", 219569, 0.5 }, { "Small Thorium Vein", 219566, 0.5 },
},
chests = { { "Battered Chest", 219372 } },
quests = {
{ "Supply Crate", 200960 }, { "Barrel", 200884 }, { "Scroll", 201113 }, { "Spider Egg Sac", 200974 },
{ "Keg", 201058 }, { "Pumpkin", 201088 },
},
others = {
{ "Book", 200912 }, { "Meeting Stone", 197022 }, { "Lever", 201061 }, { "Gong", 201029 }, { "Brazier", 200925 },
},
bobber = { { "Fishing Bobber", 201000 } },
-- Creatures by display ID (creature = true), lying dead.
skinning = {
{ "Plainstrider", 1219, creature = true }, { "Mottled Boar", 503, creature = true },
{ "Young Wolf", 447, creature = true }, { "Flatland Cougar", 1059, creature = true },
},
}
NODES.loot = NODES.skinning
local DEAD = 6 -- the "Dead" animation: a corpse lying still
-- The camera looks down a little, as you see a node on the ground, and the
-- node fills this much of the preview.
local PITCH, FOV, FILL = 0.35, 0.6, 0.7
local ZOOM_IN, ZOOM_START, ZOOM_OUT = 0.4, 1.6, 2.2 -- times that distance
-- The sparkles at the size and place they have in the world, next to the node.
-- In the world they are sized for a node 25 yards from the camera; with the game's
-- camera seeing 54 degrees top to bottom on a screen 768 UI units high, a yard is YARD units there.
local YARD = 768 / (2 * 25 * tan(math.rad(27)))
local PLATE_OVER = 1.25 -- yards from the top of the node's box up to its plate
local AREA = 100 -- the camera also stands back far enough for sparkles this size
local NEARER = { herbs = 0.85, skinning = 0.65, loot = 0.65 } -- small next to their sparkles (herbs) or their box (a corpse): the camera nearer
-- Color sets, from the game's own colors (item qualities, class colors, gold text).
local SETS = {
{ "Gold and white", "ffffd100", "ffffffff" },
{ "Nature", "ff1eff00", "ffffd100" },
{ "Arcane", "ffa335ee", "ff69ccf0" },
{ "Frost", "ff69ccf0", "ffffffff" },
{ "Fire", "ffff8000", "ffffd100" },
{ "Shadow", "ff8788ee", "ffa335ee" },
{ "Holy", "fff58cba", "ffffd100" },
{ "Blood", "ffc41f3b", "ffff8000" },
}
-- Settings for all sparkles (the General tab), saved under these keys.
local GENERAL = { gameIcons = true, brightness = true, reachLook = true, combatHide = true, instanceHide = true,
harvest = true, grayTooHard = true, myProfessions = true, cultivation = true, rareGlow = true, sparkleSound = true,
gatherDim = true, minimapButton = true, townInteractOff = true, stoneBackground = true }
-- The list's sparkle entries: each kind (its name, what it sparkles on and its icon), then the settings.
local TABS = {
{ key = "herbs", name = "Herbs", on = "Sparkles on herbs", icon = "Interface\\Icons\\INV_Misc_Herb_01",
tip = "Sparkles on the herb in front of you." },
{ key = "ore", name = "Ore", on = "Sparkles on ore", icon = "Interface\\Icons\\INV_Ore_Copper_01",
tip = "Sparkles on the ore in front of you." },
{ key = "chests", name = "Chests", on = "Sparkles on chests", icon = "Interface\\Icons\\INV_Box_01",
tip = "Sparkles on chests, footlockers and other treasure." },
{ key = "quests", name = "Quest objects", on = "Sparkles on quest objects", icon = "Interface\\Icons\\INV_Misc_Note_01",
tip = "Sparkles on things you need for a quest." },
{ key = "others", name = "Other objects", on = "Sparkles on other objects", icon = "Interface\\Icons\\INV_Box_02",
tip = "Sparkles on anything else you can use. Not mailboxes, chairs or doors." },
{ key = "bobber", name = "Fishing bobber", on = "Sparkles on your fishing bobber", icon = "Interface\\Icons\\Trade_Fishing",
tip = "Sparkles on your bobber so it's easier to spot." },
{ key = "skinning", name = "Skinning", on = "Sparkles on skinnable corpses", icon = "Interface\\Icons\\INV_Misc_Pelt_Wolf_01",
tip = "Sparkles on corpses you can skin, once they're looted." },
{ key = "loot", name = "Lootable corpses", on = "Sparkles on lootable corpses", icon = "Interface\\Icons\\INV_Misc_Bag_08",
tip = "Sparkles on corpses that still have loot." },
{ key = "general", name = "Sparkle settings", icon = "Interface\\Icons\\INV_Misc_Gear_01" },
{ key = "maker", name = "Sparkle Maker (Beta)", icon = "Interface\\Icons\\INV_Enchant_EssenceMagicLarge" },
}
-- The game's own icon over each kind when it's the interact target (its cursor's atlas).
local GAME_ICONS = { herbs = "Crosshair_GatherHerbs_64", ore = "Crosshair_Mine_64", chests = "Crosshair_lootall_64",
quests = "Crosshair_questinteract_64", others = "Crosshair_interact_64", bobber = "Crosshair_interact_64",
skinning = "Crosshair_Skin_64", loot = "Crosshair_lootall_64" }
-- Added to the on/off box's tooltip.
local NEEDS = " Sparkles turn on the game's Interact Key. Turn them all off (and the Cultivation icon) and your settings go back."
local window -- made the first time it opens
---------------------------------------------------------------------------
-- Changing the look
---------------------------------------------------------------------------
-- The kinds the shown tab changes, and the one whose look it shows (All shows the herbs').
local function Kinds()
return { window.tab.key }
end
local function Shown()
local key = window.tab.key
return (key == "general" or key == "maker" or window.tab.page) and "herbs" or key
end
-- Why sparkles may not show while some are on, most important first: { text, red }.
-- (Enable Interact Key off has a line and button of its own.)
local PROFESSIONS = { herbs = "Herbalism", ore = "Mining", skinning = "Skinning" }
local CVAR_NAMES = { SoftTargetIconGameObject = "Interact Key Icons" }
function ns.RefusedText(cvar)
return ("Something keeps turning off %s, which sparkles need. Another addon or a setting may be changing it.")
:format(CVAR_NAMES[cvar] or cvar)
end
local function Problems()
local list, any = {}, false
for _, kind in ipairs(ns.KINDS) do any = any or ns.db[kind] == true end
if not any then return list end
local cvar = ns.RefusedCVar()
if cvar then list[#list + 1] = { ns.RefusedText(cvar), true } end
if ns.SetupPending() then list[#list + 1] = { "Sparkles turn on when this fight ends." } end
if ns.InteractPaused() then
list[#list + 1] = { "Nothing sparkles in town: Interact Key off in towns is ticked. Click to change it.", false, "townInteractOff" }
end
if ns.db.instanceHide and IsInInstance() then
list[#list + 1] = { "No sparkles in instances: Hide in instances is ticked. Click to change it.", false, "instanceHide" }
end
if ns.db.combatHide and UnitAffectingCombat("player") then
list[#list + 1] = { "No sparkles in combat: Hide in combat is ticked. Click to change it.", false, "combatHide" }
end
if ns.db.myProfessions then
local missing = {}
for _, kind in ipairs({ "herbs", "ore", "skinning" }) do
if ns.db[kind] and not ns.HasProfession(kind) then missing[#missing + 1] = PROFESSIONS[kind] end
end
if missing[1] then
list[#list + 1] = { ("No %s on this character: Only for my professions is ticked. Click to change it.")
:format(table.concat(missing, " or ")), false, "myProfessions" }
end
end
return list
end
local function Hex(r, g, b)
return format("ff%02x%02x%02x", floor(r * 255 + 0.5), floor(g * 255 + 0.5), floor(b * 255 + 0.5))
end
local Refresh, FrameNode, PlaceCamera, PickStyle, PlayHarvest, ShowExample
local BuildMaker, RefreshMaker, AskDelete, ShowCode, WarnMaker, TileMenu -- (Sparkle Maker)
-- The settings the preview shows for a few seconds when they're ticked, and what it shows.
local EXAMPLES = { rareGlow = "rare", reachLook = "far", grayTooHard = "tooHard" }
local EXAMPLE_TIME = 3
-- The sparkles in the world after a change.
local function Changed()
ns.UpdateAll()
end
-- Each kind keeps every style's look as it was last left (the settings' styleLooks[kind][style]),
-- so a style picked again comes back with its changes.
local LOOK = { "size", "height", "count", "color", "color2" }
local IN_LOOK = { size = true, height = true, count = true, color = true, color2 = true }
local function Remember(kind)
local keys, looks = ns.SPARKLE_KEYS[kind], ns.db.styleLooks
local look = {}
for _, what in ipairs(LOOK) do look[what] = ns.db[keys[what]] end
looks[kind] = looks[kind] or {}
looks[kind][ns.db[keys.style]] = look
end
local START_HEIGHT = ns.SPARKLE_START_HEIGHT -- (kinds whose every style starts at one height)
local LookOf = ns.StyleLook -- (style i's look for a kind: as it was left, or the one it comes with)
-- Sets a part of the look (or "on") for the tab's kinds, then the sparkles and the window.
-- "everything": sparkles on or off for every kind.
local function Set(what, value)
if what == "own" then
if ns.SetOwnSettings then ns.SetOwnSettings(value) end
ns.AskReload()
return Refresh()
end
if GENERAL[what] then
ns.db[what] = value
Changed()
if what == "gameIcons" or what == "townInteractOff" or what == "cultivation" then ns.Setup() end
if what == "cultivation" then ns.CultivationRefresh() end
if what == "minimapButton" and ns.MinimapButtonChanged then ns.MinimapButtonChanged() end
if value and EXAMPLES[what] then return ShowExample(what) end
return Refresh()
end
local kinds = what == "everything" and ns.KINDS or Kinds()
for _, kind in ipairs(kinds) do
if what == "on" or what == "everything" then
ns.db[kind] = value
else
ns.db[ns.SPARKLE_KEYS[kind][what]] = value
if IN_LOOK[what] then Remember(kind) end
end
end
Changed()
if what == "on" or what == "everything" then ns.Setup() end
Refresh()
end
-- A kind on or off (its box in the list).
local function SetKind(kind, on)
ns.db[kind] = on
Changed()
ns.Setup()
Refresh()
end
-- A style, with its look as it was left, for the tab's kinds; it turns them on.
function PickStyle(i)
for _, kind in ipairs(Kinds()) do
local keys, look = ns.SPARKLE_KEYS[kind], LookOf(kind, i)
ns.db[keys.style], ns.db[keys.made] = i, nil
if ns.db[keys.style2] == i then ns.db[keys.style2] = nil end -- (the second one is the first now)
for _, what in ipairs(LOOK) do ns.db[keys[what]] = look[what] end
ns.db[kind] = true
end
Changed()
ns.Setup()
Refresh()
end
-- A Sparkle Maker sparkle for the tab's kinds, in place of their style; it turns them on.
local function PickMade(id)
for _, kind in ipairs(Kinds()) do
local keys = ns.SPARKLE_KEYS[kind]
ns.db[keys.made] = id
if ns.db[keys.made2] == id then ns.db[keys.made2] = nil end
ns.db[kind] = true
end
Changed()
ns.Setup()
Refresh()
end
-- Shift-click: a second style (i) or Sparkle Maker sparkle (id) shown with the first, or
-- taken away again. The first one itself stays as it is.
local function PickSecond(i, id)
for _, kind in ipairs(Kinds()) do
local keys = ns.SPARKLE_KEYS[kind]
local made = ns.FindMade(ns.db[keys.made])
local first = id and made and made.id == id or i and not made and ns.db[keys.style] == i
if not first then
local again = i and ns.db[keys.style2] == i or id and ns.db[keys.made2] == id
ns.db[keys.style2], ns.db[keys.made2] = not again and i or nil, not again and id or nil
ns.db[kind] = true
end
end
Changed()
ns.Setup()
Refresh()
end
-- The kind's style and look as they come (on or off stays as it is).
local function Defaults()
for _, kind in ipairs(Kinds()) do
local keys = ns.SPARKLE_KEYS[kind]
ns.db[keys.style], ns.db[keys.made], ns.db[keys.style2], ns.db[keys.made2] = ns.defaults[keys.style], nil, nil, nil
for _, what in ipairs(LOOK) do ns.db[keys[what]] = ns.defaults[keys[what]] end
ns.db.styleLooks[kind] = nil
end
Changed()
Refresh()
end
-- Both colors at once (a set, Reset); nil for the second: the same as the first.
local function SetColors(one, two)
for _, kind in ipairs(Kinds()) do
local keys = ns.SPARKLE_KEYS[kind]
ns.db[keys.color], ns.db[keys.color2] = one, two
Remember(kind)
end
Changed()
Refresh()
end
-- The Color set menu, and the name its dropdown shows: the set two colors are, or Custom.
local function IsSet(set)
local now, second = ns.SparkleColors(Shown())
return now == set[2] and second == set[3]
end
local function PickSet(set) SetColors(set[2], set[3]) end
local function SetsMenu(_, root)
for _, set in ipairs(SETS) do root:CreateRadio(set[1], IsSet, PickSet, set) end
end
local function SetName(one, two)
for _, set in ipairs(SETS) do
if one == set[2] and two == set[3] then return set[1] end
end
return CUSTOM
end
-- what: "color" or "color2". Cancel puts back each kind's colors from before. The picker
-- calls swatchFunc as it opens and on Okay too: nothing is saved until the color moves.
local function PickColor(what)
local one, two = ns.SparkleLook(Shown(), "color"), ns.SparkleLook(Shown(), "color2")
local r, g, b = ns.SparkleRGB(what == "color2" and (two or one) or one)
local kinds, before, start, moved = Kinds(), {}, Hex(r, g, b), false
for i, kind in ipairs(kinds) do before[i] = { ns.SparkleLook(kind, "color"), ns.SparkleLook(kind, "color2") } end
ColorPickerFrame:SetupColorPickerAndShow({ r = r, g = g, b = b, hasOpacity = false,
swatchFunc = function()
local hex = Hex(ColorPickerFrame:GetColorRGB())
if hex == start and not moved then return end
moved = true
Set(what, hex)
end,
cancelFunc = function()
for i, kind in ipairs(kinds) do
local keys = ns.SPARKLE_KEYS[kind]
ns.db[keys.color], ns.db[keys.color2] = before[i][1], before[i][2]
Remember(kind)
end
Changed()
Refresh()
end })
end
---------------------------------------------------------------------------
-- Building the window
---------------------------------------------------------------------------
-- Frames are made with no parent, then SetParent (see NewSparkles in Sparkles.lua).
local function New(kind, parent, template)
local frame = CreateFrame(kind, nil, nil, template)
frame:SetParent(parent)
return frame
end
local function Label(parent, text, font)
local label = parent:CreateFontString(nil, "ARTWORK", font or "GameFontNormal")
label:SetText(text)
return label
end
-- title and text can be functions (for the tab's own words). Hooked, so a Blizzard
-- template keeps its own hover look.
local function Tooltip(frame, title, text, hint)
frame:HookScript("OnEnter", function(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(type(title) == "function" and title() or title)
local body = type(text) == "function" and text() or text
if body then GameTooltip:AddLine(body, 1, 1, 1, true) end
local green = hint and hint() -- (an instruction line, green as Blizzard's)
if green then GameTooltip:AddLine(green, GREEN_FONT_COLOR:GetRGB()) end
GameTooltip:Show()
end)
frame:HookScript("OnLeave", function() GameTooltip:Hide() end)
end
-- An Options-style row: a gold label at the left, its control COLUMN to the right
-- (room for the labels). Its tooltip shows over the
-- label too, as on Blizzard's rows.
local COLUMN = 150
local RIGHT_COLUMN = 235 -- the settings page's second column
local LIST = 180 -- the list's width
local PREVIEW_WIDTH = 288 -- the preview's
local function Row(panel, y, text, control, tip)
local label = Label(panel, text)
label:SetPoint("LEFT", panel, "TOPLEFT", 0, y)
control:SetPoint("LEFT", panel, "TOPLEFT", COLUMN, y)
local hover
if tip then
Tooltip(control, text, tip)
hover = New("Frame", panel)
hover:SetPoint("LEFT", panel, "TOPLEFT", 0, y)
hover:SetSize(COLUMN - 4, 26)
hover:EnableMouse(true)
Tooltip(hover, text, tip)
end
return label, hover
end
local function Checkbox(panel, y, text, what, tip)
local box = New("CheckButton", panel, "MinimalCheckboxTemplate")
box:SetScript("OnClick", function(self)
PlaySound(self:GetChecked() and SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON or SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
Set(what, self:GetChecked())
end)
box.label, box.hover = Row(panel, y, text, box, tip)
return box
end
-- The look a style comes with (its tile gives it back).
local function StyleStart(kind, what)
local style = ns.SPARKLE_STYLES[ns.SparkleLook(kind, "style")] or ns.SPARKLE_STYLES[1]
if what == "height" and START_HEIGHT[kind] then return START_HEIGHT[kind] end
return style.start[what]
end
-- withDefault: the tooltip also says what the shown style comes with.
local function Slider(panel, y, text, what, low, high, tip, withDefault)
local slider = New("Frame", panel, "MinimalSliderWithSteppersTemplate")
slider:SetWidth(230)
local formatters = { [MinimalSliderWithSteppersMixin.Label.Right] = CreateMinimalSliderFormatter(MinimalSliderWithSteppersMixin.Label.Right) }
slider:Init(low, low, high, high - low, formatters)
slider:RegisterCallback(MinimalSliderWithSteppersMixin.Event.OnValueChanged, function(_, value)
if not window.refreshing then Set(what, floor(value + 0.5)) end
end, slider)
local words = tip
if withDefault then
words = function() return ("%s\n\n%s: %d"):format(tip, DEFAULT, StyleStart(Shown(), what)) end
end
Row(panel, y, text, slider, words)
-- The bar and its arrows take the mouse themselves.
for _, part in ipairs({ slider.Slider, slider.Back, slider.Forward }) do Tooltip(part, text, words) end
return slider
end
-- A tile like the Toy Box's (five across; Refresh places it) with a name at its bottom.
local function BareTile(grid, name)
local tile = New("Button", grid)
tile:SetSize(81, 76)
local background = tile:CreateTexture(nil, "BACKGROUND")
background:SetAtlas("collections-background-tile")
background:SetAllPoints()
tile.border = tile:CreateTexture(nil, "BORDER")
tile.border:SetAllPoints()
local highlight = tile:CreateTexture(nil, "HIGHLIGHT")
highlight:SetAtlas("PetList-ButtonHighlight")
highlight:SetAllPoints()
tile.name = Label(tile, name, "GameFontNormalSmall")
tile.name:SetPoint("BOTTOM", 0, 8)
return tile
end
-- A tile with a small preview of sparkles (a light beam stays inside).
local function PreviewTile(grid, name)
local tile = BareTile(grid, name)
tile:SetClipsChildren(true)
tile.anchor = New("Frame", tile) -- the sparkles sit on its bottom, like on a nameplate's
tile.anchor:SetSize(1, 1)
tile.anchor:SetPoint("BOTTOM", tile, "CENTER", 0, 10)
return tile
end
-- What Shift-click does with a kind's tile (style i or made sparkle id): nothing on the first one.
local function SecondHint(i, id)
local keys = ns.SPARKLE_KEYS[Shown()]
local made = ns.FindMade(ns.db[keys.made])
if id and made and made.id == id or i and not made and ns.db[keys.style] == i then return nil end
if i and ns.db[keys.style2] == i or id and ns.db[keys.made2] == id then return "<Shift Click to remove it>" end
return "<Shift Click to add it as a second sparkle>"
end
-- A style's tile: its name and a small preview of it; a click picks it.
local function Tile(grid, i, style)
local tile = PreviewTile(grid, style.name)
tile:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
if IsShiftKeyDown() then PickSecond(i) else PickStyle(i) end
end)
Tooltip(tile, style.name, style.tip, function() return SecondHint(i) end)
return tile
end
-- A Sparkle Maker sparkle's tile (Refresh gives it its sparkle: tile.id, tile.title).
local function MadeTile(grid)
local tile = PreviewTile(grid, "")
tile.name:SetWidth(76)
tile.name:SetWordWrap(false)
tile:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
if IsShiftKeyDown() then PickSecond(nil, tile.id) else PickMade(tile.id) end
end)
Tooltip(tile, function() return tile.title end, "Made in the Sparkle Maker.", function() return SecondHint(nil, tile.id) end)
return tile
end
-- The first tile: no sparkles on the kind.
local function NoneTile(grid)
local tile = BareTile(grid, NONE)
tile:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
Set("on", false)
end)
Tooltip(tile, NONE, function()
return "Turns off " .. window.tab.on:lower() .. ". Pick a style to turn them back on."
end)
return tile
end
-- A row in the list: a page of the addon's, a kind (its on/off box and icon) or the settings.
-- A line in one color fading out to the right (header lines, the picked row's edges).
local function Fade(texture, r, g, b, a)
texture:SetColorTexture(1, 1, 1, 1)
texture:SetGradient("HORIZONTAL", CreateColor(r, g, b, a), CreateColor(r, g, b, 0))
end
local function ListEntry(list, y, entry)
local item = New("Button", list)
item:SetSize(LIST - 12, 22)
item:SetPoint("TOPLEFT", 4, y)
-- The picked row: the logo's brown a shade lighter, bronze lines fading out above and
-- below it, a gold bar at its left.
item.selected = item:CreateTexture(nil, "BACKGROUND")
item.selected:SetColorTexture(46 / 255, 38 / 255, 27 / 255)
item.selected:SetAllPoints()
item.picked = { item.selected }
for _, edge in ipairs({ "TOP", "BOTTOM" }) do
local line = item:CreateTexture(nil, "BORDER")
line:SetPoint(edge .. "LEFT")
line:SetPoint(edge .. "RIGHT")
line:SetHeight(1)
Fade(line, 0.47, 0.39, 0.24, 1)
item.picked[#item.picked + 1] = line
end
local bar = item:CreateTexture(nil, "BORDER")
bar:SetPoint("TOPLEFT")
bar:SetPoint("BOTTOMLEFT")
bar:SetWidth(3)
bar:SetColorTexture(1, 0.82, 0)
item.picked[#item.picked + 1] = bar
item:SetHighlightAtlas("Options_List_Hover")
local x = 10
if entry.on then
local box = New("CheckButton", item, "MinimalCheckboxTemplate")
box:SetSize(20, 20)
box:SetPoint("LEFT", 4, 0)
box:SetScript("OnClick", function(self)
PlaySound(self:GetChecked() and SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON or SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
SetKind(entry.key, self:GetChecked() == true)
end)
Tooltip(box, entry.on, entry.tip .. NEEDS)
item.box = box
item.icon = item:CreateTexture(nil, "ARTWORK")
item.icon:SetTexture(entry.icon)
item.icon:SetSize(16, 16)
item.icon:SetPoint("LEFT", 28, 0)
x = 48
end
item.text = Label(item, entry.list or entry.name)
item.text:SetPoint("LEFT", x, 0)
item:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB)
window.tab = entry
Refresh()
end)
return item
end
-- A setting shown from a warning: Blizzard's proc glow round its box for a few seconds.
local FLASH_SECONDS = 3
local function Flash(box)
local flash = window.flash
if not (flash and box) then return end
flash:ClearAllPoints()
flash:SetPoint("CENTER", box)
flash:SetSize(box:GetWidth() * 1.4, box:GetHeight() * 1.4)
flash:Show()
flash.ProcLoop:Play()
flash.token = (flash.token or 0) + 1
local token = flash.token
C_Timer.After(FLASH_SECONDS, function() if flash.token == token then flash:Hide() end end)
end
-- The style grid is as tall as the biggest tab's tiles need: None, its styles and the made sparkles, five a row.
local function GridHeight()
return floor((window.mostTiles + #ns.MadeList() + 4) / 5) * 80 - 4
end
local function Build()
local most = 0
for _, tab in ipairs(TABS) do
local n = 0
for i in ipairs(ns.SPARKLE_STYLES) do
if ns.StyleFits(i, tab.key) then n = n + 1 end
end
most = max(most, n + 1)
end
window = New("Frame", UIParent, "ButtonFrameTemplate")
window.mostTiles = most
local gridHeight = GridHeight()
window.gridHeight = gridHeight
window:Hide()
window:SetSize(760 + LIST, 402 + gridHeight)
window:SetPoint("CENTER", 0, 20)
window:SetFrameStrata("DIALOG")
window:SetToplevel(true)
window:EnableMouse(true)
-- Dragged by any empty part of it and kept on screen (back in the middle after a reload).
window:SetMovable(true)
window:SetClampedToScreen(true)
window:RegisterForDrag("LeftButton")
window:SetScript("OnDragStart", window.StartMoving)
window:SetScript("OnDragStop", window.StopMovingOrSizing)
window:SetTitle(C_AddOns.GetAddOnMetadata(ADDON_NAME, "Title") or ADDON_NAME)
local logo = "Interface\\AddOns\\" .. ADDON_NAME .. "\\logo"
window:SetPortraitToAsset(logo)
-- The logo in the frame's own bronze ring, filling its hole, in place of the
-- portrait (whose round mask sits off the ring's middle). Under the ring, as the
-- portrait is.
local corner = window.NineSlice and window.NineSlice.TopLeftCorner
if corner then
local size = corner:GetWidth()
if not (size and size > 0) then size = 95 end
window.PortraitContainer.portrait:Hide()
local art = window.PortraitContainer:CreateTexture(nil, "OVERLAY")
art:SetSize(size * 0.51, size * 0.51) -- (a little past the hole, under the ring)
art:SetPoint("CENTER", corner, "TOPLEFT", size * 0.401, -size * 0.401) -- (the ring's middle in the art)
art:SetTexture(logo)
local mask = window.PortraitContainer:CreateMaskTexture()
mask:SetAllPoints(art)
mask:SetTexture("Interface\\CharacterFrame\\TempPortraitAlphaMask", "CLAMPTOBLACKADDITIVE", "CLAMPTOBLACKADDITIVE")
art:AddMaskTexture(mask)
window.logo = art
end
window.interactOff = Label(window, ns.INTERACT_OFF, "GameFontRed")
window.interactOff:SetPoint("TOP", 0, -36)
-- Turns it back on with the rest of what sparkles need (after the fight, in combat).
local turnOn = New("Button", window, "UIPanelButtonTemplate")
turnOn:SetSize(80, 22)
turnOn:SetText(ENABLE)
turnOn:SetPoint("LEFT", window.interactOff, "RIGHT", 8, 0)
turnOn:SetScript("OnClick", function()
ns.Setup()
Refresh()
end)
Tooltip(turnOn, ENABLE_INTERACT_TEXT, "Turns the game's Enable Interact Key back on, so sparkles show again.")
window.turnOn = turnOn
-- Otherwise the first reason sparkles may not show, with all of them in its tooltip.
local problem = New("Frame", window)
problem:SetPoint("TOP", 0, -36)
problem:EnableMouse(true)
problem.text = Label(problem, "", "GameFontRed")
problem.text:SetPoint("CENTER")
Tooltip(problem, "Why sparkles may not show", function()
local lines = {}
for i, reason in ipairs(problem.list or {}) do lines[i] = reason[1] end
return table.concat(lines, "\n")
end)
-- A reason with a setting: clicked, Sparkle settings with that box flashing.
problem:SetScript("OnMouseUp", function()
local key = problem.list and problem.list[1] and problem.list[1][3]
if not key then return end
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB)
for _, entry in ipairs(TABS) do
if entry.key == "general" then window.tab = entry end
end
Refresh()
Flash(window[key])
end)
window.problem = problem
ButtonFrameTemplate_HideButtonBar(window)
window.CloseButton:SetScript("OnClick", function() window:Hide() end)
-- (The previews hide with it, and their frames only run while shown.)
window:SetScript("OnShow", function() PlaySound(SOUNDKIT.IG_CHARACTER_INFO_OPEN) end)
window:SetScript("OnHide", function() PlaySound(SOUNDKIT.IG_CHARACTER_INFO_CLOSE) end)
window.tab, window.node = TABS[1], {}
-- The list and pages in the logo's own dark brown (#1B1712), and the strip under the
-- title too (over the frame's gray streaks).
window.backdrop = window.Inset:CreateTexture(nil, "BACKGROUND", nil, 7)
window.backdrop:SetAllPoints()
window.strip = window:CreateTexture(nil, "BORDER", nil, 1)
window.strip:SetPoint("TOPLEFT", 2, -21)
window.strip:SetPoint("BOTTOMRIGHT", window, "TOPRIGHT", -2, -60)
window.strip:SetColorTexture(27 / 255, 23 / 255, 18 / 255)
-- What's New (an addon that has its notes) in the strip's right end: gold words with a
-- notes icon, white under the mouse, like a link. The version in the bottom right corner.
if ns.ShowWhatsNew then
local news = New("Button", window)
news:SetPoint("RIGHT", window, "TOPRIGHT", -16, -40)
local icon = news:CreateTexture(nil, "ARTWORK")
icon:SetTexture("Interface\\Icons\\INV_Misc_Note_01")
icon:SetSize(18, 18)
icon:SetPoint("LEFT")
news.label = Label(news, GAMEMENU_NEW_BUTTON, "GameFontNormal")
news.label:SetPoint("LEFT", icon, "RIGHT", 5, 0)
news:SetSize(18 + 5 + news.label:GetStringWidth(), 22)
news:SetScript("OnEnter", function() news.label:SetFontObject("GameFontHighlight") end)
news:SetScript("OnLeave", function() news.label:SetFontObject("GameFontNormal") end)
news:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
ns.ShowWhatsNew()
end)
window.news = news
end
window.version = Label(window, ("%s %s"):format(GAME_VERSION_LABEL, C_AddOns.GetAddOnMetadata(ADDON_NAME, "Version") or ""), "GameFontDisableSmall")
window.version:SetPoint("BOTTOMRIGHT", -16, 12)
-- The list on the left: the addon's own pages, then the sparkles.
local list = New("Frame", window.Inset)
list:SetPoint("TOPLEFT", 2, -2) -- (inside the inset's border, no gap to it)
list:SetPoint("BOTTOMLEFT", 2, 2)
list:SetWidth(LIST - 2)
-- On a panel of its own: a shade lighter (added, so the stone shows through), a thin line beside it.
local panel = list:CreateTexture(nil, "BACKGROUND", nil, -1)
panel:SetAllPoints()
panel:SetColorTexture(7 / 255, 5 / 255, 4 / 255)
panel:SetBlendMode("ADD")
local divider = list:CreateTexture(nil, "BORDER")
divider:SetPoint("TOPRIGHT")
divider:SetPoint("BOTTOMRIGHT")
divider:SetWidth(1)
divider:SetColorTexture(70 / 255, 58 / 255, 40 / 255)
window.listPanel, window.listDivider = panel, divider
window.list, window.pages, window.Tabs = {}, {}, {}
-- A heading in the list (Sparkles, and a page group's), with a gold line under it.
local function Heading(text, at)
local header = Label(list, text, "GameFontNormalLarge")
header:SetPoint("TOPLEFT", 10, at - 8)
local line = list:CreateTexture(nil, "ARTWORK")
Fade(line, 1, 0.82, 0, 0.67) -- (the logo's gold)
line:SetHeight(1)
line:SetPoint("TOPLEFT", header, "BOTTOMLEFT", 0, -3)
line:SetPoint("RIGHT", list, "RIGHT", -8, 0)
return header
end
local y = -6
for i, entry in ipairs(ns.WINDOW_PAGES or {}) do
entry.index = nil
if entry.header then
entry.heading = Heading(entry.header, y)
y = y - 36
end
window.list[i] = ListEntry(list, y, entry)
y = y - 24
end
if ns.WINDOW_PAGES then
Heading("Sparkles", y)
y = y - 36
end
for i, tab in ipairs(TABS) do
tab.index = i
window.Tabs[i] = ListEntry(list, y, tab)
y = y - 24
end
-- The preview: the node turning slowly on Blizzard's mount journal background. It fills its
-- column, from the list's line to the inset's border at the top and bottom.
local preview = New("Frame", window.Inset)
preview:SetPoint("TOPLEFT", LIST, -2)
preview:SetPoint("BOTTOMLEFT", LIST, 2)
preview:SetWidth(PREVIEW_WIDTH)
preview:SetClipsChildren(true)
-- Its edge, over everything in it (the preview clips what it holds): a thin line in the
-- headers' gold with a dark one round it.
local edge = New("Frame", window.Inset)
edge:SetAllPoints(preview)
edge:SetFrameLevel(preview:GetFrameLevel() + 50)
window.edge = edge
edge.gold = {}
-- A strip along one side: across the top or bottom, or down the left or right.
local function Side(side, layer, sublevel, out, width)
local piece = edge:CreateTexture(nil, layer, nil, sublevel)
if side == "TOP" or side == "BOTTOM" then
local y = side == "TOP" and out or -out
piece:SetPoint(side .. "LEFT", -out, y)
piece:SetPoint(side .. "RIGHT", out, y)
piece:SetHeight(width)
else
local x = side == "LEFT" and -out or out
piece:SetPoint("TOP" .. side, x, out)
piece:SetPoint("BOTTOM" .. side, x, -out)
piece:SetWidth(width)
end
return piece
end
for _, side in ipairs({ "TOP", "BOTTOM", "LEFT", "RIGHT" }) do
local dark = Side(side, "OVERLAY", 0, 2, 3) -- (from 2 outside to 1 in)
dark:SetColorTexture(0.04, 0.03, 0.02, 1)
local gold = Side(side, "OVERLAY", 1, 0, 1)
gold:SetColorTexture(0.47, 0.39, 0.24, 1)
edge.gold[#edge.gold + 1] = dark
edge.gold[#edge.gold + 1] = gold
end
-- Its backdrop: Blizzard's mount journal art grayed and tinted the logo's brown and gold.
local background = preview:CreateTexture(nil, "BACKGROUND")
background:SetTexture("Interface\\PetBattles\\MountJournal-BG")
background:SetTexCoord(2 / 512, 0.78515625, 2 / 512, 510 / 512) -- the picture's left corners are white
background:SetAllPoints()
background:SetDesaturated(true)
background:SetVertexColor(0.59, 0.47, 0.24)
window.previewBackdrop = background
local scene = New("ModelScene", preview)
scene:SetAllPoints()
scene:SetCameraFieldOfView(FOV)
scene:SetCameraOrientationByYawPitchRoll(math.pi, PITCH, 0)
scene:SetLightVisible(true)
scene:SetLightType(Enum.ModelLightType.Directional)
scene:SetLightDirection(scene:GetCameraForward())
scene:SetLightAmbientColor(0.7, 0.7, 0.7)
scene:SetLightDiffuseColor(0.8, 0.8, 0.8)
local actor = scene:CreateActor()
actor:SetUseCenterForOrigin(true, true, true) -- turns on the spot, its middle in the middle
-- Drag it round to turn it; the mouse wheel zooms. Both stay as you left them.
scene.yaw, scene.zoom = 0, ZOOM_START
scene:EnableMouse(true)
scene:EnableMouseWheel(true)
scene:SetScript("OnMouseDown", function(self, button)
if button == "LeftButton" then self.dragging = GetCursorPosition() end
end)
scene:SetScript("OnMouseUp", function(self) self.dragging = nil end)
scene:SetScript("OnHide", function(self) self.dragging = nil end)
scene:SetScript("OnMouseWheel", function(self, delta)
self.zoom = math.min(ZOOM_OUT, max(ZOOM_IN, self.zoom - delta * 0.1))
if self.framed then PlaceCamera(self) end
end)
scene:SetScript("OnUpdate", function(self)
if self.dragging then
local x = GetCursorPosition()
self.yaw = self.yaw + (x - self.dragging) * 0.01
self.dragging = x
actor:SetYaw(self.yaw)
end
if not self.framed and actor:IsLoaded() then self.framed = FrameNode(self, actor) end
end)
window.scene, window.actor = scene, actor
-- The sparkles grow and shrink with the zoom, around the node's middle (PlaceCamera).
scene.zoomer = New("Frame", scene)
scene.zoomer:SetSize(1, 1)
scene.zoomer:SetPoint("CENTER", preview, "CENTER")
window.anchor = New("Frame", scene.zoomer) -- where the node's plate would be
window.anchor:SetSize(1, 1)
window.anchor:SetPoint("BOTTOM", scene.zoomer, "CENTER", 0, 60)
local picker = New("Frame", preview, "SettingsDropdownWithButtonsTemplate")
picker:SetWidth(260)
picker.Dropdown:SetWidth(210)
picker:SetPoint("TOP", 0, -6)
picker:SetFrameLevel(scene:GetFrameLevel() + 10) -- over the model, which takes the mouse
window.picker = picker
-- Under the node while these sparkles are off.
local off = New("Frame", preview)
off:SetAllPoints()
off:SetFrameLevel(scene:GetFrameLevel() + 10)
window.offText = Label(off, "Sparkles are off", "GameFontNormalLarge")
window.offText:SetPoint("BOTTOM", 0, 60)
window.offHint = Label(off, "Pick a style to turn them on.", "GameFontHighlight")
window.offHint:SetPoint("TOP", window.offText, "BOTTOM", 0, -6)
window.off = off
-- The game's icon over the node, while Keep the game's icons is on (its box in the corner).
local over = New("Frame", scene.zoomer) -- (its own frame: the sparkles are the anchor's)
over:SetSize(32, 32)
over:SetPoint("CENTER", window.anchor)
window.gameIcon = over:CreateTexture(nil, "OVERLAY")
window.gameIcon:SetAllPoints()
-- In its place on a herb, the Cultivation icon while its switch is on (it covers the game's icon in the world).
if ns.CultivationPreviewIcon then window.cultivationIcon = ns.CultivationPreviewIcon(over, window.gameIcon) end
local icons = New("Frame", preview)
icons:SetAllPoints()
icons:SetFrameLevel(scene:GetFrameLevel() + 10)
local box = New("CheckButton", icons, "MinimalCheckboxTemplate")
box:SetPoint("BOTTOMLEFT", 8, 6)
box:SetScript("OnClick", function(self)
PlaySound(self:GetChecked() and SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON or SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
Set("gameIcons", self:GetChecked())
end)
box.label = Label(icons, "Keep the game's icons", "GameFontNormal")
box.label:SetPoint("LEFT", box, "RIGHT", 4, 0)
Tooltip(box, "Keep the game's icons", "Keeps the game's own icon over things you can interact with.")
window.gameIcons, window.iconsRow = box, icons
-- The styles.
-- A kind's page: its name and a gray line on it on top (like the addon's own pages), then the styles.
window.kindTitle = Label(window.Inset, "", "GameFontHighlightLarge")
window.kindTitle:SetPoint("TOPLEFT", preview, "TOPRIGHT", 12, -12)
window.kindAbout = Label(window.Inset, "", "GameFontDisableSmall")
window.kindAbout:SetPoint("TOPLEFT", preview, "TOPRIGHT", 12, -36)
local grid = New("Frame", window.Inset)
grid:SetPoint("TOPLEFT", preview, "TOPRIGHT", 10, -58)
grid:SetSize(428, gridHeight)
window.grid, window.tiles, window.madeTiles = grid, {}, {}
window.none = NoneTile(grid)
for i, style in ipairs(ns.SPARKLE_STYLES) do window.tiles[i] = Tile(grid, i, style) end
-- The rest of the look.
local panel = New("Frame", window.Inset)
panel:SetPoint("TOPLEFT", grid, "BOTTOMLEFT", 0, -26)
panel:SetPoint("BOTTOMRIGHT", -8, 8)
local defaults = New("Button", panel, "UIPanelButtonTemplate")
defaults:SetSize(110, 22)
defaults:SetText(DEFAULTS)
defaults:SetPoint("LEFT", panel, "TOPLEFT", 0, 0)
defaults:SetScript("OnClick", Defaults)
Tooltip(defaults, DEFAULTS, "Puts this kind's style, colors, area, height and count back to how they come. On or off stays as it is.")
window.defaults = defaults
-- While the kind uses a Sparkle Maker sparkle: its name and a button to it, in place of the style's look.
local note = New("Frame", panel)
note:SetAllPoints()
note.text = Label(note, "", "GameFontHighlight")
note.text:SetPoint("LEFT", note, "TOPLEFT", 0, -36)
note.edit = New("Button", note, "UIPanelButtonTemplate")
note.edit:SetSize(150, 22)
note.edit:SetText("Open Sparkle Maker")
note.edit:SetPoint("LEFT", note, "TOPLEFT", 0, -70)
note.edit:SetScript("OnClick", function()
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB)
window.madeId, window.makerLayer = note.id, 1
for _, entry in ipairs(TABS) do
if entry.key == "maker" then window.tab = entry end
end
Refresh()
end)
window.madeNote = note
local outer = panel
panel = New("Frame", outer) -- (the style's look)
panel:SetAllPoints()
window.lookRows = panel
local swatch = New("Button", panel, "ColorSwatchTemplate")
swatch:SetSize(22, 22)
swatch:SetScript("OnClick", function() PickColor("color") end)
Row(panel, -36, COLOR, swatch, "Tints the sparkles. White keeps their own colors.")
window.swatch = swatch
local swatch2 = New("Button", panel, "ColorSwatchTemplate")
swatch2:SetSize(22, 22)
swatch2:SetPoint("LEFT", swatch, "RIGHT", 8, 0)
swatch2:SetScript("OnClick", function() PickColor("color2") end)
Tooltip(swatch2, "Second color", "Sparkles switch between the two colors. Same as the first until you pick one.")
window.swatch2 = swatch2
local reset = New("Button", panel, "UIPanelButtonTemplate")
reset:SetSize(80, 22)
reset:SetText(RESET)
reset:SetPoint("LEFT", swatch2, "RIGHT", 12, 0)
reset:SetScript("OnClick", function()
for _, kind in ipairs(Kinds()) do
local keys = ns.SPARKLE_KEYS[kind]
local start = (ns.SPARKLE_STYLES[ns.db[keys.style]] or ns.SPARKLE_STYLES[1]).start
ns.db[keys.color], ns.db[keys.color2] = start.color, start.color2
Remember(kind)
end
Changed()
Refresh()
end)
Tooltip(reset, RESET, "Back to the style's own colors.")
window.reset = reset
local sets = New("DropdownButton", panel, "WowStyle1DropdownTemplate")
sets:SetWidth(180)
sets:SetDefaultText(CUSTOM)
Row(panel, -72, "Color set", sets, "Two colors that go well together.")
window.sets = sets
-- Blizzard's template builds the whole menu each time a dropdown shows, and SetupMenu
-- builds it at once if shown, only to show the chosen option's name: here menus are
-- built when they open, and Refresh writes the names.
sets:SetScript("OnShow", nil)
sets:Hide()
sets:SetupMenu(SetsMenu)
sets:Show()
window.size = Slider(panel, -108, "Area", "size", 30, 200, "How far around the node the sparkles go.", true)
window.height = Slider(panel, -146, "Height", "height", -150, 100, "Moves the sparkles up or down.", true)
window.count = Slider(panel, -184, "Count", "count", 1, 20,
"How many sparkles show at once. Some styles don't use it.", true)
-- The settings page: for all sparkles, under headers.
window.look, window.preview = { grid, outer, window.kindTitle, window.kindAbout }, preview
local general = New("Frame", window.Inset)
general:SetPoint("TOPLEFT", grid, "TOPLEFT", 0, 38) -- (as high as the kind's name)
general:SetPoint("BOTTOMRIGHT", -8, 8)
window.general = general
local function At(box, x) -- its words first, the box right after them (as in Blizzard's options)
x = x or 0
local y = select(5, box:GetPoint(1))
local width = 170 -- (a longer label wraps instead of reaching the next column)
box.label:ClearAllPoints()
box.label:SetPoint("LEFT", general, "TOPLEFT", x, y)
box.label:SetWidth(width)
box.label:SetJustifyH("LEFT")
box:ClearAllPoints()
box:SetPoint("LEFT", general, "TOPLEFT", x + width + 4, y)
box.hover:ClearAllPoints()
box.hover:SetPoint("LEFT", box.label, "LEFT")
box.hover:SetSize(width + 4, 26)
box.hover:SetScript("OnMouseDown", function() box:Click() end) -- its words click it too
return box
end
local function Header(y, text)
local header = Label(general, text, "GameFontNormalLarge")
header:SetPoint("LEFT", general, "TOPLEFT", 0, y)
local line = general:CreateTexture(nil, "ARTWORK")
Fade(line, 1, 0.82, 0, 0.67) -- (the logo's gold)
line:SetHeight(1)
line:SetPoint("TOPLEFT", header, "BOTTOMLEFT", 0, -3)
line:SetPoint("RIGHT", general, "RIGHT", -12, 0)
end
window.everything = At(Checkbox(general, 0, "Sparkles on everything", "everything",
"Turns them all on or off at once. Each kind's None tile turns that one off." .. NEEDS))
Header(-36, "Look")
window.brightness = Slider(general, -66, "Brightness", "brightness", 10, 100,
"How bright the sparkles are.")
window.reachLook = At(Checkbox(general, -98, "Dimmer out of reach", "reachLook",
"Dimmer when it's too far to gather. Flashes when you get in range."))
window.rareGlow = At(Checkbox(general, -98, "Rare nodes stand out", "rareGlow",
"A gold glow on rare herbs and ore like Black Lotus and Truesilver."), RIGHT_COLUMN)
window.grayTooHard = At(Checkbox(general, -130, "Gray when your skill is too low", "grayTooHard",
"Herbs and ore your skill is too low for sparkle gray."))