-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcooltip.lua
More file actions
4108 lines (3455 loc) · 138 KB
/
Copy pathcooltip.lua
File metadata and controls
4108 lines (3455 loc) · 138 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
local DF = _G ["DetailsFramework"]
if (not DF or not DetailsFrameworkCanLoad) then
return
end
local detailsFramework = DF
local SharedMedia = LibStub:GetLibrary("LibSharedMedia-3.0")
local _
--lua locals
local ipairs = ipairs
local wipe = table.wipe
local insert = table.insert
local max = math.max
local issecretvalue = issecretvalue or function() return false end
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
local SPELLBOOK_BANK_PLAYER = Enum.SpellBookSpellBank and Enum.SpellBookSpellBank.Player or "player"
local IsPassiveSpell = IsPassiveSpell or C_Spell.IsSpellPassive
local GetSpellCharges = GetSpellCharges or function(spellId)
local chargesInfo = C_Spell.GetSpellCharges(spellId)
if (chargesInfo) then
return chargesInfo.currentCharges, chargesInfo.maxCharges, chargesInfo.cooldownStartTime, chargesInfo.cooldownDuration, chargesInfo.chargeModRate
end
end
--api locals
local PixelUtil = PixelUtil or DFPixelUtil
local version = 33
local CONST_MENU_TYPE_MAINMENU = "main"
local CONST_MENU_TYPE_SUBMENU = "sub"
local CONST_COOLTIP_TYPE_MENU = "menu"
local CONST_COOLTIP_TYPE_TOOLTIP = "tooltip"
function DF:CreateCoolTip()
--if a cooltip is already created with a higher version
if (_G.GameCooltip2 and _G.GameCooltip2.version >= version) then
return
end
local maxStatusBarValue = 100000000
local defaultBackdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1,
tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0}}
local defaultBackdropColor = {0.1215, 0.1176, 0.1294, 0.9500}
local defaultBackdropBorderColor = {0.05, 0.05, 0.05, 1}
local defaultTexCoord = {0, 1, 0, 1}
--initialize
local gameCooltip = {
version = version,
debug = false,
}
_G.GameCooltip2 = gameCooltip
_G.GameCooltip = gameCooltip --back compatibility
function gameCooltip:PrintDebug(...)
if (gameCooltip.debug) then
print("|cFFFFFF00Cooltip|r:", ...)
print(debugstack())
end
end
function gameCooltip:Msg(...)
print("|cFFFFFF00Cooltip|r:", ...)
end
function gameCooltip:SetDebug(bDebugState)
gameCooltip.debug = bDebugState
end
function gameCooltip:ParseMenuType(menuType)
if ((type(menuType) == "number" and menuType == 1) or (type(menuType) == "string" and menuType == CONST_MENU_TYPE_MAINMENU)) then
return CONST_MENU_TYPE_MAINMENU
end
if ((type(menuType) == "number" and menuType == 2) or (type(menuType) == "string" and menuType == CONST_MENU_TYPE_SUBMENU)) then
return CONST_MENU_TYPE_SUBMENU
end
return CONST_MENU_TYPE_MAINMENU
end
gameCooltip.LanguageEditBox = gameCooltip.LanguageEditBox or CreateFrame("editbox")
gameCooltip.LanguageEditBox:SetFontObject("GameFontNormal")
gameCooltip.LanguageEditBox:ClearFocus()
gameCooltip.LanguageEditBox:SetAutoFocus(false)
--containers
gameCooltip.LeftTextTable = {}
gameCooltip.LeftTextTableSub = {}
gameCooltip.RightTextTable = {}
gameCooltip.RightTextTableSub = {}
gameCooltip.LeftIconTable = {}
gameCooltip.LeftIconTableSub = {}
gameCooltip.RightIconTable = {}
gameCooltip.RightIconTableSub = {}
gameCooltip.Banner = {false, false, false}
gameCooltip.TopIconTableSub = {}
gameCooltip.StatusBarTable = {}
gameCooltip.StatusBarTableSub = {}
gameCooltip.WallpaperTable = {}
gameCooltip.WallpaperTableSub = {}
gameCooltip.PopupFrameTable = {}
--menus
gameCooltip.FunctionsTableMain = {}
gameCooltip.FunctionsTableSub = {}
gameCooltip.ParametersTableMain = {}
gameCooltip.ParametersTableSub = {}
gameCooltip.FixedValue = nil
gameCooltip.SelectedIndexMain = nil
gameCooltip.SelectedIndexSec = {}
--options table
gameCooltip.OptionsList = {
["RightTextMargin"] = true, --offset between the right text to the right icon, default: -3
["IconSize"] = true,
["HeightAnchorMod"] = true,
["WidthAnchorMod"] = true,
["MinWidth"] = true,
["FixedWidth"] = true,
["FixedHeight"] = true,
["FixedWidthSub"] = true,
["FixedHeightSub"] = true,
["AlignAsBlizzTooltip"] = true,
["AlignAsBlizzTooltipFrameHeightOffset"] = true,
["IgnoreSubMenu"] = true,
["IgnoreButtonAutoHeight"] = true,
["TextHeightMod"] = true,
["ButtonHeightMod"] = true,
["ButtonHeightModSub"] = true,
["YSpacingMod"] = true, --space between each line, does not work with 'IgnoreButtonAutoHeight' and 'AlignAsBlizzTooltip'
["YSpacingModSub"] = true,
["ButtonsYMod"] = true, --amount of space to leave between the top border and the first line of the tooltip, default: 0
["ButtonsYModSub"] = true, --amount of space to leave between the top border and the first line of the tooltip, default: 0
["IconHeightMod"] = true,
["StatusBarHeightMod"] = true,
["StatusBarTexture"] = true,
["TextSize"] = true,
["TextFont"] = true,
["TextColor"] = true,
["TextColorRight"] = true,
["TextShadow"] = true, --text shadow is doing the text outline
["TextActuallyShadow"] = true, --text shadow which is the actually text shadow
["LeftTextWidth"] = true,
["RightTextWidth"] = true,
["LeftTextHeight"] = true,
["RightTextHeight"] = true,
["NoFade"] = true,
["MyAnchor"] = true,
["Anchor"] = true,
["RelativeAnchor"] = true,
["NoLastSelectedBar"] = true,
["SubMenuIsTooltip"] = true,
["LeftBorderSize"] = true, --offset between the left border and the left icon, default: 10 + offset
["RightBorderSize"] = true, --offset between the right border and the right icon, default: -10 + offset
["TopBorderSize"] = true, --offset between the top border and the top of the first line, default: -6 + offset
["HeighMod"] = true,
["HeighModSub"] = true,
["TooltipFrameHeightOffset"] = true,
["TooltipFrameHeightOffsetSub"] = true,
["IconBlendMode"] = true,
["IconBlendModeHover"] = true,
["SubFollowButton"] = true,
["IgnoreArrows"] = true,
["SelectedTopAnchorMod"] = true,
["SelectedBottomAnchorMod"] = true,
["SelectedLeftAnchorMod"] = true,
["SelectedRightAnchorMod"] = true,
["SparkTexture"] = true,
["SparkHeightOffset"] = true,
["SparkWidthOffset"] = true,
["SparkHeight"] = true,
["SparkWidth"] = true,
["SparkAlpha"] = true,
["SparkColor"] = true,
["SparkPositionXOffset"] = true,
["SparkPositionYOffset"] = true,
["NoLanguageDetection"] = true,
["UseTrilinearLeft"] = true,
["UseTrilinearRight"] = true,
}
gameCooltip.AliasList = {
--set the height of each line, options 'IgnoreButtonAutoHeight' and 'AlignAsBlizzTooltip' must be false
["LineHeightSizeOffset"] = "ButtonHeightMod",
["LineHeightSizeOffsetSub"] = "ButtonHeightModSub",
["FrameHeightSizeOffset"] = "HeighMod",
["FrameHeightSizeOffsetSub"] = "HeighModSub",
["TextOutline"] = "TextShadow",
["TextSilhouette"] = "TextActuallyShadow",
["TextContour"] = "TextActuallyShadow",
--space between the tooltip's left side and the start of the line
["LeftPadding"] = "LeftBorderSize",
--space between the tooltip's right side and the end of the line
["RightPadding"] = "RightBorderSize",
--space between each line, positive values make the lines be closer
["LinePadding"] = "YSpacingMod",
["VerticalPadding"] = "YSpacingMod",
["LinePaddingSub"] = "YSpacingModSub",
["VerticalPaddingSub"] = "YSpacingModSub",
--move each line in the Y axis (vertical offsett)
["LineYOffset"] = "ButtonsYMod",
["VerticalOffset"] = "ButtonsYMod", --amount of space to leave between the top border and the first line of the tooltip, default: 0
["LineYOffsetSub"] = "ButtonsYModSub",
["VerticalOffsetSub"] = "ButtonsYModSub",
}
gameCooltip.OptionsTable = {}
--amount of lines current on shown
gameCooltip.Indexes = 0
--amount of lines current on shown
gameCooltip.IndexesSub = {}
--amount of lines current on shown
gameCooltip.HaveSubMenu = false
--amount of lines current on shown on sub menu
gameCooltip.SubIndexes = 0
--1 tooltip 2 tooltip with bars 3 menu 4 menu + submenus
gameCooltip.Type = 1
--frame to anchor
gameCooltip.Host = nil
--last size
gameCooltip.LastSize = 0
gameCooltip.LastIndex = 0
gameCooltip.internalYMod = 0
gameCooltip.internalYMod = 0
gameCooltip.overlapChecked = false
--defaults
gameCooltip.default_height = 20
gameCooltip.default_text_size = 10.5
gameCooltip.default_text_font = "GameFontHighlight"
gameCooltip.selectedAnchor = {}
gameCooltip.selectedAnchor.left = 2
gameCooltip.selectedAnchor.right = 0
gameCooltip.selectedAnchor.top = 0
gameCooltip.selectedAnchor.bottom = 0
gameCooltip.defaultFont = DF:GetBestFontForLanguage()
gameCooltip.RoundedFramePreset = {
color = {.075, .075, .075, 1},
border_color = {.3, .3, .3, 1},
roundness = 8,
}
local parseFont = function(font)
local fontFile = SharedMedia:Fetch("font", font)
if fontFile then
return fontFile
end
local isFontObejct = type(font) == "table" and _G[font] and _G[font].GetFont and _G[font]:GetFont()
if isFontObejct then
return _G[font]:GetFont()
end
return font
end
--create frames, self is frame1 or frame2
local createTooltipFrames = function(self)
self:SetSize(500, 500)
self:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
if (not self.HaveRoundedCorners) then
self:SetBackdrop(nil)
DF:AddRoundedCornersToFrame(self, gameCooltip.RoundedFramePreset)
self:DisableRoundedCorners()
self.HaveRoundedCorners = true
end
self:SetBackdrop(defaultBackdrop)
self:SetBackdropColor(DF:ParseColors(defaultBackdropColor))
self:SetBackdropBorderColor(DF:ParseColors(defaultBackdropBorderColor))
--this texture get the color from gameCooltip:SetColor()
if (not self.frameBackgroundTexture) then
self.frameBackgroundTexture = self:CreateTexture("$parent_FrameBackgroundTexture", "BACKGROUND", nil, 2)
self.frameBackgroundTexture:SetColorTexture(0, 0, 0, 0)
self.frameBackgroundTexture:SetAllPoints()
end
--this get the texture from gameCooltip:SetWallpaper(index, texture, texcoord, color, desaturate)
if (not self.frameWallpaper) then
self.frameWallpaper = self:CreateTexture("$parent_FrameWallPaper", "BACKGROUND", nil, 4)
self.frameWallpaper:SetPoint("TOPLEFT", self, "TOPLEFT", 0, 0)
self.frameWallpaper:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 0, 0)
end
if (not self.selectedTop) then
self.selectedTop = self:CreateTexture("$parent_SelectedTop", "ARTWORK")
self.selectedTop:SetColorTexture(.5, .5, .5, .75)
self.selectedTop:SetHeight(3)
end
if (not self.gradientTexture) then
self.gradientTexture = DetailsFramework:CreateTexture(self, {gradient = "vertical", fromColor = {0, 0, 0, .2}, toColor = {0, 0, 0, 0}}, 1, 1, "overlay", {0, 1, 0, 1})
self.gradientTexture.sublevel = -7
self.gradientTexture:SetAllPoints()
end
if (not self.selectedBottom) then
self.selectedBottom = self:CreateTexture("$parent_SelectedBottom", "ARTWORK")
self.selectedBottom:SetColorTexture(.5, .5, .5, .75)
self.selectedBottom:SetHeight(3)
end
if (not self.selectedMiddle) then
self.selectedMiddle = self:CreateTexture("$parent_Selected", "ARTWORK")
self.selectedMiddle:SetColorTexture(.5, .5, .5, .75)
self.selectedMiddle:SetPoint("TOPLEFT", self.selectedTop, "BOTTOMLEFT")
self.selectedMiddle:SetPoint("BOTTOMRIGHT", self.selectedBottom, "TOPRIGHT")
end
if (not self.upperImage) then
self.upperImage = self:CreateTexture("$parent_UpperImage", "OVERLAY")
self.upperImage:SetPoint("CENTER", self, "CENTER", 0, -3)
self.upperImage:SetPoint("BOTTOM", self, "TOP", 0, -3)
self.upperImage:Hide()
end
if (not self.upperImage2) then
self.upperImage2 = self:CreateTexture("$parent_UpperImage2", "ARTWORK")
self.upperImage2:SetPoint("CENTER", self, "CENTER", 0, -3)
self.upperImage2:SetPoint("BOTTOM", self, "TOP", 0, -3)
self.upperImage2:Hide()
end
if (not self.upperImageText) then
self.upperImageText = self:CreateFontString("$parent_UpperImageText", "OVERLAY", "GameTooltipHeaderText")
self.upperImageText:SetJustifyH("LEFT")
self.upperImageText:SetPoint("LEFT", self.upperImage, "RIGHT", 5, 0)
DF:SetFontSize(self.upperImageText, 13)
end
if (not self.upperImageText2) then
self.upperImageText2 = self:CreateFontString("$parent_UpperImageText2", "OVERLAY", "GameTooltipHeaderText")
self.upperImageText2:SetJustifyH("LEFT")
self.upperImageText2:SetPoint("BOTTOMRIGHT", self, "LEFT", 0, 3)
DF:SetFontSize(self.upperImageText2, 13)
end
if (not self.titleIcon) then
self.titleIcon = self:CreateTexture("$parent_TitleIcon", "OVERLAY")
self.titleIcon:SetTexture("Interface\\Challenges\\challenges-main")
self.titleIcon:SetTexCoord(0.1521484375, 0.563671875, 0.160859375, 0.234375)
self.titleIcon:SetPoint("CENTER", self, "CENTER")
self.titleIcon:SetPoint("BOTTOM", self, "TOP", 0, -22)
self.titleIcon:Hide()
end
if (not self.titleText) then
self.titleText = self:CreateFontString("$parent_TitleText", "OVERLAY", "GameFontHighlightSmall")
self.titleText:SetJustifyH("LEFT")
DF:SetFontSize(self.titleText, 10)
self.titleText:SetPoint("CENTER", self.titleIcon, "CENTER", 0, 6)
end
if (not self.modelFrame) then
self.modelFrame = CreateFrame("PlayerModel", "$parent_ModelFrame", self)
self.modelFrame:SetPoint("topleft", self, "topleft", 5, -5)
self.modelFrame:SetPoint("bottomright", self, "bottomright", -5, 5)
self.modelFrame:Hide()
end
end
--main frame
local frame1 = GameCooltipFrame1
if (not GameCooltipFrame1) then
frame1 = CreateFrame("Frame", "GameCooltipFrame1", UIParent, "BackdropTemplate")
end
DF.table.addunique(UISpecialFrames, "GameCooltipFrame1")
if (not frame1.FlashAnimation) then
DF:CreateFlashAnimation(frame1)
end
createTooltipFrames(frame1)
--secondary frame
local frame2 = GameCooltipFrame2
if (not GameCooltipFrame2) then
frame2 = CreateFrame("Frame", "GameCooltipFrame2", UIParent, "BackdropTemplate")
end
frame2:SetClampedToScreen(true)
DF.table.addunique(UISpecialFrames, "GameCooltipFrame2")
createTooltipFrames(frame2)
frame2:SetPoint("bottomleft", frame1, "bottomright", 4, 0)
if (not frame2.FlashAnimation) then
DF:CreateFlashAnimation(frame2)
end
function GameCooltip:ShowRoundedCorner()
if (not frame1.HaveRoundedCorners) then
return
end
frame1:EnableRoundedCorners()
frame2:EnableRoundedCorners()
frame1:SetBackdrop(nil)
frame2:SetBackdrop(nil)
frame1.frameBackgroundTexture:Hide()
frame2.frameBackgroundTexture:Hide()
frame1.gradientTexture:Hide()
frame2.gradientTexture:Hide()
end
function GameCooltip:HideRoundedCorner()
if (not frame1.HaveRoundedCorners) then
return
end
frame1:DisableRoundedCorners()
frame2:DisableRoundedCorners()
frame1.frameBackgroundTexture:Show()
frame2.frameBackgroundTexture:Show()
frame1.gradientTexture:Show()
frame2.gradientTexture:Show()
end
gameCooltip.frame1 = frame1
gameCooltip.frame2 = frame2
DF:FadeFrame(frame1, 0)
DF:FadeFrame(frame2, 0)
frame1.Lines = {}
frame2.Lines = {}
----------------------------------------------------------------------
--Title Function
----------------------------------------------------------------------
function gameCooltip:SetTitle(frameId, text)
if (frameId == 1) then
gameCooltip.title1 = true
gameCooltip.title_text = text
end
end
function gameCooltip:SetTitleAnchor(frameId, anchorPoint, ...)
anchorPoint = string.lower(anchorPoint)
if (frameId == 1) then
self.frame1.titleIcon:ClearAllPoints()
self.frame1.titleText:ClearAllPoints()
if (anchorPoint == "left") then
self.frame1.titleIcon:SetPoint("left", frame1, "left", ...)
self.frame1.titleText:SetPoint("left", frame1.titleIcon, "right")
elseif (anchorPoint == "center") then
self.frame1.titleIcon:SetPoint("center", frame1, "center")
self.frame1.titleIcon:SetPoint("bottom", frame1, "top")
self.frame1.titleText:SetPoint("left", frame1.titleIcon, "right")
self.frame1.titleText:Show()
self.frame1.titleIcon:Show()
elseif (anchorPoint == "right") then
self.frame1.titleIcon:SetPoint("right", frame1, "right", ...)
self.frame1.titleText:SetPoint("right", frame1.titleIcon, "left")
end
elseif (frameId == 2) then
self.frame2.titleIcon:ClearAllPoints()
self.frame2.titleText:ClearAllPoints()
if (anchorPoint == "left") then
self.frame2.titleIcon:SetPoint("left", frame2, "left", ...)
self.frame2.titleText:SetPoint("left", frame2.titleIcon, "right")
elseif (anchorPoint == "center") then
self.frame2.titleIcon:SetPoint("center", frame2, "center", ...)
self.frame2.titleText:SetPoint("left", frame2.titleIcon, "right")
elseif (anchorPoint == "right") then
self.frame2.titleIcon:SetPoint("right", frame2, "right", ...)
self.frame2.titleText:SetPoint("right", frame2.titleIcon, "left")
end
end
end
----------------------------------------------------------------------
--Button Hide and Show Functions
----------------------------------------------------------------------
local elapsedTime = 0
gameCooltip.mouseOver = false
gameCooltip.buttonClicked = false
frame1:SetScript("OnEnter", function(self)
--is cooltip a menu?
if (gameCooltip.Type ~= 1 and gameCooltip.Type ~= 2) then
gameCooltip.active = true
gameCooltip.mouseOver = true
gameCooltip.hadInteractions = true
self:SetScript("OnUpdate", nil)
DF:FadeFrame(self, 0)
if (gameCooltip.sub_menus) then
DF:FadeFrame(frame2, 0)
end
end
end)
frame2:SetScript("OnEnter", function(self)
if (gameCooltip.OptionsTable.SubMenuIsTooltip) then
return gameCooltip:Close()
end
if (gameCooltip.Type ~= 1 and gameCooltip.Type ~= 2) then
gameCooltip.active = true
gameCooltip.mouseOver = true
gameCooltip.hadInteractions = true
self:SetScript("OnUpdate", nil)
DF:FadeFrame(self, 0)
DF:FadeFrame(frame1, 0)
end
end)
local OnLeaveUpdateFrame1 = function(self, deltaTime)
elapsedTime = elapsedTime + deltaTime
if (elapsedTime > 0.7) then
if (not gameCooltip.active and not gameCooltip.buttonClicked and self == gameCooltip.Host) then
DF:FadeFrame(self, 1)
DF:FadeFrame(frame2, 1)
elseif (not gameCooltip.active) then
DF:FadeFrame(self, 1)
DF:FadeFrame(frame2, 1)
end
self:SetScript("OnUpdate", nil)
frame2:SetScript("OnUpdate", nil)
end
end
frame1:SetScript("OnLeave", function(self)
if (gameCooltip.Type ~= 1 and gameCooltip.Type ~= 2) then
gameCooltip.active = false
gameCooltip.mouseOver = false
elapsedTime = 0
self:SetScript("OnUpdate", OnLeaveUpdateFrame1)
else
gameCooltip.active = false
gameCooltip.mouseOver = false
elapsedTime = 0
self:SetScript("OnUpdate", OnLeaveUpdateFrame1)
end
end)
local OnLeaveUpdateFrame2 = function(self, deltaTime)
elapsedTime = elapsedTime + deltaTime
if (elapsedTime > 0.7) then
if (not gameCooltip.active and not gameCooltip.buttonClicked and self == gameCooltip.Host) then
DF:FadeFrame(self, 1)
DF:FadeFrame(frame2, 1)
elseif (not gameCooltip.active) then
DF:FadeFrame(self, 1)
DF:FadeFrame(frame2, 1)
end
self:SetScript("OnUpdate", nil)
frame1:SetScript("OnUpdate", nil)
end
end
frame2:SetScript("OnLeave", function(self)
if (gameCooltip.Type ~= 1 and gameCooltip.Type ~= 2) then
gameCooltip.active = false
gameCooltip.mouseOver = false
elapsedTime = 0
self:SetScript("OnUpdate", OnLeaveUpdateFrame2)
else
gameCooltip.active = false
gameCooltip.mouseOver = false
elapsedTime = 0
self:SetScript("OnUpdate", OnLeaveUpdateFrame2)
end
end)
frame1:SetScript("OnHide", function(self)
gameCooltip.active = false
gameCooltip.buttonClicked = false
gameCooltip.mouseOver = false
--reset parent and strata
frame1:SetParent(UIParent)
frame2:SetParent(UIParent)
frame1:SetFrameStrata("TOOLTIP")
frame2:SetFrameStrata("TOOLTIP")
end)
----------------------------------------------------------------------
--Button Creation Functions
----------------------------------------------------------------------
--self is the new button created
local createButtonWidgets = function(self)
self:SetSize(1, 20)
--status bar
self.statusbar = CreateFrame("StatusBar", "$Parent_StatusBar", self)
self.statusbar:SetPoint("LEFT", self, "LEFT", 10, 0)
self.statusbar:SetPoint("RIGHT", self, "RIGHT", -10, 0)
self.statusbar:SetPoint("TOP", self, "TOP", 0, 0)
self.statusbar:SetPoint("BOTTOM", self, "BOTTOM", 0, 0)
self.statusbar:SetHeight(20)
local statusbar = self.statusbar
statusbar.texture = statusbar:CreateTexture("$parent_Texture", "BACKGROUND")
statusbar.texture:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar")
statusbar.texture:SetSize(300, 14)
statusbar:SetStatusBarTexture(statusbar.texture)
statusbar:SetMinMaxValues(0, 100)
statusbar.spark = statusbar:CreateTexture("$parent_Spark", "BACKGROUND")
statusbar.spark:Hide()
statusbar.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
statusbar.spark:SetBlendMode("ADD")
statusbar.spark:SetSize(12, 24)
statusbar.spark:SetPoint("LEFT", statusbar, "RIGHT", -20, -1)
statusbar.spark.originalWidth = 12
statusbar.spark.originalHeight = 24
statusbar.spark.originalTexture = "Interface\\CastingBar\\UI-CastingBar-Spark"
statusbar.background = statusbar:CreateTexture("$parent_Background", "ARTWORK")
statusbar.background:Hide()
statusbar.background:SetTexture("Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar")
statusbar.background:SetPoint("LEFT", statusbar, "LEFT", -6, 0)
statusbar.background:SetPoint("RIGHT", statusbar, "RIGHT", 6, 0)
statusbar.background:SetPoint("TOP", statusbar, "TOP", 0, 0)
statusbar.background:SetPoint("BOTTOM", statusbar, "BOTTOM", 0, 0)
self.background = statusbar.background
statusbar.leftIcon = statusbar:CreateTexture("$parent_LeftIcon", "OVERLAY")
statusbar.leftIcon:SetSize(16, 16)
statusbar.leftIcon:SetPoint("LEFT", statusbar, "LEFT", 0, 0)
statusbar.leftIconMask = statusbar:CreateMaskTexture("$parent_LeftIconMask", "artwork")
statusbar.leftIconMask:SetAllPoints(statusbar.leftIcon)
statusbar.leftIcon:AddMaskTexture(statusbar.leftIconMask)
statusbar.rightIcon = statusbar:CreateTexture("$parent_RightIcon", "OVERLAY")
statusbar.rightIcon:SetSize(16, 16)
statusbar.rightIcon:SetPoint("RIGHT", statusbar, "RIGHT", 0, 0)
statusbar.rightIconMask = statusbar:CreateMaskTexture("$parent_RightIconMask", "artwork")
statusbar.rightIconMask:SetAllPoints(statusbar.rightIcon)
statusbar.rightIcon:AddMaskTexture(statusbar.rightIconMask)
statusbar.spark2 = statusbar:CreateTexture("$parent_Spark2", "OVERLAY")
statusbar.spark2:SetSize(32, 32)
statusbar.spark2:SetPoint("LEFT", statusbar, "RIGHT", -17, -1)
statusbar.spark2:SetBlendMode("ADD")
statusbar.spark2:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
statusbar.spark2:Hide()
statusbar.subMenuArrow = statusbar:CreateTexture("$parent_SubMenuArrow", "OVERLAY")
statusbar.subMenuArrow:SetSize(12, 12)
statusbar.subMenuArrow:SetPoint("RIGHT", statusbar, "RIGHT", 3, 0)
statusbar.subMenuArrow:SetBlendMode("ADD")
statusbar.subMenuArrow:SetTexture("Interface\\CHATFRAME\\ChatFrameExpandArrow")
statusbar.subMenuArrow:Hide()
statusbar.leftText = statusbar:CreateFontString("$parent_LeftText", "overlay", "GameFontNormal")
statusbar.leftText:SetJustifyH("LEFT")
statusbar.leftText:SetPoint("LEFT", statusbar.leftIcon, "RIGHT", 3, 0)
DF:SetFontSize(statusbar.leftText, 10)
statusbar.rightText = statusbar:CreateFontString("$parent_TextRight", "overlay", "GameFontNormal")
statusbar.rightText:SetJustifyH("RIGHT")
statusbar.rightText:SetPoint("RIGHT", statusbar.rightIcon, "LEFT", -3, 0)
DF:SetFontSize(statusbar.rightText, 10)
--background status bar
self.statusbar2 = CreateFrame("StatusBar", "$Parent_StatusBarBackground", self)
self.statusbar2:SetPoint("LEFT", self.statusbar, "LEFT")
self.statusbar2:SetPoint("RIGHT", self.statusbar, "RIGHT")
self.statusbar2:SetPoint("TOP", self.statusbar, "TOP")
self.statusbar2:SetPoint("BOTTOM", self.statusbar, "BOTTOM")
local statusbar2 = self.statusbar2
statusbar2.texture = statusbar2:CreateTexture("$parent_Texture", "BACKGROUND")
statusbar2.texture:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Skills-Bar")
statusbar2.texture:SetSize(300, 14)
statusbar2:SetStatusBarTexture(statusbar2.texture)
statusbar2:SetMinMaxValues(0, 100)
--on load
self:RegisterForClicks("LeftButtonDown")
self.leftIcon = self.statusbar.leftIcon
self.rightIcon = self.statusbar.rightIcon
self.leftIconMask = self.statusbar.leftIconMask
self.rightIconMask = self.statusbar.rightIconMask
self.texture = self.statusbar.texture
self.spark = self.statusbar.spark
self.spark2 = self.statusbar.spark2
self.leftText = self.statusbar.leftText
self.rightText = self.statusbar.rightText
self.statusbar:SetFrameLevel(self:GetFrameLevel()+2)
self.statusbar2:SetFrameLevel(self.statusbar:GetFrameLevel()-1)
self.statusbar2:SetValue(0)
--scripts
self:SetScript("OnMouseDown", GameCooltipButtonMouseDown)
self:SetScript("OnMouseUp", GameCooltipButtonMouseUp)
end
function GameCooltipButtonMouseDown(button)
local heightMod = gameCooltip.OptionsTable.TextHeightMod or 0
button.leftText:SetPoint("center", button.leftIcon, "center", 0, 0 + heightMod)
button.leftText:SetPoint("left", button.leftIcon, "right", 4, -1 + heightMod)
end
function GameCooltipButtonMouseUp(button)
local heightMod = gameCooltip.OptionsTable.TextHeightMod or 0
button.leftText:SetPoint("center", button.leftIcon, "center", 0, 0 + heightMod)
button.leftText:SetPoint("left", button.leftIcon, "right", 3, 0 + heightMod)
end
function gameCooltip:CreateButton(index, frame, name)
local newNutton = CreateFrame("Button", name, frame)
createButtonWidgets (newNutton)
frame.Lines[index] = newNutton
return newNutton
end
local OnEnterUpdateButton = function(self, deltaTime)
elapsedTime = elapsedTime + deltaTime
if (elapsedTime > 0.001) then
--search key: ~onenterupdatemain
gameCooltip:ShowSub(self.index)
gameCooltip.lastButtonInteracted = self.index
self:SetScript("OnUpdate", nil)
end
end
local OnLeaveUpdateButton = function(self, deltaTime)
elapsedTime = elapsedTime + deltaTime
if (elapsedTime > 0.7) then
if (not gameCooltip.active and not gameCooltip.buttonClicked) then
DF:FadeFrame(frame1, 1)
DF:FadeFrame(frame2, 1)
elseif (not gameCooltip.active) then
DF:FadeFrame(frame1, 1)
DF:FadeFrame(frame2, 1)
end
frame1:SetScript("OnUpdate", nil)
end
end
local OnEnterMainButton = function(self)
if (gameCooltip.Type ~= 1 and gameCooltip.Type ~= 2 and not self.isDiv) then
gameCooltip.active = true
gameCooltip.mouseOver = true
gameCooltip.hadInteractions = true
frame1:SetScript("OnUpdate", nil)
frame2:SetScript("OnUpdate", nil)
self.background:Show()
if (gameCooltip.OptionsTable.IconBlendModeHover) then
self.leftIcon:SetBlendMode(gameCooltip.OptionsTable.IconBlendModeHover)
else
self.leftIcon:SetBlendMode("BLEND")
end
if (gameCooltip.PopupFrameTable[self.index]) then
local onEnter, onLeave, param1, param2 = unpack(gameCooltip.PopupFrameTable[self.index])
if (onEnter) then
xpcall(onEnter, geterrorhandler(), frame1, param1, param2)
end
elseif (gameCooltip.IndexesSub[self.index] and gameCooltip.IndexesSub[self.index] > 0) then
if (gameCooltip.OptionsTable.SubMenuIsTooltip) then
gameCooltip:ShowSub(self.index)
self.index = self.ID
else
if (gameCooltip.lastButtonInteracted) then
gameCooltip:ShowSub(gameCooltip.lastButtonInteracted)
else
gameCooltip:ShowSub(self.index)
end
elapsedTime = 0
self.index = self.ID
self:SetScript("OnUpdate", OnEnterUpdateButton)
end
else
--hide second frame
DF:FadeFrame(frame2, 1)
gameCooltip.lastButtonInteracted = nil
end
else
gameCooltip.mouseOver = true
gameCooltip.hadInteractions = true
end
end
local OnLeaveMainButton = function(self)
if (gameCooltip.Type ~= 1 and gameCooltip.Type ~= 2 and not self.isDiv) then
gameCooltip.active = false
gameCooltip.mouseOver = false
self:SetScript("OnUpdate", nil)
self.background:Hide()
if (gameCooltip.OptionsTable.IconBlendMode) then
self.leftIcon:SetBlendMode(gameCooltip.OptionsTable.IconBlendMode)
self.rightIcon:SetBlendMode(gameCooltip.OptionsTable.IconBlendMode)
else
self.leftIcon:SetBlendMode("BLEND")
self.rightIcon:SetBlendMode("BLEND")
end
if (gameCooltip.PopupFrameTable[self.index]) then
local onEnter, onLeave, param1, param2 = unpack(gameCooltip.PopupFrameTable[self.index])
if (onLeave) then
xpcall(onLeave, geterrorhandler(), frame1, param1, param2)
end
end
elapsedTime = 0
frame1:SetScript("OnUpdate", OnLeaveUpdateButton)
else
gameCooltip.active = false
elapsedTime = 0
frame1:SetScript("OnUpdate", OnLeaveUpdateButton)
gameCooltip.mouseOver = false
end
end
--serach key: ~onenter
function gameCooltip:CreateMainFrameButton(i)
local newButton = gameCooltip:CreateButton(i, frame1, "GameCooltipMainButton" .. i)
newButton.ID = i
newButton:SetScript("OnEnter", OnEnterMainButton)
newButton:SetScript("OnLeave", OnLeaveMainButton)
return newButton
end
--buttons for the secondary frame
local OnLeaveUpdateButtonSec = function(self, deltaTime)
elapsedTime = elapsedTime + deltaTime
if (elapsedTime > 0.7) then
if (not gameCooltip.active and not gameCooltip.buttonClicked) then
DF:FadeFrame(frame1, 1)
DF:FadeFrame(frame2, 1)
elseif (not gameCooltip.active) then
DF:FadeFrame(frame1, 1)
DF:FadeFrame(frame2, 1)
end
frame2:SetScript("OnUpdate", nil)
end
end
local OnEnterSecondaryButton = function(self)
if (gameCooltip.OptionsTable.SubMenuIsTooltip) then
return gameCooltip:Close()
end
if (gameCooltip.Type ~= 1 and gameCooltip.Type ~= 2 and not self.isDiv) then
gameCooltip.active = true
gameCooltip.mouseOver = true
gameCooltip.hadInteractions = true
self.background:Show()
if (gameCooltip.OptionsTable.IconBlendModeHover) then
self.leftIcon:SetBlendMode(gameCooltip.OptionsTable.IconBlendModeHover)
else
self.leftIcon:SetBlendMode("BLEND")
end
frame1:SetScript("OnUpdate", nil)
frame2:SetScript("OnUpdate", nil)
DF:FadeFrame(frame1, 0)
DF:FadeFrame(frame2, 0)
else
gameCooltip.mouseOver = true
gameCooltip.hadInteractions = true
end
end
local OnLeaveSecondaryButton = function(self)
if (gameCooltip.Type ~= 1 and gameCooltip.Type ~= 2) then
gameCooltip.active = false
gameCooltip.mouseOver = false
self.background:Hide()
if (gameCooltip.OptionsTable.IconBlendMode) then
self.leftIcon:SetBlendMode(gameCooltip.OptionsTable.IconBlendMode)
self.rightIcon:SetBlendMode(gameCooltip.OptionsTable.IconBlendMode)
else
self.leftIcon:SetBlendMode("BLEND")
self.rightIcon:SetBlendMode("BLEND")
end
elapsedTime = 0
frame2:SetScript("OnUpdate", OnLeaveUpdateButtonSec)
else
gameCooltip.active = false
gameCooltip.mouseOver = false
elapsedTime = 0
frame2:SetScript("OnUpdate", OnLeaveUpdateButtonSec)
end
end
function gameCooltip:CreateButtonOnSecondFrame(i)
local newButton = gameCooltip:CreateButton(i, frame2, "GameCooltipSecButton" .. i)
newButton.ID = i
newButton:SetScript("OnEnter", OnEnterSecondaryButton)
newButton:SetScript("OnLeave", OnLeaveSecondaryButton)
return newButton
end
----------------------------------------------------------------------
--Button Click Functions
----------------------------------------------------------------------
gameCooltip.selectedAnchor.left = 4
gameCooltip.selectedAnchor.right = -4
gameCooltip.selectedAnchor.top = 0
gameCooltip.selectedAnchor.bottom = 0
function gameCooltip:HideSelectedTexture(frame)
frame.selectedTop:Hide()
frame.selectedBottom:Hide()
frame.selectedMiddle:Hide()
end
function gameCooltip:ShowSelectedTexture(frame)
frame.selectedTop:Show()
frame.selectedBottom:Show()
frame.selectedMiddle:Show()
end
function gameCooltip:SetSelectedAnchor(frame, button)
local left = gameCooltip.selectedAnchor.left + (gameCooltip.OptionsTable.SelectedLeftAnchorMod or 0)
local right = gameCooltip.selectedAnchor.right + (gameCooltip.OptionsTable.SelectedRightAnchorMod or 0)
local top = gameCooltip.selectedAnchor.top + (gameCooltip.OptionsTable.SelectedTopAnchorMod or 0)
local bottom = gameCooltip.selectedAnchor.bottom + (gameCooltip.OptionsTable.SelectedBottomAnchorMod or 0)
frame.selectedTop:ClearAllPoints()
frame.selectedBottom:ClearAllPoints()
frame.selectedTop:SetPoint("topleft", button, "topleft", left+1, top)
frame.selectedTop:SetPoint("topright", button, "topright", right-1, top)
frame.selectedBottom:SetPoint("bottomleft", button, "bottomleft", left+1, bottom)
frame.selectedBottom:SetPoint("bottomright", button, "bottomright", right-1, bottom)
gameCooltip:ShowSelectedTexture(frame)
end
local OnClickFunctionMainButton = function(self, button)
if (gameCooltip.IndexesSub[self.index] and gameCooltip.IndexesSub[self.index] > 0) then
gameCooltip:ShowSub(self.index)
gameCooltip.lastButtonInteracted = self.index
end
gameCooltip.buttonClicked = true
gameCooltip:SetSelectedAnchor(frame1, self)
if (not gameCooltip.OptionsTable.NoLastSelectedBar) then
gameCooltip:ShowSelectedTexture(frame1)
end
gameCooltip.SelectedIndexMain = self.index
if (gameCooltip.FunctionsTableMain[self.index]) then
local parameterTable = gameCooltip.ParametersTableMain[self.index]
local func = gameCooltip.FunctionsTableMain[self.index]
local okay, errortext = xpcall(func, geterrorhandler(), gameCooltip.Host, gameCooltip.FixedValue, parameterTable[1], parameterTable[2], parameterTable[3], button)
if (not okay) then