forked from Questie/Questie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Questie.lua
352 lines (285 loc) · 11.5 KB
/
Questie.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
if(Questie) then
C_Timer.After(4, function()
error("ERROR!! -> Questie already loaded! Please only have one Questie installed!")
for i=1, 10 do
DEFAULT_CHAT_FRAME:AddMessage("|cFFFF0000ERROR!!|r -> Questie already loaded! Please only have one Questie installed!")
end
end);
Questie = {}
return nil;
end
if not QuestieConfigCharacter then
QuestieConfigCharacter = {}
end
DEBUG_CRITICAL = "|cff00f2e6[CRITICAL]|r"
DEBUG_ELEVATED = "|cffebf441[ELEVATED]|r"
DEBUG_INFO = "|cff00bc32[INFO]|r"
DEBUG_DEVELOP = "|cff7c83ff[DEVELOP]|r"
DEBUG_SPAM = "|cffff8484[SPAM]|r"
--Initialized below
Questie = {...}
-- check if user has updated but not restarted the game (todo: add future new source files to this)
if (not LQuestie_EasyMenu) or
--Libs
(not QuestieLib) or
(not QuestiePlayer) or
(not QuestieSerializer) or
--Comms
(not QuestieComms) or
(not QuestieComms.data) or
--Options
(not QuestieOptions) or
(not QuestieOptionsDefaults) or
(not QuestieOptionsMinimapIcon) or
(not QuestieOptionsUtils) or
(not QuestieOptions.tabs) or
(not QuestieOptions.tabs.advanced) or
(not QuestieOptions.tabs.dbm) or
(not QuestieOptions.tabs.general) or
(not QuestieOptions.tabs.map) or
(not QuestieOptions.tabs.minimap) or
(not QuestieOptions.tabs.nameplate) or
(not QuestieOptions.tabs.tracker) or
(not QuestieAuto) or
(not QuestieCoords) or
(not QuestieEventHandler) or
(not QuestieFramePool) or
(not QuestieJourney) or
--Map
(not QuestieMap) or
(not QuestieMap.utils) or
(not QuestieNameplate) or
(not QuestieProfessions) or
(not QuestieQuest) or
(not QuestieReputation) or
--Search
(not QuestieSearch) or
(not QuestieSearchResults) or
(not QuestieStreamLib) or
(not QuestieTooltips) or
(not QuestieSearchResults) or
(not QuestieTracker) then
--Delay the warning.
C_Timer.After(8, function()
if QuestieLocale.locale['enUS'] and QuestieLocale.locale['enUS']['QUESTIE_UPDATED_RESTART'] then -- sometimes locale doesnt update without restarting also
print(QuestieLocale:GetUIString('QUESTIE_UPDATED_RESTART'))
else
print("|cFFFF0000WARNING!|r You have updated questie without restarting the game, this will likely cause problems. Please restart the game before continuing")
end
end)
else
-- Initialize Questie
Questie = LibStub("AceAddon-3.0"):NewAddon("Questie", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "AceComm-3.0", "AceSerializer-3.0", "AceBucket-3.0")
_Questie = {...}
end
function Questie:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("QuestieConfig", QuestieOptionsDefaults:Load(), true)
QuestieFramePool:SetIcons()
-- Set proper locale. Either default to client Locale or override based on user.
if Questie.db.global.questieLocaleDiff then
QuestieLocale:SetUILocale(Questie.db.global.questieLocale);
else
QuestieLocale:SetUILocale(GetLocale());
end
Questie:Debug(DEBUG_CRITICAL, "Questie addon loaded")
QuestieCorrections:Initialize()
QuestieLocale:Initialize()
Questie:RegisterEvent("PLAYER_LOGIN", QuestieEventHandler.PLAYER_LOGIN)
--Accepted Events
Questie:RegisterEvent("QUEST_ACCEPTED", QuestieEventHandler.QUEST_ACCEPTED)
Questie:RegisterEvent("MAP_EXPLORATION_UPDATED", QuestieEventHandler.MAP_EXPLORATION_UPDATED)
Questie:RegisterEvent("UNIT_QUEST_LOG_CHANGED", QuestieEventHandler.UNIT_QUEST_LOG_CHANGED);
Questie:RegisterEvent("QUEST_TURNED_IN", QuestieEventHandler.QUEST_TURNED_IN)
Questie:RegisterEvent("QUEST_REMOVED", QuestieEventHandler.QUEST_REMOVED)
Questie:RegisterEvent("PLAYER_LEVEL_UP", QuestieEventHandler.PLAYER_LEVEL_UP);
-- Use bucket for QUEST_LOG_UPDATE to let information propagate through to the blizzard API
-- Might be able to change this to 0.5 seconds instead, further testing needed.
Questie:RegisterBucketEvent("QUEST_LOG_UPDATE", 1, QuestieEventHandler.QUEST_LOG_UPDATE);
Questie:RegisterEvent("MODIFIER_STATE_CHANGED", QuestieEventHandler.MODIFIER_STATE_CHANGED);
-- Events to update a players professions and reputations
Questie:RegisterEvent("CHAT_MSG_SKILL", QuestieEventHandler.CHAT_MSG_SKILL)
Questie:RegisterEvent("CHAT_MSG_COMBAT_FACTION_CHANGE", QuestieEventHandler.CHAT_MSG_COMBAT_FACTION_CHANGE)
-- Party join event for QuestieComms, Use bucket to hinder this from spamming (Ex someone using a raid invite addon etc)
Questie:RegisterBucketEvent("GROUP_ROSTER_UPDATE", 1, QuestieEventHandler.GROUP_ROSTER_UPDATE);
Questie:RegisterEvent("GROUP_JOINED", QuestieEventHandler.GROUP_JOINED);
Questie:RegisterEvent("GROUP_LEFT", QuestieEventHandler.GROUP_LEFT);
--TODO: QUEST_QUERY_COMPLETE Will get all quests the character has finished, need to be implemented!
-- Nameplate / Tar5get Frame Objective Events
Questie:RegisterEvent("NAME_PLATE_UNIT_ADDED", QuestieNameplate.NameplateCreated);
Questie:RegisterEvent("NAME_PLATE_UNIT_REMOVED", QuestieNameplate.NameplateDestroyed);
Questie:RegisterEvent("PLAYER_TARGET_CHANGED", QuestieNameplate.DrawTargetFrame);
--When the quest is presented!
Questie:RegisterEvent("QUEST_DETAIL", QuestieAuto.QUEST_DETAIL)
--???
Questie:RegisterEvent("QUEST_PROGRESS", QuestieAuto.QUEST_PROGRESS)
--Gossip??
Questie:RegisterEvent("GOSSIP_SHOW", QuestieAuto.GOSSIP_SHOW)
--The window when multiple quest from a NPC
Questie:RegisterEvent("QUEST_GREETING", QuestieAuto.QUEST_GREETING)
--If an escort quest is taken by people close by
Questie:RegisterEvent("QUEST_ACCEPT_CONFIRM", QuestieAuto.QUEST_ACCEPT_CONFIRM)
--When complete window shows
Questie:RegisterEvent("QUEST_COMPLETE", QuestieAuto.QUEST_COMPLETE)
-- todo move this call into loader
QuestieTooltips:Initialize()
-- Initialize Coordinates
QuestieCoords.Initialize();
-- Initialize questiecomms
--C_ChatInfo.RegisterAddonMessagePrefix("questie")
-- JoinTemporaryChannel("questie")
--Questie:RegisterEvent("CHAT_MSG_ADDON", QuestieComms.MessageReceived)
-- Initialize Journey Window
QuestieJourney.Initialize();
-- Register Slash Commands
Questie:RegisterChatCommand("questieclassic", "QuestieSlash")
Questie:RegisterChatCommand("questie", "QuestieSlash")
QuestieOptions:Initialize();
--Initialize the DB settings.
Questie:debug(DEBUG_DEVELOP, QuestieLocale:GetUIString('DEBUG_CLUSTER', Questie.db.global.clusterLevelHotzone))
QUESTIE_CLUSTER_DISTANCE = Questie.db.global.clusterLevelHotzone;
-- Creating the minimap config icon
Questie.minimapConfigIcon = LibStub("LibDBIcon-1.0");
Questie.minimapConfigIcon:Register("MinimapIcon", QuestieOptionsMinimapIcon:Get(), Questie.db.profile.minimap);
-- Update the default text on the map show/hide button for localization
if Questie.db.char.enabled then
Questie_Toggle:SetText(QuestieLocale:GetUIString('QUESTIE_MAP_BUTTON_HIDE'));
else
Questie_Toggle:SetText(QuestieLocale:GetUIString('QUESTIE_MAP_BUTTON_SHOW'));
QuestieQuest:ToggleNotes(false)
end
-- Update status of Map button on hide between play sessions
if Questie.db.global.mapShowHideEnabled then
Questie_Toggle:Show();
else
Questie_Toggle:Hide();
end
if Questie.db.global.dbmHUDEnable then
QuestieDBMIntegration:EnableHUD()
end
end
function Questie:OnUpdate()
end
function Questie:OnEnable()
-- Called when the addon is enabled
end
function Questie:OnDisable()
-- Called when the addon is disabled
end
function Questie:QuestieSlash(input)
input = string.trim(input, " ");
-- /questie
if input == "" or not input then
QuestieOptions:OpenConfigWindow();
if QuestieJourney:IsShown() then
QuestieJourney.ToggleJourneyWindow();
end
return ;
end
-- /questie help || /questie ?
if input == "help" or input == "?" then
print(Questie:Colorize(QuestieLocale:GetUIString('SLASH_HEAD'), 'yellow'));
print(Questie:Colorize(QuestieLocale:GetUIString('SLASH_CONFIG'), 'yellow'));
print(Questie:Colorize(QuestieLocale:GetUIString('SLASH_TOGGLE_QUESTIE'), 'yellow'));
print(Questie:Colorize(QuestieLocale:GetUIString('SLASH_MINIMAP'), 'yellow'));
print(Questie:Colorize(QuestieLocale:GetUIString('SLASH_JOURNEY'), 'yellow'));
return;
end
-- /questie toggle
if input == "toggle" then
QuestieQuest:ToggleNotes();
-- CLose config window if it's open to avoid desyncing the Checkbox
QuestieOptions:HideFrame();
return;
end
if input == "reload" then
QuestieQuest:SmoothReset()
return
end
-- /questie minimap
if input == "minimap" then
Questie.db.profile.minimap.hide = not Questie.db.profile.minimap.hide;
if Questie.db.profile.minimap.hide then
Questie.minimapConfigIcon:Hide("MinimapIcon");
else
Questie.minimapConfigIcon:Show("MinimapIcon");
end
return;
end
-- /questie journey
if input == "journey" then
QuestieJourney.ToggleJourneyWindow();
QuestieOptions:HideFrame();
return;
end
print(Questie:Colorize("[Questie] :: ", 'yellow') .. QuestieLocale:GetUIString('SLASH_INVALID') .. Questie:Colorize('/questie help', 'yellow'));
end
function Questie:Colorize(str, color)
local c = '';
if color == 'red' then
c = '|cffff0000';
elseif color == 'gray' then
c = '|cFFCFCFCF';
elseif color == 'purple' then
c = '|cFFB900FF';
elseif color == 'blue' then
c = '|cB900FFFF';
elseif color == 'yellow' then
c = '|cFFFFB900';
end
return c .. str .. "|r"
end
function Questie:GetClassColor(class)
class = string.lower(class);
if class == 'druid' then
return '|cFFFF7D0A';
elseif class == 'hunter' then
return '|cFFABD473';
elseif class == 'mage' then
return '|cFF69CCF0';
elseif class == 'paladin' then
return '|cFFF58CBA';
elseif class == 'priest' then
return '|cFFFFFFFF';
elseif class == 'rogue' then
return '|cFFFFF569';
elseif class == 'shaman' then
return '|cFF0070DE';
elseif class == 'warlock' then
return '|cFF9482C9';
elseif class == 'warrior' then
return '|cFFC79C6E';
else
return '|cffff0000'; -- error red
end
end
function Questie:Error(...)
Questie:Print("|cffff0000[ERROR]|r", ...)
end
function Questie:error(...)
Questie:Error(...)
end
--debuglevel = 5 --1 Critical, 2 ELEVATED, 3 Info, 4, Develop, 5 SPAM THAT SHIT YO
--DEBUG_CRITICAL = "1DEBUG"
--DEBUG_ELEVATED = "2DEBUG"
--DEBUG_INFO = "3DEBUG"
--DEBUG_DEVELOP = "4DEBUG"
--DEBUG_SPAM = "5DEBUG"
function Questie:Debug(...)
if(Questie.db.global.debugEnabled) then
if(Questie.db.global.debugLevel < 5 and select(1, ...) == DEBUG_SPAM)then return; end
if(Questie.db.global.debugLevel < 4 and select(1, ...) == DEBUG_DEVELOP)then return; end
if(Questie.db.global.debugLevel < 3 and select(1, ...) == DEBUG_INFO)then return; end
if(Questie.db.global.debugLevel < 2 and select(1, ...) == DEBUG_ELEVATED)then return; end
if(Questie.db.global.debugLevel < 1 and select(1, ...) == DEBUG_CRITICAL)then return; end
--Questie:Print(...)
if(QuestieConfigCharacter.log) then
QuestieConfigCharacter = {};
end
if Questie.db.global.debugEnabledPrint then
Questie:Print(...)
end
end
end
function Questie:debug(...)
Questie:Debug(...)
end