comparison Hansgar_And_Franzok_Assist.lua @ 5:789bf9e40966

Version v0.6 change log: - new command /hansgar users: show who is using the addon in the raid. - new command /hansgar lock: lock or unlock the frame. - new command /hansgar dance: toggle the dance bar. - fixed the cooldown animation.
author Tercio
date Thu, 05 Mar 2015 16:30:25 -0300
parents 1c3534391efb
children 3121ac72fcda
comparison
equal deleted inserted replaced
4:1c3534391efb 5:789bf9e40966
6 local GetNumGroupMembers = GetNumGroupMembers 6 local GetNumGroupMembers = GetNumGroupMembers
7 local abs = abs 7 local abs = abs
8 8
9 local f = CreateFrame ("frame", "Hansgar_And_Franzok_Assist", UIParent) 9 local f = CreateFrame ("frame", "Hansgar_And_Franzok_Assist", UIParent)
10 f:SetFrameStrata ("DIALOG") 10 f:SetFrameStrata ("DIALOG")
11 f.version = "v0.6"
11 12
12 local tframe = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_PTrack", UIParent) 13 local tframe = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_PTrack", UIParent)
13 14
14 f:SetSize (155, 156) 15 f:SetSize (155, 156)
15 f:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = -1, right = -1, top = -1, bottom = -1}, 16 f:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = -1, right = -1, top = -1, bottom = -1},
17 f:SetPoint ("center", UIParent, "center") 18 f:SetPoint ("center", UIParent, "center")
18 f:SetBackdropColor (0, 0, 0, 0) 19 f:SetBackdropColor (0, 0, 0, 0)
19 f:SetBackdropBorderColor (0, 0, 0, 1) 20 f:SetBackdropBorderColor (0, 0, 0, 1)
20 f:SetMovable (true) 21 f:SetMovable (true)
21 f:EnableMouse (true) 22 f:EnableMouse (true)
23 f.all_blocks = {}
22 f:Hide() 24 f:Hide()
23 25
24 local title = f:CreateFontString (nil, "overlay", "GameFontNormal") 26 local title = f:CreateFontString (nil, "overlay", "GameFontNormal")
25 title:SetText ("Hansgar & Franzok Assist") 27 title:SetText ("Hansgar & Franzok Assist")
26 title:SetPoint ("center", f, "center") 28 title:SetPoint ("center", f, "center")
103 local AceTimer = LibStub:GetLibrary ("AceTimer-3.0") 105 local AceTimer = LibStub:GetLibrary ("AceTimer-3.0")
104 AceTimer:Embed (f) 106 AceTimer:Embed (f)
105 local AceComm = LibStub:GetLibrary ("AceComm-3.0") 107 local AceComm = LibStub:GetLibrary ("AceComm-3.0")
106 AceComm:Embed (f) 108 AceComm:Embed (f)
107 109
110 function f:CommReceived (_, data, _, source)
111 if (data == "US") then
112 f:SendCommMessage ("HAFR", UnitName ("player") .. " " .. f.version, "RAID")
113 else
114 f.users [data] = true
115 end
116 end
117 function f:ShowUsers()
118 f.users_schedule = nil
119
120 local users_frame = Hansgar_And_Franzok_Assist_UsersPanel
121 if (not users_frame) then
122 users_frame = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_UsersPanel", UIParent)
123 users_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = -1, right = -1, top = -1, bottom = -1},
124 edgeFile = "Interface\\AddOns\\Hansgar_And_Franzok_Assist\\border_2", edgeSize = 8})
125 users_frame:SetBackdropColor (0, 0, 0, 1)
126 tinsert (UISpecialFrames, "Hansgar_And_Franzok_Assist_UsersPanel")
127 users_frame:SetSize (200, 500)
128 users_frame:SetPoint ("right", f, "left", -15, 0)
129 users_frame.text = users_frame:CreateFontString (nil, "overlay", "GameFontHighlight")
130 users_frame.text:SetPoint ("topleft", users_frame, "topleft", 10, -10)
131 users_frame.text:SetJustifyH ("left")
132
133 users_frame.title = users_frame:CreateFontString (nil, "overlay", "GameFontNormal")
134 users_frame.title:SetText ("Hansgar & Franzok Assist: Users")
135 users_frame.title:SetPoint ("center", users_frame, "center")
136 users_frame.title:SetPoint ("bottom", users_frame, "top", 0, 2)
137
138 end
139
140 local s = ""
141
142 for key, value in pairs (f.users) do
143 s = s .. "|cFF33FF33" .. key .. "\n"
144 end
145
146 s = s .. "|r\n\n\n|cFFFFFFFFOut of Date or Not installed:|r\n\n"
147
148 for i = 1, GetNumGroupMembers() do
149 local name = UnitName ("raid" .. i)
150 if (not s:find (name)) then
151 s = s .. "|cFFFF3333" .. name .. "|r\n"
152 end
153 end
154
155 users_frame.text:SetText (s)
156
157 users_frame:Show()
158
159 end
160 f:RegisterComm ("HAFR", "CommReceived")
161
108 local db 162 local db
109 163
110 f.block_tracker = {} 164 f.block_tracker = {}
111 165
112 frame_event:SetFrameStrata ("FULLSCREEN") 166 frame_event:SetFrameStrata ("FULLSCREEN")
126 db.CD_NUMBER = false 180 db.CD_NUMBER = false
127 end 181 end
128 if (db.SHOW_DANCE == nil) then 182 if (db.SHOW_DANCE == nil) then
129 db.SHOW_DANCE = true 183 db.SHOW_DANCE = true
130 end 184 end
185 if (db.FRAME_LOCK == nil) then
186 db.FRAME_LOCK = false
187 end
131 -- 188 --
132 SLASH_Hansgar_And_Franzok_Assist1, SLASH_Hansgar_And_Franzok_Assist2 = "/hansgar", "/franzok" 189 SLASH_Hansgar_And_Franzok_Assist1, SLASH_Hansgar_And_Franzok_Assist2 = "/hansgar", "/franzok"
133 function SlashCmdList.Hansgar_And_Franzok_Assist (msg, editbox) 190 function SlashCmdList.Hansgar_And_Franzok_Assist (msg, editbox)
134 191
135 local command, rest = msg:match ("^(%S*)%s*(.-)$") 192 local command, rest = msg:match ("^(%S*)%s*(.-)$")
136 193
137 if (command == "delay") then 194 if (command == "users") then
195 if (f.users_schedule) then
196 print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
197 elseif (IsInRaid()) then
198 f.users = {}
199 f:SendCommMessage ("HAFR", "US", "RAID")
200 f.users_schedule = f:ScheduleTimer ("ShowUsers", 5)
201 print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
202 else
203 print ("|cFFFFAA00Hansgar and Franzok Assist|r you aren't in a raid group.")
204 end
205
206 elseif (command == "delay") then
138 local t = tonumber (rest) 207 local t = tonumber (rest)
139 if (t) then 208 if (t) then
140 db.STAMPERS_DELAY = t 209 db.STAMPERS_DELAY = t
141 print ("|cFFFFAA00Hansgar and Franzok Assist|r delay set to: ", t) 210 print ("|cFFFFAA00Hansgar and Franzok Assist|r delay set to: ", t)
142 else 211 else
156 if (f.StampersPhase) then 225 if (f.StampersPhase) then
157 return f:StopTracking() 226 return f:StopTracking()
158 end 227 end
159 f:EndTrackPlayerPosition() 228 f:EndTrackPlayerPosition()
160 229
230 elseif (command == "lock") then
231 f:SetLockState()
232
233 if (db.FRAME_LOCK) then
234 print ("|cFFFFAA00Hansgar and Franzok Assist|r frame locked.")
235 else
236 print ("|cFFFFAA00Hansgar and Franzok Assist|r frame unlocked.")
237 end
238
161 elseif (command == "dance") then 239 elseif (command == "dance") then
162 db.SHOW_DANCE = not db.SHOW_DANCE 240 db.SHOW_DANCE = not db.SHOW_DANCE
163 if (db.SHOW_DANCE) then 241 if (db.SHOW_DANCE) then
164 if (f.on_encounter) then 242 if (f.on_encounter) then
165 f:StartTrackPlayerPosition() 243 f:StartTrackPlayerPosition()
173 elseif (command == "cooldown") then 251 elseif (command == "cooldown") then
174 db.CD_NUMBER = not db.CD_NUMBER 252 db.CD_NUMBER = not db.CD_NUMBER
175 f:RefreshCooldownSettings() 253 f:RefreshCooldownSettings()
176 254
177 else 255 else
178 print ("|cFFFFAA00Hansgar and Franzok Assist|r |cFF00FF00v0.5|r Commands:") 256 print ("|cFFFFAA00Hansgar and Franzok Assist|r |cFF00FF00" .. f.version .. "|r Commands:")
257 print ("|cFFFFFF00/hansgar lock|r: toggle lock and unlock on the frame.")
258 print ("|cFFFFFF00/hansgar test show hide|r: active the addon on test mode or hide it.")
179 print ("|cFFFFFF00/hansgar delay <time>|r: time in seconds until the percentage goes from 0 to 100.") 259 print ("|cFFFFFF00/hansgar delay <time>|r: time in seconds until the percentage goes from 0 to 100.")
180 print ("|cFFFFFF00/hansgar cooldown|r: show the countdown for each stamper go back up to the ceiling.") 260 print ("|cFFFFFF00/hansgar dance|r: toggle dance bar (used to dodge regular stampers and searing plates).")
181 --print ("|cFFFFFF00/hansgar dance|r: toggle dance bar (used to dodge regular stampers and searing plates).") 261 print ("|cFFFFFF00/hansgar users|r: show who is using the addon in the raid.")
182 print ("|cFFFFFF00/hansgar test|r: active the addon on test mode.") 262 print ("|cFFFFFF00/hansgar cooldown|r: show the countdown text for each stamper go back up to the ceiling.")
183 print ("|cFFFFFF00/hansgar show|r: show the window and start test mode.")
184 print ("|cFFFFFF00/hansgar hide|r: hide the window.")
185 end 263 end
186 end 264 end
187 265
188 elseif (event == "ENCOUNTER_START" or event == "ENCOUNTER_END") then 266 elseif (event == "ENCOUNTER_START" or event == "ENCOUNTER_END") then
189 267
236 314
237 f:SetScript ("OnEvent", function (self, event, time, token, _, who_serial, who_name, who_flags, _, target_serial, target_name, target_flags, _, spellid, spellname, spellschool, buff_type, ...) 315 f:SetScript ("OnEvent", function (self, event, time, token, _, who_serial, who_name, who_flags, _, target_serial, target_name, target_flags, _, spellid, spellname, spellschool, buff_type, ...)
238 316
239 if (token == "SPELL_AURA_APPLIED" and spellid == 162124 and not f.StampersPhase) then 317 if (token == "SPELL_AURA_APPLIED" and spellid == 162124 and not f.StampersPhase) then
240 f:StartTracking() 318 f:StartTracking()
319 f:EndTrackPlayerPosition()
241 320
242 elseif (token == "SPELL_AURA_REMOVED" and spellid == 162124 and f.StampersPhase) then 321 elseif (token == "SPELL_AURA_REMOVED" and spellid == 162124 and f.StampersPhase) then
243 f:StopTracking() 322 f:StopTracking()
323 if (db.SHOW_DANCE) then
324 f:StartTrackPlayerPosition()
325 end
244 326
245 end 327 end
246 328
247 end) 329 end)
248 330
305 frame_tracker:SetScript ("OnUpdate", on_update_tracker) 387 frame_tracker:SetScript ("OnUpdate", on_update_tracker)
306 f:Show() 388 f:Show()
307 end 389 end
308 390
309 function f:StopTracking() 391 function f:StopTracking()
310
311 print ("|cFFFFAA00Hansgar and Franzok Assist|r: Smart Stampers phase ended.") 392 print ("|cFFFFAA00Hansgar and Franzok Assist|r: Smart Stampers phase ended.")
312 393
313 f.StampersPhase = false 394 f.StampersPhase = false
314 frame_tracker:SetScript ("OnUpdate", nil) 395 frame_tracker:SetScript ("OnUpdate", nil)
315 table.wipe (f.block_tracker) 396 table.wipe (f.block_tracker)
316 f.player_loc_box:Hide() 397 f.player_loc_box:Hide()
317 f:Hide() 398 f:Hide()
318 end 399 end
319 400
320 local on_mouse_down = function (self) 401 local on_mouse_down = function (self)
321 if (not self.isMoving) then 402 if (not self.isMoving and not db.FRAME_LOCK) then
322 self.isMoving = true 403 self.isMoving = true
323 f:StartMoving() 404 f:StartMoving()
324 end 405 end
325 end 406 end
326 local on_mouse_up = function (self) 407 local on_mouse_up = function (self)
348 429
349 if (percent == 100) then 430 if (percent == 100) then
350 self:SetScript ("OnUpdate", nil) 431 self:SetScript ("OnUpdate", nil)
351 self.stamper_icon:Show() 432 self.stamper_icon:Show()
352 self.number:Hide() 433 self.number:Hide()
434 self.cooldown:Show()
353 self.cooldown:SetCooldown (GetTime(), 37 - db.STAMPERS_DELAY, 0, 0) 435 self.cooldown:SetCooldown (GetTime(), 37 - db.STAMPERS_DELAY, 0, 0)
354 end 436 end
355 end 437 end
356 end 438 end
357 439
372 block.number:SetText (block.id) 454 block.number:SetText (block.id)
373 block.number:SetTextColor (1, 1, 1, 0.5) 455 block.number:SetTextColor (1, 1, 1, 0.5)
374 block.number:Show() 456 block.number:Show()
375 block.stamper_icon:Hide() 457 block.stamper_icon:Hide()
376 block.cooldown:SetCooldown (0, 0, 0, 0) 458 block.cooldown:SetCooldown (0, 0, 0, 0)
459 block.cooldown:Hide()
377 460
378 f.block_tracker [block.id] = nil 461 f.block_tracker [block.id] = nil
379 if (block.unpaint_process) then 462 if (block.unpaint_process) then
380 f:CancelTimer (block.unpaint_process) 463 f:CancelTimer (block.unpaint_process)
381 block.unpaint_process = nil 464 block.unpaint_process = nil
398 block.cooldown:SetDrawEdge (true) 481 block.cooldown:SetDrawEdge (true)
399 end 482 end
400 end 483 end
401 end 484 end
402 485
486 function f:SetLockState()
487 db.FRAME_LOCK = not db.FRAME_LOCK
488 if (db.FRAME_LOCK) then
489 --locked
490 f:EnableMouse (false)
491 for _, block in ipairs (f.all_blocks) do
492 block:EnableMouse (false)
493 end
494 else
495 --unlocked
496 f:EnableMouse (true)
497 for _, block in ipairs (f.all_blocks) do
498 block:EnableMouse (true)
499 end
500 end
501 end
502
403 function f:CreateWindow() 503 function f:CreateWindow()
404 local x = 0 504 local x = 0
405 local y = 0 505 local y = 0
406 506
407 f.player_loc_box = frame_event:CreateTexture (nil, "overlay") 507 f.player_loc_box = frame_event:CreateTexture (nil, "overlay")
458 end 558 end
459 559
460 tinsert (f.all_blocks, block) 560 tinsert (f.all_blocks, block)
461 561
462 end 562 end
563
564 f:SetLockState()
463 565
464 f.frames_built = true 566 f.frames_built = true
465 567
466 end 568 end
467 569
560 end 662 end
561 663
562 function f:StartTrackPlayerPosition() 664 function f:StartTrackPlayerPosition()
563 665
564 --> under development 666 --> under development
565 if (true) then 667 --if (true) then
566 return 668 -- return
567 end 669 --end
568 670
569 player_pos_frame:Show() 671 player_pos_frame:Show()
570 tframe.width = player_pos_frame:GetWidth() 672 tframe.width = player_pos_frame:GetWidth()
571 tframe.width_pixel = tframe.width / 100 673 tframe.width_pixel = tframe.width / 100
572 tframe:SetScript ("OnUpdate", track_function) 674 tframe:SetScript ("OnUpdate", track_function)