vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | local IMBA_SLASH_COMMAND = "/imba"; |
2 | IMBA_Version="1.4"; |
||
3 | |||
4 | IMBA_RaidVersions={}; |
||
5 | IMBA_Addons = {}; |
||
6 | IMBA_SavedVariables = {}; |
||
7 | IMBA_SavedVariables.Mods = {}; |
||
8 | -- Raid zones |
||
9 | IMBA_LOCATIONS_MC = "Molten Core"; |
||
10 | IMBA_LOCATIONS_BWL = "Blackwing Lair"; |
||
11 | IMBA_LOCATIONS_ZG = "Zul'Gurub"; |
||
12 | IMBA_LOCATIONS_AQ20 = "Ruins of Ahn'Qiraj"; |
||
13 | IMBA_LOCATIONS_AQ40 = "Temple of Ahn'Qiraj"; |
||
14 | IMBA_LOCATIONS_NAXX = "Naxxramas"; |
||
15 | IMBA_LOCATIONS_NAXX_ABOM = "Naxxramas - Abomination Wing"; |
||
16 | IMBA_LOCATIONS_NAXX_DK = "Naxxramas - Deathknight Wing"; |
||
17 | IMBA_LOCATIONS_NAXX_PLAGUE = "Naxxramas - Plague Wing"; |
||
18 | IMBA_LOCATIONS_NAXX_SPIDER = "Naxxramas - Spider Wing"; |
||
19 | IMBA_LOCATIONS_NAXX_LAIR = "Naxxramas - Frostwyrm Lair"; |
||
20 | |||
21 | IMBA_LOCATIONS_OTHER = "Other"; |
||
22 | |||
23 | |||
24 | IMBA_Locations = {{IMBA_LOCATIONS_MC,0}, {IMBA_LOCATIONS_BWL,0}, {IMBA_LOCATIONS_ZG,0}, {IMBA_LOCATIONS_AQ20,0}, {IMBA_LOCATIONS_AQ40,0}, { IMBA_LOCATIONS_NAXX_ABOM, 0 }, { IMBA_LOCATIONS_NAXX_DK, 0 }, { IMBA_LOCATIONS_NAXX_PLAGUE, 0 }, { IMBA_LOCATIONS_NAXX_SPIDER, 0 }, { IMBA_LOCATIONS_NAXX_LAIR, 0}, { IMBA_LOCATIONS_OTHER, 0}}; |
||
25 | |||
26 | IMBA_DEATH_MSG = "(.+) dies." |
||
27 | |||
28 | if (GetLocale()=="frFR") then |
||
29 | --Translation by A.su.K.A |
||
30 | IMBA_DEATH_MSG = "(.+) meurt." |
||
31 | end |
||
32 | |||
33 | function IMBA_SetBackdrops(num) |
||
34 | for k, v in IMBA_Addons do |
||
35 | if v.MainFrame~=nil then |
||
36 | getglobal(v.MainFrame):SetBackdrop(IMBA_BG[num].table); |
||
37 | getglobal(v.MainFrame):SetBackdropBorderColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,IMBA_SavedVariables.Colors["FrameBorder"].a); |
||
38 | getglobal(v.MainFrame):SetBackdropColor(IMBA_SavedVariables.Colors["FrameBG"].r,IMBA_SavedVariables.Colors["FrameBG"].g,IMBA_SavedVariables.Colors["FrameBG"].b,IMBA_SavedVariables.Colors["FrameBG"].a); |
||
39 | if getglobal(v.MainFrame.."_Close_Image") then |
||
40 | getglobal(v.MainFrame.."_Close_Image"):SetTexture(IMBA_BG[num].close); |
||
41 | getglobal(v.MainFrame.."_Close_Image"):SetVertexColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,IMBA_SavedVariables.Colors["FrameBorder"].a); |
||
42 | end |
||
43 | end |
||
44 | end |
||
45 | |||
46 | IMBA_Alerts:SetBackdrop(IMBA_BG[num].table); |
||
47 | if IMBA_SavedVariables.ShowAlertWindow then |
||
48 | IMBA_Alerts:SetBackdropBorderColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,IMBA_SavedVariables.Colors["FrameBorder"].a); |
||
49 | IMBA_Alerts:SetBackdropColor(IMBA_SavedVariables.Colors["FrameBG"].r,IMBA_SavedVariables.Colors["FrameBG"].g,IMBA_SavedVariables.Colors["FrameBG"].b,IMBA_SavedVariables.Colors["FrameBG"].a); |
||
50 | else |
||
51 | IMBA_Alerts:SetBackdropBorderColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,0); |
||
52 | IMBA_Alerts:SetBackdropColor(IMBA_SavedVariables.Colors["FrameBG"].r,IMBA_SavedVariables.Colors["FrameBG"].g,IMBA_SavedVariables.Colors["FrameBG"].b,0); |
||
53 | |||
54 | end |
||
55 | end |
||
56 | |||
57 | function IMBA_HideCloseButtons() |
||
58 | for k, v in IMBA_Addons do |
||
59 | if v.MainFrame~=nil then |
||
60 | if getglobal(v.MainFrame.."_Close") then |
||
61 | getglobal(v.MainFrame.."_Close"):Hide(); |
||
62 | end |
||
63 | end |
||
64 | end |
||
65 | end |
||
66 | |||
67 | function IMBA_ShowCloseButtons() |
||
68 | for k, v in IMBA_Addons do |
||
69 | if v.MainFrame~=nil then |
||
70 | if getglobal(v.MainFrame.."_Close") then |
||
71 | getglobal(v.MainFrame.."_Close"):Show(); |
||
72 | end |
||
73 | end |
||
74 | end |
||
75 | end |
||
76 | |||
77 | function IMBA_ResetPositions() |
||
78 | for k, v in IMBA_Addons do |
||
79 | if v.MainFrame~=nil then |
||
80 | getglobal(v.MainFrame):ClearAllPoints(); |
||
81 | getglobal(v.MainFrame):SetPoint("CENTER", "UIParent", "CENTER", 0, 0); |
||
82 | end |
||
83 | end |
||
84 | IMBA_Alerts:ClearAllPoints(); |
||
85 | IMBA_Alerts:SetPoint("CENTER", "UIParent", "CENTER", 0, 0); |
||
86 | end |
||
87 | |||
88 | function IMBA_AddAddon(BossName, Description, Location, RegenActivator, YellActivator, TestYell, MainFrame) |
||
89 | IMBA_Addons[BossName]={}; |
||
90 | IMBA_Addons[BossName].Active=true; |
||
91 | IMBA_Addons[BossName].Running=false; |
||
92 | IMBA_Addons[BossName].BossName=BossName; |
||
93 | IMBA_Addons[BossName].Location=Location; |
||
94 | IMBA_Addons[BossName].Description=Description; |
||
95 | IMBA_Addons[BossName].RegenActivator=RegenActivator; |
||
96 | IMBA_Addons[BossName].YellActivator=YellActivator; |
||
97 | IMBA_Addons[BossName].TestYell=TestYell; |
||
98 | IMBA_Addons[BossName].MainFrame=MainFrame; |
||
99 | IMBA_Addons[BossName].MultiBoss=0; |
||
100 | IMBA_Addons[BossName].BossNames={}; |
||
101 | |||
102 | IMBA_SavedVariables.Mods[BossName]={}; |
||
103 | IMBA_SavedVariables.Mods[BossName].Active=true; |
||
104 | IMBA_SavedVariables.Mods[BossName].Visible=false; |
||
105 | getglobal(MainFrame):Hide(); |
||
106 | |||
107 | --Sync Variables we track if the last change has been sent(delay by one cycle to allow for combat log variances), |
||
108 | --then check the last value to see if its change update the last value and set Sent to false |
||
109 | --The method determines how the variable gets sycned ("MAX" - whichever value is max gets chosen, "MIN" whatever value is minimum is chosen, "REPLACE" allows you to overwrite the value) |
||
110 | IMBA_Addons[BossName].SyncVariableFunc=nil; |
||
111 | IMBA_Addons[BossName].SyncVariablesSent={}; |
||
112 | IMBA_Addons[BossName].SyncVariablesLastVal={}; |
||
113 | IMBA_Addons[BossName].SyncVariablesMethod={}; |
||
114 | |||
115 | --DEFAULT_CHAT_FRAME:AddMessage("IMBA - "..BossName.." Added", 1.0, 1.0, 0.0); |
||
116 | end |
||
117 | |||
118 | function IMBA_AddBossName(AddonName,BossName) |
||
119 | IMBA_Addons[AddonName].MultiBoss=IMBA_Addons[AddonName].MultiBoss+1; |
||
120 | IMBA_Addons[AddonName].BossNames[IMBA_Addons[AddonName].MultiBoss]=BossName; |
||
121 | IMBA_Addons[AddonName].BossesAlive=IMBA_Addons[AddonName].MultiBoss; |
||
122 | end |
||
123 | |||
124 | function IMBA_AddOption(AddonName,OptionText,Func,ValueFunc) |
||
125 | if IMBA_Addons[AddonName].Options==nil then |
||
126 | IMBA_Addons[AddonName].Options={}; |
||
127 | end |
||
128 | IMBA_Addons[AddonName].Options[OptionText]={}; |
||
129 | IMBA_Addons[AddonName].Options[OptionText].text=OptionText; |
||
130 | IMBA_Addons[AddonName].Options[OptionText].valuefunc=ValueFunc; |
||
131 | IMBA_Addons[AddonName].Options[OptionText].func=Func; |
||
132 | |||
133 | if IMBA_Addons[AddonName].OptionsOrder==nil then |
||
134 | IMBA_Addons[AddonName].OptionsOrder={}; |
||
135 | end |
||
136 | tinsert(IMBA_Addons[AddonName].OptionsOrder,OptionText); |
||
137 | end |
||
138 | |||
139 | function IMBA_AddOption2(AddonName,VarName, OptionText) |
||
140 | if IMBA_SavedVariables.Mods[AddonName].Var==nil then |
||
141 | IMBA_SavedVariables.Mods[AddonName].Var={}; |
||
142 | IMBA_Addons[AddonName].VarText={}; |
||
143 | end |
||
144 | IMBA_SavedVariables.Mods[AddonName].Var[VarName]=false; |
||
145 | IMBA_Addons[AddonName].VarText[VarName]=OptionText; |
||
146 | |||
147 | if IMBA_Addons[AddonName].OptionsOrder2==nil then |
||
148 | IMBA_Addons[AddonName].OptionsOrder2={}; |
||
149 | end |
||
150 | tinsert(IMBA_Addons[AddonName].OptionsOrder2,VarName); |
||
151 | end |
||
152 | |||
153 | function IMBA_CheckVar(AddonName,VarName) |
||
154 | if IMBA_SavedVariables.Mods[AddonName]==nil then |
||
155 | IMBA_SavedVariables.Mods[AddonName]={}; |
||
156 | end |
||
157 | if IMBA_SavedVariables.Mods[AddonName].Var==nil then |
||
158 | IMBA_SavedVariables.Mods[AddonName].Var={}; |
||
159 | end |
||
160 | if IMBA_SavedVariables.Mods[AddonName].Var[VarName]==nil then |
||
161 | IMBA_SavedVariables.Mods[AddonName].Var[VarName]=false; |
||
162 | end |
||
163 | return IMBA_SavedVariables.Mods[AddonName].Var[VarName] |
||
164 | end |
||
165 | |||
166 | function IMBA_CheckSyncVariables(Addon) |
||
167 | for k, v in Addon.SyncVariablesLastVal do |
||
168 | --First Checking to see if need to send a variable |
||
169 | if Addon.SyncVariablesSent[k]==false then |
||
170 | SendAddonMessage("IMBA", "VARSYNC "..k.." "..Addon.SyncVariablesLastVal[k].." "..Addon.SyncVariablesMethod[k],"RAID"); |
||
171 | Addon.SyncVariablesSent[k]=true; |
||
172 | end |
||
173 | |||
174 | --Only want to potentially send if the variable has changed |
||
175 | if Addon.SyncVariablesLastVal[k]~=getglobal(k) then |
||
176 | Addon.SyncVariablesLastVal[k]=getglobal(k); |
||
177 | Addon.SyncVariablesSent[k]=false; |
||
178 | end |
||
179 | end |
||
180 | end |
||
181 | |||
182 | |||
183 | function IMBA_SyncVar(Addon,VarName,Value,Method) |
||
184 | if Method=="MAX" then |
||
185 | if Value>getglobal(VarName) then |
||
186 | setglobal(VarName,Value); |
||
187 | Addon.SyncVariablesLastVal[VarName]=Value; |
||
188 | Addon.SyncVariablesSent[VarName]=true; |
||
189 | if Addon.SyncVariableFunc~=nil then |
||
190 | getglobal(Addon.SyncVariableFunc)(); |
||
191 | end |
||
192 | end |
||
193 | elseif Method=="MIN" then |
||
194 | if Value<getglobal(VarName) then |
||
195 | setglobal(VarName,Value); |
||
196 | Addon.SyncVariablesLastVal[VarName]=Value; |
||
197 | Addon.SyncVariablesSent[VarName]=true; |
||
198 | if Addon.SyncVariableFunc~=nil then |
||
199 | getglobal(Addon.SyncVariableFunc)(); |
||
200 | end |
||
201 | end |
||
202 | elseif Method=="REPLACE" then |
||
203 | setglobal(VarName,Value); |
||
204 | Addon.SyncVariablesLastVal[VarName]=Value; |
||
205 | Addon.SyncVariablesSent[VarName]=true; |
||
206 | if Addon.SyncVariableFunc~=nil then |
||
207 | getglobal(Addon.SyncVariableFunc)(); |
||
208 | end |
||
209 | end |
||
210 | end |
||
211 | |||
212 | |||
213 | function IMBA_AddSyncVar(Addon,VarName,Method) |
||
214 | IMBA_Addons[Addon].SyncVariablesSent[VarName]=true; |
||
215 | IMBA_Addons[Addon].SyncVariablesLastVal[VarName]=getglobal(VarName); |
||
216 | IMBA_Addons[Addon].SyncVariablesMethod[VarName]=Method; |
||
217 | end |
||
218 | |||
219 | function IMBA_SetSyncFunction(Addon,Func) |
||
220 | IMBA_Addons[Addon].SyncVariableFunc=Func; |
||
221 | end |
||
222 | |||
223 | function IMBA_CheckIfRunning(Addon) |
||
224 | return IMBA_Addons[Addon].Running; |
||
225 | end |
||
226 | |||
227 | function IMBA_OnUpdate() |
||
228 | --First do we need to check for boss mod activations based on regen and is it time to? |
||
229 | if IMBA_CheckRegen and (IMBA_CheckRegenTimer < GetTime()) then |
||
230 | IMBA_CheckRegen=false; |
||
231 | for k, v in IMBA_Addons do |
||
232 | if v.Active and (v.RegenActivator ~= nil) and (v.Running==false) then |
||
233 | if v.MultiBoss==0 then |
||
234 | if IMBA_BossAggroed(v.BossName) then |
||
235 | IMBA_CombatCheckTime=GetTime()+10; --Next Time to Check in Combat |
||
236 | IMBA_SyncTime=GetTime()+2+2*math.random(); --We add a random delay to the variable syncing |
||
237 | IMBA_AddonRunning=true; |
||
238 | |||
239 | v.Running=true; |
||
240 | |||
241 | getglobal(v.RegenActivator)(); |
||
242 | |||
243 | SendAddonMessage("IMBA", "STARTADDON "..string.gsub(v.BossName," ","*"),"RAID"); |
||
244 | end |
||
245 | else |
||
246 | for i=1,v.MultiBoss do |
||
247 | if IMBA_BossAggroed(v.BossNames[i]) then |
||
248 | IMBA_CombatCheckTime=GetTime()+10; --Next Time to Check in Combat |
||
249 | IMBA_SyncTime=GetTime()+2+2*math.random(); --We add a random delay to the variable syncing |
||
250 | IMBA_AddonRunning=true; |
||
251 | |||
252 | v.Running=true; |
||
253 | |||
254 | getglobal(v.RegenActivator)(); |
||
255 | |||
256 | v.BossesAlive=v.MultiBoss; |
||
257 | |||
258 | SendAddonMessage("IMBA", "STARTADDON "..string.gsub(v.BossName," ","*"),"RAID"); |
||
259 | end |
||
260 | end |
||
261 | end |
||
262 | end |
||
263 | end |
||
264 | end |
||
265 | |||
266 | --Alright if Addons are running |
||
267 | if IMBA_AddonRunning then |
||
268 | if IMBA_CombatCheckTime<GetTime() then |
||
269 | IMBA_AddonRunning=IMBA_RaidInCombat(); |
||
270 | if IMBA_AddonRunning==false then |
||
271 | for k, v in IMBA_Addons do |
||
272 | v.Running=false; |
||
273 | end |
||
274 | end |
||
275 | end |
||
276 | |||
277 | --If still running we can sync variables etc |
||
278 | if IMBA_AddonRunning then |
||
279 | if IMBA_SyncTime<GetTime() then |
||
280 | for k, v in IMBA_Addons do |
||
281 | if v.Running then |
||
282 | IMBA_CheckSyncVariables(v); |
||
283 | end |
||
284 | end |
||
285 | |||
286 | IMBA_SyncTime=GetTime()+7.5+2.5*math.random(); |
||
287 | end |
||
288 | else--Otherwise deactivate all addons |
||
289 | for k, v in IMBA_Addons do |
||
290 | v.Running=false; |
||
291 | end |
||
292 | end |
||
293 | end |
||
294 | |||
295 | if IMBA_CheckVisibility<GetTime() then |
||
296 | for k, v in IMBA_Addons do |
||
297 | if v.MainFrame~=nil then |
||
298 | IMBA_SavedVariables.Mods[k].Visible=getglobal(v.MainFrame):IsShown(); |
||
299 | end |
||
300 | end |
||
301 | IMBA_CheckVisibility=GetTime()+0.25; |
||
302 | end |
||
303 | end |
||
304 | |||
305 | function IMBA_LoadColors() |
||
306 | if IMBA_SavedVariables.Colors==nil then |
||
307 | IMBA_SavedVariables.Colors={}; |
||
308 | end |
||
309 | if IMBA_SavedVariables.Colors["FrameBG"]==nil then |
||
310 | IMBA_SavedVariables.Colors["FrameBG"]={r=0,g=0,b=0,a=0.6}; |
||
311 | end |
||
312 | if IMBA_SavedVariables.Colors["FrameBorder"]==nil then |
||
313 | IMBA_SavedVariables.Colors["FrameBorder"]={r=1,g=1,b=1,a=1}; |
||
314 | end |
||
315 | if IMBA_SavedVariables.Colors["BarStart"]==nil then |
||
316 | IMBA_SavedVariables.Colors["BarStart"]={r=1,g=1,b=1}; |
||
317 | end |
||
318 | if IMBA_SavedVariables.Colors["BarEnd"]==nil then |
||
319 | IMBA_SavedVariables.Colors["BarEnd"]={r=1,g=1,b=1}; |
||
320 | end |
||
321 | |||
322 | if IMBA_SavedVariables.Colors["BarInner"]==nil then |
||
323 | IMBA_SavedVariables.Colors["BarInner"]={r=0.4,g=0.4,b=0.4,a=0.6}; |
||
324 | end |
||
325 | if IMBA_SavedVariables.Colors["BarBorder"]==nil then |
||
326 | IMBA_SavedVariables.Colors["BarBorder"]={r=0.9,g=0.9,b=0.9,a=0.6}; |
||
327 | end |
||
328 | end |
||
329 | |||
330 | function IMBA_OnEvent(event) |
||
331 | if event=="PLAYER_REGEN_DISABLED" then |
||
332 | IMBA_CheckRegen=true; |
||
333 | IMBA_CheckRegenTimer=GetTime()+5; |
||
334 | elseif event=="CHAT_MSG_MONSTER_YELL" then |
||
335 | for k, v in IMBA_Addons do |
||
336 | if v.Active and (v.YellActivator ~= nil) and (v.Running~=true) then |
||
337 | if IMBA_AddonRunning==false then |
||
338 | IMBA_CombatCheckTime=GetTime()+10; --Next Time to Check in Combat |
||
339 | IMBA_SyncTime=GetTime()+2+2*math.random(); --We add a random delay to the variable syncing |
||
340 | end |
||
341 | v.Running=v.Running or getglobal(v.YellActivator)(arg1); |
||
342 | IMBA_AddonRunning=IMBA_AddonRunning or v.Running; |
||
343 | end |
||
344 | end |
||
345 | elseif event=="CHAT_MSG_ADDON" then |
||
346 | if arg1=="IMBA" then |
||
347 | local commandName, params = IMBA_ExtractNextParam(arg2); |
||
348 | if commandName=="VARSYNC" then |
||
349 | local Addon, VarName, Value, Method; |
||
350 | VarName, params = IMBA_ExtractNextParam(params); |
||
351 | Value, params = IMBA_ExtractNextParam(params); |
||
352 | Method, params = IMBA_ExtractNextParam(params); |
||
353 | for k, v in IMBA_Addons do |
||
354 | for k2, v2 in v.SyncVariablesLastVal do |
||
355 | if k2==VarName then |
||
356 | IMBA_SyncVar(v,VarName,tonumber(Value),Method); |
||
357 | end |
||
358 | end |
||
359 | end |
||
360 | elseif commandName=="STARTADDON" then |
||
361 | local Addon |
||
362 | Addon,params=IMBA_ExtractNextParam(params); |
||
363 | Addon=string.gsub(Addon,"*"," "); |
||
364 | if IMBA_Addons[Addon] then |
||
365 | if (not IMBA_CheckIfRunning(Addon)) and IMBA_Addons[Addon].Active and IMBA_Addons[Addon].RegenActivator then |
||
366 | if getglobal(IMBA_Addons[Addon].RegenActivator) then |
||
367 | getglobal(IMBA_Addons[Addon].RegenActivator)(); |
||
368 | IMBA_Addons[Addon].Running=true; |
||
369 | IMBA_Addons[Addon].BossesAlive=IMBA_Addons[Addon].MultiBoss; |
||
370 | IMBA_CombatCheckTime=GetTime()+10; --Next Time to Check in Combat |
||
371 | IMBA_SyncTime=GetTime()+2+2*math.random(); --We add a random delay to the variable syncing |
||
372 | IMBA_AddonRunning=true; |
||
373 | end |
||
374 | end |
||
375 | end |
||
376 | elseif commandName=="VERSCHECK" then |
||
377 | SendAddonMessage("IMBA", "VERSNUM "..IMBA_Version,"RAID"); |
||
378 | elseif commandName=="VERSNUM" then |
||
379 | IMBA_RaidVersions[arg4]=params; |
||
380 | end |
||
381 | end |
||
382 | elseif event=="PLAYER_LOGIN" then |
||
383 | if IMBA_SavedVariables then |
||
384 | for k2, v2 in IMBA_Addons do |
||
385 | local FoundModSettings; |
||
386 | FoundModSettings=false |
||
387 | for k, v in IMBA_SavedVariables.Mods do |
||
388 | if k==k2 then |
||
389 | v2.Active=v.Active; |
||
390 | if v2.MainFrame then |
||
391 | if v.Visible then |
||
392 | getglobal(v2.MainFrame):Show(); |
||
393 | else |
||
394 | getglobal(v2.MainFrame):Hide(); |
||
395 | end |
||
396 | end |
||
397 | FoundModSettings=true; |
||
398 | end |
||
399 | end |
||
400 | if FoundModSettings==false then |
||
401 | IMBA_SavedVariables.Mods[k2]={}; |
||
402 | IMBA_SavedVariables.Mods[k2].Visible=false; |
||
403 | getglobal(v2.MainFrame):Hide(); |
||
404 | IMBA_SavedVariables.Mods[k2].Active=true; |
||
405 | end |
||
406 | end |
||
407 | else |
||
408 | IMBA_SavedVariables={}; |
||
409 | IMBA_SavedVariables.Mods={}; |
||
410 | for k, v in IMBA_Addons do |
||
411 | IMBA_SavedVariables.Mods[k]={}; |
||
412 | IMBA_SavedVariables.Mods[k].Visible=false; |
||
413 | getglobal(v.MainFrame):Hide(); |
||
414 | IMBA_SavedVariables.Mods[k].Active=true; |
||
415 | end |
||
416 | end |
||
417 | |||
418 | if IMBA_SavedVariables.Scale==nil then |
||
419 | IMBA_SavedVariables.Scale=1; |
||
420 | end |
||
421 | |||
422 | if IMBA_SavedVariables.BarTextureNum==nil then |
||
423 | IMBA_SavedVariables.BarTextureNum=1; |
||
424 | end |
||
425 | |||
426 | if IMBA_SavedVariables.FrameType==nil then |
||
427 | IMBA_SavedVariables.FrameType=1; |
||
428 | end |
||
429 | IMBA_LoadColors(); |
||
430 | IMBA_SetBackdrops(IMBA_SavedVariables.FrameType); |
||
431 | |||
432 | IMBA_SetScale(true); |
||
433 | IMBA_Options_GraphicsFrame_Slider_Scale:SetValue(IMBA_SavedVariables.Scale); |
||
434 | IMBA_Options_GraphicsFrame_Slider_ScaleText:SetText(string.format("Window Scale Size : %.2f",IMBA_SavedVariables.Scale)); |
||
435 | |||
436 | IMBA_SetScaleAlert(true); |
||
437 | IMBA_Options_GraphicsFrame_Slider_ScaleAlert:SetValue(IMBA_SavedVariables.ScaleAlert); |
||
438 | IMBA_Alert1:SetText("",0); |
||
439 | IMBA_Alert2:SetText("",0); |
||
440 | IMBA_Alert3:SetText("",0); |
||
441 | |||
442 | if IMBA_SavedVariables.ButtonPos==nil then |
||
443 | IMBA_SavedVariables.ButtonPos=300; |
||
444 | end |
||
445 | IMBA_Options_GraphicsFrame_Slider_Icon:SetValue(IMBA_SavedVariables.ButtonPos); |
||
446 | IMBA_Options_GraphicsFrame_Slider_IconText:SetText(string.format("Minimap Icon Position : %.0f",IMBA_SavedVariables.ButtonPos)); |
||
447 | |||
448 | if IMBA_SavedVariables.LockedWindows then |
||
449 | IMBA_LockWindows(); |
||
450 | else |
||
451 | IMBA_UnlockWindows() |
||
452 | end |
||
453 | |||
454 | if IMBA_SavedVariables.HideClose==nil then |
||
455 | IMBA_SavedVariables.HideClose=false; |
||
456 | end |
||
457 | |||
458 | if IMBA_SavedVariables.HideClose then |
||
459 | IMBA_HideCloseButtons() |
||
460 | else |
||
461 | IMBA_ShowCloseButtons() |
||
462 | end |
||
463 | if IMBA_SavedVariables.HideMinimapIcon then |
||
464 | IMBA_OptionsButton:Hide(); |
||
465 | else |
||
466 | IMBA_OptionsButton:Show(); |
||
467 | end |
||
468 | |||
469 | if IMBA_SavedVariables.ShowAlertWindow then |
||
470 | IMBA_Alerts.isLocked=false; |
||
471 | IMBA_Alerts:EnableMouse(true); |
||
472 | IMBA_Alerts:SetMovable(true); |
||
473 | IMBA_Alerts:SetBackdropBorderColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,IMBA_SavedVariables.Colors["FrameBorder"].a); |
||
474 | IMBA_Alerts:SetBackdropColor(IMBA_SavedVariables.Colors["FrameBG"].r,IMBA_SavedVariables.Colors["FrameBG"].g,IMBA_SavedVariables.Colors["FrameBG"].b,IMBA_SavedVariables.Colors["FrameBG"].a); |
||
475 | else |
||
476 | IMBA_Alerts.isLocked=true; |
||
477 | IMBA_Alerts:EnableMouse(false); |
||
478 | IMBA_Alerts:SetMovable(false); |
||
479 | IMBA_Alerts:SetBackdropBorderColor(IMBA_SavedVariables.Colors["FrameBorder"].r,IMBA_SavedVariables.Colors["FrameBorder"].g,IMBA_SavedVariables.Colors["FrameBorder"].b,0); |
||
480 | IMBA_Alerts:SetBackdropColor(IMBA_SavedVariables.Colors["FrameBG"].r,IMBA_SavedVariables.Colors["FrameBG"].g,IMBA_SavedVariables.Colors["FrameBG"].b,0); |
||
481 | end |
||
482 | |||
483 | IMBA_CheckVisibility=GetTime()+2.5; |
||
484 | |||
485 | if not IMBA_SavedVariables.CombatLogDist then |
||
486 | IMBA_SavedVariables.CombatLogDist=200; |
||
487 | end |
||
488 | IMBA_Options_GraphicsFrame_Slider_CombatLogDist:SetValue(IMBA_SavedVariables.CombatLogDist); |
||
489 | IMBA_Options_GraphicsFrame_Slider_CombatLogDistText:SetText(string.format("Combat Log Distance : %.0f",IMBA_SavedVariables.CombatLogDist)); |
||
490 | |||
491 | IMBA_SetLogDistance(IMBA_SavedVariables.CombatLogDist); |
||
492 | |||
493 | if not SCT_MSG_FRAME then |
||
494 | IMBA_Options_GraphicsFrame_UseSCTForAlerts:Hide(); |
||
495 | end |
||
496 | if IMBA_SavedVariables.UseSCTForAlerts then |
||
497 | IMBA_Options_GraphicsFrame_UseSCTForAlerts:SetChecked(IMBA_SavedVariables.UseSCTForAlerts) |
||
498 | end |
||
499 | |||
500 | IMBA_Loaded = true; |
||
501 | elseif event=="CHAT_MSG_COMBAT_HOSTILE_DEATH" then |
||
502 | local _,_, MobName = string.find(arg1,IMBA_DEATH_MSG); |
||
503 | |||
504 | if MobName then |
||
505 | for k, v in IMBA_Addons do |
||
506 | if getglobal(v.MainFrame):IsShown() then |
||
507 | if not (v.MultiBoss>0) then |
||
508 | if k==MobName then |
||
509 | getglobal(v.MainFrame):Hide(); |
||
510 | v.Running=false; |
||
511 | end |
||
512 | else |
||
513 | for i=1,v.MultiBoss do |
||
514 | if MobName==v.BossNames[i] then |
||
515 | v.BossesAlive=v.BossesAlive-1; |
||
516 | if v.BossesAlive<=0 then |
||
517 | getglobal(v.MainFrame):Hide(); |
||
518 | v.Running=false; |
||
519 | end |
||
520 | end |
||
521 | end |
||
522 | end |
||
523 | end |
||
524 | end |
||
525 | end |
||
526 | end |
||
527 | end |
||
528 | |||
529 | function IMBA_Command(msg) |
||
530 | msg=strlower(msg); |
||
531 | if msg=="lock" then |
||
532 | IMBA_LockWindows(); |
||
533 | elseif msg=="unlock" then |
||
534 | IMBA_UnlockWindows(); |
||
535 | elseif msg=="options" then |
||
536 | IMBA_Options:Show(); |
||
537 | elseif msg=="minimap" then |
||
538 | if IMBA_SavedVariables.HideMinimapIcon then |
||
539 | IMBA_SavedVariables.HideMinimapIcon=false; |
||
540 | IMBA_OptionsButton:Show(); |
||
541 | else |
||
542 | IMBA_SavedVariables.HideMinimapIcon=true; |
||
543 | IMBA_OptionsButton:Hide(); |
||
544 | end |
||
545 | IMBA_Options_GraphicsFrame_HideMinimapIcon:SetChecked(IMBA_SavedVariables.HideMinimapIcon) |
||
546 | else |
||
547 | DEFAULT_CHAT_FRAME:AddMessage("IMBA Commands "..IMBA_Version, 1.0, 1.0, 0.0); |
||
548 | DEFAULT_CHAT_FRAME:AddMessage(" lock - Locks all windows", 1.0, 1.0, 0.0); |
||
549 | DEFAULT_CHAT_FRAME:AddMessage(" minimap - Toggles Minimap Icon", 1.0, 1.0, 0.0); |
||
550 | DEFAULT_CHAT_FRAME:AddMessage(" options - Shows the options window", 1.0, 1.0, 0.0); |
||
551 | DEFAULT_CHAT_FRAME:AddMessage(" unlock - Unlocks all windows", 1.0, 1.0, 0.0); |
||
552 | end |
||
553 | |||
554 | end |
||
555 | |||
556 | function IMBA_SetScale(loading) |
||
557 | for k, v in IMBA_Addons do |
||
558 | if v.MainFrame then |
||
559 | if getglobal(v.MainFrame) then |
||
560 | if not loading then |
||
561 | local pointNum=getglobal(v.MainFrame):GetNumPoints() |
||
562 | local curScale=getglobal(v.MainFrame):GetScale(); |
||
563 | local pointsCleared=false |
||
564 | local points={} |
||
565 | for i=1,pointNum,1 do |
||
566 | points[i]={}; |
||
567 | points[i][1], points[i][2], points[i][3], points[i][4], points[i][5]=getglobal(v.MainFrame):GetPoint(i) |
||
568 | points[i][4]=points[i][4]*curScale/IMBA_SavedVariables.Scale; |
||
569 | points[i][5]=points[i][5]*curScale/IMBA_SavedVariables.Scale; |
||
570 | end |
||
571 | pointsCleared=false |
||
572 | for i=1,pointNum,1 do |
||
573 | if points[i][1] and points[i][2] and points[i][3] and points[i][4] and points[i][5] then |
||
574 | if not pointsCleared then |
||
575 | getglobal(v.MainFrame):ClearAllPoints() |
||
576 | pointsCleared=true; |
||
577 | end |
||
578 | getglobal(v.MainFrame):SetPoint(points[i][1],UIParent,points[i][3],points[i][4],points[i][5]); |
||
579 | end |
||
580 | end |
||
581 | end |
||
582 | getglobal(v.MainFrame):SetScale(IMBA_SavedVariables.Scale); |
||
583 | end |
||
584 | end |
||
585 | end |
||
586 | end |
||
587 | |||
588 | function IMBA_LockWindows() |
||
589 | for k, v in IMBA_Addons do |
||
590 | if v.MainFrame then |
||
591 | getglobal(v.MainFrame).isLocked=true; |
||
592 | end |
||
593 | end |
||
594 | IMBA_SavedVariables.LockedWindows=true; |
||
595 | DEFAULT_CHAT_FRAME:AddMessage("IMBA - Windows Locked", 1.0, 1.0, 0.0); |
||
596 | end |
||
597 | function IMBA_UnlockWindows() |
||
598 | for k, v in IMBA_Addons do |
||
599 | if v.MainFrame then |
||
600 | getglobal(v.MainFrame).isLocked=false; |
||
601 | end |
||
602 | end |
||
603 | IMBA_SavedVariables.LockedWindows=false; |
||
604 | DEFAULT_CHAT_FRAME:AddMessage("IMBA - Windows Unlocked", 1.0, 1.0, 0.0); |
||
605 | end |
||
606 | |||
607 | function IMBA_RegisterEvents() |
||
608 | this:RegisterEvent("CHAT_MSG_MONSTER_YELL"); |
||
609 | this:RegisterEvent("PLAYER_REGEN_DISABLED"); |
||
610 | this:RegisterEvent("CHAT_MSG_ADDON"); |
||
611 | this:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH"); |
||
612 | this:RegisterEvent("PLAYER_LOGIN"); |
||
613 | end |
||
614 | |||
615 | function IMBA_UnregisterEvents() |
||
616 | this:UnregisterEvent("CHAT_MSG_MONSTER_YELL"); |
||
617 | this:UnregisterEvent("PLAYER_REGEN_DISABLED"); |
||
618 | this:UnregisterEvent("CHAT_MSG_ADDON"); |
||
619 | this:UnregisterEvent("PLAYER_LOGIN"); |
||
620 | this:UnregisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH") |
||
621 | end |
||
622 | |||
623 | function IMBA_CloseAllWindows() |
||
624 | for k, v in IMBA_Addons do |
||
625 | if v.MainFrame then |
||
626 | getglobal(v.MainFrame):Hide(); |
||
627 | end |
||
628 | end |
||
629 | end |
||
630 | |||
631 | function IMBA_OnLoad() |
||
632 | DEFAULT_CHAT_FRAME:AddMessage("IMBA (IMPervious Boss Addons) "..IMBA_Version.." is Loading", 1.0, 1.0, 0.0); |
||
633 | |||
634 | |||
635 | IMBA_LoadColors(); |
||
636 | IMBA_RegisterEvents(); |
||
637 | |||
638 | |||
639 | --Register the slash commands |
||
640 | SLASH_IMBA1= IMBA_SLASH_COMMAND; |
||
641 | SlashCmdList["IMBA"] = function(msg) |
||
642 | IMBA_Command(msg); |
||
643 | end |
||
644 | |||
645 | |||
646 | IMBA_AddonRunning=false; --To check if an addon is currently doing something |
||
647 | IMBA_CombatCheckTime=0; --Last time checked if still in combat |
||
648 | IMBA_SyncTime=0; --Last Time synced |
||
649 | IMBA_CheckVisibility=GetTime()+1000000000; --Don't want it to start checking till variables are loaded |
||
650 | IMBA_SavedVariables.Mods={}; |
||
651 | |||
652 | DEFAULT_CHAT_FRAME:AddMessage(" Access the command via /imba", 1.0, 1.0, 0.0); |
||
653 | end |
||
654 | |||
655 |