-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathPlater_ScriptingPanels.lua
4823 lines (3879 loc) · 201 KB
/
Plater_ScriptingPanels.lua
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
local addonName, platerInternal = ...
local Plater = Plater
local GameCooltip = GameCooltip2
---@type detailsframework
local DF = DetailsFramework
local _
local unpack = _G.unpack
local tremove = _G.tremove
local CreateFrame = _G.CreateFrame
local tinsert = _G.tinsert
local GetSpellInfo = GetSpellInfo or function(spellID) if not spellID then return nil end local si = C_Spell.GetSpellInfo(spellID) if si then return si.name, nil, si.iconID, si.castTime, si.minRange, si.maxRange, si.spellID, si.originalIconID end end
---@class searchdata : table
---@field [1] number data index within the profile.script_data table
---@field [2] scriptdata
---@field [3] scriptname
---@field [4] number -- 1 enabled or 0 if disabled
---@field [5] number -- 1 has or 0 if not
--sort scripts
function Plater.SortScripts (t1, t2)
--> index 4 stores if the script is enabled
if (t1[4] > t2[4]) then
return true
elseif (t1[4] < t2[4]) then
return false
--> index 5 stores if the script is a wago update import
elseif (t1[5] > t2[5]) then
return true
elseif (t1[5] < t2[5]) then
return false
else
--> index 3 stores the script name
return t1[3] < t2[3]
end
end
-- simple rounding to full numbers
local function round(x)
if not x then return nil end
return (x + 0.5 - (x + 0.5) % 1)
end
--tab indexes
local PLATER_OPTIONS_SCRIPTING_TAB = 6
local PLATER_OPTIONS_HOOKING_TAB = 7
local PLATER_OPTIONS_PROFILES_TAB = 22
local PLATER_OPTIONS_WAGO_TAB = 25
--options
local start_y = platerInternal.optionsYStart
local main_frames_size = {600, 400}
local edit_script_size = {620, 431}
local scrollbox_size = {200, 405}
local scrollbox_lines = 13
local hook_scrollbox_lines = 12
local scrollbox_line_height = 30
local triggerbox_size = {180, 228}
local triggerbox_lines = 9
local triggerbox_line_height = 24
local hookbox_size = {triggerbox_size[1], triggerbox_size[2] + 85}
local hookbox_label_y = -145
local scrollbox_line_backdrop_color = {0, 0, 0, 0.5}
local scrollbox_line_backdrop_not_inuse = {0, 0, 0, 0.4}
local scrollbox_line_backdrop_color_selected = {.6, .6, .1, 0.7}
local buttons_size = {120, 20}
local luaeditor_backdrop_color = {.2, .2, .2, .5}
local luaeditor_border_color = {0, 0, 0, 1}
--get templates
local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
options_dropdown_template = DF.table.copy({}, options_dropdown_template)
options_dropdown_template.backdropcolor = {.2, .2, .2, .8}
options_slider_template = DF.table.copy({}, options_slider_template)
options_slider_template.backdropcolor = {.2, .2, .2, .8}
options_button_template = DF.table.copy({}, options_button_template)
options_button_template.backdropcolor = {.2, .2, .2, .8}
Plater.APIList = {
{Name = "SetNameplateColor", Signature = "Plater.SetNameplateColor (unitFrame, color)", Desc = "Set the color of the nameplate.\n\nColor formats are:\n|cFFFFFF00Just Values|r: r, g, b\n|cFFFFFF00Index Table|r: {r, g, b}\n|cFFFFFF00Hash Table|r: {r = 1, g = 1, b = 1}\n|cFFFFFF00Hex|r: '#FFFF0000' or '#FF0000'\n|cFFFFFF00Name|r: 'yellow' 'white'\n\nCalling without passing a color will reset the color to default."},
{Name = "SetNameplateSize", Signature = "Plater.SetNameplateSize (unitFrame, width, height)", Desc = "Adjust the nameplate size.\n\nCalling without passing width and height reset the size to default."},
{Name = "SetBorderColor", Signature = "Plater.SetBorderColor (unitFrame, r, g, b, a)", Desc = "Set the border color.\n\nCalling without passing any color reset the color to default."},
{Name = "SetCastBarColor", Signature = "Plater.SetCastBarColor (unitFrame, r, g, b)", Desc = "Set the cast bar color.\n\nColor formats are:\n|cFFFFFF00Just Values|r: r, g, b\n|cFFFFFF00Index Table|r: {r, g, b}\n|cFFFFFF00Hash Table|r: {r = 1, g = 1, b = 1}\n|cFFFFFF00Hex|r: '#FFFF0000' or '#FF0000'\n|cFFFFFF00Name|r: 'yellow' 'white'\n\nCalling without passing width and height reset the color to default."},
{Name = "SetCastBarSize", Signature = "Plater.SetCastBarSize (unitFrame, width, height)", Desc = "Adjust the cast bar size.\n\nCalling without passing width and height reset the size to default."},
{Name = "SetCastBarBorderColor", Signature = "Plater.SetCastBarBorderColor (castBar, color)", Desc = "Set the color of the castbar.\n\nColor formats are:\n|cFFFFFF00Just Values|r: r, g, b, a\n|cFFFFFF00Index Table|r: {r, g, b}\n|cFFFFFF00Hash Table|r: {r = 1, g = 1, b = 1}\n|cFFFFFF00Hex|r: '#FFFF0000' or '#FF0000'\n|cFFFFFF00Name|r: 'yellow' 'white'\n\nCalling without passing any color reset the color to default."},
{Name = "FlashNameplateBorder", Signature = "Plater.FlashNameplateBorder (unitFrame [, duration])", Desc = "Do a quick flash in the nameplate border, duration is optional."},
{Name = "FlashNameplateBody", Signature = "Plater.FlashNameplateBody (unitFrame [, text [, duration]])", Desc = "Flash the healthbar portion of the nameplate, text and duration are optionals."},
{Name = "NameplateHasAura", Signature = "Plater.NameplateHasAura (unitFrame, aura)", Desc = "Return true if the aura is shown on nameplate.\n\nAura can be the buff name, debuff name or spellID."},
{Name = "UnitHasAura", Signature = "Plater.UnitHasAura (unitFrame, aura)", Desc = "Return true if the aura exist on the nameplate, visible or not.\n\nAura can be the buff name, debuff name or spellID."},
{Name = "UnitHasEnrage", Signature = "Plater.UnitHasEnrage (unitFrame)", Desc = "Return true if any of the auras is an enrage effect."},
{Name = "UnitHasDispellable", Signature = "Plater.UnitHasDispellable (unitFrame)", Desc = "Return true if there is any aura on the unit your character can remove at this moment (enrage, magic, etc)."},
{Name = "NameplateInRange", Signature = "Plater.NameplateInRange (unitFrame)", Desc = "Return true if the nameplate is in range of the selected spell for range check.\n\nIt also updates the range flag for unitFrame.namePlateInRange."},
{Name = "GetNpcIDFromGUID", Signature = "Plater.GetNpcIDFromGUID (GUID)", Desc = "Extract the npcID from a GUID, guarantee to always return a number."},
{Name = "GetRaidMark", Signature = "Plater.GetRaidMark (unitFrame)", Desc = "Return which raid mark the nameplate has. Always return false if the nameplate is the personal health bar."},
{Name = "GetConfig", Signature = "Plater.GetConfig (unitFrame)", Desc = "Return a table with the settings chosen for the nameplate in the options panel. Use it to restore values is needed."},
{Name = "GetPlayerRole", Signature = "Plater:GetPlayerRole()", Desc = "Return TANK DAMAGER HEALER or NONE."},
{Name = "GetUnitGuildName", Signature = "Plater.GetUnitGuildName (unitFrame)", Desc = "Return the name unit's guild name if any, always return nil for npcs."},
{Name = "GetNpcColor", Signature = "Plater.GetNpcColor (unitFrame)", Desc = "Return a table with the color selected in the Npc Colors tab.\n\nThe color set there must have the 'Only Scripts' checked."},
{Name = "SetExecuteRange", Signature = "function Plater.SetExecuteRange (isExecuteEnabled, healthAmountLower, healthAmountUpper)", Desc = "Set if Plater should check for execute range and in what percent of health the execute range starts\n\nhealthAmountLower is in a range of zero to value, whereas healthAmountUpper is in range of value to 1.\nExample:\n'healthAmountLower = 0.25' sets lower execute range to start at 25% health; 'healthAmountUpper = 0.8' will enable execute between full health and 80%.\n'nil' or '0'/'1' values for lower/upper will disable this range."},
{Name = "IsUnitInFriendsList", Signature = "Plater.IsUnitInFriendsList (unitFrame)", Desc = "Return 'true' if the unit is in the player's friends list."},
{Name = "IsUnitTank", Signature = "Plater.IsUnitTank (unitFrame)", Desc = "Return 'true' if the unit is in tank role."},
{Name = "IsUnitTapped", Signature = "Plater.IsUnitTapped (unitFrame)", Desc = "Return 'true' if the unit is tapped and the player does not receives credits to kill it. Usually units tapped are shown with a gray color."},
{Name = "IsInCombat", Signature = "Plater.IsInCombat()", Desc = "Return 'true' if the player is in combat."},
{Name = "IsInOpenWorld", Signature = "Plater.IsInOpenWorld()", Desc = "Return 'true' if the player is in open world (not inside raids, dungeons, etc)."},
{Name = "IsPlayerTank", Signature = "Plater.IsPlayerTank()", Desc = "Return 'true' if the player is in the tank role."},
{Name = "GetTanks", Signature = "Plater.GetTanks()", Desc = "Return a table with all tanks in the group, use Plater.GetTanks()[unitName] to know if the unit is a tank."},
{Name = "ShowIndicator", Signature = "Plater.ShowIndicator (unitFrame, texture, width, height, color, L, R, T, B)", Desc = "Adds an indicator within the default indicators row.\n\nL, R, T, B: texcoordinates (optional)."},
{Name = "DisableHighlight", Signature = "Plater.DisableHighlight (unitFrame)", Desc = "The nameplate won't highlight when the mouse passes over it."},
{Name = "EnableHighlight", Signature = "Plater.EnableHighlight (unitFrame)", Desc = "Enable the mouse over highlight."},
{Name = "CheckAuras", Signature = "Plater.CheckAuras (self, buffList, debuffList, noSpecialAuras)", Desc = "Perform a custom aura check overriding the default from Plater.\n\nbuffList and debuffList receive tables with the aura name as key and true as value, example: \n{\n ['Arcane Intellect'] = true,\n}\n"},
{Name = "RefreshNameplateColor", Signature = "Plater.RefreshNameplateColor (unitFrame)", Desc = "Check which color the nameplate should have and set it."},
{Name = "RefreshNameplateStrata", Signature = "Plater.RefreshNameplateStrata (unitFrame)", Desc = "Reset the frame strata and frame levels to default."},
{Name = "UpdateNameplateThread", Signature = "Plater.UpdateNameplateThread (unitFrame)", Desc = "Perform an Aggro update on the nameplate changing color to the current thread situation."},
{Name = "SafeSetCVar", Signature = "Plater.SafeSetCVar (variableName, value)", Desc = "Change the value of a CVar, if called during combat, it'll be applied when the player leaves combat.\n\nOriginal value is stored until Plater.RestoreCVar (variableName) is called."},
{Name = "RestoreCVar", Signature = "Plater.RestoreCVar (variableName)", Desc = "Restore the value a CVar had before Plater.SafeSetCVar() was called."},
{Name = "SetAnchor", Signature = "Plater.SetAnchor (frame, config, attachTo, centered)", Desc = "Anchor the 'frame' to the 'attachTo' frame according to the given 'config' ('config = {x = 0, y = 0, side = 1}', where 'side' is one of the following:\nTOP_LEFT = 1, LEFT = 2, BOTTOM_LEFT = 3, BOTTOM = 4, BOTTOM_RIGHT = 5, RIGHT = 6, TOP_RIGHT = 7, TOP = 8, CENTER = 9, INNER_LEFT = 10, INNER_RIGHT = 11, INNER_TOP = 12, INNER_BOTTOM = 13)"},
{Name = "StartGlow", Signature = "Plater.StartGlow(frame, color, options, key)", Desc = "Starts a glow on the given frame with the given parameters.\n\n--type 'pixel'\noptions = {\n glowType = 'pixel',\n color = 'white', -- all plater color types accepted, from lib: {r,g,b,a}, color of lines and opacity, from 0 to 1. Defaul value is {0.95, 0.95, 0.32, 1}\n N = 8, -- number of lines. Defaul value is 8;\n frequency = 0.25, -- frequency, set to negative to inverse direction of rotation. Default value is 0.25;\n length = 4, -- length of lines. Default value depends on region size and number of lines;\n th = 2, -- thickness of lines. Default value is 2;\n xOffset = 0,\n yOffset = 0, -- offset of glow relative to region border;\n border = false, -- set to true to create border under lines;\n key = '', -- key of glow, allows for multiple glows on one frame;\n}\n\n-- type 'ants'\noptions = {\n glowType = 'ants',\n color = 'white', -- all plater color types accepted, from lib: {r,g,b,a}, color of lines and opacity, from 0 to 1. Defaul value is {0.95, 0.95, 0.32, 1}\n N = 4, -- number of particle groups. Each group contains 4 particles. Defaul value is 4;\n \n frequency = 0.125, -- frequency, set to negative to inverse direction of rotation. Default value is 0.125;\n scale = 1, -- scale of particles\n xOffset = 0,\n yOffset = 0, -- offset of glow relative to region border;\n \n key = '', -- key of glow, allows for multiple glows on one frame;\n}\n\n-- type 'button'\noptions = {\n glowType = 'button',\n color = 'white', -- all plater color types accepted, from lib: {r,g,b,a}, color of lines and opacity, from 0 to 1. Defaul value is {0.95, 0.95, 0.32, 1}\n frequency = 0.125, -- frequency, set to negative to inverse direction of rotation. Default value is 0.125;\n}"},
{Name = "StopGlow", Signature = "Plater.StopGlow(frame, glowType, key)", Desc = "Stops a glow with the specified glowType and/or key on the given frame. All are stopped, if omitted."},
{Name = "StartPixelGlow", Signature = "Plater.StartPixelGlow(frame, color, options, key)", Desc = "--type 'pixel'\noptions = {\n glowType = 'pixel',\n color = 'white', -- all plater color types accepted, from lib: {r,g,b,a}, color of lines and opacity, from 0 to 1. Defaul value is {0.95, 0.95, 0.32, 1}\n N = 8, -- number of lines. Defaul value is 8;\n frequency = 0.25, -- frequency, set to negative to inverse direction of rotation. Default value is 0.25;\n length = 4, -- length of lines. Default value depends on region size and number of lines;\n th = 2, -- thickness of lines. Default value is 2;\n xOffset = 0,\n yOffset = 0, -- offset of glow relative to region border;\n border = false, -- set to true to create border under lines;\n key = '', -- key of glow, allows for multiple glows on one frame;\n}"},
{Name = "StartAntsGlow", Signature = "Plater.StartAntsGlow(frame, color, options, key)", Desc = "-- type 'ants'\noptions = {\n glowType = 'ants',\n color = 'white', -- all plater color types accepted, from lib: {r,g,b,a}, color of lines and opacity, from 0 to 1. Defaul value is {0.95, 0.95, 0.32, 1}\n N = 4, -- number of particle groups. Each group contains 4 particles. Defaul value is 4;\n \n frequency = 0.125, -- frequency, set to negative to inverse direction of rotation. Default value is 0.125;\n scale = 1, -- scale of particles\n xOffset = 0,\n yOffset = 0, -- offset of glow relative to region border;\n \n key = '', -- key of glow, allows for multiple glows on one frame;\n}"},
{Name = "StartButtonGlow", Signature = "Plater.StartButtonGlow(frame, color, options, key)", Desc = "-- type 'button'\noptions = {\n glowType = 'button',\n color = 'white', -- all plater color types accepted, from lib: {r,g,b,a}, color of lines and opacity, from 0 to 1. Defaul value is {0.95, 0.95, 0.32, 1}\n frequency = 0.125, -- frequency, set to negative to inverse direction of rotation. Default value is 0.125;\n}"},
{Name = "StopButtonGlow", Signature = "Plater.StopButtonGlow(frame, key)", Desc = "Stops a button-glow with the specified glowType and/or key on the given frame. All are stopped, if omitted."},
{Name = "StopPixelGlow", Signature = "Plater.StopPixelGlow(frame, key)", Desc = "Stops a pixel-glow with the specified glowType and/or key on the given frame. All are stopped, if omitted."},
{Name = "StopAntsGlow", Signature = "Plater.StopAntsGlow(frame, key)", Desc = "Stops an ants-glow with the specified glowType and/or key on the given frame. All are stopped, if omitted."},
}
Plater.FrameworkList = {
{Name = "CreateFlash", Signature = "Plater.CreateFlash (parent, duration, amountOfFlashes, color)", Desc = "Creates a custom flash which can be triggered by the ReturnValue:Play()\n\nUse:\n|cFFFFFF00ReturnedValue:Play()|r on OnShow.\n|cFFFFFF00ReturnedValue:Stop()|r on OnHide.", AddVar = true, AddCall = "--@ENV@:Play() --@ENV@:Stop()"},
--{Name = "CreateFrameShake", Signature = "Plater:CreateFrameShake (parent, duration, amplitude, frequency, bAbsoluteSineX, bAbsoluteSineY, scaleX, scaleY, fadeInTime, fadeOutTime)", Desc = "Creates a shake for the frame.\n\nStore the returned table inside the envTable and call parent:PlayFrameShake (returned table) to play the shake.", AddVar = true, AddCall = "--parent:PlayFrameShake(@ENV@)"}, -- --parent:StopFrameShake(@ENV@)
{Name = "CreateLabel", Signature = "Plater:CreateLabel (parent, text, size, color, font, member, name, layer)", Desc = "Creates a simple text to show in the nameplate, all parameters after 'parent' are optional.\n\nUse:\n|cFFFFFF00ReturnedValue:Show()|r on OnShow.\n|cFFFFFF00ReturnedValue:Hide()|r on OnHide.\n\nMembers:\n.text = 'new text'\n.textcolor = 'red'\n.textsize = 12\n.textfont = 'fontName'", AddVar = true, AddCall = "@ENV@:SetPoint ('center', 0, 0)"},
{Name = "CreateImage", Signature = "Plater:CreateImage (parent, texture, w, h, layer, coords, member, name)", Desc = "Creates a image to show in the nameplate, all parameters after 'parent' are optional.\n\nUse:\n|cFFFFFF00ReturnedValue:Show()|r on OnShow.\n|cFFFFFF00ReturnedValue:Hide()|r on OnHide.\n\nMembers:\n.texture = 'texture path'\n.alpha = 0.5\n.width = 300\n.height = 200", AddVar = true, AddCall = "@ENV@:SetPoint ('center', 0, 0)"},
{Name = "CreateBar", Signature = "Plater:CreateBar (parent, texture, w, h, value, member, name)", Desc = "Creates progress bar, all parameters after 'parent' are optional.\n\nUse:\n|cFFFFFF00ReturnedValue:Show()|r on OnShow.\n|cFFFFFF00ReturnedValue:Hide()|r on OnHide.\n\nMembers:\n.value = 50\n.texture = 'texture path'\n.icon = 'texture path'\n.lefttext = 'new text'\n.righttext = 'new text'\n.color = color\n.width = 300\n.height = 200", AddVar = true, AddCall = "@ENV@:SetPoint ('center', 0, 0)"},
{Name = "SetFontSize", Signature = "Plater:SetFontSize (fontString, fontSize, ...)", Desc = "Set the size of a text, accept more than one size, automatically picks the bigger one."},
{Name = "SetFontFace", Signature = "Plater:SetFontFace (fontString, fontFace)", Desc = "Set the font of a text."},
{Name = "SetFontColor", Signature = "Plater:SetFontColor (fontString, r, g, b, a)", Desc = "Set the color of a text.\n\nColor formats are:\n|cFFFFFF00Just Values|r: r, g, b, a\n|cFFFFFF00Index Table|r: {r, g, b}\n|cFFFFFF00Hash Table|r: {r = 1, g = 1, b = 1}\n|cFFFFFF00Hex|r: '#FFFF0000' or '#FF0000'\n|cFFFFFF00Name|r: 'yellow' 'white'"},
{Name = "CreateAnimationHub", Signature = "Plater:CreateAnimationHub (parent, onPlayFunc, onStopFunc)", Desc = "Creates an object to hold animations, see 'CreateAnimation' to add animations to the hub. When ReturnedValue:Play() is called all animations in the hub start playing respecting the Order set in the CreateAnimation().\n\nUse onShowFunc and onHideFunc to show or hide custom frames, textures or text.\n\nMethods:\n|cFFFFFF00ReturnedValue:Play()|r plays all animations in the hub.\n|cFFFFFF00ReturnedValue:Stop()|r: stop all animations in the hub.", AddVar = true, AddCall = "--@ENV@:Play() --@ENV@:Stop()"},
{Name = "CreateAnimation", Signature = "Plater:CreateAnimation (animationHub, animationType, order, duration, |cFFCCCCCCarg1|r, |cFFCCCCCCarg2|r, |cFFCCCCCCarg3|r, |cFFCCCCCCarg4|r)", Desc = "Creates an animation within an animation hub.\n\nOrder: integer between 1 and 10, lower play first. Animations with the same Order play at the same time.\n\nDuration: how much time this animation takes to complete.\n\nAnimation Types:\n|cFFFFFF00\"Alpha\"|r:\n|cFFCCCCCCarg1|r: Alpha Start Value, |cFFCCCCCCarg2|r: Alpha End Value.\n\n|cFFFFFF00\"Scale\"|r:\n|cFFCCCCCCarg1|r: X Start, |cFFCCCCCCarg2|r: Y Start, |cFFCCCCCCarg3|r: X End, |cFFCCCCCCarg4|r: Y End.\n\n|cFFFFFF00\"Rotation\"|r:\n |cFFCCCCCCarg1|r: Rotation Degrees.\n\n|cFFFFFF00\"Translation\"|r:\n |cFFCCCCCCarg1|r: X Offset, |cFFCCCCCCarg2|r: Y Offset."},
{Name = "CreateIconGlow", Signature = "Plater.CreateIconGlow (self)", Desc = "Creates a glow effect around an icon.\n\nUse:\n|cFFFFFF00ReturnedValue:Show()|r on OnShow.\n|cFFFFFF00ReturnedValue:Hide()|r on OnHide.\n|cFFFFFF00ReturnedValue:SetColor(dotColor, glowColor)|r to adjust the color.", AddVar = true, AddCall = "--@ENV@:Show() --@ENV@:Hide()"},
{Name = "CreateNameplateGlow", Signature = "Plater.CreateNameplateGlow (unitFrame.healthBar)", Desc = "Creates a glow effect around the nameplate.\n\nUse:\n|cFFFFFF00ReturnedValue:Show()|r on OnShow.\n|cFFFFFF00ReturnedValue:Hide()|r on OnHide.\n|cFFFFFF00ReturnedValue:SetColor(dotColor, glowColor)|r to adjust the color.\n\nUse offsets to adjust the dot animation to fit the nameplate.", AddVar = true, AddCall = "--@ENV@:Show() --@ENV@:Hide() --@ENV@:SetOffset (-27, 25, 5, -7)"},
{Name = "LimitTextSize", Signature = "Plater.LimitTextSize (fontString, maxWidth)", Desc = "Cut the text making it shorter.\n\nExample: using 50 as maxWidth with 'Jaina Proudmoore' would result 'Jaina Prou'"},
{Name = "FormatNumber", Signature = "Plater.FormatNumber (number)", Desc = "Format a number to be short as possible.\n\nExample:\n300000 to 300K\n2500000 to 2.5M"},
{Name = "CommaValue", Signature = "Plater:CommaValue (number)", Desc = "Format a number separating by thousands and millions.\n\nExample: 300000 to 300.000\n2500000 to 2.500.000"},
{Name = "IntegerToTimer", Signature = "Plater:IntegerToTimer (number)", Desc = "Format a number to time\n\nExample: 94 to 1:34"},
{Name = "RemoveRealmName", Signature = "Plater:RemoveRealmName (playerName)", Desc = "Removes the realm name from a player name."},
{Name = "Trim", Signature = "Plater:Trim (string)", Desc = "Removes spaces in the begining and end of a string."},
}
Plater.UnitFrameMembers = {
"unitFrame.castBar",
"unitFrame.castBar.Text",
"unitFrame.castBar.FrameOverlay",
"unitFrame.castBar.percentText",
--"unitFrame.castBar.extraBackground",
"unitFrame.healthBar",
"unitFrame.healthBar.unitName",
--"unitFrame.healthBar.actorLevel",
"unitFrame.healthBar.lifePercent",
"unitFrame.healthBar.border",
--"unitFrame.healthBar.healthCutOff",
"unitFrame.BuffFrame",
"unitFrame.BuffFrame2",
--"unitFrame.ExtraIconFrame",
"unitFrame.Top3DFrame",
--"unitFrame.FocusIndicator",
"unitFrame.TargetNeonUp",
"unitFrame.TargetNeonDown",
}
Plater.NameplateComponents = {
["unitFrame - Members"] = {
"namePlateUnitToken",
"namePlateUnitGUID",
"namePlateNpcId",
"namePlateIsQuestObjective",
"namePlateUnitReaction",
"namePlateClassification",
"namePlateInRange",
"namePlateUnitName",
"namePlateUnitNameLower",
"namePlateIsTarget",
"namePlateThreatPercent",
"namePlateThreatStatus",
"namePlateThreatIsTanking",
"PlayerCannotAttack",
"InExecuteRange",
"InCombat",
"targetUnitID",
"UsingCustomColor",
},
["unitFrame - Frames"] = {
"healthBar",
"castBar",
"aggroGlowUpper",
"aggroGlowLower",
"BuffFrame",
"BuffFrame2",
"PlaterRaidTargetFrame",
"TargetNeonUp",
"TargetNeonDown",
"ExtraRaidMark",
"ExtraIconFrame",
"Top3DFrame",
"ActorNameSpecial",
"ActorTitleSpecial",
},
["healthBar - Members"] = {
"CurrentHealth",
"CurrentHealthMax",
},
["healthBar - Frames"] = {
"unitName",
"actorLevel",
"lifePercent",
"ExecuteRangeHealthCutOff",
"ExecuteRangeBar",
"ExecuteGlowUp",
"ExecuteGlowDown",
"ExtraRaidMark",
"FocusIndicator",
},
["castBar - Members"] = {
"unit",
"ThrottleUpdate",
"SpellName",
"SpellNameRenamed",
"SpellID",
"SpellTexture",
"SpellStartTime",
"SpellEndTime",
"CanInterrupt",
"IsInterrupted",
"InterruptSourceName",
"InterruptSourceGUID",
},
["castBar - Frames"] = {
"percentText",
"Text",
"FrameOverlay",
"TargetName",
"BorderShield",
},
}
Plater.TriggerDefaultMembers = {
[1] = {
"envTable._SpellID",
"envTable._UnitID",
"envTable._SpellName",
"envTable._Texture",
"envTable._Caster",
"envTable._StackCount",
"envTable._Duration",
"envTable._StartTime",
"envTable._EndTime",
"envTable._RemainingTime",
},
[2] = {
"envTable._SpellID",
"envTable._UnitID",
"envTable._SpellName",
"envTable._Texture",
"envTable._Caster",
"envTable._Duration",
"envTable._StartTime",
"envTable._EndTime",
"envTable._RemainingTime",
"envTable._CastPercent",
"envTable._CanInterrupt",
},
[3] = {
"envTable._UnitID",
"envTable._NpcID",
"envTable._UnitName",
"envTable._UnitGUID",
"envTable._HealthPercent",
},
}
function platerInternal.Scripts.GetDefaultScriptForSpellId(spellId)
local allScripts = Plater.db.profile.script_data
for i = 1, #allScripts do
local scriptObject = allScripts[i]
local triggers = scriptObject.SpellIds
local index = DF.table.find(triggers, spellId)
if (index) then
return scriptObject
end
end
end
local openURL = function(url)
if (not PlaterURLFrameHelper) then
local f = DF:CreateSimplePanel (UIParent, 460, 90, "URL", "PlaterURLFrameHelper")
f:SetFrameStrata ("TOOLTIP")
f:SetPoint ("center", UIParent, "center")
DF:CreateBorder (f)
local LinkBox = DF:CreateTextEntry (f, function()end, 380, 20, "ExportLinkBox", _, _, options_dropdown_template)
LinkBox:SetPoint ("center", f, "center", 0, -10)
PlaterURLFrameHelper.linkBox = LinkBox
f:SetScript ("OnShow", function()
C_Timer.After (.1, function()
LinkBox:SetFocus (true)
LinkBox:HighlightText()
end)
end)
f:Hide()
end
PlaterURLFrameHelper.linkBox:SetText(url)
PlaterURLFrameHelper:Show()
end
Plater.OpenCopyUrlDialog = openURL
--return a unique string ID to identify each script
--return a string containing time() and GetTime() merged into a string which is converted to hexadecimal
--examples: 0x60abce782cb0df 0x60abce7847845 0x60abce782cb3cd 0x60abce782cb485 0x60abce792cb51b 0x60abce792cb58f 0x60abce792cb625
local createUniqueIdentifier = function(seed)
--transform time() into a hex
local hexTime = format("%8x", tonumber(seed) or time())
--take the GetTime() and remove the dot
local getTime = tostring(GetTime()) --convert to string
getTime = getTime:gsub("%.", "") --remove the dot
local getTimeInt = tonumber(getTime) --conver to to number
getTimeInt = math.fmod(getTimeInt, 2^31) --ensure integer range
--tranform GetTime into a hex
local hexGetTime = format("%8x", getTimeInt)
--remove spaces added due to the string not having 8 digits
hexGetTime = hexGetTime:gsub("%s", "")
local finalHex = "0x" .. hexTime .. hexGetTime
return finalHex
end
function Plater.CreateUniqueIdentifier(seed)
return createUniqueIdentifier(seed)
end
--get numbers from a string of number separated by a comma
--example: "10, 45, 30, 5, 16" returns 10, 45, 30, 5, 16
function Plater.GetNumbersFromString(str)
local result = {}
for value in str:gmatch("([^,%s]+)") do
local number = tonumber(value)
if (number) then
result[#result+1] = number
end
end
return unpack(result)
end
--initialize the options panel for a script object
function Plater.CreateOptionTableForScriptObject(scriptObject)
scriptObject.Options = scriptObject.Options or {}
scriptObject.OptionsValues = scriptObject.OptionsValues or {}
--[[ tinsert(scriptObject.Options, {
Type = 5, --label
Name = "Options Intro",
Key = "",
Desc = "",
Icon = "Interface\\AddOns\\Plater\\images\\option_label",
Value = "Options For @scriptname"
});
tinsert(scriptObject.Options, {
Type = 6, --blank space
Name = "Blank Space",
Key = "",
Desc = "",
Icon = "Interface\\AddOns\\Plater\\images\\option_blank",
Value = ""
});
]]--
end
--shared functions between all script tabs
local do_script_or_hook_import = function (text, scriptType, keepExisting)
if (scriptType == "hook") then
--the user inserted a string for a hook
--call the external function to import this script with ignoreRevision, overrideExisting and showDebug
local importSuccess, newObject = Plater.ImportScriptString (text, true, true, true, keepExisting)
if (importSuccess) then
PlaterOptionsPanelContainer:SelectTabByIndex (PLATER_OPTIONS_HOOKING_TAB)
local mainFrame = PlaterOptionsPanelContainer
local hookFrame = mainFrame.AllFrames [PLATER_OPTIONS_HOOKING_TAB]
hookFrame.EditScript (newObject)
hookFrame.ScriptSelectionScrollBox:Refresh()
end
elseif (scriptType == "script") then
local importSuccess, newObject = Plater.ImportScriptString (text, true, true, true, keepExisting)
if (importSuccess) then
PlaterOptionsPanelContainer:SelectTabByIndex (PLATER_OPTIONS_SCRIPTING_TAB)
local mainFrame = PlaterOptionsPanelContainer
local scriptingFrame = mainFrame.AllFrames [PLATER_OPTIONS_SCRIPTING_TAB]
scriptingFrame.EditScript (newObject)
scriptingFrame.ScriptSelectionScrollBox:Refresh()
end
else
Plater:Msg ("Cannot import: data imported is invalid")
end
Plater.UpdateOptionsTabUpdateState()
end
local import_mod_or_script = function (text)
--cleanup the text removing extra spaces and break lines
text = DF:Trim (text)
if (string.len (text) > 0) then
local indexScriptTable = Plater.DecompressData (text, "print")
--print(DF.table.dump(indexScriptTable))
if (indexScriptTable and type (indexScriptTable) == "table") then
local scriptType = Plater.GetDecodedScriptType (indexScriptTable)
indexScriptTable.type = scriptType
indexScriptTable = Plater.MigrateScriptModImport (indexScriptTable)
--check if this is a mod or a script, if none show a msg for the import data
if (indexScriptTable.type ~= "script" and indexScriptTable.type ~= "hook") then
Plater.SendScriptTypeErrorMsg(indexScriptTable)
return
end
local promptToOverwrite = false
local scriptDB = Plater.GetScriptDB (scriptType) or {}
local newScript = Plater.BuildScriptObjectFromIndexTable (indexScriptTable, scriptType) or {}
for i = 1, #scriptDB do
local scriptObject = scriptDB [i]
if (scriptObject.Name == newScript.Name) then
promptToOverwrite = true
end
end
if promptToOverwrite then
DF:ShowPromptPanel ("This Mod/Script already exists. Do you want to overwrite it?\nClicking 'No' will create a copy instead.\nTo cancel close this window with the 'x'.", function() do_script_or_hook_import (text, scriptType, false) end, function() do_script_or_hook_import (text, scriptType, true) end, true, 550)
else
do_script_or_hook_import (text, scriptType, true)
end
else
Plater:Msg ("Cannot import: data imported is invalid")
end
end
end
-- store companion update data internally
local CompanionDataSlugs = {}
Plater.CompanionDataSlugs = CompanionDataSlugs
local CompanionDataStash = {}
local legacyDataInitialized = false
local CompanionSlugData = {}
local CompanionStashData = {}
local copy_companion_data = function(data)
if not data or not type(data) == "table" or data.encoded then return end -- just accept slugs tables
DF.table.copy(CompanionDataSlugs, data.slugs or {})
DF.table.copy(CompanionDataStash, data.stash or {})
end
Plater.AddCompanionData = copy_companion_data
local handle_legacy_wa_companion_data = function()
if legacyDataInitialized then return end
--handle update slugs
local data = WeakAurasCompanion and WeakAurasCompanion.Plater
if data then
copy_companion_data(data)
legacyDataInitialized = true
end
end
local has_wago_update = function (scriptObject)
if scriptObject and scriptObject.url then
local url = scriptObject.url
local id = url:match("wago.io/([^/]+)/([0-9]+)") or url:match("wago.io/([^/]+)$")
if id and CompanionDataSlugs[id] then
local update = CompanionDataSlugs[id]
local companionVersion = tonumber(update.wagoVersion)
--skip?
if scriptObject.skipWagoUpdate and scriptObject.skipWagoUpdate == (companionVersion or 0) then
return false
end
--ignore?
if scriptObject.ignoreWagoUpdate then
return false
end
--update?
return companionVersion > (scriptObject.version or 0)
end
end
return false
end
Plater.HasWagoUpdate = has_wago_update
-- return: notImported, isScipt, isMod, isProfile
local is_wago_stash_slug_already_imported = function(slug)
--scripts
for _, scriptObject in pairs(Plater.db.profile.script_data) do
local url = scriptObject.url
local id = url and (url:match("wago.io/([^/]+)/([0-9]+)") or url:match("wago.io/([^/]+)$"))
if id and slug == id then
return not has_wago_update(scriptObject), true, false, false
end
end
--mods:
for _, scriptObject in pairs(Plater.db.profile.hook_data) do
local url = scriptObject.url
local id = url and (url:match("wago.io/([^/]+)/([0-9]+)") or url:match("wago.io/([^/]+)$"))
if id and slug == id then
return not has_wago_update(scriptObject), false, true, false
end
end
--profile:
for _, profile in pairs(Plater.db.profiles) do
local url = profile.url
local id = url and (url:match("wago.io/([^/]+)/([0-9]+)") or url:match("wago.io/([^/]+)$"))
if id and slug == id then
return not has_wago_update(profile), false, false, true
end
end
return false
end
-- return: isUpdate, isScipt, isMod, isProfile
local is_wago_update = function(slug)
--scripts:
for _, scriptObject in pairs(Plater.db.profile.script_data) do
local url = scriptObject.url
local id = url and (url:match("wago.io/([^/]+)/([0-9]+)") or url:match("wago.io/([^/]+)$"))
if id and slug == id then
return has_wago_update(scriptObject), true, false, false
end
end
--mods:
for _, scriptObject in pairs(Plater.db.profile.hook_data) do
local url = scriptObject.url
local id = url and (url:match("wago.io/([^/]+)/([0-9]+)") or url:match("wago.io/([^/]+)$"))
if id and slug == id then
return has_wago_update(scriptObject), false, true, false
end
end
--profile:
local url = Plater.db.profile.url
local id = url and (url:match("wago.io/([^/]+)/([0-9]+)") or url:match("wago.io/([^/]+)$"))
if id and slug == id then
return has_wago_update(Plater.db.profile), false, false, true
end
return false
end
local get_update_from_companion = function (object)
--if not has_wago_update(object) then return end
if object and object.url then
local url = object.url
local id = url:match("wago.io/([^/]+)/([0-9]+)") or url:match("wago.io/([^/]+)$")
if id and CompanionDataSlugs[id] then
local update = CompanionDataSlugs[id]
return update
end
end
return nil
end
Plater.GetWagoUpdateDataFromCompanion = get_update_from_companion
local update_from_wago = function (scriptObject)
if not scriptObject.hasWagoUpdateFromImport and not has_wago_update(scriptObject) then return end
if scriptObject and scriptObject.url then
local url = scriptObject.url
local id = url:match("wago.io/([^/]+)/([0-9]+)") or url:match("wago.io/([^/]+)$")
if id and CompanionDataSlugs[id] then
local update = CompanionDataSlugs[id]
import_mod_or_script(update.encoded)
end
end
end
local import_npc_colors = function (colorData)
if (colorData and colorData.NpcColor) then
--store which npcs has a color enabled
local dbColors = Plater.db.profile.npc_colors
--table storing all npcs already detected inside dungeons and raids
local allNpcsDetectedTable = Plater.db.profile.npc_cache
--the uncompressed table is a numeric table of tables
for i, colorTable in pairs (colorData) do
--check integrity
if (type (colorTable) == "table") then
local npcID, scriptOnly, colorID, npcName, zoneName = unpack (colorTable)
if (npcID and colorID and npcName and zoneName) then
if (type (colorID) == "string" and type (npcName) == "string" and type (zoneName) == "string") then
if (type (npcID) == "number" and type (scriptOnly) == "boolean") then
dbColors [npcID] = dbColors [npcID] or {}
dbColors [npcID] [1] = true --the color for the npc is enabled
dbColors [npcID] [2] = scriptOnly --the color is only used in scripts
dbColors [npcID] [3] = colorID --string with the color name
--add this npcs in the npcs detected table as well
allNpcsDetectedTable [npcID] = allNpcsDetectedTable [npcID] or {}
allNpcsDetectedTable [npcID] [1] = npcName
allNpcsDetectedTable [npcID] [2] = zoneName
end
end
end
end
end
Plater:Msg ("NPC colors imported.")
end
end
local import_from_wago = function (script_id, isStash)
local update = script_id and isStash and CompanionStashData [script_id] or CompanionSlugData [script_id]
if update then
local encoded = update.encoded
--cleanup the text removing extra spaces and break lines
encoded = DF:Trim (encoded)
if (string.len (encoded) > 0) then
local decompressedTable = Plater.DecompressData (encoded, "print")
if (decompressedTable and type (decompressedTable) == "table") then
decompressedTable = Plater.MigrateScriptModImport (decompressedTable)
--check if the user in importing a profile
if (decompressedTable.plate_config) then
--DF:ShowErrorMessage ("Profiles are currently not supported.") --TODO! :D
local profile = decompressedTable
local profileName = update.Name
if (not profile.spell_animation_list) then
profile.spell_animation_list = DF.table.copy ({}, PLATER_DEFAULT_SETTINGS.profile.spell_animation_list)
end
local profiles = Plater.db:GetProfiles()
local profileExists = false
for i, existingProfName in ipairs(profiles) do
if existingProfName == profileName then
profileExists = true
break
end
end
local mainFrame = PlaterOptionsPanelContainer
local profilesFrame = mainFrame.AllFrames [PLATER_OPTIONS_PROFILES_TAB]
if profileExists then
local LOC = DF.Language.GetLanguageTable(addonName)
DF:ShowPromptPanel(string.format(LOC["OPTIONS_PROFILE_IMPORT_OVERWRITE"], profileName), function() profilesFrame.DoProfileImport(profileName, profile, true, isWagoUpdate) end, function() end, true, 500)
else
profilesFrame.DoProfileImport(profileName, profile, false, false)
end
return
elseif (decompressedTable.NpcColor) then
import_npc_colors(decompressedTable)
return
end
local scriptType = Plater.GetDecodedScriptType (decompressedTable)
local promptToOverwrite = false
local scriptDB = Plater.GetScriptDB (scriptType) or {}
local newScript = Plater.BuildScriptObjectFromIndexTable (decompressedTable, scriptType) or {}
for i = 1, #scriptDB do
local scriptObject = scriptDB [i]
if (scriptObject.Name == newScript.Name) then
promptToOverwrite = true
end
end
if promptToOverwrite then
DF:ShowPromptPanel ("This Mod/Script already exists. Do you want to overwrite it?\nClicking 'No' will create a copy instead.\nTo cancel close this window with the 'x'.", function() do_script_or_hook_import (encoded, scriptType, false) end, function() do_script_or_hook_import (encoded, scriptType, true) end, true, 550)
else
do_script_or_hook_import (encoded, scriptType, true)
end
else
Plater:Msg ("Cannot import: data imported is invalid")
end
end
end
end
local update_wago_slug_data = function()
handle_legacy_wa_companion_data()
local slugs = CompanionDataSlugs
local slugData = CompanionSlugData
wipe(slugData)
for slug, entry in pairs(slugs) do
local isUpdate, isScipt, isMod, isProfile = is_wago_update(slug)
local newScriptObject = { -- Dummy data --~prototype ~new ~create ñew
Enabled = true,
Name = "New Mod",
Icon = "",
Desc = "",
Author = "",
Time = time(),
Revision = 1,
PlaterCore = Plater.CoreVersion,
Hooks = {},
HooksTemp = {},
LastHookEdited = "",
LoadConditions = DF:UpdateLoadConditionsTable ({}),
Options = {},
}
Plater.CreateOptionTableForScriptObject(newScriptObject)
newScriptObject.semver = entry.wagoSemver
newScriptObject.Author = entry.author
newScriptObject.version = tonumber(entry.wagoVersion) or 0
newScriptObject.Name = DF:CleanTruncateUTF8String(strsub(entry.name, 1, 28)) --entry.name
newScriptObject.FullName = entry.name
newScriptObject.encoded = entry.encoded
newScriptObject.url = "https://wago.io/" .. slug .. "/" .. entry.wagoVersion
newScriptObject.slug = slug
newScriptObject.isWagoImport = true
newScriptObject.isWagoStash = false
newScriptObject.hasWagoUpdateFromImport = isUpdate
newScriptObject.isScipt = isScipt
newScriptObject.isMod = isMod
newScriptObject.isProfile = isProfile
tinsert(slugData, newScriptObject)
end
return slugData
end
local update_wago_stash_data = function()
handle_legacy_wa_companion_data()
local stash = CompanionDataStash
local stashData = CompanionStashData
wipe(stashData)
for slug, entry in pairs(stash) do
local isAlreadyImported = is_wago_stash_slug_already_imported(slug)
if not isAlreadyImported then
local newScriptObject = { -- Dummy data --~prototype ~new ~create ñew
Enabled = true,
Name = "New Mod",
Icon = "",
Desc = "",
Author = "",
Time = time(),
Revision = 1,
PlaterCore = Plater.CoreVersion,
Hooks = {},
HooksTemp = {},
LastHookEdited = "",
LoadConditions = DF:UpdateLoadConditionsTable ({}),
Options = {},
}
Plater.CreateOptionTableForScriptObject(newScriptObject)
newScriptObject.semver = entry.wagoSemver
newScriptObject.Author = entry.author
newScriptObject.version = tonumber(entry.wagoVersion) or 0
newScriptObject.Name = DF:CleanTruncateUTF8String(strsub(entry.name, 1, 28)) --entry.name
newScriptObject.FullName = entry.name
newScriptObject.encoded = entry.encoded
newScriptObject.url = "https://wago.io/" .. slug .. "/" .. entry.wagoVersion
newScriptObject.slug = slug
newScriptObject.isWagoImport = true
newScriptObject.isWagoStash = true
newScriptObject.hasWagoUpdateFromImport = true
newScriptObject.isScipt = isScipt
newScriptObject.isMod = isMod
newScriptObject.isProfile = isProfile
tinsert(stashData, newScriptObject)
end
end
return stashData
end
function Plater.CheckWagoUpdates(silent)
handle_legacy_wa_companion_data()
local countScripts = 0
for _, scriptObject in pairs(Plater.db.profile.script_data) do
countScripts = countScripts + (has_wago_update(scriptObject) and 1 or 0)
end
local countMods = 0
for _, scriptObject in pairs(Plater.db.profile.hook_data) do
countMods = countMods + (has_wago_update(scriptObject) and 1 or 0)
end
if not silent and (countMods > 0 or countScripts > 0) then
Plater:Msg ("There are " .. countMods .. " new mod and " .. countScripts .. " new script updates available from wago.io.")
end
local hasProfileUpdate = false
if has_wago_update(Plater.db.profile) then
hasProfileUpdate = true
if not silent then
Plater:Msg ("Your current profile has an update available from wago.io.")
end
end
return countMods, countScripts, hasProfileUpdate
end
local onclick_menu_scroll_line = function (self, scriptId, option, mainFrame)
if (option == "editscript") then
mainFrame.EditScript (scriptId)
elseif (option == "remove") then
mainFrame.RemoveScript (scriptId)
elseif (option == "duplicate") then
mainFrame.DuplicateScript (scriptId)
elseif (option == "export") then
mainFrame.ExportScript (scriptId)
elseif (option == "url") then
local url = mainFrame
openURL(url)
elseif (option == "sendtogroup") then
if (not IsInGroup()) then
Plater:Msg ("You need to be in a group to use this export option.")
return
end
Plater.ExportScriptToGroup (scriptId, mainFrame.ScriptType)
elseif (option == "exporttriggers") then
mainFrame.ExportScriptTriggers(scriptId)
elseif (option == "exportastable") then
mainFrame.ExportScriptAsLuaTable(scriptId)
elseif (option == "wago_update") then
local scriptObject = mainFrame.GetScriptObject (scriptId)
update_from_wago(scriptObject)
elseif (option == "skip_wago_update") then
local scriptObject = mainFrame.GetScriptObject (scriptId)
local update = get_update_from_companion(scriptObject)
local companionVersion = update and tonumber(update.wagoVersion) or nil
scriptObject.skipWagoUpdate = companionVersion
mainFrame.ScriptSelectionScrollBox:Refresh()
Plater.UpdateOptionsTabUpdateState()
elseif (option == "ignore_wago_update") then
local scriptObject = mainFrame.GetScriptObject (scriptId)
scriptObject.ignoreWagoUpdate = true
mainFrame.ScriptSelectionScrollBox:Refresh()
Plater.UpdateOptionsTabUpdateState()
elseif (option == "dont_skip_wago_update") then
local scriptObject = mainFrame.GetScriptObject (scriptId)
scriptObject.skipWagoUpdate = nil
mainFrame.ScriptSelectionScrollBox:Refresh()
Plater.UpdateOptionsTabUpdateState()
elseif (option == "dont_ignore_wago_update") then
local scriptObject = mainFrame.GetScriptObject (scriptId)
scriptObject.ignoreWagoUpdate = nil
mainFrame.ScriptSelectionScrollBox:Refresh()
Plater.UpdateOptionsTabUpdateState()
elseif (option == "wago_slugs") then
import_from_wago(scriptId)
update_wago_slug_data()
mainFrame.ScriptSelectionScrollBox:Refresh()
elseif (option == "wago_stash") then
import_from_wago(scriptId, true)
update_wago_stash_data()
mainFrame.ScriptSelectionScrollBox:Refresh()
end
GameCooltip:Hide()
end
--when the user hover over a scrollbox line
local onenter_scroll_line = function (self)
self:SetBackdropColor (.3, .3, .3, .6)
end
--when the user leaves a scrollbox line from a hover over
local onleave_scroll_line = function (self)
local mainFrame = self.MainFrame
local currentScript = mainFrame.GetCurrentScriptObject()
--check if the hover overed button is the current script being edited
if (currentScript == self.Data) then
self:SetBackdropColor (unpack (scrollbox_line_backdrop_color_selected))
else
self:SetBackdropColor (unpack (scrollbox_line_backdrop_color))
end
end
local onclick_wago_icon = function (self, button)
if (button == "LeftButton") then
local mainFrame = self.line.MainFrame
local scriptObject = mainFrame.GetScriptObject (self.line.ScriptId)
if not scriptObject.isWagoImport then
update_from_wago(scriptObject)
else
import_from_wago(self.line.ScriptId, scriptObject.isWagoStash)
end
end
end
--when the user clicks on a scrollbox line to select a script
local onclick_scroll_line = function (self, button)
local mainFrame = self.MainFrame
if (button == "LeftButton") then
local currentScriptObject = mainFrame.GetCurrentScriptObject()
--check if isn't the same script
local scriptToBeEdited = mainFrame.GetScriptObject (self.ScriptId)
if (scriptToBeEdited == currentScriptObject) then
--no need to load the new script if is the same
return
end