vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | ------------------------------------------------------------------------------- |
2 | -- Locals -- |
||
3 | ------------------------------------------------------------------------------- |
||
4 | |||
5 | local L = AceLibrary("AceLocale-2.2"):new("BanzaiAlert") |
||
6 | |||
7 | local lastAggroAlert = nil |
||
8 | local isFlashing = nil |
||
9 | --local lastUnitTable = nil |
||
10 | |||
11 | ------------------------------------------------------------------------------- |
||
12 | -- Localization -- |
||
13 | ------------------------------------------------------------------------------- |
||
14 | |||
15 | L:RegisterTranslations("enUS", function() return { |
||
16 | ["Sound alert"] = true, |
||
17 | ["Plays a sound alert when you get aggro."] = true, |
||
18 | ["Text alert"] = true, |
||
19 | ["Displays a message on the screen when you get aggro."] = true, |
||
20 | ["Only in group"] = true, |
||
21 | ["Only alert for aggro when you are grouped."] = true, |
||
22 | ["Health frame flash"] = true, |
||
23 | ["Flash the health frame when you get aggro."] = true, |
||
24 | ["Lost aggro"] = true, |
||
25 | ["Alerts you when you lose aggro."] = true, |
||
26 | |||
27 | ["Aggro from %s!"] = true, |
||
28 | ["Lost aggro!"] = true, |
||
29 | |||
30 | -- oRA2 module |
||
31 | ["aggroalert"] = true, |
||
32 | ["Participant/AggroAlert"] = true, |
||
33 | ["aggro"] = true, |
||
34 | ["Aggro alert"] = true, |
||
35 | ["Options for aggro notifications."] = true, |
||
36 | |||
37 | ["Display"] = true, |
||
38 | ["Set where messages are displayed."] = true, |
||
39 | |||
40 | ["Default Frame"] = "Default", |
||
41 | ["BigWigs frame"] = "BigWigs", |
||
42 | ["Mik's Scrolling Battle Text"] = "MSBT", |
||
43 | ["Scrolling Combat Text"] = "SCT", |
||
44 | } end) |
||
45 | |||
46 | L:RegisterTranslations("koKR", function() return { |
||
47 | ["Sound alert"] = "경고 효과음", |
||
48 | ["Plays a sound alert when you get aggro."] = "어그로 획득시 경고 효과음을 재생합니다.", |
||
49 | ["Text alert"] = "경고 텍스트", |
||
50 | ["Displays a message on the screen when you get aggro."] = "어그로 획득시 화면에 메세지를 표시합니다.", |
||
51 | ["Only in group"] = "파티만 사용", |
||
52 | ["Only alert for aggro when you are grouped."] = "파티에 속해 있을 때에만 경고를 사용합니다.", |
||
53 | ["Health frame flash"] = "화면 번쩍임", |
||
54 | ["Flash the health frame when you get aggro."] = "어그로 획득시 생명력 프레임(화면 외곽)을 번쩍입니다.", |
||
55 | ["Lost aggro"] = "어그로 손실", |
||
56 | ["Alerts you when you lose aggro."] = "어그로 손실시 알립니다.", |
||
57 | |||
58 | ["Aggro from %s!"] = "%s의 어그로 획득!", |
||
59 | ["Lost aggro!"] = "어그로 손실!", |
||
60 | |||
61 | -- oRA2 module |
||
62 | -- ["aggroalert"] = "어그로경고", |
||
63 | -- ["Participant/AggroAlert"] = true, |
||
64 | -- ["aggro"] = "어그로", |
||
65 | ["Aggro alert"] = "어그로 경고", |
||
66 | ["Options for aggro notifications."] = "어그로 경고에 대해 설정합니다.", |
||
67 | |||
68 | ["Display"] = "디스플레이", |
||
69 | ["Set where messages are displayed."] = "메세지가 표시되는 곳을 설정합니다.", |
||
70 | } end) |
||
71 | |||
72 | L:RegisterTranslations("zhTW", function() return { |
||
73 | ["Sound alert"] = "聲音警告", |
||
74 | ["Plays a sound alert when you get aggro."] = "當你得到Aggro時發出聲音警告", |
||
75 | ["Text alert"] = "文字警告", |
||
76 | ["Displays a message on the screen when you get aggro."] = "當你得到Aggro時在螢幕顯示文字警告", |
||
77 | ["Only in group"] = "隊伍模式", |
||
78 | ["Only alert for aggro when you are grouped."] = "只有當你在隊伍裡時發出Aggro警告", |
||
79 | ["Health frame flash"] = "全螢幕閃光警告", |
||
80 | ["Flash the health frame when you get aggro."] = "在你得到Aggro後發出全螢幕閃光警告", |
||
81 | ["Lost aggro"] = "失去Aggro", |
||
82 | ["Alerts you when you lose aggro."] = "當你失去Aggro時發出警告", |
||
83 | |||
84 | ["Aggro from %s!"] = "得到 %s 的 Aggro!", |
||
85 | ["Lost aggro!"] = "失去 Aggro!", |
||
86 | |||
87 | -- oRA2 module |
||
88 | ["aggroalert"] = "Aggro警報", |
||
89 | ["Participant/AggroAlert"] = "Participant/AggroAlert", |
||
90 | ["aggro"] = "aggro", |
||
91 | ["Aggro alert"] = "Aggro警報", |
||
92 | ["Options for aggro notifications."] = "Aggro 通知選項", |
||
93 | |||
94 | ["Display"] = "顯示", |
||
95 | ["Set where messages are displayed."] = "設定訊息將會顯示在哪裡", |
||
96 | |||
97 | ["Default Frame"] = "預設", |
||
98 | ["BigWigs frame"] = "BigWigs", |
||
99 | ["Mik's Scrolling Battle Text"] = "MSBT", |
||
100 | ["Scrolling Combat Text"] = "SCT", |
||
101 | } end) |
||
102 | |||
103 | ------------------------------------------------------------------------------- |
||
104 | -- Addon declaration -- |
||
105 | ------------------------------------------------------------------------------- |
||
106 | |||
107 | BanzaiAlert = AceLibrary("AceAddon-2.0"):new("AceConsole-2.0", "AceDB-2.0", "AceEvent-2.0") |
||
108 | BanzaiAlert:RegisterDB("BanzaiAlertDB") |
||
109 | BanzaiAlert:RegisterDefaults("profile", { |
||
110 | sound = true, |
||
111 | message = true, |
||
112 | onlyInGroup = true, |
||
113 | flash = true, |
||
114 | lost = false, |
||
115 | display = L["Default Frame"], |
||
116 | }) |
||
117 | |||
118 | local options = { |
||
119 | type = "group", |
||
120 | name = L["Aggro alert"], |
||
121 | desc = L["Options for aggro notifications."], |
||
122 | args = { |
||
123 | sound = { |
||
124 | type = "toggle", |
||
125 | name = L["Sound alert"], |
||
126 | desc = L["Plays a sound alert when you get aggro."], |
||
127 | get = function() return BanzaiAlert.db.profile.sound end, |
||
128 | set = function(v) BanzaiAlert.db.profile.sound = v end, |
||
129 | }, |
||
130 | message = { |
||
131 | type = "toggle", |
||
132 | name = L["Text alert"], |
||
133 | desc = L["Displays a message on the screen when you get aggro."], |
||
134 | get = function() return BanzaiAlert.db.profile.message end, |
||
135 | set = function(v) BanzaiAlert.db.profile.message = v end, |
||
136 | }, |
||
137 | onlyInGroup = { |
||
138 | type = "toggle", |
||
139 | name = L["Only in group"], |
||
140 | desc = L["Only alert for aggro when you are grouped."], |
||
141 | get = function() return BanzaiAlert.db.profile.onlyInGroup end, |
||
142 | set = function(v) BanzaiAlert.db.profile.onlyInGroup = v end, |
||
143 | }, |
||
144 | flash = { |
||
145 | type = "toggle", |
||
146 | name = L["Health frame flash"], |
||
147 | desc = L["Flash the health frame when you get aggro."], |
||
148 | get = function() return BanzaiAlert.db.profile.flash end, |
||
149 | set = function(v) BanzaiAlert.db.profile.flash = v end, |
||
150 | }, |
||
151 | lost = { |
||
152 | type = "toggle", |
||
153 | name = L["Lost aggro"], |
||
154 | desc = L["Alerts you when you lose aggro."], |
||
155 | get = function() return BanzaiAlert.db.profile.lost end, |
||
156 | set = function(v) BanzaiAlert.db.profile.lost = v end, |
||
157 | }, |
||
158 | display = { |
||
159 | type = "text", |
||
160 | name = L["Display"], |
||
161 | desc = L["Set where messages are displayed."], |
||
162 | get = function() return BanzaiAlert.db.profile.display end, |
||
163 | set = function(v) BanzaiAlert.db.profile.display = v end, |
||
164 | validate = { |
||
165 | L["Default Frame"], |
||
166 | L["BigWigs frame"], |
||
167 | L["Scrolling Combat Text"], |
||
168 | L["Mik's Scrolling Battle Text"] |
||
169 | }, |
||
170 | disabled = function() return BanzaiAlert.db.profile.message ~= true end, |
||
171 | } |
||
172 | }, |
||
173 | } |
||
174 | |||
175 | BanzaiAlert:RegisterChatCommand({"/banzaialert", "/banzai"}, options, "BANZAIALERT") |
||
176 | |||
177 | ------------------------------------------------------------------------------- |
||
178 | -- Initialization -- |
||
179 | ------------------------------------------------------------------------------- |
||
180 | |||
181 | local function _InitoRA() |
||
182 | if oRA and not oRAPAggroAlert then |
||
183 | oRAPAggroAlert = oRA:NewModule(L["aggroalert"]) |
||
184 | oRAPAggroAlert.participant = true |
||
185 | oRAPAggroAlert.name = L["Participant/AggroAlert"] |
||
186 | oRAPAggroAlert.consoleCmd = L["aggro"] |
||
187 | oRAPAggroAlert.consoleOptions = options |
||
188 | end |
||
189 | end |
||
190 | |||
191 | function BanzaiAlert:ADDON_LOADED() |
||
192 | if arg1 == "oRA2" then |
||
193 | _InitoRA() |
||
194 | end |
||
195 | end |
||
196 | |||
197 | function BanzaiAlert:OnEnable() |
||
198 | lastAggroAlert = nil |
||
199 | |||
200 | _InitoRA() |
||
201 | |||
202 | self:RegisterEvent("Banzai_PlayerGainedAggro") |
||
203 | self:RegisterEvent("Banzai_PlayerLostAggro") |
||
204 | self:RegisterEvent("ADDON_LOADED") |
||
205 | end |
||
206 | |||
207 | ------------------------------------------------------------------------------- |
||
208 | -- Addon methods -- |
||
209 | ------------------------------------------------------------------------------- |
||
210 | |||
211 | function BanzaiAlert:Alert( gainedAggro, unitId ) |
||
212 | local text = nil |
||
213 | if gainedAggro then |
||
214 | text = string.format(L["Aggro from %s!"], UnitName(unitId)) |
||
215 | else |
||
216 | text = L["Lost aggro!"] |
||
217 | end |
||
218 | |||
219 | if self.db.profile.display == L["BigWigs frame"] and BigWigs then -- Big Wigs |
||
220 | self:TriggerEvent("BigWigs_Message", text, "Red", true, nil) |
||
221 | elseif self.db.profile.display == L["Scrolling Combat Text"] and SCT then -- SCT 5.x |
||
222 | SCT_MSG_FRAME:AddMessage(text, 1.0, 0.0, 0.0, 1) |
||
223 | elseif self.db.profile.display == L["Mik's Scrolling Battle Text"] and MikSBT then -- MSBT |
||
224 | MikSBT.DisplayMessage(text, MikSBT.DISPLAYTYPE_NOTIFICATION, false, 255, 0, 0) |
||
225 | elseif CombatText_AddMessage then -- Blizzards FCT |
||
226 | CombatText_AddMessage(text, COMBAT_TEXT_SCROLL_FUNCTION, 1.0, 0.0, 0.0, "sticky", nil) |
||
227 | else -- Fallback |
||
228 | UIErrorsFrame:AddMessage(text, 1.0, 0.0, 0.0, 1, UIERRORS_HOLD_TIME) |
||
229 | end |
||
230 | end |
||
231 | |||
232 | ------------------------------------------------------------------------------- |
||
233 | -- Events -- |
||
234 | ------------------------------------------------------------------------------- |
||
235 | |||
236 | function BanzaiAlert:Banzai_PlayerGainedAggro( unitTable ) |
||
237 | if (self.db.profile.onlyInGroup and GetNumPartyMembers() == 0) or not unitTable then |
||
238 | return |
||
239 | end |
||
240 | |||
241 | if not lastAggroAlert or (GetTime() - lastAggroAlert) > 5 then |
||
242 | if self.db.profile.sound then |
||
243 | PlaySoundFile("Interface\\AddOns\\BanzaiAlert\\aggro.wav") |
||
244 | end |
||
245 | if unitTable[1] then |
||
246 | if self.db.profile.message then |
||
247 | self:Alert(true, unitTable[1]) |
||
248 | end |
||
249 | if self.db.profile.flash and not isFlashing then |
||
250 | self:StartFlashing() |
||
251 | end |
||
252 | end |
||
253 | lastAggroAlert = GetTime() |
||
254 | end |
||
255 | end |
||
256 | |||
257 | function BanzaiAlert:Banzai_PlayerLostAggro( unitId ) |
||
258 | if self.db.profile.flash or isFlashing then |
||
259 | self:StopFlashing() |
||
260 | end |
||
261 | |||
262 | if self.db.profile.onlyInGroup and GetNumPartyMembers() == 0 then |
||
263 | return |
||
264 | end |
||
265 | |||
266 | if self.db.profile.lost and self.db.profile.message then |
||
267 | self:Alert() |
||
268 | end |
||
269 | end |
||
270 | |||
271 | ------------------------------------------------------------------------------- |
||
272 | -- Frame flashing -- |
||
273 | ------------------------------------------------------------------------------- |
||
274 | |||
275 | function BanzaiAlert:StartFlashing() |
||
276 | if self:IsEventScheduled("banzaiflash") or isFlashing then return end |
||
277 | UIFrameFlash(LowHealthFrame, 0.2, 0.8, 10, nil, .5, 0) |
||
278 | self:ScheduleRepeatingEvent("banzaiflash", function() UIFrameFlash(LowHealthFrame, 0.2, 0.8, 10, nil, .5, 0) end, .5) |
||
279 | isFlashing = true |
||
280 | end |
||
281 | |||
282 | function BanzaiAlert:StopFlashing() |
||
283 | if not isFlashing then return end |
||
284 | |||
285 | if self:IsEventScheduled("banzaiflash") then |
||
286 | self:CancelScheduledEvent("banzaiflash") |
||
287 | end |
||
288 | UIFrameFlashRemoveFrame(LowHealthFrame) |
||
289 | UIFrameFadeRemoveFrame(LowHealthFrame) |
||
290 | UIFrameFadeOut(LowHealthFrame, 0.5, LowHealthFrame:GetAlpha(), 0) |
||
291 | isFlashing = nil |
||
292 | end |
||
293 |