-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBootstrap.lua
More file actions
125 lines (100 loc) · 3.37 KB
/
Copy pathBootstrap.lua
File metadata and controls
125 lines (100 loc) · 3.37 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
local addonName, addonTable = ...
local L = LibStub("AceLocale-3.0"):GetLocale("TaskManager")
local addon = LibStub("AceAddon-3.0"):NewAddon("TaskManager", "AceEvent-3.0")
addonTable.addon = addon
----------------------------
-- Addon Lifecycle functions
----------------------------
function addon:OnInitialize()
addon.guid = UnitGUID("player") -- cache guid call
-- TODO back up config in case of crash?
-- TODO and/or use import strings so people can share QuestIDs they find
if not TM_TASKS then TM_TASKS = {} end
if not TM_STATUS then TM_STATUS = {} end
if not TM_COLLAPSED then TM_COLLAPSED = {} end
if not TM_WINDOW then TM_WINDOW = { width = 333, height = 500 } end
LibStub:GetLibrary("LibDataBroker-1.1"):NewDataObject(L["Title"], {
type = "launcher",
icon = "Interface\\Icons\\inv_10_inscription_illusoryspellscrolls_color10",
OnClick = function(frame, buttonName) TM_AddonCompartmentFunc(addonName, buttonName) end
})
end
function addon:OnEnable()
addon.guid = UnitGUID("player") -- just in case init didn't work
-- in an ideal world, we could listen for specific events and update only relevant data
-- for now, it is WAY more straightforward to just update all data on a timer
if TM_TIMER then TM_TIMER:Cancel() end
TM_TIMER = C_Timer.NewTicker(1, function()
--local start = debugprofilestop()
if not InCombatLockdown() then
addon:PurgeExpired() -- could be daily
local changed = addon:UpdateAll()
if changed then addon:RefreshWindow() end
end
--local finish = debugprofilestop()
--print(finish - start)
end)
end
function addon:OnDisable()
if TM_TIMER then TM_TIMER:Cancel() end
TM_TIMER = nil
addon:UpdateAll()
end
-----------------
-- Minimap button
-----------------
function TM_AddonCompartmentFunc(addonName, buttonName, menuButtonFrame)
if TM_FRAME and TM_FRAME:IsShown() then
TM_FRAME:Hide()
else
addon:ShowWindow()
end
end
------------------
-- Slash commands
------------------
local commands = {}
SLASH_TASKMANAGER1 = "/taskmanager"
SLASH_TASKMANAGER2 = "/task"
SlashCmdList.TASKMANAGER = function(msg)
local tokens = {}
for token in string.gmatch(msg, "(%w+)") do
table.insert(tokens, token)
end
if not tokens[1] then tokens[1] = "show" end
local command = commands[tokens[1]]
if command then
command(tokens)
else
print("Unknown command")
-- TODO show list of commands
end
end
commands.show = function(tokens)
addon:ShowWindow()
end
commands.hide = function(tokens)
if TM_FRAME then TM_FRAME:Hide() end
end
commands.debug = function(tokens)
local entry = TM_STATUS[addon.guid][tokens[2]]
print(date("%m/%d/%y %H:%M:%S", entry.expires))
end
commands.wod = function(tokens)
ShowGarrisonLandingPage(Enum.GarrisonType.Type_6_0_Garrison)
end
commands.legion = function(tokens)
ShowGarrisonLandingPage(Enum.GarrisonType.Type_7_0_Garrison)
end
commands.bfa = function(tokens)
ShowGarrisonLandingPage(Enum.GarrisonType.Type_8_0_Garrison)
end
commands.sl = function(tokens)
ShowGarrisonLandingPage(Enum.GarrisonType.Type_9_0_Garrison)
end
commands.cloak = function(tokens)
GenericTraitUI_LoadUI()
GenericTraitFrame:SetSystemID(29)
GenericTraitFrame:SetTreeID(1115)
ToggleFrame(GenericTraitFrame)
end