-
Notifications
You must be signed in to change notification settings - Fork 0
/
Init.lua
141 lines (130 loc) · 5.73 KB
/
Init.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
--############################################
-- Namespace
--############################################
local Aname_, addon = ...;
--##########################################################################################################################
-- Default values for options and characterDatabase
--##########################################################################################################################
function addon:getCHARdefaultCharacterDatabase()
return {
["Version"] = addon.version,
["nextReset"] = addon.WeekResetTime(),
["characters"] = {}
};
end
--Defaults options for character
function addon:getCHARdefaultOptions()
return {
["Version"] = addon.version,
["showMinimapIcon"] = false,
["debug"] = false,
["minimapPos"] = 145,
["frameInfo"] = {
["frameX"] = 0,
["frameY"] = 150,
["relativePoint"] = "CENTER",
["point"] = "CENTER",
}
};
end
--##########################################################################################################################
-- Event handling
--##########################################################################################################################
function addon:eventHandling(event, arg1)
addon:Debug(event);
if (event == "ADDON_LOADED") then
if(arg1 ~= Aname_) then
return;
end
if(ClassHallsAccountReporterData == nil) then
ClassHallsAccountReporterData = addon:getCHARdefaultCharacterDatabase();
end
if(ClassHallsAccountReporterCharacterOptions == nil) then
ClassHallsAccountReporterCharacterOptions = addon:getCHARdefaultOptions();
end
addon.DataToSave.charactersDatabase = ClassHallsAccountReporterData;
addon.DataToSave.options = ClassHallsAccountReporterCharacterOptions;
--Check if obligatory values exits
if(addon.DataToSave.charactersDatabase.Version == nil) then
addon.DataToSave.charactersDatabase.Version = addon.version;
end
if(addon.DataToSave.charactersDatabase.nextReset == nil) then
addon.DataToSave.charactersDatabase.nextReset = addon:WeekResetTime();
end
if(addon.DataToSave.charactersDatabase.characters == nil) then
addon.DataToSave.charactersDatabase.characters = {};
end
addon:Update();
self:UnregisterEvent(event);
elseif(event == "PLAYER_LOGIN") then
--Reset weekly stuff so its done for all characters
if(addon.DataToSave.charactersDatabase.nextReset < time()) then
-- We already passed the reset time so reset all the weekly stuff !
addon:resetAllCharactersWeeklyData();
end
--Load commands
addon.Commands:initCommands();
--Get all data about mitics +
C_MythicPlus.RequestMapInfo();
C_MythicPlus.RequestRewards();
C_MythicPlus.RequestCurrentAffixes();
addon.MinimapIcon:initIcon();
self:UnregisterEvent(event);
elseif(event == "GARRISON_LANDINGPAGE_SHIPMENTS") then
-- Update all as nearly all is available
addon:allInfoUpdater();
elseif(event == "GARRISON_MISSION_LIST_UPDATE" or event == "GARRISON_MISSION_STARTED") then
--Update missions
addon:storeShipmentsInfo()
elseif(event == "GARRISON_FOLLOWER_ADDED" or event == "GARRISON_FOLLOWER_REMOVED") then
-- Update followers
addon:storeFollowersAndTroopsInfo();
elseif(event == "GARRISON_FOLLOWER_CATEGORIES_UPDATED") then
-- Get follower count and info
addon:storeClassTroopInfo();
elseif(event == "CHAT_MSG_CURRENCY" or event == "BONUS_ROLL_RESULT" or event == "CHAT_MSG_LOOT") then
-- Update currency
addon:storeCurrencyInfo();
if(event == "CHAT_MSG_LOOT") then
local itemLooted = arg1;
if (string.lower(itemLooted):find('keystone')) then
addon:StoreKeyInformation();
end
end
elseif(event == "BAG_UPDATE") then
addon:StoreKeyInformation();
elseif(event == "CHALLENGE_MODE_COMPLETED") then
-- Store mytic mode
addon:StoreCompletedMytic();
-- Get the Info about the new key after a short interval
C_Timer.After(3, addon.StoreKeyInformation);
elseif(event == "CHALLENGE_MODE_START") then
if(addon.mytics == nil or type(addon.mytics) ~= "table") then
addon.mytics = {};
end
addon.mytics.CurrentID = C_ChallengeMode.GetActiveChallengeMapID();
else
if (C_Garrison.HasGarrison(LE_GARRISON_TYPE_7_0)) then
C_Garrison.RequestClassSpecCategoryInfo(LE_FOLLOWER_TYPE_GARRISON_7_0);
end
end
end
-- Event handling frame
addon.main_frame = CreateFrame("Frame");
-- Set Scripts
addon.main_frame:SetScript("OnEvent", addon.eventHandling);
-- Register events
addon.main_frame:RegisterEvent("ADDON_LOADED");
addon.main_frame:RegisterEvent("PLAYER_LOGIN");
addon.main_frame:RegisterEvent("GARRISON_FOLLOWER_CATEGORIES_UPDATED");
addon.main_frame:RegisterEvent("GARRISON_FOLLOWER_ADDED");
addon.main_frame:RegisterEvent("GARRISON_FOLLOWER_REMOVED");
addon.main_frame:RegisterEvent("GARRISON_LANDINGPAGE_SHIPMENTS");
addon.main_frame:RegisterEvent("GARRISON_MISSION_LIST_UPDATE");
addon.main_frame:RegisterEvent("GARRISON_MISSION_STARTED");
addon.main_frame:RegisterEvent("GARRISON_SHOW_LANDING_PAGE");
addon.main_frame:RegisterEvent("CHAT_MSG_CURRENCY");
addon.main_frame:RegisterEvent("BONUS_ROLL_RESULT");
addon.main_frame:RegisterEvent("CHAT_MSG_LOOT");
addon.main_frame:RegisterEvent("CHALLENGE_MODE_COMPLETED");
addon.main_frame:RegisterEvent("CHALLENGE_MODE_START");