forked from Nonameby/Atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAtlasButton.lua
85 lines (69 loc) · 2.21 KB
/
AtlasButton.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
--[[
Atlas, a World of Warcraft instance map browser
Email me at [email protected]
This file is part of Atlas.
Atlas is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Atlas is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Atlas; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--]]
function AtlasButton_OnClick()
Atlas_Toggle();
end
function AtlasButton_Init()
if (AtlasOptions.AtlasButtonShown) then
AtlasButtonFrame:Show();
else
AtlasButtonFrame:Hide();
end
end
function AtlasButton_Toggle()
if (AtlasButtonFrame:IsVisible()) then
AtlasButtonFrame:Hide();
AtlasOptions.AtlasButtonShown = false;
else
AtlasButtonFrame:Show();
AtlasOptions.AtlasButtonShown = true;
end
AtlasOptions_Init();
end
function AtlasButton_UpdatePosition()
AtlasButtonFrame:SetPoint(
"TOPLEFT",
"Minimap",
"TOPLEFT",
54 - (AtlasOptions.AtlasButtonRadius * cos(AtlasOptions.AtlasButtonPosition)),
(AtlasOptions.AtlasButtonRadius * sin(AtlasOptions.AtlasButtonPosition)) - 55
);
AtlasOptions_Init();
end
-- Thanks to Yatlas for this code
function AtlasButton_BeingDragged()
-- Thanks to Gello for this code
local xpos, ypos = GetCursorPosition()
local xmin, ymin = Minimap:GetLeft(), Minimap:GetBottom()
xpos = xmin - xpos / UIParent:GetScale() + 70
ypos = ypos / UIParent:GetScale() - ymin - 70
AtlasButton_SetPosition(math.deg(math.atan2(ypos, xpos)));
end
function AtlasButton_SetPosition(v)
if (v < 0) then
v = v + 360;
end
AtlasOptions.AtlasButtonPosition = v;
AtlasButton_UpdatePosition();
end
function AtlasButton_OnEnter()
GameTooltip:SetOwner(this, "ANCHOR_LEFT");
GameTooltip:SetText("Atlas");
GameTooltipTextLeft1:SetTextColor(1, 1, 1);
GameTooltip:AddLine(ATLAS_BUTTON_TOOLTIP_HINT);
GameTooltip:Show();
end