-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapi.lua
More file actions
52 lines (41 loc) · 1.54 KB
/
Copy pathapi.lua
File metadata and controls
52 lines (41 loc) · 1.54 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
--- @class DialogKeyNS
local ns = select(2, ...);
_G.DialogKeyAPI = {};
--- @class DialogKeyAPI
local DialogKeyAPI = _G.DialogKeyAPI;
ns.API = DialogKeyAPI;
DialogKeyAPI.Enum = {}
--- @enum DialogKeyAPI.Enum.FrameType
DialogKeyAPI.Enum.FrameType = {
Popup = "Popup",
CraftingOrder = "CraftingOrder",
CustomFrame = "CustomFrame",
AuctionHouse = "AuctionHouse",
PlayerChoice = "PlayerChoice",
SpecFrame = "SpecFrame",
Quest = "Quest",
Gossip = "Gossip",
};
--- Register a custom button for
--- @param frameType DialogKeyAPI.Enum.FrameType
--- @param button Button|fun():Button|nil
function DialogKeyAPI:RegisterAddonFrame(frameType, button)
if (not self.Enum.FrameType[frameType]) then
error('Invalid frame type: ' .. tostring(frameType));
end
if (not button or (type(button) ~= "function" and not button:IsObjectType("Button"))) then
error("'button' must be a Button object or a function that returns a Button or nil.");
end
ns.Core:RegisterAddonFrame(frameType, button);
end
--- @param frameType DialogKeyAPI.Enum.FrameType
--- @param button Button|fun():Button|nil
function DialogKeyAPI:UnregisterAddonFrame(frameType, button)
if (not self.Enum.FrameType[frameType]) then
error('Invalid frame type: ' .. tostring(frameType));
end
if (not button or (type(button) ~= "function" and not button:IsObjectType("Button"))) then
error("'button' must be a Button object or a function that returns a Button or nil.");
end
ns.Core:UnregisterAddonFrame(frameType, button);
end