Advertisement
Yulai

Interface AddOns SMT core core.lua

May 17th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 74.89 KB | None | 0 0
  1. local T, C, L, G = unpack(select(2, ...))
  2.  
  3. local addon_name = G.addon_name
  4. local font = G.Font
  5.  
  6. G.Test = {}
  7. G.Icons = {}
  8. G.Texts = {}
  9. G.HL_Holders = {}
  10. G.Plate_IconHolders = {}
  11. ----------------------------------------------------------
  12. -----------------[[ Frame Holder ]]------------------
  13. ----------------------------------------------------------
  14. local FrameHolder = CreateFrame("Frame", addon_name.."FrameHolder", UIParent)
  15. G.FrameHolder = FrameHolder
  16.  
  17. local update_rate = 0.05
  18. local glow_updaterate = 0.05
  19. local glow_value = 0
  20. G.glow_value = glow_value
  21.  
  22. FrameHolder:SetScript("OnUpdate", function(self, e)
  23. glow_updaterate = glow_updaterate - e
  24. if glow_updaterate <= 0 then
  25. glow_value = glow_value + 0.05
  26. if glow_value >= .5 then
  27. glow_value = -.5
  28. end
  29. glow_updaterate = 0.05
  30. end
  31. end)
  32.  
  33. T.UpdateAll = function()
  34. if SMT_CDB["General"]["disable_all"] then
  35. FrameHolder:Hide()
  36. else
  37. FrameHolder:Show()
  38. end
  39. -- update
  40. T.EditAlertFrame("all")
  41. T.EditTextFrame("all")
  42. T.EditPlateIcons("enable")
  43. T.EditCDBar("show")
  44. end
  45.  
  46. FrameHolder:RegisterEvent("PLAYER_ENTERING_WORLD")
  47. FrameHolder:SetScript("OnEvent", function(self, event, ...)
  48. if event == "PLAYER_ENTERING_WORLD" then
  49. T.UpdateAll()
  50. FrameHolder:UnregisterEvent("PLAYER_ENTERING_WORLD")
  51. end
  52. end)
  53.  
  54. ----------------------------------------------------------
  55. -----------------[[ Alert Frame ]]------------------
  56. ----------------------------------------------------------
  57.  
  58. local AlertFrame = CreateFrame("Frame", addon_name.."AlertFrame", FrameHolder)
  59. AlertFrame:SetSize(70,70)
  60.  
  61. AlertFrame.movingname = L["图标提示"]
  62. AlertFrame.point = { a1 = "BOTTOMRIGHT", parent = "UIParent", a2 = "CENTER", x = -220, y = -20 }
  63. T.CreateDragFrame(AlertFrame)
  64.  
  65. T.EditAlertFrame = function(option)
  66. if option == "all" or option == "icon_size" then
  67. AlertFrame:SetSize(SMT_CDB["AlertFrame"]["icon_size"], SMT_CDB["AlertFrame"]["icon_size"])
  68. end
  69. for k, frame in pairs(G.Icons) do
  70. frame.update_onedit(option)
  71. end
  72. end
  73.  
  74. AlertFrame.ActiveIcons = {}
  75. AlertFrame.LineUpIcons = function()
  76. local lastframe
  77. local grow_dir = SMT_CDB["AlertFrame"]["grow_dir"]
  78. local space = SMT_CDB["AlertFrame"]["icon_space"]
  79. for v, frame in T.pairsByKeys(AlertFrame.ActiveIcons) do
  80. frame:ClearAllPoints()
  81. frame.text:ClearAllPoints()
  82.  
  83. if grow_dir == "TOP" or grow_dir == "BOTTOM" then
  84. frame.text:SetPoint("LEFT", frame, "RIGHT", 10, 0)
  85. frame.text:SetJustifyH("LEFT")
  86. else
  87. frame.text:SetPoint("TOP", frame, "BOTTOM", 0, -5)
  88. frame.text:SetJustifyH("CENTER")
  89. end
  90.  
  91. if not lastframe then
  92. frame:SetPoint(grow_dir, AlertFrame, grow_dir)
  93. elseif grow_dir == "BOTTOM" then
  94. frame:SetPoint(grow_dir, lastframe, "TOP", 0, space)
  95. elseif grow_dir == "TOP" then
  96. frame:SetPoint(grow_dir, lastframe, "BOTTOM", 0, -space)
  97. elseif grow_dir == "LEFT" then
  98. frame:SetPoint(grow_dir, lastframe, "RIGHT", space, 0)
  99. elseif grow_dir == "RIGHT" then
  100. frame:SetPoint(grow_dir, lastframe, "LEFT", -space, 0)
  101. end
  102. lastframe = frame
  103. end
  104. end
  105.  
  106. AlertFrame.QueueIcon = function(frame)
  107. frame:HookScript("OnShow", function()
  108. AlertFrame.ActiveIcons[frame.v] = frame
  109. AlertFrame.LineUpIcons()
  110. end)
  111.  
  112. frame:HookScript("OnHide", function()
  113. AlertFrame.ActiveIcons[frame.v] = nil
  114. AlertFrame.LineUpIcons()
  115. end)
  116. end
  117.  
  118. T.CreateAlertIcon = function(v, r, g, b)
  119. local frame = CreateFrame("Frame", nil, AlertFrame)
  120. frame:SetSize(70,70)
  121. frame:Hide()
  122. T.createborder(frame)
  123.  
  124. frame.map_id, _, frame.hl, frame.spell_id = strsplit("_", v)
  125. frame.map_id = tonumber(frame.map_id)
  126. frame.spell_id = tonumber(frame.spell_id)
  127.  
  128. frame.spell_name, _, frame.spell_icon, frame.cast_time = GetSpellInfo(frame.spell_id)
  129. frame.v = v
  130. frame.t = 0
  131.  
  132. frame.glow = frame:CreateTexture(nil, "OVERLAY")
  133. frame.glow:SetPoint("TOPLEFT", -25, 25)
  134. frame.glow:SetPoint("BOTTOMRIGHT", 25, -25)
  135. frame.glow:SetAlpha(1)
  136. frame.glow:SetTexture([[Interface\SpellActivationOverlay\IconAlert]])
  137. frame.glow:SetTexCoord(0.00781250, 0.50781250, 0.27734375, 0.52734375)
  138.  
  139. if frame.hl == "hl" then
  140. frame.glow:Show()
  141. else
  142. frame.glow:Hide()
  143. end
  144.  
  145. frame.texture = frame:CreateTexture(nil, "ARTWORK")
  146. frame.texture:SetTexCoord( .1, .9, .1, .9)
  147. frame.texture:SetAllPoints()
  148. frame.texture:SetTexture(frame.spell_icon)
  149.  
  150. frame.bottomtext = T.createtext(frame, "OVERLAY", 12, "OUTLINE", "CENTER")
  151. frame.bottomtext:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", -2, 10)
  152. frame.bottomtext:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 2, 10)
  153. frame.bottomtext:SetHeight(12)
  154. frame.bottomtext:SetTextColor(1, 1, 0)
  155. frame.bottomtext:SetText(frame.spell_name)
  156.  
  157. frame.toptext = T.createtext(frame, "OVERLAY", 25, "OUTLINE", "CENTER")
  158. frame.toptext:SetPoint("TOPLEFT", frame, "TOPLEFT", -2, -10)
  159. frame.toptext:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 2, -10)
  160. frame.toptext:SetHeight(25)
  161. frame.toptext:SetTextColor(0, 1, 1)
  162.  
  163. frame.text = T.createtext(frame, "OVERLAY", 40, "OUTLINE", "LEFT")
  164. frame.text:SetTextColor(r, g, b)
  165.  
  166. return frame
  167. end
  168.  
  169. T.CreateTestIcon = function(v, dur, r, g, b)
  170.  
  171. local frame = T.CreateAlertIcon(v, r, g, b)
  172.  
  173. frame.reset = function()
  174. frame:Hide()
  175. frame.exp = false
  176. end
  177.  
  178. frame.update_onedit = function()
  179. frame.enable = SMT_CDB["AlertFrame"]["enable"]
  180. if frame.enable then
  181. frame:RegisterEvent("CHAT_MSG_ADDON")
  182. else
  183. frame:UnregisterEvent("CHAT_MSG_ADDON")
  184. end
  185.  
  186. frame:SetSize(SMT_CDB["AlertFrame"]["icon_size"], SMT_CDB["AlertFrame"]["icon_size"])
  187. frame.glow:SetPoint("TOPLEFT", -SMT_CDB["AlertFrame"]["icon_size"]/3, SMT_CDB["AlertFrame"]["icon_size"]/3)
  188. frame.glow:SetPoint("BOTTOMRIGHT", SMT_CDB["AlertFrame"]["icon_size"]/3, -SMT_CDB["AlertFrame"]["icon_size"]/3)
  189.  
  190. frame.text:SetFont(G.Font, SMT_CDB["AlertFrame"]["font_size"], "OUTLINE")
  191. frame.bottomtext:SetFont(G.Font, SMT_CDB["AlertFrame"]["ifont_size"], "OUTLINE")
  192.  
  193. AlertFrame.LineUpIcons()
  194. end
  195.  
  196. frame.update_onevent = function()
  197. if frame.enable then
  198. frame.exp = GetTime() + dur
  199. frame:Show()
  200. else
  201. frame.reset()
  202. end
  203. end
  204.  
  205. frame.update_onframe = function()
  206. if frame.enable and frame.exp then
  207. local remain = frame.exp - GetTime()
  208. frame.text:SetText(T.FormatTime(remain))
  209. if remain <= 0 then
  210. frame.reset()
  211. end
  212. else
  213. frame.reset()
  214. end
  215. end
  216.  
  217. frame.StartTest = function()
  218. frame.update_onevent()
  219. end
  220.  
  221. frame:SetScript("OnUpdate", function(self, e)
  222. frame.t = frame.t + e
  223. if frame.t > update_rate then
  224. frame.update_onframe()
  225. frame.t = 0
  226. end
  227. end)
  228.  
  229. AlertFrame.QueueIcon(frame)
  230.  
  231. G.Icons[v] = frame
  232. G.Test[v] = frame
  233.  
  234. return frame
  235. end
  236.  
  237. T.CreateAura = function(option_page, v, aura_type, unit, arg_index)
  238. local frame = T.CreateAlertIcon(v, 1, .5, .2)
  239.  
  240. frame.reset = function()
  241. frame:Hide()
  242. frame.count = false
  243. frame.dur = false
  244. frame.exp = false
  245. end
  246.  
  247. frame.update_onedit = function(option)
  248. if option == "all" or option == "enable" then
  249.  
  250. frame.enable = SMT_CDB["Icons"][v] and SMT_CDB["AlertFrame"]["enable"]
  251. if frame.enable then
  252. frame:RegisterEvent("WORLD_MAP_UPDATE")
  253. else
  254. frame:UnregisterEvent("WORLD_MAP_UPDATE")
  255. end
  256.  
  257. frame.update_onevent("INIT")
  258. end
  259.  
  260. if option == "all" or option == "icon_size" then
  261. frame:SetSize(SMT_CDB["AlertFrame"]["icon_size"], SMT_CDB["AlertFrame"]["icon_size"])
  262. frame.glow:SetPoint("TOPLEFT", -SMT_CDB["AlertFrame"]["icon_size"]/3, SMT_CDB["AlertFrame"]["icon_size"]/3)
  263. frame.glow:SetPoint("BOTTOMRIGHT", SMT_CDB["AlertFrame"]["icon_size"]/3, -SMT_CDB["AlertFrame"]["icon_size"]/3)
  264. end
  265.  
  266. if option == "all" or option == "font_size" then
  267. frame.text:SetFont(G.Font, SMT_CDB["AlertFrame"]["font_size"], "OUTLINE")
  268. end
  269.  
  270. if option == "all" or option == "ifont_size" then
  271. frame.bottomtext:SetFont(G.Font, SMT_CDB["AlertFrame"]["ifont_size"], "OUTLINE")
  272. end
  273.  
  274. if option == "all" or option == "grow_dir" or option == "icon_space" then
  275. AlertFrame.LineUpIcons()
  276. end
  277. end
  278.  
  279. frame.Update = function()
  280. if frame.enable and UnitAura(unit, frame.spell_name, nil, aura_type) then
  281. frame.dur, frame.exp = select(6, UnitAura(unit, frame.spell_name, nil, aura_type))
  282. frame:Show()
  283. else
  284. frame.reset()
  285. end
  286. end
  287.  
  288. frame.map_check = function()
  289. local map = GetCurrentMapAreaID()
  290. if frame.enable and map == frame.map_id then
  291. frame:RegisterEvent("UNIT_AURA")
  292. else
  293. frame:UnregisterEvent("UNIT_AURA")
  294. frame.reset()
  295. end
  296. end
  297.  
  298. frame.update_onevent = function(event, ...)
  299. if event == "INIT" then
  300. frame.map_check()
  301. frame.Update()
  302. elseif event == "WORLD_MAP_UPDATE" then
  303. frame.map_check()
  304. elseif event == "UNIT_AURA" then
  305. local u = ...
  306. if u == unit then
  307. frame.Update()
  308. end
  309. end
  310. end
  311.  
  312. frame.update_onframe = function()
  313. if frame.enable and frame.exp then
  314. local count, time = "",""
  315.  
  316. if arg_index then
  317. frame.count = T.ShortValue(select(arg_index, UnitAura(unit, frame.spell_name, nil, aura_type)))
  318. if frame.count then
  319. count = "["..frame.count.."] "
  320. end
  321. else
  322. frame.count = select(4, UnitAura(unit, frame.spell_name, nil, aura_type))
  323. if frame.count and frame.count > 0 then
  324. count = "["..T.ShortValue(frame.count).."] "
  325. end
  326. end
  327.  
  328. if frame.dur ~= 0 then -- 有持续时间
  329. local remain = frame.exp - GetTime()
  330. time = T.FormatTime(remain)
  331. if remain <= 0 then
  332. frame.reset()
  333. end
  334. end
  335.  
  336. frame.text:SetText(count..time)
  337. else
  338. frame.reset()
  339. end
  340. end
  341.  
  342. frame:SetScript("OnEvent", function(self, event, ...)
  343. frame.update_onevent(event, ...)
  344. end)
  345.  
  346. frame:SetScript("OnUpdate", function(self, e)
  347. frame.t = frame.t + e
  348. if frame.t > update_rate then
  349. frame.update_onframe()
  350. frame.t = 0
  351. end
  352. end)
  353.  
  354. AlertFrame.QueueIcon(frame)
  355.  
  356. G.Icons[v] = frame
  357.  
  358. local options = T.Create_AlertIcon_Options(option_page, v)
  359.  
  360. return frame, options
  361. end
  362.  
  363. T.CreateAffixAura = function(option_page, v, affix_id, x, y)
  364. local frame = T.CreateAlertIcon(v, 1, .5, .2)
  365.  
  366. frame.reset = function()
  367. frame:Hide()
  368. frame.count = false
  369. frame.dur = false
  370. frame.exp = false
  371. end
  372.  
  373. frame.update_onedit = function(option)
  374. if option == "all" or option == "enable" then
  375.  
  376. frame.enable = SMT_CDB["AlertFrame"][v] and SMT_CDB["AlertFrame"]["enable"]
  377. if frame.enable then
  378. frame:RegisterEvent("CHALLENGE_MODE_COMPLETED")
  379. frame:RegisterEvent("CHALLENGE_MODE_RESET")
  380. frame:RegisterEvent("CHALLENGE_MODE_START")
  381. else
  382. frame:UnregisterEvent("CHALLENGE_MODE_COMPLETED")
  383. frame:UnregisterEvent("CHALLENGE_MODE_RESET")
  384. frame:UnregisterEvent("CHALLENGE_MODE_START")
  385. end
  386.  
  387. frame.update_onevent("INIT")
  388. end
  389.  
  390. if option == "all" or option == "icon_size" then
  391. frame:SetSize(SMT_CDB["AlertFrame"]["icon_size"], SMT_CDB["AlertFrame"]["icon_size"])
  392. frame.glow:SetPoint("TOPLEFT", -SMT_CDB["AlertFrame"]["icon_size"]/3, SMT_CDB["AlertFrame"]["icon_size"]/3)
  393. frame.glow:SetPoint("BOTTOMRIGHT", SMT_CDB["AlertFrame"]["icon_size"]/3, -SMT_CDB["AlertFrame"]["icon_size"]/3)
  394. end
  395.  
  396. if option == "all" or option == "font_size" then
  397. frame.text:SetFont(G.Font, SMT_CDB["AlertFrame"]["font_size"], "OUTLINE")
  398. end
  399.  
  400. if option == "all" or option == "ifont_size" then
  401. frame.bottomtext:SetFont(G.Font, SMT_CDB["AlertFrame"]["ifont_size"], "OUTLINE")
  402. end
  403.  
  404. if option == "all" or option == "grow_dir" or option == "icon_space" then
  405. AlertFrame.LineUpIcons()
  406. end
  407. end
  408.  
  409. frame.Update = function()
  410. if frame.enable and UnitAura(unit, frame.spell_name, nil, aura_type) then
  411. frame.dur, frame.exp = select(6, UnitAura(unit, frame.spell_name, nil, aura_type))
  412. frame:Show()
  413. else
  414. frame.reset()
  415. end
  416. end
  417.  
  418. frame.map_check = function()
  419. if C_ChallengeMode.IsChallengeModeActive() then
  420. frame:RegisterEvent("UNIT_AURA")
  421. else
  422. frame:UnregisterEvent("UNIT_AURA")
  423. frame.reset()
  424. end
  425. end
  426.  
  427. frame.update_onevent = function(event, ...)
  428. if event == "INIT" then
  429. frame.map_check()
  430. elseif strfind(event, "CHALLENGE_MODE") then
  431. frame.map_check()
  432. elseif event == "UNIT_AURA" then
  433. local u = ...
  434. if u == unit then
  435. frame.Update()
  436. end
  437. end
  438. end
  439.  
  440. frame.update_onframe = function()
  441. if frame.enable and frame.exp then
  442. local count, time = "",""
  443.  
  444. if arg_index then
  445. frame.count = select(arg_index, UnitAura(unit, frame.spell_name, nil, aura_type))
  446. if frame.count then
  447. count = "["..frame.count.."] "
  448. end
  449. else
  450. frame.count = select(4, UnitAura(unit, frame.spell_name, nil, aura_type))
  451. if frame.count > 0 then
  452. count = "["..T.ShortValue(frame.count).."] "
  453. end
  454. end
  455.  
  456. if frame.dur ~= 0 then -- 有持续时间
  457. local remain = frame.exp - GetTime()
  458. time = T.FormatTime(remain)
  459. if remain <= 0 then
  460. frame.reset()
  461. end
  462. end
  463.  
  464. frame.text:SetText(count..time)
  465. else
  466. frame.reset()
  467. end
  468. end
  469.  
  470. frame:SetScript("OnEvent", function(self, event, ...)
  471. frame.update_onevent(event, ...)
  472. end)
  473.  
  474. frame:SetScript("OnUpdate", function(self, e)
  475. frame.t = frame.t + e
  476. if frame.t > update_rate then
  477. frame.update_onframe()
  478. frame.t = 0
  479. end
  480. end)
  481.  
  482. AlertFrame.QueueIcon(frame)
  483.  
  484. T.CreateAffixAuraOptions(option_page, v, affix_id, x, y)
  485.  
  486. G.Icons[v] = frame
  487. end
  488.  
  489. T.CreateAffixAura(G.gui.Options, "1_aura_no_240559", 12, 40, 280) -- 重伤
  490. T.CreateAffixAura(G.gui.Options, "1_aura_no_240443", 11, 240, 280) -- 崩裂
  491. T.CreateAffixAura(G.gui.Options, "1_aura_no_209858", 4, 40, 310) -- 死疽
  492. T.CreateAffixAura(G.gui.Options, "1_aura_no_226512", 8, 240, 310) -- 血池
  493.  
  494. T.CreateAuras = function(option_page, v, aura_type, arg_index)
  495. local frame = T.CreateAlertIcon(v, 1, 1, 1)
  496. frame.text:SetFont(G.Font, 20, "OUTLINE")
  497. frame.num = 0
  498.  
  499. frame.reset = function()
  500. frame:Hide()
  501. frame.num = 0
  502. frame.str = ""
  503. end
  504.  
  505. frame.update_onedit = function(option)
  506. if option == "all" or option == "enable" then
  507.  
  508. frame.enable = SMT_CDB["Icons"][v] and SMT_CDB["AlertFrame"]["enable"]
  509. if frame.enable then
  510. frame:RegisterEvent("WORLD_MAP_UPDATE")
  511. else
  512. frame:UnregisterEvent("WORLD_MAP_UPDATE")
  513. end
  514.  
  515. frame.update_onevent("INIT")
  516. end
  517.  
  518. if option == "all" or option == "icon_size" then
  519. frame:SetSize(SMT_CDB["AlertFrame"]["icon_size"], SMT_CDB["AlertFrame"]["icon_size"])
  520. frame.glow:SetPoint("TOPLEFT", -SMT_CDB["AlertFrame"]["icon_size"]/3, SMT_CDB["AlertFrame"]["icon_size"]/3)
  521. frame.glow:SetPoint("BOTTOMRIGHT", SMT_CDB["AlertFrame"]["icon_size"]/3, -SMT_CDB["AlertFrame"]["icon_size"]/3)
  522. end
  523.  
  524. if option == "all" or option == "font_size" then
  525. frame.text:SetFont(G.Font, SMT_CDB["AlertFrame"]["font_size"]/2, "OUTLINE")
  526. end
  527.  
  528. if option == "all" or option == "ifont_size" then
  529. frame.bottomtext:SetFont(G.Font, SMT_CDB["AlertFrame"]["ifont_size"], "OUTLINE")
  530. end
  531.  
  532. if option == "all" or option == "grow_dir" or option == "icon_space" then
  533. AlertFrame.LineUpIcons()
  534. end
  535. end
  536.  
  537. frame.map_check = function()
  538. local map = GetCurrentMapAreaID()
  539. if frame.enable and map == frame.map_id then
  540. frame:RegisterEvent("UNIT_AURA")
  541. else
  542. frame:UnregisterEvent("UNIT_AURA")
  543. frame.reset()
  544. end
  545. end
  546.  
  547. frame.players = {}
  548. frame.update_onevent = function(event, ...)
  549. if event == "INIT" then
  550. frame.map_check()
  551. elseif event == "WORLD_MAP_UPDATE" then
  552. frame.map_check()
  553. elseif event == "UNIT_AURA" then
  554. if frame.enable then
  555. local unitID = ...
  556. if unitID and UnitInParty(unitID) then
  557. local player = UnitName(unitID)
  558. if UnitAura(unitID, frame.spell_name, nil, aura_type) then
  559. if not frame.players[player] then
  560. frame.players[player] = {}
  561. frame.players[player].dur, frame.players[player].exp = select(6, UnitAura(unitID, frame.spell_name, nil, aura_type))
  562. frame.num = frame.num + 1
  563. end
  564. else
  565. if frame.players[player] then
  566. frame.players[player] = nil
  567. frame.num = frame.num - 1
  568. end
  569. end
  570.  
  571. if frame.num > 0 then
  572. frame:Show()
  573. else
  574. frame.reset()
  575. end
  576. end
  577. else
  578. frame.reset()
  579. end
  580. end
  581. end
  582.  
  583. frame.update_onframe = function()
  584. if frame.enable and frame.num > 0 then
  585. frame.str = ""
  586.  
  587. for player, info in pairs(frame.players) do
  588.  
  589.  
  590.  
  591. if frame.players[player] then
  592.  
  593. local name = T.ColorName(player).." "
  594. local count, time = "", ""
  595.  
  596. if arg_index then
  597. frame.players[player].count = T.ShortValue(select(arg_index, UnitAura(player, frame.spell_name, nil, aura_type)))
  598. if frame.players[player].count then
  599. count = "["..frame.players[player].count.."] "
  600. end
  601. else
  602. frame.players[player].count = select(4, UnitAura(player, frame.spell_name, nil, aura_type))
  603. if frame.players[player].count > 0 then
  604. count = "["..T.ShortValue(frame.players[player].count).."] "
  605. end
  606. end
  607.  
  608. if frame.players[player].dur ~= 0 then -- 有持续时间
  609. local remain = frame.players[player].exp - GetTime()
  610. time = T.FormatTime(remain)
  611. if remain <= 0 then
  612. frame.players[player] = nil
  613. frame.num = frame.num - 1
  614. end
  615. end
  616.  
  617. if frame.str == "" then
  618. frame.str = name..count..time
  619. else
  620. frame.str = frame.str.."\n"..name..count..time
  621. end
  622. end
  623. end
  624.  
  625. frame.text:SetText(frame.str)
  626.  
  627. else
  628. frame.reset()
  629. end
  630. end
  631.  
  632. frame:SetScript("OnEvent", function(self, event, ...)
  633. frame.update_onevent(event, ...)
  634. end)
  635.  
  636. frame:SetScript("OnUpdate", function(self, e)
  637. frame.t = frame.t + e
  638. if frame.t > update_rate then
  639. frame.update_onframe()
  640. frame.t = 0
  641. end
  642. end)
  643.  
  644. AlertFrame.QueueIcon(frame)
  645.  
  646. G.Icons[v] = frame
  647.  
  648. local options = T.Create_AlertIcon_Options(option_page, v)
  649.  
  650. return frame, options
  651. end
  652.  
  653. T.CreateLog = function(option_page, v, event_type, targetID, dur)
  654. local frame = T.CreateAlertIcon(v, 1, 1, 1)
  655.  
  656. frame.dur = dur
  657.  
  658. frame.reset = function()
  659. frame:Hide()
  660. frame.exp = false
  661. frame.target = false
  662. end
  663.  
  664. frame.update_onedit = function(option)
  665. if option == "all" or option == "enable" then
  666.  
  667. frame.enable = SMT_CDB["Icons"][v] and SMT_CDB["AlertFrame"]["enable"]
  668. if frame.enable then
  669. frame:RegisterEvent("WORLD_MAP_UPDATE")
  670. else
  671. frame:UnregisterEvent("WORLD_MAP_UPDATE")
  672. end
  673.  
  674. frame.update_onevent("INIT")
  675. end
  676.  
  677. if option == "all" or option == "icon_size" then
  678. frame:SetSize(SMT_CDB["AlertFrame"]["icon_size"], SMT_CDB["AlertFrame"]["icon_size"])
  679. frame.glow:SetPoint("TOPLEFT", -SMT_CDB["AlertFrame"]["icon_size"]/3, SMT_CDB["AlertFrame"]["icon_size"]/3)
  680. frame.glow:SetPoint("BOTTOMRIGHT", SMT_CDB["AlertFrame"]["icon_size"]/3, -SMT_CDB["AlertFrame"]["icon_size"]/3)
  681. end
  682.  
  683. if option == "all" or option == "font_size" then
  684. frame.text:SetFont(G.Font, SMT_CDB["AlertFrame"]["font_size"], "OUTLINE")
  685. end
  686.  
  687. if option == "all" or option == "ifont_size" then
  688. frame.bottomtext:SetFont(G.Font, SMT_CDB["AlertFrame"]["ifont_size"], "OUTLINE")
  689. end
  690.  
  691. if option == "all" or option == "grow_dir" or option == "icon_space" then
  692. AlertFrame.LineUpIcons()
  693. end
  694. end
  695.  
  696. frame.map_check = function()
  697. local map = GetCurrentMapAreaID()
  698. if frame.enable and map == frame.map_id then
  699. frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  700. else
  701. frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  702. frame.reset()
  703. end
  704. end
  705.  
  706. frame.update_onevent = function(event, ...)
  707. if event == "INIT" then
  708. frame.map_check()
  709. elseif event == "WORLD_MAP_UPDATE" then
  710. frame.map_check()
  711. elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
  712. if frame.enable then
  713. local Time_stamp, Event_type, _, SourceGUID, SourceName, _, _, DestGUID, DestName, _, _, SpellID, SpellName = ...
  714. if Event_type == event_type and SpellID == frame.spell_id then
  715. if not targetID then
  716. frame.exp = GetTime() + frame.dur
  717. frame:Show()
  718. elseif UnitIsUnit(targetID, DestName) then -- 这里targetID只用于玩家
  719. frame.target = DestName
  720. frame.exp = GetTime() + frame.dur
  721. frame:Show()
  722. end
  723. end
  724. else
  725. frame.reset()
  726. end
  727. end
  728. end
  729.  
  730. frame.update_onframe = function()
  731. if frame.enable and frame.exp then
  732. local remain = frame.exp - GetTime()
  733. frame.text:SetText(T.FormatTime(remain))
  734.  
  735. if remain <= 0 then
  736. frame.reset()
  737. end
  738. else
  739. frame.reset()
  740. end
  741. end
  742.  
  743. frame:SetScript("OnEvent", function(self, event, ...)
  744. frame.update_onevent(event, ...)
  745. end)
  746.  
  747. frame:SetScript("OnUpdate", function(self, e)
  748. frame.t = frame.t + e
  749. if frame.t > update_rate then
  750. frame.update_onframe()
  751. frame.t = 0
  752. end
  753. end)
  754.  
  755. AlertFrame.QueueIcon(frame)
  756.  
  757. G.Icons[v] = frame
  758.  
  759. local options = T.Create_AlertIcon_Options(option_page, v)
  760.  
  761. return frame, options
  762. end
  763.  
  764. T.StopLog = function(frame, event, ...)
  765. frame:HookScript("OnEvent", function(self, event, ...)
  766. local _, Event_type, _, _, _, _, _, DestGUID = ...
  767. if Event_type == event then
  768. if event == "UNIT_DIED" then
  769. local NPCID = ...
  770. local npc_id = select(6, strsplit("-", DestGUID))
  771. if npc_id == NPCID then
  772. frame.reset()
  773. end
  774. end
  775. end
  776. end)
  777. end
  778.  
  779. local CastingEvents = {
  780. ["UNIT_SPELLCAST_START"] = true,
  781. ["UNIT_SPELLCAST_SUCCEEDED"] = true,
  782. ["UNIT_SPELLCAST_STOP"] = true,
  783. ["UNIT_SPELLCAST_CHANNEL_START"] = true,
  784. ["UNIT_SPELLCAST_CHANNEL_STOP"] = true,
  785. }
  786.  
  787. T.CreateCast = function(option_page, v)
  788. local frame = T.CreateAlertIcon(v, 1, 1, 1)
  789.  
  790. frame.reset = function()
  791. frame:Hide()
  792. frame.exp = false
  793. frame.target = false
  794. frame.source = {}
  795. frame.count = 0
  796. end
  797.  
  798. frame.update_onedit = function(option)
  799. if option == "all" or option == "enable" then
  800. frame.enable = SMT_CDB["Icons"][v] and SMT_CDB["AlertFrame"]["enable"]
  801. if frame.enable then
  802. frame:RegisterEvent("WORLD_MAP_UPDATE")
  803. else
  804. frame:UnregisterEvent("WORLD_MAP_UPDATE")
  805. end
  806.  
  807. frame.update_onevent("INIT")
  808. end
  809.  
  810. if option == "all" or option == "icon_size" then
  811. frame:SetSize(SMT_CDB["AlertFrame"]["icon_size"], SMT_CDB["AlertFrame"]["icon_size"])
  812. frame.glow:SetPoint("TOPLEFT", -SMT_CDB["AlertFrame"]["icon_size"]/3, SMT_CDB["AlertFrame"]["icon_size"]/3)
  813. frame.glow:SetPoint("BOTTOMRIGHT", SMT_CDB["AlertFrame"]["icon_size"]/3, -SMT_CDB["AlertFrame"]["icon_size"]/3)
  814. end
  815.  
  816. if option == "all" or option == "font_size" then
  817. frame.text:SetFont(G.Font, SMT_CDB["AlertFrame"]["font_size"], "OUTLINE")
  818. end
  819.  
  820. if option == "all" or option == "ifont_size" then
  821. frame.bottomtext:SetFont(G.Font, SMT_CDB["AlertFrame"]["ifont_size"], "OUTLINE")
  822. end
  823.  
  824. if option == "all" or option == "grow_dir" or option == "icon_space" then
  825. AlertFrame.LineUpIcons()
  826. end
  827. end
  828.  
  829. frame.map_check = function()
  830. local map = GetCurrentMapAreaID()
  831. if frame.enable and map == frame.map_id then
  832. for k, j in pairs(CastingEvents) do
  833. frame:RegisterEvent(k)
  834. end
  835. else
  836. for k, j in pairs(CastingEvents) do
  837. frame:UnregisterEvent(k)
  838. end
  839. frame.reset()
  840. end
  841. end
  842.  
  843. frame.update_onevent = function(e, ...)
  844. if e == "INIT" or e == "WORLD_MAP_UPDATE" then
  845. frame.map_check()
  846. elseif frame.enable then
  847. local Unit, Spell, _, _, SpellID = ...
  848. if SpellID == frame.spell_id then
  849. if e == "UNIT_SPELLCAST_CHANNEL_START" then -- 开始引导
  850. if not frame.source[UnitGUID(Unit)] then
  851. local endTimeMS = select(6, UnitChannelInfo(Unit))
  852. frame.exp = endTimeMS/1000
  853. frame.source[UnitGUID(Unit)] = true
  854. frame.count = frame.count + 1
  855. if frame.count > 1 then
  856. frame.toptext:SetText(frame.count)
  857. else
  858. frame.toptext:SetText("")
  859. end
  860. frame:Show()
  861. end
  862. elseif e == "UNIT_SPELLCAST_START" then -- 开始施法
  863. if not frame.source[UnitGUID(Unit)] then
  864. local endTimeMS = select(6, UnitCastingInfo(Unit))
  865. frame.exp = endTimeMS/1000
  866. frame.source[UnitGUID(Unit)] = true
  867. frame.count = frame.count + 1
  868. if frame.count > 1 then
  869. frame.toptext:SetText(frame.count)
  870. else
  871. frame.toptext:SetText("")
  872. end
  873. frame:Show()
  874. end
  875. elseif e == "UNIT_SPELLCAST_SUCCEEDED" then
  876. if not frame.source[UnitGUID(Unit)] then
  877. if not UnitChannelInfo(Unit) and frame.cast_time == 0 then -- 瞬发法术
  878. frame.exp = GetTime()+2
  879. frame.source[UnitGUID(Unit)] = true
  880. frame.count = frame.count + 1
  881. if frame.count > 1 then
  882. frame.toptext:SetText(frame.count)
  883. else
  884. frame.toptext:SetText("")
  885. end
  886. C_Timer.After(2, function()
  887. frame.count = frame.count - 1
  888. frame.source[UnitGUID(Unit)] = nil
  889. if frame.count > 1 then
  890. frame.toptext:SetText(frame.count)
  891. elseif frame.count == 1 then
  892. frame.toptext:SetText("")
  893. else
  894. frame.reset()
  895. end
  896. end)
  897. frame:Show()
  898. end
  899. end
  900. elseif e == "UNIT_SPELLCAST_CHANNEL_STOP" or e == "UNIT_SPELLCAST_STOP" then
  901. if frame.source[UnitGUID(Unit)] then
  902. frame.source[UnitGUID(Unit)] = nil
  903. frame.count = frame.count - 1
  904. if frame.count > 1 then
  905. frame.toptext:SetText(frame.count)
  906. elseif frame.count == 1 then
  907. frame.toptext:SetText("")
  908. else
  909. frame.reset()
  910. end
  911. end
  912. end
  913. end
  914. else
  915. frame.reset()
  916. end
  917. end
  918.  
  919. frame.update_onframe = function()
  920. if frame.enable and frame.exp then
  921. local remain = frame.exp - GetTime()
  922. frame.text:SetText(T.FormatTime(remain))
  923.  
  924. if remain <= 0 then
  925. frame.reset()
  926. end
  927. else
  928. frame.reset()
  929. end
  930. end
  931.  
  932. frame:SetScript("OnEvent", function(self, e, ...)
  933. frame.update_onevent(e, ...)
  934. end)
  935.  
  936. frame:SetScript("OnUpdate", function(self, e)
  937. frame.t = frame.t + e
  938. if frame.t > update_rate then
  939. frame.update_onframe()
  940. frame.t = 0
  941. end
  942. end)
  943.  
  944. AlertFrame.QueueIcon(frame)
  945.  
  946. G.Icons[v] = frame
  947.  
  948. local options = T.Create_AlertIcon_Options(option_page, v)
  949.  
  950. return frame, options
  951. end
  952.  
  953. T.CreateCastingOnMe = function(option_page, v)
  954.  
  955. local frame = T.CreateAlertIcon(v, 1, 1, 0)
  956.  
  957. frame.reset = function()
  958. frame:Hide()
  959. frame.exp = false
  960. frame.source = {}
  961. frame.count = 0
  962. end
  963.  
  964. frame.update_onedit = function(option)
  965. if option == "all" or option == "enable" then
  966. frame.enable = SMT_CDB["Icons"][v] and SMT_CDB["AlertFrame"]["enable"]
  967. if frame.enable then
  968. frame:RegisterEvent("WORLD_MAP_UPDATE")
  969. else
  970. frame:UnregisterEvent("WORLD_MAP_UPDATE")
  971. end
  972.  
  973. frame.update_onevent("INIT")
  974. end
  975.  
  976. if option == "all" or option == "icon_size" then
  977. frame:SetSize(SMT_CDB["AlertFrame"]["icon_size"], SMT_CDB["AlertFrame"]["icon_size"])
  978. frame.glow:SetPoint("TOPLEFT", -SMT_CDB["AlertFrame"]["icon_size"]/3, SMT_CDB["AlertFrame"]["icon_size"]/3)
  979. frame.glow:SetPoint("BOTTOMRIGHT", SMT_CDB["AlertFrame"]["icon_size"]/3, -SMT_CDB["AlertFrame"]["icon_size"]/3)
  980. end
  981.  
  982. if option == "all" or option == "font_size" then
  983. frame.text:SetFont(G.Font, SMT_CDB["AlertFrame"]["font_size"], "OUTLINE")
  984. end
  985.  
  986. if option == "all" or option == "ifont_size" then
  987. frame.bottomtext:SetFont(G.Font, SMT_CDB["AlertFrame"]["ifont_size"], "OUTLINE")
  988. end
  989.  
  990. if option == "all" or option == "grow_dir" or option == "icon_space" then
  991. AlertFrame.LineUpIcons()
  992. end
  993. end
  994.  
  995. frame.map_check = function()
  996. local map = GetCurrentMapAreaID()
  997. if frame.enable and map == frame.map_id then
  998. for k, j in pairs(CastingEvents) do
  999. frame:RegisterEvent(k)
  1000. end
  1001. else
  1002. for k, j in pairs(CastingEvents) do
  1003. frame:UnregisterEvent(k)
  1004. end
  1005. frame.reset()
  1006. end
  1007. end
  1008.  
  1009. frame.update_onevent = function(e, ...)
  1010. if e == "INIT" or e == "WORLD_MAP_UPDATE" then
  1011. frame.map_check()
  1012. elseif frame.enable then
  1013. local Unit, Spell, _, _, SpellID = ...
  1014. if SpellID == frame.spell_id then
  1015. if e == "UNIT_SPELLCAST_CHANNEL_START" then -- 开始引导
  1016. C_Timer.After(.1, function()
  1017. if UnitIsUnit(Unit.."target", "player") and not frame.source[UnitGUID(Unit)] then
  1018. local endTimeMS = select(6, UnitChannelInfo(Unit))
  1019. frame.exp = endTimeMS/1000
  1020. frame.source[UnitGUID(Unit)] = true
  1021. frame.count = frame.count + 1
  1022. if frame.count > 1 then
  1023. frame.toptext:SetText(frame.count)
  1024. else
  1025. frame.toptext:SetText("")
  1026. end
  1027. frame:Show()
  1028. end
  1029. end)
  1030. elseif e == "UNIT_SPELLCAST_START" then -- 开始施法
  1031. C_Timer.After(.1, function()
  1032. if UnitIsUnit(Unit.."target", "player") and not frame.source[UnitGUID(Unit)] then
  1033. local endTimeMS = select(6, UnitCastingInfo(Unit))
  1034. frame.exp = endTimeMS/1000
  1035. frame.source[UnitGUID(Unit)] = true
  1036. frame.count = frame.count + 1
  1037. if frame.count > 1 then
  1038. frame.toptext:SetText(frame.count)
  1039. else
  1040. frame.toptext:SetText("")
  1041. end
  1042. frame:Show()
  1043. end
  1044. end)
  1045. elseif e == "UNIT_SPELLCAST_CHANNEL_STOP" or e == "UNIT_SPELLCAST_STOP" then
  1046. if frame.source[UnitGUID(Unit)] then
  1047. frame.source[UnitGUID(Unit)] = nil
  1048. frame.count = frame.count - 1
  1049. if frame.count > 1 then
  1050. frame.toptext:SetText(frame.count)
  1051. elseif frame.count == 1 then
  1052. frame.toptext:SetText("")
  1053. else
  1054. frame.reset()
  1055. end
  1056. end
  1057. end
  1058. end
  1059. else
  1060. frame.reset()
  1061. end
  1062. end
  1063.  
  1064. frame.update_onframe = function()
  1065. if frame.enable and frame.exp then
  1066. local remain = frame.exp - GetTime()
  1067. local time = (T.FormatTime(remain).." ") or ""
  1068. local grow_dir = SMT_CDB["AlertFrame"]["grow_dir"]
  1069.  
  1070. frame.text:SetText(L["点你"].." "..time)
  1071.  
  1072. if remain <= 0 then
  1073. frame.reset()
  1074. end
  1075. else
  1076. frame.reset()
  1077. end
  1078. end
  1079.  
  1080. frame:SetScript("OnEvent", function(self, e, ...)
  1081. frame.update_onevent(e, ...)
  1082. end)
  1083.  
  1084. frame:SetScript("OnUpdate", function(self, e)
  1085. frame.t = frame.t + e
  1086. if frame.t > update_rate then
  1087. frame.update_onframe()
  1088. frame.t = 0
  1089. end
  1090. end)
  1091.  
  1092. AlertFrame.QueueIcon(frame)
  1093.  
  1094. G.Icons[v] = frame
  1095.  
  1096. local options = T.Create_AlertIcon_Options(option_page, v)
  1097.  
  1098. return frame, options
  1099. end
  1100.  
  1101. T.CreateBossMsg = function(option_page, v, event, msg, dur)
  1102. local frame = T.CreateAlertIcon(v, 1, 1, 1)
  1103.  
  1104. frame.dur = dur
  1105.  
  1106. frame.reset = function()
  1107. frame:Hide()
  1108. frame.exp = false
  1109. frame.target = false
  1110. end
  1111.  
  1112. frame.update_onedit = function(option)
  1113. if option == "all" or option == "enable" then
  1114. frame.enable = SMT_CDB["Icons"][v] and SMT_CDB["AlertFrame"]["enable"]
  1115. if frame.enable then
  1116. frame:RegisterEvent("WORLD_MAP_UPDATE")
  1117. else
  1118. frame:UnregisterEvent("WORLD_MAP_UPDATE")
  1119. end
  1120.  
  1121. frame.update_onevent("INIT")
  1122. end
  1123.  
  1124. if option == "all" or option == "icon_size" then
  1125. frame:SetSize(SMT_CDB["AlertFrame"]["icon_size"], SMT_CDB["AlertFrame"]["icon_size"])
  1126. frame.glow:SetPoint("TOPLEFT", -SMT_CDB["AlertFrame"]["icon_size"]/3, SMT_CDB["AlertFrame"]["icon_size"]/3)
  1127. frame.glow:SetPoint("BOTTOMRIGHT", SMT_CDB["AlertFrame"]["icon_size"]/3, -SMT_CDB["AlertFrame"]["icon_size"]/3)
  1128. end
  1129.  
  1130. if option == "all" or option == "font_size" then
  1131. frame.text:SetFont(G.Font, SMT_CDB["AlertFrame"]["font_size"], "OUTLINE")
  1132. end
  1133.  
  1134. if option == "all" or option == "ifont_size" then
  1135. frame.bottomtext:SetFont(G.Font, SMT_CDB["AlertFrame"]["ifont_size"], "OUTLINE")
  1136. end
  1137.  
  1138. if option == "all" or option == "grow_dir" or option == "icon_space" then
  1139. AlertFrame.LineUpIcons()
  1140. end
  1141. end
  1142.  
  1143. frame.map_check = function()
  1144. local map = GetCurrentMapAreaID()
  1145. if frame.enable and map == frame.map_id then
  1146. frame:RegisterEvent(event)
  1147. else
  1148. frame:UnregisterEvent(event)
  1149. frame.reset()
  1150. end
  1151. end
  1152.  
  1153. frame.update_onevent = function(e, ...)
  1154. if e == "INIT" then
  1155. frame.map_check()
  1156. elseif e == "WORLD_MAP_UPDATE" then
  1157. frame.map_check()
  1158. elseif e == event then
  1159. local Msg = ...
  1160. if Msg and Msg:find(msg) then
  1161. frame.exp = GetTime() + frame.dur
  1162. frame:Show()
  1163. end
  1164. end
  1165. end
  1166.  
  1167. frame.update_onframe = function()
  1168. if frame.enable and frame.exp then
  1169. local remain = frame.exp - GetTime()
  1170. frame.text:SetText(T.FormatTime(remain))
  1171.  
  1172. if remain <= 0 then
  1173. frame.reset()
  1174. end
  1175. else
  1176. frame.reset()
  1177. end
  1178. end
  1179.  
  1180. frame:SetScript("OnEvent", function(self, e, ...)
  1181. frame.update_onevent(e, ...)
  1182. end)
  1183.  
  1184. frame:SetScript("OnUpdate", function(self, e)
  1185. frame.t = frame.t + e
  1186. if frame.t > update_rate then
  1187. frame.update_onframe()
  1188. frame.t = 0
  1189. end
  1190. end)
  1191.  
  1192. AlertFrame.QueueIcon(frame)
  1193.  
  1194. G.Icons[v] = frame
  1195.  
  1196. local options = T.Create_AlertIcon_Options(option_page, v)
  1197.  
  1198. return frame, options
  1199. end
  1200.  
  1201. ----------------------------------------------------------
  1202. --------------------[[ Text Alert ]]----------------
  1203. ----------------------------------------------------------
  1204.  
  1205. local TextFrame = CreateFrame("Frame", G.addon_name.."Text_Alert", G.FrameHolder)
  1206. TextFrame:SetSize(300,50)
  1207.  
  1208. TextFrame.movingname = L["文字提示"]
  1209. TextFrame.point = { a1 = "CENTER", parent = "UIParent", a2 = "CENTER", x = 0, y = 250 }
  1210. T.CreateDragFrame(TextFrame)
  1211.  
  1212. T.EditTextFrame = function(option)
  1213. if option == "all" or option == "font_size" then
  1214. TextFrame:SetSize(SMT_CDB["TextFrame"]["font_size"]*8, SMT_CDB["TextFrame"]["font_size"])
  1215. end
  1216.  
  1217. for k, frame in pairs(G.Texts) do
  1218. frame.update_onedit(option)
  1219. end
  1220. end
  1221.  
  1222. TextFrame.ActiveTexts = {}
  1223. TextFrame.LineUpTexts = function()
  1224. local lastframe
  1225. for v, frame in T.pairsByKeys(TextFrame.ActiveTexts) do
  1226. frame:ClearAllPoints()
  1227. if not lastframe then
  1228. frame:SetPoint("TOP", TextFrame, "TOP")
  1229. else
  1230. frame:SetPoint("TOP", lastframe, "BOTTOM", 0, -5)
  1231. end
  1232. lastframe = frame
  1233. end
  1234. end
  1235.  
  1236. TextFrame.QueueText = function(frame)
  1237. frame:HookScript("OnShow", function()
  1238. TextFrame.ActiveTexts[frame.v] = frame
  1239. TextFrame.LineUpTexts()
  1240. end)
  1241.  
  1242. frame:HookScript("OnHide", function()
  1243. TextFrame.ActiveTexts[frame.v] = nil
  1244. TextFrame.LineUpTexts()
  1245. end)
  1246. end
  1247.  
  1248. T.CreateAlertText = function(r, g, b, v)
  1249. local frame = CreateFrame("Frame", nil, TextFrame)
  1250. frame:SetSize(300,50)
  1251. frame:Hide()
  1252.  
  1253. frame.v = v
  1254. frame.t = 0
  1255.  
  1256. frame.text = T.createtext(frame, "OVERLAY", 50, "OUTLINE", "LEFT")
  1257. frame.text:SetPoint("CENTER", frame, "CENTER", 0, 0)
  1258. frame.text:SetTextColor(r, g, b)
  1259.  
  1260. return frame
  1261. end
  1262.  
  1263. T.CreateBigText = function(v, r, g, b, events)
  1264.  
  1265. local frame = T.CreateAlertText(r, g, b, v)
  1266.  
  1267. frame.update_onedit = function(option)
  1268. if option == "all" or option == "enable" then
  1269. frame.enable = SMT_CDB["TextFrame"][v]
  1270. if frame.enable then
  1271. frame:RegisterEvent("PLAYER_ENTERING_WORLD")
  1272. else
  1273. frame:UnregisterEvent("PLAYER_ENTERING_WORLD")
  1274. end
  1275.  
  1276. frame.Update_onevent(frame, "INIT")
  1277. end
  1278.  
  1279. if option == "all" or option == "font_size" then
  1280. frame:SetSize(SMT_CDB["TextFrame"]["font_size"]*8, SMT_CDB["TextFrame"]["font_size"])
  1281. frame.text:SetFont(G.Font, SMT_CDB["TextFrame"]["font_size"], "OUTLINE")
  1282. end
  1283.  
  1284. TextFrame.LineUpTexts()
  1285. end
  1286.  
  1287. frame.Update_onevent = function(self, event, ...)
  1288. if event == "INIT" then
  1289. local ins_size = select(5, GetInstanceInfo())
  1290. if frame.enable and ins_size == 5 then
  1291. for i, j in pairs(events) do
  1292. frame:RegisterEvent(j)
  1293. end
  1294. else
  1295. for i, j in pairs(events) do
  1296. frame:UnregisterEvent(j)
  1297. frame:Hide()
  1298. end
  1299. end
  1300. elseif event == "PLAYER_ENTERING_WORLD" then
  1301. local ins_size = select(5, GetInstanceInfo())
  1302. if frame.enable and ins_size == 5 then
  1303. for i, j in pairs(events) do
  1304. frame:RegisterEvent(j)
  1305. end
  1306. else
  1307. for i, j in pairs(events) do
  1308. frame:UnregisterEvent(j)
  1309. frame:Hide()
  1310. end
  1311. end
  1312. else
  1313. frame.update_onevent(self, event, ...)
  1314. end
  1315. end
  1316.  
  1317. frame:SetScript("OnEvent", function(self, event, ...)
  1318. frame.Update_onevent(self, event, ...)
  1319. end)
  1320.  
  1321. frame:SetScript("OnUpdate", function(self, e)
  1322. frame.t = frame.t + e
  1323. if frame.t > update_rate then
  1324. frame.update_onframe(self)
  1325. frame.t = 0
  1326. end
  1327. end)
  1328.  
  1329. TextFrame.QueueText(frame)
  1330.  
  1331. G.Texts[v] = frame
  1332.  
  1333. return frame
  1334. end
  1335.  
  1336. T.CreateTestText = function(v, dur, r, g, b, text)
  1337. local frame = T.CreateAlertText(r, g, b, v)
  1338.  
  1339. frame.reset = function()
  1340. frame:Hide()
  1341. frame.exp = false
  1342. end
  1343.  
  1344. frame.update_onedit = function()
  1345. frame:SetSize(SMT_CDB["AlertFrame"]["font_size"]*8, SMT_CDB["TextFrame"]["font_size"])
  1346. frame.text:SetFont(G.Font, SMT_CDB["TextFrame"]["font_size"], "OUTLINE")
  1347.  
  1348. if v == "Quaking" then
  1349. local icon = "|T136025:12:12:0:0:64:64:4:60:4:60|t"
  1350. if SMT_CDB["TextFrame"]["short"] then
  1351. frame.text:SetText(L["打断施法"])
  1352. else
  1353. frame.text:SetText(icon.." "..L["打断施法"].." ".."1.2s".." "..icon)
  1354. end
  1355. elseif v == "Explosive" then
  1356. local icon = "|T876914:12:12:0:0:64:64:4:60:4:60|t"
  1357. if SMT_CDB["TextFrame"]["short"] then
  1358. frame.text:SetText(icon.." 3")
  1359. else
  1360. frame.text:SetText(icon.." "..C_ChallengeMode.GetAffixInfo(13).." 3 "..icon)
  1361. end
  1362. end
  1363.  
  1364. TextFrame.LineUpTexts()
  1365. end
  1366.  
  1367. frame.StartTest = function()
  1368. if SMT_CDB["TextFrame"][v] then
  1369. frame:Show()
  1370. C_Timer.After(5, function() frame.reset() end)
  1371. else
  1372. frame.reset()
  1373. end
  1374. end
  1375.  
  1376. TextFrame.QueueText(frame)
  1377.  
  1378. G.Texts["test"..v] = frame
  1379. G.Test[v] = frame
  1380.  
  1381. return frame
  1382. end
  1383.  
  1384. local events_quaking = {"UNIT_AURA"}
  1385. local text_quaking = T.CreateBigText("Quaking", 1, 1, 0, events_quaking)
  1386.  
  1387. text_quaking.reset = function()
  1388. text_quaking:Hide()
  1389. text_quaking.exp = false
  1390. end
  1391.  
  1392. text_quaking.update_onevent = function(self, event, unit)
  1393. if event == "UNIT_AURA" and unit == "player" then
  1394. if self.enable and UnitDebuff("player", GetSpellInfo(240447)) then
  1395. self.count, _, self.dur, self.exp = select(4, UnitDebuff("player", GetSpellInfo(240447)))
  1396. self:Show()
  1397. else
  1398. self.reset()
  1399. end
  1400. end
  1401. end
  1402.  
  1403. text_quaking.update_onframe = function(self)
  1404. if self.enable and self.exp then
  1405. local remain = self.exp - GetTime()
  1406.  
  1407. local time_t = T.FormatTime(remain)
  1408. local icon = "|T136025:12:12:0:0:64:64:4:60:4:60|t"
  1409.  
  1410. local cast_end= select(6, UnitCastingInfo("player"))
  1411.  
  1412. if cast_end then -- 正在施法
  1413. if cast_end/1000 < self.exp then -- 当不用打断
  1414. if SMT_CDB["TextFrame"]["short"] then
  1415. self.text:SetText(L["安全施法"])
  1416. else
  1417. self.text:SetText(icon.." "..L["安全施法"].." "..time_t.." "..icon)
  1418. end
  1419. else
  1420. if SMT_CDB["TextFrame"]["short"] then
  1421. self.text:SetText(L["打断施法"])
  1422. else
  1423. self.text:SetText(icon.." "..L["打断施法"].." "..time_t.." "..icon)
  1424. end
  1425. end
  1426. else -- 没有施法
  1427. if remain > 2 then
  1428. if SMT_CDB["TextFrame"]["short"] then
  1429. self.text:SetText(L["可以读条"])
  1430. else
  1431. self.text:SetText(icon.." "..L["可以读条"].." "..time_t.." "..icon)
  1432. end
  1433. else -- 等2秒
  1434. if SMT_CDB["TextFrame"]["short"] then
  1435. self.text:SetText(L["不要读条"])
  1436. else
  1437. self.text:SetText(icon.." "..L["不要读条"].." "..time_t.." "..icon)
  1438. end
  1439. end
  1440. end
  1441.  
  1442. if remain <= 0 then
  1443. self.reset()
  1444. end
  1445. else
  1446. self.reset()
  1447. end
  1448. end
  1449.  
  1450. local events_explosive = {"NAME_PLATE_UNIT_ADDED", "NAME_PLATE_UNIT_REMOVED"}
  1451. local text_explosive = T.CreateBigText("Explosive", 0, 1, 0, events_explosive)
  1452.  
  1453. local bombs = {}
  1454. text_explosive.update_onevent = function(self, event, ...)
  1455. if event == "NAME_PLATE_UNIT_ADDED" or event == "NAME_PLATE_UNIT_REMOVED" then
  1456. local unit = ...
  1457. local guid = UnitGUID(unit)
  1458. local name = GetUnitName(unit, false)
  1459. local NPC_ID = select(6, strsplit("-", guid))
  1460. local icon = "|T876914:12:12:0:0:64:64:4:60:4:60|t"
  1461.  
  1462. if NPC_ID == "120651" then
  1463. if event == "NAME_PLATE_UNIT_ADDED" and not bombs[guid] then
  1464. bombs[guid] = 1
  1465. --SendChatMessage("出炸弹了!","YELL")
  1466. --PlaySoundFile("Sound/creature/SaboteurKiptilak/VO_GSS_SABOTEUR_SPECIAL_02B.ogg")
  1467. elseif event == "NAME_PLATE_UNIT_REMOVED" and bombs[guid] then
  1468. bombs[guid] = nil
  1469. end
  1470.  
  1471. local num = 0
  1472. for k, v in pairs(bombs) do
  1473. num = num + 1
  1474. end
  1475. if num > 0 then
  1476. if SMT_CDB["TextFrame"]["short"] then
  1477. self.text:SetText(icon.." "..num)
  1478. else
  1479. self.text:SetText(icon.." "..name.." "..num.." "..icon)
  1480. end
  1481. self:Show()
  1482. else
  1483. self:Hide()
  1484. end
  1485. end
  1486. end
  1487. end
  1488.  
  1489. text_explosive.update_onframe = function() end
  1490. ----------------------------------------------------------
  1491. ----------[[ Highlight Icon on Raid UF ]]-----------
  1492. ----------------------------------------------------------
  1493. local add_HL_holder = function(f)
  1494. if f.hl_holder then return end
  1495.  
  1496. f.hl_holder = CreateFrame("Frame", nil, f)
  1497. f.hl_holder:SetPoint(SMT_CDB["HL_Frame"]["position"], 0, 0)
  1498. f.hl_holder:SetSize(10, 10)
  1499. f.hl_holder:SetFrameStrata("HIGH")
  1500. table.insert(G.HL_Holders, f.hl_holder)
  1501.  
  1502. f.hl_holder.ActiveIcons = {}
  1503. f.hl_holder.LineUpIcons = function()
  1504. local lastframe
  1505. for v, frame in T.pairsByKeys(f.hl_holder.ActiveIcons) do
  1506. frame:ClearAllPoints()
  1507. local anchor = SMT_CDB["HL_Frame"]["position"]
  1508. if strfind(anchor, "LEFT") then
  1509. if not lastframe then
  1510. frame:SetPoint(anchor, f.hl_holder, anchor)
  1511. else
  1512. frame:SetPoint("LEFT", lastframe, "RIGHT", 3, 0)
  1513. end
  1514. elseif strfind(anchor, "RIGHT") then
  1515. if not lastframe then
  1516. frame:SetPoint(anchor, f.hl_holder, anchor)
  1517. else
  1518. frame:SetPoint("RIGHT", lastframe, "LEFT", -3, 0)
  1519. end
  1520. elseif not lastframe then
  1521. local num = 0
  1522. for k, j in pairs(f.hl_holder.ActiveIcons) do
  1523. num = num + 1
  1524. end
  1525. local iconsize = SMT_CDB["HL_Frame"]["iconSize"]
  1526. if anchor == "TOP" then
  1527. frame:SetPoint("TOPLEFT", f.hl_holder, "TOP", -((iconsize+2)*num-2)/2,0)
  1528. elseif anchor == "CENTER" then
  1529. frame:SetPoint("LEFT", f.hl_holder, "CENTER", -((iconsize+2)*num-2)/2,0)
  1530. elseif anchor == "BOTTOM" then
  1531. frame:SetPoint("BOTTOMLEFT", f.hl_holder, "BOTTOM", -((iconsize+2)*num-2)/2,0)
  1532. end
  1533. else
  1534. frame:SetPoint("LEFT", lastframe, "RIGHT", 3, 0)
  1535. end
  1536.  
  1537. lastframe = frame
  1538. end
  1539. end
  1540.  
  1541. f.hl_holder.QueueIcon = function(frame, tag)
  1542. frame.v = tag
  1543.  
  1544. frame.show = function()
  1545. frame:Show()
  1546. ActionButton_ShowOverlayGlow(frame)
  1547. end
  1548.  
  1549. frame.hide = function()
  1550. ActionButton_HideOverlayGlow(frame)
  1551. frame:Hide()
  1552. end
  1553.  
  1554. frame:HookScript("OnShow", function()
  1555. f.hl_holder.ActiveIcons[frame.v] = frame
  1556. f.hl_holder.LineUpIcons()
  1557. end)
  1558.  
  1559. frame:HookScript("OnHide", function()
  1560. f.hl_holder.ActiveIcons[frame.v] = nil
  1561. f.hl_holder.LineUpIcons()
  1562. end)
  1563.  
  1564. end
  1565. end
  1566.  
  1567. local add_Icon = function(f, v, t, target, sourceGUID)
  1568. add_HL_holder(f)
  1569. local tag = v..sourceGUID or ""
  1570.  
  1571. if f.hl_holder.ActiveIcons[tag] then return end
  1572.  
  1573. local _, ID_str, DUR_str = strsplit("_" , v)
  1574. local spellID = tonumber(ID_str)
  1575. local spellName, _, spellIcon = GetSpellInfo(spellID)
  1576.  
  1577. local frame = CreateFrame("Frame", nil, f.hl_holder)
  1578. frame:SetSize(SMT_CDB["HL_Frame"]["iconSize"], SMT_CDB["HL_Frame"]["iconSize"])
  1579. frame:SetAlpha(SMT_CDB["HL_Frame"]["iconAlpha"]/100)
  1580. frame:Hide()
  1581. f.hl_holder.QueueIcon(frame, tag)
  1582.  
  1583. local texture = frame:CreateTexture(nil,"HIGH")
  1584. texture:SetTexture(spellIcon)
  1585. texture:SetPoint("TOPLEFT", 2, -2)
  1586. texture:SetPoint("BOTTOMRIGHT", -2, 2)
  1587. texture:SetTexCoord(0.1, 0.9, 0.1, 0.9)
  1588.  
  1589.  
  1590. if t == "HL_Auras" then
  1591. local debuff_dur = select(6, UnitBuff(target, spellName))
  1592. if not debuff_dur then return end
  1593.  
  1594. frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  1595. frame:SetScript("OnEvent", function(self, event, ...)
  1596. local _, Event_type, _, _, _, _, _, _, DestName, _, _, SpellID = ...
  1597. if Event_type == "SPELL_AURA_REMOVED" and SpellID == spellID and DestName then
  1598. local Tar = string.split("-", DestName)
  1599. if Tar == target then
  1600. frame.hide()
  1601. end
  1602. end
  1603. end)
  1604.  
  1605. if debuff_dur > 0 then -- 有持续时间
  1606. local cooldown = CreateFrame("COOLDOWN", nil, frame, "CooldownFrameTemplate")
  1607. cooldown:SetCooldown(GetTime(), debuff_dur)
  1608. cooldown:SetPoint("TOPLEFT", 4, -4)
  1609. cooldown:SetPoint("BOTTOMRIGHT", -4, 4)
  1610. cooldown:SetDrawEdge(false)
  1611. cooldown:SetHideCountdownNumbers(true)
  1612.  
  1613. C_Timer.After(debuff_dur, function()
  1614. if frame:IsShown() then
  1615. frame.hide()
  1616. end
  1617. end)
  1618.  
  1619. end
  1620.  
  1621. frame.show()
  1622.  
  1623. elseif t == "HL_Cast" then
  1624.  
  1625. local dur = tonumber(DUR_str)
  1626.  
  1627. local cooldown = CreateFrame("COOLDOWN", nil, frame, "CooldownFrameTemplate")
  1628. cooldown:SetCooldown(GetTime(), dur)
  1629. cooldown:SetPoint("TOPLEFT", 4, -4)
  1630. cooldown:SetPoint("BOTTOMRIGHT", -4, 4)
  1631. cooldown:SetDrawEdge(false)
  1632. cooldown:SetHideCountdownNumbers(true)
  1633.  
  1634. C_Timer.After(dur, function()
  1635. frame.hide()
  1636. end)
  1637.  
  1638. frame.show()
  1639.  
  1640. elseif t == "HL_Casting" then
  1641.  
  1642. local cast_time = select(4, GetSpellInfo(spellID))/1000
  1643.  
  1644. local cooldown = CreateFrame("COOLDOWN", nil, frame, "CooldownFrameTemplate")
  1645. cooldown:SetCooldown(GetTime(), cast_time)
  1646. cooldown:SetPoint("TOPLEFT", 4, -4)
  1647. cooldown:SetPoint("BOTTOMRIGHT", -4, 4)
  1648. cooldown:SetDrawEdge(false)
  1649. cooldown:SetHideCountdownNumbers(true)
  1650.  
  1651. C_Timer.After(cast_time, function()
  1652. if frame:IsShown() then
  1653. frame.hide()
  1654. end
  1655. end)
  1656.  
  1657. frame:RegisterEvent("UNIT_SPELLCAST_STOP")
  1658.  
  1659. frame:SetScript("OnEvent", function(self, event, ...)
  1660. local Unit, Spell, _, _, SpellID = ...
  1661. if SpellID == spellID and UnitGUID(Unit) == sourceGUID then
  1662. ActionButton_HideOverlayGlow(frame)
  1663. frame:Hide()
  1664. end
  1665. end)
  1666.  
  1667. frame.show()
  1668. end
  1669. end
  1670.  
  1671. T.EditHL = function()
  1672. for _, holder in pairs(G.HL_Holders) do
  1673. holder:ClearAllPoints()
  1674. holder:SetPoint(SMT_CDB["HL_Frame"]["position"], 0, 0)
  1675. end
  1676. end
  1677.  
  1678. T.HL_OnRaid = function(v, t, target, sourceGUID)
  1679.  
  1680. if SMT_CDB["General"]["disable_all"] or not SMT_CDB["HL_Frame"]["enable"] or not SMT_CDB[t][v] then return end
  1681.  
  1682. local hasGrid = IsAddOnLoaded("Grid")
  1683. local hasGrid2 = IsAddOnLoaded("Grid2")
  1684. local hasCompactRaid = IsAddOnLoaded("CompactRaid")
  1685. local hasVuhDo = IsAddOnLoaded("VuhDo")
  1686. local hasElvUI = _G["ElvUF_Raid"] and _G["ElvUF_Raid"]:IsVisible() or IsAddOnLoaded("ElvUI")
  1687. local hasElvUI2 = _G["ElvUF_Party"] and _G["ElvUF_Party"]:IsVisible() or IsAddOnLoaded("ElvUI")
  1688. local hasAltzUI = _G["Altz_HealerRaid"] and _G["Altz_HealerRaid"]:IsVisible()
  1689. local hasNDui = IsAddOnLoaded("NDui")
  1690.  
  1691. if hasElvUI then
  1692. for i=1, 8 do
  1693. for j=1, 5 do
  1694. local f = _G["ElvUF_RaidGroup"..i.."UnitButton"..j]
  1695. if f and f.unit and UnitName(f.unit) == target then
  1696. add_Icon(f, v, t, target, sourceGUID)
  1697. return
  1698. end
  1699. end
  1700. end
  1701. elseif hasElvUI2 then
  1702. for i=1, 8 do
  1703. for j=1, 5 do
  1704. local f = _G["ElvUF_PartyGroup"..i.."UnitButton"..j]
  1705. if f and f.unit and UnitName(f.unit) == target then
  1706. add_Icon(f, v, t, target, sourceGUID)
  1707. return
  1708. end
  1709. end
  1710. end
  1711. elseif hasGrid then
  1712. local layout = GridLayoutFrame
  1713.  
  1714. if layout then
  1715. local children = {layout:GetChildren()}
  1716. for _, child in ipairs(children) do
  1717. if child:IsVisible() then
  1718. local frames = {child:GetChildren()}
  1719. for _, f in ipairs(frames) do
  1720. if f.unit and UnitName(f.unit) == target then
  1721. add_Icon(f, v, t, target, sourceGUID)
  1722. return
  1723. end
  1724. end
  1725. end
  1726. end
  1727. end
  1728. elseif hasGrid2 then
  1729. local layout = Grid2LayoutFrame
  1730.  
  1731. if layout then
  1732. local children = {layout:GetChildren()}
  1733. for _, child in ipairs(children) do
  1734. if child:IsVisible() then
  1735. local frames = {child:GetChildren()}
  1736. for _, f in ipairs(frames) do
  1737. if f.unit and UnitName(f.unit) == target then
  1738. add_Icon(f, v, t, target, sourceGUID)
  1739. return
  1740. end
  1741. end
  1742. end
  1743. end
  1744. end
  1745. elseif hasVuhDo then
  1746. for i = 1, 40 do
  1747. local f = _G["Vd1H"..i]
  1748. if f and f.raidid and UnitName(f.raidid) == target then
  1749. add_Icon(f, v, t, target, sourceGUID)
  1750. return
  1751. end
  1752. end
  1753. elseif hasAltzUI then
  1754. for i = 1, 40 do
  1755. local f = _G["Altz_HealerRaidUnitButton"..i]
  1756. if f and f.unit and UnitName(f.unit) == target then
  1757. add_Icon(f, v, t, target, sourceGUID)
  1758. return
  1759. end
  1760. end
  1761. elseif hasNDui then
  1762. for i =1, 8 do
  1763. for j = 1, 5 do
  1764. local f = _G["oUF_Raid"..i.."UnitButton"..j]
  1765. if f and f.unit and UnitName(f.unit) == target then
  1766. add_Icon(f, v, t, target, sourceGUID)
  1767. return
  1768. end
  1769. end
  1770. end
  1771. elseif hasCompactRaid then
  1772. for i =1, 8 do
  1773. for j = 1, 5 do
  1774. local f = _G["CompactRaidGroupHeaderSubGroup"..i.."UnitButton"..j]
  1775. if f and f.unit and UnitName(f.unit) == target then
  1776. add_Icon(f, v, t, target, sourceGUID)
  1777. return
  1778. end
  1779. end
  1780. end
  1781. else
  1782. for i=1, 40 do
  1783. local f = _G["CompactRaidFrame"..i]
  1784. if f and f.unitExists and f.unit and UnitName(f.unit) == target then
  1785. add_Icon(f, v, t, target, sourceGUID)
  1786. return
  1787. end
  1788. end
  1789. for i=1, 4 do
  1790. for j=1, 5 do
  1791. local f = _G["CompactRaidGroup"..i.."Member"..j]
  1792. if f and f.unitExists and f.unit and UnitName(f.unit) == target then
  1793. add_Icon(f, v, t, target, sourceGUID)
  1794. return
  1795. end
  1796. end
  1797. end
  1798. end
  1799.  
  1800. end
  1801.  
  1802. T.Create_HL_EventFrame = function(parent, v, t)
  1803. local frame = CreateFrame("Frame", addon_name.."HL_EventFrame"..v, FrameHolder)
  1804. frame:RegisterEvent("WORLD_MAP_UPDATE")
  1805. frame.map_id, frame.spell_id = strsplit("_", v)
  1806. frame.map_id = tonumber(frame.map_id)
  1807. frame.spell_id = tonumber(frame.spell_id)
  1808.  
  1809. if t == "HL_Auras" then
  1810. frame:SetScript("OnEvent", function(self, e, ...)
  1811. if e == "WORLD_MAP_UPDATE" then
  1812. local map = GetCurrentMapAreaID()
  1813. if map == frame.map_id then
  1814. frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  1815. else
  1816. frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  1817. end
  1818. else
  1819. local _, Event_type, _, sourceGUID, _, _, _, _, DestName, _, _, SpellID = ...
  1820. if SpellID == frame.spell_id and Event_type == "SPELL_AURA_APPLIED" and DestName then
  1821. local target = string.split("-", DestName)
  1822. T.HL_OnRaid(v, t, target, sourceGUID)
  1823. end
  1824. end
  1825. end)
  1826. elseif t == "HL_Cast" then
  1827. frame:SetScript("OnEvent", function(self, e, ...)
  1828. if e == "WORLD_MAP_UPDATE" then
  1829. local map = GetCurrentMapAreaID()
  1830. if map == frame.map_id then
  1831. frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  1832. else
  1833. frame:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  1834. end
  1835. else
  1836. local _, Event_type, _, sourceGUID, _, _, _, _, DestName, _, _, SpellID = ...
  1837. if SpellID == frame.spell_id and Event_type == "SPELL_CAST_SUCCESS" and DestName then
  1838. local target = string.split("-", DestName)
  1839. T.HL_OnRaid(v, t, target, sourceGUID)
  1840. end
  1841. end
  1842. end)
  1843. elseif t == "HL_Casting" then
  1844. frame:SetScript("OnEvent", function(self, e, ...)
  1845. if e == "WORLD_MAP_UPDATE" then
  1846. local map = GetCurrentMapAreaID()
  1847. if map == frame.map_id then
  1848. frame:RegisterEvent("UNIT_SPELLCAST_START")
  1849. frame:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
  1850. else
  1851. frame:UnregisterEvent("UNIT_SPELLCAST_START")
  1852. frame:UnregisterEvent("UNIT_SPELLCAST_CHANNEL_START")
  1853. end
  1854. elseif e == "UNIT_SPELLCAST_START" or e == "UNIT_SPELLCAST_CHANNEL_START" then
  1855. local Unit, Spell, _, _, SpellID = ...
  1856. if SpellID == frame.spell_id then
  1857. C_Timer.After(.1, function()
  1858. local target = UnitName(Unit.."target")
  1859. if target then
  1860. local sourceGUID = UnitGUID(Unit)
  1861. T.HL_OnRaid(v, t, target, sourceGUID)
  1862. end
  1863. end)
  1864. end
  1865. end
  1866. end)
  1867. end
  1868.  
  1869. T.Create_HLOnRaid_Options(parent, v, t)
  1870.  
  1871. return frame
  1872. end
  1873. ----------------------------------------------------------
  1874. ---------------[[ Nameplate Icons ]]----------------
  1875. ----------------------------------------------------------
  1876. local function CreateIcon(parent, tag)
  1877. local button = CreateFrame("Frame", nil, parent)
  1878. button:SetSize(SMT_CDB["PlateAlerts"]["size"], SMT_CDB["PlateAlerts"]["size"])
  1879.  
  1880. button.icon = button:CreateTexture(nil, "OVERLAY", nil, 3)
  1881. button.icon:SetPoint("TOPLEFT",button,"TOPLEFT", 1, -1)
  1882. button.icon:SetPoint("BOTTOMRIGHT",button,"BOTTOMRIGHT",-1, 1)
  1883. button.icon:SetTexCoord(.08, .92, 0.08, 0.92)
  1884.  
  1885. button.overlay = button:CreateTexture(nil, "ARTWORK", nil, 7)
  1886. button.overlay:SetTexture("Interface\\Buttons\\WHITE8x8")
  1887. button.overlay:SetAllPoints(button)
  1888.  
  1889. button.bd = button:CreateTexture(nil, "ARTWORK", nil, 6)
  1890. button.bd:SetTexture("Interface\\Buttons\\WHITE8x8")
  1891. button.bd:SetVertexColor(0, 0, 0)
  1892. button.bd:SetPoint("TOPLEFT",button,"TOPLEFT", -1, 1)
  1893. button.bd:SetPoint("BOTTOMRIGHT",button,"BOTTOMRIGHT", 1, -1)
  1894.  
  1895. if strfind(tag, "spells") then
  1896. button.cd = CreateFrame("COOLDOWN", nil, button, "CooldownFrameTemplate")
  1897. button.cd:SetPoint("TOPLEFT", 1, -1)
  1898. button.cd:SetPoint("BOTTOMRIGHT", -1, 1)
  1899. button.cd:SetDrawEdge(false)
  1900.  
  1901. button.cast = CreateFrame("Frame", nil, button)
  1902. button.cast:SetAllPoints()
  1903. button.cast:Hide()
  1904.  
  1905. button.cast.icon = button.cast:CreateTexture(nil, "OVERLAY", nil, 3)
  1906. button.cast.icon:SetPoint("TOPLEFT",button.cast,"TOPLEFT", 1, -1)
  1907. button.cast.icon:SetPoint("BOTTOMRIGHT",button.cast,"BOTTOMRIGHT",-1, 1)
  1908. button.cast.icon:SetTexCoord(.08, .92, 0.08, 0.92)
  1909.  
  1910. button.cast.overlay = button.cast:CreateTexture(nil, "ARTWORK", nil, 7)
  1911. button.cast.overlay:SetTexture("Interface\\Buttons\\WHITE8x8")
  1912. button.cast.overlay:SetAllPoints()
  1913. button.cast.overlay:SetVertexColor(1, 1, 0)
  1914.  
  1915. button.cast.spell = T.createtext(button.cast, "OVERLAY", SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE", "CENTER") -- 中间
  1916. button.cast.spell:SetPoint("TOPLEFT", button.cast, "TOPLEFT", -5, 1)
  1917. button.cast.spell:SetPoint("TOPRIGHT", button.cast, "TOPRIGHT", 5, 1)
  1918. button.cast.spell:SetTextColor(1, 1, 0)
  1919. button.cast.spell:SetHeight(SMT_CDB["PlateAlerts"]["fsize"])
  1920.  
  1921. button.cast.target = T.createtext(button.cast, "OVERLAY", SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE", "CENTER") -- 中间
  1922. button.cast.target:SetPoint("BOTTOMLEFT", button.cast, "BOTTOMLEFT", -5, -1)
  1923. button.cast.target:SetPoint("BOTTOMRIGHT", button.cast, "BOTTOMRIGHT", 5, -1)
  1924. button.cast.target:SetHeight(SMT_CDB["PlateAlerts"]["fsize"]*2.5)
  1925.  
  1926. button.cast.dur = T.createtext(button.cast, "OVERLAY", SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE", "CENTER") -- 中间
  1927. button.cast.dur:SetPoint("TOP", button.cast, "BOTTOM", 0, -2)
  1928.  
  1929. button.cast.t = 0
  1930. button.cast:SetScript("OnUpdate", function(self, e)
  1931. self.t = self.t + e
  1932. if self.t > .1 then
  1933. if self.exp then
  1934. self.dur:SetText(T.FormatTime(self.exp-GetTime()))
  1935. end
  1936. self.t = 0
  1937. end
  1938. end)
  1939. end
  1940.  
  1941. if strfind(tag, "aura") then
  1942. button.text = T.createtext(button, "OVERLAY", SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE", "CENTER") -- 中间
  1943. button.text:SetPoint("BOTTOM", button, "BOTTOM", 0, -2)
  1944. button.text:SetTextColor(1, 1, 0)
  1945. end
  1946.  
  1947. if strfind(tag, "aura") or strfind(tag, "power") or strfind(tag, "bolster") then
  1948. button.count = T.createtext(button, "OVERLAY", SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE", "RIGHT") -- 右上
  1949. button.count:SetPoint("TOPRIGHT", button, "TOPRIGHT", -1, 2)
  1950. button.count:SetTextColor(.4, .95, 1)
  1951. end
  1952.  
  1953. if strfind(tag, "bomb") then
  1954. button.icon:SetTexture(876914)
  1955. elseif strfind(tag, "bolster") then
  1956. button.icon:SetTexture(1041231)
  1957. elseif strfind(tag, "sanguine") then
  1958. button.icon:SetTexture(136124)
  1959. elseif strfind(tag, "raging") then
  1960. button.icon:SetTexture(132117)
  1961. end
  1962.  
  1963. button:Hide()
  1964. parent.QueueIcon(button, tag)
  1965.  
  1966. return button
  1967. end
  1968.  
  1969. local function UpdateSpellIcon(event, event_SpellID, button, unit, spellID, cd)
  1970. local spell_name, _, icon = GetSpellInfo(spellID)
  1971. button.icon:SetTexture(icon)
  1972. button.cast.icon:SetTexture(icon)
  1973. button.cast.spell:SetText(spell_name)
  1974.  
  1975. if event == "UNIT_SPELLCAST_START" or event == "all" then
  1976. local _, _, _, _, startTimeMS, endTimeMS, _, _, notInterruptible, casting_spellID = UnitCastingInfo(unit)
  1977. if casting_spellID == spellID then
  1978. if notInterruptible then
  1979. button.cast.overlay:SetVertexColor(1, 0, 0)
  1980. else
  1981. button.cast.overlay:SetVertexColor(0, 1, 1)
  1982. end
  1983. button.cast.exp = endTimeMS/1000
  1984. C_Timer.After(.1, function()
  1985. if UnitName(unit.."target") then
  1986. button.cast.target:SetText(T.ColorUnitName(unit.."target", UnitName(unit.."target")))
  1987. end
  1988. end)
  1989. C_Timer.After((endTimeMS-startTimeMS)/1000, function()
  1990. button.cast:Hide()
  1991. button.cast.target:SetText("")
  1992. end)
  1993. button.cast:Show()
  1994. if cd == 1 then button:Show() end
  1995. end
  1996. elseif event == "UNIT_SPELLCAST_START" or event == "all" then
  1997. local _, _, _, _, startTimeMS, endTimeMS, _, _, notInterruptible, casting_spellID = UnitChannelInfo(unit)
  1998. if casting_spellID == spellID then
  1999. if notInterruptible then
  2000. button.cast.overlay:SetVertexColor(1, 0, 0)
  2001. else
  2002. button.cast.overlay:SetVertexColor(0, 1, 1)
  2003. end
  2004. button.cast.exp = endTimeMS/1000
  2005. C_Timer.After(.1, function()
  2006. if UnitName(unit.."target") then
  2007. button.cast.target:SetText(T.ColorUnitName(unit.."target", UnitName(unit.."target")))
  2008. end
  2009. end)
  2010. C_Timer.After((endTimeMS-startTimeMS)/1000, function()
  2011. button.cast:Hide()
  2012. button.cast.target:SetText("")
  2013. end)
  2014. button.cast:Show()
  2015. if cd == 1 then button:Show() end
  2016. end
  2017. elseif event == "UNIT_SPELLCAST_SUCCEEDED" then
  2018. if event_SpellID == spellID and cd > 1 then
  2019. local realcd = cd - select(4, GetSpellInfo(spellID))*(100+GetHaste())/1e5
  2020. button.cd:SetCooldown(GetTime(), realcd)
  2021. end
  2022. elseif not (UnitCastingInfo(unit) or UnitChannelInfo(unit)) then
  2023. button.cast:Hide()
  2024. if cd == 1 then button:Hide() end
  2025. end
  2026.  
  2027. if cd ~= 1 then
  2028. button:Show()
  2029. end
  2030. end
  2031.  
  2032. local function UpdateSpells(unitFrame, event, event_SpellID)
  2033. if not unitFrame.unit or SMT_CDB["General"]["disable_all"] or not SMT_CDB["PlateAlerts"]["enable"] then return end
  2034. local i = 1
  2035.  
  2036. if G.Npc[unitFrame.npcID] then
  2037. for spellID, cd in pairs(G.Npc[unitFrame.npcID]) do
  2038. local unit = unitFrame.unit
  2039. if i <= 5 then
  2040. if not unitFrame.icons.Spell_Icons[i] then
  2041. unitFrame.icons.Spell_Icons[i] = CreateIcon(unitFrame.icons, "spells"..i)
  2042. end
  2043. UpdateSpellIcon(event, event_SpellID, unitFrame.icons.Spell_Icons[i], unit, spellID, cd)
  2044. i = i + 1
  2045. end
  2046. end
  2047. end
  2048.  
  2049. for index = i, #unitFrame.icons.Spell_Icons do unitFrame.icons.Spell_Icons[index]:Hide() end
  2050. end
  2051.  
  2052. local function UpdateAuraIcon(button, unit, index, filter)
  2053. local name, _, icon, count, debuffType, duration, expirationTime, _, _, _, spellID = UnitAura(unit, index, filter)
  2054.  
  2055. button.icon:SetTexture(icon)
  2056. button.expirationTime = expirationTime
  2057. button.duration = duration
  2058. button.spellID = spellID
  2059.  
  2060. local color = DebuffTypeColor[debuffType] or DebuffTypeColor.none
  2061. button.overlay:SetVertexColor(color.r, color.g, color.b)
  2062.  
  2063. if count and count > 1 then
  2064. button.count:SetText(count)
  2065. else
  2066. button.count:SetText("")
  2067. end
  2068.  
  2069. button:SetScript("OnUpdate", function(self, elapsed)
  2070. if not self.duration then return end
  2071.  
  2072. self.elapsed = (self.elapsed or 0) + elapsed
  2073.  
  2074. if self.elapsed < .2 then return end
  2075. self.elapsed = 0
  2076.  
  2077. local timeLeft = self.expirationTime - GetTime()
  2078. if timeLeft <= 0 then
  2079. self.text:SetText(nil)
  2080. else
  2081. self.text:SetText(T.FormatTime(timeLeft))
  2082. end
  2083. end)
  2084.  
  2085. button:Show()
  2086. end
  2087.  
  2088. local function UpdateAuras(unitFrame)
  2089. if not unitFrame.unit or SMT_CDB["General"]["disable_all"] or not SMT_CDB["PlateAlerts"]["enable"] then return end
  2090. local unit = unitFrame.unit
  2091. local i = 1
  2092.  
  2093. for index = 1, 20 do
  2094. if i <= 5 then
  2095. local bname, _, _, _, _, bduration, _, bcaster, _, _, bspellid = UnitAura(unit, index, 'HELPFUL')
  2096. if bname and SMT_CDB["PlateAuras"][bspellid] then
  2097. if not unitFrame.icons.Aura_Icons[i] then
  2098. unitFrame.icons.Aura_Icons[i] = CreateIcon(unitFrame.icons, "aura"..i)
  2099. end
  2100. UpdateAuraIcon(unitFrame.icons.Aura_Icons[i], unit, index, 'HELPFUL')
  2101. i = i + 1
  2102. end
  2103. end
  2104. end
  2105.  
  2106. for index = 1, 20 do
  2107. if i <= 5 then
  2108. local dname, _, _, _, _, dduration, _, dcaster, _, _, dspellid = UnitAura(unit, index, 'HARMFUL')
  2109. if dname and SMT_CDB["PlateAuras"][dspellid] then
  2110. if not unitFrame.icons.Aura_Icons[i] then
  2111. unitFrame.icons.Aura_Icons[i] = CreateIcon(unitFrame.icons, "aura"..i)
  2112. end
  2113. UpdateAuraIcon(unitFrame.icons.Aura_Icons[i], unit, index, 'HARMFUL')
  2114. i = i + 1
  2115. end
  2116. end
  2117. end
  2118.  
  2119. for index = i, #unitFrame.icons.Aura_Icons do unitFrame.icons.Aura_Icons[index]:Hide() end
  2120. end
  2121.  
  2122. local function UpdatePower(unitFrame)
  2123. if not unitFrame.unit or SMT_CDB["General"]["disable_all"] or not SMT_CDB["PlateAlerts"]["enable"] or not SMT_CDB["PlatePower"][unitFrame.npcID] then
  2124. if unitFrame.icons.powericon and unitFrame.icons.powericon:IsShown() then
  2125. unitFrame.icons.powericon:Hide()
  2126. end
  2127. return
  2128. end
  2129.  
  2130. local unit = unitFrame.unit
  2131. local pp = UnitPower(unit)
  2132.  
  2133. if not unitFrame.icons.powericon then
  2134. unitFrame.icons.powericon = CreateIcon(unitFrame.icons, "power")
  2135. end
  2136.  
  2137. if pp > 85 then
  2138. unitFrame.icons.powericon.icon:SetTexture(531771)
  2139. elseif pp > 45 then
  2140. unitFrame.icons.powericon.icon:SetTexture(531773)
  2141. else
  2142. unitFrame.icons.powericon.icon:SetTexture(531776)
  2143. end
  2144. unitFrame.icons.powericon.count:SetText(pp)
  2145. unitFrame.icons.powericon:Show()
  2146. end
  2147.  
  2148. local function UpdateBomb(unitFrame)
  2149. if not unitFrame.unit or SMT_CDB["General"]["disable_all"] or not SMT_CDB["PlateAlerts"]["enable"] or not SMT_CDB["PlateAlerts"]["Explosive_np"] then
  2150. if unitFrame.icons.bombicon and unitFrame.icons.bombicon:IsShown() then
  2151. unitFrame.icons.bombicon:Hide()
  2152. end
  2153. return
  2154. end
  2155.  
  2156. if not C_ChallengeMode.GetActiveKeystoneInfo() or select(2, C_ChallengeMode.GetActiveKeystoneInfo())[2] ~= 13 then return end
  2157.  
  2158. local NpcID = select(6, strsplit("-", UnitGUID(unitFrame.unit)))
  2159.  
  2160. if NpcID == "120651" then
  2161. if not unitFrame.icons.bombicon then
  2162. unitFrame.icons.bombicon = CreateIcon(unitFrame.icons, "bomb")
  2163. end
  2164. unitFrame.icons.bombicon:Show()
  2165. else
  2166. if unitFrame.icons.bombicon and unitFrame.icons.bombicon:IsShown() then
  2167. unitFrame.icons.bombicon:Hide()
  2168. end
  2169. end
  2170. end
  2171.  
  2172. local function UpdateBolster(unitFrame)
  2173. if not unitFrame.unit or SMT_CDB["General"]["disable_all"] or not SMT_CDB["PlateAlerts"]["enable"] or not SMT_CDB["PlateAlerts"]["Bolster_np"] then return end
  2174.  
  2175. if not C_ChallengeMode.GetActiveKeystoneInfo() or select(2, C_ChallengeMode.GetActiveKeystoneInfo())[1] ~= 7 then return end
  2176.  
  2177. local unit = unitFrame.unit
  2178. local stack = 0
  2179.  
  2180. for index = 1, 20 do
  2181. local bspellid = select(11, UnitAura(unit, index, 'HELPFUL'))
  2182. if bspellid == 209859 then
  2183. stack = stack + 1
  2184. end
  2185. end
  2186.  
  2187. if stack > 0 then
  2188. if not unitFrame.icons.bolstericon then
  2189. unitFrame.icons.bolstericon = CreateIcon(unitFrame.icons, "bolster")
  2190. end
  2191. unitFrame.icons.bolstericon.count:SetText(format("%d%%", 1.2^stack*100))
  2192. unitFrame.icons.bolstericon:Show()
  2193. elseif unitFrame.icons.bolstericon and unitFrame.icons.bolstericon:IsShown() then
  2194. unitFrame.icons.bolstericon:Hide()
  2195. end
  2196. end
  2197.  
  2198. local function UpdateSanguine(unitFrame)
  2199. if not unitFrame.unit or SMT_CDB["General"]["disable_all"] or not SMT_CDB["PlateAlerts"]["enable"] or not SMT_CDB["PlateAlerts"]["Sanguine_np"] then return end
  2200.  
  2201. if not C_ChallengeMode.GetActiveKeystoneInfo() or select(2, C_ChallengeMode.GetActiveKeystoneInfo())[1] ~= 8 then return end
  2202.  
  2203. local unit = unitFrame.unit
  2204.  
  2205. if UnitBuff(unit, GetSpellInfo(226510)) then
  2206. if not unitFrame.icons.sanguineicon then
  2207. unitFrame.icons.sanguineicon = CreateIcon(unitFrame.icons, "sanguine")
  2208. end
  2209. unitFrame.icons.sanguineicon:Show()
  2210. elseif unitFrame.icons.sanguineicon and unitFrame.icons.sanguineicon:IsShown() then
  2211. unitFrame.icons.sanguineicon:Hide()
  2212. end
  2213. end
  2214.  
  2215. local function UpdateRaging(unitFrame)
  2216. if not unitFrame.unit or SMT_CDB["General"]["disable_all"] or not SMT_CDB["PlateAlerts"]["enable"] or not SMT_CDB["PlateAlerts"]["Raging_np"] then return end
  2217.  
  2218. if not C_ChallengeMode.GetActiveKeystoneInfo() or select(2, C_ChallengeMode.GetActiveKeystoneInfo())[2] ~= 6 then return end
  2219.  
  2220. local unit = unitFrame.unit
  2221.  
  2222. if UnitBuff(unit, GetSpellInfo(228318)) then
  2223. if not unitFrame.icons.ragingicon then
  2224. unitFrame.icons.ragingicon = CreateIcon(unitFrame.icons, "raging")
  2225. end
  2226. unitFrame.icons.ragingicon:Show()
  2227. elseif unitFrame.icons.ragingicon and unitFrame.icons.ragingicon:IsShown() then
  2228. unitFrame.icons.ragingicon:Hide()
  2229. end
  2230. end
  2231.  
  2232. local function NamePlate_OnEvent(self, event, arg1, ...)
  2233. if event == "PLAYER_ENTERING_WORLD" then
  2234. UpdateAuras(self)
  2235. UpdatePower(self)
  2236. UpdateBomb(self)
  2237. UpdateBolster(self)
  2238. UpdateSanguine(self)
  2239. UpdateRaging(self)
  2240. UpdateSpells(self, "all")
  2241. elseif event == "UNIT_AURA" and arg1 == self.unit then
  2242. UpdateAuras(self)
  2243. UpdateBolster(self)
  2244. UpdateSanguine(self)
  2245. UpdateRaging(self)
  2246. elseif event == "UNIT_POWER_FREQUENT" and arg1 == self.unit then
  2247. UpdatePower(self)
  2248. elseif CastingEvents[event] and arg1 == self.unit then
  2249. local event_SpellID = select(4, ...)
  2250. UpdateSpells(self, event, event_SpellID)
  2251. end
  2252. end
  2253.  
  2254. local function SetUnit(unitFrame, unit)
  2255. unitFrame.unit = unit
  2256. if unit then
  2257. unitFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
  2258. unitFrame:RegisterUnitEvent("UNIT_AURA", unitFrame.unit)
  2259. unitFrame:RegisterUnitEvent("UNIT_POWER_FREQUENT", unitFrame.unit)
  2260. unitFrame:RegisterUnitEvent("UNIT_SPELLCAST_START", unitFrame.unit)
  2261. unitFrame:RegisterUnitEvent("UNIT_SPELLCAST_SUCCEEDED", unitFrame.unit)
  2262. unitFrame:RegisterUnitEvent("UNIT_SPELLCAST_STOP", unitFrame.unit)
  2263. unitFrame:RegisterUnitEvent("UNIT_SPELLCAST_CHANNEL_START", unitFrame.unit)
  2264. unitFrame:RegisterUnitEvent("UNIT_SPELLCAST_CHANNEL_STOP", unitFrame.unit)
  2265. unitFrame:SetScript("OnEvent", NamePlate_OnEvent)
  2266. unitFrame.npcID = select(6, strsplit("-", UnitGUID(unit)))
  2267. else
  2268. unitFrame:UnregisterAllEvents()
  2269. unitFrame:SetScript("OnEvent", nil)
  2270. unitFrame.npcID = nil
  2271. end
  2272. end
  2273.  
  2274. function NamePlates_UpdateAllNamePlates()
  2275. for i, namePlate in ipairs(C_NamePlate.GetNamePlates()) do
  2276. local unitFrame = namePlate.suf
  2277. UpdateAuras(unitFrame)
  2278. UpdatePower(unitFrame)
  2279. UpdateBomb(unitFrame)
  2280. UpdateBolster(unitFrame)
  2281. UpdateSanguine(unitFrame)
  2282. UpdateRaging(unitFrame)
  2283. UpdateSpells(unitFrame, "all")
  2284. end
  2285. end
  2286.  
  2287. local function OnNamePlateCreated(namePlate)
  2288. namePlate.suf = CreateFrame("Button", "$parentUnitFrame", namePlate)
  2289. namePlate.suf:SetAllPoints(namePlate)
  2290. namePlate.suf:SetFrameLevel(namePlate:GetFrameLevel())
  2291.  
  2292. namePlate.suf.icons = CreateFrame("Frame", nil, namePlate.suf)
  2293. namePlate.suf.icons:SetPoint("BOTTOM", namePlate.suf, "TOP", 0, SMT_CDB["PlateAlerts"]["y"])
  2294. namePlate.suf.icons:SetWidth(90)
  2295. namePlate.suf.icons:SetHeight(30)
  2296. namePlate.suf.icons:SetFrameLevel(namePlate:GetFrameLevel()+1)
  2297.  
  2298. namePlate.suf.icons.Aura_Icons = {}
  2299. namePlate.suf.icons.Spell_Icons = {}
  2300.  
  2301. namePlate.suf.icons.ActiveIcons = {}
  2302. namePlate.suf.icons.LineUpIcons = function()
  2303. local lastframe
  2304. for v, frame in T.pairsByKeys(namePlate.suf.icons.ActiveIcons) do
  2305. frame:ClearAllPoints()
  2306. if not lastframe then
  2307. local num = 0
  2308. for k, j in pairs(namePlate.suf.icons.ActiveIcons) do
  2309. num = num + 1
  2310. end
  2311. frame:SetPoint("LEFT", namePlate.suf.icons, "CENTER", -((SMT_CDB["PlateAlerts"]["size"]+4)*num-4)/2,0)
  2312. else
  2313. frame:SetPoint("LEFT", lastframe, "RIGHT", 3, 0)
  2314. end
  2315.  
  2316. lastframe = frame
  2317. end
  2318. end
  2319.  
  2320. namePlate.suf.icons.QueueIcon = function(frame, tag)
  2321. frame.v = tag
  2322.  
  2323. frame:HookScript("OnShow", function()
  2324. namePlate.suf.icons.ActiveIcons[frame.v] = frame
  2325. namePlate.suf.icons.LineUpIcons()
  2326. end)
  2327.  
  2328. frame:HookScript("OnHide", function()
  2329. namePlate.suf.icons.ActiveIcons[frame.v] = nil
  2330. namePlate.suf.icons.LineUpIcons()
  2331. end)
  2332. end
  2333.  
  2334. table.insert(G.Plate_IconHolders, namePlate.suf.icons)
  2335.  
  2336. namePlate.suf:EnableMouse(false)
  2337. end
  2338.  
  2339. local function OnNamePlateAdded(unit)
  2340. local namePlate = C_NamePlate.GetNamePlateForUnit(unit)
  2341. local unitFrame = namePlate.suf
  2342. SetUnit(unitFrame, unit)
  2343. UpdateAuras(unitFrame)
  2344. UpdatePower(unitFrame)
  2345. UpdateBomb(unitFrame)
  2346. UpdateBolster(unitFrame)
  2347. UpdateSanguine(unitFrame)
  2348. UpdateRaging(unitFrame)
  2349. UpdateSpells(unitFrame, "all")
  2350. end
  2351.  
  2352. local function OnNamePlateRemoved(unit)
  2353. local namePlate = C_NamePlate.GetNamePlateForUnit(unit)
  2354. SetUnit(namePlate.suf, nil)
  2355. end
  2356.  
  2357. local function NamePlates_OnEvent(self, event, ...)
  2358. if ( event == "VARIABLES_LOADED" ) then
  2359. NamePlates_UpdateAllNamePlates()
  2360. elseif ( event == "NAME_PLATE_CREATED" ) then
  2361. local namePlate = ...
  2362. OnNamePlateCreated(namePlate)
  2363. elseif ( event == "NAME_PLATE_UNIT_ADDED" ) then
  2364. local unit = ...
  2365. OnNamePlateAdded(unit)
  2366. elseif ( event == "NAME_PLATE_UNIT_REMOVED" ) then
  2367. local unit = ...
  2368. OnNamePlateRemoved(unit)
  2369. end
  2370. end
  2371.  
  2372. local NamePlatesFrame = CreateFrame("Frame", G.addon_name.."NamePlatesFrame", UIParent)
  2373. NamePlatesFrame:SetScript("OnEvent", NamePlates_OnEvent)
  2374. NamePlatesFrame:RegisterEvent("VARIABLES_LOADED")
  2375. NamePlatesFrame:RegisterEvent("NAME_PLATE_CREATED")
  2376. NamePlatesFrame:RegisterEvent("NAME_PLATE_UNIT_ADDED")
  2377. NamePlatesFrame:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
  2378.  
  2379. T.EditPlateIcons = function(tag)
  2380. if tag == "enable" or tag == "all" then
  2381. if SMT_CDB["General"]["disable_all"] or not SMT_CDB["PlateAlerts"]["enable"] then
  2382. for k, frame in pairs(G.Plate_IconHolders) do
  2383. frame:SetAlpha(0)
  2384. end
  2385. else
  2386. for k, frame in pairs(G.Plate_IconHolders) do
  2387. frame:SetAlpha(1)
  2388. end
  2389. end
  2390. end
  2391.  
  2392. if tag == "Explosive_np" or tag == "all" then
  2393. for i, namePlate in ipairs(C_NamePlate.GetNamePlates()) do
  2394. local unitFrame = namePlate.suf
  2395. UpdateBomb(unitFrame)
  2396. end
  2397. end
  2398.  
  2399. if tag == "Bolster_np" or tag == "all" then
  2400. for i, namePlate in ipairs(C_NamePlate.GetNamePlates()) do
  2401. local unitFrame = namePlate.suf
  2402. UpdateBolster(unitFrame)
  2403. end
  2404. end
  2405.  
  2406. if tag == "Sanguine_np" or tag == "all" then
  2407. for i, namePlate in ipairs(C_NamePlate.GetNamePlates()) do
  2408. local unitFrame = namePlate.suf
  2409. UpdateSanguine(unitFrame)
  2410. end
  2411. end
  2412.  
  2413. if tag == "Raging_np" or tag == "all" then
  2414. for i, namePlate in ipairs(C_NamePlate.GetNamePlates()) do
  2415. local unitFrame = namePlate.suf
  2416. UpdateRaging(unitFrame)
  2417. end
  2418. end
  2419.  
  2420. if tag == "icon_size" or tag == "all" then
  2421. for k, frame in pairs(G.Plate_IconHolders) do
  2422. for j, icon in pairs(frame.Aura_Icons) do
  2423. icon:SetSize(SMT_CDB["PlateAlerts"]["size"], SMT_CDB["PlateAlerts"]["size"])
  2424. end
  2425. for j, icon in pairs(frame.Spell_Icons) do
  2426. icon:SetSize(SMT_CDB["PlateAlerts"]["size"], SMT_CDB["PlateAlerts"]["size"])
  2427. end
  2428. if frame.powericon then
  2429. frame.powericon:SetSize(SMT_CDB["PlateAlerts"]["size"], SMT_CDB["PlateAlerts"]["size"])
  2430. end
  2431. if frame.bombicon then
  2432. frame.bombicon:SetSize(SMT_CDB["PlateAlerts"]["size"], SMT_CDB["PlateAlerts"]["size"])
  2433. end
  2434. if frame.bolstericon then
  2435. frame.bolstericon:SetSize(SMT_CDB["PlateAlerts"]["size"], SMT_CDB["PlateAlerts"]["size"])
  2436. end
  2437. if frame.sanguineicon then
  2438. frame.sanguineicon:SetSize(SMT_CDB["PlateAlerts"]["size"], SMT_CDB["PlateAlerts"]["size"])
  2439. end
  2440. if frame.ragingicon then
  2441. frame.ragingicon:SetSize(SMT_CDB["PlateAlerts"]["size"], SMT_CDB["PlateAlerts"]["size"])
  2442. end
  2443. frame.LineUpIcons()
  2444. end
  2445. end
  2446.  
  2447. if tag == "font_size" or tag == "all" then
  2448. for k, frame in pairs(G.Plate_IconHolders) do
  2449. for j, icon in pairs(frame.Aura_Icons) do
  2450. icon.text:SetFont(font, SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE")
  2451. icon.count:SetFont(font, SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE")
  2452. end
  2453. for j, icon in pairs(frame.Spell_Icons) do
  2454. icon.cast.target:SetFont(font, SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE")
  2455. icon.cast.target:SetHeight(SMT_CDB["PlateAlerts"]["fsize"]*2.5)
  2456. icon.cast.spell:SetFont(font, SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE")
  2457. icon.cast.spell:SetHeight(SMT_CDB["PlateAlerts"]["fsize"])
  2458. icon.cast.dur:SetFont(font, SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE")
  2459. end
  2460. if frame.powericon then
  2461. frame.powericon.count:SetFont(font, SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE")
  2462. end
  2463. if frame.bolstericon then
  2464. frame.bolstericon.count:SetFont(font, SMT_CDB["PlateAlerts"]["fsize"], "OUTLINE")
  2465. end
  2466. end
  2467. end
  2468.  
  2469. if tag == "y" or tag == "all" then
  2470. for k, frame in pairs(G.Plate_IconHolders) do
  2471. frame:SetPoint("BOTTOM", frame:GetParent(), "TOP", 0, SMT_CDB["PlateAlerts"]["y"])
  2472. end
  2473. end
  2474. end
  2475. ----------------------------------------------------------
  2476. ----------------[[ Chat Message ]]------------------
  2477. ----------------------------------------------------------
  2478. local ChatMsgEventFrame = CreateFrame("Frame", G.addon_name.."ChatMsgEventFrame", G.FrameHolder)
  2479.  
  2480. ChatMsgEventFrame:SetScript("OnEvent", function(self, event, ...)
  2481. if SMT_CDB["General"]["disable_all"] then return end
  2482.  
  2483. if event == "COMBAT_LOG_EVENT_UNFILTERED" then
  2484. local _, Event_type, _, _, _, _, _, _, DestName, _, _, SpellID = ...
  2485. if Event_type == "SPELL_AURA_APPLIED" and DestName == G.PlayerName then
  2486. if SMT_CDB["ChatMsgAuras"][SpellID] then
  2487. local spell_name = GetSpellInfo(SpellID)
  2488. T.SendChatMsg(G.PlayerName.." "..spell_name, "SAY")
  2489. end
  2490. end
  2491. elseif event == "RAID_BOSS_WHISPER" then
  2492. local Msg = ...
  2493. for spell, v in pairs(SMT_CDB["ChatMsgBossWhispers"]) do
  2494. if Msg and strfind(Msg, spell) then
  2495. local spell_name = GetSpellInfo(tonumber(spell))
  2496. T.SendChatMsg(G.PlayerName.." "..spell_name, "SAY")
  2497. break
  2498. end
  2499. end
  2500. end
  2501. end)
  2502.  
  2503. ChatMsgEventFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  2504. ChatMsgEventFrame:RegisterEvent("RAID_BOSS_WHISPER")
  2505. ----------------------------------------------------------
  2506. -----------------[[ Test Frame ]]-------------------
  2507. ----------------------------------------------------------
  2508. T.CreateTestIcon("123_test_hl_200768", 5, 1, 1, 1)
  2509. T.CreateTestIcon("123_test_no_200630", 7, 1, 1, 0)
  2510. T.CreateTestIcon("123_test_no_200580", 8, 1, 0, 0)
  2511.  
  2512. T.CreateTestText("Quaking", 5, 1, 1, 0)
  2513. T.CreateTestText("Explosive", 5, 0, 1, 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement