From 070aa48b8650ce2c99141487ea4f75a41bbdc476 Mon Sep 17 00:00:00 2001 From: Aaron-onVBH Date: Sun, 15 Nov 2020 16:41:52 -0500 Subject: [PATCH 1/9] upping version number for 9.0.1 --- EavesDrop.toc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EavesDrop.toc b/EavesDrop.toc index 5cdd547..2f348fa 100644 --- a/EavesDrop.toc +++ b/EavesDrop.toc @@ -1,4 +1,4 @@ -## Interface: 80000 +## Interface: 90001 ## Name: EavesDrop ## Title: EavesDrop ## Notes: A simple combat log that displays events similar to SCT From 0b7e89aac630be5ba1d1909b95fe466440e556ea Mon Sep 17 00:00:00 2001 From: Aaron-onVBH Date: Sat, 12 Dec 2020 12:20:04 -0500 Subject: [PATCH 2/9] background / frame fix --- EavesDrop.lua | 1705 +++++++++++++++++++++++--------------------- EavesDrop.xml | 21 +- EavesDropStats.lua | 6 +- 3 files changed, 923 insertions(+), 809 deletions(-) diff --git a/EavesDrop.lua b/EavesDrop.lua index ec16338..830c9da 100644 --- a/EavesDrop.lua +++ b/EavesDrop.lua @@ -6,9 +6,9 @@ from Andalia`s SideCombatLog and CombatChat. Notes: Code comments coming at a later time. - ****************************************************************]] - -EavesDrop = LibStub("AceAddon-3.0"):NewAddon("EavesDrop", "AceEvent-3.0", "AceConsole-3.0", "AceTimer-3.0") + ****************************************************************]] EavesDrop = + LibStub("AceAddon-3.0"):NewAddon("EavesDrop", "AceEvent-3.0", + "AceConsole-3.0", "AceTimer-3.0") local EavesDrop = EavesDrop local db @@ -19,14 +19,14 @@ local OUTGOING = 1 local INCOMING = -1 local MISC = 3 -local critchar = "*" +local critchar = "*" local deathchar = "†" local crushchar = "^" local glancechar = "~" local newhigh = "|cffffff00!|r" local arrEventData = {} -local arrEventFrames = {} +local arrEventFrames = {} local frameSize = 21 local arrSize = 10 local arrDisplaySize = 20 @@ -41,7 +41,7 @@ local timeStart = 0 local curTime = 0 local lastTime = 0 ---LUA calls +-- LUA calls local _G = _G local tonumber = tonumber local strsub = strsub @@ -51,67 +51,67 @@ local gsub = gsub local tremove = tremove local tinsert = tinsert local function string_nil(val) - if val then - return val - else - return UNKNOWN - end + if val then + return val + else + return UNKNOWN + end end ---API calls +-- API calls local UnitName = UnitName local UnitXP = UnitXP local GetSpellInfo = GetSpellInfo local GetTime = GetTime local InCombatLockdown = InCombatLockdown ---Combat log locals +-- Combat log locals local pxp = UnitXP("player") -local skillmsg = gsub(gsub(gsub(SKILL_RANK_UP, '%d%$', ''), '%%s', '(.+)'), '%%d', '(%%d+)') +local skillmsg = gsub(gsub(gsub(SKILL_RANK_UP, '%d%$', ''), '%%s', '(.+)'), + '%%d', '(%%d+)') local CombatLog_Object_IsA = CombatLog_Object_IsA local Blizzard_CombatLog_CurrentSettings local COMBATLOG_OBJECT_NONE = COMBATLOG_OBJECT_NONE local COMBATLOG_FILTER_MINE = COMBATLOG_FILTER_MINE local COMBATLOG_FILTER_MY_PET = COMBATLOG_FILTER_MY_PET -local COMBATLOG_FILTER_HOSTILE = bit.bor( - COMBATLOG_FILTER_HOSTILE_PLAYERS, - COMBATLOG_FILTER_HOSTILE_UNITS) +local COMBATLOG_FILTER_HOSTILE = bit.bor(COMBATLOG_FILTER_HOSTILE_PLAYERS, + COMBATLOG_FILTER_HOSTILE_UNITS) local COMBAT_EVENTS = { - ["SWING_DAMAGE"] = "DAMAGE", - ["RANGE_DAMAGE"] = "DAMAGE", - ["SPELL_DAMAGE"] = "DAMAGE", - ["SPELL_PERIODIC_DAMAGE"] = "DAMAGE", - ["ENVIRONMENTAL_DAMAGE"] = "DAMAGE", - ["DAMAGE_SHIELD"] = "DAMAGE", - ["DAMAGE_SPLIT"] = "DAMAGE", - ["SPELL_HEAL"] = "HEAL", - ["SPELL_PERIODIC_HEAL"] = "HEAL", - ["SWING_MISSED"] = "MISS", - ["RANGE_MISSED"] = "MISS", - ["SPELL_MISSED"] = "MISS", - ["SPELL_PERIODIC_MISSED"] = "MISS", - ["DAMAGE_SHIELD_MISSED"] = "MISS", - ["SPELL_DRAIN"] = "DRAIN", - ["SPELL_LEECH"] = "DRAIN", - ["SPELL_PERIODIC_DRAIN"] = "DRAIN", - ["SPELL_PERIODIC_LEECH"] = "DRAIN", - ["SPELL_ENERGIZE"] = "POWER", - ["SPELL_PERIODIC_ENERGIZE"] = "POWER", - ["PARTY_KILL"] = "DEATH", - ["UNIT_DIED"] = "DEATH", - ["UNIT_DESTROYED"] = "DEATH", + ["SWING_DAMAGE"] = "DAMAGE", + ["RANGE_DAMAGE"] = "DAMAGE", + ["SPELL_DAMAGE"] = "DAMAGE", + ["SPELL_PERIODIC_DAMAGE"] = "DAMAGE", + ["ENVIRONMENTAL_DAMAGE"] = "DAMAGE", + ["DAMAGE_SHIELD"] = "DAMAGE", + ["DAMAGE_SPLIT"] = "DAMAGE", + ["SPELL_HEAL"] = "HEAL", + ["SPELL_PERIODIC_HEAL"] = "HEAL", + ["SWING_MISSED"] = "MISS", + ["RANGE_MISSED"] = "MISS", + ["SPELL_MISSED"] = "MISS", + ["SPELL_PERIODIC_MISSED"] = "MISS", + ["DAMAGE_SHIELD_MISSED"] = "MISS", + ["SPELL_DRAIN"] = "DRAIN", + ["SPELL_LEECH"] = "DRAIN", + ["SPELL_PERIODIC_DRAIN"] = "DRAIN", + ["SPELL_PERIODIC_LEECH"] = "DRAIN", + ["SPELL_ENERGIZE"] = "POWER", + ["SPELL_PERIODIC_ENERGIZE"] = "POWER", + ["PARTY_KILL"] = "DEATH", + ["UNIT_DIED"] = "DEATH", + ["UNIT_DESTROYED"] = "DEATH" } local SCHOOL_STRINGS = { - [SCHOOL_MASK_PHYSICAL] = SPELL_SCHOOL0_CAP, - [SCHOOL_MASK_HOLY] = SPELL_SCHOOL1_CAP, - [SCHOOL_MASK_FIRE] = SPELL_SCHOOL2_CAP, - [SCHOOL_MASK_NATURE] = SPELL_SCHOOL3_CAP, - [SCHOOL_MASK_FROST] = SPELL_SCHOOL4_CAP, - [SCHOOL_MASK_SHADOW] = SPELL_SCHOOL5_CAP, - [SCHOOL_MASK_ARCANE] = SPELL_SCHOOL6_CAP, + [SCHOOL_MASK_PHYSICAL] = SPELL_SCHOOL0_CAP, + [SCHOOL_MASK_HOLY] = SPELL_SCHOOL1_CAP, + [SCHOOL_MASK_FIRE] = SPELL_SCHOOL2_CAP, + [SCHOOL_MASK_NATURE] = SPELL_SCHOOL3_CAP, + [SCHOOL_MASK_FROST] = SPELL_SCHOOL4_CAP, + [SCHOOL_MASK_SHADOW] = SPELL_SCHOOL5_CAP, + [SCHOOL_MASK_ARCANE] = SPELL_SCHOOL6_CAP } --[[local POWER_STRINGS = { @@ -135,937 +135,1042 @@ local SCHOOL_STRINGS = { [SPELL_POWER_PAIN] = PAIN, }]] ---set table default size sense table.insert no longer does -for i=1, arrMaxSize do - arrEventData[i] = {} -end +-- set table default size sense table.insert no longer does +for i = 1, arrMaxSize do arrEventData[i] = {} end local function convertRGBtoHEXString(color, text) - return string_format("|cFF%02x%02x%02x%s|r", ceil(color.r * 255), ceil(color.g * 255), ceil(color.b * 255), text) + return string_format("|cFF%02x%02x%02x%s|r", ceil(color.r * 255), + ceil(color.g * 255), ceil(color.b * 255), text) end local function shortenValue(value) - if value >= 10000000 then - value = string_format("%.1fm", value / 1000000) - elseif value >= 1000000 then - value = string_format("%.2fm",value / 1000000) - elseif value >= 100000 then - value = string_format("%.0fk",value / 1000) - elseif value >= 10000 then - value = string_format("%.1fk",value / 1000) - end - return value + if value >= 10000000 then + value = string_format("%.1fm", value / 1000000) + elseif value >= 1000000 then + value = string_format("%.2fm", value / 1000000) + elseif value >= 100000 then + value = string_format("%.0fk", value / 1000) + elseif value >= 10000 then + value = string_format("%.1fk", value / 1000) + end + return value end local function round(num, idp) - return tonumber(string_format("%." .. (idp or 0) .. "f", num)) + return tonumber(string_format("%." .. (idp or 0) .. "f", num)) end local function cleanstring(s) - s = gsub(s, "|r", "") - s = gsub(s, "|c........", "") - s = gsub(s, "|Hunit:%a+%-[^|]+|h", "") - s = gsub(s, "|Haction:([%w_*]*)|h", "") - s = gsub(s, "|Hitem:(%d+)|h", "") - s = gsub(s, "|Hicon:%d+:dest|h", "") - s = gsub(s, "|Hicon:%d+:source|h", "") - s = gsub(s, "|Hspell:%d+:%d+:([%w_*]*)|h", "") - s = gsub(s, "|TInterface.TargetingFrame.UI.RaidTargetingIcon.%d.blp:0|t", "") - s = gsub(s, "|h", "") - s = gsub(s, "\n", ", ") - s = gsub(s, "\124", "\124\124") - s=s:gsub("[\r\n]+"," ") - return s + s = gsub(s, "|r", "") + s = gsub(s, "|c........", "") + s = gsub(s, "|Hunit:%a+%-[^|]+|h", "") + s = gsub(s, "|Haction:([%w_*]*)|h", "") + s = gsub(s, "|Hitem:(%d+)|h", "") + s = gsub(s, "|Hicon:%d+:dest|h", "") + s = gsub(s, "|Hicon:%d+:source|h", "") + s = gsub(s, "|Hspell:%d+:%d+:([%w_*]*)|h", "") + s = + gsub(s, "|TInterface.TargetingFrame.UI.RaidTargetingIcon.%d.blp:0|t", "") + s = gsub(s, "|h", "") + s = gsub(s, "\n", ", ") + s = gsub(s, "\124", "\124\124") + s = s:gsub("[\r\n]+", " ") + return s end local function clearSummary() - totDamageIn = 0 - totDamageOut = 0 - totHealingIn = 0 - totHealingOut = 0 + totDamageIn = 0 + totDamageOut = 0 + totHealingIn = 0 + totHealingOut = 0 end ---Main Functions +-- Main Functions function EavesDrop:OnInitialize() - --setup table for display frame objects - for i=1, arrDisplaySize do - arrEventFrames[i] = {} - arrEventFrames[i].frame = _G[string_format("EavesDropEvent%d", i)] - arrEventFrames[i].text = _G[string_format("EavesDropEvent%dEventText", i)] - arrEventFrames[i].intexture = _G[string_format("EavesDropEvent%dIncomingTexture", i)] - arrEventFrames[i].intextureframe = _G[string_format("EavesDropEvent%dIncoming", i)] - arrEventFrames[i].outtexture = _G[string_format("EavesDropEvent%dOutgoingTexture", i)] - arrEventFrames[i].outtextureframe = _G[string_format("EavesDropEvent%dOutgoing", i)] - end - - self.db = LibStub("AceDB-3.0"):New("EavesDropDB", self:GetDefaultConfig()) - self.chardb = LibStub("AceDB-3.0"):New("EavesDropStatsDB", {profile = {[OUTGOING] = {},[INCOMING] = {}}}) + -- setup table for display frame objects + for i = 1, arrDisplaySize do + arrEventFrames[i] = {} + arrEventFrames[i].frame = _G[string_format("EavesDropEvent%d", i)] + arrEventFrames[i].text = + _G[string_format("EavesDropEvent%dEventText", i)] + arrEventFrames[i].intexture = _G[string_format( + "EavesDropEvent%dIncomingTexture", i)] + arrEventFrames[i].intextureframe = + _G[string_format("EavesDropEvent%dIncoming", i)] + arrEventFrames[i].outtexture = _G[string_format( + "EavesDropEvent%dOutgoingTexture", i)] + arrEventFrames[i].outtextureframe = + _G[string_format("EavesDropEvent%dOutgoing", i)] + end - self:SetupOptions() + self.db = LibStub("AceDB-3.0"):New("EavesDropDB", self:GetDefaultConfig()) + self.chardb = LibStub("AceDB-3.0"):New("EavesDropStatsDB", { + profile = {[OUTGOING] = {}, [INCOMING] = {}} + }) - --callbacks for profile changes - self.db.RegisterCallback(self, "OnProfileChanged", "UpdateFrame") - self.db.RegisterCallback(self, "OnProfileCopied", "UpdateFrame") - self.db.RegisterCallback(self, "OnProfileReset", "UpdateFrame") + self:SetupOptions() - --local the profile table - db = self.db.profile + -- callbacks for profile changes + self.db.RegisterCallback(self, "OnProfileChanged", "UpdateFrame") + self.db.RegisterCallback(self, "OnProfileCopied", "UpdateFrame") + self.db.RegisterCallback(self, "OnProfileReset", "UpdateFrame") - self:PerformDisplayOptions() + -- local the profile table + db = self.db.profile + self:PerformDisplayOptions() - self:RegisterEvent("ADDON_LOADED", self.SetFonts) + self:RegisterEvent("ADDON_LOADED", self.SetFonts) end function EavesDrop:OnEnable() - self:RegisterEvent("PLAYER_DEAD") - self:UpdateExpEvents() - self:UpdateRepHonorEvents() - self:UpdateCombatEvents() - self:UpdateBuffEvents() - self:UpdateBuffFadeEvents() - self:UpdateSkillEvents() - - self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED","CombatEvent") - - --show frame - EavesDropFrame:Show() - if (db["FADEFRAME"]) then - self:HideFrame() - end + self:RegisterEvent("PLAYER_DEAD") + self:UpdateExpEvents() + self:UpdateRepHonorEvents() + self:UpdateCombatEvents() + self:UpdateBuffEvents() + self:UpdateBuffFadeEvents() + self:UpdateSkillEvents() + + self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED", "CombatEvent") + + -- show frame + EavesDropFrame:Show() + if (db["FADEFRAME"]) then self:HideFrame() end end function EavesDrop:OnDisable() - self:UnregisterAllEvents() - EavesDropFrame:Hide() + self:UnregisterAllEvents() + EavesDropFrame:Hide() end function EavesDrop:UpdateCombatEvents() - if (db["COMBAT"] == true) then - self:RegisterEvent("PLAYER_REGEN_DISABLED") - self:RegisterEvent("PLAYER_REGEN_ENABLED") - else - self:UnregisterEvent("PLAYER_REGEN_DISABLED") - self:UnregisterEvent("PLAYER_REGEN_ENABLED") - end + if (db["COMBAT"] == true) then + self:RegisterEvent("PLAYER_REGEN_DISABLED") + self:RegisterEvent("PLAYER_REGEN_ENABLED") + else + self:UnregisterEvent("PLAYER_REGEN_DISABLED") + self:UnregisterEvent("PLAYER_REGEN_ENABLED") + end end function EavesDrop:UpdateExpEvents() - if (db["EXP"] == true) then - self:RegisterEvent("PLAYER_XP_UPDATE") - else - self:UnregisterEvent("PLAYER_XP_UPDATE") - end + if (db["EXP"] == true) then + self:RegisterEvent("PLAYER_XP_UPDATE") + else + self:UnregisterEvent("PLAYER_XP_UPDATE") + end end function EavesDrop:UpdateRepHonorEvents() - if (db["REP"] or db["HONOR"]) then - self:RegisterEvent("COMBAT_TEXT_UPDATE") - else - self:UnregisterEvent("COMBAT_TEXT_UPDATE") - end + if (db["REP"] or db["HONOR"]) then + self:RegisterEvent("COMBAT_TEXT_UPDATE") + else + self:UnregisterEvent("COMBAT_TEXT_UPDATE") + end end function EavesDrop:UpdateBuffEvents() - if (db["DEBUFF"] == true or db["BUFF"] == true) then - COMBAT_EVENTS["SPELL_AURA_APPLIED"] = "BUFF" - COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED"] = "BUFF" - COMBAT_EVENTS["SPELL_AURA_APPLIED_DOSE"] = "BUFF" - COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED_DOSE"] = "BUFF" - COMBAT_EVENTS["ENCHANT_APPLIED"] = "ENCHANT_APPLIED" - else - COMBAT_EVENTS["SPELL_AURA_APPLIED"] = nil - COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED"] = nil - COMBAT_EVENTS["SPELL_AURA_APPLIED_DOSE"] = nil - COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED_DOSE"] = nil - COMBAT_EVENTS["ENCHANT_APPLIED"] = nil - end + if (db["DEBUFF"] == true or db["BUFF"] == true) then + COMBAT_EVENTS["SPELL_AURA_APPLIED"] = "BUFF" + COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED"] = "BUFF" + COMBAT_EVENTS["SPELL_AURA_APPLIED_DOSE"] = "BUFF" + COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED_DOSE"] = "BUFF" + COMBAT_EVENTS["ENCHANT_APPLIED"] = "ENCHANT_APPLIED" + else + COMBAT_EVENTS["SPELL_AURA_APPLIED"] = nil + COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED"] = nil + COMBAT_EVENTS["SPELL_AURA_APPLIED_DOSE"] = nil + COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED_DOSE"] = nil + COMBAT_EVENTS["ENCHANT_APPLIED"] = nil + end end function EavesDrop:UpdateBuffFadeEvents() - if (db["DEBUFFFADE"] == true or db["BUFFFADE"] == true) then - COMBAT_EVENTS["SPELL_AURA_REMOVED"] = "FADE" - COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED"] = "FADE" - COMBAT_EVENTS["SPELL_AURA_REMOVED_DOSE"] = "FADE" - COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED_DOSE"] = "FADE" - COMBAT_EVENTS["ENCHANT_REMOVED"] = "ENCHANT_REMOVED" - else - COMBAT_EVENTS["SPELL_AURA_REMOVED"] = nil - COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED"] = nil - COMBAT_EVENTS["SPELL_AURA_REMOVED_DOSE"] = nil - COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED_DOSE"] = nil - COMBAT_EVENTS["ENCHANT_REMOVED"] = nil - end + if (db["DEBUFFFADE"] == true or db["BUFFFADE"] == true) then + COMBAT_EVENTS["SPELL_AURA_REMOVED"] = "FADE" + COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED"] = "FADE" + COMBAT_EVENTS["SPELL_AURA_REMOVED_DOSE"] = "FADE" + COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED_DOSE"] = "FADE" + COMBAT_EVENTS["ENCHANT_REMOVED"] = "ENCHANT_REMOVED" + else + COMBAT_EVENTS["SPELL_AURA_REMOVED"] = nil + COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED"] = nil + COMBAT_EVENTS["SPELL_AURA_REMOVED_DOSE"] = nil + COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED_DOSE"] = nil + COMBAT_EVENTS["ENCHANT_REMOVED"] = nil + end end function EavesDrop:UpdateSkillEvents() - if (db["SKILL"] == true) then - self:RegisterEvent("CHAT_MSG_SKILL") - else - self:UnregisterEvent("CHAT_MSG_SKILL") - end + if (db["SKILL"] == true) then + self:RegisterEvent("CHAT_MSG_SKILL") + else + self:UnregisterEvent("CHAT_MSG_SKILL") + end end ---------------------- ---Reset everything to default +-- Reset everything to default function EavesDrop:UpdateFrame() - --local the profile table - db = self.db.profile - self:UpdateExpEvents() - self:UpdateRepHonorEvents() - self:UpdateCombatEvents() - self:UpdateBuffEvents() - self:UpdateBuffFadeEvents() - self:UpdateSkillEvents() - self:PerformDisplayOptions() - self:UpdateEvents() + -- local the profile table + db = self.db.profile + self:UpdateExpEvents() + self:UpdateRepHonorEvents() + self:UpdateCombatEvents() + self:UpdateBuffEvents() + self:UpdateBuffFadeEvents() + self:UpdateSkillEvents() + self:PerformDisplayOptions() + self:UpdateEvents() end function EavesDrop:PerformDisplayOptions() - --set size - arrSize = db["NUMLINES"] - frameSize = db["LINEHEIGHT"] + 1 - local totalh = (frameSize * arrSize) + 50 - local totalw = (db["LINEHEIGHT"] * 2) + db["LINEWIDTH"] - EavesDropFrame:SetHeight(totalh) - EavesDropFrame:SetWidth(totalw) - --update look of frame - local r,g,b,a = db["FRAME"].r, db["FRAME"].g, db["FRAME"].b, db["FRAME"].a - --main frame - EavesDropFrame:SetBackdropColor(r, g, b, a) - EavesDropTopBar:SetGradientAlpha("VERTICAL", r*.1, g*.1, b*.1, 0, r*.2, g*.2, b*.2, a) - EavesDropBottomBar:SetGradientAlpha("VERTICAL", r*.2, g*.2, b*.2, a, r*.1, g*.1, b*.1, 0) - EavesDropTopBar:SetWidth(totalw-10) - EavesDropBottomBar:SetWidth(totalw-10) - r,g,b,a = db["BORDER"].r, db["BORDER"].g, db["BORDER"].b, db["BORDER"].a - EavesDropFrame:SetBackdropBorderColor(r, g, b, a) - EavesDropFrame:EnableMouse(not db["LOCKED"]) - --tooltips - EavesDropTab.tooltipText = L["TabTip"] - if (db["SCROLLBUTTON"]) then - EavesDropFrameDownButton:Hide() - EavesDropFrameUpButton:Hide() - else - EavesDropFrameDownButton.tooltipText = L["DownTip"] - EavesDropFrameUpButton.tooltipText = L["UpTip"] - self:UpdateScrollButtons() - end - self.ToolTipAnchor = "ANCHOR_"..strupper(db["TOOLTIPSANCHOR"]) - --labels - r,g,b,a = db["LABELC"].r, db["LABELC"].g, db["LABELC"].b, db["LABELC"].a - if (db["FLIP"] == true) then - EavesDropFramePlayerText:SetText(L["TargetLabel"]) - EavesDropFrameTargetText:SetText(L["PlayerLabel"]) - else - EavesDropFramePlayerText:SetText(L["PlayerLabel"]) - EavesDropFrameTargetText:SetText(L["TargetLabel"]) - end - EavesDropFramePlayerText:SetTextColor(r,g,b,a) - EavesDropFrameTargetText:SetTextColor(r,g,b,a) - --fonts - self:SetFonts() - --tab - if (db["HIDETAB"] == true) then - EavesDropTab:Hide() - else - EavesDropTab:Show() - end - --position frame (have to schedule cause UI scale is still 1 for some reason during init) - self:ScheduleTimer("PlaceFrame", .1, self) - - self:ResetEvents() - self:SetupHistory() - - if (db["FADEFRAME"]) then - self:HideFrame() - else - self:ShowFrame() - end + -- set size + arrSize = db["NUMLINES"] + frameSize = db["LINEHEIGHT"] + 1 + local totalh = (frameSize * arrSize) + 50 + local totalw = (db["LINEHEIGHT"] * 2) + db["LINEWIDTH"] + + -- FRAME SIZING + EavesDropFrame:SetHeight(totalh) + EavesDropFrame:SetWidth(totalw) + + -- BACKGROUND APPEARANCE + local color = db["FRAME"] + local r, g, b, a = color.r, color.g, color.b, color.a + + EavesDropBackground:SetHeight(totalh) + EavesDropBackground:SetWidth(totalw) + EavesDropBackground:SetGradientAlpha("VERTICAL", r, g, b, a, r, g, b, a) + + -- BORDER CONFIG + color = db["BORDER"] + r, g, b, a = color.r, color.g, color.b, color.a + + EavesDropTopBar:SetWidth(totalw) + EavesDropBottomBar:SetWidth(totalw) + + + EavesDropTopBar:SetGradientAlpha("VERTICAL", r * .1, g * .1, b * .1, 0, + r * .2, g * .2, b * .2, a) + EavesDropBottomBar:SetGradientAlpha("VERTICAL", r * .2, g * .2, b * .2, a, + r * .1, g * .1, b * .1, 0) + + + EavesDropFrame:EnableMouse(not db["LOCKED"]) + -- tooltips + EavesDropTab.tooltipText = L["TabTip"] + if (db["SCROLLBUTTON"]) then + EavesDropFrameDownButton:Hide() + EavesDropFrameUpButton:Hide() + else + EavesDropFrameDownButton.tooltipText = L["DownTip"] + EavesDropFrameUpButton.tooltipText = L["UpTip"] + self:UpdateScrollButtons() + end + self.ToolTipAnchor = "ANCHOR_" .. strupper(db["TOOLTIPSANCHOR"]) + -- labels + r, g, b, a = db["LABELC"].r, db["LABELC"].g, db["LABELC"].b, db["LABELC"].a + if (db["FLIP"] == true) then + EavesDropFramePlayerText:SetText(L["TargetLabel"]) + EavesDropFrameTargetText:SetText(L["PlayerLabel"]) + else + EavesDropFramePlayerText:SetText(L["PlayerLabel"]) + EavesDropFrameTargetText:SetText(L["TargetLabel"]) + end + EavesDropFramePlayerText:SetTextColor(r, g, b, a) + EavesDropFrameTargetText:SetTextColor(r, g, b, a) + -- fonts + self:SetFonts() + -- tab + if (db["HIDETAB"] == true) then + EavesDropTab:Hide() + else + EavesDropTab:Show() + end + -- position frame (have to schedule cause UI scale is still 1 for some reason during init) + self:ScheduleTimer("PlaceFrame", .1, self) + + self:ResetEvents() + self:SetupHistory() + + if (db["FADEFRAME"]) then + self:HideFrame() + else + self:ShowFrame() + end end function EavesDrop:SetFonts() - EavesDropFontNormal:SetFont(media:Fetch("font", db["FONT"]), db["TEXTSIZE"]) - EavesDropFontNormalSmall:SetFont(media:Fetch("font", db["FONT"]), db["TEXTSIZE"]) + EavesDropFontNormal:SetFont(media:Fetch("font", db["FONT"]), db["TEXTSIZE"]) + EavesDropFontNormalSmall:SetFont(media:Fetch("font", db["FONT"]), + db["TEXTSIZE"]) end function EavesDrop:PlaceFrame() - local frame, x, y = EavesDropFrame, db.x, db.y - frame:ClearAllPoints() - if x==0 and y==0 then - frame:SetPoint("CENTER", UIParent, "CENTER") - else - local es = frame:GetEffectiveScale() - frame:SetPoint("TOPLEFT", UIParent, "CENTER", x/es, y/es) - end + local frame, x, y = EavesDropFrame, db.x, db.y + frame:ClearAllPoints() + if x == 0 and y == 0 then + frame:SetPoint("CENTER", UIParent, "CENTER") + else + local es = frame:GetEffectiveScale() + frame:SetPoint("TOPLEFT", UIParent, "CENTER", x / es, y / es) + end end -function EavesDrop:HideFrame() - EavesDropFrame:SetAlpha(0) -end +function EavesDrop:HideFrame() EavesDropFrame:SetAlpha(0) end function EavesDrop:ShowFrame() - EavesDropFrame:SetAlpha(1) - EavesDropTab:SetAlpha(0) + EavesDropFrame:SetAlpha(1) + EavesDropTab:SetAlpha(0) end function EavesDrop:CombatEvent() - local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 = CombatLogGetCurrentEventInfo() - local etype = COMBAT_EVENTS[event] - if not etype then return end - - if not Blizzard_CombatLog_CurrentSettings then - Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.filters[Blizzard_CombatLog_Filters.currentFilter] - end - - --check for reflect damage - if event == "SPELL_DAMAGE" and sourceName == destName and CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_HOSTILE) then - self:ParseReflect(timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) - return - end - - local toPlayer, fromPlayer, toPet, fromPet - if (sourceName and not CombatLog_Object_IsA(sourceFlags, COMBATLOG_OBJECT_NONE) ) then - fromPlayer = CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MINE) - fromPet = CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MY_PET) - end - if (destName and not CombatLog_Object_IsA(destFlags, COMBATLOG_OBJECT_NONE) ) then - toPlayer = CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_MINE) - toPet = CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_MY_PET) - end - - if not fromPlayer and not toPlayer and not fromPet and not toPet then return end - if (not fromPlayer and not toPlayer) and (toPet or fromPet) and not db["PET"] then return end - - local amount, overDamage, school, resisted, blocked, absorbed, critical, glancing, crushing - local spellId, spellName, spellSchool, missType, powerType, extraAmount, environmentalType, overHeal - local text, texture, message, inout, color - - --defaults - if toPet or fromPet then texture = "pet" end - if toPlayer or toPet then inout = INCOMING end - if fromPlayer or fromPet then inout = OUTGOING end - if toPet then color = db["PETI"] end - if fromPet then color = db["PETO"] end - - --get combat log message (for tooltip) - message = CombatLog_OnEvent(Blizzard_CombatLog_CurrentSettings, timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) - - - ------------damage---------------- - if etype == "DAMAGE" then - local intype, outtype - if event == "SWING_DAMAGE" then - amount, overDamage, school, resisted, blocked, absorbed, critical, glancing, crushing = a1, a2, a3, a4, a5, a6, a7, a8, a9 - if school == SCHOOL_MASK_PHYSICAL then - outtype, intype = "TMELEE", "PHIT" - else - outtype, intype = "TSPELL", "PSPELL" - end - elseif event == "RANGE_DAMAGE" then - spellId, spellName, spellSchool, amount, overDamage, school, resisted, blocked, absorbed, critical, glancing, crushing = a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 - if school == SCHOOL_MASK_PHYSICAL then - outtype, intype = "TMELEE", "PHIT" - else - outtype, intype = "TSPELL", "PSPELL" - end - elseif event == "ENVIRONMENTAL_DAMAGE" then - environmentalType, amount, overDamage, school, resisted, blocked, absorbed, critical, glancing, crushing = a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 - outtype, intype = "TSPELL", "PSPELL" - else - spellId, spellName, spellSchool, amount, overDamage, school, resisted, blocked, absorbed, critical, glancing, crushing = a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 - texture = select(3, GetSpellInfo(spellId)) - outtype, intype = "TSPELL", "PSPELL" + local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, + sourceFlags2, destGUID, destName, destFlags, destFlags2, a1, a2, a3, + a4, a5, a6, a7, a8, a9, a10, a11, a12 = CombatLogGetCurrentEventInfo() + local etype = COMBAT_EVENTS[event] + if not etype then return end + + if not Blizzard_CombatLog_CurrentSettings then + Blizzard_CombatLog_CurrentSettings = + Blizzard_CombatLog_Filters.filters[Blizzard_CombatLog_Filters.currentFilter] end - text = tostring(shortenValue(amount)) - - if (critical) then text = critchar..text..critchar end - if (crushing) then text = crushchar..text..crushchar end - if (glancing) then text = glancechar..text..glancechar end - if (resisted) then text = string_format("%s (%d)", text, shortenValue(resisted)) end - if (blocked) then text = string_format("%s (%d)", text, shortenValue(blocked)) end - if (absorbed) then text = string_format("%s (%d)", text, shortenValue(absorbed))end - - if fromPlayer then - if (self:TrackStat(inout, "hit", spellName, texture, SCHOOL_STRINGS[school], amount, critical, message)) then - text = newhigh..text..newhigh - end - --fix colors for self physical - if school == SCHOOL_MASK_PHYSICAL then school = 0 end - color = self:SpellColor(db[outtype], SCHOOL_STRINGS[school]) - totDamageOut = totDamageOut + amount - elseif toPlayer then - if (self:TrackStat(inout, "hit", spellName, texture, SCHOOL_STRINGS[school], amount, critical, message)) then - text = newhigh..text..newhigh - end - color = self:SpellColor(db[intype], SCHOOL_STRINGS[school]) - text = "-"..text - totDamageIn = totDamageIn + amount - elseif toPet then - text = "-"..text - end - self:DisplayEvent(inout, text, texture, color, message, spellName) - ------------buff/debuff gain---------------- - elseif etype == "BUFF" then - spellId, spellName, spellSchool, auraType, amount = a1, a2, a3, a4, a5 - texture = select(3, GetSpellInfo(spellId)) - if toPlayer and db[auraType] then - self:DisplayEvent(INCOMING, self:ShortenString(spellName).." "..L["Gained"], texture, db["P"..auraType], message, spellName) - else return - end - ------------buff/debuff lose---------------- - elseif etype == "FADE" then - spellId, spellName, spellSchool, auraType, amount = a1, a2, a3, a4, a5 - texture = select(3, GetSpellInfo(spellId)) - if toPlayer and db[auraType.."FADE"] then - self:DisplayEvent(INCOMING, self:ShortenString(spellName).." "..L["Fades"], texture, db["P"..auraType], message, spellName) - else return - end - ------------heals---------------- - elseif etype == "HEAL" then - spellId, spellName, spellSchool, amount, overHeal, absorbed, critical = a1, a2, a3, a4, a5, a6, a7 - text = tostring(shortenValue(amount)) - texture = select(3, GetSpellInfo(spellId)) - - if toPlayer then - totHealingIn = totHealingIn + amount - if (amount < db["HFILTER"]) then return end - if (db["OVERHEAL"]) and overHeal > 0 then text = string_format("%d {%d}", shortenValue(amount-overHeal), shortenValue(overHeal)) end - if (critical) then text = critchar..text..critchar end - if (db["HEALERID"] == true and not fromPlayer) then text = text.." ("..sourceName..")" end - color = db["PHEAL"] - if (self:TrackStat(inout, "heal", spellName, texture, SCHOOL_STRINGS[spellSchool], amount, critical, message)) then - text = newhigh..text..newhigh - end - text = "+"..text - elseif fromPlayer then - totHealingOut = totHealingOut + amount - if (amount < db["HFILTER"]) then return end - if (db["OVERHEAL"]) and overHeal > 0 then text = string_format("%d {%d}", shortenValue(amount-overHeal), shortenValue(overHeal)) end - if (critical) then text = critchar..text..critchar end - color = db["THEAL"] - if (self:TrackStat(inout, "heal", spellName, texture, SCHOOL_STRINGS[spellSchool], amount, critical, message)) then - text = newhigh..text..newhigh - end - text = "+"..text - if (db["HEALERID"] == true) then text = destName..": "..text end - end - self:DisplayEvent(inout, text, texture, color, message, spellName) - ------------misses---------------- - elseif etype == "MISS" then - local tcolor - if event == "SWING_MISSED" or event == "RANGE_MISSED" then - missType = a1 - tcolor = "TMELEE" - else - spellId, spellName, spellSchool, missType = a1, a2, a3, a4 - texture = select(3, GetSpellInfo(spellId)) - tcolor = "TSPELL" + + -- check for reflect damage + if event == "SPELL_DAMAGE" and sourceName == destName and + CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_HOSTILE) then + self:ParseReflect(timestamp, event, hideCaster, sourceGUID, sourceName, + sourceFlags, sourceFlags2, destGUID, destName, + destFlags, destFlags2, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12) + return end - text = _G[missType] - if fromPlayer then - color = db[tcolor] - elseif toPlayer then - if missType == "REFLECT" then - self:SetReflect(sourceName, spellName) - end - color = db["PMISS"] + + local toPlayer, fromPlayer, toPet, fromPet + if (sourceName and + not CombatLog_Object_IsA(sourceFlags, COMBATLOG_OBJECT_NONE)) then + fromPlayer = CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MINE) + fromPet = CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MY_PET) end - self:DisplayEvent(inout, text, texture, color, message, spellName) - ------------leech and drains---------------- - elseif etype == "DRAIN" then - if (db["GAINS"]) then - spellId, spellName, spellSchool, amount, powerType, extraAmount = a1, a2, a3, a4, a5, a6 - texture = select(3, GetSpellInfo(spellId)) - if toPlayer then - text = string_format("-%d %s", amount, string_nil("")) - color = db["PGAIN"] - elseif fromPlayer and extraAmount then - if (extraAmount < db["MFILTER"]) then return end - text = string_format("+%d %s", extraAmount, string_nil("")) - color = db["PGAIN"] - elseif fromPlayer then - return - --for showing your drain damage - --text = string_format("%d %s", amount, string_nil("")) - --color = db["TSPELL"] - end - self:DisplayEvent(inout, text, texture, color, message, spellName) + if (destName and not CombatLog_Object_IsA(destFlags, COMBATLOG_OBJECT_NONE)) then + toPlayer = CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_MINE) + toPet = CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_MY_PET) end - ------------power gains---------------- - elseif etype == "POWER" then - if (db["GAINS"]) then - spellId, spellName, spellSchool, amount, powerType = a1, a2, a3, a4, a5 - texture = select(3, GetSpellInfo(spellId)) - if toPlayer then - if (amount < db["MFILTER"]) then return end - color = db["PGAIN"] - elseif not toPet then + + if not fromPlayer and not toPlayer and not fromPet and not toPet then return - end - text = string_format("+%d %s", amount, string_nil("")) - self:DisplayEvent(inout, text, texture, color, message, spellName) end - ------------deaths---------------- - elseif etype == "DEATH" then - if fromPlayer then - text = deathchar..destName..deathchar - self:DisplayEvent(MISC, text, texture, db["DEATH"], message, spellName) - else return + if (not fromPlayer and not toPlayer) and (toPet or fromPet) and + not db["PET"] then return end + + local amount, overDamage, school, resisted, blocked, absorbed, critical, + glancing, crushing + local spellId, spellName, spellSchool, missType, powerType, extraAmount, + environmentalType, overHeal + local text, texture, message, inout, color + + -- defaults + if toPet or fromPet then texture = "pet" end + if toPlayer or toPet then inout = INCOMING end + if fromPlayer or fromPet then inout = OUTGOING end + if toPet then color = db["PETI"] end + if fromPet then color = db["PETO"] end + + -- get combat log message (for tooltip) + message = CombatLog_OnEvent(Blizzard_CombatLog_CurrentSettings, timestamp, + event, hideCaster, sourceGUID, sourceName, + sourceFlags, sourceFlags2, destGUID, destName, + destFlags, destFlags2, a1, a2, a3, a4, a5, a6, + a7, a8, a9, a10, a11, a12) + + ------------damage---------------- + if etype == "DAMAGE" then + local intype, outtype + if event == "SWING_DAMAGE" then + amount, overDamage, school, resisted, blocked, absorbed, critical, glancing, crushing = + a1, a2, a3, a4, a5, a6, a7, a8, a9 + if school == SCHOOL_MASK_PHYSICAL then + outtype, intype = "TMELEE", "PHIT" + else + outtype, intype = "TSPELL", "PSPELL" + end + elseif event == "RANGE_DAMAGE" then + spellId, spellName, spellSchool, amount, overDamage, school, resisted, blocked, absorbed, critical, glancing, crushing = + a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 + if school == SCHOOL_MASK_PHYSICAL then + outtype, intype = "TMELEE", "PHIT" + else + outtype, intype = "TSPELL", "PSPELL" + end + elseif event == "ENVIRONMENTAL_DAMAGE" then + environmentalType, amount, overDamage, school, resisted, blocked, absorbed, critical, glancing, crushing = + a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 + outtype, intype = "TSPELL", "PSPELL" + else + spellId, spellName, spellSchool, amount, overDamage, school, resisted, blocked, absorbed, critical, glancing, crushing = + a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12 + texture = select(3, GetSpellInfo(spellId)) + outtype, intype = "TSPELL", "PSPELL" + end + text = tostring(shortenValue(amount)) + + if (critical) then text = critchar .. text .. critchar end + if (crushing) then text = crushchar .. text .. crushchar end + if (glancing) then text = glancechar .. text .. glancechar end + if (resisted) then + text = string_format("%s (%d)", text, shortenValue(resisted)) + end + if (blocked) then + text = string_format("%s (%d)", text, shortenValue(blocked)) + end + if (absorbed) then + text = string_format("%s (%d)", text, shortenValue(absorbed)) + end + + if fromPlayer then + if (self:TrackStat(inout, "hit", spellName, texture, + SCHOOL_STRINGS[school], amount, critical, message)) then + text = newhigh .. text .. newhigh + end + -- fix colors for self physical + if school == SCHOOL_MASK_PHYSICAL then school = 0 end + color = self:SpellColor(db[outtype], SCHOOL_STRINGS[school]) + totDamageOut = totDamageOut + amount + elseif toPlayer then + if (self:TrackStat(inout, "hit", spellName, texture, + SCHOOL_STRINGS[school], amount, critical, message)) then + text = newhigh .. text .. newhigh + end + color = self:SpellColor(db[intype], SCHOOL_STRINGS[school]) + text = "-" .. text + totDamageIn = totDamageIn + amount + elseif toPet then + text = "-" .. text + end + self:DisplayEvent(inout, text, texture, color, message, spellName) + ------------buff/debuff gain---------------- + elseif etype == "BUFF" then + spellId, spellName, spellSchool, auraType, amount = a1, a2, a3, a4, a5 + texture = select(3, GetSpellInfo(spellId)) + if toPlayer and db[auraType] then + self:DisplayEvent(INCOMING, self:ShortenString(spellName) .. " " .. + L["Gained"], texture, db["P" .. auraType], + message, spellName) + else + return + end + ------------buff/debuff lose---------------- + elseif etype == "FADE" then + spellId, spellName, spellSchool, auraType, amount = a1, a2, a3, a4, a5 + texture = select(3, GetSpellInfo(spellId)) + if toPlayer and db[auraType .. "FADE"] then + self:DisplayEvent(INCOMING, self:ShortenString(spellName) .. " " .. + L["Fades"], texture, db["P" .. auraType], + message, spellName) + else + return + end + ------------heals---------------- + elseif etype == "HEAL" then + spellId, spellName, spellSchool, amount, overHeal, absorbed, critical = + a1, a2, a3, a4, a5, a6, a7 + text = tostring(shortenValue(amount)) + texture = select(3, GetSpellInfo(spellId)) + + if toPlayer then + totHealingIn = totHealingIn + amount + if (amount < db["HFILTER"]) then return end + if (db["OVERHEAL"]) and overHeal > 0 then + text = string_format("%d {%d}", shortenValue(amount - overHeal), + shortenValue(overHeal)) + end + if (critical) then text = critchar .. text .. critchar end + if (db["HEALERID"] == true and not fromPlayer) then + text = text .. " (" .. sourceName .. ")" + end + color = db["PHEAL"] + if (self:TrackStat(inout, "heal", spellName, texture, + SCHOOL_STRINGS[spellSchool], amount, critical, + message)) then + text = newhigh .. text .. newhigh + end + text = "+" .. text + elseif fromPlayer then + totHealingOut = totHealingOut + amount + if (amount < db["HFILTER"]) then return end + if (db["OVERHEAL"]) and overHeal > 0 then + text = string_format("%d {%d}", shortenValue(amount - overHeal), + shortenValue(overHeal)) + end + if (critical) then text = critchar .. text .. critchar end + color = db["THEAL"] + if (self:TrackStat(inout, "heal", spellName, texture, + SCHOOL_STRINGS[spellSchool], amount, critical, + message)) then + text = newhigh .. text .. newhigh + end + text = "+" .. text + if (db["HEALERID"] == true) then + text = destName .. ": " .. text + end + end + self:DisplayEvent(inout, text, texture, color, message, spellName) + ------------misses---------------- + elseif etype == "MISS" then + local tcolor + if event == "SWING_MISSED" or event == "RANGE_MISSED" then + missType = a1 + tcolor = "TMELEE" + else + spellId, spellName, spellSchool, missType = a1, a2, a3, a4 + texture = select(3, GetSpellInfo(spellId)) + tcolor = "TSPELL" + end + text = _G[missType] + if fromPlayer then + color = db[tcolor] + elseif toPlayer then + if missType == "REFLECT" then + self:SetReflect(sourceName, spellName) + end + color = db["PMISS"] + end + self:DisplayEvent(inout, text, texture, color, message, spellName) + ------------leech and drains---------------- + elseif etype == "DRAIN" then + if (db["GAINS"]) then + spellId, spellName, spellSchool, amount, powerType, extraAmount = + a1, a2, a3, a4, a5, a6 + texture = select(3, GetSpellInfo(spellId)) + if toPlayer then + text = string_format("-%d %s", amount, string_nil("")) + color = db["PGAIN"] + elseif fromPlayer and extraAmount then + if (extraAmount < db["MFILTER"]) then return end + text = string_format("+%d %s", extraAmount, string_nil("")) + color = db["PGAIN"] + elseif fromPlayer then + return + -- for showing your drain damage + -- text = string_format("%d %s", amount, string_nil("")) + -- color = db["TSPELL"] + end + self:DisplayEvent(inout, text, texture, color, message, spellName) + end + ------------power gains---------------- + elseif etype == "POWER" then + if (db["GAINS"]) then + spellId, spellName, spellSchool, amount, powerType = a1, a2, a3, a4, + a5 + texture = select(3, GetSpellInfo(spellId)) + if toPlayer then + if (amount < db["MFILTER"]) then return end + color = db["PGAIN"] + elseif not toPet then + return + end + text = string_format("+%d %s", amount, string_nil("")) + self:DisplayEvent(inout, text, texture, color, message, spellName) + end + ------------deaths---------------- + elseif etype == "DEATH" then + if fromPlayer then + text = deathchar .. destName .. deathchar + self:DisplayEvent(MISC, text, texture, db["DEATH"], message, + spellName) + else + return + end + ------------enchants---------------- + elseif etype == "ENCHANT_APPLIED" then + spellName = a1 + self:DisplayEvent(INCOMING, self:ShortenString(spellName), texture, + db["PBUFF"], message, spellName) + elseif etype == "ENCHANT_REMOVED" then + spellName = a1 + self:DisplayEvent(INCOMING, + self:ShortenString(spellName) .. " " .. L["Fades"], + texture, db["PBUFF"], message, spellName) + -------------anything else------------- + -- else + -- self:Print(event, sourceName, destName) end - ------------enchants---------------- - elseif etype == "ENCHANT_APPLIED" then - spellName = a1 - self:DisplayEvent(INCOMING, self:ShortenString(spellName), texture, db["PBUFF"], message, spellName) - elseif etype == "ENCHANT_REMOVED" then - spellName = a1 - self:DisplayEvent(INCOMING, self:ShortenString(spellName).." "..L["Fades"], texture, db["PBUFF"], message, spellName) - -------------anything else------------- - --else - --self:Print(event, sourceName, destName) - end end function EavesDrop:PLAYER_XP_UPDATE() - local xp = UnitXP("player") - local xpgained = xp - pxp - self:DisplayEvent(MISC, string_format("+%d (%s)", shortenValue(xpgained), XP), nil, db["EXPC"], nil) - pxp = xp + local xp = UnitXP("player") + local xpgained = xp - pxp + self:DisplayEvent(MISC, + string_format("+%d (%s)", shortenValue(xpgained), XP), + nil, db["EXPC"], nil) + pxp = xp end function EavesDrop:COMBAT_TEXT_UPDATE(event, larg1, larg2, larg3) - if larg1=="FACTION" then - local sign = "+" - if larg2 == nil then - larg2 = 0 - end - if larg3 == nil then - larg3 = 0 - sign = "" - end - if (tonumber(larg3) < 0) then sign = "" end - self:DisplayEvent(MISC, string_format("%s%d (%s)", sign, larg3, larg2), nil, db["REPC"], nil) - elseif larg1=="HONOR_GAINED" then - self:DisplayEvent(MISC, string_format("+%d (%s)", larg2, HONOR) , nil, db["HONORC"], nil) - end + if larg1 == "FACTION" then + local sign = "+" + if larg2 == nil then larg2 = 0 end + if larg3 == nil then + larg3 = 0 + sign = "" + end + if (tonumber(larg3) < 0) then sign = "" end + self:DisplayEvent(MISC, string_format("%s%d (%s)", sign, larg3, larg2), + nil, db["REPC"], nil) + elseif larg1 == "HONOR_GAINED" then + self:DisplayEvent(MISC, string_format("+%d (%s)", larg2, HONOR), nil, + db["HONORC"], nil) + end end function EavesDrop:PLAYER_REGEN_DISABLED() - pxp = UnitXP("player") - timeStart = GetTime() - clearSummary() - self:DisplayEvent(MISC, L["StartCombat"], nil, db["MISC"]) - --stop on update, since in combat - self:StopOnUpdate() - --show frame, if its hidden - self:ShowFrame() - --flag all as being shown, so buttons appear - allShown = true + pxp = UnitXP("player") + timeStart = GetTime() + clearSummary() + self:DisplayEvent(MISC, L["StartCombat"], nil, db["MISC"]) + -- stop on update, since in combat + self:StopOnUpdate() + -- show frame, if its hidden + self:ShowFrame() + -- flag all as being shown, so buttons appear + allShown = true end function EavesDrop:PLAYER_REGEN_ENABLED() - self:DisplayEvent(MISC, L["EndCombat"], nil, db["MISC"]) - if (db["SUMMARY"] == true) then - local duration = round(GetTime() - timeStart, 1) - local DPS = round(totDamageOut/duration,1) or 0 - local HPS = round(totHealingOut/duration,1) or 0 - local IDPS = round(totDamageIn/duration,1) or 0 - local IHPS = round(totHealingIn/duration,1) or 0 - local strSummary = convertRGBtoHEXString(db["MISC"], duration.." "..L["IncombatSummary"]).."\n".. - convertRGBtoHEXString(db["PHIT"], L["IncomingDamge"]..": "..totDamageIn.." ("..IDPS..")").."\n".. - convertRGBtoHEXString(db["PHEAL"], L["IncomingHeals"]..": "..totHealingIn.." ("..IHPS..")").."\n".. - convertRGBtoHEXString(db["THEAL"], L["OutgoingHeals"]..": "..totHealingOut.." ("..HPS..")").."\n".. - convertRGBtoHEXString(db["TSPELL"], L["OutgoingDamage"]..": "..totDamageOut.." ("..DPS..")") - - self:DisplayEvent(MISC, - convertRGBtoHEXString(db["PHIT"], shortenValue(totDamageIn)).." | ".. - convertRGBtoHEXString(db["PHEAL"], shortenValue(totHealingIn)).." | ".. - convertRGBtoHEXString(db["THEAL"], shortenValue(totHealingOut)).." | ".. - convertRGBtoHEXString(db["TSPELL"], shortenValue(totDamageOut)), - nil, db["MISC"], strSummary) - end - clearSummary() - --since out of combat, try and start onupdate to count down frames - self:StartOnUpdate() + self:DisplayEvent(MISC, L["EndCombat"], nil, db["MISC"]) + if (db["SUMMARY"] == true) then + local duration = round(GetTime() - timeStart, 1) + local DPS = round(totDamageOut / duration, 1) or 0 + local HPS = round(totHealingOut / duration, 1) or 0 + local IDPS = round(totDamageIn / duration, 1) or 0 + local IHPS = round(totHealingIn / duration, 1) or 0 + local strSummary = convertRGBtoHEXString(db["MISC"], duration .. " " .. + L["IncombatSummary"]) .. + "\n" .. + convertRGBtoHEXString(db["PHIT"], + L["IncomingDamge"] .. ": " .. + totDamageIn .. " (" .. + IDPS .. ")") .. "\n" .. + convertRGBtoHEXString(db["PHEAL"], + L["IncomingHeals"] .. ": " .. + totHealingIn .. " (" .. + IHPS .. ")") .. "\n" .. + convertRGBtoHEXString(db["THEAL"], + L["OutgoingHeals"] .. ": " .. + totHealingOut .. " (" .. + HPS .. ")") .. "\n" .. + convertRGBtoHEXString(db["TSPELL"], + L["OutgoingDamage"] .. ": " .. + totDamageOut .. " (" .. + DPS .. ")") + + self:DisplayEvent(MISC, + convertRGBtoHEXString(db["PHIT"], + shortenValue(totDamageIn)) .. + " | " .. + convertRGBtoHEXString(db["PHEAL"], + shortenValue(totHealingIn)) .. + " | " .. + convertRGBtoHEXString(db["THEAL"], + shortenValue(totHealingOut)) .. + " | " .. + convertRGBtoHEXString(db["TSPELL"], + shortenValue(totDamageOut)), + nil, db["MISC"], strSummary) + end + clearSummary() + -- since out of combat, try and start onupdate to count down frames + self:StartOnUpdate() end function EavesDrop:PLAYER_DEAD() - self:DisplayEvent(MISC, deathchar..UnitName("player")..deathchar, nil, db["DEATH"]) + self:DisplayEvent(MISC, deathchar .. UnitName("player") .. deathchar, nil, + db["DEATH"]) end function EavesDrop:CHAT_MSG_SKILL(event, larg1) - local skill, rank = string_match(larg1, skillmsg) - if skill then - self:DisplayEvent(MISC, string_format("%s: %d", skill, rank), nil, db["SKILLC"], larg1) - end + local skill, rank = string_match(larg1, skillmsg) + if skill then + self:DisplayEvent(MISC, string_format("%s: %d", skill, rank), nil, + db["SKILLC"], larg1) + end end local tempcolor = {r = 1, g = 1, b = 1} function EavesDrop:DisplayEvent(type, text, texture, color, message, spellname) - --remove oldest table and create new display event - local pEvent = tremove(arrEventData, 1) - local tooltiptext = message - if (db["FLIP"] == true) then type = type * -1 end - pEvent.type = type - pEvent.text = text - pEvent.texture = texture - pEvent.color = color or tempcolor - - -- Messages probably already have a timestamp, so let's clear that up - if (db["TIMESTAMP"] == true and message) then - - -- Check if we have a timestamp here and remove to use our own - local timecutoff = string.find(message, '> ') + -- remove oldest table and create new display event + local pEvent = tremove(arrEventData, 1) + local tooltiptext = message + if (db["FLIP"] == true) then type = type * -1 end + pEvent.type = type + pEvent.text = text + pEvent.texture = texture + pEvent.color = color or tempcolor - -- If we did, skip those two characters "> " - if timecutoff then - message = strsub(message, timecutoff + 2) - end + -- Messages probably already have a timestamp, so let's clear that up + if (db["TIMESTAMP"] == true and message) then - pEvent.tooltipText = string_format('|cffffffff%s\n%s', date('%I:%M:%S'), message) - - elseif (db["TIMESTAMP"] == true and text) then - pEvent.tooltipText = string_format('|cffffffff%s|r\n%s', date('%I:%M:%S'), text) - - elseif (db["TIMESTAMP"] == true) then - pEvent.tooltipText = string_format('|cffffffff%s|r\n%s', date('%I:%M:%S'), tooltiptext or '') - - elseif spellname then - pEvent.tooltipText = spellname - - else - pEvent.tooltipText = tooltiptext - - end - tinsert(arrEventData, arrMaxSize, pEvent) - self:UpdateEvents() + -- Check if we have a timestamp here and remove to use our own + local timecutoff = string.find(message, '> ') + + -- If we did, skip those two characters "> " + if timecutoff then message = strsub(message, timecutoff + 2) end + + pEvent.tooltipText = string_format('|cffffffff%s\n%s', date('%I:%M:%S'), + message) + + elseif (db["TIMESTAMP"] == true and text) then + pEvent.tooltipText = string_format('|cffffffff%s|r\n%s', + date('%I:%M:%S'), text) + + elseif (db["TIMESTAMP"] == true) then + pEvent.tooltipText = string_format('|cffffffff%s|r\n%s', + date('%I:%M:%S'), tooltiptext or '') + + elseif spellname then + pEvent.tooltipText = spellname + + else + pEvent.tooltipText = tooltiptext + + end + tinsert(arrEventData, arrMaxSize, pEvent) + self:UpdateEvents() end function EavesDrop:UpdateEvents() - local key, value - local frame, text, intexture, outexture - local start, finish - local delay = db["FADETIME"] + (4 * arrSize) - start = arrMaxSize-scroll - finish = arrMaxSize-arrSize+1-scroll - for i=start,finish,-1 do - value = arrEventData[i] - key = i - (arrMaxSize-arrSize) + scroll - frame = arrEventFrames[key].frame - text = arrEventFrames[key].text - intexture = arrEventFrames[key].intexture - outtexture = arrEventFrames[key].outtexture - if (not value.text) then - text:SetText(nil) - intexture:SetTexture(nil) - outtexture:SetTexture(nil) - frame.delay = 0 - frame.alpha = 0 - frame.tooltipText = nil - frame:Hide() - else - if (value.type == INCOMING) then - text:SetJustifyH("LEFT") - text:SetWidth(db["LINEWIDTH"]-20) - text:SetPoint("LEFT", intexture, "RIGHT", 5, 0) - intexture:SetTexCoord(.1,.9,.1,.9) - outtexture:SetTexture(nil) - if value.texture == "pet" then - SetPortraitTexture(intexture, value.texture) + local key, value + local frame, text, intexture, outexture + local start, finish + local delay = db["FADETIME"] + (4 * arrSize) + start = arrMaxSize - scroll + finish = arrMaxSize - arrSize + 1 - scroll + for i = start, finish, -1 do + value = arrEventData[i] + key = i - (arrMaxSize - arrSize) + scroll + frame = arrEventFrames[key].frame + text = arrEventFrames[key].text + intexture = arrEventFrames[key].intexture + outtexture = arrEventFrames[key].outtexture + if (not value.text) then + text:SetText(nil) + intexture:SetTexture(nil) + outtexture:SetTexture(nil) + frame.delay = 0 + frame.alpha = 0 + frame.tooltipText = nil + frame:Hide() else - intexture:SetTexture(value.texture) + if (value.type == INCOMING) then + text:SetJustifyH("LEFT") + text:SetWidth(db["LINEWIDTH"] - 20) + text:SetPoint("LEFT", intexture, "RIGHT", 5, 0) + intexture:SetTexCoord(.1, .9, .1, .9) + outtexture:SetTexture(nil) + if value.texture == "pet" then + SetPortraitTexture(intexture, value.texture) + else + intexture:SetTexture(value.texture) + end + elseif (value.type == OUTGOING) then + text:SetJustifyH("RIGHT") + text:SetWidth(db["LINEWIDTH"] - 20) + text:SetPoint("LEFT", intexture, "RIGHT", 5, 0) + intexture:SetTexture(nil) + outtexture:SetTexCoord(.1, .9, .1, .9) + if value.texture == "pet" then + SetPortraitTexture(outtexture, value.texture) + else + outtexture:SetTexture(value.texture) + end + else + text:SetJustifyH("CENTER") + text:SetWidth((db["LINEHEIGHT"] * 2) + (db["LINEWIDTH"] - 10)) + text:SetPoint("LEFT", intexture, "LEFT", 0, 0) + intexture:SetTexture(nil) + outtexture:SetTexture(nil) + end + text:SetText(value.text) + text:SetTextColor(value.color.r, value.color.g, value.color.b) + frame.delay = delay + frame.alpha = 1 + if (db["TOOLTIPS"] == true) then + frame.tooltipText = value.tooltipText + else + frame.tooltipText = nil + end + frame:Show() + frame:SetAlpha(frame.alpha) end - elseif (value.type == OUTGOING) then - text:SetJustifyH("RIGHT") - text:SetWidth(db["LINEWIDTH"]-20) - text:SetPoint("LEFT", intexture, "RIGHT", 5, 0) - intexture:SetTexture(nil) - outtexture:SetTexCoord(.1,.9,.1,.9) - if value.texture == "pet" then - SetPortraitTexture(outtexture, value.texture) + delay = delay - 4 + -- set clickthru + if (frame.tooltipText) then + frame:EnableMouse(true) else - outtexture:SetTexture(value.texture) + frame:EnableMouse(false) end - else - text:SetJustifyH("CENTER") - text:SetWidth((db["LINEHEIGHT"] * 2) + (db["LINEWIDTH"]-10)) - text:SetPoint("LEFT", intexture, "LEFT", 0, 0) - intexture:SetTexture(nil) - outtexture:SetTexture(nil) - end - text:SetText(value.text) - text:SetTextColor(value.color.r, value.color.g, value.color.b) - frame.delay = delay - frame.alpha = 1 - if (db["TOOLTIPS"] == true) then - frame.tooltipText = value.tooltipText - else - frame.tooltipText = nil - end - frame:Show() - frame:SetAlpha(frame.alpha) - end - delay = delay - 4 - --set clickthru - if (frame.tooltipText) then - frame:EnableMouse(true) - else - frame:EnableMouse(false) end - end - --Update scrolls - self:UpdateScrollButtons() - --try to start up onUpdate. if in combat it won't start. - self:StartOnUpdate() + -- Update scrolls + self:UpdateScrollButtons() + -- try to start up onUpdate. if in combat it won't start. + self:StartOnUpdate() end function EavesDrop:StartOnUpdate() - --only start on update if not in combat, and not already started. - if not InCombatLockdown() and not self.OnUpdateStarted then - lastTime = GetTime() - self.OnUpdateStarted = self:ScheduleRepeatingTimer("OnUpdate", .2, self) - end + -- only start on update if not in combat, and not already started. + if not InCombatLockdown() and not self.OnUpdateStarted then + lastTime = GetTime() + self.OnUpdateStarted = self:ScheduleRepeatingTimer("OnUpdate", .2, self) + end end function EavesDrop:StopOnUpdate() - self:CancelTimer(self.OnUpdateStarted, true) - self.OnUpdateStarted = nil + self:CancelTimer(self.OnUpdateStarted, true) + self.OnUpdateStarted = nil end function EavesDrop:ResetEvents() - local frame, text, intexture, outexture - for i=1,arrDisplaySize do - frame = arrEventFrames[i].frame - text = arrEventFrames[i].text - intexture = arrEventFrames[i].intextureframe - outtexture = arrEventFrames[i].outtextureframe - frame.delay = 0 - frame.alpha = 0 - frame.tooltipText = nil - frame:SetHeight(db["LINEHEIGHT"] + 1) - frame:SetWidth((db["LINEHEIGHT"] * 2) + db["LINEWIDTH"]) - frame:Hide() - text:SetHeight(db["LINEHEIGHT"]) - intexture:SetHeight(db["LINEHEIGHT"]) - intexture:SetWidth(db["LINEHEIGHT"]) - intexture:SetPoint("LEFT", frame, "RIGHT", 5, 0) - outtexture:SetHeight(db["LINEHEIGHT"]) - outtexture:SetWidth(db["LINEHEIGHT"]) - end + local frame, text, intexture, outexture + for i = 1, arrDisplaySize do + frame = arrEventFrames[i].frame + text = arrEventFrames[i].text + intexture = arrEventFrames[i].intextureframe + outtexture = arrEventFrames[i].outtextureframe + frame.delay = 0 + frame.alpha = 0 + frame.tooltipText = nil + frame:SetHeight(db["LINEHEIGHT"] + 1) + frame:SetWidth((db["LINEHEIGHT"] * 2) + db["LINEWIDTH"]) + frame:Hide() + text:SetHeight(db["LINEHEIGHT"]) + intexture:SetHeight(db["LINEHEIGHT"]) + intexture:SetWidth(db["LINEHEIGHT"]) + intexture:SetPoint("LEFT", frame, "RIGHT", 5, 0) + outtexture:SetHeight(db["LINEHEIGHT"]) + outtexture:SetWidth(db["LINEHEIGHT"]) + end end function EavesDrop:OnUpdate() - local frame - local count = 0 - curTime = GetTime() - elapsed = curTime - lastTime - lastTime = curTime - for i=1,arrSize do - frame = arrEventFrames[i].frame - if (frame:IsShown()) then - count = count + 1 - frame.delay = frame.delay - elapsed - if frame.delay <= 0 then - frame.alpha = frame.alpha - .2 - frame:SetAlpha(frame.alpha) - end - if (frame.alpha <= 0) then - frame:Hide() - EavesDropFrameUpButton:Hide() - count = count - 1 - end + local frame + local count = 0 + curTime = GetTime() + elapsed = curTime - lastTime + lastTime = curTime + for i = 1, arrSize do + frame = arrEventFrames[i].frame + if (frame:IsShown()) then + count = count + 1 + frame.delay = frame.delay - elapsed + if frame.delay <= 0 then + frame.alpha = frame.alpha - .2 + frame:SetAlpha(frame.alpha) + end + if (frame.alpha <= 0) then + frame:Hide() + EavesDropFrameUpButton:Hide() + count = count - 1 + end + end end - end - if (count == arrSize) then - allShown = true - else - allShown = false - end - --if none are active, stop onUpdate - if (count == 0) then - self:StopOnUpdate() - end - --hide frame when none active - if (db["FADEFRAME"]) then - if ((count == 0) and (scroll==0)) then - self:HideFrame() + if (count == arrSize) then + allShown = true else - self:ShowFrame() + allShown = false + end + -- if none are active, stop onUpdate + if (count == 0) then self:StopOnUpdate() end + -- hide frame when none active + if (db["FADEFRAME"]) then + if ((count == 0) and (scroll == 0)) then + self:HideFrame() + else + self:ShowFrame() + end end - end end function EavesDrop:Scroll(this, dir) - local self = EavesDrop - if dir > 0 then - if IsShiftKeyDown() then - self:ScrollToTop() - elseif IsControlKeyDown() then - self:FindCombatUp() - else - self:ScrollUp() - end - elseif dir < 0 then - if IsShiftKeyDown() then - self:ScrollToBottom() - elseif IsControlKeyDown() then - self:FindCombatDown() - else - self:ScrollDown() + local self = EavesDrop + if dir > 0 then + if IsShiftKeyDown() then + self:ScrollToTop() + elseif IsControlKeyDown() then + self:FindCombatUp() + else + self:ScrollUp() + end + elseif dir < 0 then + if IsShiftKeyDown() then + self:ScrollToBottom() + elseif IsControlKeyDown() then + self:FindCombatDown() + else + self:ScrollDown() + end end - end end function EavesDrop:FindCombatUp() - for i=arrMaxSize-scroll-arrSize, 1, -1 do - if arrEventData[i].text and arrEventData[i].text == L["StartCombat"] then - scroll = arrMaxSize-i-arrSize+1 - self:UpdateScrollButtons() - self:UpdateEvents() - return + for i = arrMaxSize - scroll - arrSize, 1, -1 do + if arrEventData[i].text and arrEventData[i].text == L["StartCombat"] then + scroll = arrMaxSize - i - arrSize + 1 + self:UpdateScrollButtons() + self:UpdateEvents() + return + end end - end end function EavesDrop:FindCombatDown() - for i=arrMaxSize-scroll+1,arrMaxSize do - if arrEventData[i].text and arrEventData[i].text == L["EndCombat"] then - scroll = arrMaxSize-i - self:UpdateScrollButtons() - self:UpdateEvents() - return + for i = arrMaxSize - scroll + 1, arrMaxSize do + if arrEventData[i].text and arrEventData[i].text == L["EndCombat"] then + scroll = arrMaxSize - i + self:UpdateScrollButtons() + self:UpdateEvents() + return + end end - end end function EavesDrop:ScrollToTop() - scroll = arrMaxSize-arrSize - self:UpdateScrollButtons() - self:UpdateEvents() + scroll = arrMaxSize - arrSize + self:UpdateScrollButtons() + self:UpdateEvents() end function EavesDrop:ScrollToBottom() - scroll = 0 - self:UpdateScrollButtons() - self:UpdateEvents() + scroll = 0 + self:UpdateScrollButtons() + self:UpdateEvents() end function EavesDrop:ScrollUp() - scroll = scroll + 1 - if (scroll > (arrMaxSize-arrSize)) then - scroll = arrMaxSize-arrSize - end - self:UpdateScrollButtons() - self:UpdateEvents() + scroll = scroll + 1 + if (scroll > (arrMaxSize - arrSize)) then scroll = arrMaxSize - arrSize end + self:UpdateScrollButtons() + self:UpdateEvents() end function EavesDrop:ScrollDown() - scroll = scroll - 1 - if (scroll < 0) then - scroll = 0 - end - self:UpdateScrollButtons() - self:UpdateEvents() + scroll = scroll - 1 + if (scroll < 0) then scroll = 0 end + self:UpdateScrollButtons() + self:UpdateEvents() end function EavesDrop:UpdateScrollButtons() - if ( not db["SCROLLBUTTON"]) then - - if (scroll > 0) then - EavesDropFrameDownButton:Show() - if (scroll == arrMaxSize-arrSize) then - EavesDropFrameUpButton:Hide() - else - EavesDropFrameUpButton:Show() - end - else - EavesDropFrameDownButton:Hide() - if (not allShown) then - EavesDropFrameUpButton:Hide() - else - EavesDropFrameUpButton:Show() - end + if (not db["SCROLLBUTTON"]) then + + if (scroll > 0) then + EavesDropFrameDownButton:Show() + if (scroll == arrMaxSize - arrSize) then + EavesDropFrameUpButton:Hide() + else + EavesDropFrameUpButton:Show() + end + else + EavesDropFrameDownButton:Hide() + if (not allShown) then + EavesDropFrameUpButton:Hide() + else + EavesDropFrameUpButton:Show() + end + end end - end end function EavesDrop:SpellColor(option, type) - if (db["SPELLCOLOR"] == true) then - return db[type] or option - else - return option - end + if (db["SPELLCOLOR"] == true) then + return db[type] or option + else + return option + end end ------------------------- ---Set last reflection -function EavesDrop:ParseReflect(timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2, ...) - local spellId, spellName, spellSchool, amount, school, resisted, blocked, absorbed, critical, glancing, crushing = ... - local texture = select(3, GetSpellInfo(spellId)) - local text = amount - local messsage = CombatLog_OnEvent(Blizzard_CombatLog_CurrentSettings, timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags, destFlags2, ...) - - --reflected events - if (self.ReflectTarget == sourceName and sourceName == destName and self.ReflectSkill == spellName) then - local text = string_format("%s: %d", REFLECT, shortenValue(amount)) - if (critical) then text = critchar..text..critchar end - self:DisplayEvent(OUTGOING, text, texture, self:SpellColor(db["TSPELL"], SCHOOL_STRINGS[school]), messsage, spellName) - self:ClearReflect() - end +-- Set last reflection +function EavesDrop:ParseReflect(timestamp, event, hideCaster, sourceGUID, + sourceName, sourceFlags, sourceFlags2, destGUID, + destName, destFlags, destFlags2, ...) + local spellId, spellName, spellSchool, amount, school, resisted, blocked, + absorbed, critical, glancing, crushing = ... + local texture = select(3, GetSpellInfo(spellId)) + local text = amount + local messsage = CombatLog_OnEvent(Blizzard_CombatLog_CurrentSettings, + timestamp, event, hideCaster, sourceGUID, + sourceName, sourceFlags, sourceFlags2, + destGUID, destName, destFlags, + destFlags2, ...) + + -- reflected events + if (self.ReflectTarget == sourceName and sourceName == destName and + self.ReflectSkill == spellName) then + local text = string_format("%s: %d", REFLECT, shortenValue(amount)) + if (critical) then text = critchar .. text .. critchar end + self:DisplayEvent(OUTGOING, text, texture, + self:SpellColor(db["TSPELL"], SCHOOL_STRINGS[school]), + messsage, spellName) + self:ClearReflect() + end end ------------------------- ---Set last reflection +-- Set last reflection function EavesDrop:SetReflect(target, skill) - self.ReflectTarget = target - self.ReflectSkill = skill - --clear reflection after 3 seconds. - self:ScheduleTimer(self.ClearReflect, 3, self) + self.ReflectTarget = target + self.ReflectSkill = skill + -- clear reflection after 3 seconds. + self:ScheduleTimer(self.ClearReflect, 3, self) end ------------------------- ---Clear last reflection +-- Clear last reflection function EavesDrop:ClearReflect() - self.ReflectTarget = nil - self.ReflectSkill = nil + self.ReflectTarget = nil + self.ReflectSkill = nil end ------------------------------ ---Shorten a spell/buff function EavesDrop:ShortenString(strString) - if (db["TRUNCATETYPE"] ~= "0") and strlen(strString) > db["TRUNCATESIZE"] then - if (db["TRUNCATETYPE"] == "1") then - return strsub(strString, 1, db["TRUNCATESIZE"]).."..." - elseif (db["TRUNCATETYPE"] == "2") then - return gsub(gsub(gsub(strString," of ","O"),"%s",""), "(%u)%l*", "%1") + if (db["TRUNCATETYPE"] ~= "0") and strlen(strString) > db["TRUNCATESIZE"] then + if (db["TRUNCATETYPE"] == "1") then + return strsub(strString, 1, db["TRUNCATESIZE"]) .. "..." + elseif (db["TRUNCATETYPE"] == "2") then + return gsub(gsub(gsub(strString, " of ", "O"), "%s", ""), "(%u)%l*", + "%1") + end + else + return strString end - else - return strString - end end ------------------------------ ---Send Text to the editbox function EavesDrop:SendToChat(text) - local tmptext = cleanstring(text) - if tmptext == "" then return end - local edit_box = _G.ChatEdit_ChooseBoxForSend() - if edit_box:IsShown() then - edit_box:Insert(tmptext) - else - _G.ChatEdit_ActivateChat(edit_box) - edit_box:Insert(tmptext) - end + local tmptext = cleanstring(text) + if tmptext == "" then return end + local edit_box = _G.ChatEdit_ChooseBoxForSend() + if edit_box:IsShown() then + edit_box:Insert(tmptext) + else + _G.ChatEdit_ActivateChat(edit_box) + edit_box:Insert(tmptext) + end end ------------------------------ ---Show/Hide history frame function EavesDrop:ShowHistory() - if (not EavesDropHistoryFrame:IsShown()) then - EavesDropHistoryFrame:Show() - else - EavesDropHistoryFrame:Hide() - end - PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON) -end \ No newline at end of file + if (not EavesDropHistoryFrame:IsShown()) then + EavesDropHistoryFrame:Show() + else + EavesDropHistoryFrame:Hide() + end + PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON) +end diff --git a/EavesDrop.xml b/EavesDrop.xml index 6cc617c..36508d3 100644 --- a/EavesDrop.xml +++ b/EavesDrop.xml @@ -202,7 +202,7 @@ - + @@ -222,21 +222,27 @@ + + + + + + - + - + - + @@ -458,6 +464,7 @@ EavesDrop:Scroll(self, delta); + EavesDrop:SetBackdropColor(1,1,1,1) EavesDropTab:SetAlpha(1); @@ -520,7 +527,7 @@ self:RegisterForDrag("LeftButton"); - self:SetAlpha(0); + self:SetAlpha(1); GameTooltip:Hide(); @@ -632,7 +639,7 @@ - + @@ -644,7 +651,7 @@ - + diff --git a/EavesDropStats.lua b/EavesDropStats.lua index be9e547..90238b3 100644 --- a/EavesDropStats.lua +++ b/EavesDropStats.lua @@ -188,8 +188,10 @@ function EavesDrop:SetupHistory() --Frame local r,g,b,a = db["FRAME"].r, db["FRAME"].g, db["FRAME"].b, db["FRAME"].a EavesDropHistoryFrame:SetBackdropColor(r, g, b, a) - EavesDropHistoryTopBar:SetGradientAlpha("VERTICAL", r*.1, g*.1, b*.1, 0, r*.2, g*.2, b*.2, a) - EavesDropHistoryBottomBar:SetGradientAlpha("VERTICAL", r*.2, g*.2, b*.2, a, r*.1, g*.1, b*.1, 0) + + EavesDropHistoryTopBar:SetGradientAlpha("VERTICAL", r*.1, g*.1, b*.1, .5 * a, r*.2, g*.2, b*.2, a) + EavesDropHistoryBottomBar:SetGradientAlpha("VERTICAL", r*.2, g*.2, b*.2, a, r*.1, g*.1, b*.1, 0.5 * a) + r,g,b,a = db["BORDER"].r, db["BORDER"].g, db["BORDER"].b, db["BORDER"].a EavesDropHistoryFrame:SetBackdropBorderColor(r, g, b, a) --position frame (have to schedule cause UI scale is still 1 for some reason during init) From 22d31aef587ffd3ffa381f954937e35ea91ad250 Mon Sep 17 00:00:00 2001 From: TreyH Date: Wed, 30 Nov 2022 17:18:55 -0500 Subject: [PATCH 3/9] ace updates, not yet functional for DF --- EavesDrop.toc | 8 +- libs/AceAddon-3.0/AceAddon-3.0.lua | 171 +++-- libs/AceAddon-3.0/AceAddon-3.0.xml | 2 +- libs/AceConfig-3.0/AceConfig-3.0.lua | 11 +- libs/AceConfig-3.0/AceConfig-3.0.xml | 2 +- .../AceConfigCmd-3.0/AceConfigCmd-3.0.lua | 169 +++-- .../AceConfigCmd-3.0/AceConfigCmd-3.0.xml | 2 +- .../AceConfigDialog-3.0.lua | 590 ++++++++++-------- .../AceConfigDialog-3.0.xml | 2 +- .../AceConfigRegistry-3.0.lua | 54 +- .../AceConfigRegistry-3.0.xml | 2 +- libs/AceConsole-3.0/AceConsole-3.0.lua | 46 +- libs/AceConsole-3.0/AceConsole-3.0.xml | 2 +- libs/AceDB-3.0/AceDB-3.0.lua | 58 +- libs/AceDB-3.0/AceDB-3.0.xml | 2 +- libs/AceDBOptions-3.0/AceDBOptions-3.0.lua | 40 +- libs/AceDBOptions-3.0/AceDBOptions-3.0.xml | 2 +- libs/AceEvent-3.0/AceEvent-3.0.lua | 18 +- libs/AceEvent-3.0/AceEvent-3.0.xml | 2 +- libs/AceGUI-3.0/AceGUI-3.0.lua | 505 ++++++++++----- .../AceGUIContainer-BlizOptionsGroup.lua | 9 +- .../widgets/AceGUIContainer-DropDownGroup.lua | 6 +- .../widgets/AceGUIContainer-Frame.lua | 37 +- .../widgets/AceGUIContainer-InlineGroup.lua | 4 +- .../widgets/AceGUIContainer-ScrollFrame.lua | 33 +- .../widgets/AceGUIContainer-TabGroup.lua | 239 ++++++- .../widgets/AceGUIContainer-TreeGroup.lua | 126 ++-- .../widgets/AceGUIContainer-Window.lua | 129 ++-- .../widgets/AceGUIWidget-Button.lua | 6 +- .../widgets/AceGUIWidget-CheckBox.lua | 67 +- .../widgets/AceGUIWidget-ColorPicker.lua | 26 +- .../widgets/AceGUIWidget-DropDown-Items.lua | 160 +++-- .../widgets/AceGUIWidget-DropDown.lua | 255 ++++---- .../widgets/AceGUIWidget-EditBox.lua | 26 +- .../widgets/AceGUIWidget-Heading.lua | 4 +- libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua | 4 +- .../widgets/AceGUIWidget-InteractiveLabel.lua | 9 +- .../widgets/AceGUIWidget-Keybinding.lua | 8 +- .../AceGUI-3.0/widgets/AceGUIWidget-Label.lua | 45 +- .../widgets/AceGUIWidget-MultiLineEditBox.lua | 29 +- .../widgets/AceGUIWidget-Slider.lua | 35 +- libs/AceLocale-3.0/AceLocale-3.0.lua | 10 +- libs/AceLocale-3.0/AceLocale-3.0.xml | 2 +- libs/AceTimer-3.0/AceTimer-3.0.lua | 42 +- libs/AceTimer-3.0/AceTimer-3.0.xml | 2 +- .../CallbackHandler-1.0.lua | 67 +- .../CallbackHandler-1.0.xml | 2 +- .../CallbackHandler-1.0.lua | 240 ------- .../LibSharedMedia-3.0.lua | 28 +- .../LibSharedMedia-3.0/LibSharedMedia-3.0.toc | 22 - .../LibSharedMedia-3.0/lib.xml | 4 - libs/LibSharedMedia-3.0/LibStub/LibStub.lua | 51 -- libs/LibSharedMedia-3.0/lib.xml | 6 +- libs/LibStub/LibStub.toc | 13 - 54 files changed, 1753 insertions(+), 1681 deletions(-) delete mode 100644 libs/LibSharedMedia-3.0/CallbackHandler-1.0/CallbackHandler-1.0.lua rename libs/LibSharedMedia-3.0/{LibSharedMedia-3.0 => }/LibSharedMedia-3.0.lua (91%) delete mode 100644 libs/LibSharedMedia-3.0/LibSharedMedia-3.0.toc delete mode 100644 libs/LibSharedMedia-3.0/LibSharedMedia-3.0/lib.xml delete mode 100644 libs/LibSharedMedia-3.0/LibStub/LibStub.lua delete mode 100644 libs/LibStub/LibStub.toc diff --git a/EavesDrop.toc b/EavesDrop.toc index 2f348fa..b00aa00 100644 --- a/EavesDrop.toc +++ b/EavesDrop.toc @@ -1,12 +1,12 @@ -## Interface: 90001 +## Interface: 100002 ## Name: EavesDrop ## Title: EavesDrop ## Notes: A simple combat log that displays events similar to SCT -## Version: 2.60 -## Author: Grayhoof (Edited by Domzae) +## Version: 10.0.02 +## Author: Grayhoof (Edited by Domzae, Schoolias) ## SavedVariables: EavesDropDB ## SavedVariablesPerCharacter: EavesDropStatsDB -## X-Website: http://grayhoof.wowinterface.com/ +## X-Website: http://github.com/vbhayden/Eavesdrop ## X-Category: Combat ## X-RelSite-WoWI: 5332 ## X-Embeds: Ace3, LibSharedMedia-3.0 diff --git a/libs/AceAddon-3.0/AceAddon-3.0.lua b/libs/AceAddon-3.0/AceAddon-3.0.lua index a7f7279..f392a21 100644 --- a/libs/AceAddon-3.0/AceAddon-3.0.lua +++ b/libs/AceAddon-3.0/AceAddon-3.0.lua @@ -6,31 +6,31 @@ -- * **OnEnable** which gets called during the PLAYER_LOGIN event, when most of the data provided by the game is already present. -- * **OnDisable**, which is only called when your addon is manually being disabled. -- @usage --- -- A small (but complete) addon, that doesn't do anything, +-- -- A small (but complete) addon, that doesn't do anything, -- -- but shows usage of the callbacks. -- local MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") --- +-- -- function MyAddon:OnInitialize() --- -- do init tasks here, like loading the Saved Variables, +-- -- do init tasks here, like loading the Saved Variables, -- -- or setting up slash commands. -- end --- +-- -- function MyAddon:OnEnable() -- -- Do more initialization here, that really enables the use of your addon. --- -- Register Events, Hook functions, Create Frames, Get information from +-- -- Register Events, Hook functions, Create Frames, Get information from -- -- the game that wasn't available in OnInitialize -- end -- -- function MyAddon:OnDisable() -- -- Unhook, Unregister Events, Hide frames that you created. --- -- You would probably only use an OnDisable if you want to +-- -- You would probably only use an OnDisable if you want to -- -- build a "standby" mode, or be able to toggle modules on/off. -- end -- @class file -- @name AceAddon-3.0.lua --- @release $Id: AceAddon-3.0.lua 1084 2013-04-27 20:14:11Z nevcairiel $ +-- @release $Id: AceAddon-3.0.lua 1284 2022-09-25 09:15:30Z nevcairiel $ -local MAJOR, MINOR = "AceAddon-3.0", 12 +local MAJOR, MINOR = "AceAddon-3.0", 13 local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR) if not AceAddon then return end -- No Upgrade needed. @@ -49,10 +49,6 @@ local select, pairs, next, type, unpack = select, pairs, next, type, unpack local loadstring, assert, error = loadstring, assert, error local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget --- Global vars/functions that we don't upvalue since they might get hooked, or upgraded --- List them here for Mikk's FindGlobals script --- GLOBALS: LibStub, IsLoggedIn, geterrorhandler - --[[ xpcall safecall implementation ]] @@ -62,43 +58,12 @@ local function errorhandler(err) return geterrorhandler()(err) end -local function CreateDispatcher(argCount) - local code = [[ - local xpcall, eh = ... - local method, ARGS - local function call() return method(ARGS) end - - local function dispatch(func, ...) - method = func - if not method then return end - ARGS = ... - return xpcall(call, eh) - end - - return dispatch - ]] - - local ARGS = {} - for i = 1, argCount do ARGS[i] = "arg"..i end - code = code:gsub("ARGS", tconcat(ARGS, ", ")) - return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler) -end - -local Dispatchers = setmetatable({}, {__index=function(self, argCount) - local dispatcher = CreateDispatcher(argCount) - rawset(self, argCount, dispatcher) - return dispatcher -end}) -Dispatchers[0] = function(func) - return xpcall(func, errorhandler) -end - local function safecall(func, ...) -- we check to see if the func is passed is actually a function here and don't error when it isn't -- this safecall is used for optional functions like OnInitialize OnEnable etc. When they are not -- present execution should continue without hinderance if type(func) == "function" then - return Dispatchers[select('#', ...)](func, ...) + return xpcall(func, errorhandler, ...) end end @@ -106,7 +71,7 @@ end local Enable, Disable, EnableModule, DisableModule, Embed, NewModule, GetModule, GetName, SetDefaultModuleState, SetDefaultModuleLibraries, SetEnabledState, SetDefaultModulePrototype -- used in the addon metatable -local function addontostring( self ) return self.name end +local function addontostring( self ) return self.name end -- Check if the addon is queued for initialization local function queuedForInitialization(addon) @@ -119,14 +84,14 @@ local function queuedForInitialization(addon) end --- Create a new AceAddon-3.0 addon. --- Any libraries you specified will be embeded, and the addon will be scheduled for +-- Any libraries you specified will be embeded, and the addon will be scheduled for -- its OnInitialize and OnEnable callbacks. -- The final addon object, with all libraries embeded, will be returned. -- @paramsig [object ,]name[, lib, ...] -- @param object Table to use as a base for the addon (optional) -- @param name Name of the addon object to create -- @param lib List of libraries to embed into the addon --- @usage +-- @usage -- -- Create a simple addon object -- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceEvent-3.0") -- @@ -146,10 +111,10 @@ function AceAddon:NewAddon(objectorname, ...) if type(name)~="string" then error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end - if self.addons[name] then + if self.addons[name] then error(("Usage: NewAddon([object,] name, [lib, lib, lib, ...]): 'name' - Addon '%s' already exists."):format(name), 2) end - + object = object or {} object.name = name @@ -159,7 +124,7 @@ function AceAddon:NewAddon(objectorname, ...) for k, v in pairs(oldmeta) do addonmeta[k] = v end end addonmeta.__tostring = addontostring - + setmetatable( object, addonmeta ) self.addons[name] = object object.modules = {} @@ -167,7 +132,7 @@ function AceAddon:NewAddon(objectorname, ...) object.defaultModuleLibraries = {} Embed( object ) -- embed NewModule, GetModule methods self:EmbedLibraries(object, select(i,...)) - + -- add to queue of addons to be initialized upon ADDON_LOADED tinsert(self.initializequeue, object) return object @@ -178,7 +143,7 @@ end -- Throws an error if the addon object cannot be found (except if silent is set). -- @param name unique name of the addon object -- @param silent if true, the addon is optional, silently return nil if its not found --- @usage +-- @usage -- -- Get the Addon -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") function AceAddon:GetAddon(name, silent) @@ -233,7 +198,7 @@ end -- @paramsig name[, silent] -- @param name unique name of the module -- @param silent if true, the module is optional, silently return nil if its not found (optional) --- @usage +-- @usage -- -- Get the Addon -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- -- Get the Module @@ -256,23 +221,23 @@ local function IsModuleTrue(self) return true end -- @param name unique name of the module -- @param prototype object to derive this module from, methods and values from this table will be mixed into the module (optional) -- @param lib List of libraries to embed into the addon --- @usage +-- @usage -- -- Create a module with some embeded libraries -- MyModule = MyAddon:NewModule("MyModule", "AceEvent-3.0", "AceHook-3.0") --- +-- -- -- Create a module with a prototype -- local prototype = { OnEnable = function(self) print("OnEnable called!") end } -- MyModule = MyAddon:NewModule("MyModule", prototype, "AceEvent-3.0", "AceHook-3.0") function NewModule(self, name, prototype, ...) if type(name) ~= "string" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end if type(prototype) ~= "string" and type(prototype) ~= "table" and type(prototype) ~= "nil" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'prototype' - table (prototype), string (lib) or nil expected got '%s'."):format(type(prototype)), 2) end - + if self.modules[name] then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - Module '%s' already exists."):format(name), 2) end - + -- modules are basically addons. We treat them as such. They will be added to the initializequeue properly as well. -- NewModule can only be called after the parent addon is present thus the modules will be initialized after their parent is. local module = AceAddon:NewAddon(fmt("%s_%s", self.name or tostring(self), name)) - + module.IsModule = IsModuleTrue module:SetEnabledState(self.defaultModuleState) module.moduleName = name @@ -287,24 +252,24 @@ function NewModule(self, name, prototype, ...) if not prototype or type(prototype) == "string" then prototype = self.defaultModulePrototype or nil end - + if type(prototype) == "table" then local mt = getmetatable(module) mt.__index = prototype setmetatable(module, mt) -- More of a Base class type feel. end - + safecall(self.OnModuleCreated, self, module) -- Was in Ace2 and I think it could be a cool thing to have handy. self.modules[name] = module tinsert(self.orderedModules, module) - + return module end --- Returns the real name of the addon or module, without any prefix. -- @name //addon//:GetName --- @paramsig --- @usage +-- @paramsig +-- @usage -- print(MyAddon:GetName()) -- -- prints "MyAddon" function GetName(self) @@ -316,8 +281,8 @@ end -- and enabling all modules of the addon (unless explicitly disabled).\\ -- :Enable() also sets the internal `enableState` variable to true -- @name //addon//:Enable --- @paramsig --- @usage +-- @paramsig +-- @usage -- -- Enable MyModule -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- MyModule = MyAddon:GetModule("MyModule") @@ -337,8 +302,8 @@ end -- and disabling all modules of the addon.\\ -- :Disable() also sets the internal `enableState` variable to false -- @name //addon//:Disable --- @paramsig --- @usage +-- @paramsig +-- @usage -- -- Disable MyAddon -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- MyAddon:Disable() @@ -351,7 +316,7 @@ end -- Short-hand function that retrieves the module via `:GetModule` and calls `:Enable` on the module object. -- @name //addon//:EnableModule -- @paramsig name --- @usage +-- @usage -- -- Enable MyModule using :GetModule -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- MyModule = MyAddon:GetModule("MyModule") @@ -369,7 +334,7 @@ end -- Short-hand function that retrieves the module via `:GetModule` and calls `:Disable` on the module object. -- @name //addon//:DisableModule -- @paramsig name --- @usage +-- @usage -- -- Disable MyModule using :GetModule -- MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon") -- MyModule = MyAddon:GetModule("MyModule") @@ -388,7 +353,7 @@ end -- @name //addon//:SetDefaultModuleLibraries -- @paramsig lib[, lib, ...] -- @param lib List of libraries to embed into the addon --- @usage +-- @usage -- -- Create the addon object -- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") -- -- Configure default libraries for modules (all modules need AceEvent-3.0) @@ -407,7 +372,7 @@ end -- @name //addon//:SetDefaultModuleState -- @paramsig state -- @param state Default state for new modules, true for enabled, false for disabled --- @usage +-- @usage -- -- Create the addon object -- MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon") -- -- Set the default state to "disabled" @@ -427,7 +392,7 @@ end -- @name //addon//:SetDefaultModulePrototype -- @paramsig prototype -- @param prototype Default prototype for the new modules (table) --- @usage +-- @usage -- -- Define a prototype -- local prototype = { OnEnable = function(self) print("OnEnable called!") end } -- -- Set the default prototype @@ -459,8 +424,8 @@ end --- Return an iterator of all modules associated to the addon. -- @name //addon//:IterateModules --- @paramsig --- @usage +-- @paramsig +-- @usage -- -- Enable all modules -- for name, module in MyAddon:IterateModules() do -- module:Enable() @@ -469,13 +434,13 @@ local function IterateModules(self) return pairs(self.modules) end -- Returns an iterator of all embeds in the addon -- @name //addon//:IterateEmbeds --- @paramsig +-- @paramsig local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end --- Query the enabledState of an addon. -- @name //addon//:IsEnabled --- @paramsig --- @usage +-- @paramsig +-- @usage -- if MyAddon:IsEnabled() then -- MyAddon:Disable() -- end @@ -520,20 +485,20 @@ end -- - Initialize the addon after creation. -- This function is only used internally during the ADDON_LOADED event --- It will call the **OnInitialize** function on the addon object (if present), +-- It will call the **OnInitialize** function on the addon object (if present), -- and the **OnEmbedInitialize** function on all embeded libraries. --- +-- -- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. -- @param addon addon object to intialize function AceAddon:InitializeAddon(addon) safecall(addon.OnInitialize, addon) - + local embeds = self.embeds[addon] for i = 1, #embeds do local lib = LibStub:GetLibrary(embeds[i], true) if lib then safecall(lib.OnEmbedInitialize, lib, addon) end end - + -- we don't call InitializeAddon on modules specifically, this is handled -- from the event handler and only done _once_ end @@ -541,7 +506,7 @@ end -- - Enable the addon after creation. -- Note: This function is only used internally during the PLAYER_LOGIN event, or during ADDON_LOADED, -- if IsLoggedIn() already returns true at that point, e.g. for LoD Addons. --- It will call the **OnEnable** function on the addon object (if present), +-- It will call the **OnEnable** function on the addon object (if present), -- and the **OnEmbedEnable** function on all embeded libraries.\\ -- This function does not toggle the enable state of the addon itself, and will return early if the addon is disabled. -- @@ -551,12 +516,12 @@ end function AceAddon:EnableAddon(addon) if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end if self.statuses[addon.name] or not addon.enabledState then return false end - + -- set the statuses first, before calling the OnEnable. this allows for Disabling of the addon in OnEnable. self.statuses[addon.name] = true - + safecall(addon.OnEnable, addon) - + -- make sure we're still enabled before continueing if self.statuses[addon.name] then local embeds = self.embeds[addon] @@ -564,7 +529,7 @@ function AceAddon:EnableAddon(addon) local lib = LibStub:GetLibrary(embeds[i], true) if lib then safecall(lib.OnEmbedEnable, lib, addon) end end - + -- enable possible modules. local modules = addon.orderedModules for i = 1, #modules do @@ -576,24 +541,24 @@ end -- - Disable the addon -- Note: This function is only used internally. --- It will call the **OnDisable** function on the addon object (if present), +-- It will call the **OnDisable** function on the addon object (if present), -- and the **OnEmbedDisable** function on all embeded libraries.\\ -- This function does not toggle the enable state of the addon itself, and will return early if the addon is still enabled. -- --- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. +-- **Note:** Do not call this function manually, unless you're absolutely sure that you know what you are doing. -- Use :Disable on the addon itself instead. -- @param addon addon object to enable function AceAddon:DisableAddon(addon) if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end if not self.statuses[addon.name] then return false end - + -- set statuses first before calling OnDisable, this allows for aborting the disable in OnDisable. self.statuses[addon.name] = false - + safecall( addon.OnDisable, addon ) - + -- make sure we're still disabling... - if not self.statuses[addon.name] then + if not self.statuses[addon.name] then local embeds = self.embeds[addon] for i = 1, #embeds do local lib = LibStub:GetLibrary(embeds[i], true) @@ -605,12 +570,12 @@ function AceAddon:DisableAddon(addon) self:DisableAddon(modules[i]) end end - + return not self.statuses[addon.name] -- return true if we're disabled end --- Get an iterator over all registered addons. --- @usage +-- @usage -- -- Print a list of all installed AceAddon's -- for name, addon in AceAddon:IterateAddons() do -- print("Addon: " .. name) @@ -618,7 +583,7 @@ end function AceAddon:IterateAddons() return pairs(self.addons) end --- Get an iterator over the internal status registry. --- @usage +-- @usage -- -- Print a list of all enabled addons -- for name, status in AceAddon:IterateAddonStatus() do -- if status then @@ -632,10 +597,20 @@ function AceAddon:IterateAddonStatus() return pairs(self.statuses) end function AceAddon:IterateEmbedsOnAddon(addon) return pairs(self.embeds[addon]) end function AceAddon:IterateModulesOfAddon(addon) return pairs(addon.modules) end +-- Blizzard AddOns which can load very early in the loading process and mess with Ace3 addon loading +local BlizzardEarlyLoadAddons = { + Blizzard_DebugTools = true, + Blizzard_TimeManager = true, + Blizzard_BattlefieldMap = true, + Blizzard_MapCanvas = true, + Blizzard_SharedMapDataProviders = true, + Blizzard_CombatLog = true, +} + -- Event Handling local function onEvent(this, event, arg1) - -- 2011-08-17 nevcairiel - ignore the load event of Blizzard_DebugTools, so a potential startup error isn't swallowed up - if (event == "ADDON_LOADED" and arg1 ~= "Blizzard_DebugTools") or event == "PLAYER_LOGIN" then + -- 2020-08-28 nevcairiel - ignore the load event of Blizzard addons which occur early in the loading process + if (event == "ADDON_LOADED" and (arg1 == nil or not BlizzardEarlyLoadAddons[arg1])) or event == "PLAYER_LOGIN" then -- if a addon loads another addon, recursion could happen here, so we need to validate the table on every iteration while(#AceAddon.initializequeue > 0) do local addon = tremove(AceAddon.initializequeue, 1) @@ -644,7 +619,7 @@ local function onEvent(this, event, arg1) AceAddon:InitializeAddon(addon) tinsert(AceAddon.enablequeue, addon) end - + if IsLoggedIn() then while(#AceAddon.enablequeue > 0) do local addon = tremove(AceAddon.enablequeue, 1) diff --git a/libs/AceAddon-3.0/AceAddon-3.0.xml b/libs/AceAddon-3.0/AceAddon-3.0.xml index e6ad639..dcf24c7 100644 --- a/libs/AceAddon-3.0/AceAddon-3.0.xml +++ b/libs/AceAddon-3.0/AceAddon-3.0.xml @@ -1,4 +1,4 @@