vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 ZOOMMAPPING_TIMER = 5;
2 ZOOMMAPPING_FADE_TIMER = 0.5;
3 CURSOR_OFFSET_X = -7;
4 CURSOR_OFFSET_Y = -9;
5  
6 function ZoomMap_OnLoad()
7 ZoomMapPing.fadeOut = nil;
8 this:SetSequence(0);
9 this:RegisterEvent("MINIMAP_PING");
10 this:RegisterEvent("MINIMAP_UPDATE_ZOOM");
11 ZoomMapCluster:Hide();
12 end
13  
14 function ToggleZoomMap(show)
15 if(ZoomMapCluster:IsVisible() or show == 0) then
16 PlaySound("igMiniMapClose");
17 ZoomMapCluster:Hide();
18 Minimap:Show();
19  
20 if(Minimap:GetZoom() == 0) then
21 Minimap:SetZoom(Minimap:GetZoom()+1);
22 Minimap:SetZoom(Minimap:GetZoom()-1);
23 else
24 Minimap:SetZoom(Minimap:GetZoom()-1);
25 Minimap:SetZoom(Minimap:GetZoom()+1);
26 end
27  
28 else
29 PlaySound("igMiniMapOpen");
30 Minimap:Hide();
31 ZoomMapCluster:Show();
32  
33 if(ZoomMap:GetZoom() == 0) then
34 ZoomMap:SetZoom(ZoomMap:GetZoom()+1);
35 ZoomMap:SetZoom(ZoomMap:GetZoom()-1);
36 else
37 ZoomMap:SetZoom(ZoomMap:GetZoom()-1);
38 ZoomMap:SetZoom(ZoomMap:GetZoom()+1);
39 end
40  
41  
42 end
43 end
44  
45  
46  
47 function ZoomMap_Update()
48  
49 end
50  
51 function ZoomMap_OnEvent()
52 if ( event == "MINIMAP_PING" ) then
53 ZoomMap_SetPing(arg2, arg3, 1);
54 ZoomMap.timer = MINIMAPPING_TIMER;
55 elseif ( event == "MINIMAP_UPDATE_ZOOM" ) then
56 ZoomMapZoomIn:Enable();
57 ZoomMapZoomOut:Enable();
58 local zoom = ZoomMap:GetZoom();
59 if ( zoom == (ZoomMap:GetZoomLevels() - 1) ) then
60 ZoomMapZoomIn:Disable();
61 elseif ( zoom == 0 ) then
62 ZoomMapZoomOut:Disable();
63 end
64 end
65 end
66  
67 function ZoomMap_OnUpdate(elapsed)
68 if ( ZoomMap.timer > 0 ) then
69 ZoomMap.timer = ZoomMap.timer - elapsed;
70 if ( ZoomMap.timer <= 0 ) then
71 ZoomMapPing_FadeOut();
72 else
73 ZoomMap_SetPing(ZoomMap:GetPingPosition());
74 end
75 elseif ( ZoomMapPing.fadeOut ) then
76 ZoomMapPing.fadeOutTimer = ZoomMapPing.fadeOutTimer - elapsed;
77 if ( ZoomMapPing.fadeOutTimer > 0 ) then
78 ZoomMapPing:SetAlpha(255 * (ZoomMapPing.fadeOutTimer/ZOOMMAPPING_FADE_TIMER))
79 else
80 ZoomMapPing.fadeOut = nil;
81 ZoomMapPing:Hide();
82 end
83 end
84 end
85  
86 function ZoomMap_SetPing(x, y, playSound)
87 x = x * ZoomMap:GetWidth();
88 y = y * ZoomMap:GetHeight();
89  
90 if ( sqrt(x * x + y * y) < (ZoomMap:GetWidth() / 2) ) then
91 ZoomMapPing:SetPoint("CENTER", "ZoomMap", "CENTER", x, y);
92 ZoomMapPing:SetAlpha(255);
93 ZoomMapPing:Show();
94 if ( playSound ) then
95 PlaySound("MapPing");
96 end
97 else
98 ZoomMapPing:Hide();
99 end
100  
101 end
102  
103 function ZoomMapPing_FadeOut()
104 ZoomMapPing.fadeOut = 1;
105 ZoomMapPing.fadeOutTimer = ZOOMMAPPING_FADE_TIMER;
106 end
107  
108 function ZoomMap_ZoomInClick()
109 ZoomMapZoomOut:Enable();
110 PlaySound("igMiniMapZoomIn");
111 ZoomMap:SetZoom(ZoomMap:GetZoom() + 1);
112 if(ZoomMap:GetZoom() == (ZoomMap:GetZoomLevels() - 1)) then
113 ZoomMapZoomIn:Disable();
114 end
115 end
116  
117 function ZoomMap_ZoomOutClick()
118 ZoomMapZoomIn:Enable();
119 PlaySound("igMiniMapZoomOut");
120 ZoomMap:SetZoom(ZoomMap:GetZoom() - 1);
121 if(ZoomMap:GetZoom() == 0) then
122 ZoomMapZoomOut:Disable();
123 end
124 end
125  
126 function ZoomMap_OnClick()
127 local x, y = GetCursorPosition();
128 x = x / this:GetScale();
129 y = y / this:GetScale();
130  
131 local cx, cy = this:GetCenter();
132 x = x + CURSOR_OFFSET_X - cx;
133 y = y + CURSOR_OFFSET_Y - cy;
134 if ( sqrt(x * x + y * y) < (this:GetWidth() / 2) ) then
135 ZoomMap:PingLocation(x, y);
136 end
137 end
138  
139 function ZoomMap_ZoomIn()
140 ZoomMapZoomIn:Click();
141 end
142  
143 function ZoomMap_ZoomOut()
144 ZoomMapZoomOut:Click();
145 end