-
Notifications
You must be signed in to change notification settings - Fork 0
/
AntiFTWToolbox.lua
218 lines (195 loc) · 8.95 KB
/
AntiFTWToolbox.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
-------------------------------------------------------------------------------------------------
-- Libraries --
-------------------------------------------------------------------------------------------------
local LAM2 = LibAddonMenu2 --This global variable LibAddonMenu2 only exists with LAM version 2.0 r28 or higher!
-------------------------------------------------------------------------------------------------
-- Variable Definitions --
-------------------------------------------------------------------------------------------------
AntiFTWToolbox = {};
-- define name, used for regestering events
AntiFTWToolbox.name = "AntiFTWToolbox";
AntiFTWToolbox.version = 1;
AntiFTWToolbox.guildMessage = 0;
AntiFTWToolbox.unreadMessage = false;
AntiFTWToolbox.Default = {
offsetX = 958,
offsetY = 125,
show = true,
guild1 = true,
guild2 = true,
guild3 = true,
guild4 = true,
guild5 = true,
whisper = true,
};
-------------------------------------------------------------------------------------------------
-- Initialize Function --
-------------------------------------------------------------------------------------------------
function AntiFTWToolbox:Initialize()
self.savedVariables = ZO_SavedVars:NewAccountWide("AntiFTWToolboxVariables", AntiFTWToolbox.version, nil, AntiFTWToolbox.Default)
AntiFTWToolbox.CreateSettingsWindow()
EVENT_MANAGER:RegisterForEvent(AntiFTWToolbox.name, EVENT_CHAT_MESSAGE_CHANNEL, self.chatCallback);
AntiFTWToolbox.guildMessage = 0;
AntiFTWToolbox.unreadMessage = false;
self:RestorePosition();
--AntiFTWToolbox.CreateSettingsWindow();
--CirconianStaminaBarWindow:SetHidden(not AntiFTWToolbox.savedVariables.Show)
end
function AntiFTWToolbox.hideCommand()
AntiFTWToolbox.unreadMessage = false;
AntiFTWToolboxIndicator:SetHidden(not AntiFTWToolbox.unreadMessage);
end
function hideCommand()
AntiFTWToolbox:hideCommand();
end
-------------------------------------------------------------------------------------------------
-- OnAddOnLoaded --
-------------------------------------------------------------------------------------------------
function AntiFTWToolbox.OnAddOnLoaded(event, addonName)
-- The event fires each time *any* addon loads - but we only care about when our own addon loads.
if addonName ~= AntiFTWToolbox.name then return end
AntiFTWToolbox:Initialize();
SLASH_COMMANDS["/ftw"] = hideCommand;
end
-------------------------------------------------------------------------------------------------
-- chatCallback --
-------------------------------------------------------------------------------------------------
function AntiFTWToolbox.chatCallback(eventCode, messageType, fromName, text)
if(AntiFTWToolbox.savedVariables.show) then
if (AntiFTWToolbox.savedVariables.guild1 and (messageType == CHAT_CHANNEL_GUILD_1 or messageType == CHAT_CHANNEL_OFFICER_1)) then
AntiFTWToolbox.guildMessage = 1;
AntiFTWToolbox.unreadMessage = true;
elseif (AntiFTWToolbox.savedVariables.guild2 and (messageType == CHAT_CHANNEL_GUILD_2 or messageType == CHAT_CHANNEL_OFFICER_2)) then
AntiFTWToolbox.guildMessage = 2;
AntiFTWToolbox.unreadMessage = true;
elseif (AntiFTWToolbox.savedVariables.guild3 and (messageType == CHAT_CHANNEL_GUILD_3 or messageType == CHAT_CHANNEL_OFFICER_3)) then
AntiFTWToolbox.guildMessage = 3;
AntiFTWToolbox.unreadMessage = true;
elseif (AntiFTWToolbox.savedVariables.guild4 and (messageType == CHAT_CHANNEL_GUILD_4 or messageType == CHAT_CHANNEL_OFFICER_4)) then
AntiFTWToolbox.guildMessage = 4;
AntiFTWToolbox.unreadMessage = true;
elseif (AntiFTWToolbox.savedVariables.guild5 and (messageType == CHAT_CHANNEL_GUILD_5 or messageType == CHAT_CHANNEL_OFFICER_5)) then
AntiFTWToolbox.guildMessage = 5;
AntiFTWToolbox.unreadMessage = true;
elseif (AntiFTWToolbox.savedVariables.whisper and (messageType == CHAT_CHANNEL_WHISPER)) then
AntiFTWToolbox.guildMessage = 6;
AntiFTWToolbox.unreadMessage = true;
end
end
if(GetDisplayName() == fromName) then
AntiFTWToolbox.unreadMessage = false;
end
if (string.match(text, "wtfanti")) then
AntiFTWToolbox.unreadMessage = true;
end
AntiFTWToolboxIndicator:SetHidden(not AntiFTWToolbox.unreadMessage)
--return false = run the other event callback functions for the same event
--return true = don#t run the other event callback functions for this event as you tell them by "true": Everything was done already in this function here
--The same applies to ZoPreHook() and ZoPreHookHandler() functions
return false
end
function AntiFTWToolbox.OnIndicatorMoveStop()
AntiFTWToolbox.savedVariables.offsetX = AntiFTWToolboxIndicator:GetLeft()
AntiFTWToolbox.savedVariables.offsetY = AntiFTWToolboxIndicator:GetTop()
end
function AntiFTWToolbox:RestorePosition()
local x = self.savedVariables.offsetX
local y = self.savedVariables.offsetY
AntiFTWToolboxIndicator:ClearAnchors()
AntiFTWToolboxIndicator:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, x, y)
end
-------------------------------------------------------------------------------------------------
-- Menu Functions --
-------------------------------------------------------------------------------------------------
function AntiFTWToolbox.CreateSettingsWindow()
local panelData = {
type = "panel",
name = "AntiFTWs Toolbox",
displayName = "AntiFTWs Toolbox",
author = "AntiFTW",
version = AntiFTWToolbox.version,
slashCommand = "/ftw",
registerForRefresh = true,
registerForDefaults = true,
}
local cntrlOptionsPanel = LAM2:RegisterAddonPanel("AntiFTW_Toolbox", panelData);
local optionsData = {
[1] = {
type = "header",
name = "AntiFTW Toolbox Settings"
},
[2] = {
type = "description",
text = "Here you can define which parts of the toolbox you want to use."
},
[3] = {
type = "checkbox",
name = "Show Chat Warning",
tooltip = "When ON the chat warning will be visible. When OFF the chat warning will be hidden.",
default = true,
getFunc = function() return AntiFTWToolbox.savedVariables.Show end,
setFunc = function(newValue)
AntiFTWToolbox.savedVariables.Show = newValue
AntiFTWToolboxIndicator:SetHidden(not newValue) end,
},
[4] = {
type = "checkbox",
name = "Whisper",
tooltip = "When ON the chat warning will work for whispers. When OFF the chat warning will not.",
default = true,
getFunc = function() return AntiFTWToolbox.savedVariables.whisper end,
setFunc = function(newValue)
AntiFTWToolbox.savedVariables.whisper = newValue end,
},
[5] = {
type = "checkbox",
name = "Guild 1",
tooltip = "When ON the chat warning will work for guild 1. When OFF the chat warning will not.",
default = true,
getFunc = function() return AntiFTWToolbox.savedVariables.guild1 end,
setFunc = function(newValue)
AntiFTWToolbox.savedVariables.guild1 = newValue end,
},
[6] = {
type = "checkbox",
name = "Guild 2",
tooltip = "When ON the chat warning will work for guild 2. When OFF the chat warning will not.",
default = true,
getFunc = function() return AntiFTWToolbox.savedVariables.guild2 end,
setFunc = function(newValue)
AntiFTWToolbox.savedVariables.guild2 = newValue end,
},
[7] = {
type = "checkbox",
name = "Guild 3",
tooltip = "When ON the chat warning will work for guild 3. When OFF the chat warning will not.",
default = true,
getFunc = function() return AntiFTWToolbox.savedVariables.guild3 end,
setFunc = function(newValue)
AntiFTWToolbox.savedVariables.guild3 = newValue end,
},
[8] = {
type = "checkbox",
name = "Guild 4",
tooltip = "When ON the chat warning will work for guild 4. When OFF the chat warning will not.",
default = true,
getFunc = function() return AntiFTWToolbox.savedVariables.guild4 end,
setFunc = function(newValue)
AntiFTWToolbox.savedVariables.guild4 = newValue end,
},
[9] = {
type = "checkbox",
name = "Guild 5",
tooltip = "When ON the chat warning will work for guild 5. When OFF the chat warning will not.",
default = true,
getFunc = function() return AntiFTWToolbox.savedVariables.guild5 end,
setFunc = function(newValue)
AntiFTWToolbox.savedVariables.guild5 = newValue end,
},
}
LAM2:RegisterOptionControls("AntiFTW_Toolbox", optionsData)
end
-------------------------------------------------------------------------------------------------
-- Register Events --
-------------------------------------------------------------------------------------------------
EVENT_MANAGER:RegisterForEvent(AntiFTWToolbox.name, EVENT_ADD_ON_LOADED, AntiFTWToolbox.OnAddOnLoaded);