-
Notifications
You must be signed in to change notification settings - Fork 1
/
DataBroker.lua
58 lines (52 loc) · 2.04 KB
/
DataBroker.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
local ADDON_NAME, Internal = ...
local External = _G[ADDON_NAME]
local L = Internal.L
local ldb = LibStub("LibDataBroker-1.1")
local ldbi = LibStub("LibDBIcon-1.0")
local dataBroker = ldb:NewDataObject(ADDON_NAME, {
type = "launcher",
label = ADDON_NAME,
icon = 3586266,
OnClick = function(clickedframe, button)
if button == "LeftButton" then
if IsShiftKeyDown() then
External.RunAction(BtWTodoDataBroker.shiftLeftClickAction)
else
External.RunAction(BtWTodoDataBroker.leftClickAction)
end
else
External.RunAction(BtWTodoDataBroker.rightClickAction)
end
end,
OnEnter = function(button)
local show = not BtWTodoDataBroker.hideTooltip
if InterfaceOptionsFrame and InterfaceOptionsFrame:IsShown() then
show = BtWTodoConfigPanel.MinimapTooltipButton:GetChecked()
elseif SettingsPanel and SettingsPanel:IsShown() then
show = BtWTodoConfigPanel.MinimapTooltipButton:GetChecked()
end
if show then
BtWTodoTooltipFrame:ClearAllPoints()
BtWTodoTooltipFrame:SetPoint("TOPRIGHT", button, "TOPLEFT")
BtWTodoTooltipFrame:Show()
end
end,
OnLeave = function()
BtWTodoTooltipFrame:Hide()
end,
})
local function ADDON_LOADED(_, addon)
if addon == ADDON_NAME then
if not BtWTodoDataBroker then
BtWTodoDataBroker = {}
end
-- defaults
if not BtWTodoDataBroker.leftClickAction then BtWTodoDataBroker.leftClickAction = "toggleWindow:main" end
if not BtWTodoDataBroker.shiftLeftClickAction then BtWTodoDataBroker.shiftLeftClickAction = "toggleWindow:small" end
if not BtWTodoDataBroker.rightClickAction then BtWTodoDataBroker.rightClickAction = "openConfig" end
ldbi:Register(ADDON_NAME, dataBroker, BtWTodoDataBroker)
ldbi:Refresh(ADDON_NAME)
Internal.UnregisterEvent("ADDON_LOADED", ADDON_LOADED)
end
end
Internal.RegisterEvent("ADDON_LOADED", ADDON_LOADED)