-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathPlater_OptionsPanel.lua
11469 lines (10544 loc) · 399 KB
/
Plater_OptionsPanel.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 addonId, platerInternal = ...
local Plater = Plater
---@type detailsframework
local DF = DetailsFramework
local LibSharedMedia = LibStub:GetLibrary ("LibSharedMedia-3.0")
local LibRangeCheck = LibStub:GetLibrary ("LibRangeCheck-3.0")
local _
local IS_WOW_PROJECT_MAINLINE = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
local IS_WOW_PROJECT_NOT_MAINLINE = WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE
local IS_WOW_PROJECT_CLASSIC_ERA = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local IS_WOW_PROJECT_CLASSIC_TBC = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC
local IS_WOW_PROJECT_CLASSIC_WRATH = IS_WOW_PROJECT_NOT_MAINLINE and ClassicExpansionAtLeast and LE_EXPANSION_WRATH_OF_THE_LICH_KING and ClassicExpansionAtLeast(LE_EXPANSION_WRATH_OF_THE_LICH_KING)
--local IS_WOW_PROJECT_CLASSIC_CATACLYSM = IS_WOW_PROJECT_NOT_MAINLINE and ClassicExpansionAtLeast and LE_EXPANSION_CATACLYSM and ClassicExpansionAtLeast(LE_EXPANSION_CATACLYSM)
local PixelUtil = PixelUtil or DFPixelUtil
--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")
--configs
local startX, startY, heightSize = 10, platerInternal.optionsYStart, 755
local optionsWidth, optionsHeight = 1100, 670
local mainHeightSize = 820
local IMPORT_EXPORT_EDIT_MAX_BYTES = 0 --1024000*4 -- 0 appears to be "no limit"
local IMPORT_EXPORT_EDIT_MAX_LETTERS = 0 --128000*4 -- 0 appears to be "no limit"
local highlightColorLastCombat = {1, 1, .2, .25}
local dropdownStatusBarTexture = platerInternal.Defaults.dropdownStatusBarTexture
local dropdownStatusBarColor = platerInternal.Defaults.dropdownStatusBarColor
local CONST_DELAY_TO_CREATE_SPELLLISTTAB = 0.15
--when opening the options after an encounter, open at the tab "spell list", it shows the spells used on the encounter
local CONST_LASTEVENTS_TAB_INDEX = 19
--cvars
local CVAR_ENABLED = "1"
local CVAR_DISABLED = "0"
local CVAR_RESOURCEONTARGET = "nameplateResourceOnTarget"
local CVAR_CULLINGDISTANCE = "nameplateMaxDistance"
local CVAR_AGGROFLASH = "ShowNamePlateLoseAggroFlash"
local CVAR_MOVEMENT_SPEED = "nameplateMotionSpeed"
local CVAR_MIN_ALPHA = "nameplateMinAlpha"
local CVAR_MIN_ALPHA_DIST = "nameplateMinAlphaDistance"
local CVAR_SHOWALL = "nameplateShowAll"
local CVAR_ENEMY_ALL = "nameplateShowEnemies"
local CVAR_ENEMY_MINIONS = "nameplateShowEnemyMinions"
local CVAR_ENEMY_MINUS = "nameplateShowEnemyMinus"
local CVAR_PLATEMOTION = "nameplateMotion"
local CVAR_FRIENDLY_ALL = "nameplateShowFriends"
local CVAR_FRIENDLY_GUARDIAN = "nameplateShowFriendlyGuardians"
local CVAR_FRIENDLY_PETS = "nameplateShowFriendlyPets"
local CVAR_FRIENDLY_TOTEMS = "nameplateShowFriendlyTotems"
local CVAR_FRIENDLY_MINIONS = "nameplateShowFriendlyMinions"
local CVAR_CLASSCOLOR = "ShowClassColorInNameplate"
local CVAR_SCALE_HORIZONTAL = "NamePlateHorizontalScale"
local CVAR_SCALE_VERTICAL = "NamePlateVerticalScale"
--members
local MEMBER_UNITID = "namePlateUnitToken"
local MEMBER_GUID = "namePlateUnitGUID"
local MEMBER_NPCID = "namePlateNpcId"
local MEMBER_QUEST = "namePlateIsQuestObjective"
local MEMBER_REACTION = "namePlateUnitReaction"
local MEMBER_ALPHA = "namePlateAlpha"
local MEMBER_RANGE = "namePlateInRange"
local MEMBER_NOCOMBAT = "namePlateNoCombat"
local MEMBER_NAME = "namePlateUnitName"
local MEMBER_NAMELOWER = "namePlateUnitNameLower"
local MEMBER_TARGET = "namePlateIsTarget"
local MEMBER_CLASSIFICATION = "namePlateClassification"
--actor types
local ACTORTYPE_FRIENDLY_PLAYER = "friendlyplayer"
local ACTORTYPE_FRIENDLY_NPC = "friendlynpc"
local ACTORTYPE_ENEMY_PLAYER = "enemyplayer"
local ACTORTYPE_ENEMY_NPC = "enemynpc"
local ACTORTYPE_PLAYER = "player"
--reaction
local UNITREACTION_HOSTILE = 3
local UNITREACTION_NEUTRAL = 4
local UNITREACTION_FRIENDLY = 5
local lower = string.lower
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
--db upvalues
local DB_CAPTURED_SPELLS
local DB_CAPTURED_CASTS
local DB_NPCID_CACHE
local DB_NPCID_COLORS
local DB_AURA_ALPHA
local DB_AURA_ENABLED
local DB_AURA_SEPARATE_BUFFS
local on_refresh_db = function()
local profile = Plater.db.profile
DB_CAPTURED_SPELLS = PlaterDB.captured_spells
DB_CAPTURED_CASTS = PlaterDB.captured_casts
DB_NPCID_CACHE = profile.npc_cache
DB_NPCID_COLORS = profile.npc_colors
DB_AURA_ALPHA = profile.aura_alpha
DB_AURA_ENABLED = profile.aura_enabled
DB_AURA_SEPARATE_BUFFS = Plater.db.profile.buffs_on_aura2
end
Plater.RegisterRefreshDBCallback (on_refresh_db)
local update_wago_update_icons = function()
local countMods, countScripts, hasProfileUpdate = Plater.CheckWagoUpdates(true)
local mainFrame = PlaterOptionsPanelContainer
local scriptButton = mainFrame.AllButtons [6] --~changeindex1
local modButton = mainFrame.AllButtons [7]
local profileButton = mainFrame.AllButtons [22]
if countMods > 0 then
modButton.updateIcon:Show()
else
modButton.updateIcon:Hide()
end
if countScripts > 0 then
scriptButton.updateIcon:Show()
else
scriptButton.updateIcon:Hide()
end
if hasProfileUpdate then
profileButton.updateIcon:Show()
else
profileButton.updateIcon:Hide()
end
end
Plater.UpdateOptionsTabUpdateState = update_wago_update_icons
--check if a encounter has just ended and open the aura ease tab
function Plater.CheckOptionsTab()
if (Plater.LatestEncounter) then
if (Plater.LatestEncounter + 60 > time()) then
---@type df_tabcontainer
local tabContainer = _G["PlaterOptionsPanelContainer"]
C_Timer.After(CONST_DELAY_TO_CREATE_SPELLLISTTAB+0.050, function()
tabContainer:SelectTabByIndex(CONST_LASTEVENTS_TAB_INDEX)
end)
end
end
update_wago_update_icons()
end
---@param profileName string
---@param profile table
---@param bIsUpdate boolean
---@param bKeepModsNotInUpdate boolean
---@param doNotReload boolean
function Plater.ImportAndSwitchProfile(profileName, profile, bIsUpdate, bKeepModsNotInUpdate, doNotReload, keepScaleTune)
if type(profile) == "string" then -- try decompressing
local profileTmp = Plater.DecompressData (profile, "print", true)
if type(profileTmp) == "table" then
profile = profileTmp
end
end
assert((type(profileName) == "string"), "Plater requires a proper profile name for ImportAndSwitchProfile.")
assert((type(profile) == "table"), "Plater requires a proper compressed profile string or decompressed and deserialized profile table for ImportAndSwitchProfile.")
assert(profile.plate_config, "Plater requires a proper compressed profile string or decompressed and deserialized profile table for ImportAndSwitchProfile.")
local bWasUsingUIParent = Plater.db.profile.use_ui_parent
local scriptDataBackup = (bIsUpdate or bKeepModsNotInUpdate) and DF.table.copy({}, Plater.db.profile.script_data) or {}
local hookDataBackup = (bIsUpdate or bKeepModsNotInUpdate) and DF.table.copy({}, Plater.db.profile.hook_data) or {}
--switch to profile
Plater.db:SetProfile(profileName)
--cleanup profile -> reset to defaults
Plater.db:ResetProfile(false, true)
--import new profile settings
DF.table.copy(Plater.db.profile, profile)
--make the option reopen after the reload
Plater.db.profile.reopoen_options_panel_on_tab = TAB_INDEX_PROFILES
--check if parent to UIParent is enabled and calculate the new scale
if (Plater.db.profile.use_ui_parent) then
if (not bIsUpdate or not bWasUsingUIParent and not keepScaleTune) then --only update if necessary
Plater.db.profile.ui_parent_scale_tune = 1 / UIParent:GetEffectiveScale()
end
else
Plater.db.profile.ui_parent_scale_tune = 0
end
if (bIsUpdate or bKeepModsNotInUpdate) then
--copy user settings for mods/scripts and keep mods/scripts which are not part of the profile
for index, oldScriptObject in ipairs(scriptDataBackup) do
local scriptDB = Plater.db.profile.script_data or {}
local bFound = false
for i = 1, #scriptDB do
local scriptObject = scriptDB[i]
if (scriptObject.Name == oldScriptObject.Name) then
if (bIsUpdate) then
Plater.UpdateOptionsForModScriptImport(scriptObject, oldScriptObject)
end
bFound = true
break
end
end
if (not bFound and bKeepModsNotInUpdate) then
table.insert(scriptDB, oldScriptObject)
end
end
for index, oldScriptObject in ipairs(hookDataBackup) do
local scriptDB = Plater.db.profile.hook_data or {}
local bFound = false
for i = 1, #scriptDB do
local scriptObject = scriptDB[i]
if (scriptObject.Name == oldScriptObject.Name) then
if (bIsUpdate) then
Plater.UpdateOptionsForModScriptImport(scriptObject, oldScriptObject)
end
bFound = true
break
end
end
if (not bFound and bKeepModsNotInUpdate) then
table.insert(scriptDB, oldScriptObject)
end
end
end
--cleanup NPC cache/colors
---@type table<number, string[]> [1] npcname [2] zonename [3] language
local cache = Plater.db.profile.npc_cache
local cacheTemp = DetailsFramework.table.copy({}, cache)
for npcId, npcData in pairs(cacheTemp) do
---@cast npcData table{key1: string, key2: string, key3: string|nil}
if (tonumber(npcId)) then
cache[npcId] = nil
cache[tonumber(npcId)] = npcData
end
end
--cleanup npc colors
---@type npccolordb
local colors = Plater.db.profile.npc_colors
---@type npccolordb
local colorsTemp = DetailsFramework.table.copy({}, colors)
---@type number, npccolortable
for npcId, npcColorTable in pairs(colorsTemp) do
if tonumber(npcId) then
colors[npcId] = nil
colors[tonumber(npcId)] = npcColorTable
end
end
--cleanup cast colors/sounds
---@type castcolordb
local castColors = Plater.db.profile.cast_colors
---@type castcolordb
local castColorsTemp = DetailsFramework.table.copy({}, castColors)
---@type number, castcolortable
for spellId, castColorTable in pairs(castColorsTemp) do
if tonumber(spellId) then
castColors[spellId] = nil
castColors[tonumber(spellId)] = castColorTable
end
end
---@type renamednpcsdb
local renamedNPCs = Plater.db.profile.npcs_renamed
---@type renamednpcsdb
local renamedNPCsTemp = DetailsFramework.table.copy({}, renamedNPCs)
for npcId, renamedName in pairs(renamedNPCsTemp) do
if tonumber(npcId) then
renamedNPCs[npcId] = nil
renamedNPCs[tonumber(npcId)] = renamedName
end
end
---@type audiocuedb
local audioCues = Plater.db.profile.cast_audiocues
---@type audiocuedb
local audioCuesTemp = DetailsFramework.table.copy({}, audioCues)
for spellId, audioCuePath in pairs(audioCuesTemp) do
if tonumber(spellId) then
audioCues[spellId] = nil
audioCues[tonumber(spellId)] = audioCuePath
end
end
---@type spellanimationdb
local spellAnimations = Plater.db.profile.spell_animation_list
---@type spellanimationdb
local spellAnimationsTemp = DetailsFramework.table.copy({}, spellAnimations)
for spellId, animation in pairs(spellAnimationsTemp) do
if tonumber(spellId) then
spellAnimations[spellId] = nil
spellAnimations[tonumber(spellId)] = animation
end
end
---@type ghostauras
local ghostAuras = Plater.db.profile.ghost_auras.auras
---@type ghostauras
local ghostAurasTemp = DetailsFramework.table.copy({}, ghostAuras)
local ghostAurasDefault = PLATER_DEFAULT_SETTINGS.profile.ghost_auras.auras
--cleanup is needed for proper number indexing. will remove crap as well.
for class, specs in pairs(ghostAurasTemp) do
for specID, specData in pairs(specs) do
ghostAuras[class][specID] = nil
if ghostAurasDefault[class][tonumber(specID)] then
ghostAuras[class][tonumber(specID)] = ghostAuras[class][tonumber(specID)] or {}
for spellId, enabled in pairs(specData) do
if tonumber(spellId) then
ghostAuras[class][tonumber(specID)][tonumber(spellId)] = enabled
end
end
end
end
end
-- cleanup captured_spells
for spellId, data in pairs(Plater.db.profile.captured_spells) do
DB_CAPTURED_SPELLS[spellId] = DB_CAPTURED_SPELLS[spellId] or data --retain original
end
Plater.db.profile.captured_spells = nil --this does belong into PlaterDB
-- cleanup captured_casts
for spellId, data in pairs(Plater.db.profile.captured_casts) do
DB_CAPTURED_CASTS[spellId] = DB_CAPTURED_CASTS[spellId] or data --retain original
end
Plater.db.profile.captured_casts = nil --this does belong into PlaterDB
--restore CVars of the profile
Plater.RestoreProfileCVars()
--automatically reload the user UI unless explicitly posponed (external importer, for example)
if not doNotReload then
ReloadUI()
end
end
local TAB_INDEX_UIPARENTING = 5
local TAB_INDEX_PROFILES = 22
local bIsOptionsPanelFullyLoaded = false
-- ~options �ptions
function Plater.OpenOptionsPanel(pageNumber, bIgnoreLazyLoad)
platerInternal.OpenOptionspanelAfterCombat = nil
--__benchmark() --~perf
--localization
local L = DF.Language.GetLanguageTable(addonId)
if (PlaterOptionsPanelFrame) then
PlaterOptionsPanelFrame:Show()
if (not bIgnoreLazyLoad) then
Plater.CheckOptionsTab()
end
if (pageNumber) then
if (not bIsOptionsPanelFullyLoaded and not bIgnoreLazyLoad) then
C_Timer.After(1.5, function()
---@type df_tabcontainer
local tabContainer = _G["PlaterOptionsPanelContainer"]
tabContainer:SelectTabByIndex(pageNumber)
end)
else
---@type df_tabcontainer
local tabContainer = _G["PlaterOptionsPanelContainer"]
tabContainer:SelectTabByIndex(pageNumber)
end
end
return true
end
if (InCombatLockdown() and not Plater.IsInOpenWorld()) then
Plater:Msg ("Optionspanel not loaded and cannot open during combat. It will open automatically after combat ends.")
platerInternal.OpenOptionspanelAfterCombat = {pageNumber, bIgnoreLazyLoad}
return
end
if (pageNumber) then
C_Timer.After(0, function()
---@type df_tabcontainer
local tabContainer = _G["PlaterOptionsPanelContainer"]
tabContainer:SelectTabByIndex(pageNumber)
end)
end
Plater.db.profile.OptionsPanelDB = Plater.db.profile.OptionsPanelDB or {}
C_Timer.After(2, function() bIsOptionsPanelFullyLoaded = true end)
--build the main frame
local f = DF:CreateSimplePanel (UIParent, optionsWidth, optionsHeight, "Plater |cFFFF8822[|r|cFFFFFFFFNameplates|r|cFFFF8822]|r: professional addon for hardcore gamers", "PlaterOptionsPanelFrame", {UseScaleBar = true}, Plater.db.profile.OptionsPanelDB)
f.Title:SetAlpha(.75)
f:SetFrameStrata("DIALOG")
f:SetToplevel(true)
DF:ApplyStandardBackdrop(f)
f:ClearAllPoints()
PixelUtil.SetPoint(f, "center", UIParent, "center", 2, 2, 1, 1)
--over the top frame
local OTTFrame = CreateFrame("frame", "PlaterNameplatesOverTheTopFrame", f)
OTTFrame:SetFrameLevel(2000)
OTTFrame:SetSize(1, 1)
OTTFrame:SetPoint("topright", f, "topright", -22, -110)
f:HookScript("OnShow", function()
OTTFrame:Show()
end)
f:HookScript("OnHide", function()
OTTFrame:Hide()
end)
-- version text
local versionText = DF:CreateLabel (f, Plater.fullVersionInfo, 11, "white")
versionText:SetPoint ("topright", f, "topright", -25, -7)
versionText:SetAlpha(0.75)
local profile = Plater.db.profile
--local CVarDesc = "\n\n|cFFFF7700[*]|r |cFFa0a0a0CVar, not saved within Plater profile and is a Per-Character setting.|r"
local CVarDesc = "\n\n|cFFFF7700[*]|r |cFFa0a0a0CVar, saved within Plater profile and restored when loading the profile.|r"
local CVarIcon = "|cFFFF7700*|r"
local CVarNeedReload = "\n\n|cFFFF2200[*]|r |cFFa0a0a0A /reload may be required to take effect.|r"
local ImportantText = "|cFFFFFF00 Important |r: "
local SliderRightClickDesc = "\n\n" .. ImportantText .. "right click to type the value."
local hookList = {
---@param tabContainer df_tabcontainer
---@param tabButton df_tabcontainerbutton
OnSelectIndex = function(tabContainer, tabButton)
if (not tabButton.leftSelectionIndicator) then
return
end
for index, frame in ipairs(tabContainer.AllFrames) do
local tabButton = tabContainer.AllButtons[index]
tabButton.leftSelectionIndicator:SetColorTexture(.4, .4, .4)
end
tabButton.leftSelectionIndicator:SetColorTexture(1, 1, 0)
tabButton.selectedUnderlineGlow:Hide()
end,
}
local frame_options = {
y_offset = 0,
button_width = 108,
button_height = 23,
button_x = 190,
button_y = 1,
button_text_size = 10,
right_click_y = 5,
rightbutton_always_close = true,
close_text_alpha = 0.4,
container_width_offset = 30,
}
local languageInfo = {
language_addonId = addonId,
}
-- mainFrame � um frame vazio para sustentrar todos os demais frames, este frame sempre ser� mostrado
local mainFrame = DF:CreateTabContainer (f, "Plater Options", "PlaterOptionsPanelContainer",
{
--when chaging these indexes also need to change the function f.CopySettings
{name = "FrontPage", text = "OPTIONS_TABNAME_GENERALSETTINGS"},
{name = "ThreatConfig", text = "OPTIONS_TABNAME_THREAT"},
{name = "TargetConfig", text = "OPTIONS_TABNAME_TARGET"},
{name = "CastBarConfig", text = "OPTIONS_TABNAME_CASTBAR", createOnDemandFunc = platerInternal.CreateCastBarOptions},
{name = "LevelStrataConfig", text = "OPTIONS_TABNAME_STRATA"},
{name = "Scripting", text = "OPTIONS_TABNAME_SCRIPTING"},
{name = "AutoRunCode", text = "OPTIONS_TABNAME_MODDING"},
{name = "PersonalBar", text = "OPTIONS_TABNAME_PERSONAL"},
{name = "DebuffConfig", text = "OPTIONS_TABNAME_BUFF_SETTINGS"},
{name = "DebuffBlacklist", text = "OPTIONS_TABNAME_BUFF_TRACKING"},
{name = "DebuffSpecialContainer", text = "OPTIONS_TABNAME_BUFF_SPECIAL"},
{name = "GhostAurasFrame", text = "Ghost Auras"}, --localize-me
{name = "EnemyNpc", text = "OPTIONS_TABNAME_NPCENEMY"},
{name = "EnemyPlayer", text = "OPTIONS_TABNAME_PLAYERENEMY"},
{name = "FriendlyNpc", text = "OPTIONS_TABNAME_NPCFRIENDLY"},
{name = "FriendlyPlayer", text = "OPTIONS_TABNAME_PLAYERFRIENDLY"},
{name = "ColorManagement", text = "OPTIONS_TABNAME_NPC_COLORNAME"},
{name = "CastColorManagement", text = "OPTIONS_TABNAME_CASTCOLORS"},
{name = "DebuffLastEvent", text = "OPTIONS_TABNAME_BUFF_LIST"},
{name = "AnimationPanel", text = "OPTIONS_TABNAME_ANIMATIONS"},
{name = "Automation", text = "OPTIONS_TABNAME_AUTO"},
{name = "ProfileManagement", text = "OPTIONS_TABNAME_PROFILES"},
{name = "AdvancedConfig", text = "OPTIONS_TABNAME_ADVANCED", createOnDemandFunc = platerInternal.CreateAdvancedOptions},
{name = "resourceFrame", text = "OPTIONS_TABNAME_COMBOPOINTS"},
{name = "WagoIo", text = "Wago Imports"}, --wago_imports --localize-me
{name = "SearchFrame", text = "OPTIONS_TABNAME_SEARCH", createOnDemandFunc = platerInternal.CreateSearchOptions},
{name = "PluginsFrame", text = "Plugins"}, --localize-me
{name = "BossModConfig", text = "Boss-Mods", createOnDemandFunc = platerInternal.CreateBossModOptions}, --localize-me
},
frame_options, hookList, languageInfo)
mainFrame:SetAllPoints()
--> when any setting is changed, call this function
local globalCallback = function()
Plater.IncreaseRefreshID()
Plater.RefreshDBUpvalues()
Plater.UpdateAllPlates()
--trigger the event "Options Changed" for mods
platerInternal.OnOptionChanged()
end
--export the function to other files
platerInternal.OptionsGlobalCallback = globalCallback
--make the tab button's text be aligned to left and fit the button's area
for index, frame in ipairs(mainFrame.AllFrames) do
--DF:ApplyStandardBackdrop(frame)
local frameBackgroundTexture = frame:CreateTexture(nil, "artwork")
frameBackgroundTexture:SetPoint("topleft", frame, "topleft", 1, -140)
frameBackgroundTexture:SetPoint("bottomright", frame, "bottomright", -1, 20)
frameBackgroundTexture:SetColorTexture (0.2317647, 0.2317647, 0.2317647)
frameBackgroundTexture:SetVertexColor (0.27, 0.27, 0.27)
frameBackgroundTexture:SetAlpha (0.3)
--frameBackgroundTexture:Hide()
--divisor shown above the background (create above)
local frameBackgroundTextureTopLine = frame:CreateTexture(nil, "artwork")
frameBackgroundTextureTopLine:SetPoint("bottomleft", frameBackgroundTexture, "topleft", 0, 0)
frameBackgroundTextureTopLine:SetPoint("bottomright", frame, "topright", -1, 0)
frameBackgroundTextureTopLine:SetHeight(1)
frameBackgroundTextureTopLine:SetColorTexture(0.1215, 0.1176, 0.1294)
frameBackgroundTextureTopLine:SetAlpha(1)
frame.titleText.fontsize = 12
local gradientBelowTheLine = DF:CreateTexture(frame, {gradient = "vertical", fromColor = "transparent", toColor = DF.IsDragonflight() and {0, 0, 0, 0.15} or {0, 0, 0, 0.25}}, 1, 100, "artwork", {0, 1, 0, 1}, "gradientBelowTheLine")
gradientBelowTheLine:SetPoint("top-bottom", frameBackgroundTextureTopLine)
local gradientAboveTheLine = DF:CreateTexture(frame, {gradient = "vertical", fromColor = DF.IsDragonflight() and {0, 0, 0, 0.3} or {0, 0, 0, 0.4}, toColor = "transparent"}, 1, 80, "artwork", {0, 1, 0, 1}, "gradientAboveTheLine")
gradientAboveTheLine:SetPoint("bottom-top", frameBackgroundTextureTopLine)
local tabButton = mainFrame.AllButtons[index]
local leftSelectionIndicator = tabButton:CreateTexture(nil, "overlay")
if (index == 1) then
leftSelectionIndicator:SetColorTexture(1, 1, 0)
else
leftSelectionIndicator:SetColorTexture(.4, .4, .4)
end
leftSelectionIndicator:SetPoint("left", tabButton.widget, "left", 2, 0)
leftSelectionIndicator:SetSize(4, tabButton:GetHeight()-4)
tabButton.leftSelectionIndicator = leftSelectionIndicator
local maxTextLength = tabButton:GetWidth() - 7
local fontString = _G[tabButton:GetName() .. "_Text"]
fontString:ClearAllPoints()
fontString:SetPoint("left", leftSelectionIndicator, "right", 2, 0)
fontString:SetJustifyH("left")
fontString:SetWidth(maxTextLength)
fontString:SetHeight(tabButton:GetHeight()+20)
fontString:SetWordWrap(true)
fontString:SetText(fontString:GetText())
local stringWidth = fontString:GetStringWidth()
--print(stringWidth, maxTextLength, fontString:GetText())
if (stringWidth > maxTextLength) then
local fontSize = DF:GetFontSize(fontString)
DF:SetFontSize(fontString, fontSize-0.5)
end
end
--1st row
local frontPageFrame = mainFrame.AllFrames [1]
local threatFrame = mainFrame.AllFrames [2]
local targetFrame = mainFrame.AllFrames [3]
local castBarFrame = mainFrame.AllFrames [4]--; print(castBarFrame:GetName())
local uiParentFeatureFrame = mainFrame.AllFrames [5]
local scriptingFrame = mainFrame.AllFrames [6]
local runCodeFrame = mainFrame.AllFrames [7]
local personalPlayerFrame = mainFrame.AllFrames [8]
--2nd row
local auraOptionsFrame = mainFrame.AllFrames [9]
local auraFilterFrame = mainFrame.AllFrames [10]
local auraSpecialFrame = mainFrame.AllFrames [11]
local ghostAuras = mainFrame.AllFrames [12]
local enemyNPCsFrame = mainFrame.AllFrames [13]
local enemyPCsFrame = mainFrame.AllFrames [14]
local friendlyNPCsFrame = mainFrame.AllFrames [15]
local friendlyPCsFrame = mainFrame.AllFrames [16]
--3rd row
local npcColorsFrame = mainFrame.AllFrames [17]; platerInternal.NpcColorsFrameIndex = 17; platerInternal.NpcColorsCreationDelay = 0.08;
local castColorsFrame = mainFrame.AllFrames [18]; platerInternal.CastColorsFrameIndex = 18; platerInternal.CastColorsCreationDelay = 0.1;
local auraLastEventFrame = mainFrame.AllFrames [19]; platerInternal.AuraLastFrameIndex = 19; platerInternal.AuraLastCreationDelay = 0.02;
local animationFrame = mainFrame.AllFrames [20] --when this index is changed, need to also change the index on Plater_AnimationEditor.lua
local autoFrame = mainFrame.AllFrames [21]
local profilesFrame = mainFrame.AllFrames [22]
local advancedFrame = mainFrame.AllFrames [23]
local resourceFrame = mainFrame.AllFrames [24]
--4th row
local wagoIoFrame = mainFrame.AllFrames [25] --wago_imports
local searchFrame = mainFrame.AllFrames [26]
local pluginsFrame = mainFrame.AllFrames [27]
local bossModFrame = mainFrame.AllFrames [28]
local scriptButton = mainFrame.AllButtons [6] --also need update on ~changeindex1 and ~changeindex2
local modButton = mainFrame.AllButtons [7]
local profileButton = mainFrame.AllButtons [22]
local ghostAurasButton = mainFrame.AllButtons [12]
--[=[ ghost auras isn't new anymore, keeping this code in case need to add the button into another tab
if (time() + 60*60*24*15 > 1647542962) then
ghostAuras.newTexture = ghostAurasButton:CreateTexture(nil, "overlay", nil, 7)
ghostAuras.newTexture:SetTexture([[Interface\AddOns\Plater\images\new]])
ghostAuras.newTexture:SetPoint("right", ghostAurasButton.widget, "right", 4, -9)
ghostAuras.newTexture:SetSize(35, 35)
ghostAuras.newTexture:SetAlpha(0.88)
end
--]=]
C_Timer.After(0.1, function() Plater.Resources.BuildResourceOptionsTab(resourceFrame) end)
C_Timer.After(0.1, function() Plater.Auras.BuildGhostAurasOptionsTab(ghostAuras) end)
C_Timer.After(platerInternal.CastColorsCreationDelay, function() Plater.CreateCastColorOptionsFrame(castColorsFrame) end)
--C_Timer.After(platerInternal.NpcColorsCreationDelay, function() Plater.CreateNpcColorOptionsFrame(npcColorsFrame) end)
C_Timer.After(CONST_DELAY_TO_CREATE_SPELLLISTTAB, function()
Plater.CreateAuraLastEventOptionsFrame(auraLastEventFrame)
end)
C_Timer.After(0.20, function()
Plater.CreateNpcColorOptionsFrame(npcColorsFrame)
end)
C_Timer.After(0.1, function() platerInternal.Plugins.CreatePluginsOptionsTab(pluginsFrame) end)
local generalOptionsAnchor = CreateFrame ("frame", "$parentOptionsAnchor", frontPageFrame, BackdropTemplateMixin and "BackdropTemplate")
generalOptionsAnchor:SetSize (1, 1)
generalOptionsAnchor:SetPoint ("topleft", frontPageFrame, "topleft", startX, startY)
local statusBar = CreateFrame ("frame", "$parentStatusBar", f, BackdropTemplateMixin and "BackdropTemplate")
statusBar:SetPoint ("bottomleft", f, "bottomleft")
statusBar:SetPoint ("bottomright", f, "bottomright")
statusBar:SetHeight (20)
DF:ApplyStandardBackdrop (statusBar)
statusBar:SetAlpha (0.9)
statusBar:SetFrameLevel (f:GetFrameLevel()+10)
DF:BuildStatusbarAuthorInfo (statusBar, "Plater is Maintained by ", "Cont1nuity & Terciob")
--if (DF.IsDragonflight()) then
local bottomGradient = DF:CreateTexture(f, {gradient = "vertical", fromColor = {0, 0, 0, 0.6}, toColor = "transparent"}, 1, 100, "artwork", {0, 1, 0, 1}, "bottomGradient")
bottomGradient:SetPoint("bottom-top", statusBar)
--end
--wago.io support
local wagoDesc = DF:CreateLabel (statusBar, L["OPTIONS_STATUSBAR_TEXT"])
wagoDesc.textcolor = "white"
wagoDesc.textsize = 11
wagoDesc:SetPoint ("left", statusBar.DiscordTextBox, "right", 10, 0)
wagoDesc.Anim = DF:CreateAnimationHub (wagoDesc)
wagoDesc.Anim:SetLooping ("repeat")
DF:CreateAnimation (wagoDesc.Anim, "alpha", 1, 1, .3, .7)
DF:CreateAnimation (wagoDesc.Anim, "alpha", 2, 1, 1, .3)
--wagoDesc.Anim:Play()
local updateIconScripts = scriptButton.button:CreateTexture ("$parentIcon", "overlay")
updateIconScripts:SetSize (16, 10)
updateIconScripts:SetTexture([[Interface\AddOns\Plater\images\wagologo.tga]])
updateIconScripts:SetPoint("bottomright", scriptButton.button, "bottomright", -2, 2)
updateIconScripts:Hide()
scriptButton.updateIcon = updateIconScripts
local updateIconMods = modButton.button:CreateTexture ("$parentIcon", "overlay")
updateIconMods:SetSize (16, 10)
updateIconMods:SetTexture([[Interface\AddOns\Plater\images\wagologo.tga]])
updateIconMods:SetPoint("bottomright", modButton.button, "bottomright", -2, 2)
updateIconMods:Hide()
modButton.updateIcon = updateIconMods
local updateIconProfile = profileButton.button:CreateTexture ("$parentIcon", "overlay")
updateIconProfile:SetSize (16, 10)
updateIconProfile:SetTexture([[Interface\AddOns\Plater\images\wagologo.tga]])
updateIconProfile:SetPoint("bottomright", profileButton.button, "bottomright", -2, 2)
updateIconProfile:Hide()
profileButton.updateIcon = updateIconProfile
f.AllMenuFrames = {}
for _, frame in ipairs (mainFrame.AllFrames) do
tinsert (f.AllMenuFrames, frame)
end
tinsert (f.AllMenuFrames, generalOptionsAnchor)
--~languages
---executed when the user selects a language in the dropdown
---@param languageId string
local onLanguageChangedCallback = function(languageId)
PlaterLanguage.language = languageId
end
---@type string
local currentLanguage = PlaterLanguage.language
--addonId, parent, callback, defaultLanguage
local languageSelectorDropdown = DF.Language.CreateLanguageSelector(addonId, OTTFrame, onLanguageChangedCallback, currentLanguage)
languageSelectorDropdown:SetPoint("topright", 0, 0)
--end of languages
--> on profile change
function f.RefreshOptionsFrame()
for _, frame in ipairs (f.AllMenuFrames) do
if (frame.RefreshOptions) then
frame:RefreshOptions()
elseif (frame.canvasFrame and frame.canvasFrame.child and frame.canvasFrame.child.RefreshOptions) then
frame.canvasFrame.child.RefreshOptions() -- new scroll menus
end
end
Plater.UpdateMaxCastbarTextLength()
end
function f.CopySettingsConfirmed()
DF.table.copy (Plater.db.profile.plate_config [f.CopyingTo], Plater.db.profile.plate_config [f.CopyingFrom])
PlaterOptionsPanelFrame.RefreshOptionsFrame()
Plater:Msg (L["OPTIONS_SETTINGS_COPIED"])
end
--> copy settings from one actor type to another
function f.CopySettings (_, _, from)
local currentTab = mainFrame.CurrentIndex
local settingsTo
if (currentTab == 8) then
settingsTo = "player"
elseif (currentTab == 13) then
settingsTo = "enemynpc"
elseif (currentTab == 14) then
settingsTo = "enemyplayer"
elseif (currentTab == 15) then
settingsTo = "friendlynpc"
elseif (currentTab == 16) then
settingsTo = "friendlyplayer"
end
if (settingsTo) then
f.CopyingFrom = from
f.CopyingTo = settingsTo
DF:ShowPromptPanel ("Copy setting from '" .. from .. "' to '" .. settingsTo .. "' ?", f.CopySettingsConfirmed, function() f.CopyingFrom = nil; f.CopyingTo = nil; end)
else
Plater:Msg (L["OPTIONS_SETTINGS_FAIL_COPIED"])
end
end
local copy_settings_options = {
{label = L["OPTIONS_TABNAME_PERSONAL"], value = "player", onclick = f.CopySettings},
{label = L["OPTIONS_TABNAME_NPCENEMY"], value = "enemynpc", onclick = f.CopySettings},
{label = L["OPTIONS_TABNAME_PLAYERENEMY"], value = "enemyplayer", onclick = f.CopySettings},
{label = L["OPTIONS_TABNAME_NPCFRIENDLY"], value = "friendlynpc", onclick = f.CopySettings},
{label = L["OPTIONS_TABNAME_PLAYERFRIENDLY"], value = "friendlyplayer", onclick = f.CopySettings},
}
------------------------------------------------------------------------------------------------------------
--> profile frame ~profile
do
--logic
--when the user click to export the current profile
function profilesFrame.ExportCurrentProfile()
profilesFrame.IsExporting = true
profilesFrame.IsImporting = nil
profilesFrame.ImportStringField.importDataText = nil
local editbox = profilesFrame.ImportStringField.editbox
editbox:SetMaxBytes (IMPORT_EXPORT_EDIT_MAX_BYTES)
editbox:SetScript("OnChar", nil);
if (not profilesFrame.ImportingProfileAlert) then
profilesFrame.ImportingProfileAlert = CreateFrame ("frame", "PlaterExportingProfileAlert", UIParent, BackdropTemplateMixin and "BackdropTemplate")
profilesFrame.ImportingProfileAlert:SetSize (340, 75)
profilesFrame.ImportingProfileAlert:SetPoint ("center")
profilesFrame.ImportingProfileAlert:SetFrameStrata ("TOOLTIP")
DF:ApplyStandardBackdrop (profilesFrame.ImportingProfileAlert)
profilesFrame.ImportingProfileAlert:SetBackdropBorderColor (1, 0.8, 0.1)
profilesFrame.ImportingProfileAlert.IsLoadingLabel1 = DF:CreateLabel (profilesFrame.ImportingProfileAlert, L["OPTIONS_PROFILE_CONFIG_EXPORTINGTASK"])
profilesFrame.ImportingProfileAlert.IsLoadingLabel2 = DF:CreateLabel (profilesFrame.ImportingProfileAlert, L["OPTIONS_PLEASEWAIT"])
profilesFrame.ImportingProfileAlert.IsLoadingImage1 = DF:CreateImage (profilesFrame.ImportingProfileAlert, [[Interface\DialogFrame\UI-Dialog-Icon-AlertOther]], 32, 32)
profilesFrame.ImportingProfileAlert.IsLoadingLabel1.align = "center"
profilesFrame.ImportingProfileAlert.IsLoadingLabel2.align = "center"
profilesFrame.ImportingProfileAlert.IsLoadingLabel1:SetPoint ("center", 16, 10)
profilesFrame.ImportingProfileAlert.IsLoadingLabel2:SetPoint ("center", 16, -5)
profilesFrame.ImportingProfileAlert.IsLoadingImage1:SetPoint ("left", 10, 0)
end
profilesFrame.NewProfileLabel:Hide()
profilesFrame.NewProfileTextEntry:Hide()
profilesFrame.ImportStringField:Show()
profilesFrame.ImportingProfileAlert:Show()
C_Timer.After (.1, function()
--save mod/script editing
local hookFrame = mainFrame.AllFrames [7]
local scriptObject = hookFrame.GetCurrentScriptObject()
if (scriptObject) then
hookFrame.SaveScript()
hookFrame.CancelEditing()
end
local scriptingFrame = mainFrame.AllFrames [6]
local scriptObject = scriptingFrame.GetCurrentScriptObject()
if (scriptObject) then
scriptingFrame.SaveScript()
scriptingFrame.CancelEditing()
end
Plater.db.profile.captured_spells = {} -- cleanup, although it should be empty, stored in PlaterDB
Plater.db.profile.captured_casts = {} -- cleanup, although it should be empty, stored in PlaterDB
--create a modifiable copy, do not modify "in use" profile for safety
local profile = DF.table.copy(Plater.db.profile, {})
local npc_cacheOrig = Plater.db.profile.npc_cache
--do not export cache data, these data can be rebuild at run time
profile.npc_cache = {}
profile.saved_cvars_last_change = {}
profile.script_data_trash = {}
profile.hook_data_trash = {}
profile.plugins_data = {} -- it might be good to remove those to ensure no addon dependencies break anything
--profile.spell_animation_list = nil -- nil -> default will be used. but this should be part of the profile?!
--retain npc_cache for set npc_colors
for npcID, _ in pairs (profile.npc_colors) do
profile.npc_cache [npcID] = npc_cacheOrig [npcID]
end
--retain npc_cache for set npcs_renamed
for npcID, _ in pairs (profile.npcs_renamed) do
profile.npc_cache [npcID] = npc_cacheOrig [npcID]
end
--retain npc_cache, captured_spells and captured_casts for set cast_colors
for spellId, _ in pairs (profile.cast_colors) do
profile.captured_spells[spellId] = DB_CAPTURED_SPELLS[spellId]
profile.captured_casts[spellId] = DB_CAPTURED_CASTS[spellId]
local capturedSpell = DB_CAPTURED_SPELLS[spellId] or DB_CAPTURED_CASTS[spellId]
if capturedSpell and capturedSpell.npcID then
local npcID = capturedSpell.npcID
profile.npc_cache [npcID] = npc_cacheOrig [npcID]
end
end
--retain npc_cache, captured_spells and captured_casts for set cast_colors
for spellId, _ in pairs (profile.cast_audiocues) do
profile.captured_spells[spellId] = DB_CAPTURED_SPELLS[spellId]
profile.captured_casts[spellId] = DB_CAPTURED_CASTS[spellId]
local capturedSpell = DB_CAPTURED_SPELLS[spellId] or DB_CAPTURED_CASTS[spellId]
if capturedSpell and capturedSpell.npcID then
local npcID = capturedSpell.npcID
profile.npc_cache [npcID] = npc_cacheOrig [npcID]
end
end
--cleanup mods HooksTemp (for good)
for i = #profile.hook_data, 1, -1 do
local scriptObject = profile.hook_data [i]
scriptObject.HooksTemp = {}
end
--store current profile name
profile.profile_name = Plater.db:GetCurrentProfile()
profile.tocversion = select(4, GetBuildInfo()) -- provide export toc
--convert the profile to string
local data = Plater.CompressData (profile, "print")
if (not data) then
Plater:Msg ("failed to compress the profile")
end
--export to string
profilesFrame.ImportStringField:SetText (data or L["OPTIONS_ERROR_EXPORTSTRINGERROR"])
end)
C_Timer.After (.3, function()
profilesFrame.ImportStringField:SetFocus (true)
profilesFrame.ImportStringField.editbox:HighlightText()
profilesFrame.ImportingProfileAlert:Hide()
end)
end
function profilesFrame.ImportProfile()
profilesFrame.IsExporting = nil
profilesFrame.IsImporting = true
profilesFrame.ImportStringField.importDataText = nil
local editbox = profilesFrame.ImportStringField.editbox
local pasteBuffer, pasteCharCount, isPasting = {}, 0, false
--editbox:SetMaxBytes (1) -- for performance
local function clearBuffer(self)
self:SetScript('OnUpdate', nil)
editbox:SetMaxBytes (IMPORT_EXPORT_EDIT_MAX_BYTES)
isPasting = false
if pasteCharCount > 10 then
local paste = strtrim(table.concat(pasteBuffer))
local wagoProfile = Plater.DecompressData (paste, "print")
if (wagoProfile and type (wagoProfile) == "table") then
if (wagoProfile.plate_config) then
local existingProfileName = nil
local wagoInfoText = "Import data verified.\n\n"
if wagoProfile.url then
local impProfUrl = wagoProfile.url or ""
local impProfID = impProfUrl:match("wago.io/([^/]+)/([0-9]+)") or impProfUrl:match("wago.io/([^/]+)$")
local profiles = Plater.db.profiles
if impProfID then
for pName, pData in pairs(profiles) do
local pUrl = pData.url or ""
local id = pUrl:match("wago.io/([^/]+)/([0-9]+)") or pUrl:match("wago.io/([^/]+)$")
if id and impProfID == id then
existingProfileName = pName
break
end
end
end
wagoInfoText = wagoInfoText .. "Extracted the following wago information from the profile data:\n"
wagoInfoText = wagoInfoText .. " Local Profile Name: " .. (wagoProfile.profile_name or "N/A") .. "\n"
wagoInfoText = wagoInfoText .. " Wago-Revision: " .. (wagoProfile.version or "-") .. "\n"
wagoInfoText = wagoInfoText .. " Wago-Version: " .. (wagoProfile.semver or "-") .. "\n"
wagoInfoText = wagoInfoText .. " Wago-URL: " .. (wagoProfile.url and (wagoProfile.url .. "\n") or "")
wagoInfoText = wagoInfoText .. (existingProfileName and ("\nThis profile already exists as: '" .. existingProfileName .. "' in your profiles.\n") or "")
else
wagoInfoText = "This profile does not contain any wago.io information.\n"
end
wagoInfoText = wagoInfoText .. "\nYou may change the name below and click on '".. L["OPTIONS_OKAY"] .. "' to import the profile."
editbox:SetText (wagoInfoText)
profilesFrame.ImportStringField.importDataText = paste
local curNewProfName = profilesFrame.NewProfileTextEntry:GetText()
if existingProfileName and curNewProfName and curNewProfName == "MyNewProfile" then
profilesFrame.NewProfileTextEntry:SetText(existingProfileName)
elseif wagoProfile.profile_name and wagoProfile.profile_name ~= "Default" and curNewProfName and curNewProfName == "MyNewProfile" then
profilesFrame.NewProfileTextEntry:SetText(wagoProfile.profile_name)
end
else
local scriptType = Plater.GetDecodedScriptType (wagoProfile)
if (scriptType == "hook" or scriptType == "script") then
editbox:SetText (L["OPTIONS_PROFILE_ERROR_WRONGTAB"])
else
editbox:SetText (L["OPTIONS_PROFILE_ERROR_STRINGINVALID"])
end
end
else
editbox:SetText("Could not decompress the data. The text pasted does not appear to be a serialized Plater profile.\nTry copying the import string again.")
end
editbox:ClearFocus()
end
end
editbox:SetScript('OnChar', function(self, c)
if not isPasting then
if editbox:GetMaxBytes() ~= 1 then -- ensure this for performance!
editbox:SetMaxBytes (1)
end
pasteBuffer, pasteCharCount, isPasting = {}, 0, true
self:SetScript('OnUpdate', clearBuffer)
end
pasteCharCount = pasteCharCount + 1
pasteBuffer[pasteCharCount] = c
end)