forked from CoreLootManager/CoreLootManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinimapIcon.lua
120 lines (107 loc) · 3.49 KB
/
MinimapIcon.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
local _, CLM = ...
local addonName = "Classic Loot Manager"
local ldb = LibStub:GetLibrary("LibDataBroker-1.1", true)
if not ldb then return end
local icon = LibStub("LibDBIcon-1.0", true)
if not icon then return end
CLM.MinimapDBI = ldb:NewDataObject(addonName, {
type = "data source",
text = "0",
icon = "Interface\\AddOns\\ClassicLootManager\\Media\\Icons\\clm-sync-32.tga"
})
-- Minimap icon dropdown menu
local dropdown
local Minimap = {}
function Minimap:Initialize()
local options = {
{
title = "Menu",
isTitle = true
},
{
title = "Standings",
func = (function() CLM.GUI.Standings:Toggle() end)
},
{
title = "Loot History",
func = (function() CLM.GUI.Loot:Toggle() end)
},
{
title = "Point History",
func = (function() CLM.GUI.PointHistory:Toggle() end)
},
{
title = "Bidding",
func = (function() CLM.GUI.BiddingManager:Toggle() end)
},
{
title = "Auctioning",
func = (function() CLM.GUI.AuctionManager:Toggle() end),
trustedOnly = true
},
{
title = "Raid",
func = (function() CLM.GUI.RaidManager:Toggle() end),
trustedOnly = true
},
{
title = "Profiles",
func = (function() CLM.GUI.Profiles:Toggle() end),
trustedOnly = true
},
{
title = "Configuration",
icon = "Interface\\AddOns\\ClassicLootManager\\Media\\Icons\\clm-ok-32.tga",
func = (function()
InterfaceOptionsFrame_OpenToCategory(addonName)
InterfaceOptionsFrame_OpenToCategory(addonName)
end)
},
}
dropdown = CLM.UTILS.GenerateDropDownMenu(options, CLM.MODULES.ACL:IsTrusted())
self._initialized = true
end
function Minimap:IsInitialized()
return self._initialized
end
function CLM.MinimapDBI.OnClick(self, button)
if button == "RightButton" then
if Minimap:IsInitialized() then
CLM.UTILS.LibDD:ToggleDropDownMenu(1, nil, dropdown, self, -20, 0)
end
else
CLM.GUI.Standings:Toggle()
end
end
do
function CLM.MinimapDBI.OnTooltipShow(tooltip)
local info
tooltip:AddDoubleLine(addonName, CLM.CORE:GetVersionString())
if CLM.MODULES.LedgerManager:IsInitialized() then
local lag = CLM.MODULES.LedgerManager:Lag()
local count = CLM.MODULES.LedgerManager:Length()
-- hash = CLM.MODULES.LedgerManager:Hash()
if lag > 0 then
info = string.format("%s events (%s pending)", count, lag)
else
info = string.format("%s events", count)
end
else
info = string.format("Loading events...")
end
if CLM.MODULES.LedgerManager:IsInSync() then
tooltip:AddDoubleLine("In-Sync", info, 0.0, 0.8, 0.0)
elseif CLM.MODULES.LedgerManager:IsSyncOngoing() then
tooltip:AddDoubleLine("Sync ongoing", info, 0.6, 0.0, 0.0)
else -- Unknown state
tooltip:AddDoubleLine("Unknown sync state", info, 0.4, 0.6, 1)
end
end
end
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function()
if not CLM_MinimapIcon then CLM_MinimapIcon = {} end
icon:Register(addonName, CLM.MinimapDBI, CLM_MinimapIcon)
end)
f:RegisterEvent("PLAYER_LOGIN")
CLM.MODULES.Minimap = Minimap