diff --git a/Libs/DF/auras.lua b/Libs/DF/auras.lua index 39089b7f..f651cb9a 100644 --- a/Libs/DF/auras.lua +++ b/Libs/DF/auras.lua @@ -424,8 +424,8 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t return end - --add the spellId to the blacklist - f.db.aura_tracker.buff_banned [spellId] = true + --add the spellName to the blacklist + f.db.aura_tracker.buff_banned [spellId] = true --refresh the buff blacklist frame f.buff_ignored:DoRefresh() @@ -436,7 +436,38 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t same_name_spells_add (spellId) end - end, textEntryWidth, 20, "Add to Blacklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + end, textEntryWidth/2 -3, 20, "By Name", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + + local add_blacklist_buff_button_id = self:CreateButton (background_add_blacklist, function() + local text = buff_name_blacklist_entry.text + buff_name_blacklist_entry:SetText ("") + buff_name_blacklist_entry:ClearFocus() + + if (text ~= "") then + if (not tonumber(text)) then + DetailsFramework.Msg ({__name = "DetailsFramework"}, "Invalid Spell-ID.") + end + + --get the spellId + local spellId = get_spellID_from_string (text) + if (not spellId) then + DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") + return + end + + --add the spellId to the blacklist + f.db.aura_tracker.buff_banned [spellId] = false + + --refresh the buff blacklist frame + f.buff_ignored:DoRefresh() + + DF:QuickDispatch (change_callback) + + --add to spells with the same name cache + same_name_spells_add (spellId) + end + + end, textEntryWidth/2 -3, 20, "By ID", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) local add_blacklist_debuff_button = self:CreateButton (background_add_blacklist, function() local text = debuff_name_blacklist_entry.text @@ -451,7 +482,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t return end - --add the spellId to the blacklist + --add the spellName to the blacklist f.db.aura_tracker.debuff_banned [spellId] = true --refresh the buff blacklist frame @@ -462,7 +493,37 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t --add to spells with the same name cache same_name_spells_add (spellId) end - end, textEntryWidth, 20, "Add to Blacklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + end, textEntryWidth/2 -3, 20, "By Name", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + + local add_blacklist_debuff_button_id = self:CreateButton (background_add_blacklist, function() + local text = debuff_name_blacklist_entry.text + debuff_name_blacklist_entry:SetText ("") + debuff_name_blacklist_entry:ClearFocus() + + if (text ~= "") then + if (not tonumber(text)) then + DetailsFramework.Msg ({__name = "DetailsFramework"}, "Invalid Spell-ID.") + end + + --get the spellId + local spellId = get_spellID_from_string (text) + if (not spellId) then + DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") + return + end + + --add the spellId to the blacklist + f.db.aura_tracker.debuff_banned [spellId] = false + + --refresh the buff blacklist frame + f.debuff_ignored:DoRefresh() + + DF:QuickDispatch (change_callback) + + --add to spells with the same name cache + same_name_spells_add (spellId) + end + end, textEntryWidth/2 -3, 20, "By ID", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) --track list @@ -493,8 +554,8 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") return end - - --add the spellId to the blacklist + + --add the spellName to the tracklist f.db.aura_tracker.debuff_tracked [spellId] = true --refresh the buff blacklist frame @@ -505,7 +566,36 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t --add to spells with the same name cache same_name_spells_add (spellId) end - end, textEntryWidth, 20, "Add to Tracklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + end, textEntryWidth/2 -3, 20, "By Name", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + + local add_tracklist_debuff_button_id = self:CreateButton (background_add_tracklist, function() + local text = debuff_name_tracklist_entry.text + debuff_name_tracklist_entry:SetText ("") + debuff_name_tracklist_entry:ClearFocus() + + if (text ~= "") then + if (not tonumber(text)) then + DetailsFramework.Msg ({__name = "DetailsFramework"}, "Invalid Spell-ID.") + end + + --get the spellId + local spellId = get_spellID_from_string (text) + if (not spellId) then + DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") + return + end + + f.db.aura_tracker.debuff_tracked [spellId] = false + + --refresh the buff blacklist frame + f.debuff_tracked:DoRefresh() + + DF:QuickDispatch (change_callback) + + --add to spells with the same name cache + same_name_spells_add (spellId) + end + end, textEntryWidth/2 -3, 20, "By ID", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) local add_tracklist_buff_button = self:CreateButton (background_add_tracklist, function() local text = buff_name_tracklist_entry.text @@ -520,8 +610,8 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t return end - --add the spellId to the blacklist - f.db.aura_tracker.buff_tracked [spellId] = true + --add the spellName to the tracklist + f.db.aura_tracker.buff_tracked [spellId] = true --refresh the buff tracklist frame f.buff_tracked:DoRefresh() @@ -533,7 +623,38 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t same_name_spells_add (spellId) end - end, textEntryWidth, 20, "Add to Tracklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + end, textEntryWidth/2 -3, 20, "By Name", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + + local add_tracklist_buff_button_id = self:CreateButton (background_add_tracklist, function() + local text = buff_name_tracklist_entry.text + buff_name_tracklist_entry:SetText ("") + buff_name_tracklist_entry:ClearFocus() + + if (text ~= "") then + if (not tonumber(text)) then + DetailsFramework.Msg ({__name = "DetailsFramework"}, "Invalid Spell-ID.") + end + + --get the spellId + local spellId = get_spellID_from_string (text) + if (not spellId) then + DetailsFramework.Msg ({__name = "DetailsFramework"}, "Spell not found!") + return + end + + --add the spellId to the tracklist + f.db.aura_tracker.buff_tracked [spellId] = false + + --refresh the buff tracklist frame + f.buff_tracked:DoRefresh() + + --callback the addon + DF:QuickDispatch (change_callback) + + --add to spells with the same name cache + same_name_spells_add (spellId) + end + end, textEntryWidth/2 -3, 20, "By ID", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) --anchors: background_add_blacklist:SetPoint ("topleft", f_auto, "topleft", 0, y) @@ -543,22 +664,26 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t debuff_name_blacklist_entry:SetPoint ("topleft", background_add_blacklist, "topleft", 5, -20) debuff_blacklist_label:SetPoint ("bottomleft", debuff_name_blacklist_entry, "topleft", 0, 2) add_blacklist_debuff_button:SetPoint ("topleft", debuff_name_blacklist_entry, "bottomleft", 0, -2) + add_blacklist_debuff_button_id:SetPoint ("left", add_blacklist_debuff_button, "right", 1, 0) --buff blacklist buff_blacklist_label:SetPoint ("topleft", add_blacklist_debuff_button.widget, "bottomleft", 0, -10) buff_name_blacklist_entry:SetPoint ("topleft", buff_blacklist_label, "bottomleft", 0, -2) add_blacklist_buff_button:SetPoint ("topleft", buff_name_blacklist_entry, "bottomleft", 0, -2) + add_blacklist_buff_button_id:SetPoint ("left", add_blacklist_buff_button, "right", 1, 0) --debuff tracklist debuff_name_tracklist_entry:SetPoint ("topleft", background_add_tracklist, "topleft", 5, -20) debuff_tracklist_label:SetPoint ("bottomleft", debuff_name_tracklist_entry, "topleft", 0, 2) add_tracklist_debuff_button:SetPoint ("topleft", debuff_name_tracklist_entry, "bottomleft", 0, -2) + add_tracklist_debuff_button_id:SetPoint ("left", add_tracklist_debuff_button, "right", 1, 0) --buff tracklist buff_tracklist_label:SetPoint ("topleft", add_tracklist_debuff_button.widget, "bottomleft", 0, -10) buff_name_tracklist_entry:SetPoint ("topleft", buff_tracklist_label, "bottomleft", 0, -2) add_tracklist_buff_button:SetPoint ("topleft", buff_name_tracklist_entry, "bottomleft", 0, -2) + add_tracklist_buff_button_id:SetPoint ("left", add_tracklist_buff_button, "right", 1, 0) local ALL_BUFFS = {} local ALL_DEBUFFS = {} @@ -568,31 +693,46 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t local autoTrackList_LineOnEnter = function (self, capsule, value) + local flag = self.Flag value = value or self.SpellID - local spellName = GetSpellInfo (value) - if (spellName) then - - local spellsWithSameName = db.aura_cache_by_name [lower (spellName)] - if (not spellsWithSameName) then - same_name_spells_add (value) - spellsWithSameName = db.aura_cache_by_name [lower (spellName)] - end + if not flag then + GameCooltip2:Preset (2) + GameCooltip2:SetOwner (self, "left", "right", 2, 0) + GameCooltip2:SetOption ("TextSize", 10) - if (spellsWithSameName) then - GameCooltip2:Preset (2) - GameCooltip2:SetOwner (self, "left", "right", 2, 0) - GameCooltip2:SetOption ("TextSize", 10) - - for i, spellID in ipairs (spellsWithSameName) do - local spellName, _, spellIcon = GetSpellInfo (spellID) - if (spellName) then - GameCooltip2:AddLine (spellName .. " (" .. spellID .. ")") - GameCooltip2:AddIcon (spellIcon, 1, 1, 14, 14, .1, .9, .1, .9) - end + local spellName, _, spellIcon = GetSpellInfo (value) + if (spellName) then + GameCooltip2:AddLine (spellName .. " (" .. value .. ")") + GameCooltip2:AddIcon (spellIcon, 1, 1, 14, 14, .1, .9, .1, .9) + end + GameCooltip2:Show() + else + + local spellName = GetSpellInfo (value) + if (spellName) then + + local spellsWithSameName = db.aura_cache_by_name [lower (spellName)] + if (not spellsWithSameName) then + same_name_spells_add (value) + spellsWithSameName = db.aura_cache_by_name [lower (spellName)] end - GameCooltip2:Show() + if (spellsWithSameName) then + GameCooltip2:Preset (2) + GameCooltip2:SetOwner (self, "left", "right", 2, 0) + GameCooltip2:SetOption ("TextSize", 10) + + for i, spellID in ipairs (spellsWithSameName) do + local spellName, _, spellIcon = GetSpellInfo (spellID) + if (spellName) then + GameCooltip2:AddLine (spellName .. " (" .. spellID .. ")") + GameCooltip2:AddIcon (spellIcon, 1, 1, 14, 14, .1, .9, .1, .9) + end + end + + GameCooltip2:Show() + end end end @@ -617,13 +757,19 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t local auraTable = data [index] if (auraTable) then local line = self:GetLine (i) - local spellID, spellName, spellIcon = unpack (auraTable) + local spellID, spellName, spellIcon, lowerSpellName, flag = unpack (auraTable) line.SpellID = spellID line.SpellName = spellName + line.SpellNameLower = lowerSpellName line.SpellIcon = spellIcon + line.Flag = flag - line.name:SetText (spellName) + if flag then + line.name:SetText (spellName) + else + line.name:SetText (spellName .. " (" .. spellID .. ")") + end line.icon:SetTexture (spellIcon) line.icon:SetTexCoord (.1, .9, .1, .9) end @@ -647,6 +793,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t local onRemoveClick = function (self) local spellID = self:GetParent().SpellID db [spellID] = nil + db ["".. (spellID or "")] = nil -- cleanup... parent [member]:DoRefresh() end @@ -691,11 +838,13 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t function scroll:DoRefresh() local t = {} - for spellID, _ in pairs (scroll.OriginalData) do + local added = {} + for spellID, flag in pairs (scroll.OriginalData) do local spellName, _, spellIcon = GetSpellInfo (spellID) - if (spellName) then + if (spellName and not added[tonumber(spellID) or 0]) then local lowerSpellName = spellName:lower() - tinsert (t, {spellID, spellName, spellIcon, lowerSpellName}) + tinsert (t, {spellID, spellName, spellIcon, lowerSpellName, flag}) + added[tonumber(spellID) or 0] = true end end @@ -756,7 +905,7 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t buff_tracked:DoRefresh() debuff_tracked:DoRefresh() - buff_ignored:DoRefresh() + buff_ignored:DoRefresh() debuff_ignored:DoRefresh() end) @@ -923,6 +1072,13 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t if (spellID) then tinsert (f.db.aura_tracker.buff, spellID) + --[[ + if not tonumber(spellName) then + tinsert (f.db.aura_tracker.buff, spellName) + else + tinsert (f.db.aura_tracker.buff, spellID) + end + ]]-- else print ("spellId not found for spell:", spellName) end @@ -936,6 +1092,13 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t end tinsert (f.db.aura_tracker.buff, spellID) + --[[ + if not tonumber(text) then + tinsert (f.db.aura_tracker.buff, text) + else + tinsert (f.db.aura_tracker.buff, spellID) + end + ]]-- end buffs_added:Refresh() @@ -956,6 +1119,13 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t if (spellID) then tinsert (f.db.aura_tracker.debuff, spellID) + --[[ + if not tonumber(spellName) then + tinsert (f.db.aura_tracker.debuff, spellName) + else + tinsert (f.db.aura_tracker.debuff, spellID) + end + ]]-- else print ("spellId not found for spell:", spellName) end @@ -969,6 +1139,15 @@ function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, t end tinsert (f.db.aura_tracker.debuff, spellID) + --[[ + if not tonumber(text) then + print(text) + tinsert (f.db.aura_tracker.debuff, text) + else + print(spellID) + tinsert (f.db.aura_tracker.debuff, spellID) + end + ]]-- end debuffs_added:Refresh() diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index fca7c354..9304df50 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 233 +local dversion = 236 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary (major, minor) @@ -2409,6 +2409,16 @@ end ----------------------------- function DF:OpenInterfaceProfile() + -- OptionsFrame1/2 should be registered if created with DF:CreateAddOn, so open to them directly + if self.OptionsFrame1 then + InterfaceOptionsFrame_OpenToCategory (self.OptionsFrame1) + if self.OptionsFrame2 then + InterfaceOptionsFrame_OpenToCategory (self.OptionsFrame2) + end + return + end + + -- fallback (broken as of ElvUI Skins in version 12.18+... maybe fix/change will come) InterfaceOptionsFrame_OpenToCategory (self.__name) InterfaceOptionsFrame_OpenToCategory (self.__name) for i = 1, 100 do diff --git a/Libs/DF/panel.lua b/Libs/DF/panel.lua index 45b7ba1b..9c10a00c 100644 --- a/Libs/DF/panel.lua +++ b/Libs/DF/panel.lua @@ -9226,7 +9226,7 @@ function DF:CreateUnitFrame (parent, name, unitFrameSettingsOverride, healthBarS --> overlay frame (widgets that need to stay above the unit frame) local overlayFrame = CreateFrame ("frame", "$parentOverlayFrame", f, "BackdropTemplate") - borderFrame:SetFrameLevel (f:GetFrameLevel() + 6) + overlayFrame:SetFrameLevel (f:GetFrameLevel() + 6) f.overlayFrame = overlayFrame --> unit frame layers @@ -10038,13 +10038,16 @@ DF.ListboxFunctions = { for i = 1, totalLines do local index = i + offset local lineData = data[index] --what is shown in the textentries, array + if (lineData) then local line = self:GetLine(i) line.dataIndex = index line.deleteButton:SetClickFunction(DF.ListboxFunctions.deleteEntry, data, index) + line.indexText:SetText(index) local amountEntries = #lineData for o = 1, amountEntries do + --data local textEntry = line.widgets[o] textEntry.dataTable = lineData textEntry.dataTableIndex = o @@ -10082,12 +10085,13 @@ DF.ListboxFunctions = { local options = listBox.options line:SetBackdrop(options.line_backdrop) line:SetBackdropColor(unpack(options.line_backdrop_color)) + line:SetBackdropBorderColor(unpack(options.line_backdrop_border_color)) DF:Mixin(line, DF.HeaderFunctions) line.widgets = {} - for i = 1, (listBox.headerLength+1) do --+1 to add the delete button + for i = 1, (listBox.headerLength+2) do --+2 to add the delete button and index local headerColumn = listBox.headerTable[i] if (headerColumn.isDelete) then @@ -10095,9 +10099,16 @@ DF.ListboxFunctions = { line.deleteButton = deleteButton line:AddFrameToHeaderAlignment(deleteButton) + elseif (headerColumn.isIndex) then + local indexText = DF:CreateLabel(line) + line.indexText = indexText + line:AddFrameToHeaderAlignment(indexText) + elseif (headerColumn.text) then local template = DF.table.copy({}, DF:GetTemplate("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) - template.backdropcolor = {0.1, 0.1, 0.1, .7} + template.backdropcolor = {.1, .1, .1, .7} + template.backdropbordercolor = {.2, .2, .2, .6} + local textEntry = DF:CreateTextEntry(line, function()end, headerColumn.width, self.lineHeight, nil, nil, nil, template) textEntry:SetHook("OnEditFocusGained", function() textEntry:HighlightText(0) end) textEntry:SetHook("OnEditFocusLost", function() @@ -10122,6 +10133,7 @@ DF.ListboxFunctions = { end frameCanvas.data = newData + frameCanvas.scrollBox:SetData(newData) frameCanvas.scrollBox:Refresh() end, } @@ -10132,7 +10144,8 @@ local listbox_options = { auto_width = true, line_height = 16, line_backdrop = {bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}, - line_backdrop_color = {.3, .3, .3, .8}, + line_backdrop_color = {.1, .1, .1, .6}, + line_backdrop_border_color = {0, 0, 0, .5}, } --@parent: parent frame @@ -10165,8 +10178,8 @@ function DF:CreateListBox(parent, name, data, options, headerTable, headerOption --> header --check for default values in the header headerTable = headerTable or { - {text = "Spell Name", width = 70}, {text = "Spell Id", width = 70}, + {text = "Spell Name", width = 70}, } headerOptions = headerOptions or { padding = 2, @@ -10176,6 +10189,7 @@ function DF:CreateListBox(parent, name, data, options, headerTable, headerOption frameCanvas.headerLength = #headerTable --add the detele line column into the header frame + tinsert(headerTable, 1, {text = "#", width = 20, isIndex = true}) --isDelete signals the createScrollLine() to make the delete button for the line tinsert(headerTable, {text = "Delete", width = 50, isDelete = true}) --isDelete signals the createScrollLine() to make the delete button for the line local header = DF:CreateHeader(frameCanvas, headerTable, headerOptions) @@ -10206,7 +10220,8 @@ function DF:CreateListBox(parent, name, data, options, headerTable, headerOption --> scroll frame local lineHeight = frameCanvas.options.line_height - local lineAmount = floor(height / lineHeight) + --calc the size of the space occupied by the add button, header etc + local lineAmount = floor((height - 60) / lineHeight) -- -12 is padding: 5 on top, 7 bottom, 2 header scrollbar blank space | -24 to leave space to the add button local scrollBox = DF:CreateScrollBox(frameCanvas, "$parentScrollbox", frameCanvas.scrollRefresh, data, width-4, height - header:GetHeight() - 12 - 24, lineAmount, lineHeight) diff --git a/Libs/DF/spells.lua b/Libs/DF/spells.lua index 0ede4b4a..1fed15a1 100644 --- a/Libs/DF/spells.lua +++ b/Libs/DF/spells.lua @@ -759,6 +759,7 @@ DF.CrowdControlSpells = { [221562] = "DEATHKNIGHT", --Asphyxiate [108194] = "DEATHKNIGHT", --Asphyxiate (talent) [207167] = "DEATHKNIGHT", --Blinding Sleet + [334693] = "DEAHTKNIGHT", --Absolute Zero (legendary) [339] = "DRUID", --Entangling Roots [2637] = "DRUID", --Hibernate @@ -807,6 +808,8 @@ DF.CrowdControlSpells = { [200166] = "DEMONHUNTER", --Metamorphosis [207685] = "DEMONHUNTER", --Sigil of Misery [211881] = "DEMONHUNTER", -- Fel Eruption + + [331866] = "COVENANT|VENTHYR", --Agent of Chaos (Nadia soulbind) } DF.SpecIds = { @@ -859,6 +862,69 @@ DF.SpecIds = { [270] = "MONK", } +DF.ClassSpecIds = { --private + ["DEMONHUNTER"] = { + [577] = true, + [581] = true, + }, + ["DEATHKNIGHT"] = { + [250] = true, + [251] = true, + [252] = true, + }, + ["WARRIOR"] = { + [71] = true, + [72] = true, + [73] = true, + }, + ["MAGE"] = { + [62] = true, + [63] = true, + [64] = true, + }, + ["ROGUE"] = { + [259] = true, + [260] = true, + [261] = true, + }, + ["DRUID"] = { + [102] = true, + [103] = true, + [104] = true, + [105] = true, + }, + ["HUNTER"] = { + [253] = true, + [254] = true, + [255] = true, + }, + ["SHAMAN"] = { + [262] = true, + [263] = true, + [264] = true, + }, + ["PRIEST"] = { + [256] = true, + [257] = true, + [258] = true, + }, + ["WARLOCK"] = { + [265] = true, + [266] = true, + [267] = true, + }, + ["PALADIN"] = { + [65] = true, + [66] = true, + [70] = true, + }, + ["MONK"] = { + [268] = true, + [269] = true, + [270] = true, + }, +} + DF.CooldownToClass = {} DF.CooldownsAttack = {} diff --git a/functions/pack.lua b/functions/pack.lua index 4f4c83c0..dd17ca98 100644 --- a/functions/pack.lua +++ b/functions/pack.lua @@ -18,6 +18,7 @@ local IsInRaid = _G.IsInRaid local GetNumGroupMembers = _G.GetNumGroupMembers local GetRaidRosterInfo = _G.GetRaidRosterInfo local unpack = _G.unpack +local IsInGroup = _G.IsInGroup Details.packFunctions = {} @@ -106,7 +107,7 @@ function Details.packFunctions.PackCombatData(combatObject, flags) Details.packFunctions.PackDamage(combatObject) end - if (bit.band(flags, 0x2) ~= 0 and false) then + if (bit.band(flags, 0x2) ~= 0) then Details.packFunctions.PackHeal(combatObject) end @@ -134,7 +135,7 @@ function Details.packFunctions.PackCombatData(combatObject, flags) end --add the heal actors data - if (bit.band(flags, 0x2) ~= 0 and false) then + if (bit.band(flags, 0x2) ~= 0) then exportedString = exportedString .. "!H" .. "," for index, data in ipairs(actorHealInfo) do exportedString = exportedString .. data .. "," @@ -425,7 +426,7 @@ function Details.packFunctions.PackDamage(combatObject) end end - local playerIndex = UnitInRaid("player") + local playerIndex = _G.UnitInRaid("player") if (not playerIndex) then --no player index if (isDebugging) then @@ -462,7 +463,7 @@ function Details.packFunctions.PackDamage(combatObject) for i = 1, 20 do local name, _, subgroup = GetRaidRosterInfo(i) if (name) then --maybe the group has less than 20 players - name = Ambiguate(name, "none") + name = _G.Ambiguate(name, "none") if (name and subgroup <= 4) then tinsert(allPlayerNames, name) end @@ -588,8 +589,8 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi --get or create the actor object local actorObject = damageContainer:GetOrCreateActor(serialNumber, actorName, actorFlag, true) - --set the actor class, spec and group + --set the actor class, spec and group actorObject.classe = class actorObject.spec = spec actorObject.grupo = isActorInGroup(class, actorFlag) @@ -635,7 +636,6 @@ function Details.packFunctions.UnPackDamage(currentCombat, combatData, tablePosi spellIndex = spellIndex + targetsSize + 4 end - --each iteration need to build a new target table actorObject.targets = newTargetsTable tablePosition = tablePosition + spellsSize --increase table position end @@ -676,19 +676,9 @@ function Details.packFunctions.PackHeal(combatObject) end end - local playerIndex - --check if this player has to send information about an enemy npc - if (IsInGroup()) then - for i = 1, GetNumGroupMembers() do - local name = GetRaidRosterInfo(i) - if (name == playerName) then - playerIndex = i - break - end - end - end + local playerIndex = UnitInRaid("player") - if (not playerIndex) then + if (not playerIndex) then --no player index if (isDebugging) then print("PackHeal(): return | no player index found.") end @@ -705,9 +695,10 @@ function Details.packFunctions.PackHeal(combatObject) --check if is an enemy or neutral if (actor:IsNeutralOrEnemy()) then --get the spawnId - local spawnId = select(7, strsplit( "-", actor.serial)) + local spawnId = select(7, strsplit("-", actor.serial)) if (spawnId) then - spawnId = tonumber(spawnId) + --convert hex to number + spawnId = tonumber(spawnId:sub(1, 10), 16) if (spawnId) then --first index is the actorObject, the second index is the spawnId to sort enemies tinsert(allEnemies, {actor, spawnId}) @@ -715,12 +706,31 @@ function Details.packFunctions.PackHeal(combatObject) end end end - --sort enemies by their spawnId table.sort(allEnemies, Details.Sort2) + local allPlayerNames = {} + for i = 1, 20 do + local name, _, subgroup = GetRaidRosterInfo(i) + if (name) then --maybe the group has less than 20 players + name = Ambiguate(name, "none") + if (name and subgroup <= 4) then + tinsert(allPlayerNames, name) + end + end + end + table.sort(allPlayerNames, function(t1, t2) return t1 < t2 end) + + local playerName = UnitName("player") + for i = 1, #allPlayerNames do + if (playerName == allPlayerNames[i]) then + playerIndex = i + break + end + end + --this is the enemy that this player has to send - local enemyObjectToSend = allEnemies[playerIndex] + local enemyObjectToSend = allEnemies[playerIndex] and allEnemies[playerIndex][1] if (enemyObjectToSend) then tinsert(actorsToPack, enemyObjectToSend) end @@ -735,8 +745,6 @@ function Details.packFunctions.PackHeal(combatObject) end end - local spellSize = 0 - for i = 1, #actorsToPack do --get the actor object local actor = actorsToPack[i] @@ -745,8 +753,8 @@ function Details.packFunctions.PackHeal(combatObject) --where the information of this actor starts local currentIndex = #actorHealInfo + 1 - --[1] index where is stored the this actor general information - actorHealInfo[currentIndex] = indexToActorInfo --[1] + --[1] index where is stored the this actor info like name, class, spec, etc + actorHealInfo[currentIndex] = indexToActorInfo --[1] --[2 - 6] actorHealInfo [currentIndex + 1] = floor(actor.total) --[2] @@ -770,28 +778,22 @@ function Details.packFunctions.PackHeal(combatObject) actorHealInfo [#actorHealInfo + 1] = floor(spellId) actorHealInfo [#actorHealInfo + 1] = floor(spellHealingDone) actorHealInfo [#actorHealInfo + 1] = floor(spellHits) + totalSpellIndexes = totalSpellIndexes + 3 --build targets local targetsSize = Details.packFunctions.CountTableEntriesValid(spellTargets) * 2 actorHealInfo [#actorHealInfo + 1] = targetsSize + totalSpellIndexes = totalSpellIndexes + 1 - for actorName, damageDone in pairs(spellTargets) do - local actorInfoIndex = actorInformationIndexes[actorName] - if (actorInfoIndex) then - actorHealInfo [#actorHealInfo + 1] = actorInfoIndex - actorHealInfo [#actorHealInfo + 1] = floor(damageDone) - spellSize = spellSize + 2 - end + for actorName, healingDone in pairs(spellTargets) do + actorHealInfo [#actorHealInfo + 1] = actorName + actorHealInfo [#actorHealInfo + 1] = floor(healingDone) + totalSpellIndexes = totalSpellIndexes + 2 end - - --+3: spellId, damage, spellHits - --+1: the index that tell the size of targets - totalSpellIndexes = totalSpellIndexes + 3 + targetsSize + 1 - spellSize = spellSize + 1 --debug end --amount of indexes spells are using - actorDamageInfo[reservedSpellSizeIndex] = totalSpellIndexes + actorHealInfo[reservedSpellSizeIndex] = totalSpellIndexes end if (isDebugging) then @@ -811,8 +813,12 @@ function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePositi --get the healing container local healContainer = currentCombat[DETAILS_ATTRIBUTE_HEAL] + --loop from 1 to 199, the amount of actors store is unknown + --todo: it's only unpacking the first actor from the table, e.g. theres izimode and eye of corruption, after export it only shows the eye of corruption + --table position does not move forward for i = 1, 199 do - --this is the same as damage, all comments for the code are there + --actor information index in the combatData table + --this index gives the position where the actor name, class, spec are stored local actorReference = tonumber(combatData[tablePosition]) --[1] local actorName, actorFlag, serialNumber, class, spec = Details.packFunctions.RetriveActorInformation(combatData, actorReference) @@ -820,6 +826,7 @@ function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePositi print("UnPackHeal(): Retrivied Data From " .. (actorReference or "nil") .. ":", actorName, actorFlag, serialNumber, class, spec) end + --check if all healing actors has been processed --if there's no actor name it means it reached the end if (not actorName) then if (isDebugging) then @@ -828,43 +835,56 @@ function Details.packFunctions.UnPackHeal(currentCombat, combatData, tablePositi break end - --creata the actor object + --get or create the actor object local actorObject = healContainer:GetOrCreateActor(serialNumber, actorName, actorFlag, true) + --set the actor class, spec and group actorObject.classe = class actorObject.spec = spec actorObject.grupo = isActorInGroup(class, actorFlag) + actorObject.flag_original = actorFlag --> copy the base healing actorObject.total = tonumber(combatData[tablePosition+1]) --[2] actorObject.totalabsorb = tonumber(combatData[tablePosition+2]) --[3] actorObject.totalover = tonumber(combatData[tablePosition+3]) --[4] actorObject.healing_taken = tonumber(combatData[tablePosition+4]) --[5] - actorObject.totalover_without_pet = tonumber(combatData[tablePosition+5]) --[6] + actorObject.totalover_without_pet = tonumber(combatData[tablePosition+5]) --[6] tablePosition = tablePosition + 6 --> copy back the actor spells --amount of indexes used to store spells for this actor local spellsSize = tonumber(combatData [tablePosition]) --[7] + if (isDebugging) then + print("spell size unpack:", spellsSize) + end + tablePosition = tablePosition + 1 + local newTargetsTable = {} local spellIndex = tablePosition while(spellIndex < tablePosition + spellsSize) do local spellId = tonumber(combatData [spellIndex]) --[1] - local spellDamage = tonumber(combatData [spellIndex+1]) --[2] + local spellHealingDone = tonumber(combatData [spellIndex+1]) --[2] local spellHits = tonumber(combatData [spellIndex+2]) --[3] - local targetsSize = combatData [spellIndex+3] --[4] + local targetsSize = tonumber(combatData[spellIndex+3]) --[4] + local targetTable = Details.packFunctions.UnpackTable(combatData, spellIndex+3, true) local spellObject = actorObject.spells:GetOrCreateSpell(spellId, true) --this one need some translation - spellObject.total = spellDamage + spellObject.total = spellHealingDone spellObject.counter = spellHits spellObject.targets = targetTable + for targetName, amount in pairs (spellObject.targets) do + newTargetsTable[targetName] = (newTargetsTable[targetName] or 0) + amount + end + spellIndex = spellIndex + targetsSize + 4 end + actorObject.targets = newTargetsTable tablePosition = tablePosition + spellsSize --increase table position end @@ -975,29 +995,57 @@ function Details.packFunctions.DeployPackedCombatData(packedCombatData) currentCombat[DETAILS_ATTRIBUTE_HEAL]:Remap() --refresh damage taken - local damageContainer = currentCombat[DETAILS_ATTRIBUTE_DAMAGE] - local allActors = damageContainer._ActorTable + do + local damageContainer = currentCombat[DETAILS_ATTRIBUTE_DAMAGE] + local allActors = damageContainer._ActorTable - for i = 1, #allActors do --reset damage taken table - local actor = allActors[i] - actor.damage_taken = 0 - actor.damage_from = {} - end + for i = 1, #allActors do --reset damage taken table + local actor = allActors[i] + actor.damage_taken = 0 + actor.damage_from = {} + end - for i = 1, #allActors do - local actor = allActors[i] - for targetName, amount in pairs (actor.targets) do - local actorIndex = damageContainer._NameIndexTable[targetName] - if (actorIndex) then - local targetActor = allActors[actorIndex] - if (targetActor) then - targetActor.damage_taken = targetActor.damage_taken + amount - targetActor.damage_from[actor.nome] = (targetActor.damage_from[actor.nome] or 0) + amount + for i = 1, #allActors do + local actor = allActors[i] + for targetName, amount in pairs (actor.targets) do + local actorIndex = damageContainer._NameIndexTable[targetName] + if (actorIndex) then + local targetActor = allActors[actorIndex] + if (targetActor) then + targetActor.damage_taken = targetActor.damage_taken + amount + targetActor.damage_from[actor.nome] = (targetActor.damage_from[actor.nome] or 0) + amount + end end end end end + --refresh healing taken + do + local healingContainer = currentCombat[DETAILS_ATTRIBUTE_HEAL] + local allActors = healingContainer._ActorTable + + for i = 1, #allActors do --reset healing taken table + local actor = allActors[i] + actor.healing_taken = 0 + actor.healing_from = {} + end + + for i = 1, #allActors do + local actor = allActors[i] + for targetName, amount in pairs (actor.targets) do + local actorIndex = healingContainer._NameIndexTable[targetName] + if (actorIndex) then + local targetActor = allActors[actorIndex] + if (targetActor) then + targetActor.healing_taken = targetActor.healing_taken + amount + targetActor.healing_from[actor.nome] = (targetActor.healing_from[actor.nome] or 0) + amount + end + end + end + end + end + --refresh windows currentCombat[DETAILS_ATTRIBUTE_DAMAGE].need_refresh = true currentCombat[DETAILS_ATTRIBUTE_HEAL].need_refresh = true