-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobalPlayed.lua
71 lines (60 loc) · 1.83 KB
/
GlobalPlayed.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
----------------------
-- Addon behavior
----------------------
local currentCharacter = nil
SLASH_GLOBAL_PLAYED1 = '/gplayed'
SlashCmdList['GLOBAL_PLAYED'] = function(msg, editbox)
if msg == "" then
GlobalPlayed_UpdateAll()
if GlobalPlayed_Addon_IsAceEnabled() == false then
GlobalPlayed_Log(GlobalPlayed_Account_GetPlayed(GlobalPlayed_MyAccount))
else
GlobalPlayed_OpenUI()
end
elseif msg == "all" then
GlobalPlayed_UpdateAll()
if GlobalPlayed_Addon_IsAceEnabled() == false then
GlobalPlayed_LogCharactersPlayed()
GlobalPlayed_Log(GlobalPlayed_Account_GetPlayed(GlobalPlayed_MyAccount))
else
GlobalPlayed_OpenUI()
end
elseif msg == "options" then
GlobalPlayed_OpenOptionsPanel()
GlobalPlayed_OpenOptionsPanel()
else
GlobalPlayed_Log("Unknown command: /gplayed " .. msg)
GlobalPlayed_Log("Availaible commands:")
GlobalPlayed_Log(" /gplayed")
GlobalPlayed_Log(" /gplayed all")
GlobalPlayed_Log(" /gplayed options")
end
end
function GlobalPlayedFrame_OnLoad(self)
self:RegisterEvent("ADDON_LOADED")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("TIME_PLAYED_MSG")
end
function GlobalPlayedFrame_OnEvent(self, event, ...)
if event == "ADDON_LOADED" then
local addon = ...
if addon == "GlobalPlayed" then
GlobalPlayed_AddonLoadedHandler()
end
end
if event == "PLAYER_ENTERING_WORLD" then
-- Do something when player enter in world (also after loading a new place like after tp, etc...)
end
if event == "TIME_PLAYED_MSG" then
local total, currentLvl = ...
GlobalPlayed_TimePlayedMsgHandler(total, currentLvl)
end
end
function GlobalPlayed_UpdateAll()
if currentCharacter ~= nil then
GlobalPlayed_Character_UpdatePlayed(currentCharacter, days, hours)
end
if GlobalPlayed_MyAccount ~= nil then
GlobalPlayed_Account_UpdatePlayed(GlobalPlayed_MyAccount)
end
end