PageRenderTime 74ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 1ms

/AddOns/Blizzard_CombatLog/Blizzard_CombatLog.lua

https://bitbucket.org/Shenton/world-of-warcraft-user-interface-source
Lua | 3672 lines | 2704 code | 358 blank | 610 comment | 453 complexity | 1be40671c61a777a6441264e7422cb8f MD5 | raw file
  1. --[[
  2. -- Blizzard Combat Log
  3. -- by Alexander Yoshi
  4. --
  5. -- This is a prototype combat log designed to serve the
  6. -- majority of needs for WoW players. The new and improved
  7. -- combat log event formatting should allow for the community
  8. -- to develop even better combat logs in the future.
  9. --
  10. -- Thanks to:
  11. -- Chris Heald & Xinhuan - Code Optimization Support
  12. --
  13. --]]
  14. -- Version
  15. -- Constant -- Incrementing this number will erase saved filter settings!!
  16. COMBATLOG_FILTER_VERSION = 4.3;
  17. -- Saved Variable
  18. Blizzard_CombatLog_Filter_Version = 0;
  19. -- Define the log
  20. COMBATLOG = ChatFrame2;
  21. -- BUFF / DEBUFF
  22. AURA_TYPE_BUFF = "BUFF";
  23. AURA_TYPE_DEBUFF = "DEBUFF"
  24. -- Message Limit
  25. COMBATLOG_LIMIT_PER_FRAME = 1;
  26. COMBATLOG_HIGHLIGHT_MULTIPLIER = 1.5;
  27. -- Default Colors
  28. COMBATLOG_DEFAULT_COLORS = {
  29. -- Unit names
  30. unitColoring = {
  31. [COMBATLOG_FILTER_MINE] = {a=1.0,r=0.70,g=0.70,b=0.70}; --{a=1.0,r=0.14,g=1.00,b=0.15};
  32. [COMBATLOG_FILTER_MY_PET] = {a=1.0,r=0.70,g=0.70,b=0.70}; --{a=1.0,r=0.14,g=0.80,b=0.15};
  33. [COMBATLOG_FILTER_FRIENDLY_UNITS] = {a=1.0,r=0.34,g=0.64,b=1.00};
  34. [COMBATLOG_FILTER_HOSTILE_UNITS] = {a=1.0,r=0.75,g=0.05,b=0.05};
  35. [COMBATLOG_FILTER_HOSTILE_PLAYERS] = {a=1.0,r=0.75,g=0.05,b=0.05};
  36. [COMBATLOG_FILTER_NEUTRAL_UNITS] = {a=1.0,r=0.75,g=0.05,b=0.05}; -- {a=1.0,r=0.80,g=0.80,b=0.14};
  37. [COMBATLOG_FILTER_UNKNOWN_UNITS] = {a=1.0,r=0.75,g=0.75,b=0.75};
  38. };
  39. -- School coloring
  40. schoolColoring = {
  41. [SCHOOL_MASK_NONE] = {a=1.0,r=1.00,g=1.00,b=1.00};
  42. [SCHOOL_MASK_PHYSICAL] = {a=1.0,r=1.00,g=1.00,b=0.00};
  43. [SCHOOL_MASK_HOLY] = {a=1.0,r=1.00,g=0.90,b=0.50};
  44. [SCHOOL_MASK_FIRE] = {a=1.0,r=1.00,g=0.50,b=0.00};
  45. [SCHOOL_MASK_NATURE] = {a=1.0,r=0.30,g=1.00,b=0.30};
  46. [SCHOOL_MASK_FROST] = {a=1.0,r=0.50,g=1.00,b=1.00};
  47. [SCHOOL_MASK_SHADOW] = {a=1.0,r=0.50,g=0.50,b=1.00};
  48. [SCHOOL_MASK_ARCANE] = {a=1.0,r=1.00,g=0.50,b=1.00};
  49. };
  50. -- Defaults
  51. defaults = {
  52. spell = {a=1.0,r=1.00,g=1.00,b=1.00};
  53. damage = {a=1.0,r=1.00,g=1.00,b=0.00};
  54. };
  55. -- Line coloring
  56. eventColoring = {
  57. };
  58. -- Highlighted events
  59. highlightedEvents = {
  60. ["PARTY_KILL"] = true;
  61. };
  62. };
  63. COMBATLOG_DEFAULT_SETTINGS = {
  64. -- Settings
  65. fullText = false;
  66. textMode = TEXT_MODE_A;
  67. timestamp = false;
  68. timestampFormat = TEXT_MODE_A_TIMESTAMP;
  69. unitColoring = false;
  70. sourceColoring = true;
  71. destColoring = true;
  72. lineColoring = true;
  73. lineHighlighting = true;
  74. abilityColoring = false;
  75. abilityActorColoring = false;
  76. abilitySchoolColoring = false;
  77. abilityHighlighting = true;
  78. actionColoring = false;
  79. actionActorColoring = false;
  80. actionHighlighting = false;
  81. amountColoring = false;
  82. amountActorColoring = false;
  83. amountSchoolColoring = false;
  84. amountHighlighting = true;
  85. schoolNameColoring = false;
  86. schoolNameActorColoring = false;
  87. schoolNameHighlighting = true;
  88. noMeleeSwingColoring = false;
  89. missColoring = true;
  90. braces = false;
  91. unitBraces = true;
  92. sourceBraces = true;
  93. destBraces = true;
  94. spellBraces = false;
  95. itemBraces = true;
  96. showHistory = true;
  97. lineColorPriority = 1; -- 1 = source->dest->event, 2 = dest->source->event, 3 = event->source->dest
  98. unitIcons = true;
  99. hideBuffs = true;
  100. hideDebuffs = true;
  101. --unitTokens = true;
  102. };
  103. --
  104. -- Combat Log Icons
  105. --
  106. COMBATLOG_ICON_RAIDTARGET1 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_1.blp:0|t";
  107. COMBATLOG_ICON_RAIDTARGET2 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_2.blp:0|t";
  108. COMBATLOG_ICON_RAIDTARGET3 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_3.blp:0|t";
  109. COMBATLOG_ICON_RAIDTARGET4 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_4.blp:0|t";
  110. COMBATLOG_ICON_RAIDTARGET5 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_5.blp:0|t";
  111. COMBATLOG_ICON_RAIDTARGET6 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_6.blp:0|t";
  112. COMBATLOG_ICON_RAIDTARGET7 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_7.blp:0|t";
  113. COMBATLOG_ICON_RAIDTARGET8 = "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_8.blp:0|t";
  114. --
  115. -- Default Event List
  116. --
  117. COMBATLOG_EVENT_LIST = {
  118. ["ENVIRONMENTAL_DAMAGE"] = true,
  119. ["SWING_DAMAGE"] = true,
  120. ["SWING_MISSED"] = true,
  121. ["RANGE_DAMAGE"] = true,
  122. ["RANGE_MISSED"] = true,
  123. ["SPELL_CAST_START"] = false,
  124. ["SPELL_CAST_SUCCESS"] = false,
  125. ["SPELL_CAST_FAILED"] = false,
  126. ["SPELL_MISSED"] = true,
  127. ["SPELL_DAMAGE"] = true,
  128. ["SPELL_HEAL"] = true,
  129. ["SPELL_ENERGIZE"] = true,
  130. ["SPELL_DRAIN"] = true,
  131. ["SPELL_LEECH"] = true,
  132. ["SPELL_SUMMON"] = true,
  133. ["SPELL_RESURRECT"] = true,
  134. ["SPELL_CREATE"] = true,
  135. ["SPELL_INSTAKILL"] = true,
  136. ["SPELL_INTERRUPT"] = true,
  137. ["SPELL_EXTRA_ATTACKS"] = true,
  138. ["SPELL_DURABILITY_DAMAGE"] = false,
  139. ["SPELL_DURABILITY_DAMAGE_ALL"] = false,
  140. ["SPELL_AURA_APPLIED"] = false,
  141. ["SPELL_AURA_APPLIED_DOSE"] = false,
  142. ["SPELL_AURA_REMOVED"] = false,
  143. ["SPELL_AURA_REMOVED_DOSE"] = false,
  144. ["SPELL_AURA_BROKEN"] = false,
  145. ["SPELL_AURA_BROKEN_SPELL"] = false,
  146. ["SPELL_AURA_REFRESH"] = false,
  147. ["SPELL_DISPEL"] = true,
  148. ["SPELL_STOLEN"] = true,
  149. ["ENCHANT_APPLIED"] = true,
  150. ["ENCHANT_REMOVED"] = true,
  151. ["SPELL_PERIODIC_MISSED"] = true,
  152. ["SPELL_PERIODIC_DAMAGE"] = true,
  153. ["SPELL_PERIODIC_HEAL"] = true,
  154. ["SPELL_PERIODIC_ENERGIZE"] = true,
  155. ["SPELL_PERIODIC_DRAIN"] = true,
  156. ["SPELL_PERIODIC_LEECH"] = true,
  157. ["SPELL_DISPEL_FAILED"] = true,
  158. ["DAMAGE_SHIELD"] = false,
  159. ["DAMAGE_SHIELD_MISSED"] = false,
  160. ["DAMAGE_SPLIT"] = false,
  161. ["PARTY_KILL"] = true,
  162. ["UNIT_DIED"] = true,
  163. ["UNIT_DESTROYED"] = true,
  164. ["SPELL_BUILDING_DAMAGE"] = true,
  165. ["SPELL_BUILDING_HEAL"] = true,
  166. ["UNIT_DISSIPATES"] = true,
  167. };
  168. COMBATLOG_FLAG_LIST = {
  169. [COMBATLOG_FILTER_MINE] = true,
  170. [COMBATLOG_FILTER_MY_PET] = true,
  171. [COMBATLOG_FILTER_FRIENDLY_UNITS] = true,
  172. [COMBATLOG_FILTER_HOSTILE_UNITS] = true,
  173. [COMBATLOG_FILTER_HOSTILE_PLAYERS] = true,
  174. [COMBATLOG_FILTER_NEUTRAL_UNITS] = true,
  175. [COMBATLOG_FILTER_UNKNOWN_UNITS] = true,
  176. };
  177. EVENT_TEMPLATE_FORMATS = {
  178. ["SPELL_AURA_BROKEN_SPELL"] = TEXT_MODE_A_STRING_3,
  179. ["SPELL_CAST_START"] = TEXT_MODE_A_STRING_2,
  180. ["SPELL_CAST_SUCCESS"] = TEXT_MODE_A_STRING_2
  181. };
  182. --
  183. -- Creates an empty filter
  184. --
  185. function Blizzard_CombatLog_InitializeFilters( settings )
  186. settings.filters =
  187. {
  188. [1] = {
  189. eventList = {};
  190. };
  191. };
  192. end
  193. --
  194. -- Generates a new event list from the COMBATLOG_EVENT_LIST global
  195. --
  196. -- I wish there was a better way built in to do this.
  197. --
  198. -- Returns:
  199. -- An array, indexed by the events, with a value of true
  200. --
  201. function Blizzard_CombatLog_GenerateFullEventList ( )
  202. local eventList = {}
  203. for event, v in pairs ( COMBATLOG_EVENT_LIST ) do
  204. eventList[event] = true;
  205. end
  206. return eventList;
  207. end
  208. function Blizzard_CombatLog_GenerateFullFlagList(flag)
  209. local flagList = {};
  210. for k, v in pairs(COMBATLOG_FLAG_LIST) do
  211. if ( flag ) then
  212. flagList[k] = true
  213. else
  214. flagList[k] = false;
  215. end
  216. end
  217. return flagList;
  218. end
  219. --
  220. -- Default CombatLog Filter
  221. -- This table is used to create new CombatLog filters
  222. --
  223. DEFAULT_COMBATLOG_FILTER_TEMPLATE = {
  224. -- Descriptive Information
  225. hasQuickButton = true;
  226. quickButtonDisplay = {
  227. solo = true;
  228. party = true;
  229. raid = true;
  230. };
  231. -- Default Color and Formatting Options
  232. settings = CopyTable(COMBATLOG_DEFAULT_SETTINGS);
  233. -- Coloring
  234. colors = CopyTable(COMBATLOG_DEFAULT_COLORS);
  235. -- The actual client filters
  236. filters = {
  237. [1] = {
  238. eventList = Blizzard_CombatLog_GenerateFullEventList();
  239. sourceFlags = {
  240. [COMBATLOG_FILTER_MINE] = true,
  241. [COMBATLOG_FILTER_MY_PET] = true;
  242. };
  243. destFlags = nil;
  244. };
  245. [2] = {
  246. eventList = Blizzard_CombatLog_GenerateFullEventList();
  247. sourceFlags = nil;
  248. destFlags = {
  249. [COMBATLOG_FILTER_MINE] = true,
  250. [COMBATLOG_FILTER_MY_PET] = true;
  251. };
  252. };
  253. };
  254. };
  255. local CombatLogUpdateFrame = CreateFrame("Frame", "CombatLogUpdateFrame", UIParent)
  256. local _G = getfenv(0)
  257. local bit_bor = _G.bit.bor
  258. local bit_band = _G.bit.band
  259. local tinsert = _G.tinsert
  260. local tremove = _G.tremove
  261. local math_floor = _G.math.floor
  262. local format = _G.format
  263. local gsub = _G.gsub
  264. local strsub = _G.strsub
  265. -- Make all the constants upvalues. This prevents the global environment lookup + table lookup each time we use one (and they're used a lot)
  266. local COMBATLOG_OBJECT_AFFILIATION_MINE = COMBATLOG_OBJECT_AFFILIATION_MINE
  267. local COMBATLOG_OBJECT_AFFILIATION_PARTY = COMBATLOG_OBJECT_AFFILIATION_PARTY
  268. local COMBATLOG_OBJECT_AFFILIATION_RAID = COMBATLOG_OBJECT_AFFILIATION_RAID
  269. local COMBATLOG_OBJECT_AFFILIATION_OUTSIDER = COMBATLOG_OBJECT_AFFILIATION_OUTSIDER
  270. local COMBATLOG_OBJECT_AFFILIATION_MASK = COMBATLOG_OBJECT_AFFILIATION_MASK
  271. local COMBATLOG_OBJECT_REACTION_FRIENDLY = COMBATLOG_OBJECT_REACTION_FRIENDLY
  272. local COMBATLOG_OBJECT_REACTION_NEUTRAL = COMBATLOG_OBJECT_REACTION_NEUTRAL
  273. local COMBATLOG_OBJECT_REACTION_HOSTILE = COMBATLOG_OBJECT_REACTION_HOSTILE
  274. local COMBATLOG_OBJECT_REACTION_MASK = COMBATLOG_OBJECT_REACTION_MASK
  275. local COMBATLOG_OBJECT_CONTROL_PLAYER = COMBATLOG_OBJECT_CONTROL_PLAYER
  276. local COMBATLOG_OBJECT_CONTROL_NPC = COMBATLOG_OBJECT_CONTROL_NPC
  277. local COMBATLOG_OBJECT_CONTROL_MASK = COMBATLOG_OBJECT_CONTROL_MASK
  278. local COMBATLOG_OBJECT_TYPE_PLAYER = COMBATLOG_OBJECT_TYPE_PLAYER
  279. local COMBATLOG_OBJECT_TYPE_NPC = COMBATLOG_OBJECT_TYPE_NPC
  280. local COMBATLOG_OBJECT_TYPE_PET = COMBATLOG_OBJECT_TYPE_PET
  281. local COMBATLOG_OBJECT_TYPE_GUARDIAN = COMBATLOG_OBJECT_TYPE_GUARDIAN
  282. local COMBATLOG_OBJECT_TYPE_OBJECT = COMBATLOG_OBJECT_TYPE_OBJECT
  283. local COMBATLOG_OBJECT_TYPE_MASK = COMBATLOG_OBJECT_TYPE_MASK
  284. local COMBATLOG_OBJECT_TARGET = COMBATLOG_OBJECT_TARGET
  285. local COMBATLOG_OBJECT_FOCUS = COMBATLOG_OBJECT_FOCUS
  286. local COMBATLOG_OBJECT_MAINTANK = COMBATLOG_OBJECT_MAINTANK
  287. local COMBATLOG_OBJECT_MAINASSIST = COMBATLOG_OBJECT_MAINASSIST
  288. local COMBATLOG_OBJECT_RAIDTARGET1 = COMBATLOG_OBJECT_RAIDTARGET1
  289. local COMBATLOG_OBJECT_RAIDTARGET2 = COMBATLOG_OBJECT_RAIDTARGET2
  290. local COMBATLOG_OBJECT_RAIDTARGET3 = COMBATLOG_OBJECT_RAIDTARGET3
  291. local COMBATLOG_OBJECT_RAIDTARGET4 = COMBATLOG_OBJECT_RAIDTARGET4
  292. local COMBATLOG_OBJECT_RAIDTARGET5 = COMBATLOG_OBJECT_RAIDTARGET5
  293. local COMBATLOG_OBJECT_RAIDTARGET6 = COMBATLOG_OBJECT_RAIDTARGET6
  294. local COMBATLOG_OBJECT_RAIDTARGET7 = COMBATLOG_OBJECT_RAIDTARGET7
  295. local COMBATLOG_OBJECT_RAIDTARGET8 = COMBATLOG_OBJECT_RAIDTARGET8
  296. local COMBATLOG_OBJECT_NONE = COMBATLOG_OBJECT_NONE
  297. local COMBATLOG_OBJECT_SPECIAL_MASK = COMBATLOG_OBJECT_SPECIAL_MASK
  298. local COMBATLOG_FILTER_ME = COMBATLOG_FILTER_ME
  299. local COMBATLOG_FILTER_MINE = COMBATLOG_FILTER_MINE
  300. local COMBATLOG_FILTER_MY_PET = COMBATLOG_FILTER_MY_PET
  301. local COMBATLOG_FILTER_FRIENDLY_UNITS = COMBATLOG_FILTER_FRIENDLY_UNITS
  302. local COMBATLOG_FILTER_HOSTILE_UNITS = COMBATLOG_FILTER_HOSTILE_UNITS
  303. local COMBATLOG_FILTER_HOSTILE_PLAYERS = COMBATLOG_FILTER_HOSTILE_PLAYERS
  304. local COMBATLOG_FILTER_NEUTRAL_UNITS = COMBATLOG_FILTER_NEUTRAL_UNITS
  305. local COMBATLOG_FILTER_UNKNOWN_UNITS = COMBATLOG_FILTER_UNKNOWN_UNITS
  306. local COMBATLOG_FILTER_EVERYTHING = COMBATLOG_FILTER_EVERYTHING
  307. local COMBATLOG = COMBATLOG
  308. local AURA_TYPE_BUFF = AURA_TYPE_BUFF
  309. local AURA_TYPE_DEBUFF = AURA_TYPE_DEBUFF
  310. local SPELL_POWER_MANA = SPELL_POWER_MANA
  311. local SPELL_POWER_RAGE = SPELL_POWER_RAGE
  312. local SPELL_POWER_FOCUS = SPELL_POWER_FOCUS
  313. local SPELL_POWER_ENERGY = SPELL_POWER_ENERGY
  314. local SPELL_POWER_RUNES = SPELL_POWER_RUNES
  315. local SPELL_POWER_RUNIC_POWER = SPELL_POWER_RUNIC_POWER
  316. local SPELL_POWER_SOUL_SHARDS = SPELL_POWER_SOUL_SHARDS;
  317. local SPELL_POWER_ECLIPSE = SPELL_POWER_ECLIPSE;
  318. local SPELL_POWER_HOLY_POWER = SPELL_POWER_HOLY_POWER;
  319. local SPELL_POWER_ALTERNATE_POWER = SPELL_POWER_ALTERNATE_POWER;
  320. local SPELL_POWER_BURNING_EMBERS = SPELL_POWER_BURNING_EMBERS;
  321. local SCHOOL_MASK_NONE = SCHOOL_MASK_NONE
  322. local SCHOOL_MASK_PHYSICAL = SCHOOL_MASK_PHYSICAL
  323. local SCHOOL_MASK_HOLY = SCHOOL_MASK_HOLY
  324. local SCHOOL_MASK_FIRE = SCHOOL_MASK_FIRE
  325. local SCHOOL_MASK_NATURE = SCHOOL_MASK_NATURE
  326. local SCHOOL_MASK_FROST = SCHOOL_MASK_FROST
  327. local SCHOOL_MASK_SHADOW = SCHOOL_MASK_SHADOW
  328. local SCHOOL_MASK_ARCANE = SCHOOL_MASK_ARCANE
  329. local COMBATLOG_LIMIT_PER_FRAME = COMBATLOG_LIMIT_PER_FRAME
  330. local COMBATLOG_HIGHLIGHT_MULTIPLIER = COMBATLOG_HIGHLIGHT_MULTIPLIER
  331. local COMBATLOG_DEFAULT_COLORS = COMBATLOG_DEFAULT_COLORS
  332. local COMBATLOG_DEFAULT_SETTINGS = COMBATLOG_DEFAULT_SETTINGS
  333. local COMBATLOG_ICON_RAIDTARGET1 = COMBATLOG_ICON_RAIDTARGET1
  334. local COMBATLOG_ICON_RAIDTARGET2 = COMBATLOG_ICON_RAIDTARGET2
  335. local COMBATLOG_ICON_RAIDTARGET3 = COMBATLOG_ICON_RAIDTARGET3
  336. local COMBATLOG_ICON_RAIDTARGET4 = COMBATLOG_ICON_RAIDTARGET4
  337. local COMBATLOG_ICON_RAIDTARGET5 = COMBATLOG_ICON_RAIDTARGET5
  338. local COMBATLOG_ICON_RAIDTARGET6 = COMBATLOG_ICON_RAIDTARGET6
  339. local COMBATLOG_ICON_RAIDTARGET7 = COMBATLOG_ICON_RAIDTARGET7
  340. local COMBATLOG_ICON_RAIDTARGET8 = COMBATLOG_ICON_RAIDTARGET8
  341. local COMBATLOG_EVENT_LIST = COMBATLOG_EVENT_LIST
  342. local CombatLog_OnEvent -- for later
  343. local CombatLog_Object_IsA = CombatLog_Object_IsA
  344. -- Create a dummy CombatLogQuickButtonFrame for line 803 of FloatingChatFrame.lua. It causes inappropriate show/hide behavior. Instead, we'll use our own frame display handling.
  345. -- If there are more than 2 combat log frames, then the CombatLogQuickButtonFrame gets tied to the last frame tab's visibility status. Yuck! Let's just instead tie it to the combat log's tab.
  346. local CombatLogQuickButtonFrame, CombatLogQuickButtonFrameProgressBar, CombatLogQuickButtonFrameTexture
  347. _G.CombatLogQuickButtonFrame = CreateFrame("Frame", "CombatLogQuickButtonFrame", UIParent)
  348. local Blizzard_CombatLog_Update_QuickButtons
  349. local Blizzard_CombatLog_PreviousSettings
  350. --
  351. -- Persistant Variables
  352. --
  353. --
  354. -- Default Filters
  355. --
  356. Blizzard_CombatLog_Filter_Defaults = {
  357. -- All of the filters
  358. filters = {
  359. [1] = {
  360. -- Descriptive Information
  361. name = QUICKBUTTON_NAME_MY_ACTIONS;
  362. hasQuickButton = true;
  363. quickButtonName = QUICKBUTTON_NAME_MY_ACTIONS;
  364. quickButtonDisplay = {
  365. solo = true;
  366. party = true;
  367. raid = true;
  368. };
  369. tooltip = QUICKBUTTON_NAME_MY_ACTIONS_TOOLTIP;
  370. -- Default Color and Formatting Options
  371. settings = CopyTable(COMBATLOG_DEFAULT_SETTINGS);
  372. -- Coloring
  373. colors = CopyTable(COMBATLOG_DEFAULT_COLORS);
  374. -- The actual client filters
  375. filters = {
  376. [1] = {
  377. eventList = {
  378. ["ENVIRONMENTAL_DAMAGE"] = false,
  379. ["SWING_DAMAGE"] = true,
  380. ["SWING_MISSED"] = false,
  381. ["RANGE_DAMAGE"] = true,
  382. ["RANGE_MISSED"] = false,
  383. --["SPELL_CAST_START"] = true,
  384. --["SPELL_CAST_SUCCESS"] = true,
  385. --["SPELL_CAST_FAILED"] = true,
  386. ["SPELL_MISSED"] = false,
  387. ["SPELL_DAMAGE"] = true,
  388. ["SPELL_HEAL"] = true,
  389. ["SPELL_ENERGIZE"] = false,
  390. ["SPELL_DRAIN"] = false,
  391. ["SPELL_LEECH"] = false,
  392. ["SPELL_INSTAKILL"] = false,
  393. ["SPELL_INTERRUPT"] = false,
  394. ["SPELL_EXTRA_ATTACKS"] = false,
  395. --["SPELL_DURABILITY_DAMAGE"] = true,
  396. --["SPELL_DURABILITY_DAMAGE_ALL"] = true,
  397. ["SPELL_AURA_APPLIED"] = false,
  398. ["SPELL_AURA_APPLIED_DOSE"] = false,
  399. ["SPELL_AURA_REMOVED"] = false,
  400. ["SPELL_AURA_REMOVED_DOSE"] = false,
  401. ["SPELL_AURA_BROKEN"] = false,
  402. ["SPELL_AURA_BROKEN_SPELL"] = false,
  403. ["SPELL_AURA_REFRESH"] = false,
  404. ["SPELL_DISPEL"] = false,
  405. ["SPELL_STOLEN"] = false,
  406. ["ENCHANT_APPLIED"] = false,
  407. ["ENCHANT_REMOVED"] = false,
  408. ["SPELL_PERIODIC_MISSED"] = false,
  409. ["SPELL_PERIODIC_DAMAGE"] = true,
  410. ["SPELL_PERIODIC_HEAL"] = true,
  411. ["SPELL_PERIODIC_ENERGIZE"] = false,
  412. ["SPELL_PERIODIC_DRAIN"] = false,
  413. ["SPELL_PERIODIC_LEECH"] = false,
  414. ["SPELL_DISPEL_FAILED"] = false,
  415. --["DAMAGE_SHIELD"] = true,
  416. --["DAMAGE_SHIELD_MISSED"] = true,
  417. ["DAMAGE_SPLIT"] = true,
  418. ["PARTY_KILL"] = true,
  419. ["UNIT_DIED"] = false,
  420. ["UNIT_DESTROYED"] = true,
  421. ["UNIT_DISSIPATES"] = true
  422. };
  423. sourceFlags = {
  424. [COMBATLOG_FILTER_MINE] = true
  425. };
  426. destFlags = nil;
  427. };
  428. [2] = {
  429. eventList = {
  430. --["ENVIRONMENTAL_DAMAGE"] = true,
  431. ["SWING_DAMAGE"] = true,
  432. ["SWING_MISSED"] = true,
  433. ["RANGE_DAMAGE"] = true,
  434. ["RANGE_MISSED"] = true,
  435. --["SPELL_CAST_START"] = true,
  436. --["SPELL_CAST_SUCCESS"] = true,
  437. --["SPELL_CAST_FAILED"] = true,
  438. ["SPELL_MISSED"] = true,
  439. ["SPELL_DAMAGE"] = true,
  440. ["SPELL_HEAL"] = true,
  441. ["SPELL_ENERGIZE"] = true,
  442. ["SPELL_DRAIN"] = true,
  443. ["SPELL_LEECH"] = true,
  444. ["SPELL_INSTAKILL"] = true,
  445. ["SPELL_INTERRUPT"] = true,
  446. ["SPELL_EXTRA_ATTACKS"] = true,
  447. --["SPELL_DURABILITY_DAMAGE"] = true,
  448. --["SPELL_DURABILITY_DAMAGE_ALL"] = true,
  449. --["SPELL_AURA_APPLIED"] = true,
  450. --["SPELL_AURA_APPLIED_DOSE"] = true,
  451. --["SPELL_AURA_REMOVED"] = true,
  452. --["SPELL_AURA_REMOVED_DOSE"] = true,
  453. ["SPELL_DISPEL"] = true,
  454. ["SPELL_STOLEN"] = true,
  455. ["ENCHANT_APPLIED"] = true,
  456. ["ENCHANT_REMOVED"] = true,
  457. --["SPELL_PERIODIC_MISSED"] = true,
  458. --["SPELL_PERIODIC_DAMAGE"] = true,
  459. --["SPELL_PERIODIC_HEAL"] = true,
  460. --["SPELL_PERIODIC_ENERGIZE"] = true,
  461. --["SPELL_PERIODIC_DRAIN"] = true,
  462. --["SPELL_PERIODIC_LEECH"] = true,
  463. ["SPELL_DISPEL_FAILED"] = true,
  464. --["DAMAGE_SHIELD"] = true,
  465. --["DAMAGE_SHIELD_MISSED"] = true,
  466. ["DAMAGE_SPLIT"] = true,
  467. ["PARTY_KILL"] = true,
  468. ["UNIT_DIED"] = true,
  469. ["UNIT_DESTROYED"] = true,
  470. ["UNIT_DISSIPATES"] = true
  471. };
  472. sourceFlags = nil;
  473. destFlags = {
  474. [COMBATLOG_FILTER_MINE] = false,
  475. [COMBATLOG_FILTER_MY_PET] = false;
  476. };
  477. };
  478. };
  479. };
  480. [2] = {
  481. -- Descriptive Information
  482. name = QUICKBUTTON_NAME_ME;
  483. hasQuickButton = true;
  484. quickButtonName = QUICKBUTTON_NAME_ME;
  485. quickButtonDisplay = {
  486. solo = true;
  487. party = true;
  488. raid = true;
  489. };
  490. tooltip = QUICKBUTTON_NAME_ME_TOOLTIP;
  491. -- Settings
  492. settings = CopyTable(COMBATLOG_DEFAULT_SETTINGS);
  493. -- Coloring
  494. colors = CopyTable(COMBATLOG_DEFAULT_COLORS);
  495. -- The actual client filters
  496. filters = {
  497. [1] = {
  498. eventList = {
  499. ["ENVIRONMENTAL_DAMAGE"] = true,
  500. ["SWING_DAMAGE"] = true,
  501. ["RANGE_DAMAGE"] = true,
  502. ["SPELL_DAMAGE"] = true,
  503. ["SPELL_HEAL"] = true,
  504. ["SPELL_PERIODIC_DAMAGE"] = true,
  505. ["SPELL_PERIODIC_HEAL"] = true,
  506. ["DAMAGE_SPLIT"] = true,
  507. ["UNIT_DIED"] = true,
  508. ["UNIT_DESTROYED"] = true,
  509. ["UNIT_DISSIPATES"] = true
  510. };
  511. sourceFlags = Blizzard_CombatLog_GenerateFullFlagList(false);
  512. destFlags = nil;
  513. };
  514. [2] = {
  515. eventList = Blizzard_CombatLog_GenerateFullEventList();
  516. sourceFlags = nil;
  517. destFlags = {
  518. [COMBATLOG_FILTER_MINE] = true,
  519. [COMBATLOG_FILTER_MY_PET] = false;
  520. };
  521. };
  522. };
  523. };
  524. };
  525. -- Current Filter
  526. currentFilter = 1;
  527. };
  528. Blizzard_CombatLog_Filters = Blizzard_CombatLog_Filter_Defaults;
  529. -- Combat Log Filter Resetting Code
  530. --
  531. -- args:
  532. -- config - the configuration array we are about to apply
  533. --
  534. function Blizzard_CombatLog_ApplyFilters(config)
  535. if ( not config ) then
  536. return;
  537. end
  538. CombatLogResetFilter()
  539. -- Loop over all associated filters
  540. local eventList;
  541. for k,v in pairs(config.filters) do
  542. local eList
  543. -- Only use the first filter's eventList because for some reason each filter that the player can see actually
  544. -- has two filters, one for source flags and one for dest flags (??), even though only the eventList for the source
  545. -- flags is updated properly
  546. eventList = config.filters[1].eventList;
  547. if ( eventList ) then
  548. for k2,v2 in pairs(eventList) do
  549. if ( v2 == true ) then
  550. -- The true comparison is because check boxes whose parent is unchecked will be non-false but not "true"
  551. eList = eList and (eList .. "," .. k2) or k2
  552. end
  553. end
  554. end
  555. local sourceFlags, destFlags;
  556. if ( v.sourceFlags ) then
  557. sourceFlags = 0;
  558. for k2, v2 in pairs(v.sourceFlags) do
  559. -- Support for GUIDs
  560. if ( type (k2) == "string" ) then
  561. sourceFlags = k2;
  562. break;
  563. end
  564. -- Otherwise OR bits
  565. if ( v2 ) then
  566. sourceFlags = bit_bor(sourceFlags, k2);
  567. end
  568. end
  569. end
  570. if ( v.destFlags ) then
  571. destFlags = 0;
  572. for k2, v2 in pairs(v.destFlags) do
  573. -- Support for GUIDs
  574. if ( type (k2) == "string" ) then
  575. destFlags = k2;
  576. break;
  577. end
  578. -- Otherwise OR bits
  579. if ( v2 ) then
  580. destFlags = bit_bor(destFlags, k2);
  581. end
  582. end
  583. end
  584. if ( type(sourceFlags) == "string" and destFlags == 0 ) then
  585. destFlags = nil;
  586. end
  587. if ( type(destFlags) == "string" and sourceFlags == 0 ) then
  588. sourceFlags = nil;
  589. end
  590. -- This is a HACK!!! Need filters to be able to accept empty or zero sourceFlags or destFlags
  591. if ( sourceFlags == 0 or destFlags == 0 ) then
  592. CombatLogAddFilter("", COMBATLOG_FILTER_MINE, nil);
  593. else
  594. CombatLogAddFilter(eList, sourceFlags, destFlags);
  595. end
  596. end
  597. end
  598. --
  599. -- Combat Log Repopulation Code
  600. --
  601. -- Message Limit
  602. COMBATLOG_MESSAGE_LIMIT = 300;
  603. --
  604. -- Repopulate the combat log with message history
  605. --
  606. function Blizzard_CombatLog_Refilter()
  607. local count = CombatLogGetNumEntries();
  608. COMBATLOG:SetMaxLines(COMBATLOG_MESSAGE_LIMIT);
  609. -- count should be between 1 and COMBATLOG_MESSAGE_LIMIT
  610. count = max(1, min(count, COMBATLOG_MESSAGE_LIMIT));
  611. CombatLogSetCurrentEntry(0);
  612. -- Clear the combat log
  613. COMBATLOG:Clear();
  614. -- Moved setting the max value here, since we don't really need to reset the max every frame, do we?
  615. -- We can't add events while refiltering (:AddFilter short circuits) so this should be safe optimization.
  616. CombatLogQuickButtonFrameProgressBar:SetMinMaxValues(0, count);
  617. CombatLogQuickButtonFrameProgressBar:SetValue(0);
  618. CombatLogQuickButtonFrameProgressBar:Show();
  619. -- Enable the distributed frame
  620. CombatLogUpdateFrame.refiltering = true;
  621. CombatLogUpdateFrame:SetScript("OnUpdate", Blizzard_CombatLog_RefilterUpdate)
  622. Blizzard_CombatLog_RefilterUpdate()
  623. end
  624. --
  625. -- This is a single frame "step" in the refiltering process
  626. --
  627. function Blizzard_CombatLog_RefilterUpdate()
  628. local valid = CombatLogGetCurrentEntry(); -- CombatLogAdvanceEntry(0);
  629. -- Clear the combat log
  630. local total = 0;
  631. while (valid and total < COMBATLOG_LIMIT_PER_FRAME) do
  632. -- Log to the window
  633. local text, r, g, b, a = CombatLog_OnEvent(Blizzard_CombatLog_CurrentSettings, CombatLogGetCurrentEntry());
  634. -- NOTE: be sure to pass in nil for the color id or the color id may override the r, g, b values for this message
  635. if ( text ) then
  636. COMBATLOG:AddMessage( text, r, g, b, nil, true );
  637. end
  638. -- count can be
  639. -- positive to advance from oldest to newest
  640. -- negative to advance from newest to oldest
  641. valid = CombatLogAdvanceEntry(-1)
  642. total = total + 1;
  643. end
  644. -- Show filtering progress bar
  645. CombatLogQuickButtonFrameProgressBar:SetValue(CombatLogQuickButtonFrameProgressBar:GetValue() + total);
  646. if ( not valid or (CombatLogQuickButtonFrameProgressBar:GetValue() >= COMBATLOG_MESSAGE_LIMIT) ) then
  647. CombatLogUpdateFrame.refiltering = false
  648. CombatLogUpdateFrame:SetScript("OnUpdate", nil)
  649. CombatLogQuickButtonFrameProgressBar:Hide();
  650. end
  651. end
  652. --
  653. -- Checks for an event over all filters
  654. --
  655. function Blizzard_CombatLog_HasEvent ( settings, ... )
  656. -- If this actually happens, we have data corruption issues.
  657. if ( not settings.filters ) then
  658. settings.filters = {}
  659. end
  660. for _, filter in pairs (settings.filters) do
  661. if ( filter.eventList ) then
  662. for i = 1, select("#", ...) do
  663. local event = select(i, ...)
  664. if ( filter.eventList[event] == true ) then
  665. return true
  666. end
  667. end
  668. end
  669. end
  670. end
  671. --
  672. -- Checks for an event over all filters
  673. --
  674. function Blizzard_CombatLog_EnableEvent ( settings, ... )
  675. -- If this actually happens, we have data corruption issues.
  676. if ( not settings.filters ) then
  677. settings.filters = Blizzard_CombatLog_InitializeFilters( settings );
  678. end
  679. for _, filter in pairs (settings.filters) do
  680. if ( not filter.eventList ) then
  681. filter.eventList = {};
  682. end
  683. for i = 1, select("#", ...) do
  684. filter.eventList[select(i, ...)] = true;
  685. end
  686. end
  687. end
  688. --
  689. -- Checks for an event over all filters
  690. --
  691. function Blizzard_CombatLog_DisableEvent ( settings, ... )
  692. -- If this actually happens, we have data corruption issues.
  693. if ( not settings.filters ) then
  694. settings.filters = {}
  695. end
  696. for _, filter in pairs (settings.filters) do
  697. if ( filter.eventList ) then
  698. for i = 1, select("#", ...) do
  699. filter.eventList[select(i, ...)] = false;
  700. end
  701. end
  702. end
  703. end
  704. --
  705. -- Creates the action menu popup
  706. --
  707. do
  708. local eventType
  709. local actionMenu = {
  710. [1] = {
  711. text = "string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_HIDE, eventType)",
  712. func = function () Blizzard_CombatLog_SpellMenuClick ("HIDE", nil, nil, eventType); end;
  713. },
  714. };
  715. function Blizzard_CombatLog_CreateActionMenu(eventType_arg)
  716. -- Update upvalues
  717. eventType = eventType_arg
  718. actionMenu[1].text = string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_HIDE, eventType_arg);
  719. return actionMenu
  720. end
  721. end
  722. --
  723. -- Creates the spell menu popup
  724. --
  725. do
  726. local spellName, spellId, eventType
  727. local spellMenu = {
  728. [1] = {
  729. text = "string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_LINK, spellName)",
  730. func = function () Blizzard_CombatLog_SpellMenuClick ("LINK", spellName, spellId, eventType); end;
  731. },
  732. };
  733. local spellMenu2 = {
  734. [2] = {
  735. text = "string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_HIDE, eventType)",
  736. func = function () Blizzard_CombatLog_SpellMenuClick ("HIDE", spellName, spellId, eventType); end;
  737. },
  738. [3] = {
  739. text = "------------------";
  740. disabled = true;
  741. },
  742. };
  743. function Blizzard_CombatLog_CreateSpellMenu(spellName_arg, spellId_arg, eventType_arg)
  744. -- Update upvalues
  745. spellName, spellId, eventType = spellName_arg, spellId_arg, eventType_arg;
  746. -- Update menu text and filters
  747. spellMenu[1].text = string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_LINK, spellName);
  748. if ( eventType ) then
  749. spellMenu2[2].text = string.format(BLIZZARD_COMBAT_LOG_MENU_SPELL_HIDE, eventType);
  750. -- Copy the table references over
  751. spellMenu[2] = spellMenu2[2];
  752. if ( DEBUG ) then
  753. spellMenu[3] = spellMenu2[3];
  754. -- These 2 calls update the menus in their respective do-end blocks
  755. spellMenu[4] = Blizzard_CombatLog_FormattingMenu(Blizzard_CombatLog_Filters.currentFilter);
  756. spellMenu[5] = Blizzard_CombatLog_MessageTypesMenu(Blizzard_CombatLog_Filters.currentFilter);
  757. end
  758. else
  759. -- Remove the table references, they are still stored in their various closures
  760. spellMenu[2] = nil;
  761. spellMenu[3] = nil;
  762. spellMenu[4] = nil;
  763. spellMenu[5] = nil;
  764. end
  765. return spellMenu;
  766. end
  767. end
  768. --
  769. -- Temporary Menu
  770. --
  771. do
  772. -- This big table currently only has one upvalue: Blizzard_CombatLog_CurrentSettings
  773. local messageTypesMenu = {
  774. text = "Message Types";
  775. hasArrow = true;
  776. menuList = {
  777. [1] = {
  778. text = "Melee";
  779. hasArrow = true;
  780. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SWING_DAMAGE", "SWING_MISSED"); end;
  781. keepShownOnClick = true;
  782. func = function ( self, arg1, arg2, checked )
  783. Blizzard_CombatLog_MenuHelper ( checked, "SWING_DAMAGE", "SWING_MISSED" );
  784. end;
  785. menuList = {
  786. [1] = {
  787. text = "Damage";
  788. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SWING_DAMAGE");end;
  789. keepShownOnClick = true;
  790. func = function ( self, arg1, arg2, checked )
  791. Blizzard_CombatLog_MenuHelper ( checked, "SWING_DAMAGE" );
  792. end;
  793. };
  794. [2] = {
  795. text = "Failure";
  796. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SWING_MISSED"); end;
  797. keepShownOnClick = true;
  798. func = function ( self, arg1, arg2, checked )
  799. Blizzard_CombatLog_MenuHelper ( checked, "SWING_MISSED" );
  800. end;
  801. };
  802. };
  803. };
  804. [2] = {
  805. text = "Ranged";
  806. hasArrow = true;
  807. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "RANGE_DAMAGE", "RANGE_MISSED"); end;
  808. keepShownOnClick = true;
  809. func = function ( self, arg1, arg2, checked )
  810. Blizzard_CombatLog_MenuHelper ( checked, "RANGED_DAMAGE", "RANGED_MISSED" );
  811. end;
  812. menuList = {
  813. [1] = {
  814. text = "Damage";
  815. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "RANGE_DAMAGE"); end;
  816. keepShownOnClick = true;
  817. func = function ( self, arg1, arg2, checked )
  818. Blizzard_CombatLog_MenuHelper ( checked, "RANGE_DAMAGE" );
  819. end;
  820. };
  821. [2] = {
  822. text = "Failure";
  823. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "RANGE_MISSED"); end;
  824. keepShownOnClick = true;
  825. func = function ( self, arg1, arg2, checked )
  826. Blizzard_CombatLog_MenuHelper ( checked, "RANGE_MISSED" );
  827. end;
  828. };
  829. };
  830. };
  831. [3] = {
  832. text = "Spells";
  833. hasArrow = true;
  834. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_DAMAGE", "SPELL_MISSED", "SPELL_HEAL", "SPELL_ENERGIZE", "SPELL_DRAIN", "SPELL_LEECH", "SPELL_INTERRUPT", "SPELL_EXTRA_ATTACKS", "SPELL_CAST_START", "SPELL_CAST_SUCCESS", "SPELL_CAST_FAILED", "SPELL_INSTAKILL", "SPELL_DURABILITY_DAMAGE" ); end;
  835. keepShownOnClick = true;
  836. func = function ( self, arg1, arg2, checked )
  837. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_DAMAGE", "SPELL_MISSED", "SPELL_HEAL", "SPELL_ENERGIZE", "SPELL_DRAIN", "SPELL_LEECH", "SPELL_INTERRUPT", "SPELL_EXTRA_ATTACKS", "SPELL_CAST_START", "SPELL_CAST_SUCCESS", "SPELL_CAST_FAILED", "SPELL_INSTAKILL", "SPELL_DURABILITY_DAMAGE" );
  838. end;
  839. menuList = {
  840. [1] = {
  841. text = "Damage";
  842. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_DAMAGE"); end;
  843. keepShownOnClick = true;
  844. func = function ( self, arg1, arg2, checked )
  845. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_DAMAGE" );
  846. end;
  847. };
  848. [2] = {
  849. text = "Failure";
  850. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_MISSED"); end;
  851. keepShownOnClick = true;
  852. func = function ( self, arg1, arg2, checked )
  853. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_MISSED" );
  854. end;
  855. };
  856. [3] = {
  857. text = "Heals";
  858. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_HEAL"); end;
  859. keepShownOnClick = true;
  860. func = function ( self, arg1, arg2, checked )
  861. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_HEAL" );
  862. end;
  863. };
  864. [4] = {
  865. text = "Power Gains";
  866. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_ENERGIZE"); end;
  867. keepShownOnClick = true;
  868. func = function ( self, arg1, arg2, checked )
  869. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_ENERGIZE" );
  870. end;
  871. };
  872. [4] = {
  873. text = "Drains";
  874. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_DRAIN", "SPELL_LEECH"); end;
  875. keepShownOnClick = true;
  876. func = function ( self, arg1, arg2, checked )
  877. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_DRAIN", "SPELL_LEECH" );
  878. end;
  879. };
  880. [5] = {
  881. text = "Interrupts";
  882. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_INTERRUPT"); end;
  883. keepShownOnClick = true;
  884. func = function ( self, arg1, arg2, checked )
  885. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_INTERRUPT" );
  886. end;
  887. };
  888. [6] = {
  889. text = "Extra Attacks";
  890. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_EXTRA_ATTACKS"); end;
  891. keepShownOnClick = true;
  892. func = function ( self, arg1, arg2, checked )
  893. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_EXTRA_ATTACKS" );
  894. end;
  895. };
  896. [7] = {
  897. text = "Casting";
  898. hasArrow = true;
  899. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_CAST_START", "SPELL_CAST_SUCCESS", "SPELL_CAST_FAILED"); end;
  900. keepShownOnClick = true;
  901. func = function ( self, arg1, arg2, checked )
  902. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_CAST_START", "SPELL_CAST_SUCCESS", "SPELL_CAST_FAILED");
  903. end;
  904. menuList = {
  905. [1] = {
  906. text = "Start";
  907. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_CAST_START"); end;
  908. keepShownOnClick = true;
  909. func = function ( self, arg1, arg2, checked )
  910. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_CAST_START" );
  911. end;
  912. };
  913. [2] = {
  914. text = "Success";
  915. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_CAST_SUCCESS"); end;
  916. keepShownOnClick = true;
  917. func = function ( self, arg1, arg2, checked )
  918. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_CAST_SUCCESS" );
  919. end;
  920. };
  921. [3] = {
  922. text = "Failed";
  923. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_CAST_FAILED"); end;
  924. keepShownOnClick = true;
  925. func = function ( self, arg1, arg2, checked )
  926. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_CAST_FAILED" );
  927. end;
  928. };
  929. };
  930. };
  931. [8] = {
  932. text = "Special";
  933. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_INSTAKILL", "SPELL_DURABILITY_DAMAGE"); end;
  934. keepShownOnClick = true;
  935. func = function ( self, arg1, arg2, checked )
  936. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_INSTAKILL", "SPELL_DURABILITY_DAMAGE" );
  937. end;
  938. };
  939. };
  940. };
  941. [4] = {
  942. text = "Auras";
  943. hasArrow = true;
  944. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_AURA_APPLIED", "SPELL_AURA_BROKEN", "SPELL_AURA_REFRESH", "SPELL_AURA_BROKEN_SPELL", "SPELL_AURA_APPLIED_DOSE", "SPELL_AURA_REMOVED", "SPELL_AURA_REMOVED_DOSE", "SPELL_DISPEL", "SPELL_STOLEN", "ENCHANT_APPLIED", "ENCHANT_REMOVED" ); end;
  945. keepShownOnClick = true;
  946. func = function ( self, arg1, arg2, checked )
  947. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_AURA_APPLIED", "SPELL_AURA_BROKEN", "SPELL_AURA_REFRESH", "SPELL_AURA_BROKEN_SPELL", "SPELL_AURA_APPLIED_DOSE", "SPELL_AURA_REMOVED", "SPELL_AURA_REMOVED_DOSE", "SPELL_DISPEL", "SPELL_STOLEN", "ENCHANT_APPLIED", "ENCHANT_REMOVED" );
  948. end;
  949. menuList = {
  950. [1] = {
  951. text = "Applied";
  952. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_AURA_APPLIED", "SPELL_AURA_BROKEN", "SPELL_AURA_REFRESH", "SPELL_AURA_BROKEN_SPELL", "SPELL_AURA_APPLIED_DOSE"); end;
  953. keepShownOnClick = true;
  954. func = function ( self, arg1, arg2, checked )
  955. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_AURA_APPLIED", "SPELL_AURA_BROKEN", "SPELL_AURA_REFRESH", "SPELL_AURA_BROKEN_SPELL", "SPELL_AURA_APPLIED_DOSE", "ENCHANT_APPLIED" );
  956. end;
  957. };
  958. [2] = {
  959. text = "Removed";
  960. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_AURA_REMOVED", "SPELL_AURA_REMOVED_DOSE", "ENCHANT_REMOVED" ); end;
  961. keepShownOnClick = true;
  962. func = function ( self, arg1, arg2, checked )
  963. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_AURA_REMOVED", "SPELL_AURA_REMOVED_DOSE" );
  964. end;
  965. };
  966. [3] = {
  967. text = "Dispelled";
  968. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_DISPEL"); end;
  969. keepShownOnClick = true;
  970. func = function ( self, arg1, arg2, checked )
  971. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_DISPEL" );
  972. end;
  973. };
  974. [4] = {
  975. text = "Stolen";
  976. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_STOLEN"); end;
  977. keepShownOnClick = true;
  978. func = function ( self, arg1, arg2, checked )
  979. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_STOLEN" );
  980. end;
  981. };
  982. };
  983. };
  984. [5] = {
  985. text = "Periodics";
  986. hasArrow = true;
  987. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_PERIODIC_DAMAGE", "SPELL_PERIODIC_MISSED", "SPELL_PERIODIC_DRAIN", "SPELL_PERIODIC_ENERGIZE", "SPELL_PERIODIC_HEAL", "SPELL_PERIODIC_LEECH" ); end;
  988. keepShownOnClick = true;
  989. func = function ( self, arg1, arg2, checked )
  990. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_PERIODIC_DAMAGE", "SPELL_PERIODIC_MISSED", "SPELL_PERIODIC_DRAIN", "SPELL_PERIODIC_ENERGIZE", "SPELL_PERIODIC_HEAL", "SPELL_PERIODIC_LEECH" );
  991. end;
  992. menuList = {
  993. [1] = {
  994. text = "Damage";
  995. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_PERIODIC_DAMAGE"); end;
  996. keepShownOnClick = true;
  997. func = function ( self, arg1, arg2, checked )
  998. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_PERIODIC_DAMAGE" );
  999. end;
  1000. };
  1001. [2] = {
  1002. text = "Failure";
  1003. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_PERIODIC_MISSED" ); end;
  1004. keepShownOnClick = true;
  1005. func = function ( self, arg1, arg2, checked )
  1006. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_PERIODIC_MISSED" );
  1007. end;
  1008. };
  1009. [3] = {
  1010. text = "Heals";
  1011. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_PERIODIC_HEAL"); end;
  1012. keepShownOnClick = true;
  1013. func = function ( self, arg1, arg2, checked )
  1014. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_PERIODIC_HEAL" );
  1015. end;
  1016. };
  1017. [4] = {
  1018. text = "Other";
  1019. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "SPELL_PERIODIC_DRAIN", "SPELL_PERIODIC_ENERGIZE", "SPELL_PERIODIC_LEECH"); end;
  1020. keepShownOnClick = true;
  1021. func = function ( self, arg1, arg2, checked )
  1022. Blizzard_CombatLog_MenuHelper ( checked, "SPELL_PERIODIC_DRAIN", "SPELL_PERIODIC_ENERGIZE", "SPELL_PERIODIC_LEECH" );
  1023. end;
  1024. };
  1025. };
  1026. };
  1027. [6] = {
  1028. text = "Other";
  1029. hasArrow = true;
  1030. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "PARTY_KILL", "UNIT_DIED", "UNIT_DESTROYED", "UNIT_DISSIPATES", "DAMAGE_SPLIT", "ENVIRONMENTAL_DAMAGE" ); end;
  1031. keepShownOnClick = true;
  1032. func = function ( self, arg1, arg2, checked )
  1033. Blizzard_CombatLog_MenuHelper ( checked, "PARTY_KILL", "UNIT_DIED", "UNIT_DESTROYED", "UNIT_DISSIPATES", "DAMAGE_SPLIT", "ENVIRONMENTAL_DAMAGE" );
  1034. end;
  1035. menuList = {
  1036. [1] = {
  1037. text = "Kills";
  1038. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "PARTY_KILL"); end;
  1039. keepShownOnClick = true;
  1040. func = function ( self, arg1, arg2, checked )
  1041. Blizzard_CombatLog_MenuHelper ( checked, "PARTY_KILL" );
  1042. end;
  1043. };
  1044. [2] = {
  1045. text = "Deaths";
  1046. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "UNIT_DIED", "UNIT_DESTROYED", "UNIT_DISSIPATES"); end;
  1047. keepShownOnClick = true;
  1048. func = function ( self, arg1, arg2, checked )
  1049. Blizzard_CombatLog_MenuHelper ( checked, "UNIT_DIED", "UNIT_DESTROYED", "UNIT_DISSIPATES" );
  1050. end;
  1051. };
  1052. [3] = {
  1053. text = "Damage Split";
  1054. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "DAMAGE_SPLIT"); end;
  1055. keepShownOnClick = true;
  1056. func = function ( self, arg1, arg2, checked )
  1057. Blizzard_CombatLog_MenuHelper ( checked, "DAMAGE_SPLIT" );
  1058. end;
  1059. };
  1060. [4] = {
  1061. text = "Environmental Damage";
  1062. checked = function() return Blizzard_CombatLog_HasEvent (Blizzard_CombatLog_CurrentSettings, "ENVIRONMENTAL_DAMAGE"); end;
  1063. keepShownOnClick = true;
  1064. func = function ( self, arg1, arg2, checked )
  1065. Blizzard_CombatLog_MenuHelper ( checked, "ENVIRONMENTAL_DAMAGE" );
  1066. end;
  1067. };
  1068. };
  1069. };
  1070. };
  1071. };
  1072. -- functions I see do pass in arguments, update upvalues as necessary.
  1073. function Blizzard_CombatLog_MessageTypesMenu()
  1074. return messageTypesMenu;
  1075. end
  1076. end
  1077. --
  1078. -- Temporary Menu
  1079. --
  1080. do
  1081. local filterId
  1082. local filter
  1083. local currentFilter
  1084. local formattingMenu = {
  1085. text = "Formatting";
  1086. hasArrow = true;
  1087. menuList = {
  1088. {
  1089. text = "Full Text";
  1090. checked = function() return filter.fullText; end;
  1091. func = function(self, arg1, arg2, checked)
  1092. filter.fullText = checked;
  1093. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1094. end;
  1095. keepShownOnClick = true;
  1096. },
  1097. {
  1098. text = "Timestamp";
  1099. checked = function() return filter.timestamp; end;
  1100. func = function(self, arg1, arg2, checked)
  1101. filter.timestamp = checked;
  1102. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1103. end;
  1104. keepShownOnClick = true;
  1105. },
  1106. {
  1107. text = "Unit Name Coloring";
  1108. checked = function() return filter.unitColoring; end;
  1109. func = function(self, arg1, arg2, checked)
  1110. filter.unitColoring = checked;
  1111. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1112. end;
  1113. keepShownOnClick = true;
  1114. },
  1115. {
  1116. text = "Line Coloring";
  1117. checked = function() return filter.lineColoring; end;
  1118. func = function(self, arg1, arg2, checked)
  1119. filter.lineColoring = checked;
  1120. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1121. end;
  1122. keepShownOnClick = true;
  1123. },
  1124. {
  1125. text = "Line Highlighting";
  1126. checked = function() return filter.lineHighlighting; end;
  1127. func = function(self, arg1, arg2, checked)
  1128. filter.lineHighlighting = checked;
  1129. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1130. end;
  1131. keepShownOnClick = true;
  1132. },
  1133. {
  1134. text = "Ability Coloring";
  1135. checked = function() return filter.abilityColoring; end;
  1136. func = function(self, arg1, arg2, checked)
  1137. filter.abilityColoring = checked;
  1138. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1139. end;
  1140. keepShownOnClick = true;
  1141. },
  1142. {
  1143. text = "Ability-by-School Coloring";
  1144. checked = function() return filter.abilitySchoolColoring; end;
  1145. --disabled = not filter.abilityColoring;
  1146. func = function(self, arg1, arg2, checked)
  1147. filter.abilitySchoolColoring = checked;
  1148. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1149. end;
  1150. keepShownOnClick = true;
  1151. },
  1152. {
  1153. text = "Ability-by-Actor Coloring";
  1154. checked = function() return filter.abilityActorColoring; end;
  1155. func = function(self, arg1, arg2, checked)
  1156. filter.abilityActorColoring = checked;
  1157. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1158. end;
  1159. keepShownOnClick = true;
  1160. },
  1161. {
  1162. text = "Ability Highlighting";
  1163. checked = function() return filter.abilityHighlighting; end;
  1164. func = function(self, arg1, arg2, checked)
  1165. filter.abilityHighlighting = checked;
  1166. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1167. end;
  1168. keepShownOnClick = true;
  1169. },
  1170. {
  1171. text = "Action Coloring";
  1172. checked = function() return filter.actionColoring; end;
  1173. func = function(self, arg1, arg2, checked)
  1174. filter.actionColoring = checked;
  1175. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1176. end;
  1177. keepShownOnClick = true;
  1178. },
  1179. {
  1180. text = "Action-by-School Coloring";
  1181. checked = function() return filter.actionSchoolColoring; end;
  1182. func = function(self, arg1, arg2, checked)
  1183. filter.actionSchoolColoring = checked;
  1184. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1185. end;
  1186. keepShownOnClick = true;
  1187. },
  1188. {
  1189. text = "Action-by-Actor Coloring";
  1190. checked = function() return filter.actionActorColoring; end;
  1191. --disabled = not filter.abilityColoring;
  1192. func = function(self, arg1, arg2, checked)
  1193. filter.actionActorColoring = checked;
  1194. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1195. end;
  1196. keepShownOnClick = true;
  1197. },
  1198. {
  1199. text = "Action Highlighting";
  1200. checked = function() return filter.actionHighlighting; end;
  1201. --disabled = not filter.abilityColoring;
  1202. func = function(self, arg1, arg2, checked)
  1203. filter.actionHighlighting = checked;
  1204. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1205. end;
  1206. keepShownOnClick = true;
  1207. },
  1208. {
  1209. text = "Damage Coloring";
  1210. checked = function() return filter.amountColoring; end;
  1211. func = function(self, arg1, arg2, checked)
  1212. filter.amountColoring = checked;
  1213. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1214. end;
  1215. keepShownOnClick = true;
  1216. },
  1217. {
  1218. text = "Damage-by-School Coloring";
  1219. checked = function() return filter.amountSchoolColoring; end;
  1220. --disabled = not filter.amountColoring;
  1221. func = function(self, arg1, arg2, checked)
  1222. filter.amountSchoolColoring = checked;
  1223. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1224. end;
  1225. keepShownOnClick = true;
  1226. },
  1227. {
  1228. text = "Damage-by-Actor Coloring";
  1229. checked = function() return filter.amountActorColoring; end;
  1230. --disabled = not filter.amountColoring;
  1231. func = function(self, arg1, arg2, checked)
  1232. filter.amountActorColoring = checked;
  1233. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1234. end;
  1235. keepShownOnClick = true;
  1236. },
  1237. {
  1238. text = "Damage Highlighting";
  1239. checked = function() return filter.amountHighlighting; end;
  1240. func = function(self, arg1, arg2, checked)
  1241. filter.amountHighlighting = checked;
  1242. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1243. end;
  1244. keepShownOnClick = true;
  1245. },
  1246. {
  1247. text = "Color School Names";
  1248. checked = function() return filter.schoolNameColoring; end;
  1249. func = function(self, arg1, arg2, checked)
  1250. filter.schoolNameColoring = checked;
  1251. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1252. end;
  1253. keepShownOnClick = true;
  1254. },
  1255. {
  1256. text = "School Name Highlighting";
  1257. checked = function() return filter.schoolNameHighlighting; end;
  1258. func = function(self, arg1, arg2, checked)
  1259. filter.schoolNameHighlighting = checked;
  1260. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1261. end;
  1262. keepShownOnClick = true;
  1263. },
  1264. {
  1265. text = "White Swing Rule";
  1266. checked = function() return filter.noMeleeSwingColoring; end;
  1267. func = function(self, arg1, arg2, checked)
  1268. filter.noMeleeSwingColoring = checked;
  1269. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1270. end;
  1271. keepShownOnClick = true;
  1272. },
  1273. {
  1274. text = "Misses Colored Rule";
  1275. checked = function() return filter.missColoring; end;
  1276. func = function(self, arg1, arg2, checked)
  1277. filter.missColoring = checked;
  1278. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1279. end;
  1280. keepShownOnClick = true;
  1281. },
  1282. {
  1283. text = "Braces";
  1284. checked = function() return filter.braces; end;
  1285. func = function(self, arg1, arg2, checked)
  1286. filter.braces = checked;
  1287. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1288. end;
  1289. keepShownOnClick = true;
  1290. },
  1291. {
  1292. text = "Refiltering";
  1293. checked = function() return filter.showHistory; end;
  1294. func = function(self, arg1, arg2, checked)
  1295. filter.showHistory = checked;
  1296. Blizzard_CombatLog_QuickButton_OnClick(currentFilter)
  1297. end;
  1298. keepShownOnClick = true;
  1299. tooltipTitle = "Refiltering";
  1300. tooltipText = "This clears the chat frame and refills it with the last 500 events.";
  1301. },
  1302. };
  1303. };
  1304. function Blizzard_CombatLog_FormattingMenu(filterId_arg)
  1305. -- Update upvalues
  1306. filterId = filterId_arg;
  1307. filter = Blizzard_CombatLog_Filters.filters[filterId].settings;
  1308. currentFilter = Blizzard_CombatLog_Filters.currentFilter;
  1309. return formattingMenu;
  1310. end
  1311. end
  1312. --
  1313. -- Menu Option Helper Function
  1314. --
  1315. function Blizzard_CombatLog_MenuHelper ( checked, ... )
  1316. if ( not checked ) then
  1317. Blizzard_CombatLog_DisableEvent (Blizzard_CombatLog_CurrentSettings, ...);
  1318. else
  1319. Blizzard_CombatLog_EnableEvent (Blizzard_CombatLog_CurrentSettings, ...);
  1320. end
  1321. Blizzard_CombatLog_ApplyFilters(Blizzard_CombatLog_CurrentSettings);
  1322. if ( Blizzard_CombatLog_CurrentSettings.settings.showHistory ) then
  1323. Blizzard_CombatLog_Refilter();
  1324. end
  1325. end;
  1326. --
  1327. -- Blizzard_CombatLog_CreateTabMenu
  1328. --
  1329. -- Creates a context sensitive menu based on the current quick button
  1330. --
  1331. -- args:
  1332. -- settingsIndex - the filter settings to use
  1333. --
  1334. do
  1335. local filterId
  1336. local unitName, unitGUID, special
  1337. local tabMenu = {
  1338. [1] = {
  1339. text = BLIZZARD_COMBAT_LOG_MENU_EVERYTHING;
  1340. func = function () Blizzard_CombatLog_UnitMenuClick ("EVERYTHING", unitName, unitGUID, special); end;
  1341. },
  1342. [2] = {
  1343. text = BLIZZARD_COMBAT_LOG_MENU_SAVE;
  1344. func = function () Blizzard_CombatLog_UnitMenuClick ("SAVE", unitName, unitGUID, special); end;
  1345. },
  1346. [3] = {
  1347. text = BLIZZARD_COMBAT_LOG_MENU_RESET;
  1348. func = function () Blizzard_CombatLog_UnitMenuClick ("RESET", unitName, unitGUID, special); end;
  1349. },
  1350. [4] = {
  1351. text = "--------- Temporary Adjustments ---------";
  1352. disabled = true;
  1353. },
  1354. };
  1355. function Blizzard_CombatLog_CreateTabMenu ( filterId_arg )
  1356. -- Update upvalues
  1357. filterId = filterId_arg
  1358. -- Update menus
  1359. tabMenu[2].disabled = (Blizzard_CombatLog_PreviousSettings == Blizzard_CombatLog_CurrentSettings)
  1360. tabMenu[5] = Blizzard_CombatLog_FormattingMenu(filterId);
  1361. tabMenu[6] = Blizzard_CombatLog_MessageTypesMenu(filterId);
  1362. return tabMenu;
  1363. end
  1364. end
  1365. --
  1366. -- Temporary Menu
  1367. --
  1368. do
  1369. function Blizzard_CombatLog_CreateUnitMenu(unitName, unitGUID, special)
  1370. local displayName = unitName;
  1371. if ( (unitGUID == UnitGUID("player")) and (_G["COMBAT_LOG_UNIT_YOU_ENABLED"] == "1") ) then
  1372. displayName = UNIT_YOU;
  1373. end
  1374. local unitMenu = {
  1375. [1] = {
  1376. text = string.format(BLIZZARD_COMBAT_LOG_MENU_BOTH, displayName); -- Dummy text
  1377. func = function () Blizzard_CombatLog_UnitMenuClick ("BOTH", unitName, unitGUID, special); end;
  1378. },
  1379. [2] = {
  1380. text = string.format(BLIZZARD_COMBAT_LOG_MENU_INCOMING, displayName);
  1381. func = function () Blizzard_CombatLog_UnitMenuClick ("INCOMING", unitName, unitGUID, special); end;
  1382. },
  1383. [3] = {
  1384. text = string.format(BLIZZARD_COMBAT_LOG_MENU_OUTGOING, displayName);
  1385. func = function () Blizzard_CombatLog_UnitMenuClick ("OUTGOING", unitName, unitGUID, special); end;
  1386. },
  1387. [4] = {
  1388. text = "------------------";
  1389. disabled = true;
  1390. },
  1391. [5] = {
  1392. text = BLIZZARD_COMBAT_LOG_MENU_EVERYTHING;
  1393. func = function () Blizzard_CombatLog_UnitMenuClick ("EVERYTHING", unitName, unitGUID, special); end;
  1394. },
  1395. [6] = {
  1396. text = BLIZZARD_COMBAT_LOG_MENU_SAVE;
  1397. func = function () Blizzard_CombatLog_UnitMenuClick ("SAVE", unitName, unitGUID, special); end;
  1398. disabled = not CanCreateFilters();
  1399. },
  1400. [7] = {
  1401. text = BLIZZARD_COMBAT_LOG_MENU_RESET;
  1402. func = function () Blizzard_CombatLog_UnitMenuClick ("RESET", unitName, unitGUID, special); end;
  1403. },
  1404. };
  1405. --[[
  1406. -- These 2 calls update the menus in their respective do-end blocks
  1407. unitMenu[9] = Blizzard_CombatLog_FormattingMenu(Blizzard_CombatLog_Filters.currentFilter);
  1408. unitMenu[10] = Blizzard_CombatLog_MessageTypesMenu(Blizzard_CombatLog_Filters.currentFilter);
  1409. ]]
  1410. if ( unitGUID ~= UnitGUID("player") ) then
  1411. table.insert(unitMenu, 4, {
  1412. text = string.format(BLIZZARD_COMBAT_LOG_MENU_OUTGOING_ME, displayName);
  1413. func = function () Blizzard_CombatLog_UnitMenuClick ("OUTGOING_ME", unitName, unitGUID, special); end;
  1414. } );
  1415. end
  1416. return unitMenu
  1417. end
  1418. end
  1419. -- Create additional filter dropdown list
  1420. do
  1421. local menu = {};
  1422. function Blizzard_CombatLog_CreateFilterMenu()
  1423. local count = 1;
  1424. for index, value in pairs(menu) do
  1425. if ( not value ) then
  1426. value = {};
  1427. else
  1428. for k, v in pairs(value) do
  1429. value[k] = nil;
  1430. end
  1431. end
  1432. end
  1433. local selectedIndex = Blizzard_CombatLog_Filters.currentFilter;
  1434. local checked;
  1435. for index, value in ipairs(Blizzard_CombatLog_Filters.filters) do
  1436. if ( not value.onQuickBar ) then
  1437. if ( not menu[count] ) then
  1438. menu[count] = {};
  1439. end
  1440. menu[count].text = value.name;
  1441. menu[count].func = function () Blizzard_CombatLog_QuickButton_OnClick(index); end;
  1442. if ( selectedIndex == index ) then
  1443. checked = 1;
  1444. else
  1445. checked = nil;
  1446. end
  1447. menu[count].checked = checked;
  1448. count = count+1;
  1449. end
  1450. end
  1451. return menu;
  1452. end
  1453. end
  1454. --
  1455. -- Handle mini menu clicks
  1456. --
  1457. -- args:
  1458. -- event - "EVERYTHING" | "RESET" | "INCOMING" | "OUTGOING" | "BOTH"
  1459. -- unitName - string for the units name
  1460. -- unitGUID - unique global unit ID for the specific unit
  1461. -- special - bit code for special filters, such as raid targets
  1462. --
  1463. function Blizzard_CombatLog_UnitMenuClick(event, unitName, unitGUID, unitFlags)
  1464. -- ChatFrame1:AddMessage("Event: "..event.." N: "..tostring(unitName).." GUID: "..tostring(unitGUID).." Flags: "..tostring(unitFlags));
  1465. --
  1466. -- This code was for the context menus to support different formatting criteria
  1467. --
  1468. -- -- Apply the correct settings.
  1469. -- if ( Blizzard_CombatLog_Filters.contextMenu[event] ) then
  1470. -- Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.contextMenu[event]
  1471. -- end
  1472. -- I'm not sure if we really want this feature for live
  1473. if ( event == "REVERT" ) then
  1474. local temp = Blizzard_CombatLog_CurrentSettings;
  1475. Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_PreviousSettings;
  1476. Blizzard_CombatLog_PreviousSettings = temp;
  1477. temp = nil;
  1478. -- Apply the old filters
  1479. Blizzard_CombatLog_ApplyFilters(Blizzard_CombatLog_CurrentSettings);
  1480. elseif ( event == "SAVE" ) then
  1481. local dialog = StaticPopup_Show("COPY_COMBAT_FILTER");
  1482. dialog.data = Blizzard_CombatLog_CurrentSettings;
  1483. return;
  1484. elseif ( event == "RESET" ) then
  1485. Blizzard_CombatLog_PreviousSettings = Blizzard_CombatLog_CurrentSettings;
  1486. Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.filters[Blizzard_CombatLog_Filters.currentFilter];
  1487. Blizzard_CombatLog_ApplyFilters(Blizzard_CombatLog_CurrentSettings);
  1488. else
  1489. -- Copy the current settings
  1490. Blizzard_CombatLog_PreviousSettings = Blizzard_CombatLog_CurrentSettings;
  1491. Blizzard_CombatLog_CurrentSettings = {};
  1492. for k,v in pairs( Blizzard_CombatLog_PreviousSettings ) do
  1493. Blizzard_CombatLog_CurrentSettings[k] = v;
  1494. end
  1495. -- Erase the filter criteria
  1496. Blizzard_CombatLog_CurrentSettings.filters = {}; -- We want to be careful not to destroy the active data, so the user can reset
  1497. if ( event == "EVERYTHING" ) then
  1498. -- Reset all filtering.
  1499. CombatLogResetFilter()
  1500. --Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.contextMenu[event];
  1501. CombatLogAddFilter(nil, nil, nil)
  1502. tinsert ( Blizzard_CombatLog_CurrentSettings.filters, {} );
  1503. end
  1504. if ( event == "INCOMING" or event == "BOTH" ) then
  1505. if ( unitFlags ) then
  1506. tinsert ( Blizzard_CombatLog_CurrentSettings.filters, { destFlags = { [unitFlags] = true; } } );
  1507. else
  1508. tinsert ( Blizzard_CombatLog_CurrentSettings.filters, { destFlags = { [unitGUID] = true; } } );
  1509. end
  1510. end
  1511. if ( event == "OUTGOING" or event == "BOTH" ) then
  1512. if ( unitFlags ) then
  1513. tinsert ( Blizzard_CombatLog_CurrentSettings.filters, { sourceFlags = { [unitFlags] = true; } } );
  1514. else
  1515. tinsert ( Blizzard_CombatLog_CurrentSettings.filters, { sourceFlags = { [unitGUID] = true; } } );
  1516. end
  1517. end
  1518. if ( event == "OUTGOING_ME" ) then
  1519. if ( unitFlags ) then
  1520. tinsert ( Blizzard_CombatLog_CurrentSettings.filters, { sourceFlags = { [unitFlags] = true; }; destFlags = { [COMBATLOG_FILTER_MINE] = true; } } );
  1521. else
  1522. tinsert ( Blizzard_CombatLog_CurrentSettings.filters, { sourceFlags = { [unitGUID] = true; }; destFlags = { [COMBATLOG_FILTER_MINE] = true; } } );
  1523. end
  1524. end
  1525. -- If the context menu is not resetting, then we need to create an event list,
  1526. -- So that right click removal works when the user right clicks
  1527. --
  1528. -- Fill the event list
  1529. local fullEventList = Blizzard_CombatLog_GenerateFullEventList();
  1530. -- Insert to the active data
  1531. for k,v in pairs (Blizzard_CombatLog_CurrentSettings.filters) do
  1532. v.eventList = fullEventList;
  1533. end
  1534. -- Apply the generated filters
  1535. Blizzard_CombatLog_ApplyFilters(Blizzard_CombatLog_CurrentSettings);
  1536. -- Let the system know that this filter is temporary and unhighlight any quick buttons
  1537. Blizzard_CombatLog_CurrentSettings.isTemp = true;
  1538. Blizzard_CombatLog_Update_QuickButtons()
  1539. end
  1540. -- Reset the combat log text box! (Grats!)
  1541. Blizzard_CombatLog_Refilter();
  1542. end
  1543. --
  1544. -- Shows a simplified version of the menu if you right click on the quick button
  1545. --
  1546. -- This function isn't used anywhere yet. The QuickButtons doesn't have a event handler for right click yet.
  1547. function Blizzard_CombatLog_QuickButtonRightClick(event, filterId)
  1548. -- I'm not sure if we really want this feature for live
  1549. if ( event == "REVERT" ) then
  1550. local temp = Blizzard_CombatLog_CurrentSettings;
  1551. Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_PreviousSettings;
  1552. Blizzard_CombatLog_PreviousSettings = temp;
  1553. temp = nil;
  1554. -- Apply the old filters
  1555. Blizzard_CombatLog_ApplyFilters(Blizzard_CombatLog_CurrentSettings);
  1556. elseif ( event == "RESET" ) then
  1557. Blizzard_CombatLog_PreviousSettings = Blizzard_CombatLog_CurrentSettings;
  1558. Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.filters[filterId];
  1559. --CombatLogAddFilter(nil, nil, COMBATLOG_FILTER_MINE)
  1560. --CombatLogAddFilter(nil, COMBATLOG_FILTER_MINE, nil)
  1561. else
  1562. -- Copy the current settings
  1563. Blizzard_CombatLog_PreviousSettings = Blizzard_CombatLog_CurrentSettings;
  1564. Blizzard_CombatLog_CurrentSettings = {};
  1565. for k,v in pairs( Blizzard_CombatLog_Filters.filters[filterId] ) do
  1566. Blizzard_CombatLog_CurrentSettings[k] = v;
  1567. end
  1568. -- Erase the filter criteria
  1569. Blizzard_CombatLog_CurrentSettings.filters = {}; -- We want to be careful not to destroy the active data, so the user can reset
  1570. if ( event == "EVERYTHING" ) then
  1571. CombatLogAddFilter(nil, nil, nil)
  1572. table.insert ( Blizzard_CombatLog_CurrentSettings.filters, {} );
  1573. end
  1574. -- If the context menu is not resetting, then we need to create an event list,
  1575. -- So that right click removal works when the user right clicks
  1576. --
  1577. -- Fill the event list
  1578. local fullEventList = Blizzard_CombatLog_GenerateFullEventList();
  1579. -- Insert to the active data
  1580. for k,v in pairs (Blizzard_CombatLog_CurrentSettings.filters) do
  1581. v.eventList = fullEventList;
  1582. end
  1583. -- Apply the generated filters
  1584. Blizzard_CombatLog_ApplyFilters(Blizzard_CombatLog_CurrentSettings);
  1585. end
  1586. -- Reset the combat log text box! (Grats!)
  1587. Blizzard_CombatLog_Refilter();
  1588. end
  1589. --
  1590. -- Handle spell mini menu clicks
  1591. -- args:
  1592. -- action - "HIDE" | "LINK"
  1593. -- spellName - Spell or ability's name
  1594. -- spellId - Spell or ability's id (100, 520, 30000, etc)
  1595. -- event - the event type that generated this message
  1596. --
  1597. function Blizzard_CombatLog_SpellMenuClick(action, spellName, spellId, eventType)
  1598. if ( action == "HIDE" ) then
  1599. for k,v in pairs (Blizzard_CombatLog_CurrentSettings.filters) do
  1600. if ( type (v.eventList) ~= "table" ) then
  1601. v.eventList = Blizzard_CombatLog_GenerateFullEventList();
  1602. end
  1603. v.eventList[eventType] = false;
  1604. end
  1605. elseif ( action == "LINK" ) then
  1606. if ( ChatEdit_GetActiveWindow() ) then
  1607. ChatEdit_InsertLink(GetSpellLink(spellId));
  1608. else
  1609. ChatFrame_OpenChat(GetSpellLink(spellId));
  1610. end
  1611. return;
  1612. end
  1613. -- Apply the newly reconstituted filters
  1614. Blizzard_CombatLog_ApplyFilters(Blizzard_CombatLog_CurrentSettings);
  1615. -- Reset the combat log text box! (Grats!)
  1616. Blizzard_CombatLog_Refilter();
  1617. end
  1618. --
  1619. -- Temporary Settings
  1620. --
  1621. Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.filters[1];
  1622. Blizzard_CombatLog_PreviousSettings = Blizzard_CombatLog_CurrentSettings;
  1623. local Blizzard_CombatLog_UnitTokens = {};
  1624. --[[
  1625. -- Converts 4 floats into FF code
  1626. --
  1627. --]]
  1628. local function CombatLog_Color_FloatToText(r,g,b,a)
  1629. if ( type(r) == "table" ) then
  1630. r, g, b, a = r.r, r.g, r.b, r.a;
  1631. end
  1632. a = min(1, a or 1) * 255
  1633. r = min(1, r) * 255
  1634. g = min(1, g) * 255
  1635. b = min(1, b) * 255
  1636. -- local fmt = "%.2x";
  1637. return ("%.2x%.2x%.2x%.2x"):format(math_floor(a), math_floor(r), math_floor(g), math_floor(b))
  1638. end
  1639. _G.CombatLog_Color_FloatToText = CombatLog_Color_FloatToText
  1640. --
  1641. -- Gets the appropriate color for an event type
  1642. --
  1643. -- If this needs to return a new table per event (ie, the table gets modified), then just replace the "defaultColorArray" in the function with
  1644. -- a new table creation.
  1645. local defaultColorArray = {a=1.0,r=0.5,g=0.5,b=0.5}
  1646. local function CombatLog_Color_ColorArrayByEventType( event )
  1647. return Blizzard_CombatLog_CurrentSettings.colors.eventColoring[event] or defaultColorArray
  1648. end
  1649. _G.CombatLog_Color_ColorArrayByEventType = CombatLog_Color_ColorArrayByEventType
  1650. --
  1651. -- Gets the appropriate color for a unit type
  1652. --
  1653. local function CombatLog_Color_ColorArrayByUnitType(unitFlags, settings)
  1654. local array = nil;
  1655. if ( not settings ) then
  1656. settings = Blizzard_CombatLog_CurrentSettings;
  1657. end
  1658. for mask,colorArray in pairs( settings.colors.unitColoring ) do
  1659. if ( CombatLog_Object_IsA (unitFlags, mask) )then
  1660. array = colorArray;
  1661. break;
  1662. end
  1663. end
  1664. return array or defaultColorArray
  1665. end
  1666. _G.CombatLog_Color_ColorArrayByUnitType = CombatLog_Color_ColorArrayByUnitType
  1667. --
  1668. -- Gets the appropriate color for a spell school
  1669. --
  1670. local function CombatLog_Color_ColorArrayBySchool(school, settings)
  1671. if ( not settings ) then
  1672. settings = Blizzard_CombatLog_CurrentSettings;
  1673. end
  1674. if ( not school ) then
  1675. return settings.colors.schoolColoring.default;
  1676. end
  1677. return settings.colors.schoolColoring[school] or settings.colors.defaults.spell;
  1678. end
  1679. _G.CombatLog_Color_ColorArrayBySchool = CombatLog_Color_ColorArrayBySchool
  1680. --
  1681. -- Gets the appropriate color for a spell school
  1682. --
  1683. local highlightColorTable = {}
  1684. local function CombatLog_Color_HighlightColorArray(colorArray)
  1685. highlightColorTable.r = colorArray.r * COMBATLOG_HIGHLIGHT_MULTIPLIER;
  1686. highlightColorTable.g = colorArray.g * COMBATLOG_HIGHLIGHT_MULTIPLIER;
  1687. highlightColorTable.b = colorArray.b * COMBATLOG_HIGHLIGHT_MULTIPLIER;
  1688. highlightColorTable.a = colorArray.a;
  1689. return highlightColorTable
  1690. end
  1691. _G.CombatLog_Color_HighlightColorArray = CombatLog_Color_HighlightColorArray
  1692. --
  1693. -- Returns a string associated with a numeric power type
  1694. --
  1695. local function CombatLog_String_PowerType(powerType, amount, alternatePowerType)
  1696. if ( not powerType ) then
  1697. return "";
  1698. elseif ( powerType == SPELL_POWER_MANA ) then
  1699. return MANA;
  1700. elseif ( powerType == SPELL_POWER_RAGE ) then
  1701. return RAGE;
  1702. elseif ( powerType == SPELL_POWER_ENERGY ) then
  1703. return ENERGY;
  1704. elseif ( powerType == SPELL_POWER_FOCUS ) then
  1705. return FOCUS;
  1706. elseif ( powerType == SPELL_POWER_RUNES ) then
  1707. return RUNES;
  1708. elseif ( powerType == SPELL_POWER_RUNIC_POWER ) then
  1709. return RUNIC_POWER;
  1710. elseif ( powerType == SPELL_POWER_SOUL_SHARDS ) then
  1711. return SOUL_SHARDS;
  1712. elseif ( powerType == SPELL_POWER_ECLIPSE ) then
  1713. if amount and amount > 0 then
  1714. return BALANCE_POSITIVE_ENERGY;
  1715. else
  1716. return BALANCE_NEGATIVE_ENERGY;
  1717. end
  1718. elseif ( powerType == SPELL_POWER_HOLY_POWER ) then
  1719. return HOLY_POWER;
  1720. elseif ( powerType == SPELL_POWER_CHI ) then
  1721. return CHI_POWER; -- "Chi"
  1722. elseif ( powerType == SPELL_POWER_BURNING_EMBERS ) then
  1723. return BURNING_EMBERS_POWER;
  1724. elseif ( powerType == SPELL_POWER_SHADOW_ORBS ) then
  1725. return SHADOW_ORBS_POWER;
  1726. elseif ( powerType == SPELL_POWER_ALTERNATE_POWER and alternatePowerType ) then
  1727. local costName = select(12, GetAlternatePowerInfoByID(alternatePowerType));
  1728. return costName; --costName could be nil if we didn't get the alternatePowerType for some reason (e.g. target out of AOI)
  1729. end
  1730. end
  1731. _G.CombatLog_String_PowerType = CombatLog_String_PowerType
  1732. local function CombatLog_String_SchoolString(school)
  1733. if ( not school or school == SCHOOL_MASK_NONE ) then
  1734. return STRING_SCHOOL_UNKNOWN;
  1735. end
  1736. local schoolString = GetSchoolString(school);
  1737. return schoolString or STRING_SCHOOL_UNKNOWN
  1738. end
  1739. _G.CombatLog_String_SchoolString = CombatLog_String_SchoolString
  1740. local function CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill )
  1741. local resultStr;
  1742. -- Result String formatting
  1743. local useOverhealing = overhealing and overhealing > 0;
  1744. local useOverkill = overkill and overkill > 0;
  1745. local useAbsorbed = absorbed and absorbed > 0;
  1746. if ( resisted or blocked or critical or glancing or crushing or useOverhealing or useOverkill or useAbsorbed) then
  1747. resultStr = nil;
  1748. if ( resisted ) then
  1749. if ( resisted < 0 ) then --Its really a vulnerability
  1750. resultStr = format(TEXT_MODE_A_STRING_RESULT_VULNERABILITY, -resisted);
  1751. else
  1752. resultStr = format(TEXT_MODE_A_STRING_RESULT_RESIST, resisted);
  1753. end
  1754. end
  1755. if ( blocked ) then
  1756. if ( resultStr ) then
  1757. resultStr = resultStr.." "..format(TEXT_MODE_A_STRING_RESULT_BLOCK, blocked);
  1758. else
  1759. resultStr = format(TEXT_MODE_A_STRING_RESULT_BLOCK, blocked);
  1760. end
  1761. end
  1762. if ( useAbsorbed ) then
  1763. if ( resultStr ) then
  1764. resultStr = resultStr.." "..format(TEXT_MODE_A_STRING_RESULT_ABSORB, absorbed);
  1765. else
  1766. resultStr = format(TEXT_MODE_A_STRING_RESULT_ABSORB, absorbed);
  1767. end
  1768. end
  1769. if ( glancing ) then
  1770. if ( resultStr ) then
  1771. resultStr = resultStr.." "..TEXT_MODE_A_STRING_RESULT_GLANCING;
  1772. else
  1773. resultStr = TEXT_MODE_A_STRING_RESULT_GLANCING;
  1774. end
  1775. end
  1776. if ( crushing ) then
  1777. if ( resultStr ) then
  1778. resultStr = resultStr.." "..TEXT_MODE_A_STRING_RESULT_CRUSHING;
  1779. else
  1780. resultStr = TEXT_MODE_A_STRING_RESULT_CRUSHING;
  1781. end
  1782. end
  1783. if ( useOverhealing ) then
  1784. if ( resultStr ) then
  1785. resultStr = resultStr.." "..format(TEXT_MODE_A_STRING_RESULT_OVERHEALING, overhealing);
  1786. else
  1787. resultStr = format(TEXT_MODE_A_STRING_RESULT_OVERHEALING, overhealing);
  1788. end
  1789. end
  1790. if ( useOverkill ) then
  1791. if ( resultStr ) then
  1792. resultStr = resultStr.." "..format(TEXT_MODE_A_STRING_RESULT_OVERKILLING, overkill);
  1793. else
  1794. resultStr = format(TEXT_MODE_A_STRING_RESULT_OVERKILLING, overkill);
  1795. end
  1796. end
  1797. if ( critical ) then
  1798. local critString = TEXT_MODE_A_STRING_RESULT_CRITICAL;
  1799. if ( spellId ) then
  1800. critString = TEXT_MODE_A_STRING_RESULT_CRITICAL_SPELL;
  1801. end
  1802. if ( resultStr ) then
  1803. resultStr = resultStr.." "..critString;
  1804. else
  1805. resultStr = critString;
  1806. end
  1807. end
  1808. end
  1809. return resultStr;
  1810. end
  1811. _G.CombatLog_String_DamageResultString = CombatLog_String_DamageResultString
  1812. --
  1813. -- Get the appropriate raid icon for a unit
  1814. --
  1815. local function CombatLog_String_GetIcon ( unitFlags, direction )
  1816. -- Check for an appropriate icon for this unit
  1817. local raidTarget = bit_band(unitFlags, COMBATLOG_OBJECT_RAIDTARGET_MASK);
  1818. if ( raidTarget == 0 ) then
  1819. return "";
  1820. end
  1821. local iconString = "";
  1822. local icon = nil;
  1823. local iconBit = 0;
  1824. if ( raidTarget == COMBATLOG_OBJECT_RAIDTARGET1 ) then
  1825. icon = COMBATLOG_ICON_RAIDTARGET1;
  1826. iconBit = COMBATLOG_OBJECT_RAIDTARGET1;
  1827. elseif ( raidTarget == COMBATLOG_OBJECT_RAIDTARGET2 ) then
  1828. icon = COMBATLOG_ICON_RAIDTARGET2;
  1829. iconBit = COMBATLOG_OBJECT_RAIDTARGET2;
  1830. elseif ( raidTarget == COMBATLOG_OBJECT_RAIDTARGET3 ) then
  1831. icon = COMBATLOG_ICON_RAIDTARGET3;
  1832. iconBit = COMBATLOG_OBJECT_RAIDTARGET3;
  1833. elseif ( raidTarget == COMBATLOG_OBJECT_RAIDTARGET4 ) then
  1834. icon = COMBATLOG_ICON_RAIDTARGET4;
  1835. iconBit = COMBATLOG_OBJECT_RAIDTARGET4;
  1836. elseif ( raidTarget == COMBATLOG_OBJECT_RAIDTARGET5 ) then
  1837. icon = COMBATLOG_ICON_RAIDTARGET5;
  1838. iconBit = COMBATLOG_OBJECT_RAIDTARGET5;
  1839. elseif ( raidTarget == COMBATLOG_OBJECT_RAIDTARGET6 ) then
  1840. icon = COMBATLOG_ICON_RAIDTARGET6;
  1841. iconBit = COMBATLOG_OBJECT_RAIDTARGET6;
  1842. elseif ( raidTarget == COMBATLOG_OBJECT_RAIDTARGET7 ) then
  1843. icon = COMBATLOG_ICON_RAIDTARGET7;
  1844. iconBit = COMBATLOG_OBJECT_RAIDTARGET7;
  1845. elseif ( raidTarget == COMBATLOG_OBJECT_RAIDTARGET8 ) then
  1846. icon = COMBATLOG_ICON_RAIDTARGET8;
  1847. iconBit = COMBATLOG_OBJECT_RAIDTARGET8;
  1848. end
  1849. -- Insert the Raid Icon if it exists
  1850. if ( icon ) then
  1851. --
  1852. -- Insert a hyperlink for that icon
  1853. if ( direction == "source" ) then
  1854. iconString = format(TEXT_MODE_A_STRING_SOURCE_ICON, iconBit, icon);
  1855. else
  1856. iconString = format(TEXT_MODE_A_STRING_DEST_ICON, iconBit, icon);
  1857. end
  1858. end
  1859. return iconString;
  1860. end
  1861. _G.CombatLog_String_GetIcon = CombatLog_String_GetIcon
  1862. --
  1863. -- Obtains the appropriate unit token for a GUID
  1864. --
  1865. local function CombatLog_String_GetToken (unitGUID, unitName, unitFlags)
  1866. --
  1867. -- Code to display Defias Pillager (A), Defias Pillager (B), etc
  1868. --
  1869. --[[
  1870. local newName = TEXT_MODE_A_STRING_TOKEN_UNIT;
  1871. -- Use the local cache if possible
  1872. if ( Blizzard_CombatLog_UnitTokens[unitGUID] ) then
  1873. -- For unique creatures, hide the token
  1874. if ( Blizzard_CombatLog_UnitTokens[unitGUID] == unitName ) then
  1875. return unitName;
  1876. end
  1877. newName = gsub ( newName, "$token", Blizzard_CombatLog_UnitTokens[unitGUID] );
  1878. newName = gsub ( newName, "$unitName", unitName );
  1879. else
  1880. if ( not Blizzard_CombatLog_UnitTokens[unitName] or Blizzard_CombatLog_UnitTokens[unitName] > 26*26) then
  1881. Blizzard_CombatLog_UnitTokens[unitName] = 1;
  1882. Blizzard_CombatLog_UnitTokens[unitGUID] = unitName;
  1883. newName = unitName;
  1884. else
  1885. Blizzard_CombatLog_UnitTokens[unitName] = Blizzard_CombatLog_UnitTokens[unitName] + 1;
  1886. if ( Blizzard_CombatLog_UnitTokens[unitName] > 26 ) then
  1887. Blizzard_CombatLog_UnitTokens[unitGUID] =
  1888. string.char ( TEXT_MODE_A_STRING_TOKEN_BASE + math.floor(Blizzard_CombatLog_UnitTokens[unitName] / 26) )..
  1889. string.char ( TEXT_MODE_A_STRING_TOKEN_BASE + math.fmod(Blizzard_CombatLog_UnitTokens[unitName], 26) );
  1890. else
  1891. Blizzard_CombatLog_UnitTokens[unitGUID] = string.char ( TEXT_MODE_A_STRING_TOKEN_BASE + math.fmod(Blizzard_CombatLog_UnitTokens[unitName], 26) );
  1892. end
  1893. newName = gsub ( newName, "$token", Blizzard_CombatLog_UnitTokens[unitGUID] );
  1894. newName = gsub ( newName, "$unitName", unitName );
  1895. end
  1896. end
  1897. ]]
  1898. -- Shortcut since the above block is commented out.
  1899. -- newName = unitName;
  1900. return unitName;
  1901. end
  1902. _G.CombatLog_String_GetToken = CombatLog_String_GetToken
  1903. --
  1904. -- Gets the appropriate color for a unit type
  1905. --
  1906. --
  1907. local function CombatLog_Color_ColorStringByUnitType(unitFlags)
  1908. local colorArray = CombatLog_Color_ColorArrayByUnitType(unitFlags);
  1909. return CombatLog_Color_FloatToText(colorArray.r, colorArray.g, colorArray.b, colorArray.a )
  1910. end
  1911. _G.CombatLog_Color_ColorStringByUnitType = CombatLog_Color_ColorStringByUnitType
  1912. --[[
  1913. -- Gets the appropriate color for a school
  1914. --
  1915. --]]
  1916. local function CombatLog_Color_ColorStringBySchool(school)
  1917. local colorArray = CombatLog_Color_ColorArrayBySchool(school);
  1918. return CombatLog_Color_FloatToText(colorArray.r, colorArray.g, colorArray.b, colorArray.a )
  1919. end
  1920. _G.CombatLog_Color_ColorStringBySchool = CombatLog_Color_ColorStringBySchool
  1921. --
  1922. -- Gets the appropriate color for an event type
  1923. --
  1924. --
  1925. local function CombatLog_Color_ColorStringByEventType(unitFlags)
  1926. local colorArray = CombatLog_Color_ColorArrayByEventType(unitFlags);
  1927. return CombatLog_Color_FloatToText(colorArray.r, colorArray.g, colorArray.b, colorArray.a )
  1928. end
  1929. _G.CombatLog_Color_ColorStringByEventType = CombatLog_Color_ColorStringByEventType
  1930. --[[
  1931. -- Handles events and dumps them to the specified frame.
  1932. --]]
  1933. -- Add settings as an arg
  1934. local defaultCombatLogLineColor = { a = 1.00, r = 1.00, g = 1.00, b = 1.00 };
  1935. function CombatLog_OnEvent(filterSettings, timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...)
  1936. -- [environmentalDamageType]
  1937. -- [spellName, spellRank, spellSchool]
  1938. -- [damage, school, [resisted, blocked, absorbed, crit, glancing, crushing]]
  1939. -- Upvalue this, we're gonna use it a lot
  1940. local settings = filterSettings.settings;
  1941. local lineColor = defaultCombatLogLineColor;
  1942. local sourceColor, destColor = nil, nil;
  1943. local braceColor = "FFFFFFFF";
  1944. local abilityColor = "FFFFFF00";
  1945. -- Processing variables
  1946. local textMode = settings.textMode;
  1947. local timestampEnabled = settings.timestamp;
  1948. local hideBuffs = settings.hideBuffs;
  1949. local hideDebuffs = settings.hideDebuffs;
  1950. local sourceEnabled = true;
  1951. local falseSource = false;
  1952. local destEnabled = true;
  1953. local spellEnabled = true;
  1954. local actionEnabled = true;
  1955. local valueEnabled = true;
  1956. local valueTypeEnabled = true;
  1957. local resultEnabled = true;
  1958. local powerTypeEnabled = true;
  1959. local itemEnabled = false;
  1960. local extraSpellEnabled = false;
  1961. local valueIsItem = false;
  1962. local schoolEnabled = true;
  1963. local withPoints = false;
  1964. local forceDestPossessive = false;
  1965. -- Get the initial string
  1966. local schoolString;
  1967. local resultStr;
  1968. local formatString = TEXT_MODE_A_STRING_1;
  1969. if ( EVENT_TEMPLATE_FORMATS[event] ) then
  1970. formatString = EVENT_TEMPLATE_FORMATS[event];
  1971. end
  1972. -- Replacements to do:
  1973. -- * Src, Dest, Action, Spell, Amount, Result
  1974. -- Spell standard order
  1975. local spellId, spellName, spellSchool;
  1976. local extraSpellId, extraSpellName, extraSpellSchool;
  1977. -- For Melee/Ranged swings and enchants
  1978. local nameIsNotSpell, extraNameIsNotSpell;
  1979. -- Damage standard order
  1980. local amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing, overhealing;
  1981. -- Miss argument order
  1982. local missType, isOffHand, amountMissed;
  1983. -- Aura arguments
  1984. local auraType; -- BUFF or DEBUFF
  1985. -- Enchant arguments
  1986. local itemId, itemName;
  1987. -- Special Spell values
  1988. local valueType = 1; -- 1 = School, 2 = Power Type
  1989. local extraAmount; -- Used for Drains and Leeches
  1990. local powerType; -- Used for energizes, drains and leeches
  1991. local alternatePowerType; -- Used for energizes, drains and leeches
  1992. local environmentalType; -- Used for environmental damage
  1993. local message; -- Used for server spell messages
  1994. local originalEvent = event; -- Used for spell links
  1995. local remainingPoints; --Used for absorbs with the correct flag set (like Power Word: Shield)
  1996. -- Generic disabling stuff
  1997. if ( not sourceName or CombatLog_Object_IsA(sourceFlags, COMBATLOG_OBJECT_NONE) ) then
  1998. sourceEnabled = false;
  1999. end
  2000. if ( not destName or CombatLog_Object_IsA(destFlags, COMBATLOG_OBJECT_NONE) ) then
  2001. destEnabled = false;
  2002. end
  2003. local subVal = strsub(event, 1, 5)
  2004. -- Swings
  2005. if ( subVal == "SWING" ) then
  2006. spellName = ACTION_SWING;
  2007. nameIsNotSpell = true;
  2008. end
  2009. -- Break out the arguments into variable
  2010. if ( event == "SWING_DAMAGE" ) then
  2011. -- Damage standard
  2012. amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = ...;
  2013. -- Parse the result string
  2014. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2015. if ( not resultStr ) then
  2016. resultEnabled = false;
  2017. end
  2018. if ( overkill > 0 ) then
  2019. amount = amount - overkill;
  2020. end
  2021. elseif ( event == "SWING_MISSED" ) then
  2022. spellName = ACTION_SWING;
  2023. -- Miss type
  2024. missType, isOffHand, amountMissed = ...;
  2025. -- Result String
  2026. if( missType == "RESIST" or missType == "BLOCK" or missType == "ABSORB" ) then
  2027. resultStr = format(_G["TEXT_MODE_A_STRING_RESULT_"..missType], amountMissed);
  2028. else
  2029. resultStr = _G["ACTION_SWING_MISSED_"..missType];
  2030. end
  2031. -- Miss Type
  2032. if ( settings.fullText and missType ) then
  2033. event = format("%s_%s", event, missType);
  2034. end
  2035. -- Disable appropriate sections
  2036. nameIsNotSpell = true;
  2037. valueEnabled = false;
  2038. resultEnabled = true;
  2039. elseif ( subVal == "SPELL" ) then -- Spell standard arguments
  2040. spellId, spellName, spellSchool = ...;
  2041. if ( event == "SPELL_DAMAGE" or event == "SPELL_BUILDING_DAMAGE") then
  2042. -- Damage standard
  2043. amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = select(4, ...);
  2044. -- Parse the result string
  2045. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2046. if ( not resultStr ) then
  2047. resultEnabled = false
  2048. end
  2049. if ( overkill > 0 ) then
  2050. amount = amount - overkill;
  2051. end
  2052. elseif ( event == "SPELL_MISSED" ) then
  2053. -- Miss type
  2054. missType, isOffHand, amountMissed = select(4, ...);
  2055. resultEnabled = true;
  2056. -- Result String
  2057. if( missType == "RESIST" or missType == "BLOCK" or missType == "ABSORB" ) then
  2058. if ( amountMissed ~= 0 ) then
  2059. resultStr = format(_G["TEXT_MODE_A_STRING_RESULT_"..missType], amountMissed);
  2060. else
  2061. resultEnabled = false;
  2062. end
  2063. else
  2064. resultStr = _G["ACTION_SWING_MISSED_"..missType];
  2065. end
  2066. -- Miss Event
  2067. if ( missType ) then
  2068. event = format("%s_%s", event, missType);
  2069. end
  2070. -- Disable appropriate sections
  2071. valueEnabled = false;
  2072. elseif ( event == "SPELL_HEAL" or event == "SPELL_BUILDING_HEAL") then
  2073. -- Did the heal crit?
  2074. amount, overhealing, absorbed, critical = select(4, ...);
  2075. -- Parse the result string
  2076. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2077. if ( not resultStr ) then
  2078. resultEnabled = false
  2079. end
  2080. -- Temporary Spell School Hack
  2081. school = spellSchool;
  2082. -- Disable appropriate sections
  2083. valueEnabled = true;
  2084. valueTypeEnabled = true;
  2085. amount = amount - overhealing;
  2086. elseif ( event == "SPELL_ENERGIZE" ) then
  2087. -- Set value type to be a power type
  2088. valueType = 2;
  2089. -- Did the heal crit?
  2090. amount, powerType, alternatePowerType = select(4, ...);
  2091. -- Parse the result string
  2092. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2093. if ( not resultStr ) then
  2094. resultEnabled = false
  2095. end
  2096. -- Disable appropriate sections
  2097. valueEnabled = true;
  2098. valueTypeEnabled = true;
  2099. elseif ( strsub(event, 1, 14) == "SPELL_PERIODIC" ) then
  2100. if ( event == "SPELL_PERIODIC_MISSED" ) then
  2101. -- Miss type
  2102. missType = select(4, ...);
  2103. -- Result String
  2104. if ( missType == "ABSORB" ) then
  2105. resultStr = CombatLog_String_DamageResultString( resisted, blocked, select(5,...), critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2106. else
  2107. resultStr = _G["ACTION_SPELL_PERIODIC_MISSED_"..missType];
  2108. end
  2109. -- Miss Event
  2110. if ( settings.fullText and missType ) then
  2111. event = format("%s_%s", event, missType);
  2112. end
  2113. -- Disable appropriate sections
  2114. valueEnabled = false;
  2115. resultEnabled = true;
  2116. elseif ( event == "SPELL_PERIODIC_DAMAGE" ) then
  2117. -- Damage standard
  2118. amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = select(4, ...);
  2119. -- Parse the result string
  2120. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2121. -- Disable appropriate sections
  2122. if ( not resultStr ) then
  2123. resultEnabled = false
  2124. end
  2125. if ( overkill > 0 ) then
  2126. amount = amount - overkill;
  2127. end
  2128. elseif ( event == "SPELL_PERIODIC_HEAL" ) then
  2129. -- Did the heal crit?
  2130. amount, overhealing, absorbed, critical = select(4, ...);
  2131. -- Parse the result string
  2132. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2133. if ( not resultStr ) then
  2134. resultEnabled = false
  2135. end
  2136. -- Temporary Spell School Hack
  2137. school = spellSchool;
  2138. -- Disable appropriate sections
  2139. valueEnabled = true;
  2140. valueTypeEnabled = true;
  2141. amount = amount - overhealing;
  2142. elseif ( event == "SPELL_PERIODIC_DRAIN" ) then
  2143. -- Special attacks
  2144. amount, powerType, extraAmount, alternatePowerType = select(4, ...);
  2145. -- Set value type to be a power type
  2146. valueType = 2;
  2147. -- Result String
  2148. --resultStr = _G[textModeString .. "RESULT"];
  2149. --resultStr = gsub(resultStr,"$resultString", _G["ACTION_"..event.."_RESULT"]);
  2150. -- Disable appropriate sections
  2151. if ( not resultStr ) then
  2152. resultEnabled = false
  2153. end
  2154. valueEnabled = true;
  2155. schoolEnabled = false;
  2156. elseif ( event == "SPELL_PERIODIC_LEECH" ) then
  2157. -- Special attacks
  2158. amount, powerType, extraAmount, alternatePowerType = select(4, ...);
  2159. -- Set value type to be a power type
  2160. valueType = 2;
  2161. -- Result String
  2162. resultStr = format(_G["ACTION_SPELL_PERIODIC_LEECH_RESULT"], nil, nil, nil, nil, nil, nil, nil, CombatLog_String_PowerType(powerType, amount, alternatePowerType), nil, extraAmount) --"($extraAmount $powerType Gained)"
  2163. -- Disable appropriate sections
  2164. if ( not resultStr ) then
  2165. resultEnabled = false
  2166. end
  2167. valueEnabled = true;
  2168. schoolEnabled = false;
  2169. elseif ( event == "SPELL_PERIODIC_ENERGIZE" ) then
  2170. -- Set value type to be a power type
  2171. valueType = 2;
  2172. -- Did the heal crit?
  2173. amount, powerType, alternatePowerType = select(4, ...);
  2174. -- Parse the result string
  2175. --resultStr = _G[textModeString .. "RESULT"];
  2176. --resultStr = gsub(resultStr,"$resultString", _G["ACTION_"..event.."_RESULT"]);
  2177. if ( not resultStr ) then
  2178. resultEnabled = false
  2179. end
  2180. -- Disable appropriate sections
  2181. valueEnabled = true;
  2182. valueTypeEnabled = true;
  2183. end
  2184. elseif ( event == "SPELL_CAST_START" ) then -- Spellcast
  2185. if ( not destName ) then
  2186. destEnabled = false;
  2187. end
  2188. if ( not sourceName and not settings.fullText ) then
  2189. sourceName = COMBATLOG_UNKNOWN_UNIT;
  2190. sourceEnabled = true;
  2191. falseSource = true;
  2192. end
  2193. -- Disable appropriate types
  2194. resultEnabled = false;
  2195. valueEnabled = false;
  2196. elseif ( event == "SPELL_CAST_SUCCESS" ) then
  2197. if ( not destName ) then
  2198. destEnabled = false;
  2199. end
  2200. if ( not sourceName and not settings.fullText ) then
  2201. sourceName = COMBATLOG_UNKNOWN_UNIT;
  2202. sourceEnabled = true;
  2203. falseSource = true;
  2204. end
  2205. -- Disable appropriate types
  2206. resultEnabled = false;
  2207. valueEnabled = false;
  2208. elseif ( event == "SPELL_CAST_FAILED" ) then
  2209. if ( not destName ) then
  2210. destEnabled = false;
  2211. end
  2212. -- Miss reason
  2213. missType = select(4, ...);
  2214. -- Result String
  2215. resultStr = format("(%s)", missType);
  2216. --resultStr = gsub(_G[textModeString .. "RESULT"],"$resultString", missType);
  2217. -- Disable appropriate sections
  2218. valueEnabled = false;
  2219. destEnabled = false;
  2220. if ( not resultStr ) then
  2221. resultEnabled = false;
  2222. end
  2223. elseif ( event == "SPELL_DRAIN" ) then -- Special Spell effects
  2224. -- Special attacks
  2225. amount, powerType, extraAmount, alternatePowerType = select(4, ...);
  2226. -- Set value type to be a power type
  2227. valueType = 2;
  2228. -- Disable appropriate sections
  2229. if ( not resultStr ) then
  2230. resultEnabled = false;
  2231. end
  2232. valueEnabled = true;
  2233. schoolEnabled = false;
  2234. elseif ( event == "SPELL_LEECH" ) then
  2235. -- Special attacks
  2236. amount, powerType, extraAmount, alternatePowerType = select(4, ...);
  2237. -- Set value type to be a power type
  2238. valueType = 2;
  2239. -- Result String
  2240. resultStr = format(_G["ACTION_SPELL_LEECH_RESULT"], nil, nil, nil, nil, nil, nil, nil, CombatLog_String_PowerType(powerType, amount, alternatePowerType), nil, extraAmount)
  2241. -- Disable appropriate sections
  2242. if ( not resultStr ) then
  2243. resultEnabled = false;
  2244. end
  2245. valueEnabled = true;
  2246. schoolEnabled = false;
  2247. elseif ( event == "SPELL_INTERRUPT" ) then
  2248. -- Spell interrupted
  2249. extraSpellId, extraSpellName, extraSpellSchool = select(4, ...);
  2250. -- Replace the value token with a spell token
  2251. if ( extraSpellId ) then
  2252. extraSpellEnabled = true;
  2253. end
  2254. -- Disable appropriate sections
  2255. resultEnabled = false;
  2256. valueEnabled = false;
  2257. valueTypeEnabled = false;
  2258. schoolEnabled = false;
  2259. elseif ( event == "SPELL_EXTRA_ATTACKS" ) then
  2260. -- Special attacks
  2261. amount = select(4, ...);
  2262. -- Disable appropriate sections
  2263. resultEnabled = false;
  2264. valueEnabled = true;
  2265. valueTypeEnabled = false;
  2266. schoolEnabled = false;
  2267. elseif ( event == "SPELL_SUMMON" ) then
  2268. -- Disable appropriate sections
  2269. resultEnabled = false;
  2270. valueEnabled = false;
  2271. schoolEnabled = false;
  2272. elseif ( event == "SPELL_RESURRECT" ) then
  2273. -- Disable appropriate sections
  2274. resultEnabled = false;
  2275. valueEnabled = false;
  2276. schoolEnabled = false;
  2277. elseif ( event == "SPELL_CREATE" ) then
  2278. -- Disable appropriate sections
  2279. resultEnabled = false;
  2280. valueEnabled = false;
  2281. schoolEnabled = false;
  2282. elseif ( event == "SPELL_INSTAKILL" ) then
  2283. -- Disable appropriate sections
  2284. resultEnabled = false;
  2285. valueEnabled = false;
  2286. schoolEnabled = false;
  2287. elseif ( event == "SPELL_DURABILITY_DAMAGE" ) then
  2288. -- Disable appropriate sections
  2289. resultEnabled = false;
  2290. valueEnabled = false;
  2291. schoolEnabled = false;
  2292. elseif ( event == "SPELL_DURABILITY_DAMAGE_ALL" ) then
  2293. -- Disable appropriate sections
  2294. resultEnabled = false;
  2295. valueEnabled = false;
  2296. schoolEnabled = false;
  2297. elseif ( event == "SPELL_DISPEL_FAILED" ) then
  2298. -- Extra Spell standard
  2299. extraSpellId, extraSpellName, extraSpellSchool = select(4, ...);
  2300. -- Replace the value token with a spell token
  2301. if ( extraSpellId ) then
  2302. extraSpellEnabled = true;
  2303. end
  2304. -- Disable appropriate sections
  2305. resultEnabled = false;
  2306. valueEnabled = false;
  2307. elseif ( event == "SPELL_DISPEL" or event == "SPELL_STOLEN" ) then
  2308. -- Extra Spell standard, Aura standard
  2309. extraSpellId, extraSpellName, extraSpellSchool, auraType = select(4, ...);
  2310. -- Event Type
  2311. event = format("%s_%s", event, auraType);
  2312. -- Replace the value token with a spell token
  2313. if ( extraSpellId ) then
  2314. extraSpellEnabled = true;
  2315. valueEnabled = true;
  2316. else
  2317. valueEnabled = false;
  2318. end
  2319. -- Disable appropriate sections
  2320. resultEnabled = false;
  2321. elseif ( event == "SPELL_AURA_BROKEN" or event == "SPELL_AURA_BROKEN_SPELL") then
  2322. -- Extra Spell standard, Aura standard
  2323. if(event == "SPELL_AURA_BROKEN") then
  2324. auraType = select(4, ...);
  2325. else
  2326. extraSpellId, extraSpellName, extraSpellSchool, auraType = select(4, ...);
  2327. end
  2328. -- Abort if buff/debuff is not set to true
  2329. if ( hideBuffs and auraType == AURA_TYPE_BUFF ) then
  2330. return;
  2331. elseif ( hideDebuffs and auraType == AURA_TYPE_DEBUFF ) then
  2332. return;
  2333. end
  2334. -- Event Type
  2335. event = format("%s_%s", event, auraType);
  2336. -- Replace the value token with a spell token
  2337. if ( extraSpellId ) then
  2338. extraSpellEnabled = true;
  2339. valueEnabled = true;
  2340. else
  2341. forceDestPossessive = true;
  2342. valueEnabled = false;
  2343. end
  2344. resultEnabled = false;
  2345. elseif ( event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REMOVED" or event == "SPELL_AURA_REFRESH") then -- Aura Events
  2346. -- Aura standard
  2347. auraType, remainingPoints = select(4, ...);
  2348. -- Abort if buff/debuff is not set to true
  2349. if ( hideBuffs and auraType == AURA_TYPE_BUFF ) then
  2350. return;
  2351. elseif ( hideDebuffs and auraType == AURA_TYPE_DEBUFF ) then
  2352. return;
  2353. end
  2354. formatString = TEXT_MODE_A_STRING_1;
  2355. -- Event Type
  2356. event = format("%s_%s", event, auraType);
  2357. if ( remainingPoints and settings.fullText ) then
  2358. withPoints = true;
  2359. end
  2360. resultEnabled = false;
  2361. valueEnabled = false;
  2362. elseif ( event == "SPELL_AURA_APPLIED_DOSE" or event == "SPELL_AURA_REMOVED_DOSE" ) then
  2363. -- Aura standard
  2364. auraType, amount = select(4, ...);
  2365. -- Abort if buff/debuff is not set to true
  2366. if ( hideBuffs and auraType == AURA_TYPE_BUFF ) then
  2367. return;
  2368. elseif ( hideDebuffs and auraType == AURA_TYPE_DEBUFF ) then
  2369. return;
  2370. end
  2371. -- Event Type
  2372. event = format("%s_%s", event, auraType);
  2373. -- Disable appropriate sections
  2374. resultEnabled = false;
  2375. valueEnabled = true;
  2376. valueTypeEnabled = false;
  2377. end
  2378. elseif ( subVal == "RANGE" ) then
  2379. --spellName = ACTION_RANGED;
  2380. --nameIsNotSpell = true;
  2381. -- Shots are spells, technically
  2382. spellId, spellName, spellSchool = ...;
  2383. if ( event == "RANGE_DAMAGE" ) then
  2384. -- Damage standard
  2385. amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = select(4, ...);
  2386. -- Parse the result string
  2387. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2388. if ( not resultStr ) then
  2389. resultEnabled = false
  2390. end
  2391. -- Disable appropriate sections
  2392. nameIsNotSpell = true;
  2393. if ( overkill > 0 ) then
  2394. amount = amount - overkill;
  2395. end
  2396. elseif ( event == "RANGE_MISSED" ) then
  2397. spellName = ACTION_RANGED;
  2398. -- Miss type
  2399. missType, isOffHand, amountMissed = select(4,...);
  2400. -- Result String
  2401. if( missType == "RESIST" or missType == "BLOCK" or missType == "ABSORB" ) then
  2402. resultStr = format(_G["TEXT_MODE_A_STRING_RESULT_"..missType], amountMissed);
  2403. else
  2404. resultStr = _G["ACTION_RANGE_MISSED_"..missType];
  2405. end
  2406. -- Miss Type
  2407. if ( settings.fullText and missType ) then
  2408. event = format("%s_%s", event, missType);
  2409. end
  2410. -- Disable appropriate sections
  2411. nameIsNotSpell = true;
  2412. valueEnabled = false;
  2413. resultEnabled = true;
  2414. end
  2415. elseif ( event == "DAMAGE_SHIELD" ) then -- Damage Shields
  2416. -- Spell standard, Damage standard
  2417. spellId, spellName, spellSchool, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = ...;
  2418. -- Parse the result string
  2419. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2420. -- Disable appropriate sections
  2421. if ( not resultStr ) then
  2422. resultEnabled = false
  2423. end
  2424. if ( overkill > 0 ) then
  2425. amount = amount - overkill;
  2426. end
  2427. elseif ( event == "DAMAGE_SHIELD_MISSED" ) then
  2428. -- Spell standard, Miss type
  2429. spellId, spellName, spellSchool, missType = ...;
  2430. -- Result String
  2431. resultStr = _G["ACTION_DAMAGE_SHIELD_MISSED_"..missType];
  2432. -- Miss Event
  2433. if ( settings.fullText and missType ) then
  2434. event = format("%s_%s", event, missType);
  2435. end
  2436. -- Disable appropriate sections
  2437. valueEnabled = false;
  2438. if ( not resultStr ) then
  2439. resultEnabled = false;
  2440. end
  2441. elseif ( event == "PARTY_KILL" ) then -- Unique Events
  2442. -- Disable appropriate sections
  2443. resultEnabled = false;
  2444. valueEnabled = false;
  2445. spellEnabled = false;
  2446. elseif ( event == "ENCHANT_APPLIED" ) then
  2447. -- Get the enchant name, item id and item name
  2448. spellName, itemId, itemName = ...;
  2449. nameIsNotSpell = true;
  2450. -- Disable appropriate sections
  2451. valueIsItem = true;
  2452. itemEnabled = true;
  2453. resultEnabled = false;
  2454. elseif ( event == "ENCHANT_REMOVED" ) then
  2455. -- Get the enchant name, item id and item name
  2456. spellName, itemId, itemName = ...;
  2457. nameIsNotSpell = true;
  2458. -- Disable appropriate sections
  2459. valueIsItem = true;
  2460. itemEnabled = true;
  2461. resultEnabled = false;
  2462. sourceEnabled = false;
  2463. elseif ( event == "UNIT_DIED" or event == "UNIT_DESTROYED" or event == "UNIT_DISSIPATES" ) then
  2464. -- Swap Source with Dest
  2465. sourceName = destName;
  2466. sourceGUID = destGUID;
  2467. sourceFlags = destFlags;
  2468. -- Disable appropriate sections
  2469. resultEnabled = false;
  2470. sourceEnabled = true;
  2471. destEnabled = false;
  2472. spellEnabled = false;
  2473. valueEnabled = false;
  2474. elseif ( event == "ENVIRONMENTAL_DAMAGE" ) then
  2475. --Environemental Type, Damage standard
  2476. environmentalType, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = ...
  2477. environmentalType = string.upper(environmentalType);
  2478. -- Miss Event
  2479. spellName = _G["ACTION_ENVIRONMENTAL_DAMAGE_"..environmentalType];
  2480. spellSchool = school;
  2481. nameIsNotSpell = true;
  2482. -- Parse the result string
  2483. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2484. -- Environmental Event
  2485. if ( settings.fullText and environmentalType ) then
  2486. event = "ENVIRONMENTAL_DAMAGE_"..environmentalType;
  2487. end
  2488. if ( not resultStr ) then
  2489. resultEnabled = false;
  2490. end
  2491. if ( overkill > 0 ) then
  2492. amount = amount - overkill;
  2493. end
  2494. elseif ( event == "DAMAGE_SPLIT" ) then
  2495. -- Spell Standard Arguments, Damage standard
  2496. spellId, spellName, spellSchool, amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing = ...;
  2497. -- Parse the result string
  2498. resultStr = CombatLog_String_DamageResultString( resisted, blocked, absorbed, critical, glancing, crushing, overhealing, textMode, spellId, overkill );
  2499. if ( not resultStr ) then
  2500. resultEnabled = false
  2501. end
  2502. if ( overkill > 0 ) then
  2503. amount = amount - overkill;
  2504. end
  2505. end
  2506. -- Throw away all of the assembled strings and just grab a premade one
  2507. if ( settings.fullText ) then
  2508. local formatStringEvent;
  2509. if (withPoints) then
  2510. formatStringEvent = format("ACTION_%s_WITH_POINTS_FULL_TEXT", event);
  2511. else
  2512. formatStringEvent = format("ACTION_%s_FULL_TEXT", event);
  2513. end
  2514. -- Get the base string
  2515. if ( _G[formatStringEvent] ) then
  2516. formatString = _G[formatStringEvent];
  2517. end
  2518. -- Set any special cases
  2519. if ( not sourceEnabled ) then
  2520. formatStringEvent = formatStringEvent.."_NO_SOURCE";
  2521. end
  2522. if ( not destEnabled ) then
  2523. formatStringEvent = formatStringEvent.."_NO_DEST";
  2524. end
  2525. if (event=="DAMAGE_SPLIT" and resultStr) then
  2526. if (amount == 0) then
  2527. formatStringEvent = "ACTION_DAMAGE_SPLIT_ABSORBED_FULL_TEXT";
  2528. else
  2529. formatStringEvent = "ACTION_DAMAGE_SPLIT_RESULT_FULL_TEXT";
  2530. end
  2531. end
  2532. -- Get the special cased string
  2533. if ( _G[formatStringEvent] ) then
  2534. formatString = _G[formatStringEvent];
  2535. end
  2536. sourceEnabled = true;
  2537. destEnabled = true;
  2538. spellEnabled = true;
  2539. valueEnabled = true;
  2540. end
  2541. -- Actor name construction.
  2542. --
  2543. local sourceNameStr = "";
  2544. local destNameStr = "";
  2545. local sourceIcon = "";
  2546. local destIcon = "";
  2547. local spellNameStr = spellName;
  2548. local extraSpellNameStr = extraSpellName;
  2549. local itemNameStr = itemName;
  2550. local actionEvent = "ACTION_"..event;
  2551. local actionStr = _G[actionEvent];
  2552. local timestampStr = timestamp;
  2553. local powerTypeString = "";
  2554. -- If this ever succeeds, the event string is missing.
  2555. --
  2556. if ( not actionStr ) then
  2557. actionStr = event;
  2558. end
  2559. -- Initialize the strings now
  2560. sourceNameStr, destNameStr = sourceName, destName;
  2561. -- Special changes for localization when not in full text mode
  2562. if ( not settings.fullText and COMBAT_LOG_UNIT_YOU_ENABLED == "1" ) then
  2563. -- Replace your name with "You";
  2564. if ( sourceName and CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MINE) ) then
  2565. sourceNameStr = UNIT_YOU_SOURCE;
  2566. end
  2567. if ( destName and CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_MINE) ) then
  2568. destNameStr = UNIT_YOU_DEST;
  2569. end
  2570. -- Apply the possessive form to the source
  2571. if ( sourceName and spellName and _G[actionEvent.."_POSSESSIVE"] == "1" ) then
  2572. if ( sourceName and CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MINE) ) then
  2573. sourceNameStr = UNIT_YOU_SOURCE_POSSESSIVE;
  2574. end
  2575. end
  2576. -- Apply the possessive form to the source
  2577. if ( destName and ( extraSpellName or itemName ) ) then
  2578. if ( destName and CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_MINE) ) then
  2579. destNameStr = UNIT_YOU_DEST_POSSESSIVE;
  2580. end
  2581. end
  2582. -- If its full text mode
  2583. else
  2584. -- Apply the possessive form to the source
  2585. if ( sourceName and spellName and _G[actionEvent.."_POSSESSIVE"] == "1" ) then
  2586. sourceNameStr = format(TEXT_MODE_A_STRING_POSSESSIVE, sourceNameStr);
  2587. end
  2588. -- Apply the possessive form to the dest if the dest has a spell
  2589. if ( ( extraSpellName or forceDestPossessive or itemName ) and destName ) then
  2590. destNameStr = format(TEXT_MODE_A_STRING_POSSESSIVE, destNameStr);
  2591. end
  2592. end
  2593. -- Unit Tokens
  2594. if ( settings.unitTokens ) then
  2595. -- Apply the possessive form to the source
  2596. if ( sourceName ) then
  2597. sourceName = CombatLog_String_GetToken(sourceGUID, sourceName, sourceFlags);
  2598. end
  2599. if ( destName ) then
  2600. destName = CombatLog_String_GetToken(destGUID, destName, destFlags);
  2601. end
  2602. end
  2603. -- Unit Icons
  2604. if ( settings.unitIcons ) then
  2605. if ( sourceName ) then
  2606. sourceIcon = CombatLog_String_GetIcon(sourceRaidFlags, "source");
  2607. end
  2608. if ( destName ) then
  2609. destIcon = CombatLog_String_GetIcon(destRaidFlags, "dest");
  2610. end
  2611. end
  2612. -- Get the source color
  2613. if ( sourceName ) then
  2614. sourceColor = CombatLog_Color_ColorStringByUnitType( sourceFlags );
  2615. end
  2616. -- Get the dest color
  2617. if ( destName ) then
  2618. destColor = CombatLog_Color_ColorStringByUnitType( destFlags );
  2619. end
  2620. -- Whole line coloring
  2621. if ( settings.lineColoring ) then
  2622. if ( settings.lineColorPriority == 3 or ( not sourceName and not destName) ) then
  2623. lineColor = CombatLog_Color_ColorArrayByEventType( event, filterSettings );
  2624. else
  2625. if ( ( settings.lineColorPriority == 1 and sourceName ) or not destName ) then
  2626. lineColor = CombatLog_Color_ColorArrayByUnitType( sourceFlags, filterSettings );
  2627. elseif ( ( settings.lineColorPriority == 2 and destName ) ) then
  2628. lineColor = CombatLog_Color_ColorArrayByUnitType( destFlags, filterSettings );
  2629. else
  2630. lineColor = CombatLog_Color_ColorArrayByUnitType( sourceFlags, filterSettings );
  2631. end
  2632. end
  2633. end
  2634. -- Power Type
  2635. if ( powerType ) then
  2636. powerTypeString = CombatLog_String_PowerType(powerType, amount, alternatePowerType);
  2637. if powerTypeString == BALANCE_NEGATIVE_ENERGY then
  2638. amount = abs(amount);
  2639. end
  2640. end
  2641. -- Only replace if there's an amount
  2642. if ( amount ) then
  2643. local amountColor;
  2644. -- Color amount numbers
  2645. if ( settings.amountColoring ) then
  2646. -- To make white swings white
  2647. if ( settings.noMeleeSwingColoring and school == SCHOOL_MASK_PHYSICAL and not spellId ) then
  2648. -- Do nothing
  2649. elseif ( settings.amountActorColoring ) then
  2650. if ( sourceName ) then
  2651. amountColor = CombatLog_Color_ColorArrayByUnitType( sourceFlags, filterSettings );
  2652. elseif ( destName ) then
  2653. amountColor = CombatLog_Color_ColorArrayByUnitType( destFlags, filterSettings );
  2654. end
  2655. elseif ( settings.amountSchoolColoring ) then
  2656. amountColor = CombatLog_Color_ColorArrayBySchool(school, filterSettings);
  2657. else
  2658. amountColor = filterSettings.colors.defaults.damage;
  2659. end
  2660. end
  2661. -- Highlighting
  2662. if ( settings.amountHighlighting ) then
  2663. local colorArray;
  2664. if ( not amountColor ) then
  2665. colorArray = lineColor;
  2666. else
  2667. colorArray = amountColor;
  2668. end
  2669. amountColor = CombatLog_Color_HighlightColorArray (colorArray);
  2670. end
  2671. if ( amountColor ) then
  2672. amountColor = CombatLog_Color_FloatToText(amountColor);
  2673. amount = format("|c%s%s|r", amountColor, amount);
  2674. end
  2675. schoolString = CombatLog_String_SchoolString(school);
  2676. local schoolNameColor = nil;
  2677. -- Color school names
  2678. if ( settings.schoolNameColoring ) then
  2679. if ( settings.noMeleeSwingColoring and school == SCHOOL_MASK_PHYSICAL and not spellId ) then
  2680. elseif ( settings.schoolNameActorColoring ) then
  2681. if ( sourceName ) then
  2682. schoolNameColor = CombatLog_Color_ColorArrayByUnitType( sourceFlags, filterSettings );
  2683. elseif ( destName ) then
  2684. schoolNameColor = CombatLog_Color_ColorArrayByUnitType( destFlags, filterSettings );
  2685. end
  2686. else
  2687. schoolNameColor = CombatLog_Color_ColorArrayBySchool( school, filterSettings );
  2688. end
  2689. end
  2690. -- Highlighting
  2691. if ( settings.schoolNameHighlighting ) then
  2692. local colorArray;
  2693. if ( not schoolNameColor ) then
  2694. colorArray = lineColor;
  2695. else
  2696. colorArray = schoolNameColor;
  2697. end
  2698. schoolNameColor = CombatLog_Color_HighlightColorArray (colorArray);
  2699. end
  2700. if ( schoolNameColor ) then
  2701. schoolNameColor = CombatLog_Color_FloatToText(schoolNameColor);
  2702. schoolString = format("|c%s%s|r", schoolNameColor, schoolString);
  2703. end
  2704. end
  2705. -- Color source names
  2706. if ( settings.unitColoring ) then
  2707. if ( sourceName and settings.sourceColoring ) then
  2708. sourceNameStr = format("|c%s%s|r", sourceColor, sourceNameStr);
  2709. end
  2710. if ( destName and settings.destColoring ) then
  2711. destNameStr = format("|c%s%s|r", destColor, destNameStr);
  2712. end
  2713. end
  2714. -- If there's an action (always)
  2715. if ( actionStr ) then
  2716. local actionColor = nil;
  2717. -- Color ability names
  2718. if ( settings.actionColoring ) then
  2719. if ( settings.actionActorColoring ) then
  2720. if ( sourceName ) then
  2721. actionColor = CombatLog_Color_ColorArrayByUnitType( sourceFlags, filterSettings );
  2722. elseif ( destName ) then
  2723. actionColor = CombatLog_Color_ColorArrayByUnitType( destFlags, filterSettings );
  2724. end
  2725. elseif ( settings.actionSchoolColoring and spellSchool ) then
  2726. actionColor = CombatLog_Color_ColorArrayBySchool( spellSchool, filterSettings );
  2727. else
  2728. actionColor = CombatLog_Color_ColorArrayByEventType(event);
  2729. end
  2730. -- Special option to only color "Miss" if there's no damage
  2731. elseif ( settings.missColoring ) then
  2732. if ( event ~= "SWING_DAMAGE" and
  2733. event ~= "RANGE_DAMAGE" and
  2734. event ~= "SPELL_DAMAGE" and
  2735. event ~= "SPELL_PERIODIC_DAMAGE" ) then
  2736. local actionColor = nil;
  2737. if ( settings.actionActorColoring ) then
  2738. actionColor = CombatLog_Color_ColorArrayByUnitType( sourceFlags, filterSettings );
  2739. elseif ( settings.actionSchoolColoring ) then
  2740. actionColor = CombatLog_Color_ColorArrayBySchool( spellSchool, filterSettings );
  2741. else
  2742. actionColor = CombatLog_Color_ColorArrayByEventType(event);
  2743. end
  2744. end
  2745. end
  2746. -- Highlighting
  2747. if ( settings.actionHighlighting ) then
  2748. local colorArray;
  2749. if ( not actionColor ) then
  2750. colorArray = lineColor;
  2751. else
  2752. colorArray = actionColor;
  2753. end
  2754. actionColor = CombatLog_Color_HighlightColorArray (colorArray);
  2755. end
  2756. if ( actionColor ) then
  2757. actionColor = CombatLog_Color_FloatToText(actionColor);
  2758. actionStr = format("|c%s%s|r", actionColor, actionStr);
  2759. end
  2760. end
  2761. -- If there's a spell name
  2762. if ( spellName ) then
  2763. local abilityColor = nil;
  2764. -- Color ability names
  2765. if ( settings.abilityColoring ) then
  2766. if ( settings.abilityActorColoring ) then
  2767. abilityColor = CombatLog_Color_ColorArrayByUnitType( sourceFlags, filterSettings );
  2768. elseif ( settings.abilitySchoolColoring ) then
  2769. abilityColor = CombatLog_Color_ColorArrayBySchool( spellSchool, filterSettings );
  2770. else
  2771. if ( spellSchool ) then
  2772. abilityColor = filterSettings.colors.defaults.spell;
  2773. end
  2774. end
  2775. end
  2776. -- Highlight this color
  2777. if ( settings.abilityHighlighting ) then
  2778. local colorArray;
  2779. if ( not abilityColor ) then
  2780. colorArray = lineColor;
  2781. else
  2782. colorArray = abilityColor;
  2783. end
  2784. abilityColor = CombatLog_Color_HighlightColorArray (colorArray);
  2785. end
  2786. if ( abilityColor ) then
  2787. abilityColor = CombatLog_Color_FloatToText(abilityColor);
  2788. if ( itemId ) then
  2789. spellNameStr = spellName;
  2790. else
  2791. spellNameStr = format("|c%s%s|r", abilityColor, spellName);
  2792. end
  2793. end
  2794. end
  2795. -- If there's a spell name
  2796. if ( extraSpellName ) then
  2797. local abilityColor = nil;
  2798. -- Color ability names
  2799. if ( settings.abilityColoring ) then
  2800. if ( settings.abilitySchoolColoring ) then
  2801. abilityColor = CombatLog_Color_ColorArrayBySchool( extraSpellSchool, filterSettings );
  2802. else
  2803. if ( extraSpellSchool ) then
  2804. abilityColor = CombatLog_Color_ColorArrayBySchool( SCHOOL_MASK_HOLY, filterSettings );
  2805. else
  2806. abilityColor = CombatLog_Color_ColorArrayBySchool( nil, filterSettings );
  2807. end
  2808. end
  2809. end
  2810. -- Highlight this color
  2811. if ( settings.abilityHighlighting ) then
  2812. local colorArray;
  2813. if ( not abilityColor ) then
  2814. colorArray = lineColor;
  2815. else
  2816. colorArray = abilityColor;
  2817. end
  2818. abilityColor = CombatLog_Color_HighlightColorArray (colorArray);
  2819. end
  2820. if ( abilityColor ) then
  2821. abilityColor = CombatLog_Color_FloatToText(abilityColor);
  2822. extraSpellNameStr = format("|c%s%s|r", abilityColor, extraSpellName);
  2823. end
  2824. end
  2825. -- Whole line highlighting
  2826. if ( settings.lineHighlighting ) then
  2827. if ( filterSettings.colors.highlightedEvents[event] ) then
  2828. lineColor = CombatLog_Color_HighlightColorArray (lineColor);
  2829. end
  2830. end
  2831. -- Build braces
  2832. if ( settings.braces ) then
  2833. -- Unit specific braces
  2834. if ( settings.unitBraces ) then
  2835. if ( sourceName and settings.sourceBraces ) then
  2836. sourceNameStr = format(TEXT_MODE_A_STRING_BRACE_UNIT, braceColor, sourceNameStr, braceColor);
  2837. end
  2838. if ( destName and settings.destBraces ) then
  2839. destNameStr = format(TEXT_MODE_A_STRING_BRACE_UNIT, braceColor, destNameStr, braceColor);
  2840. end
  2841. end
  2842. -- Spell name braces
  2843. if ( spellName and settings.spellBraces ) then
  2844. if ( not itemId ) then
  2845. spellNameStr = format(TEXT_MODE_A_STRING_BRACE_SPELL, braceColor, spellNameStr, braceColor);
  2846. end
  2847. end
  2848. if ( extraSpellName and settings.spellBraces ) then
  2849. extraSpellNameStr = format(TEXT_MODE_A_STRING_BRACE_SPELL, braceColor, extraSpellNameStr, braceColor);
  2850. end
  2851. -- Build item braces
  2852. if ( itemName and settings.itemBraces ) then
  2853. itemNameStr = format(TEXT_MODE_A_STRING_BRACE_ITEM, braceColor, itemNameStr, braceColor);
  2854. end
  2855. end
  2856. local sourceString = "";
  2857. local spellString = "";
  2858. local actionString = "";
  2859. local destString = "";
  2860. local valueString = "";
  2861. local resultString = "";
  2862. local remainingPointsString = "";
  2863. if ( sourceEnabled and sourceName and falseSource ) then
  2864. sourceString = sourceName;
  2865. elseif ( sourceEnabled and sourceName ) then
  2866. sourceString = format(TEXT_MODE_A_STRING_SOURCE_UNIT, sourceIcon, sourceGUID, sourceName, sourceNameStr);
  2867. end
  2868. if ( spellName ) then
  2869. if ( nameIsNotSpell ) then
  2870. spellString = format(TEXT_MODE_A_STRING_ACTION, originalEvent, spellNameStr);
  2871. else
  2872. spellString = format(TEXT_MODE_A_STRING_SPELL, spellId, originalEvent, spellNameStr, spellId);
  2873. end
  2874. end
  2875. if ( actionString ) then
  2876. actionString = format(TEXT_MODE_A_STRING_ACTION, originalEvent, actionStr);
  2877. end
  2878. if ( destEnabled and destName ) then
  2879. destString = format(TEXT_MODE_A_STRING_DEST_UNIT, destIcon, destGUID, destName, destNameStr);
  2880. end
  2881. if ( valueEnabled ) then
  2882. if ( extraSpellEnabled and extraSpellNameStr ) then
  2883. if ( extraNameIsNotSpell ) then
  2884. valueString = extraSpellNameStr;
  2885. else
  2886. valueString = format(TEXT_MODE_A_STRING_SPELL_EXTRA, extraSpellId, originalEvent, extraSpellNameStr, spellId);
  2887. end
  2888. elseif ( valueIsItem and itemNameStr ) then
  2889. valueString = format(TEXT_MODE_A_STRING_ITEM, itemId, itemNameStr);
  2890. elseif ( amount ) then
  2891. if ( valueTypeEnabled ) then
  2892. if ( valueType == 1 and schoolString ) then
  2893. valueString = format(TEXT_MODE_A_STRING_VALUE_SCHOOL, amount, schoolString);
  2894. elseif ( valueType == 2 and powerTypeString ) then
  2895. valueString = format(TEXT_MODE_A_STRING_VALUE_TYPE, amount, powerTypeString);
  2896. end
  2897. end
  2898. if ( valueString == "" ) then
  2899. valueString = amount;
  2900. end
  2901. end
  2902. end
  2903. if ( resultEnabled and resultStr ) then
  2904. resultString = resultStr;
  2905. end
  2906. if ( not schoolString ) then
  2907. schoolString = "";
  2908. end
  2909. if ( not powerTypeString ) then
  2910. powerTypeString = "";
  2911. end
  2912. if ( not amount ) then
  2913. amount = "";
  2914. end
  2915. if ( not extraAmount) then
  2916. extraAmount = "";
  2917. end
  2918. if ( sourceString == "" and not hideCaster ) then
  2919. sourceString = UNKNOWN;
  2920. end
  2921. if ( destEnabled and destString == "" ) then
  2922. destString = UNKNOWN;
  2923. end
  2924. if ( remainingPoints ) then
  2925. remainingPointsString = format(TEXT_MODE_A_STRING_REMAINING_POINTS, remainingPoints);
  2926. end
  2927. local finalString = format(formatString, sourceString, spellString, actionString, destString, valueString, resultString, schoolString, powerTypeString, amount, extraAmount, remainingPointsString);
  2928. finalString = gsub(finalString, " [ ]+", " " ); -- extra white spaces
  2929. finalString = gsub(finalString, " ([.,])", "%1" ); -- spaces before periods or comma
  2930. finalString = gsub(finalString, "^([ .,]+)", "" ); -- spaces, period or comma at the beginning of a line
  2931. if ( timestampEnabled and timestamp ) then
  2932. -- Replace the timestamp
  2933. finalString = format(TEXT_MODE_A_STRING_TIMESTAMP, date(settings.timestampFormat, timestamp), finalString);
  2934. end
  2935. -- NOTE: be sure to pass back nil for the color id or the color id may override the r, g, b values for this message line
  2936. return finalString, lineColor.r, lineColor.g, lineColor.b;
  2937. end
  2938. _G.CombatLog_OnEvent = CombatLog_OnEvent
  2939. -- Process the event and add it to the combat log
  2940. function CombatLog_AddEvent(...)
  2941. if ( DEBUG == true ) then
  2942. local info = ChatTypeInfo["COMBAT_MISC_INFO"];
  2943. local timestamp, event, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags = ...
  2944. local message = format("%s, %s, %s, 0x%x, %s, %s, 0x%x",
  2945. --date("%H:%M:%S", timestamp),
  2946. event,
  2947. srcGUID, srcName or "nil", srcFlags,
  2948. dstGUID, dstName or "nil", dstFlags);
  2949. for i = 9, select("#", ...) do
  2950. message = message..", "..(select(i, ...) or "nil");
  2951. end
  2952. ChatFrame1:AddMessage(message, info.r, info.g, info.b);
  2953. end
  2954. -- Add the messages
  2955. local text, r, g, b, a = CombatLog_OnEvent(Blizzard_CombatLog_CurrentSettings, ... );
  2956. if ( text ) then
  2957. COMBATLOG:AddMessage(text, r, g, b, a);
  2958. end
  2959. end
  2960. --
  2961. -- Overrides for the combat log
  2962. --
  2963. -- Save the original event handler
  2964. local original_OnEvent = COMBATLOG:GetScript("OnEvent");
  2965. COMBATLOG:SetScript("OnEvent",
  2966. function(self, event, ...)
  2967. if ( event == "COMBAT_LOG_EVENT" ) then
  2968. CombatLog_AddEvent(...);
  2969. return;
  2970. elseif ( event == "COMBAT_LOG_EVENT_UNFILTERED") then
  2971. --[[
  2972. local timestamp, event, srcGUID, srcName, srcFlags, dstGUID, dstName, dstFlags = select(1, ...);
  2973. local message = string.format("%s, %s, %s, 0x%x, %s, %s, 0x%x",
  2974. --date("%H:%M:%S", timestamp),
  2975. event,
  2976. srcGUID, srcName or "nil", srcFlags,
  2977. dstGUID, dstName or "nil", dstFlags);
  2978. for i = 9, select("#", ...) do
  2979. message = message..", "..(select(i, ...) or "nil");
  2980. end
  2981. ChatFrame1:AddMessage(message);
  2982. --COMBATLOG:AddMessage(message);
  2983. ]]
  2984. return;
  2985. else
  2986. original_OnEvent(self, event, ...);
  2987. end
  2988. end
  2989. );
  2990. --COMBATLOG:RegisterEvent("COMBAT_LOG_EVENT");
  2991. --COMBATLOG:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
  2992. --[[
  2993. _G[COMBATLOG:GetName().."Tab"]:SetScript("OnDragStart",
  2994. function(self, event, ...)
  2995. local chatFrame = _G["ChatFrame"..this:GetID()];
  2996. if ( chatFrame == DEFAULT_CHAT_FRAME ) then
  2997. if (chatFrame.isLocked) then
  2998. return;
  2999. end
  3000. chatFrame:StartMoving();
  3001. MOVING_CHATFRAME = chatFrame;
  3002. return;
  3003. elseif ( chatFrame.isDocked ) then
  3004. FCF_UnDockFrame(chatFrame);
  3005. FCF_SetLocked(chatFrame, nil);
  3006. local chatTab = _G[chatFrame:GetName().."Tab"];
  3007. local x,y = chatTab:GetCenter();
  3008. if ( x and y ) then
  3009. x = x - (chatTab:GetWidth()/2);
  3010. y = y - (chatTab:GetHeight()/2);
  3011. chatTab:ClearAllPoints();
  3012. chatFrame:ClearAllPoints();
  3013. chatFrame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", x, y - CombatLogQuickButtonFrame:GetHeight());
  3014. end
  3015. FCF_SetTabPosition(chatFrame, 0);
  3016. chatFrame:StartMoving();
  3017. MOVING_CHATFRAME = chatFrame;
  3018. end
  3019. SELECTED_CHAT_FRAME = chatFrame;
  3020. end
  3021. );
  3022. ]]--
  3023. --
  3024. -- XML Function Overrides Part 2
  3025. --
  3026. --
  3027. -- Attach the Combat Log Button Frame to the Combat Log
  3028. --
  3029. -- On Event
  3030. function Blizzard_CombatLog_QuickButtonFrame_OnEvent(self, event, ...)
  3031. local arg1 = ...;
  3032. if ( event == "ADDON_LOADED" ) then
  3033. if ( arg1 == "Blizzard_CombatLog" ) then
  3034. Blizzard_CombatLog_Filters = _G.Blizzard_CombatLog_Filters or Blizzard_CombatLog_Filters
  3035. Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.filters[1];
  3036. _G.Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_CurrentSettings;
  3037. Blizzard_CombatLog_QuickButton_OnClick( Blizzard_CombatLog_Filters.currentFilter );
  3038. Blizzard_CombatLog_Refilter();
  3039. for k,v in pairs (Blizzard_CombatLog_UnitTokens) do
  3040. Blizzard_CombatLog_UnitTokens[k] = nil;
  3041. end
  3042. Blizzard_CombatLog_Update_QuickButtons();
  3043. --Hide the quick button frame if chatframe1 is selected and the combat log is docked
  3044. if ( COMBATLOG.isDocked and SELECTED_CHAT_FRAME == ChatFrame1 ) then
  3045. self:Hide();
  3046. end
  3047. end
  3048. end
  3049. end
  3050. -- BUG: Since we're futzing with the frame height, the combat log tab fades out on hover while other tabs remain faded in. This bug is in the stock version, as well.
  3051. local function Blizzard_CombatLog_AdjustCombatLogHeight()
  3052. -- This prevents improper positioning of the frame due to the scale not yet being set.
  3053. -- This whole method of resizing the frame and extending the background to preserve visual continuity really screws with repositioning after
  3054. -- a reload. I'm not sure it's going to work well in the long run.
  3055. local uiScale = tonumber(GetCVar("uiScale"));
  3056. --if UIParent:GetScale() ~= uiScale then return end
  3057. local quickButtonHeight = CombatLogQuickButtonFrame:GetHeight();
  3058. if ( COMBATLOG.isDocked ) then
  3059. local oldPoint,relativeTo,relativePoint,xOfs,yOfs;
  3060. for i=1, COMBATLOG:GetNumPoints() do
  3061. oldPoint,relativeTo,relativePoint,xOfs,yOfs = COMBATLOG:GetPoint(i);
  3062. if ( oldPoint == "TOPLEFT" ) then
  3063. break;
  3064. end
  3065. end
  3066. COMBATLOG:SetPoint("TOPLEFT", relativeTo, relativePoint, xOfs/uiScale, -quickButtonHeight);
  3067. end
  3068. local yOffset = (3 + quickButtonHeight*uiScale) / uiScale;
  3069. local xOffset = 2 / uiScale;
  3070. local combatLogBackground = _G[COMBATLOG:GetName().."Background"];
  3071. combatLogBackground:SetPoint("TOPLEFT", COMBATLOG, "TOPLEFT", -xOffset, yOffset);
  3072. combatLogBackground:SetPoint("TOPRIGHT", COMBATLOG, "TOPRIGHT", xOffset, yOffset);
  3073. end
  3074. -- On Load
  3075. local hooksSet = false
  3076. function Blizzard_CombatLog_QuickButtonFrame_OnLoad(self)
  3077. self:RegisterEvent("ADDON_LOADED");
  3078. -- We're using the _Custom suffix to get around the show/hide bug in FloatingChatFrame.lua.
  3079. -- Once the fading is removed from FloatingChatFrame.lua these can do back to the non-custom values, and the dummy frame creation should be removed.
  3080. CombatLogQuickButtonFrame = _G.CombatLogQuickButtonFrame_Custom
  3081. CombatLogQuickButtonFrameProgressBar = _G.CombatLogQuickButtonFrame_CustomProgressBar
  3082. CombatLogQuickButtonFrameTexture = _G.CombatLogQuickButtonFrame_CustomTexture
  3083. -- Parent it to the tab so that we just inherit the tab's alpha. No need to do special fading for it.
  3084. CombatLogQuickButtonFrame:SetParent(COMBATLOG:GetName() .. "Tab");
  3085. CombatLogQuickButtonFrame:ClearAllPoints();
  3086. CombatLogQuickButtonFrame:SetPoint("BOTTOMLEFT", COMBATLOG, "TOPLEFT");
  3087. CombatLogQuickButtonFrame:SetPoint("BOTTOMRIGHT", COMBATLOG, "TOPRIGHT");
  3088. CombatLogQuickButtonFrameProgressBar:Hide();
  3089. -- Hook the frame's hide/show events so we can hide/show the quick buttons as appropriate.
  3090. local show, hide = COMBATLOG:GetScript("OnShow"), COMBATLOG:GetScript("OnHide")
  3091. COMBATLOG:SetScript("OnShow", function(self)
  3092. CombatLogQuickButtonFrame_Custom:Show()
  3093. --Blizzard_CombatLog_AdjustCombatLogHeight()
  3094. COMBATLOG:RegisterEvent("COMBAT_LOG_EVENT");
  3095. -- select a filter for the user only the first time it's shown
  3096. if ( not self.loaded ) then
  3097. Blizzard_CombatLog_QuickButton_OnClick(Blizzard_CombatLog_Filters.currentFilter);
  3098. self.loaded = true;
  3099. end
  3100. return show and show(self)
  3101. end)
  3102. COMBATLOG:SetScript("OnHide", function(self)
  3103. CombatLogQuickButtonFrame_Custom:Hide()
  3104. -- Blizzard_CombatLog_AdjustCombatLogHeight()
  3105. COMBATLOG:UnregisterEvent("COMBAT_LOG_EVENT");
  3106. return hide and hide(self)
  3107. end)
  3108. if ( COMBATLOG:IsShown() ) then
  3109. COMBATLOG:RegisterEvent("COMBAT_LOG_EVENT");
  3110. end
  3111. FCF_SetButtonSide(COMBATLOG, COMBATLOG.buttonSide, true);
  3112. end
  3113. local oldFCF_DockUpdate = FCF_DockUpdate;
  3114. FCF_DockUpdate = function()
  3115. oldFCF_DockUpdate();
  3116. Blizzard_CombatLog_AdjustCombatLogHeight();
  3117. end
  3118. --
  3119. -- Combat Log Global Functions
  3120. --
  3121. --[[
  3122. --
  3123. -- Returns the correct {} code for the combat log bit
  3124. --
  3125. -- args:
  3126. -- bit - a bit exactly equal to a raid target icon.
  3127. --]]
  3128. local function Blizzard_CombatLog_BitToBraceCode(bit)
  3129. if ( bit == COMBATLOG_OBJECT_RAIDTARGET1 ) then
  3130. return "{"..strlower(RAID_TARGET_1).."}";
  3131. elseif ( bit == COMBATLOG_OBJECT_RAIDTARGET2 ) then
  3132. return "{"..strlower(RAID_TARGET_2).."}";
  3133. elseif ( bit == COMBATLOG_OBJECT_RAIDTARGET3 ) then
  3134. return "{"..strlower(RAID_TARGET_3).."}";
  3135. elseif ( bit == COMBATLOG_OBJECT_RAIDTARGET4 ) then
  3136. return "{"..strlower(RAID_TARGET_4).."}";
  3137. elseif ( bit == COMBATLOG_OBJECT_RAIDTARGET5 ) then
  3138. return "{"..strlower(RAID_TARGET_5).."}";
  3139. elseif ( bit == COMBATLOG_OBJECT_RAIDTARGET6 ) then
  3140. return "{"..strlower(RAID_TARGET_6).."}";
  3141. elseif ( bit == COMBATLOG_OBJECT_RAIDTARGET7 ) then
  3142. return "{"..strlower(RAID_TARGET_7).."}";
  3143. elseif ( bit == COMBATLOG_OBJECT_RAIDTARGET8 ) then
  3144. return "{"..strlower(RAID_TARGET_8).."}";
  3145. end
  3146. return "";
  3147. end
  3148. -- Override Hyperlink Handlers
  3149. -- The SetItemRef() function hook is to be moved out into the core FrameXML.
  3150. -- It is currently in the Constants.lua stub file to simulate being moved out to the core.
  3151. --
  3152. -- The reason is because Blizzard_CombatLog is a LoD addon and can be replaced by the user
  3153. -- If the functionality of these new unit/icon/spell/action links is not in the core FrameXML
  3154. -- file in ItemRef.lua, then every combat log addon that replaces Blizzard_CombatLog must
  3155. -- provide the same functionality.
  3156. -- Players may also get all sorts of errors on trying to click on these new linktypes before
  3157. -- Blizzard_CombatLog gets loaded.
  3158. -- Override Hyperlink Handlers
  3159. -- This entire function hook should/must be directly integrated into ItemRef.lua
  3160. -- The reason is because Blizzard_CombatLog is a LoD addon and can be replaced by the user
  3161. -- If the functionality of these new unit/icon/spell/action links is not in the core FrameXML
  3162. -- file in ItemRef.lua, then every combat log addon that replaces Blizzard_CombatLog must
  3163. -- provide the same functionality.
  3164. -- Players may also get all sorts of errors on trying to click on these new linktypes before
  3165. -- Blizzard_CombatLog gets loaded.
  3166. local oldSetItemRef = SetItemRef;
  3167. function SetItemRef(link, text, button, chatFrame)
  3168. if ( strsub(link, 1, 4) == "unit") then
  3169. local _, guid, name = strsplit(":", link);
  3170. if ( IsModifiedClick("CHATLINK") ) then
  3171. ChatEdit_InsertLink (name);
  3172. return;
  3173. elseif( button == "RightButton") then
  3174. -- Show Popup Menu
  3175. EasyMenu(Blizzard_CombatLog_CreateUnitMenu(name, guid), CombatLogDropDown, "cursor", nil, nil, "MENU");
  3176. return;
  3177. end
  3178. elseif ( strsub(link, 1, 4) == "icon") then
  3179. local _, bit, direction = strsplit(":", link);
  3180. local texture = string.gsub(text,".*|h(.*)|h.*","%1");
  3181. -- Show Popup Menu
  3182. if( button == "RightButton") then
  3183. -- need to fix this to be actual texture
  3184. EasyMenu(Blizzard_CombatLog_CreateUnitMenu(Blizzard_CombatLog_BitToBraceCode(tonumber(bit)), nil, tonumber(bit)), CombatLogDropDown, "cursor", nil, nil, "MENU");
  3185. elseif ( IsModifiedClick("CHATLINK") ) then
  3186. ChatEdit_InsertLink (Blizzard_CombatLog_BitToBraceCode(tonumber(bit)));
  3187. end
  3188. return;
  3189. elseif ( strsub(link, 1,5) == "spell" ) then
  3190. local _, spellId, event = strsplit(":", link);
  3191. spellId = tonumber (spellId);
  3192. if ( IsModifiedClick("CHATLINK") ) then
  3193. if ( spellId > 0 ) then
  3194. if ( ChatEdit_InsertLink(GetSpellLink(spellId)) ) then
  3195. return;
  3196. end
  3197. else
  3198. return;
  3199. end
  3200. -- Show Popup Menu
  3201. elseif( button == "RightButton" and event ) then
  3202. EasyMenu(Blizzard_CombatLog_CreateSpellMenu(text, spellId, event), CombatLogDropDown, "cursor", nil, nil, "MENU");
  3203. return;
  3204. end
  3205. elseif ( strsub(link, 1,6) == "action" ) then
  3206. local _, event = strsplit(":", link);
  3207. -- Show Popup Menu
  3208. if( button == "RightButton") then
  3209. EasyMenu(Blizzard_CombatLog_CreateActionMenu(event), CombatLogDropDown, "cursor", nil, nil, "MENU");
  3210. end
  3211. return;
  3212. elseif ( strsub(link, 1, 4) == "item") then
  3213. if ( IsModifiedClick("CHATLINK") ) then
  3214. local name, link = GetItemInfo(text);
  3215. ChatEdit_InsertLink (link);
  3216. return;
  3217. end
  3218. end
  3219. oldSetItemRef(link, text, button, chatFrame);
  3220. end
  3221. function Blizzard_CombatLog_Update_QuickButtons()
  3222. local baseName = "CombatLogQuickButtonFrame";
  3223. local buttonName, button, textWidth;
  3224. local buttonIndex = 1;
  3225. -- subtract the width of the dropdown button
  3226. local clogleft, clogright = COMBATLOG:GetRight(), COMBATLOG:GetLeft();
  3227. local maxWidth;
  3228. if ( clogleft and clogright ) then
  3229. maxWidth = (COMBATLOG:GetRight()-COMBATLOG:GetLeft())-31; --Hacky hacky because GetWidth goes crazy when it is docked
  3230. else
  3231. maxWidth = COMBATLOG:GetWidth() - 31;
  3232. end
  3233. local totalWidth = 0;
  3234. local padding = 13;
  3235. local showMoreQuickButtons = true;
  3236. for index, filter in ipairs(_G.Blizzard_CombatLog_Filters.filters) do
  3237. buttonName = baseName.."Button"..buttonIndex;
  3238. button = _G[buttonName];
  3239. if ( ShowQuickButton(filter) and showMoreQuickButtons ) then
  3240. if ( not button ) then
  3241. button = CreateFrame("BUTTON", buttonName, CombatLogQuickButtonFrame, "CombatLogQuickButtonTemplate");
  3242. end
  3243. button:SetText(filter.name);
  3244. textWidth = button:GetTextWidth();
  3245. totalWidth = totalWidth + textWidth + padding;
  3246. if ( totalWidth <= maxWidth ) then
  3247. button:SetWidth(textWidth+padding);
  3248. button:SetID(index);
  3249. button:Show();
  3250. button.tooltip = filter.tooltip;
  3251. if ( buttonIndex > 1 ) then
  3252. button:SetPoint("LEFT", _G[baseName.."Button"..buttonIndex-1], "RIGHT", 3, 0);
  3253. else
  3254. button:SetPoint("LEFT", CombatLogQuickButtonFrame, "LEFT", 3, 0);
  3255. end
  3256. if ( Blizzard_CombatLog_Filters.currentFilter == index and (Blizzard_CombatLog_CurrentSettings and not Blizzard_CombatLog_CurrentSettings.isTemp) ) then
  3257. button:LockHighlight();
  3258. else
  3259. button:UnlockHighlight();
  3260. end
  3261. filter.onQuickBar = true;
  3262. else
  3263. -- Don't show anymore buttons if the maxwidth has been exceeded
  3264. showMoreQuickButtons = false;
  3265. button:Hide();
  3266. filter.onQuickBar = false;
  3267. end
  3268. buttonIndex = buttonIndex + 1;
  3269. else
  3270. filter.onQuickBar = false;
  3271. if ( button ) then
  3272. button:Hide();
  3273. end
  3274. end
  3275. end
  3276. -- Hide remaining buttons
  3277. repeat
  3278. button = _G[baseName.."Button"..buttonIndex];
  3279. if ( button ) then
  3280. button:Hide();
  3281. end
  3282. buttonIndex = buttonIndex+1;
  3283. until not button;
  3284. end
  3285. _G.Blizzard_CombatLog_Update_QuickButtons = Blizzard_CombatLog_Update_QuickButtons
  3286. function Blizzard_CombatLog_QuickButton_OnClick(id)
  3287. Blizzard_CombatLog_Filters.currentFilter = id;
  3288. Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.filters[Blizzard_CombatLog_Filters.currentFilter];
  3289. Blizzard_CombatLog_ApplyFilters(Blizzard_CombatLog_CurrentSettings);
  3290. if ( Blizzard_CombatLog_CurrentSettings.settings.showHistory ) then
  3291. Blizzard_CombatLog_Refilter();
  3292. end
  3293. Blizzard_CombatLog_Update_QuickButtons();
  3294. PlaySound("UChatScrollButton");
  3295. end
  3296. function ShowQuickButton(filter)
  3297. if ( filter.hasQuickButton ) then
  3298. if ( IsInRaid() ) then
  3299. return filter.quickButtonDisplay.raid;
  3300. elseif ( IsInGroup() ) then
  3301. return filter.quickButtonDisplay.party;
  3302. else
  3303. return filter.quickButtonDisplay.solo;
  3304. end
  3305. else
  3306. return false;
  3307. end;
  3308. end
  3309. function Blizzard_CombatLog_RefreshGlobalLinks()
  3310. -- Have to do this because Blizzard_CombatLog_Filters is a reference to the _G.Blizzard_CombatLog_Filters
  3311. Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.filters[Blizzard_CombatLog_Filters.currentFilter];
  3312. end