This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
/
Core.lua
110 lines (102 loc) · 3.75 KB
/
Core.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
--[[--
@module MyDungeonsBook
]]
--[[--
Core
@section Core
]]
local L = LibStub("AceLocale-3.0"):GetLocale("MyDungeonsBook");
MyDungeonsBook = LibStub("AceAddon-3.0"):NewAddon("MyDungeonsBook", "AceEvent-3.0", "AceTimer-3.0", "AceHook-3.0", "AceConsole-3.0", "AceSerializer-3.0", "AceComm-3.0");
--[[--
Initial ACE-addon setup.
]]
function MyDungeonsBook:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("MyDungeonsBookDB", self.OptionsDefaults);
LibStub("AceConfig-3.0"):RegisterOptionsTable("MyDungeonsBook", self.Options);
LibStub("AceConfigDialog-3.0"):AddToBlizOptions("MyDungeonsBook", L["My Dungeons Book"]);
self:RegisterChatCommand("mydungeonsbook", "ParseChatCommand");
self:RegisterChatCommand("mdb", "ParseChatCommand");
StaticPopupDialogs["MDB_CONFIRM_DELETE_CHALLENGE"] = {
text = L["Are you sure you want to delete info about challenge?"],
button1 = L["Yes"],
button2 = L["No"],
OnAccept = function(data)
self:Challenge_Delete(data.data);
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3
};
StaticPopupDialogs["MDB_FILLED_WOWHEAD_LINK_INPUT"] = {
text = L["WowHead Link for %s"],
OnShow = function (self, linkToShow)
self.editBox:SetText(linkToShow);
self.editBox:HighlightText();
end,
hideOnEscape = true,
hasEditBox = true,
whileDead = true,
button1 = L["Close"],
};
StaticPopupDialogs["MDB_WA_CUSTOM_TEXT_INPUT"] = {
text = L["Custom Text for WA"],
OnShow = function (self, data)
self.editBox:SetText("Custom Text");
end,
OnAccept = function (self, data, data2)
local customText = self.editBox:GetText();
if (data.type == "AURA") then
MyDungeonsBook:WA_Aura_Aura_Create(data.auraData, data.instanceId, data.bossId, data.affixId, customText);
end
if (data.type == "GTFO") then
MyDungeonsBook:WA_GTFO_Aura_Create(data.auraData, data.instanceId, data.bossId, data.affixId, customText);
end
if (data.type == "CAST_ON_ME") then
MyDungeonsBook:WA_CastOnMe_Aura_Create(data.auraData, data.instanceId, data.bossId, data.affixId, customText);
end
if (data.type == "PARTY_AURA") then
MyDungeonsBook:WA_PartyAura_Aura_Create(data.auraData, data.instanceId, data.bossId, data.affixId, customText);
end
if (data.type == "CUSTOM_ACTION_ON_SPELL_CAST_START") then
MyDungeonsBook:WA_CustomActionOnSpellStart_Aura_Create(data.auraData, data.instanceId, data.bossId, data.affixId, customText);
end
if (data.type == "CUSTOM_ACTION_ON_SPELL_CAST_SUCCESS") then
MyDungeonsBook:WA_CustomActionOnSpellSuccess_Aura_Create(data.auraData, data.instanceId, data.bossId, data.affixId, customText);
end
end,
whileDead = true,
hideOnEscape = true,
hasEditBox = true,
button1 = L["Create WA"],
button2 = L["Cancel"],
};
self:DebugPrint("Loaded");
end
--[[--
Setup event handlers.
Next events are handled:
* `CHALLENGE_MODE_START`
* `CHALLENGE_MODE_COMPLETED`
* `CHALLENGE_MODE_RESET`
* `PLAYER_ENTERING_WORLD`
* `INSPECT_READY`
* `ENCOUNTER_END`
* `ENCOUNTER_START`
Events `COMBAT_LOG_EVENT_UNFILTERED`, `PLAYER_REGEN_DISABLED` and `PLAYER_REGEN_ENABLED` are handled while challenge is active. E.g. from `CHALLENGE_MODE_START` to `CHALLENGE_MODE_COMPLETED` or `CHALLENGE_MODE_RESET`.
Check methods with the same names to get more info about handlers.
]]
function MyDungeonsBook:OnEnable()
self:RegisterEvent("CHALLENGE_MODE_START");
self:RegisterEvent("CHALLENGE_MODE_COMPLETED");
self:RegisterEvent("CHALLENGE_MODE_RESET");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("INSPECT_READY");
self:RegisterEvent("ENCOUNTER_END");
self:RegisterEvent("ENCOUNTER_START");
self:RegisterEvent("SCENARIO_CRITERIA_UPDATE");
self:RegisterEvent("ENCOUNTER_LOOT_RECEIVED");
self:Messages_StartTrack();
self:DebugPrint("Enabled");
self:CleanupOlderChallenges();
end