-
Notifications
You must be signed in to change notification settings - Fork 10
/
Core.lua
85 lines (61 loc) · 2.48 KB
/
Core.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
--[[----------------------------------------------------------------------------
LiteMount/Core.lua
Addon core.
Copyright 2011 Mike Battersby
LiteMount is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License, version 2, as published by
the Free Software Foundation.
LiteMount is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
The file LICENSE.txt included with LiteMount contains a copy of the
license. If the LICENSE.txt file is missing, you can find a copy at
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
----------------------------------------------------------------------------]]--
local _, LM = ...
-- This is still a SecureActionButton for backwards compatibility with
-- people's macros with /click LiteMount in them.
_G.LiteMount = LM.CreateAutoEventFrame("Button", "LiteMount", UIParent, "SecureActionButtonTemplate")
LiteMount:RegisterEvent("PLAYER_LOGIN")
LiteMount.LM = LM
function LiteMount:Initialize()
-- Do this first because LM.Debug doesn't work until it's loaded.
LM.Options:Initialize()
local version = C_AddOns.GetAddOnMetadata("LiteMount", "Version") or "UNKNOWN"
LM.Debug("Initializing LiteMount v%s, debugging enabled.", version)
LM.MountRegistry:Initialize()
SlashCmdList["LiteMount"] = LM.SlashCommandFunc
_G.SLASH_LiteMount1 = "/litemount"
_G.SLASH_LiteMount2 = "/lmt"
-- Create SecureActionButtons
self.actions = { }
for i = 1,4 do
self.actions[i] = LM.ActionButton:Create(i)
end
-- Backwards-compatibility SecureActionButton setup so you can do
-- still do /click LiteMount if you had it in a macro.
self:SetAttribute("type", "click")
for i = 1,#self.actions do
self:SetAttribute("*clickbutton"..i, self.actions[i])
end
-- Setup actions for the initial profile
LM.Options:OnProfile()
end
function LiteMount:PLAYER_LOGIN()
self:UnregisterEvent("PLAYER_LOGIN")
-- We might login already in combat.
if InCombatLockdown() then
self:RegisterEvent("PLAYER_REGEN_ENABLED")
else
self:Initialize()
end
end
function LiteMount:PLAYER_REGEN_ENABLED()
LM.Debug("Got event PLAYER_REGEN_ENABLED")
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
self:Initialize()
end
--@debug@
_G.LM = LM
--@end-debug@