-
Notifications
You must be signed in to change notification settings - Fork 1
/
GroupCalendar_Clock.lua
executable file
·94 lines (76 loc) · 2.83 KB
/
GroupCalendar_Clock.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
local gAddonName = ...
GroupCalendarClock_Data = nil
if not GroupCalendar.cHelpClock then
GroupCalendar.cHelpClock = "Sets the minimap clock to display local time or server time"
end
function GroupCalendar.Clock:Initialize()
if not GroupCalendarClock_Data then
GroupCalendarClock_Data =
{
ShowLocalTime = false,
HideMinimapClock = false
}
end
self.Data = GroupCalendarClock_Data
self.Frame = GroupCalendar:New(GroupCalendar._Clock, 40, GameTimeFrame, -1, 1, true, true)
self.Frame:SetShowLocalTime(self.Data.ShowLocalTime)
if self.Data.HideMinimapClock then
self.Frame:Hide()
end
end
function GroupCalendar.Clock:PrefsChanged()
if self.Data.HideMinimapClock then
self.Frame:Hide()
else
self.Frame:Show()
end
end
function GroupCalendar:HookScript(pFrame, pScriptID, pFunction)
if not pFrame:GetScript(pScriptID) then
pFrame:SetScript(pScriptID, pFunction)
else
pFrame:HookScript(pScriptID, pFunction)
end
end
----------------------------------------
-- /cal
----------------------------------------
if not GroupCalendar.InstallSlashCommand then
function GroupCalendar:InstallSlashCommand()
SlashCmdList.CAL = function (...) GroupCalendar:ExecuteCommand(...) end
SLASH_CAL1 = "/cal"
end
function GroupCalendar:ExecuteCommand(pCommandString, ...)
local _, _, vCommand, vParameter = string.find(pCommandString, "([^%s]+) ?(.*)")
local vCommandFunc = self.Commands[strlower(vCommand or "help")] or self.Commands.help
vCommandFunc(self, vParameter)
end
GroupCalendar.CommandHelp = {}
GroupCalendar.Commands = {}
end
if GroupCalendar.EventLib then
GroupCalendar.EventLib:RegisterCustomEvent("GC5_INIT", function () GroupCalendar.Clock:Initialize() end)
GroupCalendar.EventLib:RegisterCustomEvent("GC5_PREFS_CHANGED", GroupCalendar.Clock.PrefsChanged, GroupCalendar.Clock)
else
GroupCalendar:HookScript(GameTimeFrame, "OnEvent", function (pFrame, pEventID, pAddonName) if pEventID == "ADDON_LOADED" and pAddonName == gAddonName then GroupCalendar.Clock:Initialize() end end)
GameTimeFrame:RegisterEvent("ADDON_LOADED")
end
----------------------------------------
-- Commands
----------------------------------------
table.insert(GroupCalendar.CommandHelp, HIGHLIGHT_FONT_COLOR_CODE.."/cal clock [local|server]"..NORMAL_FONT_COLOR_CODE.." "..GroupCalendar.cHelpClock)
function GroupCalendar.Commands:clock(pParam)
local vParam = pParam:lower()
if vParam == "local" then
self.Clock.Data.ShowLocalTime = true
elseif vParam == "server" then
self.Clock.Data.ShowLocalTime = false
elseif vParam == "on" then
self.Clock.Data.HideMinimapClock = false
elseif vParam == "off" then
self.Clock.Data.HideMinimapClock = true
end
if GroupCalendar.EventLib then
GroupCalendar.EventLib:DispatchEvent("GC5_PREFS_CHANGED")
end
end