forked from funkydude/BugSack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ldb.lua
69 lines (61 loc) · 1.85 KB
/
ldb.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
local addonName, addon = ...
if not addon.healthCheck then return end
local L = addon.L
local ldb = LibStub:GetLibrary("LibDataBroker-1.1", true)
if not ldb then return end
local plugin = ldb:NewDataObject(addonName, {
type = "data source",
text = "0",
icon = "Interface\\AddOns\\"..addonName.."\\Media\\icon",
})
local BugGrabber = BugGrabber
function plugin.OnClick(self, button)
if button == "RightButton" then
if InterfaceOptionsFrame_OpenToCategory then
InterfaceOptionsFrame_OpenToCategory(addonName)
InterfaceOptionsFrame_OpenToCategory(addonName)
else
Settings.OpenToCategory(addon.settingsCategory.ID)
end
else
if IsShiftKeyDown() then
ReloadUI()
elseif IsAltKeyDown() and (addon.db.altwipe == true) then
addon:Reset()
elseif BugSackFrame and BugSackFrame:IsShown() then
addon:CloseSack()
else
addon:OpenSack()
end
end
end
hooksecurefunc(addon, "UpdateDisplay", function()
local count = #addon:GetErrors(BugGrabber:GetSessionId())
plugin.text = count
plugin.icon = count == 0 and "Interface\\AddOns\\"..addonName.."\\Media\\icon" or "Interface\\AddOns\\"..addonName.."\\Media\\icon_red"
end)
do
local line = "%d. %s (x%d)"
function plugin.OnTooltipShow(tt)
local errs = addon:GetErrors(BugGrabber:GetSessionId())
if #errs == 0 then
tt:AddLine(L["You have no bugs, yay!"])
else
tt:AddLine(addonName)
for i, err in next, errs do
tt:AddLine(line:format(i, addon.ColorStack(err.message), err.counter), .5, .5, .5)
if i > 8 then break end
end
end
tt:AddLine(" ")
tt:AddLine(L.minimapHint, 0.2, 1, 0.2, 1)
end
end
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function()
local icon = LibStub("LibDBIcon-1.0", true)
if not icon then return end
if not BugSackLDBIconDB then BugSackLDBIconDB = {} end
icon:Register(addonName, plugin, BugSackLDBIconDB)
end)
f:RegisterEvent("PLAYER_LOGIN")