-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlizzMovePlugin_QuestTracker.lua
More file actions
104 lines (93 loc) · 3.5 KB
/
Copy pathBlizzMovePlugin_QuestTracker.lua
File metadata and controls
104 lines (93 loc) · 3.5 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
-- upvalue the globals
local CreateFrame = CreateFrame;
local ObjectiveTrackerFrame = ObjectiveTrackerFrame;
local QuestWatchFrame = QuestWatchFrame;
local WatchFrame = WatchFrame;
--- @type BlizzMoveAPI
local BlizzMoveAPI = BlizzMoveAPI;
local print = print;
local IsAddOnLoaded = C_AddOns.IsAddOnLoaded;
local name, Plugin = ...;
local frame = CreateFrame('Frame');
frame:HookScript('OnEvent', function(_, _, addonName) Plugin:ADDON_LOADED(addonName); end);
frame:RegisterEvent('ADDON_LOADED');
function Plugin:CreateMoveHandleAtPoint(parentFrame, anchorPoint, relativePoint, offX, offY)
if (not parentFrame) then return nil; end
local handleFrame = CreateFrame('Frame', nil, parentFrame);
handleFrame:SetPoint(anchorPoint, parentFrame, relativePoint, offX, offY);
handleFrame:SetHeight(16);
handleFrame:SetWidth(16);
handleFrame:SetFrameStrata(parentFrame:GetFrameStrata());
handleFrame:SetClampedToScreen(true);
handleFrame:SetClampRectInsets(0, 0, 0, 0);
handleFrame.texture = handleFrame:CreateTexture();
handleFrame.texture:SetTexture('Interface/Buttons/UI-Panel-BiggerButton-Up');
handleFrame.texture:SetTexCoord(0.15, 0.85, 0.15, 0.85);
handleFrame.texture:SetAllPoints();
return handleFrame;
end
function Plugin:ADDON_LOADED(addonName)
if (addonName == 'BlizzMove' or (addonName == name and IsAddOnLoaded('BlizzMove'))) then
local compatible = false;
if(BlizzMoveAPI and BlizzMoveAPI.GetVersion and BlizzMoveAPI.RegisterAddOnFrames) then
local _, _, _, _, versionInt = BlizzMoveAPI:GetVersion()
if (versionInt == nil or versionInt >= 30200) then
compatible = true;
end
end
if(not compatible) then
print(name .. ' is not compatible with the current version of BlizzMove, please update.')
return;
end
local frameName;
if (ObjectiveTrackerFrame) then
frameName = 'ObjectiveTrackerFrame';
self.MoveHandleFrame = self:CreateMoveHandleAtPoint(
ObjectiveTrackerFrame,
'CENTER',
'TOPRIGHT',
5,
-5
);
elseif (QuestWatchFrame) then
frameName = 'QuestWatchFrame';
self.MoveHandleFrame = self:CreateMoveHandleAtPoint(
QuestWatchFrame,
'CENTER',
'TOPRIGHT',
-10,
0
);
elseif (WatchFrame) then
frameName = 'WatchFrame';
self.MoveHandleFrame = self:CreateMoveHandleAtPoint(
WatchFrame,
'CENTER',
'TOPRIGHT',
-10,
0
);
WatchFrame:SetHeight(WatchFrame:GetHeight());
end
BlizzMoveAPI:RegisterAddOnFrames({
[name] = {
[frameName] = {
IgnoreMouse = true,
ForcePosition = true,
SubFrames = {
['BlizzMovePlugin-QuestTrackerButton'] = {
FrameReference = self.MoveHandleFrame,
IgnoreClamping = true,
},
},
},
},
});
EventRegistry:RegisterCallback('EditMode.Exit', Plugin.OnEditModeExit, Plugin);
end
end
function Plugin:OnEditModeExit()
if (self.MoveHandleFrame) then
self.MoveHandleFrame:GetParent():SetMovable(true);
end
end