-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
PawnUI.lua
2871 lines (2535 loc) · 109 KB
/
PawnUI.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
-- Pawn by Vger-Azjol-Nerub
-- www.vgermods.com
-- © 2006-2024 Travis Spomer. This mod is released under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 license.
-- See Readme.htm for more information.
--
-- User interface code
------------------------------------------------------------
------------------------------------------------------------
-- Globals
------------------------------------------------------------
PawnUICurrentScale = nil
PawnUICurrentTabNumber = nil
PawnUICurrentListIndex = 0
PawnUICurrentStatIndex = 0
-- The currently-active string dialog.
local PawnUIStringDialog
-- An array with indices 1 and 2 for the left and right compare items, respectively; each one is of the type returned by GetItemData.
local PawnUIComparisonItems = {}
-- An array with indices 1 and 2 for the first and second left side shortcut items.
local PawnUIShortcutItems = {}
local PawnUIGemQualityLevel
local PawnUITotalScaleLines = 0
local PawnUIIsShowingNoneWarning = false
local PawnUITotalComparisonLines = 0
local PawnUITotalGemLines = 0
-- Index n is the quest advisor overlay image for the reward with index n
local PawnQuestAdvisorOverlays = {}
-- PlayerGetTimerunningSeasonID() returns nil when first executing this on a full load (not a /reload), so it gets set in PawnUI_EnsureLoaded instead.
local StandardGemsUnavailable = nil
-- Don't taint the global variable "_".
local _
------------------------------------------------------------
-- "Constants"
------------------------------------------------------------
local PawnUIScaleSelectorNoneWarningHeight = 80 -- the "no scales selected" warning is this tall
local PawnUIScaleLineHeight = 16 -- each scale line is 16 pixels tall
local PawnUIScaleSelectorPaddingBottom = 5 -- add 5 pixels of padding to the bottom of the scrolling area
local PawnUIStatsListHeight = 20 -- the stats list contains 20 items
local PawnUIStatsListItemHeight = 16 -- each item is 16 pixels tall
local PawnUIComparisonLineHeight = 20 -- each comparison line is 20 pixels tall
local PawnUIComparisonAreaPaddingBottom = 10 -- add 10 pixels of padding to the bottom of the scrolling area
local PawnUIGemLineHeight = 17 -- each gem line is 17 pixels tall
local PawnUIGemAreaPaddingBottom = 0 -- add no padding to the bottom of the scrolling area
local PawnUIFrameNeedsScaleSelector = { true, true, true, true, false, false, false }
------------------------------------------------------------
-- Inventory button
------------------------------------------------------------
-- Moves the Pawn inventory sheet button and inspect button to the location specified by the user's current preferences.
function PawnUI_InventoryPawnButton_Move()
if PawnCommon.ButtonPosition == PawnButtonPositionRight then
PawnUI_InventoryPawnButton:ClearAllPoints()
if VgerCore.IsCataclysm or PaperDollFrame.ExpandButton then
-- DejaCharacterStats compatibility
PawnUI_InventoryPawnButton:SetPoint("TOPRIGHT", "CharacterTrinket1Slot", "BOTTOMRIGHT", -25, -8)
else
PawnUI_InventoryPawnButton:SetPoint("TOPRIGHT", "CharacterTrinket1Slot", "BOTTOMRIGHT", -1, -8)
end
PawnUI_InventoryPawnButton:Show()
if PawnUI_InspectPawnButton then
PawnUI_InspectPawnButton:ClearAllPoints()
PawnUI_InspectPawnButton:SetPoint("TOPRIGHT", "InspectTrinket1Slot", "BOTTOMRIGHT", -1, -8)
PawnUI_InspectPawnButton:Show()
end
if PawnUI_SocketingPawnButton then
PawnUI_SocketingPawnButton:ClearAllPoints()
PawnUI_SocketingPawnButton:SetPoint("TOPRIGHT", "ItemSocketingFrame", "TOPRIGHT", -14, -32)
PawnUI_SocketingPawnButton:Show()
end
elseif PawnCommon.ButtonPosition == PawnButtonPositionLeft then
PawnUI_InventoryPawnButton:ClearAllPoints()
PawnUI_InventoryPawnButton:SetPoint("TOPLEFT", "CharacterWristSlot", "BOTTOMLEFT", 1, -8)
PawnUI_InventoryPawnButton:Show()
if PawnUI_InspectPawnButton then
PawnUI_InspectPawnButton:ClearAllPoints()
PawnUI_InspectPawnButton:SetPoint("TOPLEFT", "InspectWristSlot", "BOTTOMLEFT", 1, -8)
PawnUI_InspectPawnButton:Show()
end
if PawnUI_SocketingPawnButton then
PawnUI_SocketingPawnButton:ClearAllPoints()
PawnUI_SocketingPawnButton:SetPoint("TOPRIGHT", "ItemSocketingFrame", "TOPRIGHT", -14, -32)
PawnUI_SocketingPawnButton:Show()
end
else
PawnUI_InventoryPawnButton:Hide()
if PawnUI_InspectPawnButton then
PawnUI_InspectPawnButton:Hide()
end
if PawnUI_SocketingPawnButton then
PawnUI_SocketingPawnButton:Hide()
end
end
end
function PawnUI_InventoryPawnButton_OnEnter(this)
-- Even if there are no scales, we'll at least display this much.
GameTooltip:ClearLines()
GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT")
GameTooltip:AddLine("Pawn", 1, 1, 1, 1)
GameTooltip:AddLine(PawnLocal.UI.InventoryButtonTooltip, nil, nil, nil, 1)
-- If the user has at least one scale and at least one type of value is enabled, calculate a total of all equipped items' values.
if not PawnCommon.ShowValuesForUpgradesOnly then
PawnUI_AddInventoryTotalsToTooltip(GameTooltip, "player")
end
-- Finally, display the tooltip.
GameTooltip:Show()
end
function PawnUI_InspectPawnButton_OnEnter(this)
GameTooltip:ClearLines()
GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT")
GameTooltip:AddLine("Pawn", 1, 1, 1, 1)
-- For some reason INSPECTED_UNIT isn't getting set in Classic, so fall back to target if it's nil.
PawnUI_AddInventoryTotalsToTooltip(GameTooltip, INSPECTED_UNIT or "target")
GameTooltip:Show()
end
function PawnUI_SocketingPawnButton_OnEnter(this)
GameTooltip:ClearLines()
GameTooltip:SetOwner(this, "ANCHOR_BOTTOMRIGHT")
GameTooltip:AddLine("Pawn", 1, 1, 1, 1)
GameTooltip:AddLine(PawnLocal.UI.SocketingAdvisorButtonTooltip)
-- Finally, display the tooltip.
GameTooltip:Show()
end
function PawnUI_SocketingPawnButton_OnClick(this)
-- Set the suggested gem quality level to the level of the current item so relevant gems will be displayed.
local ItemLevel
local _, ItemLink = ItemSocketingDescription:GetItem()
_, _, _, ItemLevel = C_Item.GetItemInfo(ItemLink)
PawnUI_SetGemQualityLevel(ItemLevel)
-- Show the Gems tab.
PawnUIShowTab(PawnUIGemsTabPage, true)
end
function PawnUI_AddInventoryTotalsToTooltip(Tooltip, Unit)
-- Get the total stats for all items.
local ItemValues, Count, AverageItemLevel = PawnGetInventoryItemValues(Unit)
if not PawnCommon.ShowValuesForUpgradesOnly then
if Count and Count > 0 then
Tooltip:AddLine(" ")
Tooltip:AddLine(PawnLocal.UI.InventoryButtonTotalsHeader, 1, 1, 1, 1)
PawnAddValuesToTooltip(Tooltip, ItemValues, nil, nil, nil, nil, true)
end
end
-- Add average item level information to the inspect window. (It's not necessary for the current player's
-- character sheet because that's part of the default UI now.)
if AverageItemLevel and AverageItemLevel > 0 and Unit ~= "player" then
if PawnCommon.AlignNumbersRight then
Tooltip:AddDoubleLine(PawnLocal.AverageItemLevelIgnoringRarityTooltipLine, AverageItemLevel, VgerCore.Color.OrangeR, VgerCore.Color.OrangeG, VgerCore.Color.OrangeB, VgerCore.Color.OrangeR, VgerCore.Color.OrangeG, VgerCore.Color.OrangeB)
else
Tooltip:AddLine(PawnLocal.AverageItemLevelIgnoringRarityTooltipLine .. ": " .. AverageItemLevel, VgerCore.Color.OrangeR, VgerCore.Color.OrangeG, VgerCore.Color.OrangeB)
end
end
end
function PawnUI_InspectPawnButton_Attach()
VgerCore.Assert(InspectPaperDollFrame ~= nil, "InspectPaperDollFrame should be loaded by now!")
CreateFrame("Button", "PawnUI_InspectPawnButton", InspectPaperDollFrame, "PawnUI_InspectPawnButtonTemplate")
PawnUI_InspectPawnButton:SetParent(InspectPaperDollFrame)
PawnUI_InventoryPawnButton_Move()
end
function PawnUI_SocketingPawnButton_Attach()
PawnUI_EnsureLoaded()
if StandardGemsUnavailable then return end
-- Attach the socketing button.
VgerCore.Assert(ItemSocketingFrame ~= nil, "ItemSocketingFrame should be loaded by now!")
CreateFrame("Button", "PawnUI_SocketingPawnButton", ItemSocketingFrame, "PawnUI_SocketingPawnButtonTemplate")
PawnUI_SocketingPawnButton:SetParent(ItemSocketingFrame)
PawnUI_InventoryPawnButton_Move()
-- Hook the item update event.
hooksecurefunc(ItemSocketingDescription, "SetSocketedItem", PawnUI_OnSocketUpdate)
end
function PawnUI_HookArtifactUI()
local OriginalOnRelicSlotMouseEnter = ArtifactFrame.PerksTab.TitleContainer.OnRelicSlotMouseEnter
ArtifactFrame.PerksTab.TitleContainer.OnRelicSlotMouseEnter =
function(...)
PawnIsHoveringSocketedRelic = true
OriginalOnRelicSlotMouseEnter(...)
PawnIsHoveringSocketedRelic = false
end
-- individual slots: ArtifactFrame.PerksTab.TitleContainer.RelicSlots[1]
end
function PawnUI_HookEncounterJournal()
-- aka the Adventure Guide
-- (This wouldn't be necessary if you hooked GameTooltip.ProcessInfo instead, but you can't do that until you go through and
-- disable all of the old GameTooltip.Set__ methods on Dragonflight because otherwise you'd do double the work!)
if EncounterJournal_SetTooltipWithCompare then
hooksecurefunc("EncounterJournal_SetTooltipWithCompare", function(Tooltip, ItemLink)
if Tooltip ~= GameTooltip then return end
if ItemLink then PawnUpdateTooltip("GameTooltip", "SetHyperlink", ItemLink) end
end)
end
end
------------------------------------------------------------
-- Scale selector events
------------------------------------------------------------
function PawnUIFrame_ScaleSelector_Refresh()
-- First, delete the existing scale lines.
for i = 1, PawnUITotalScaleLines do
local LineName = "PawnUIScaleLine" .. i
local Line = getglobal(LineName)
if Line then Line:Hide() end
setglobal(LineName, nil)
end
PawnUITotalScaleLines = 0
-- Get a sorted list of scale data and display it all.
local ScaleData
local ScaleList = PawnGetAllScalesEx()
PawnUIIsShowingNoneWarning = true
for _, ScaleData in pairs(ScaleList) do
if ScaleData.IsVisible then
PawnUIIsShowingNoneWarning = false
break
end
end
if PawnUIIsShowingNoneWarning then
PawnUIFrame_ScaleSelector_NoneWarning:Show()
else
PawnUIFrame_ScaleSelector_NoneWarning:Hide()
end
local NewSelectedScale, FirstScale, LastHeader, _
for _, ScaleData in pairs(ScaleList) do
local ScaleName = ScaleData.Name
if ScaleName == PawnUICurrentScale then NewSelectedScale = ScaleName end
if not FirstScale then FirstScale = ScaleName end
-- Add the header if necessary.
if ScaleData.Header ~= LastHeader then
LastHeader = ScaleData.Header
PawnUIFrame_ScaleSelector_AddHeaderLine(LastHeader)
end
-- Then, list the scale.
PawnUIFrame_ScaleSelector_AddScaleLine(ScaleName, ScaleData.LocalizedName, ScaleData.IsVisible)
end
PawnUIScaleSelectorScrollContent:SetHeight(PawnUIScaleLineHeight + PawnUIScaleLineHeight * PawnUITotalScaleLines + PawnUIScaleSelectorPaddingBottom)
-- If the scale that they previously selected isn't in the list, or they didn't have a previously-selected
-- scale, just select the first visible one, or the first one if there's no visible scale.
PawnUICurrentScale = NewSelectedScale or FirstScale or PawnLocal.NoScale
PawnUI_HighlightCurrentScale()
-- Also refresh a few other related UI elements.
PawnUIUpdateHeader()
PawnUIFrame_ShowScaleCheck_Update()
PawnUIFrame_ScaleSelector_UpdateAuto()
end
function PawnUIFrame_ScaleSelector_UpdateAuto()
local Scale = PawnCommon.Scales[PawnUICurrentScale]
if Scale and Scale.ClassID and Scale.SpecID then
local _, LocalizedSpecName, _, IconTexturePath = PawnGetSpecializationInfoForClassID(Scale.ClassID, Scale.SpecID)
PawnUIFrame_ScaleSelector_SpecLabel:SetText(LocalizedSpecName)
PawnUIFrame_ScaleSelector_SpecIcon:SetTexture(IconTexturePath)
else
PawnUIFrame_ScaleSelector_SpecLabel:SetText("")
PawnUIFrame_ScaleSelector_SpecIcon:SetTexture(nil)
end
end
function PawnUIFrame_ScaleSelector_AddHeaderLine(Text)
local Line = PawnUIFrame_ScaleSelector_AddLineCore(Text)
Line:Disable()
end
function PawnUIFrame_ScaleSelector_AddScaleLine(ScaleName, LocalizedName, IsActive)
local ColoredName = LocalizedName
local Line = PawnUIFrame_ScaleSelector_AddLineCore(" " .. ColoredName)
if not IsActive then
Line:SetNormalFontObject("PawnFontSilver")
end
Line.ScaleName = ScaleName
end
function PawnUIFrame_ScaleSelector_AddLineCore(Text)
PawnUITotalScaleLines = PawnUITotalScaleLines + 1
local LineName = "PawnUIScaleLine" .. PawnUITotalScaleLines
local Line = CreateFrame("Button", LineName, PawnUIScaleSelectorScrollContent, "PawnUIFrame_ScaleSelector_ItemTemplate")
Line:SetPoint("TOPLEFT", PawnUIScaleSelectorScrollContent, "TOPLEFT", 0, -PawnUIScaleLineHeight * (PawnUITotalScaleLines - 1) - (PawnUIIsShowingNoneWarning and PawnUIScaleSelectorNoneWarningHeight or 0))
Line:SetText(Text)
return Line, LineName
end
function PawnUIFrame_ScaleSelector_OnClick(self)
local ScaleName = self.ScaleName
-- If they held down the shift key, also toggle the scale visibility; otherwise, just select that scale.
if IsShiftKeyDown() then
PawnSetScaleVisible(ScaleName, not PawnIsScaleVisible(ScaleName))
PawnUIFrame_ScaleSelector_Refresh()
end
PawnUI_SelectScale(ScaleName)
end
-- Selects a scale in the scales list.
function PawnUI_SelectScale(ScaleName)
-- Close popup UI as necessary.
PawnUIStringDialogSingleLine:Hide()
PawnUIStringDialogMultiLine:Hide()
ColorPickerFrame:Hide()
-- Select the scale.
PawnUICurrentScale = ScaleName
PawnUI_HighlightCurrentScale()
-- After selecting a new scale, update the rest of the UI.
PawnUIFrame_ShowScaleCheck_Update()
PawnUIUpdateHeader()
PawnUIFrame_ScaleSelector_UpdateAuto()
if PawnUIScalesTabPage:IsVisible() then
PawnUI_ScalesTab_Refresh()
end
if PawnUIValuesTabPage:IsVisible() then
PawnUI_ValuesTab_Refresh()
end
if PawnUICompareTabPage:IsVisible() then
PawnUI_CompareTab_Refresh()
end
if PawnUIGemsTabPage:IsVisible() then
PawnUI_ShowBestGems()
end
end
function PawnUI_HighlightCurrentScale()
PawnUIFrame_ScaleSelector_HighlightFrame:ClearAllPoints()
PawnUIFrame_ScaleSelector_HighlightFrame:Hide()
for i = 1, PawnUITotalScaleLines do
local LineName = "PawnUIScaleLine" .. i
local Line = getglobal(LineName)
if Line and Line.ScaleName == PawnUICurrentScale then
PawnUIFrame_ScaleSelector_HighlightFrame:SetPoint("TOPLEFT", "PawnUIScaleLine" .. i, "TOPLEFT", 0, 0)
PawnUIFrame_ScaleSelector_HighlightFrame:Show()
break
end
end
end
------------------------------------------------------------
-- Scales tab events
------------------------------------------------------------
function PawnUI_ScalesTab_Refresh()
PawnUIFrame_ScaleColorSwatch_Update()
if PawnUICurrentScale ~= PawnLocal.NoScale then
PawnUIFrame_ScaleNameLabel:SetText(PawnGetScaleColor(PawnUICurrentScale) .. PawnGetScaleLocalizedName(PawnUICurrentScale))
if PawnScaleIsReadOnly(PawnUICurrentScale) then
PawnUIFrame_ScaleTypeLabel:SetText(PawnUIFrame_ScaleTypeLabel_ReadOnlyScaleText)
PawnUIFrame_RenameScaleButton:Disable()
PawnUIFrame_DeleteScaleButton:Disable()
else
PawnUIFrame_ScaleTypeLabel:SetText(PawnUIFrame_ScaleTypeLabel_NormalScaleText)
PawnUIFrame_RenameScaleButton:Enable()
PawnUIFrame_DeleteScaleButton:Enable()
end
PawnUIFrame_CopyScaleButton:Enable()
PawnUIFrame_ExportScaleButton:Enable()
else
PawnUIFrame_ScaleNameLabel:SetText(PawnLocal.NoScale)
PawnUIFrame_CopyScaleButton:Disable()
PawnUIFrame_RenameScaleButton:Disable()
PawnUIFrame_DeleteScaleButton:Disable()
PawnUIFrame_ExportScaleButton:Disable()
end
PawnUI_ScalesTab_SelectFrame()
end
------------------------------------------------------------
-- Values tab events
------------------------------------------------------------
function PawnUI_ValuesTab_Refresh()
PawnUIFrame_StatsList_Update()
PawnUIFrame_StatsList_SelectStat(PawnUICurrentStatIndex)
local Scale
if PawnUICurrentScale ~= PawnLocal.NoScale then Scale = PawnCommon.Scales[PawnUICurrentScale] end
if PawnUICurrentScale == PawnLocal.NoScale then
PawnUIFrame_ValuesWelcomeLabel:SetText(PawnUIFrame_ValuesWelcomeLabel_NoScalesText)
elseif PawnScaleIsReadOnly(PawnUICurrentScale) then
PawnUIFrame_ValuesWelcomeLabel:SetText(PawnUIFrame_ValuesWelcomeLabel_ReadOnlyScaleText)
PawnUIFrame_NormalizeValuesCheck:Disable()
else
PawnUIFrame_ValuesWelcomeLabel:SetText(PawnUIFrame_ValuesWelcomeLabel_NormalText)
PawnUIFrame_NormalizeValuesCheck:Enable()
end
if Scale then
PawnUIFrame_NormalizeValuesCheck:SetChecked(Scale.NormalizationFactor and Scale.NormalizationFactor > 0)
PawnUIFrame_NormalizeValuesCheck:Show()
else
PawnUIFrame_NormalizeValuesCheck:Hide()
end
end
function PawnUIFrame_ImportScaleButton_OnClick()
PawnUIImportScale()
end
function PawnUIFrame_NewScaleButton_OnClick()
PawnUIGetString(PawnLocal.NewScaleEnterName, "", PawnUIFrame_NewScale_OnOK)
end
function PawnUIFrame_NewScale_OnOK(NewScaleName)
-- Does this scale already exist?
if NewScaleName == PawnLocal.NoScale then
PawnUIGetString(PawnLocal.NewScaleEnterName, "", PawnUIFrame_NewScale_OnOK)
return
elseif strfind(NewScaleName, "\"") then
PawnUIGetString(PawnLocal.NewScaleNoQuotes, NewScaleName, PawnUIFrame_NewScale_OnOK)
elseif PawnDoesScaleExist(NewScaleName) then
PawnUIGetString(PawnLocal.NewScaleDuplicateName, NewScaleName, PawnUIFrame_NewScale_OnOK)
return
end
-- Add and select the scale.
PawnAddEmptyScale(NewScaleName)
PawnUIFrame_ScaleSelector_Refresh()
PawnUI_SelectScale(NewScaleName)
PawnUISwitchToTab(PawnUIValuesTabPage)
end
function PawnUIFrame_NewScaleFromDefaultsButton_OnClick()
PawnUIGetString(PawnLocal.NewScaleEnterName, "", PawnUIFrame_NewScaleFromDefaults_OnOK)
end
function PawnUIFrame_NewScaleFromDefaults_OnOK(NewScaleName)
-- Does this scale already exist?
if NewScaleName == PawnLocal.NoScale then
PawnUIGetString(PawnLocal.NewScaleEnterName, "", PawnUIFrame_NewScaleFromDefaults_OnOK)
return
elseif strfind(NewScaleName, "\"") then
PawnUIGetString(PawnLocal.NewScaleNoQuotes, NewScaleName, PawnUIFrame_NewScaleFromDefaults_OnOK)
elseif PawnDoesScaleExist(NewScaleName) then
PawnUIGetString(PawnLocal.NewScaleDuplicateName, NewScaleName, PawnUIFrame_NewScaleFromDefaults_OnOK)
return
end
-- Add and select the scale.
PawnAddDefaultScale(NewScaleName)
PawnUIFrame_ScaleSelector_Refresh()
PawnUI_SelectScale(NewScaleName)
PawnUISwitchToTab(PawnUIValuesTabPage)
end
function PawnUIFrame_ExportScaleButton_OnClick()
PawnUIExportScale(PawnUICurrentScale)
end
function PawnUIFrame_RenameScaleButton_OnClick()
PawnUIGetString(format(PawnLocal.RenameScaleEnterName, PawnUICurrentScale), PawnUICurrentScale, PawnUIFrame_RenameScale_OnOK)
end
function PawnUIFrame_CopyScaleButton_OnClick()
PawnUIGetString(format(PawnLocal.CopyScaleEnterName, PawnGetScaleLocalizedName(PawnUICurrentScale)), "", PawnUIFrame_CopyScale_OnOK)
end
-- Shows a dialog where the user can copy a scale tag for a given scale to the clipboard.
-- Immediately returns true if successful, or false if not.
function PawnUIExportScale(ScaleName)
local ScaleTag = PawnGetScaleTag(ScaleName)
if ScaleTag then
PawnUIShowCopyableString(format(PawnLocal.ExportScaleMessage, PawnGetScaleLocalizedName(PawnUICurrentScale)), ScaleTag, nil, true)
return true
else
return false
end
end
-- Exports all custom scales as a series of scale tags.
function PawnUIExportAllScales()
local ScaleTags, ScaleName, Scale
ScaleTags = ""
for ScaleName in pairs(PawnCommon.Scales) do
if not PawnScaleIsReadOnly(ScaleName) then ScaleTags = ScaleTags .. PawnGetScaleTag(ScaleName) .. " " end
end
if ScaleTags and ScaleTags ~= "" then
PawnUIShowCopyableString(PawnLocal.ExportAllScalesMessage, ScaleTags, nil, true)
return true
else
return false
end
end
-- Shows a dialog where the user can paste a scale tag from the clipboard.
-- Immediately returns.
function PawnUIImportScale()
PawnUIGetString(PawnLocal.ImportScaleMessage, "", PawnUIImportScaleCallback, nil, true)
end
-- Callback function for PawnUIImportScale.
function PawnUIImportScaleCallback(ScaleTag)
-- Try to import the scale. If successful, we don't need to do anything else.
local Status, ScaleName = PawnImportScale(ScaleTag, true) -- allow overwriting a scale with the same name
if Status == PawnImportScaleResultSuccess then
if PawnUIFrame_ScaleSelector_Refresh then
-- Select the new scale if the UI is up.
PawnUIFrame_ScaleSelector_Refresh()
PawnUI_SelectScale(ScaleName)
PawnUISwitchToTab(PawnUIValuesTabPage)
end
return
end
-- If there was a problem, show an error message or reshow the dialog as appropriate.
if Status == PawnImportScaleResultAlreadyExists then
VgerCore.Message(VgerCore.Color.Salmon .. format(PawnLocal.ImportScaleAlreadyExistsMessage, ScaleName))
return
end
if Status == PawnImportScaleResultTagError then
-- Don't use the tag that was pasted as the default value; it makes it harder to paste.
PawnUIGetString(PawnLocal.ImportScaleTagErrorMessage, "", PawnUIImportScaleCallback, nil, true)
return
end
VgerCore.Fail("Unexpected PawnImportScaleResult value: " .. tostring(Status))
end
function PawnUIFrame_RenameScale_OnOK(NewScaleName)
-- Did they change anything?
if NewScaleName == PawnUICurrentScale then return end
-- Does this scale already exist?
if NewScaleName == PawnLocal.NoScale then
PawnUIGetString(format(PawnLocal.RenameScaleEnterName, PawnUICurrentScale), PawnUICurrentScale, PawnUIFrame_RenameScale_OnOK)
return
elseif strfind(NewScaleName, "\"") then
PawnUIGetString(PawnLocal.NewScaleNoQuotes, NewScaleName, PawnUIFrame_RenameScale_OnOK)
elseif PawnDoesScaleExist(NewScaleName) then
PawnUIGetString(PawnLocal.NewScaleDuplicateName, PawnUICurrentScale, PawnUIFrame_RenameScale_OnOK)
return
end
-- Rename and select the scale.
PawnRenameScale(PawnUICurrentScale, NewScaleName)
PawnUIFrame_ScaleSelector_Refresh()
PawnUI_SelectScale(NewScaleName)
end
function PawnUIFrame_CopyScale_OnOK(NewScaleName)
-- Does this scale already exist?
if NewScaleName == PawnLocal.NoScale then
PawnUIGetString(PawnLocal.CopyScaleEnterName, "", PawnUIFrame_CopyScale_OnOK)
return
elseif strfind(NewScaleName, "\"") then
PawnUIGetString(PawnLocal.NewScaleNoQuotes, NewScaleName, PawnUIFrame_CopyScale_OnOK)
elseif PawnDoesScaleExist(NewScaleName) then
PawnUIGetString(PawnLocal.NewScaleDuplicateName, NewScaleName, PawnUIFrame_CopyScale_OnOK)
return
end
-- Create the new scale.
PawnDuplicateScale(PawnUICurrentScale, NewScaleName)
if PawnScaleIsReadOnly(PawnUICurrentScale) then PawnSetScaleVisible(PawnUICurrentScale, false) end
PawnUIFrame_ScaleSelector_Refresh()
PawnUI_SelectScale(NewScaleName)
PawnUISwitchToTab(PawnUIValuesTabPage)
end
function PawnUIFrame_DeleteScaleButton_OnClick()
if IsShiftKeyDown() then
-- If the user held down the shift key when clicking the Delete button, just do it immediately.
PawnUIFrame_DeleteScaleButton_OnOK(DELETE_ITEM_CONFIRM_STRING)
else
PawnUIGetString(format(PawnLocal.DeleteScaleConfirmation, PawnUICurrentScale, DELETE_ITEM_CONFIRM_STRING), "", PawnUIFrame_DeleteScaleButton_OnOK)
end
end
function PawnUIFrame_DeleteScaleButton_OnOK(ConfirmationText)
-- If they didn't type "DELETE" (ignoring case), just exit.
if strlower(ConfirmationText) ~= strlower(DELETE_ITEM_CONFIRM_STRING) then return end
PawnDeleteScale(PawnUICurrentScale)
PawnUICurrentScale = nil
PawnUIFrame_ScaleSelector_Refresh()
PawnUI_ScalesTab_Refresh()
end
function PawnUI_ScalesTab_SelectFrame()
if not VgerCore.SpecsExist then
PawnUIFrame_AutoSelectScalesOnButton:Hide()
PawnUIFrame_AutoSelectScalesOffButton.SelectedTexture:Show()
PawnUIScalesTab_AutoFrame:Hide()
PawnUIScalesTab_ManualFrame:Show()
elseif PawnOptions.AutoSelectScales then
PawnUIFrame_AutoSelectScalesOnButton.SelectedTexture:Show()
PawnUIScalesTab_AutoFrame:Show()
PawnUIFrame_AutoSelectScalesOffButton.SelectedTexture:Hide()
PawnUIScalesTab_ManualFrame:Hide()
else
PawnUIFrame_AutoSelectScalesOnButton.SelectedTexture:Hide()
PawnUIScalesTab_AutoFrame:Hide()
PawnUIFrame_AutoSelectScalesOffButton.SelectedTexture:Show()
PawnUIScalesTab_ManualFrame:Show()
end
PawnUISwitchToTab(PawnUIScalesTabPage)
end
function PawnUIFrame_AutoSelectScalesOnButton_OnClick()
PawnOptions.UpgradeTracking = false
PawnSetAutoSelectScales(true)
PawnUI_ScalesTab_SelectFrame()
end
function PawnUIFrame_AutoSelectScalesOffButton_OnClick()
PawnSetAutoSelectScales(false)
PawnUI_ScalesTab_SelectFrame()
end
function PawnUIFrame_StatsList_Update()
if not PawnStats then return end
-- First, update the control and get our new offset.
FauxScrollFrame_Update(PawnUIFrame_StatsList, #PawnStats, PawnUIStatsListHeight, PawnUIStatsListItemHeight) -- list, number of items, number of items visible per page, item height
local Offset = FauxScrollFrame_GetOffset(PawnUIFrame_StatsList)
-- Then, update the list items as necessary.
local ThisScale
if PawnUICurrentScale ~= PawnLocal.NoScale then ThisScale = PawnGetAllStatValues(PawnUICurrentScale) end
local i
for i = 1, PawnUIStatsListHeight do
local Index = i + Offset
PawnUIFrame_StatsList_UpdateStatItem(i, Index, ThisScale)
end
-- After the user scrolled, we need to adjust their selection.
PawnUIFrame_StatsList_MoveHighlight()
end
-- Updates a single stat in the list based on its index into the PawnStats table.
function PawnUIFrame_StatsList_UpdateStat(Index)
local Offset = FauxScrollFrame_GetOffset(PawnUIFrame_StatsList)
local i = Index - Offset
if i <= 0 or i > PawnUIStatsListHeight then return end
PawnUIFrame_StatsList_UpdateStatItem(i, Index, PawnGetAllStatValues(PawnUICurrentScale))
end
-- Updates a single stat in the list.
function PawnUIFrame_StatsList_UpdateStatItem(i, Index, ThisScale)
local Title = PawnStats[Index][1]
local ThisStat = PawnStats[Index][2]
local Line = getglobal("PawnUIFrame_StatsList_Item" .. i)
if Index <= #PawnStats then
if not ThisStat then
-- This is a header row.
Line:SetText(Title)
Line:Disable()
elseif ThisScale and ThisScale[ThisStat] then
-- This is a stat that's in the current scale.
if ThisScale[ThisStat] <= PawnIgnoreStatValue then
-- Well, technically, it's ignored.
Line:SetText(" " .. Title .. " " .. PawnLocal.Unusable)
Line:SetNormalFontObject("PawnFontSilver")
else
Line:SetText(" " .. Title .. " = " .. format("%g", ThisScale[ThisStat]))
Line:SetNormalFontObject("GameFontHighlight")
end
Line:Enable()
else
-- This is a stat that's not in the current scale.
Line:SetText(" " .. Title)
Line:SetNormalFontObject("PawnFontSilver")
Line:Enable()
end
Line:Show()
else
Line:Hide()
end
end
-- Adjusts PawnUICurrentListIndex and the position of the highlight based on PawnUICurrentStatIndex.
function PawnUIFrame_StatsList_MoveHighlight()
-- If no stat is selected, just hide the highlight.
if not PawnUICurrentStatIndex or PawnUICurrentStatIndex == 0 then
PawnUICurrentListIndex = 0
PawnUIFrame_StatsList_HighlightFrame:Hide()
return
end
-- Otherwise, see if we need to draw a highlight. If the selected stat isn't visible, we shouldn't draw anything.
local Offset = FauxScrollFrame_GetOffset(PawnUIFrame_StatsList)
local i = PawnUICurrentStatIndex - Offset
if i <= 0 or i > PawnUIStatsListHeight then
PawnUICurrentListIndex = 0
PawnUIFrame_StatsList_HighlightFrame:Hide()
return
end
-- If we made it this far, then we need to draw a highlight.
PawnUICurrentListIndex = i
PawnUIFrame_StatsList_HighlightFrame:ClearAllPoints()
PawnUIFrame_StatsList_HighlightFrame:SetPoint("TOPLEFT", "PawnUIFrame_StatsList_Item" .. i, "TOPLEFT", 0, 0)
PawnUIFrame_StatsList_HighlightFrame:Show()
end
-- This is the click handler for list item #i.
function PawnUIFrame_StatsList_OnClick(i)
if not i or i <= 0 or i > PawnUIStatsListHeight then return end
local Offset = FauxScrollFrame_GetOffset(PawnUIFrame_StatsList)
local Index = i + Offset
PawnUIFrame_StatsList_SelectStat(Index)
end
function PawnUIFrame_StatsList_SelectStat(Index)
-- First, make sure that the stat is in the correct range.
if not Index or Index < 0 or Index > #PawnStats then
Index = 0
end
-- Then, find out what they've clicked on.
local Title, ThisStat, ThisDescription, ThisPrompt
if Index > 0 then
Title = PawnStats[Index][1]
ThisStat = PawnStats[Index][2]
if ThisStat then
-- This is a stat, not a header row.
else
-- This is a header row, or empty space.
Index = 0
end
end
PawnUICurrentStatIndex = Index
-- Show, move, or hide the highlight as appropriate.
PawnUIFrame_StatsList_MoveHighlight()
-- Finally, change the UI to the right.
local ThisScale
local ThisScaleIsReadOnly = PawnScaleIsReadOnly(PawnUICurrentScale)
if PawnUICurrentScale ~= PawnLocal.NoScale then ThisScale = PawnGetAllStatValues(PawnUICurrentScale) end
if Index > 0 and ThisScale then
-- They've selected a stat.
local ThisStatIsIgnored = ThisScale[ThisStat] and ThisScale[ThisStat] <= PawnIgnoreStatValue
ThisDescription = PawnStats[Index][3]
PawnUIFrame_DescriptionLabel:SetText(ThisDescription)
ThisPrompt = PawnStats[Index][5]
if ThisPrompt then
PawnUIFrame_StatNameLabel:SetText(ThisPrompt)
else
PawnUIFrame_StatNameLabel:SetText(format(PawnLocal.StatNameText, Title))
end
PawnUIFrame_StatNameLabel:Show()
local ThisScaleValue = ThisScale[ThisStat]
local ThisScaleValueUneditable = ThisScaleValue
if ThisStatIsIgnored then ThisScaleValueUneditable = "0" end
if not ThisScaleValueUneditable then ThisScaleValueUneditable = "0" end
if not ThisScaleValue or ThisScaleValue == 0 then ThisScaleValue = "" else ThisScaleValue = tostring(ThisScaleValue) end
PawnUIFrame_StatValueBox.SettingValue = (PawnUIFrame_StatValueBox:GetText() ~= ThisScaleValue)
PawnUIFrame_StatValueBox:SetText(ThisScaleValue)
PawnUIFrame_StatValueLabel:SetText(ThisScaleValueUneditable)
if ThisScaleIsReadOnly or ThisStatIsIgnored then
PawnUIFrame_StatValueLabel:Show()
PawnUIFrame_StatValueBox:Hide()
PawnUIFrame_ClearValueButton:Hide()
else
PawnUIFrame_StatValueBox:Show()
PawnUIFrame_StatValueLabel:Hide()
if ThisScaleValue ~= "" then
PawnUIFrame_ClearValueButton:Show()
else
PawnUIFrame_ClearValueButton:Hide()
end
end
PawnUIFrame_IgnoreStatCheck:SetChecked(ThisStatIsIgnored)
local TypeOfStat = PawnStats[Index][4]
if (not ThisScaleIsReadOnly) and (TypeOfStat ~= PawnStatUnignorable) then
-- Shown and editable: scale is editable and stat is not unignorable
PawnUIFrame_IgnoreStatCheck_Label:SetText(TypeOfStat == PawnStatItemType and PawnLocal.UI.ValuesIgnoreItemType or PawnLocal.UI.ValuesIgnoreStat)
PawnUIFrame_IgnoreStatCheck:Show()
PawnUIFrame_IgnoreStatCheck:Enable()
elseif ThisScaleIsReadOnly and (ThisStatIsIgnored) then
-- Shown but not editable: scale is not editable and stat is currently ignored
PawnUIFrame_IgnoreStatCheck_Label:SetText(TypeOfStat == PawnStatItemType and PawnLocal.UI.ValuesIgnoreItemType or PawnLocal.UI.ValuesIgnoreStat)
PawnUIFrame_IgnoreStatCheck:Show()
PawnUIFrame_IgnoreStatCheck:Disable()
else
-- Hidden: anytime else
PawnUIFrame_IgnoreStatCheck:Hide()
PawnUIFrame_IgnoreStatCheck:Disable()
end
local WeaponSet = PawnGetWeaponSetForStat(ThisStat)
if WeaponSet then PawnUIFrame_NoUpgradesCheck:SetChecked(not PawnGetShowUpgradesForWeapons(PawnUICurrentScale, WeaponSet)) end
if WeaponSet == 1 then
PawnUIFrame_NoUpgradesCheck_Label:SetText(PawnLocal.UI.ValuesDoNotShowUpgradesFor1H)
elseif WeaponSet == 2 then
PawnUIFrame_NoUpgradesCheck_Label:SetText(PawnLocal.UI.ValuesDoNotShowUpgradesFor2H)
end
if WeaponSet == nil then
PawnUIFrame_NoUpgradesCheck:Hide()
else
PawnUIFrame_NoUpgradesCheck:Show()
end
elseif PawnUICurrentScale == PawnLocal.NoScale then
-- They don't have any scales.
PawnUIFrame_DescriptionLabel:SetText(PawnLocal.NoScalesDescription)
PawnUIFrame_StatNameLabel:Hide()
PawnUIFrame_StatValueBox:Hide()
PawnUIFrame_StatValueLabel:Hide()
PawnUIFrame_ClearValueButton:Hide()
PawnUIFrame_IgnoreStatCheck:Hide()
PawnUIFrame_NoUpgradesCheck:Hide()
else
-- They haven't selected a stat.
PawnUIFrame_DescriptionLabel:SetText(PawnLocal.NoStatDescription)
PawnUIFrame_StatNameLabel:Hide()
PawnUIFrame_StatValueBox:Hide()
PawnUIFrame_StatValueLabel:Hide()
PawnUIFrame_ClearValueButton:Hide()
PawnUIFrame_IgnoreStatCheck:Hide()
PawnUIFrame_NoUpgradesCheck:Hide()
end
end
function PawnUIFrame_IgnoreStatCheck_OnClick()
if PawnScaleIsReadOnly(PawnUICurrentScale) then return end
local IsIgnoredNow = PawnUIFrame_IgnoreStatCheck:GetChecked()
if IsIgnoredNow then
PawnUIFrame_ClearValueButton:Hide()
PawnUIFrame_StatValueBox:Hide()
PawnUIFrame_StatValueLabel:Show()
PawnUIFrame_StatValueLabel:SetText("0")
PawnSetStatValue(PawnUICurrentScale, PawnStats[PawnUICurrentStatIndex][2], PawnIgnoreStatValue)
else
PawnUIFrame_ClearValueButton:Disable()
PawnUIFrame_ClearValueButton:Show()
PawnUIFrame_StatValueBox:SetText("")
PawnUIFrame_StatValueBox:Show()
PawnSetStatValue(PawnUICurrentScale, PawnStats[PawnUICurrentStatIndex][2], 0)
end
PawnUIFrame_StatsList_UpdateStat(PawnUICurrentStatIndex)
end
function PawnUIFrame_NoUpgradesCheck_OnClick()
local WeaponSet = PawnGetWeaponSetForStat(PawnStats[PawnUICurrentStatIndex][2])
if not WeaponSet then VgerCore.Fail("Couldn't find the weapon set to enable or disable.") return end
PawnSetShowUpgradesForWeapons(PawnUICurrentScale, WeaponSet, not PawnUIFrame_NoUpgradesCheck:GetChecked())
end
function PawnUIFrame_StatValueBox_OnTextChanged()
if PawnScaleIsReadOnly(PawnUICurrentScale) then return end
local NewString = gsub(PawnUIFrame_StatValueBox:GetText(), ",", ".")
local NewValue = tonumber(NewString)
if NewValue == 0 then NewValue = nil end
if NewValue then
if NewValue <= PawnIgnoreStatValue then
PawnUIFrame_StatValueBox:Hide()
PawnUIFrame_ClearValueButton:Hide()
PawnUIFrame_IgnoreStatCheck:SetChecked(true)
else
PawnUIFrame_StatValueBox:Show()
PawnUIFrame_ClearValueButton:Show()
PawnUIFrame_ClearValueButton:Enable()
PawnUIFrame_IgnoreStatCheck:SetChecked(false)
end
else
PawnUIFrame_StatValueBox:Show()
PawnUIFrame_ClearValueButton:Show()
PawnUIFrame_ClearValueButton:Disable()
PawnUIFrame_IgnoreStatCheck:SetChecked(false)
end
-- If other code is setting this value, we should ignore this event and not set any values.
if PawnUIFrame_StatValueBox.SettingValue then
PawnUIFrame_StatValueBox.SettingValue = false
return
end
PawnSetStatValue(PawnUICurrentScale, PawnStats[PawnUICurrentStatIndex][2], NewValue)
PawnUIFrame_StatsList_UpdateStat(PawnUICurrentStatIndex)
end
function PawnUIFrame_ClearValueButton_OnClick()
PawnUIFrame_StatValueBox:SetText("")
end
function PawnUIFrame_GetCurrentScaleColor()
local r, g, b
if PawnUICurrentScale and PawnUICurrentScale ~= PawnLocal.NoScale then r, g, b = VgerCore.HexToRGB(PawnCommon.Scales[PawnUICurrentScale].Color) end
if not r then
r, g, b = VgerCore.Color.BlueR, VgerCore.Color.BlueG, VgerCore.Color.BlueB
end
return r, g, b
end
function PawnUIFrame_ScaleColorSwatch_OnClick()
local info = {}
info.swatchFunc = PawnUIFrame_ScaleColorSwatch_OnChange
info.hasOpacity = false
info.r, info.g, info.b = PawnUIFrame_GetCurrentScaleColor()
info.cancelFunc = PawnUIFrame_ScaleColorSwatch_OnCancel
if ColorPickerFrame.SetupColorPickerAndShow then
-- Dragonflight 10.2.5 and later
ColorPickerFrame:SetupColorPickerAndShow(info)
else
-- Classic
ColorPickerFrame.func = info.swatchFunc
ColorPickerFrame.cancelFunc = info.cancelFunc
ColorPickerFrame.previousValues = { r = info.r, g = info.g, b = info.b }
ColorPickerFrame.hasOpacity = info.hasOpacity
ColorPickerFrame:SetColorRGB(info.r, info.g, info.b)
ShowUIPanel(ColorPickerFrame)
end
end
function PawnUIFrame_ScaleColorSwatch_OnChange()
local r, g, b = ColorPickerFrame:GetColorRGB()
PawnUIFrame_ScaleColorSwatch_SetColor(r, g, b)
end
function PawnUIFrame_ScaleColorSwatch_OnCancel()
local r, g, b
if ColorPickerFrame.GetPreviousValues then
-- Dragonflight 10.2.5 and later
r, g, b = ColorPickerFrame:GetPreviousValues()
else
-- Classic
r, g, b = ColorPicker_GetPreviousValues()
end
PawnUIFrame_ScaleColorSwatch_SetColor(r, g, b)
end
function PawnUIFrame_ScaleColorSwatch_SetColor(r, g, b)
PawnSetScaleColor(PawnUICurrentScale, VgerCore.RGBToHex(r, g, b))
PawnUI_ScalesTab_Refresh()
PawnResetTooltips()
end
function PawnUIFrame_ScaleColorSwatch_Update()
if PawnUICurrentScale ~= PawnLocal.NoScale then
local r, g, b = PawnUIFrame_GetCurrentScaleColor()
PawnUIFrame_ScaleColorSwatch_Color:SetColorTexture(r, g, b)
PawnUIFrame_ScaleColorSwatch_Label:Show()
PawnUIFrame_ScaleColorSwatch:Show()
else
PawnUIFrame_ScaleColorSwatch_Label:Hide()
PawnUIFrame_ScaleColorSwatch:Hide()
end
end
function PawnUIFrame_ShowScaleCheck_Update()
if PawnUICurrentScale ~= PawnLocal.NoScale then
PawnUIFrame_ShowScaleCheck:SetChecked(PawnIsScaleVisible(PawnUICurrentScale))
PawnUIFrame_ShowScaleCheck:Show()
else
PawnUIFrame_ShowScaleCheck:Hide()
end
end
function PawnUIFrame_ShowScaleCheck_OnClick()
PawnSetScaleVisible(PawnUICurrentScale, PawnUIFrame_ShowScaleCheck:GetChecked())
PawnUIFrame_ScaleSelector_Refresh()
end
function PawnUIFrame_NormalizeValuesCheck_OnClick()
if PawnUICurrentScale == PawnLocal.NoScale or PawnScaleIsReadOnly(PawnUICurrentScale) then return end
if PawnUIFrame_NormalizeValuesCheck:GetChecked() then
PawnSetScaleNormalizationFactor(PawnUICurrentScale, 1)
else
PawnSetScaleNormalizationFactor(PawnUICurrentScale, nil)
end
end