-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathUtils.lua
137 lines (108 loc) · 3.36 KB
/
Utils.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
--Similar to UIFrameFadeIn
--Hide the frame in the end.
--Shows the frame if it's not protected - important when touching protected frames.
--It also sets the alpha to "1" after hiding.
--frame: frame to fade in/out
--duration: time that takes the animation
--startAlpha: starting alpha
--endAlpha: ending alpha
--hideEnd: if true, hides the frame in the end.
local frameFadeManager = CreateFrame("FRAME");
local queueFrame = {};
local size = 0;
local GetTime = GetTime;
function frameFade(frame, duration, startAlpha, endAlpha, hideEnd)
if(size > 0) then
if(not queueFrame[frame]) then
size = size + 1;
end
queueFrame[frame] = { GetTime(), GetTime()+duration, duration, startAlpha, endAlpha, hideEnd};
frame:SetAlpha(startAlpha);
if(not frame:IsProtected()) then
frame:Show();
end
return;
end
local currentTime, newAlpha;
size = 1;
queueFrame[frame] = { GetTime(), GetTime()+duration, duration, startAlpha, endAlpha, hideEnd};
if(not frame:IsProtected()) then
frame:Show();
end
frameFadeManager:SetScript("OnUpdate", function(self, elapsed)
currentTime = GetTime();
for frame, animationInfo in pairs(queueFrame) do
local startTime, endTime, duration, startAlpha, endAlpha, hideEnd = unpack(animationInfo);
--setting new alpha
local timeElapsed = currentTime - startTime;
newAlpha = endAlpha*(timeElapsed/duration) + startAlpha*((endTime - currentTime)/duration);
frame:SetAlpha(newAlpha);
if(currentTime > endTime) then
frame:SetAlpha(endAlpha);
if(hideEnd and not frame:IsProtected()) then
frame:Hide();
frame:SetAlpha(1);
end
queueFrame[frame] = nil;
size = size - 1;
if(size == 0) then
self:SetScript("OnUpdate", nil);
end
end
end
end);
end
function cancelFade(frame)
queueFrame[frame] = nil;
end
function isFrameFading(frame)
return queueFrame[frame];
end
---UPDATED Blizzard tooltip func - used on CatchTheWind.xml
function CTW_GameTooltip_ShowCompareItem(self, shift)
GameTooltip_ShowCompareItem(self,shift);
local shoppingTooltip1, shoppingTooltip2 = unpack(self.shoppingTooltips);
if(CatchTheWind:IsShown() and shoppingTooltip2:IsShown()) then
local item, link = self:GetItem();
local side = "left";
local rightDist = 0;
local leftPos = self:GetLeft();
local rightPos = self:GetRight();
if ( not rightPos ) then
rightPos = 0;
end
if ( not leftPos ) then
leftPos = 0;
end
rightDist = GetScreenWidth() - rightPos;
if (leftPos and (rightDist < leftPos)) then
side = "left";
else
side = "right";
end
--setting up shoppingTooltip1's position
shoppingTooltip1:SetOwner(self, "ANCHOR_NONE");
shoppingTooltip1:ClearAllPoints();
if ( side and side == "left" ) then
shoppingTooltip1:SetPoint("TOPRIGHT", self, "TOPLEFT", 0, -10);
else
shoppingTooltip1:SetPoint("TOPLEFT", self, "TOPRIGHT", 0, -10);
end
shoppingTooltip1:SetHyperlinkCompareItem(link, 1, shift, self);
shoppingTooltip1:Show();
--setting up shoppingTooltip2's position
shoppingTooltip2:SetOwner(shoppingTooltip1, "ANCHOR_TOP");
shoppingTooltip2:SetHyperlinkCompareItem(link, 2, shift, self);
shoppingTooltip2:Show();
end
end
function CTW_DressUpItemLink(link)
if ( not link or not IsDressableItem(link) ) then
return;
end
if ( not CTWDressUpModel:IsShown() ) then
CTWDressUpModel:Show();
CTWDressUpModel:SetUnit("player");
end
CTWDressUpModel:TryOn(link);
end