Mercurial > wow > hansgar_and_franzok_assist
diff Libs/DF/auras.lua @ 58:0682d738499b v8.0.1.058
- 8.0.1 Update.
| author | Tercio |
|---|---|
| date | Fri, 20 Jul 2018 19:04:12 -0300 |
| parents | b740f601e824 |
| children |
line wrap: on
line diff
--- a/Libs/DF/auras.lua Sun Mar 11 10:50:42 2018 -0300 +++ b/Libs/DF/auras.lua Fri Jul 20 19:04:12 2018 -0300 @@ -10,6 +10,98 @@ local lower = string.lower local GetSpellBookItemInfo = GetSpellBookItemInfo +local CONST_MAX_SPELLS = 300000 + +function DF:GetAuraByName (unit, spellName, isDebuff) + isDebuff = isDebuff and "HARMFUL|PLAYER" + + for i = 1, 40 do + local name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll = UnitAura (unit, i, isDebuff) + if (not name) then + return + end + + if (name == spellName) then + return name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll + end + end +end + +local default_text_for_aura_frame = { + AUTOMATIC = "Automatic", + MANUAL = "Manual", + METHOD = "Aura Tracking Method:", + BUFFS_IGNORED = "Buffs Ignored", + DEBUFFS_IGNORED = "Debuffs Ignored", + BUFFS_TRACKED = "Buffs Tracked", + DEBUFFS_TRACKED = "Debuffs Tracked", + + AUTOMATIC_DESC = "Auras are being tracked automatically, the addon controls what to show.\nYou may add auras to the blacklist or add extra auras to track.", + MANUAL_DESC = "Auras are being tracked manually, the addon only check for auras you entered below.", + + MANUAL_ADD_BLACKLIST_BUFF = "Add Buff to Blacklist", + MANUAL_ADD_BLACKLIST_DEBUFF = "Add Debuff to Blacklist", + MANUAL_ADD_TRACKLIST_BUFF = "Add Buff to Tracklist", + MANUAL_ADD_TRACKLIST_DEBUFF = "Add Debuff to Tracklist", +} + +function DF:LoadAllSpells (hashMap, indexTable) + + --pre checking which tables to fill to avoid checking if the table exists during the gigantic loop for performance + + if (not DF.LoadingAuraAlertFrame) then + DF.LoadingAuraAlertFrame = CreateFrame ("frame", "DetailsFrameworkLoadingAurasAlert", UIParent) + DF.LoadingAuraAlertFrame:SetSize (340, 75) + DF.LoadingAuraAlertFrame:SetPoint ("center") + DF.LoadingAuraAlertFrame:SetFrameStrata ("TOOLTIP") + DF:ApplyStandardBackdrop (DF.LoadingAuraAlertFrame) + DF.LoadingAuraAlertFrame:SetBackdropBorderColor (1, 0.8, 0.1) + + DF.LoadingAuraAlertFrame.IsLoadingLabel1 = DF:CreateLabel (DF.LoadingAuraAlertFrame, "We are currently loading spell names and spell IDs") + DF.LoadingAuraAlertFrame.IsLoadingLabel2 = DF:CreateLabel (DF.LoadingAuraAlertFrame, "This may take only a few seconds") + DF.LoadingAuraAlertFrame.IsLoadingImage1 = DF:CreateImage (DF.LoadingAuraAlertFrame, [[Interface\DialogFrame\UI-Dialog-Icon-AlertOther]], 32, 32) + DF.LoadingAuraAlertFrame.IsLoadingLabel1.align = "center" + DF.LoadingAuraAlertFrame.IsLoadingLabel2.align = "center" + + DF.LoadingAuraAlertFrame.IsLoadingLabel1:SetPoint ("center", 16, 10) + DF.LoadingAuraAlertFrame.IsLoadingLabel2:SetPoint ("center", 16, -5) + DF.LoadingAuraAlertFrame.IsLoadingImage1:SetPoint ("left", 10, 0) + end + + DF.LoadingAuraAlertFrame:Show() + + C_Timer.After (0.1, function() + if (hashMap and not indexTable) then + for i = 1, CONST_MAX_SPELLS do + local spellName = GetSpellInfo (i) + if (spellName) then + hashMap [lower (spellName)] = i + end + end + + elseif (not hashMap and indexTable) then + for i = 1, CONST_MAX_SPELLS do + local spellName = GetSpellInfo (i) + if (spellName) then + indexTable [#indexTable+1] = lower (spellName) + end + end + + elseif (hashMap and indexTable) then + for i = 1, CONST_MAX_SPELLS do + local spellName = GetSpellInfo (i) + if (spellName) then + indexTable [#indexTable+1] = lower (spellName) + hashMap [indexTable [#indexTable]] = i + end + end + end + + DF.LoadingAuraAlertFrame:Hide() + end) + +end + local cleanfunction = function() end do @@ -32,10 +124,13 @@ --automatic self.buff_ignored:SetData (newdb.aura_tracker.buff_banned) self.debuff_ignored:SetData (newdb.aura_tracker.debuff_banned) - self.buff_available:Refresh() + self.buff_tracked:SetData (newdb.aura_tracker.buff_tracked) + self.debuff_tracked:SetData (newdb.aura_tracker.debuff_tracked) + self.buff_ignored:Refresh() - self.debuff_available:Refresh() self.debuff_ignored:Refresh() + self.buff_tracked:Refresh() + self.debuff_tracked:Refresh() --manual self.buffs_added:SetData (newdb.aura_tracker.buff) @@ -47,18 +142,29 @@ if (newdb.aura_tracker.track_method == 0x1) then self.f_auto:Show() self.f_manual:Hide() + + self.AutomaticTrackingCheckbox:SetValue (true) + self.ManualTrackingCheckbox:SetValue (false) + self.desc_label.text = texts.AUTOMATIC_DESC + elseif (newdb.aura_tracker.track_method == 0x2) then self.f_auto:Hide() self.f_manual:Show() + + self.AutomaticTrackingCheckbox:SetValue (false) + self.ManualTrackingCheckbox:SetValue (true) + self.desc_label.text = texts.MANUAL_DESC end end local aura_panel_defaultoptions = { height = 400, - row_height = 16, + row_height = 18, width = 230, + button_text_template = "OPTIONS_FONT_TEMPLATE" } -function DF:CreateAuraConfigPanel (parent, name, db, method_change_callback, options) + +function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, texts) local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE") local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE") @@ -81,155 +187,412 @@ f.f_auto = f_auto f.f_manual = f_manual - local on_select_tracking_option = function (_, _, method) + --check if the texts table is valid and also deploy default values into the table in case some value is nil + texts = (type (texts == "table") and texts) or default_text_for_aura_frame + DF.table.deploy (texts, default_text_for_aura_frame) + + ------------- + + local on_switch_tracking_method = function (self) + local method = self.Method + f.db.aura_tracker.track_method = method - if (method_change_callback) then - method_change_callback (self, method) + if (change_callback) then + DF:QuickDispatch (change_callback) end if (method == 0x1) then f_auto:Show() f_manual:Hide() - f.desc_label.text = "Auras are being tracked automatically, the addon controls what to show. You may entry an aura to ignore.\nCast spells to fill the Buff and Buff available boxes." - f.desc_label:SetPoint ("topleft", f.tracking_method, "topright", 10, 8) + f.AutomaticTrackingCheckbox:SetValue (true) + f.ManualTrackingCheckbox:SetValue (false) + f.desc_label.text = texts.AUTOMATIC_DESC + elseif (method == 0x2) then f_auto:Hide() f_manual:Show() - f.desc_label.text = "Auras are being tracked manually, the addon only check for auras you entered below." - f.desc_label:SetPoint ("topleft", f.tracking_method, "topright", 10, 1) + f.AutomaticTrackingCheckbox:SetValue (false) + f.ManualTrackingCheckbox:SetValue (true) + f.desc_label.text = texts.MANUAL_DESC end end - local tracking_options = function() - return { - {label = "Automatic", value = 0x1, onclick = on_select_tracking_option, desc = "Show all your auras by default, you can exclude those you don't want to show."}, - {label = "Manual", value = 0x2, onclick = on_select_tracking_option, desc = "Do not show any aura by default, you need to manually add each aura you want to track."}, - } + local background_method_selection = CreateFrame ("frame", nil, f) + background_method_selection:SetHeight (82) + background_method_selection:SetPoint ("topleft", f, "topleft", 0, 0) + background_method_selection:SetPoint ("topright", f, "topright", 0, 0) + DF:ApplyStandardBackdrop (background_method_selection) + + local tracking_method_label = self:CreateLabel (background_method_selection, texts.METHOD, 12, "orange") + tracking_method_label:SetPoint ("topleft", background_method_selection, "topleft", 6, -4) + + f.desc_label = self:CreateLabel (background_method_selection, "", 10, "silver") + f.desc_label:SetPoint ("left", background_method_selection, "left", 130, 0) + f.desc_label:SetJustifyV ("top") + + local automatic_tracking_checkbox = DF:CreateSwitch (background_method_selection, on_switch_tracking_method, f.db.aura_tracker.track_method == 0x1, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE")) + automatic_tracking_checkbox.Method = 0x1 + automatic_tracking_checkbox:SetAsCheckBox() + automatic_tracking_checkbox:SetSize (24, 24) + f.AutomaticTrackingCheckbox = automatic_tracking_checkbox + + local automatic_tracking_label = DF:CreateLabel (background_method_selection, "Automatic") + automatic_tracking_label:SetPoint ("left", automatic_tracking_checkbox, "right", 2, 0) + + local manual_tracking_checkbox = DF:CreateSwitch (background_method_selection, on_switch_tracking_method, f.db.aura_tracker.track_method == 0x2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_BRIGHT_TEMPLATE")) + manual_tracking_checkbox.Method = 0x2 + manual_tracking_checkbox:SetAsCheckBox() + manual_tracking_checkbox:SetSize (24, 24) + f.ManualTrackingCheckbox = manual_tracking_checkbox + + local manual_tracking_label = DF:CreateLabel (background_method_selection, "Manual") + manual_tracking_label:SetPoint ("left", manual_tracking_checkbox, "right", 2, 0) + + automatic_tracking_checkbox:SetPoint ("topleft", tracking_method_label, "bottomleft", 0, -6) + manual_tracking_checkbox:SetPoint ("topleft", automatic_tracking_checkbox, "bottomleft", 0, -6) + + +-------- anchors points + + local y = -110 + local xLocation = 230 + + +-------- automatic + + --manual add the buff and ebuff names + local AllSpellsMap = {} + local AllSpellNames = {} + + local load_all_spells = function (self, capsule) + if (not next (AllSpellsMap)) then + DF:LoadAllSpells (AllSpellsMap, AllSpellNames) + + f_auto.AddBuffBlacklistTextBox.SpellAutoCompleteList = AllSpellNames + f_auto.AddDebuffBlacklistTextBox.SpellAutoCompleteList = AllSpellNames + f_auto.AddBuffTracklistTextBox.SpellAutoCompleteList = AllSpellNames + f_auto.AddDebuffTracklistTextBox.SpellAutoCompleteList = AllSpellNames + + f_manual.NewBuffTextBox.SpellAutoCompleteList = AllSpellNames + f_manual.NewDebuffTextBox.SpellAutoCompleteList = AllSpellNames + + -- + + f_auto.AddBuffBlacklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList") + f_auto.AddDebuffBlacklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList") + f_auto.AddBuffTracklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList") + f_auto.AddDebuffTracklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList") + + f_manual.NewBuffTextBox:SetAsAutoComplete ("SpellAutoCompleteList") + f_manual.NewDebuffTextBox:SetAsAutoComplete ("SpellAutoCompleteList") + + -- + + f_auto.AddBuffBlacklistTextBox.ShouldOptimizeAutoComplete = true + f_auto.AddDebuffBlacklistTextBox.ShouldOptimizeAutoComplete = true + f_auto.AddBuffTracklistTextBox.ShouldOptimizeAutoComplete = true + f_auto.AddDebuffTracklistTextBox.ShouldOptimizeAutoComplete = true + + f_manual.NewBuffTextBox.ShouldOptimizeAutoComplete = true + f_manual.NewDebuffTextBox.ShouldOptimizeAutoComplete = true + end end + + local background_add_blacklist = CreateFrame ("frame", nil, f_auto) + background_add_blacklist:SetSize (220, 135) + DF:ApplyStandardBackdrop (background_add_blacklist) - local tracking_method_label = self:CreateLabel (f, "Tracking Aura Method:", 12, "orange") - local tracking_method = self:CreateDropDown (f, tracking_options, f.db.aura_tracker.track_method, 120, 20, "dropdown_tracking_method", _, self:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")) + local background_add_tracklist = CreateFrame ("frame", nil, f_auto) + background_add_tracklist:SetSize (220, 135) + DF:ApplyStandardBackdrop (background_add_tracklist) - tracking_method_label:SetPoint ("topleft", f, "topleft", 10, -10) - tracking_method:SetPoint ("left", tracking_method_label, "right", 2, 0) - tracking_method:SetFrameStrata ("tooltip") - tracking_method.tooltip = "Choose which aura tracking method you want to use." - f.tracking_method = tracking_method + --black list + local buff_blacklist_label = self:CreateLabel (background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_BUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")) + local debuff_blacklist_label = self:CreateLabel (background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_DEBUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")) + + local buff_name_blacklist_entry = self:CreateTextEntry (background_add_blacklist, function()end, 200, 20, "AddBuffBlacklistTextBox", _, _, options_dropdown_template) + buff_name_blacklist_entry:SetHook ("OnEditFocusGained", load_all_spells) + buff_name_blacklist_entry:SetJustifyH ("left") + buff_name_blacklist_entry.tooltip = "Enter the buff name using lower case letters." + f_auto.AddBuffBlacklistTextBox = buff_name_blacklist_entry + + local debuff_name_blacklist_entry = self:CreateTextEntry (background_add_blacklist, function()end, 200, 20, "AddDebuffBlacklistTextBox", _, _, options_dropdown_template) + debuff_name_blacklist_entry:SetHook ("OnEditFocusGained", load_all_spells) + debuff_name_blacklist_entry:SetJustifyH ("left") + debuff_name_blacklist_entry.tooltip = "Enter the debuff name using lower case letters." + f_auto.AddDebuffBlacklistTextBox = debuff_name_blacklist_entry - f.desc_label = self:CreateLabel (f, "", 10, "silver") - f.desc_label:SetSize (400, 40) - f.desc_label:SetPoint ("topleft", tracking_method, "topright", 10, 8) - f.desc_label:SetJustifyV ("top") + local add_blacklist_buff_button = 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 + text = lower (text) + + --get the spellId + local spellId = AllSpellsMap [text] + if (not spellId) then + print ("spell not found") + return + end + + --add the spellId to the blacklist + f.db.aura_tracker.buff_banned [spellId] = true + + --refresh the buff blacklist frame + _G [f_auto:GetName() .. "BuffIgnored"]:Refresh() + + DF:QuickDispatch (change_callback) + end + + end, 100, 20, "Add to Blacklist", 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 + debuff_name_blacklist_entry:SetText ("") + debuff_name_blacklist_entry:ClearFocus() + + if (text ~= "") then + text = lower (text) + + --get the spellId + local spellId = AllSpellsMap [text] + if (not spellId) then + print ("spell not found") + return + end + + --add the spellId to the blacklist + f.db.aura_tracker.debuff_banned [spellId] = true + + --refresh the buff blacklist frame + _G [f_auto:GetName() .. "DebuffIgnored"]:Refresh() + + DF:QuickDispatch (change_callback) + end + end, 100, 20, "Add to Blacklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + + + --track list + local buff_tracklist_label = self:CreateLabel (background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_BUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")) + local debuff_tracklist_label = self:CreateLabel (background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_DEBUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")) + + local buff_name_tracklist_entry = self:CreateTextEntry (background_add_tracklist, function()end, 200, 20, "AddBuffTracklistTextBox", _, _, options_dropdown_template) + buff_name_tracklist_entry:SetHook ("OnEditFocusGained", load_all_spells) + buff_name_tracklist_entry:SetJustifyH ("left") + buff_name_tracklist_entry.tooltip = "Enter the buff name using lower case letters." + f_auto.AddBuffTracklistTextBox = buff_name_tracklist_entry + + local debuff_name_tracklist_entry = self:CreateTextEntry (background_add_tracklist, function()end, 200, 20, "AddDebuffTracklistTextBox", _, _, options_dropdown_template) + debuff_name_tracklist_entry:SetHook ("OnEditFocusGained", load_all_spells) + debuff_name_tracklist_entry:SetJustifyH ("left") + debuff_name_tracklist_entry.tooltip = "Enter the debuff name using lower case letters." + f_auto.AddDebuffTracklistTextBox = debuff_name_tracklist_entry + + local add_tracklist_buff_button = 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 + text = lower (text) + + --get the spellId + local spellId = AllSpellsMap [text] + if (not spellId) then + print ("spell not found") + return + end + + --add the spellId to the blacklist + f.db.aura_tracker.buff_tracked [spellId] = true + + --refresh the buff blacklist frame + _G [f_auto:GetName() .. "BuffTracked"]:Refresh() + + DF:QuickDispatch (change_callback) + end + + end, 100, 20, "Add to Tracklist", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"), DF:GetTemplate ("font", options.button_text_template)) + + local add_tracklist_debuff_button = 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 + text = lower (text) + + --get the spellId + local spellId = AllSpellsMap [text] + if (not spellId) then + print ("spell not found") + return + end + + --add the spellId to the blacklist + f.db.aura_tracker.debuff_tracked [spellId] = true + + --refresh the buff blacklist frame + _G [f_auto:GetName() .. "DebuffTracked"]:Refresh() + + DF:QuickDispatch (change_callback) + end + end, 100, 20, "Add to Tracklist", 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) + background_add_tracklist:SetPoint ("topleft", background_add_blacklist, "bottomleft", 0, -10) + + --debuff blacklist + debuff_name_blacklist_entry:SetPoint ("topleft", background_add_blacklist, "topleft", 4, -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) + + --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) ---------automatic + + --debuff tracklist + debuff_name_tracklist_entry:SetPoint ("topleft", background_add_tracklist, "topleft", 4, -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) + + --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) local ALL_BUFFS = {} local ALL_DEBUFFS = {} + --options passed to the create aura panel local width, height, row_height = options.width, options.height, options.row_height + - local buff_ignored = self:CreateSimpleListBox (f_auto, "$parentBuffIgnored", "Buffs Ignored", "The list is empty, select a spell from the buff list to ignore it.", f.db.aura_tracker.buff_banned, - function (spellid) - f.db.aura_tracker.buff_banned [spellid] = nil; - end, - { - icon = function(spellid) return select (3, GetSpellInfo (spellid)) end, - text = function(spellid) return select (1, GetSpellInfo (spellid)) end, - height = height, - row_height = row_height, - width = width, - onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:AddLine ("Click to un-ignore this aura", .2, 1, .2); GameTooltip:Show() end, - }) + --Debuffs on the black list + local debuff_ignored = self:CreateSimpleListBox (f_auto, "$parentDebuffIgnored", texts.DEBUFFS_IGNORED, "the list is empty", f.db.aura_tracker.debuff_banned, function (spellid) + --f.db.aura_tracker.debuff_banned [spellid] = nil; DF:QuickDispatch (change_callback); + end, + { + icon = function(spellid) return select (3, GetSpellInfo (spellid)) end, + text = function(spellid) return select (1, GetSpellInfo (spellid)) end, + height = height, + row_height = row_height, + width = width, + backdrop_color = {.8, .8, .8, 0.2}, + panel_border_color = {.01, 0, 0, 1}, + iconcoords = {.1, .9, .1, .9}, + onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:Show() end, + show_x_button = true, + x_button_func = function (spellId) + f.db.aura_tracker.debuff_banned [spellId] = nil; DF:QuickDispatch (change_callback); + end, + }) - local buff_available = self:CreateSimpleListBox (f_auto, "$parentBuffAvailable", "Buffs Available", "The list is empty, cast spells to fill it", ALL_BUFFS, function (spellid) - f.db.aura_tracker.buff_banned [spellid] = true; buff_ignored:Refresh() - end, - { - icon = function(spellid) return select (3, GetSpellInfo (spellid)) end, - text = function(spellid) return select (1, GetSpellInfo (spellid)) end, - height = height, - row_height = row_height, - width = width, - onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:AddLine ("Click to ignore this aura", .2, 1, .2); GameTooltip:Show() end, - }) - - local debuff_ignored = self:CreateSimpleListBox (f_auto, "$parentDebuffIgnored", "Debuffs Ignored", "The list is empty, select a spell from the debuff list to ignore it.", f.db.aura_tracker.debuff_banned, function (spellid) - f.db.aura_tracker.debuff_banned [spellid] = nil; - end, - { - icon = function(spellid) return select (3, GetSpellInfo (spellid)) end, - text = function(spellid) return select (1, GetSpellInfo (spellid)) end, - height = height, - row_height = row_height, - width = width, - onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:AddLine ("Click to un-ignore this aura", .2, 1, .2); GameTooltip:Show() end, - }) - - local debuff_available = self:CreateSimpleListBox (f_auto, "$parentDebuffAvailable", "Debuffs Available", "The list is empty, cast spells to fill it", ALL_DEBUFFS, function (spellid) - f.db.aura_tracker.debuff_banned [spellid] = true; debuff_ignored:Refresh() - end, { - icon = function(spellid) return select (3, GetSpellInfo (spellid)) end, - text = function(spellid) return select (1, GetSpellInfo (spellid)) end, - height = height, - row_height = row_height, - width = width, - onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:AddLine ("Click to ignore this aura", .2, 1, .2); GameTooltip:Show() end, - }) - - --como ira preencher ela no inicio e como ficara o lance dos profiles + --Buffs on the black list + local buff_ignored = self:CreateSimpleListBox (f_auto, "$parentBuffIgnored", texts.BUFFS_IGNORED, "the list is empty", f.db.aura_tracker.buff_banned, + function (spellid) + --f.db.aura_tracker.buff_banned [spellid] = nil; DF:QuickDispatch (change_callback); + end, + { + icon = function(spellid) return select (3, GetSpellInfo (spellid)) end, + text = function(spellid) return select (1, GetSpellInfo (spellid)) end, + height = height, + row_height = row_height, + width = width, + backdrop_color = {.8, .8, .8, 0.2}, + panel_border_color = {.02, 0, 0, 1}, + iconcoords = {.1, .9, .1, .9}, + onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:Show() end, + show_x_button = true, + x_button_func = function (spellId) + f.db.aura_tracker.buff_banned [spellId] = nil; DF:QuickDispatch (change_callback); + end, + }) - local y = -40 - buff_available:SetPoint ("topleft", f_auto, "topleft", 0, y) - buff_ignored:SetPoint ("topleft", f_auto, "topleft", 6 + width, y) - debuff_available:SetPoint ("topleft", f_auto, "topleft", 12 + (width*2), y) - debuff_ignored:SetPoint ("topleft", f_auto, "topleft", 18 + (width*3), y) - - f.buff_available = buff_available + --Debuffs on the track list + local debuff_tracked = self:CreateSimpleListBox (f_auto, "$parentDebuffTracked", texts.DEBUFFS_TRACKED, "the list is empty", f.db.aura_tracker.debuff_tracked, function (spellid) + --f.db.aura_tracker.debuff_tracked [spellid] = nil; DF:QuickDispatch (change_callback); + end, + { + icon = function(spellid) return select (3, GetSpellInfo (spellid)) end, + text = function(spellid) return select (1, GetSpellInfo (spellid)) end, + height = height, + row_height = row_height, + width = width, + backdrop_color = {.8, .8, .8, 0.2}, + panel_border_color = {0, .02, 0, 1}, + iconcoords = {.1, .9, .1, .9}, + onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:Show() end, + show_x_button = true, + x_button_func = function (spellId) + f.db.aura_tracker.debuff_tracked [spellId] = nil; DF:QuickDispatch (change_callback); + end, + }) + + --Buffs on the track list + local buff_tracked = self:CreateSimpleListBox (f_auto, "$parentBuffTracked", texts.BUFFS_TRACKED, "the list is empty", f.db.aura_tracker.buff_tracked, function (spellid) + --f.db.aura_tracker.buff_tracked [spellid] = nil; DF:QuickDispatch (change_callback); + end, + { + icon = function(spellid) return select (3, GetSpellInfo (spellid)) end, + text = function(spellid) return select (1, GetSpellInfo (spellid)) end, + height = height, + row_height = row_height, + width = width, + backdrop_color = {.8, .8, .8, 0.2}, + panel_border_color = {0, .01, 0, 1}, + iconcoords = {.1, .9, .1, .9}, + onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:Show() end, + show_x_button = true, + x_button_func = function (spellId) + f.db.aura_tracker.buff_tracked [spellId] = nil; DF:QuickDispatch (change_callback); + end, + }) + + debuff_ignored:SetPoint ("topleft", f_auto, "topleft", 0 + xLocation, y) + buff_ignored:SetPoint ("topleft", f_auto, "topleft", 8 + width + xLocation, y) + debuff_tracked:SetPoint ("topleft", f_auto, "topleft", 16 + (width*2) + xLocation, y) + buff_tracked:SetPoint ("topleft", f_auto, "topleft", 24 + (width*3) + xLocation, y) + f.buff_ignored = buff_ignored - f.debuff_available = debuff_available f.debuff_ignored = debuff_ignored + f.buff_tracked = buff_tracked + f.debuff_tracked = debuff_tracked - local readCombatLog = CreateFrame ("frame", nil, f_auto) - readCombatLog:SetScript ("OnEvent", function (self, event, time, token, hidding, sourceGUID, sourceName, sourceFlag, sourceFlag2, targetGUID, targetName, targetFlag, targetFlag2, spellid, spellname, spellschool, auraType, amount) - if (auraType == "BUFF" and sourceGUID == readCombatLog.playerGUID) then - if (not ALL_BUFFS [spellid]) then - ALL_BUFFS [spellid] = true - buff_available:Refresh() - end - elseif (auraType == "DEBUFF" and sourceGUID == readCombatLog.playerGUID) then - if (not ALL_DEBUFFS [spellid]) then - ALL_DEBUFFS [spellid] = true - debuff_available:Refresh() - end - end - end) - f_auto:SetScript ("OnShow", function() for i = 1, BUFF_MAX_DISPLAY do - local name, rank, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HELPFUL") + local name, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HELPFUL") if (name) then ALL_BUFFS [spellId] = true end - local name, rank, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HARMFUL") + local name, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HARMFUL") if (name) then ALL_DEBUFFS [spellId] = true end end - buff_available:Refresh() - buff_ignored:Refresh() - debuff_available:Refresh() + buff_tracked:Refresh() + debuff_tracked:Refresh() + buff_ignored:Refresh() debuff_ignored:Refresh() - readCombatLog.playerGUID = UnitGUID ("player") - readCombatLog:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED") end) f_auto:SetScript ("OnHide", function() - readCombatLog:UnregisterEvent ("COMBAT_LOG_EVENT_UNFILTERED") + -- end) - + --show the frame selecton on the f.db - on_select_tracking_option (_, _, f.db.aura_tracker.track_method) + + if (f.db.aura_tracker.track_method == 0x1) then + on_switch_tracking_method (automatic_tracking_checkbox) + elseif (f.db.aura_tracker.track_method == 0x2) then + on_switch_tracking_method (manual_tracking_checkbox) + end -------manual @@ -250,7 +613,6 @@ GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID (spellid) GameTooltip:AddLine (" ") - GameTooltip:AddLine ("Click to untrack this aura", .2, 1, .2) GameTooltip:Show() end end @@ -259,9 +621,10 @@ self:SetBackdropColor (unpack (backdrop_color)) GameTooltip:Hide() end - local line_onclick = function (self) - local spell = self.value - local data = self:GetParent():GetData() + + local onclick_remove_button = function (self) + local spell = self:GetParent().value + local data = self:GetParent():GetParent():GetData() for i = 1, #data do if (data[i] == spell) then @@ -270,27 +633,36 @@ end end - self:GetParent():Refresh() + self:GetParent():GetParent():Refresh() end local scroll_createline = function (self, index) local line = CreateFrame ("button", "$parentLine" .. index, self) - line:SetPoint ("topleft", self, "topleft", 0, -((index-1)*(scroll_line_height+1))) - line:SetSize (scroll_width, scroll_line_height) + line:SetPoint ("topleft", self, "topleft", 1, -((index-1)*(scroll_line_height+1)) - 1) + line:SetSize (scroll_width - 2, scroll_line_height) line:SetScript ("OnEnter", line_onenter) line:SetScript ("OnLeave", line_onleave) - line:SetScript ("OnClick", line_onclick) line:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) line:SetBackdropColor (unpack (backdrop_color)) local icon = line:CreateTexture ("$parentIcon", "overlay") - icon:SetSize (scroll_line_height, scroll_line_height) + icon:SetSize (scroll_line_height - 2, scroll_line_height - 2) + local name = line:CreateFontString ("$parentName", "overlay", "GameFontNormal") + + local remove_button = CreateFrame ("button", "$parentRemoveButton", line, "UIPanelCloseButton") + remove_button:SetSize (16, 16) + remove_button:SetScript ("OnClick", onclick_remove_button) + remove_button:SetPoint ("topright", line, "topright") + remove_button:GetNormalTexture():SetDesaturated (true) + icon:SetPoint ("left", line, "left", 2, 0) name:SetPoint ("left", icon, "right", 2, 0) + line.icon = icon line.name = name + line.removebutton = remove_button return line end @@ -306,6 +678,7 @@ if (name) then line.name:SetText (name) line.icon:SetTexture (icon) + line.icon:SetTexCoord (.1, .9, .1, .9) else line.name:SetText (aura) line.icon:SetTexture ([[Interface\InventoryItems\WoWUnknownItem01]]) @@ -316,18 +689,16 @@ local buffs_added = self:CreateScrollBox (f_manual, "$parentBuffsAdded", scroll_refresh, f.db.aura_tracker.buff, scroll_width, scroll_height, scroll_lines, scroll_line_height) buffs_added:SetPoint ("topleft", f_manual, "topleft", 0, y) - buffs_added:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) - buffs_added:SetBackdropColor (0, 0, 0, 0.2) - buffs_added:SetBackdropBorderColor (0, 0, 0, 1) + DF:ReskinSlider (buffs_added) + for i = 1, scroll_lines do buffs_added:CreateLine (scroll_createline) end local debuffs_added = self:CreateScrollBox (f_manual, "$parentDebuffsAdded", scroll_refresh, f.db.aura_tracker.debuff, scroll_width, scroll_height, scroll_lines, scroll_line_height) debuffs_added:SetPoint ("topleft", f_manual, "topleft", width+30, y) - debuffs_added:SetBackdrop ({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true}) - debuffs_added:SetBackdropColor (0, 0, 0, 0.2) - debuffs_added:SetBackdropBorderColor (0, 0, 0, 1) + DF:ReskinSlider (debuffs_added) + for i = 1, scroll_lines do debuffs_added:CreateLine (scroll_createline) end @@ -339,6 +710,7 @@ buffs_added_name:SetTemplate (DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")) buffs_added_name:SetPoint ("bottomleft", buffs_added, "topleft", 0, 2) buffs_added.Title = buffs_added_name + local debuffs_added_name = DF:CreateLabel (debuffs_added, "Debuffs", 12, "silver") debuffs_added_name:SetTemplate (DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")) debuffs_added_name:SetPoint ("bottomleft", debuffs_added, "topleft", 0, 2) @@ -347,36 +719,55 @@ --> build the text entry to type the spellname local new_buff_string = self:CreateLabel (f_manual, "Add Buff") local new_debuff_string = self:CreateLabel (f_manual, "Add Debuff") - local new_buff_entry = self:CreateTextEntry (f_manual, function()end, 200, 20, "NewBuffTextBox", _, _, options_dropdown_template) local new_debuff_entry = self:CreateTextEntry (f_manual, function()end, 200, 20, "NewDebuffTextBox", _, _, options_dropdown_template) + new_buff_entry:SetHook ("OnEditFocusGained", load_all_spells) + new_debuff_entry:SetHook ("OnEditFocusGained", load_all_spells) + new_buff_entry.tooltip = "Enter the buff name using lower case letters.\n\nYou can add several spells at once using |cFFFFFF00;|r to separate each spell name." + new_debuff_entry.tooltip = "Enter the debuff name using lower case letters.\n\nYou can add several spells at once using |cFFFFFF00;|r to separate each spell name." + new_buff_entry:SetJustifyH ("left") new_debuff_entry:SetJustifyH ("left") - DF:SetAutoCompleteWithSpells (new_buff_entry) - DF:SetAutoCompleteWithSpells (new_debuff_entry) + local add_buff_button = self:CreateButton (f_manual, function() - local add_buff_button = self:CreateButton (f_manual, function() local text = new_buff_entry.text new_buff_entry:SetText ("") new_buff_entry:ClearFocus() + if (text ~= "") then --> check for more than one spellname if (text:find (";")) then - for _, spellname in ipairs ({strsplit (";", text)}) do - spellname = self:trim (spellname) - if (string.len (spellname) > 0) then - tinsert (f.db.aura_tracker.buff, spellname) + for _, spellName in ipairs ({strsplit (";", text)}) do + spellName = self:trim (spellName) + spellName = lower (spellName) + if (string.len (spellName) > 0) then + local spellId = AllSpellsMap [spellName] + if (spellId) then + tinsert (f.db.aura_tracker.buff, spellId) + else + print ("spellId not found for spell:", spellName) + end end end else - tinsert (f.db.aura_tracker.buff, text) + --get the spellId + local spellName = lower (text) + local spellId = AllSpellsMap [spellName] + if (not spellId) then + print ("spellIs for spell ", spellName, "not found") + return + end + + tinsert (f.db.aura_tracker.buff, spellId) end buffs_added:Refresh() end + end, 100, 20, "Add Buff", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")) + local add_debuff_button = self:CreateButton (f_manual, function() local text = new_debuff_entry.text new_debuff_entry:SetText ("") @@ -384,29 +775,47 @@ if (text ~= "") then --> check for more than one spellname if (text:find (";")) then - for _, spellname in ipairs ({strsplit (";", text)}) do - spellname = self:trim (spellname) - if (string.len (spellname) > 0) then - tinsert (f.db.aura_tracker.debuff, spellname) + for _, spellName in ipairs ({strsplit (";", text)}) do + spellName = self:trim (spellName) + spellName = lower (spellName) + if (string.len (spellName) > 0) then + local spellId = AllSpellsMap [spellName] + if (spellId) then + tinsert (f.db.aura_tracker.debuff, spellId) + else + print ("spellId not found for spell:", spellName) + end end end else - tinsert (f.db.aura_tracker.debuff, text) + --get the spellId + local spellName = lower (text) + local spellId = AllSpellsMap [spellName] + if (not spellId) then + print ("spellIs for spell ", spellName, "not found") + return + end + + tinsert (f.db.aura_tracker.debuff, spellId) end + debuffs_added:Refresh() end end, 100, 20, "Add Debuff", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")) local multiple_spells_label = DF:CreateLabel (buffs_added, "You can add multiple auras at once by separating them with ';'.\nExample: Fireball; Frostbolt; Flamestrike", 10, "gray") - multiple_spells_label:SetSize (350, 60) + multiple_spells_label:SetSize (350, 24) multiple_spells_label:SetJustifyV ("top") local export_box = self:CreateTextEntry (f_manual, function()end, 242, 20, "ExportAuraTextBox", _, _, options_dropdown_template) local export_buff_button = self:CreateButton (f_manual, function() local str = "" - for _, spellname in ipairs (f.db.aura_tracker.buff) do - str = str .. spellname .. "; " + for _, spellId in ipairs (f.db.aura_tracker.buff) do + local spellName = GetSpellInfo (spellId) + if (spellName) then + str = str .. spellName .. "; " + end end export_box.text = str export_box:SetFocus (true) @@ -416,30 +825,34 @@ local export_debuff_button = self:CreateButton (f_manual, function() local str = "" - for _, spellname in ipairs (f.db.aura_tracker.debuff) do - str = str .. spellname .. "; " + for _, spellId in ipairs (f.db.aura_tracker.debuff) do + local spellName = GetSpellInfo (spellId) + if (spellName) then + str = str .. spellName .. "; " + end end + export_box.text = str export_box:SetFocus (true) export_box:HighlightText() end, 120, 20, "Export Debuffs", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")) - multiple_spells_label:SetPoint ("topleft", f_manual, "topleft", 480, -120) - - export_buff_button:SetPoint ("topleft", f_manual, "topleft", 480, -160) - export_debuff_button:SetPoint ("left",export_buff_button, "right", 2, 0) - export_box:SetPoint ("topleft", f_manual, "topleft", 480, -185) - - new_buff_string:SetPoint ("topleft", f_manual, "topleft", 480, -40) - new_buff_entry:SetPoint ("topleft", new_buff_string, "bottomleft", 0, -2) + new_buff_entry:SetPoint ("topleft", f_manual, "topleft", 480, y) + new_buff_string:SetPoint ("bottomleft", new_buff_entry, "topleft", 0, 2) add_buff_button:SetPoint ("left", new_buff_entry, "right", 2, 0) add_buff_button.tooltip = "Add the aura to be tracked.\n\nClick an aura on the list to remove it." - new_debuff_string:SetPoint ("topleft", f_manual, "topleft", 480, -80) + new_debuff_string:SetPoint ("topleft", new_buff_entry, "bottomleft", 0, -6) new_debuff_entry:SetPoint ("topleft", new_debuff_string, "bottomleft", 0, -2) add_debuff_button:SetPoint ("left", new_debuff_entry, "right", 2, 0) add_debuff_button.tooltip = "Add the aura to be tracked.\n\nClick an aura on the list to remove it." + + multiple_spells_label:SetPoint ("topleft", new_debuff_entry, "bottomleft", 0, -6) + + export_buff_button:SetPoint ("topleft", multiple_spells_label, "bottomleft", 0, -12) + export_debuff_button:SetPoint ("left",export_buff_button, "right", 2, 0) + export_box:SetPoint ("topleft", export_buff_button, "bottomleft", 0, -6) buffs_added:Refresh() debuffs_added:Refresh()
