-
Notifications
You must be signed in to change notification settings - Fork 1
/
Startup.lua
83 lines (70 loc) · 2.17 KB
/
Startup.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
local ADDON_NAME = "FarmingParty"
local FPSettings
local listContainer
local highscoreWindowIsHidden = true
FarmingParty = ZO_Object:Subclass()
FarmingParty.Modules = {}
FarmingParty.DataTypes = {
MEMBER = 1,
MEMBER_ITEM = 2
}
FarmingParty.SaveData = {}
FarmingParty.Settings = {}
local function OnPlayerDeactivated(eventCode)
FarmingParty:Finalize()
end
-- EVENT_ADD_ON_LOADED
function FarmingParty:OnAddOnLoaded(event, addonName)
if (addonName ~= ADDON_NAME) then
return
end
EVENT_MANAGER:RegisterForEvent(ADDON_NAME, EVENT_PLAYER_DEACTIVATED, OnPlayerDeactivated)
EVENT_MANAGER:UnregisterForEvent(ADDON_NAME, EVENT_ADD_ON_LOADED)
FarmingParty.Settings = FarmingPartySettings:New()
self:Initialize()
end
function FarmingParty:Finalize()
for moduleName, moduleObject in pairs(self.Modules) do
moduleObject:Finalize()
end
end
function FarmingParty:Initialize()
self.Modules.MemberList = FarmingPartyMemberList:New()
FarmingParty:ConsoleCommands()
end
function FarmingParty:ConsoleCommands()
-- Print all available commands to chat
SLASH_COMMANDS["/fphelp"] = function()
d("-- Farming Party commands --")
d("/fp Show or hide the highscore window.")
d("/fpc Print highscores to the chat.")
d("/fpreset Reset all highscore values (doesn't remove).")
d("/fpdelete Remove everything from highscores.")
end
-- Toggle the highscore window
SLASH_COMMANDS["/fp"] = function()
self.Modules.MemberList:ToggleMembersWindow()
end
SLASH_COMMANDS["/fpc"] = function()
self.Modules.MemberList:PrintScoresToChat()
end
-- Reset all stats from the .member table
SLASH_COMMANDS["/fpreset"] = function()
self.Modules.MemberList:Reset()
d("Farming Party has been reset")
end
-- Show all registered modules
SLASH_COMMANDS["/fpm"] = function()
for moduleName, moduleObject in pairs(self.Modules) do
d(moduleName)
end
end
end
-- Load the addon with this
EVENT_MANAGER:RegisterForEvent(
ADDON_NAME,
EVENT_ADD_ON_LOADED,
function(...)
FarmingParty:OnAddOnLoaded(...)
end
)