annotate Libs/DF/auras.lua @ 63:3552946c0b9a tip

Added tag v8.2.0.062 for changeset d6704922ef5d
author Tercioo
date Fri, 28 Jun 2019 20:06:18 -0300
parents 0682d738499b
children
rev   line source
Tercio@41 1
Tercio@41 2 local DF = _G ["DetailsFramework"]
Tercio@41 3 if (not DF or not DetailsFrameworkCanLoad) then
Tercio@41 4 return
Tercio@41 5 end
Tercio@41 6
Tercio@41 7 local _
Tercio@41 8 local tinsert = tinsert
Tercio@41 9 local GetSpellInfo = GetSpellInfo
Tercio@41 10 local lower = string.lower
Tercio@41 11 local GetSpellBookItemInfo = GetSpellBookItemInfo
Tercio@41 12
Tercio@58 13 local CONST_MAX_SPELLS = 300000
Tercio@58 14
Tercio@58 15 function DF:GetAuraByName (unit, spellName, isDebuff)
Tercio@58 16 isDebuff = isDebuff and "HARMFUL|PLAYER"
Tercio@58 17
Tercio@58 18 for i = 1, 40 do
Tercio@58 19 local name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll = UnitAura (unit, i, isDebuff)
Tercio@58 20 if (not name) then
Tercio@58 21 return
Tercio@58 22 end
Tercio@58 23
Tercio@58 24 if (name == spellName) then
Tercio@58 25 return name, texture, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal, spellId, canApplyAura, isBossDebuff, isCastByPlayer, nameplateShowAll
Tercio@58 26 end
Tercio@58 27 end
Tercio@58 28 end
Tercio@58 29
Tercio@58 30 local default_text_for_aura_frame = {
Tercio@58 31 AUTOMATIC = "Automatic",
Tercio@58 32 MANUAL = "Manual",
Tercio@58 33 METHOD = "Aura Tracking Method:",
Tercio@58 34 BUFFS_IGNORED = "Buffs Ignored",
Tercio@58 35 DEBUFFS_IGNORED = "Debuffs Ignored",
Tercio@58 36 BUFFS_TRACKED = "Buffs Tracked",
Tercio@58 37 DEBUFFS_TRACKED = "Debuffs Tracked",
Tercio@58 38
Tercio@58 39 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.",
Tercio@58 40 MANUAL_DESC = "Auras are being tracked manually, the addon only check for auras you entered below.",
Tercio@58 41
Tercio@58 42 MANUAL_ADD_BLACKLIST_BUFF = "Add Buff to Blacklist",
Tercio@58 43 MANUAL_ADD_BLACKLIST_DEBUFF = "Add Debuff to Blacklist",
Tercio@58 44 MANUAL_ADD_TRACKLIST_BUFF = "Add Buff to Tracklist",
Tercio@58 45 MANUAL_ADD_TRACKLIST_DEBUFF = "Add Debuff to Tracklist",
Tercio@58 46 }
Tercio@58 47
Tercio@58 48 function DF:LoadAllSpells (hashMap, indexTable)
Tercio@58 49
Tercio@58 50 --pre checking which tables to fill to avoid checking if the table exists during the gigantic loop for performance
Tercio@58 51
Tercio@58 52 if (not DF.LoadingAuraAlertFrame) then
Tercio@58 53 DF.LoadingAuraAlertFrame = CreateFrame ("frame", "DetailsFrameworkLoadingAurasAlert", UIParent)
Tercio@58 54 DF.LoadingAuraAlertFrame:SetSize (340, 75)
Tercio@58 55 DF.LoadingAuraAlertFrame:SetPoint ("center")
Tercio@58 56 DF.LoadingAuraAlertFrame:SetFrameStrata ("TOOLTIP")
Tercio@58 57 DF:ApplyStandardBackdrop (DF.LoadingAuraAlertFrame)
Tercio@58 58 DF.LoadingAuraAlertFrame:SetBackdropBorderColor (1, 0.8, 0.1)
Tercio@58 59
Tercio@58 60 DF.LoadingAuraAlertFrame.IsLoadingLabel1 = DF:CreateLabel (DF.LoadingAuraAlertFrame, "We are currently loading spell names and spell IDs")
Tercio@58 61 DF.LoadingAuraAlertFrame.IsLoadingLabel2 = DF:CreateLabel (DF.LoadingAuraAlertFrame, "This may take only a few seconds")
Tercio@58 62 DF.LoadingAuraAlertFrame.IsLoadingImage1 = DF:CreateImage (DF.LoadingAuraAlertFrame, [[Interface\DialogFrame\UI-Dialog-Icon-AlertOther]], 32, 32)
Tercio@58 63 DF.LoadingAuraAlertFrame.IsLoadingLabel1.align = "center"
Tercio@58 64 DF.LoadingAuraAlertFrame.IsLoadingLabel2.align = "center"
Tercio@58 65
Tercio@58 66 DF.LoadingAuraAlertFrame.IsLoadingLabel1:SetPoint ("center", 16, 10)
Tercio@58 67 DF.LoadingAuraAlertFrame.IsLoadingLabel2:SetPoint ("center", 16, -5)
Tercio@58 68 DF.LoadingAuraAlertFrame.IsLoadingImage1:SetPoint ("left", 10, 0)
Tercio@58 69 end
Tercio@58 70
Tercio@58 71 DF.LoadingAuraAlertFrame:Show()
Tercio@58 72
Tercio@58 73 C_Timer.After (0.1, function()
Tercio@58 74 if (hashMap and not indexTable) then
Tercio@58 75 for i = 1, CONST_MAX_SPELLS do
Tercio@58 76 local spellName = GetSpellInfo (i)
Tercio@58 77 if (spellName) then
Tercio@58 78 hashMap [lower (spellName)] = i
Tercio@58 79 end
Tercio@58 80 end
Tercio@58 81
Tercio@58 82 elseif (not hashMap and indexTable) then
Tercio@58 83 for i = 1, CONST_MAX_SPELLS do
Tercio@58 84 local spellName = GetSpellInfo (i)
Tercio@58 85 if (spellName) then
Tercio@58 86 indexTable [#indexTable+1] = lower (spellName)
Tercio@58 87 end
Tercio@58 88 end
Tercio@58 89
Tercio@58 90 elseif (hashMap and indexTable) then
Tercio@58 91 for i = 1, CONST_MAX_SPELLS do
Tercio@58 92 local spellName = GetSpellInfo (i)
Tercio@58 93 if (spellName) then
Tercio@58 94 indexTable [#indexTable+1] = lower (spellName)
Tercio@58 95 hashMap [indexTable [#indexTable]] = i
Tercio@58 96 end
Tercio@58 97 end
Tercio@58 98 end
Tercio@58 99
Tercio@58 100 DF.LoadingAuraAlertFrame:Hide()
Tercio@58 101 end)
Tercio@58 102
Tercio@58 103 end
Tercio@58 104
Tercio@41 105 local cleanfunction = function() end
Tercio@41 106
Tercio@41 107 do
Tercio@41 108 local metaPrototype = {
Tercio@41 109 WidgetType = "aura_tracker",
Tercio@41 110 SetHook = DF.SetHook,
Tercio@41 111 RunHooksForWidget = DF.RunHooksForWidget,
Tercio@41 112 }
Tercio@41 113
Tercio@41 114 _G [DF.GlobalWidgetControlNames ["aura_tracker"]] = _G [DF.GlobalWidgetControlNames ["aura_tracker"]] or metaPrototype
Tercio@41 115 end
Tercio@41 116
Tercio@41 117 local AuraTrackerMetaFunctions = _G [DF.GlobalWidgetControlNames ["aura_tracker"]]
Tercio@41 118
Tercio@41 119 --create panels
Tercio@41 120 local on_profile_changed = function (self, newdb)
Tercio@41 121 self.db = newdb
Tercio@41 122 self.tracking_method:Select (newdb.aura_tracker.track_method)
Tercio@41 123
Tercio@41 124 --automatic
Tercio@41 125 self.buff_ignored:SetData (newdb.aura_tracker.buff_banned)
Tercio@41 126 self.debuff_ignored:SetData (newdb.aura_tracker.debuff_banned)
Tercio@58 127 self.buff_tracked:SetData (newdb.aura_tracker.buff_tracked)
Tercio@58 128 self.debuff_tracked:SetData (newdb.aura_tracker.debuff_tracked)
Tercio@58 129
Tercio@41 130 self.buff_ignored:Refresh()
Tercio@41 131 self.debuff_ignored:Refresh()
Tercio@58 132 self.buff_tracked:Refresh()
Tercio@58 133 self.debuff_tracked:Refresh()
Tercio@41 134
Tercio@41 135 --manual
Tercio@41 136 self.buffs_added:SetData (newdb.aura_tracker.buff)
Tercio@41 137 self.debuffs_added:SetData (newdb.aura_tracker.debuff)
Tercio@41 138 self.buffs_added:Refresh()
Tercio@41 139 self.debuffs_added:Refresh()
Tercio@41 140
Tercio@41 141 --method
Tercio@41 142 if (newdb.aura_tracker.track_method == 0x1) then
Tercio@41 143 self.f_auto:Show()
Tercio@41 144 self.f_manual:Hide()
Tercio@58 145
Tercio@58 146 self.AutomaticTrackingCheckbox:SetValue (true)
Tercio@58 147 self.ManualTrackingCheckbox:SetValue (false)
Tercio@58 148 self.desc_label.text = texts.AUTOMATIC_DESC
Tercio@58 149
Tercio@41 150 elseif (newdb.aura_tracker.track_method == 0x2) then
Tercio@41 151 self.f_auto:Hide()
Tercio@41 152 self.f_manual:Show()
Tercio@58 153
Tercio@58 154 self.AutomaticTrackingCheckbox:SetValue (false)
Tercio@58 155 self.ManualTrackingCheckbox:SetValue (true)
Tercio@58 156 self.desc_label.text = texts.MANUAL_DESC
Tercio@41 157 end
Tercio@41 158 end
Tercio@41 159
Tercio@41 160 local aura_panel_defaultoptions = {
Tercio@41 161 height = 400,
Tercio@58 162 row_height = 18,
Tercio@41 163 width = 230,
Tercio@58 164 button_text_template = "OPTIONS_FONT_TEMPLATE"
Tercio@41 165 }
Tercio@58 166
Tercio@58 167 function DF:CreateAuraConfigPanel (parent, name, db, change_callback, options, texts)
Tercio@41 168
Tercio@41 169 local options_text_template = DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE")
Tercio@41 170 local options_dropdown_template = DF:GetTemplate ("dropdown", "OPTIONS_DROPDOWN_TEMPLATE")
Tercio@41 171 local options_switch_template = DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE")
Tercio@41 172 local options_slider_template = DF:GetTemplate ("slider", "OPTIONS_SLIDER_TEMPLATE")
Tercio@41 173 local options_button_template = DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE")
Tercio@41 174
Tercio@41 175 local f = CreateFrame ("frame", name, parent)
Tercio@41 176 f.db = db
Tercio@41 177 f.OnProfileChanged = on_profile_changed
Tercio@41 178 options = options or {}
Tercio@41 179 self.table.deploy (options, aura_panel_defaultoptions)
Tercio@41 180
Tercio@41 181 local f_auto = CreateFrame ("frame", "$parent_Automatic", f)
Tercio@41 182 local f_manual = CreateFrame ("frame", "$parent_Manual", f)
Tercio@41 183 f_auto:SetPoint ("topleft", f, "topleft", 0, -24)
Tercio@41 184 f_manual:SetPoint ("topleft", f, "topleft", 0, -24)
Tercio@41 185 f_auto:SetSize (600, 600)
Tercio@41 186 f_manual:SetSize (600, 600)
Tercio@41 187 f.f_auto = f_auto
Tercio@41 188 f.f_manual = f_manual
Tercio@41 189
Tercio@58 190 --check if the texts table is valid and also deploy default values into the table in case some value is nil
Tercio@58 191 texts = (type (texts == "table") and texts) or default_text_for_aura_frame
Tercio@58 192 DF.table.deploy (texts, default_text_for_aura_frame)
Tercio@58 193
Tercio@58 194 -------------
Tercio@58 195
Tercio@58 196 local on_switch_tracking_method = function (self)
Tercio@58 197 local method = self.Method
Tercio@58 198
Tercio@41 199 f.db.aura_tracker.track_method = method
Tercio@58 200 if (change_callback) then
Tercio@58 201 DF:QuickDispatch (change_callback)
Tercio@41 202 end
Tercio@41 203
Tercio@41 204 if (method == 0x1) then
Tercio@41 205 f_auto:Show()
Tercio@41 206 f_manual:Hide()
Tercio@58 207 f.AutomaticTrackingCheckbox:SetValue (true)
Tercio@58 208 f.ManualTrackingCheckbox:SetValue (false)
Tercio@58 209 f.desc_label.text = texts.AUTOMATIC_DESC
Tercio@58 210
Tercio@41 211 elseif (method == 0x2) then
Tercio@41 212 f_auto:Hide()
Tercio@41 213 f_manual:Show()
Tercio@58 214 f.AutomaticTrackingCheckbox:SetValue (false)
Tercio@58 215 f.ManualTrackingCheckbox:SetValue (true)
Tercio@58 216 f.desc_label.text = texts.MANUAL_DESC
Tercio@41 217 end
Tercio@41 218 end
Tercio@41 219
Tercio@58 220 local background_method_selection = CreateFrame ("frame", nil, f)
Tercio@58 221 background_method_selection:SetHeight (82)
Tercio@58 222 background_method_selection:SetPoint ("topleft", f, "topleft", 0, 0)
Tercio@58 223 background_method_selection:SetPoint ("topright", f, "topright", 0, 0)
Tercio@58 224 DF:ApplyStandardBackdrop (background_method_selection)
Tercio@58 225
Tercio@58 226 local tracking_method_label = self:CreateLabel (background_method_selection, texts.METHOD, 12, "orange")
Tercio@58 227 tracking_method_label:SetPoint ("topleft", background_method_selection, "topleft", 6, -4)
Tercio@58 228
Tercio@58 229 f.desc_label = self:CreateLabel (background_method_selection, "", 10, "silver")
Tercio@58 230 f.desc_label:SetPoint ("left", background_method_selection, "left", 130, 0)
Tercio@58 231 f.desc_label:SetJustifyV ("top")
Tercio@58 232
Tercio@58 233 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"))
Tercio@58 234 automatic_tracking_checkbox.Method = 0x1
Tercio@58 235 automatic_tracking_checkbox:SetAsCheckBox()
Tercio@58 236 automatic_tracking_checkbox:SetSize (24, 24)
Tercio@58 237 f.AutomaticTrackingCheckbox = automatic_tracking_checkbox
Tercio@58 238
Tercio@58 239 local automatic_tracking_label = DF:CreateLabel (background_method_selection, "Automatic")
Tercio@58 240 automatic_tracking_label:SetPoint ("left", automatic_tracking_checkbox, "right", 2, 0)
Tercio@58 241
Tercio@58 242 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"))
Tercio@58 243 manual_tracking_checkbox.Method = 0x2
Tercio@58 244 manual_tracking_checkbox:SetAsCheckBox()
Tercio@58 245 manual_tracking_checkbox:SetSize (24, 24)
Tercio@58 246 f.ManualTrackingCheckbox = manual_tracking_checkbox
Tercio@58 247
Tercio@58 248 local manual_tracking_label = DF:CreateLabel (background_method_selection, "Manual")
Tercio@58 249 manual_tracking_label:SetPoint ("left", manual_tracking_checkbox, "right", 2, 0)
Tercio@58 250
Tercio@58 251 automatic_tracking_checkbox:SetPoint ("topleft", tracking_method_label, "bottomleft", 0, -6)
Tercio@58 252 manual_tracking_checkbox:SetPoint ("topleft", automatic_tracking_checkbox, "bottomleft", 0, -6)
Tercio@58 253
Tercio@58 254
Tercio@58 255 -------- anchors points
Tercio@58 256
Tercio@58 257 local y = -110
Tercio@58 258 local xLocation = 230
Tercio@58 259
Tercio@58 260
Tercio@58 261 -------- automatic
Tercio@58 262
Tercio@58 263 --manual add the buff and ebuff names
Tercio@58 264 local AllSpellsMap = {}
Tercio@58 265 local AllSpellNames = {}
Tercio@58 266
Tercio@58 267 local load_all_spells = function (self, capsule)
Tercio@58 268 if (not next (AllSpellsMap)) then
Tercio@58 269 DF:LoadAllSpells (AllSpellsMap, AllSpellNames)
Tercio@58 270
Tercio@58 271 f_auto.AddBuffBlacklistTextBox.SpellAutoCompleteList = AllSpellNames
Tercio@58 272 f_auto.AddDebuffBlacklistTextBox.SpellAutoCompleteList = AllSpellNames
Tercio@58 273 f_auto.AddBuffTracklistTextBox.SpellAutoCompleteList = AllSpellNames
Tercio@58 274 f_auto.AddDebuffTracklistTextBox.SpellAutoCompleteList = AllSpellNames
Tercio@58 275
Tercio@58 276 f_manual.NewBuffTextBox.SpellAutoCompleteList = AllSpellNames
Tercio@58 277 f_manual.NewDebuffTextBox.SpellAutoCompleteList = AllSpellNames
Tercio@58 278
Tercio@58 279 --
Tercio@58 280
Tercio@58 281 f_auto.AddBuffBlacklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
Tercio@58 282 f_auto.AddDebuffBlacklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
Tercio@58 283 f_auto.AddBuffTracklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
Tercio@58 284 f_auto.AddDebuffTracklistTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
Tercio@58 285
Tercio@58 286 f_manual.NewBuffTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
Tercio@58 287 f_manual.NewDebuffTextBox:SetAsAutoComplete ("SpellAutoCompleteList")
Tercio@58 288
Tercio@58 289 --
Tercio@58 290
Tercio@58 291 f_auto.AddBuffBlacklistTextBox.ShouldOptimizeAutoComplete = true
Tercio@58 292 f_auto.AddDebuffBlacklistTextBox.ShouldOptimizeAutoComplete = true
Tercio@58 293 f_auto.AddBuffTracklistTextBox.ShouldOptimizeAutoComplete = true
Tercio@58 294 f_auto.AddDebuffTracklistTextBox.ShouldOptimizeAutoComplete = true
Tercio@58 295
Tercio@58 296 f_manual.NewBuffTextBox.ShouldOptimizeAutoComplete = true
Tercio@58 297 f_manual.NewDebuffTextBox.ShouldOptimizeAutoComplete = true
Tercio@58 298 end
Tercio@41 299 end
Tercio@58 300
Tercio@58 301 local background_add_blacklist = CreateFrame ("frame", nil, f_auto)
Tercio@58 302 background_add_blacklist:SetSize (220, 135)
Tercio@58 303 DF:ApplyStandardBackdrop (background_add_blacklist)
Tercio@41 304
Tercio@58 305 local background_add_tracklist = CreateFrame ("frame", nil, f_auto)
Tercio@58 306 background_add_tracklist:SetSize (220, 135)
Tercio@58 307 DF:ApplyStandardBackdrop (background_add_tracklist)
Tercio@41 308
Tercio@58 309 --black list
Tercio@58 310 local buff_blacklist_label = self:CreateLabel (background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_BUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
Tercio@58 311 local debuff_blacklist_label = self:CreateLabel (background_add_blacklist, texts.MANUAL_ADD_BLACKLIST_DEBUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
Tercio@58 312
Tercio@58 313 local buff_name_blacklist_entry = self:CreateTextEntry (background_add_blacklist, function()end, 200, 20, "AddBuffBlacklistTextBox", _, _, options_dropdown_template)
Tercio@58 314 buff_name_blacklist_entry:SetHook ("OnEditFocusGained", load_all_spells)
Tercio@58 315 buff_name_blacklist_entry:SetJustifyH ("left")
Tercio@58 316 buff_name_blacklist_entry.tooltip = "Enter the buff name using lower case letters."
Tercio@58 317 f_auto.AddBuffBlacklistTextBox = buff_name_blacklist_entry
Tercio@58 318
Tercio@58 319 local debuff_name_blacklist_entry = self:CreateTextEntry (background_add_blacklist, function()end, 200, 20, "AddDebuffBlacklistTextBox", _, _, options_dropdown_template)
Tercio@58 320 debuff_name_blacklist_entry:SetHook ("OnEditFocusGained", load_all_spells)
Tercio@58 321 debuff_name_blacklist_entry:SetJustifyH ("left")
Tercio@58 322 debuff_name_blacklist_entry.tooltip = "Enter the debuff name using lower case letters."
Tercio@58 323 f_auto.AddDebuffBlacklistTextBox = debuff_name_blacklist_entry
Tercio@41 324
Tercio@58 325 local add_blacklist_buff_button = self:CreateButton (background_add_blacklist, function()
Tercio@58 326 local text = buff_name_blacklist_entry.text
Tercio@58 327 buff_name_blacklist_entry:SetText ("")
Tercio@58 328 buff_name_blacklist_entry:ClearFocus()
Tercio@58 329
Tercio@58 330 if (text ~= "") then
Tercio@58 331 text = lower (text)
Tercio@58 332
Tercio@58 333 --get the spellId
Tercio@58 334 local spellId = AllSpellsMap [text]
Tercio@58 335 if (not spellId) then
Tercio@58 336 print ("spell not found")
Tercio@58 337 return
Tercio@58 338 end
Tercio@58 339
Tercio@58 340 --add the spellId to the blacklist
Tercio@58 341 f.db.aura_tracker.buff_banned [spellId] = true
Tercio@58 342
Tercio@58 343 --refresh the buff blacklist frame
Tercio@58 344 _G [f_auto:GetName() .. "BuffIgnored"]:Refresh()
Tercio@58 345
Tercio@58 346 DF:QuickDispatch (change_callback)
Tercio@58 347 end
Tercio@58 348
Tercio@58 349 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))
Tercio@58 350
Tercio@58 351 local add_blacklist_debuff_button = self:CreateButton (background_add_blacklist, function()
Tercio@58 352 local text = debuff_name_blacklist_entry.text
Tercio@58 353 debuff_name_blacklist_entry:SetText ("")
Tercio@58 354 debuff_name_blacklist_entry:ClearFocus()
Tercio@58 355
Tercio@58 356 if (text ~= "") then
Tercio@58 357 text = lower (text)
Tercio@58 358
Tercio@58 359 --get the spellId
Tercio@58 360 local spellId = AllSpellsMap [text]
Tercio@58 361 if (not spellId) then
Tercio@58 362 print ("spell not found")
Tercio@58 363 return
Tercio@58 364 end
Tercio@58 365
Tercio@58 366 --add the spellId to the blacklist
Tercio@58 367 f.db.aura_tracker.debuff_banned [spellId] = true
Tercio@58 368
Tercio@58 369 --refresh the buff blacklist frame
Tercio@58 370 _G [f_auto:GetName() .. "DebuffIgnored"]:Refresh()
Tercio@58 371
Tercio@58 372 DF:QuickDispatch (change_callback)
Tercio@58 373 end
Tercio@58 374 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))
Tercio@58 375
Tercio@58 376
Tercio@58 377 --track list
Tercio@58 378 local buff_tracklist_label = self:CreateLabel (background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_BUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
Tercio@58 379 local debuff_tracklist_label = self:CreateLabel (background_add_tracklist, texts.MANUAL_ADD_TRACKLIST_DEBUFF, DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
Tercio@58 380
Tercio@58 381 local buff_name_tracklist_entry = self:CreateTextEntry (background_add_tracklist, function()end, 200, 20, "AddBuffTracklistTextBox", _, _, options_dropdown_template)
Tercio@58 382 buff_name_tracklist_entry:SetHook ("OnEditFocusGained", load_all_spells)
Tercio@58 383 buff_name_tracklist_entry:SetJustifyH ("left")
Tercio@58 384 buff_name_tracklist_entry.tooltip = "Enter the buff name using lower case letters."
Tercio@58 385 f_auto.AddBuffTracklistTextBox = buff_name_tracklist_entry
Tercio@58 386
Tercio@58 387 local debuff_name_tracklist_entry = self:CreateTextEntry (background_add_tracklist, function()end, 200, 20, "AddDebuffTracklistTextBox", _, _, options_dropdown_template)
Tercio@58 388 debuff_name_tracklist_entry:SetHook ("OnEditFocusGained", load_all_spells)
Tercio@58 389 debuff_name_tracklist_entry:SetJustifyH ("left")
Tercio@58 390 debuff_name_tracklist_entry.tooltip = "Enter the debuff name using lower case letters."
Tercio@58 391 f_auto.AddDebuffTracklistTextBox = debuff_name_tracklist_entry
Tercio@58 392
Tercio@58 393 local add_tracklist_buff_button = self:CreateButton (background_add_tracklist, function()
Tercio@58 394 local text = buff_name_tracklist_entry.text
Tercio@58 395 buff_name_tracklist_entry:SetText ("")
Tercio@58 396 buff_name_tracklist_entry:ClearFocus()
Tercio@58 397
Tercio@58 398 if (text ~= "") then
Tercio@58 399 text = lower (text)
Tercio@58 400
Tercio@58 401 --get the spellId
Tercio@58 402 local spellId = AllSpellsMap [text]
Tercio@58 403 if (not spellId) then
Tercio@58 404 print ("spell not found")
Tercio@58 405 return
Tercio@58 406 end
Tercio@58 407
Tercio@58 408 --add the spellId to the blacklist
Tercio@58 409 f.db.aura_tracker.buff_tracked [spellId] = true
Tercio@58 410
Tercio@58 411 --refresh the buff blacklist frame
Tercio@58 412 _G [f_auto:GetName() .. "BuffTracked"]:Refresh()
Tercio@58 413
Tercio@58 414 DF:QuickDispatch (change_callback)
Tercio@58 415 end
Tercio@58 416
Tercio@58 417 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))
Tercio@58 418
Tercio@58 419 local add_tracklist_debuff_button = self:CreateButton (background_add_tracklist, function()
Tercio@58 420 local text = debuff_name_tracklist_entry.text
Tercio@58 421 debuff_name_tracklist_entry:SetText ("")
Tercio@58 422 debuff_name_tracklist_entry:ClearFocus()
Tercio@58 423
Tercio@58 424 if (text ~= "") then
Tercio@58 425 text = lower (text)
Tercio@58 426
Tercio@58 427 --get the spellId
Tercio@58 428 local spellId = AllSpellsMap [text]
Tercio@58 429 if (not spellId) then
Tercio@58 430 print ("spell not found")
Tercio@58 431 return
Tercio@58 432 end
Tercio@58 433
Tercio@58 434 --add the spellId to the blacklist
Tercio@58 435 f.db.aura_tracker.debuff_tracked [spellId] = true
Tercio@58 436
Tercio@58 437 --refresh the buff blacklist frame
Tercio@58 438 _G [f_auto:GetName() .. "DebuffTracked"]:Refresh()
Tercio@58 439
Tercio@58 440 DF:QuickDispatch (change_callback)
Tercio@58 441 end
Tercio@58 442 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))
Tercio@58 443
Tercio@58 444 --anchors:
Tercio@58 445 background_add_blacklist:SetPoint ("topleft", f_auto, "topleft", 0, y)
Tercio@58 446 background_add_tracklist:SetPoint ("topleft", background_add_blacklist, "bottomleft", 0, -10)
Tercio@58 447
Tercio@58 448 --debuff blacklist
Tercio@58 449 debuff_name_blacklist_entry:SetPoint ("topleft", background_add_blacklist, "topleft", 4, -20)
Tercio@58 450 debuff_blacklist_label:SetPoint ("bottomleft", debuff_name_blacklist_entry, "topleft", 0, 2)
Tercio@58 451 add_blacklist_debuff_button:SetPoint ("topleft", debuff_name_blacklist_entry, "bottomleft", 0, -2)
Tercio@58 452
Tercio@58 453 --buff blacklist
Tercio@58 454 buff_blacklist_label:SetPoint ("topleft", add_blacklist_debuff_button.widget, "bottomleft", 0, -10)
Tercio@58 455 buff_name_blacklist_entry:SetPoint ("topleft", buff_blacklist_label, "bottomleft", 0, -2)
Tercio@58 456 add_blacklist_buff_button:SetPoint ("topleft", buff_name_blacklist_entry, "bottomleft", 0, -2)
Tercio@41 457
Tercio@58 458
Tercio@58 459 --debuff tracklist
Tercio@58 460 debuff_name_tracklist_entry:SetPoint ("topleft", background_add_tracklist, "topleft", 4, -20)
Tercio@58 461 debuff_tracklist_label:SetPoint ("bottomleft", debuff_name_tracklist_entry, "topleft", 0, 2)
Tercio@58 462 add_tracklist_debuff_button:SetPoint ("topleft", debuff_name_tracklist_entry, "bottomleft", 0, -2)
Tercio@58 463
Tercio@58 464 --buff tracklist
Tercio@58 465 buff_tracklist_label:SetPoint ("topleft", add_tracklist_debuff_button.widget, "bottomleft", 0, -10)
Tercio@58 466 buff_name_tracklist_entry:SetPoint ("topleft", buff_tracklist_label, "bottomleft", 0, -2)
Tercio@58 467 add_tracklist_buff_button:SetPoint ("topleft", buff_name_tracklist_entry, "bottomleft", 0, -2)
Tercio@41 468
Tercio@41 469 local ALL_BUFFS = {}
Tercio@41 470 local ALL_DEBUFFS = {}
Tercio@41 471
Tercio@58 472 --options passed to the create aura panel
Tercio@41 473 local width, height, row_height = options.width, options.height, options.row_height
Tercio@58 474
Tercio@41 475
Tercio@58 476 --Debuffs on the black list
Tercio@58 477 local debuff_ignored = self:CreateSimpleListBox (f_auto, "$parentDebuffIgnored", texts.DEBUFFS_IGNORED, "the list is empty", f.db.aura_tracker.debuff_banned, function (spellid)
Tercio@58 478 --f.db.aura_tracker.debuff_banned [spellid] = nil; DF:QuickDispatch (change_callback);
Tercio@58 479 end,
Tercio@58 480 {
Tercio@58 481 icon = function(spellid) return select (3, GetSpellInfo (spellid)) end,
Tercio@58 482 text = function(spellid) return select (1, GetSpellInfo (spellid)) end,
Tercio@58 483 height = height,
Tercio@58 484 row_height = row_height,
Tercio@58 485 width = width,
Tercio@58 486 backdrop_color = {.8, .8, .8, 0.2},
Tercio@58 487 panel_border_color = {.01, 0, 0, 1},
Tercio@58 488 iconcoords = {.1, .9, .1, .9},
Tercio@58 489 onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:Show() end,
Tercio@58 490 show_x_button = true,
Tercio@58 491 x_button_func = function (spellId)
Tercio@58 492 f.db.aura_tracker.debuff_banned [spellId] = nil; DF:QuickDispatch (change_callback);
Tercio@58 493 end,
Tercio@58 494 })
Tercio@41 495
Tercio@58 496 --Buffs on the black list
Tercio@58 497 local buff_ignored = self:CreateSimpleListBox (f_auto, "$parentBuffIgnored", texts.BUFFS_IGNORED, "the list is empty", f.db.aura_tracker.buff_banned,
Tercio@58 498 function (spellid)
Tercio@58 499 --f.db.aura_tracker.buff_banned [spellid] = nil; DF:QuickDispatch (change_callback);
Tercio@58 500 end,
Tercio@58 501 {
Tercio@58 502 icon = function(spellid) return select (3, GetSpellInfo (spellid)) end,
Tercio@58 503 text = function(spellid) return select (1, GetSpellInfo (spellid)) end,
Tercio@58 504 height = height,
Tercio@58 505 row_height = row_height,
Tercio@58 506 width = width,
Tercio@58 507 backdrop_color = {.8, .8, .8, 0.2},
Tercio@58 508 panel_border_color = {.02, 0, 0, 1},
Tercio@58 509 iconcoords = {.1, .9, .1, .9},
Tercio@58 510 onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:Show() end,
Tercio@58 511 show_x_button = true,
Tercio@58 512 x_button_func = function (spellId)
Tercio@58 513 f.db.aura_tracker.buff_banned [spellId] = nil; DF:QuickDispatch (change_callback);
Tercio@58 514 end,
Tercio@58 515 })
Tercio@41 516
Tercio@58 517 --Debuffs on the track list
Tercio@58 518 local debuff_tracked = self:CreateSimpleListBox (f_auto, "$parentDebuffTracked", texts.DEBUFFS_TRACKED, "the list is empty", f.db.aura_tracker.debuff_tracked, function (spellid)
Tercio@58 519 --f.db.aura_tracker.debuff_tracked [spellid] = nil; DF:QuickDispatch (change_callback);
Tercio@58 520 end,
Tercio@58 521 {
Tercio@58 522 icon = function(spellid) return select (3, GetSpellInfo (spellid)) end,
Tercio@58 523 text = function(spellid) return select (1, GetSpellInfo (spellid)) end,
Tercio@58 524 height = height,
Tercio@58 525 row_height = row_height,
Tercio@58 526 width = width,
Tercio@58 527 backdrop_color = {.8, .8, .8, 0.2},
Tercio@58 528 panel_border_color = {0, .02, 0, 1},
Tercio@58 529 iconcoords = {.1, .9, .1, .9},
Tercio@58 530 onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:Show() end,
Tercio@58 531 show_x_button = true,
Tercio@58 532 x_button_func = function (spellId)
Tercio@58 533 f.db.aura_tracker.debuff_tracked [spellId] = nil; DF:QuickDispatch (change_callback);
Tercio@58 534 end,
Tercio@58 535 })
Tercio@58 536
Tercio@58 537 --Buffs on the track list
Tercio@58 538 local buff_tracked = self:CreateSimpleListBox (f_auto, "$parentBuffTracked", texts.BUFFS_TRACKED, "the list is empty", f.db.aura_tracker.buff_tracked, function (spellid)
Tercio@58 539 --f.db.aura_tracker.buff_tracked [spellid] = nil; DF:QuickDispatch (change_callback);
Tercio@58 540 end,
Tercio@58 541 {
Tercio@58 542 icon = function(spellid) return select (3, GetSpellInfo (spellid)) end,
Tercio@58 543 text = function(spellid) return select (1, GetSpellInfo (spellid)) end,
Tercio@58 544 height = height,
Tercio@58 545 row_height = row_height,
Tercio@58 546 width = width,
Tercio@58 547 backdrop_color = {.8, .8, .8, 0.2},
Tercio@58 548 panel_border_color = {0, .01, 0, 1},
Tercio@58 549 iconcoords = {.1, .9, .1, .9},
Tercio@58 550 onenter = function(self, capsule, value) GameTooltip:SetOwner (self, "ANCHOR_RIGHT"); GameTooltip:SetSpellByID(value); GameTooltip:AddLine (" "); GameTooltip:Show() end,
Tercio@58 551 show_x_button = true,
Tercio@58 552 x_button_func = function (spellId)
Tercio@58 553 f.db.aura_tracker.buff_tracked [spellId] = nil; DF:QuickDispatch (change_callback);
Tercio@58 554 end,
Tercio@58 555 })
Tercio@58 556
Tercio@58 557 debuff_ignored:SetPoint ("topleft", f_auto, "topleft", 0 + xLocation, y)
Tercio@58 558 buff_ignored:SetPoint ("topleft", f_auto, "topleft", 8 + width + xLocation, y)
Tercio@58 559 debuff_tracked:SetPoint ("topleft", f_auto, "topleft", 16 + (width*2) + xLocation, y)
Tercio@58 560 buff_tracked:SetPoint ("topleft", f_auto, "topleft", 24 + (width*3) + xLocation, y)
Tercio@58 561
Tercio@41 562 f.buff_ignored = buff_ignored
Tercio@41 563 f.debuff_ignored = debuff_ignored
Tercio@58 564 f.buff_tracked = buff_tracked
Tercio@58 565 f.debuff_tracked = debuff_tracked
Tercio@41 566
Tercio@41 567 f_auto:SetScript ("OnShow", function()
Tercio@41 568 for i = 1, BUFF_MAX_DISPLAY do
Tercio@58 569 local name, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HELPFUL")
Tercio@41 570 if (name) then
Tercio@41 571 ALL_BUFFS [spellId] = true
Tercio@41 572 end
Tercio@58 573 local name, texture, count, debuffType, duration, expirationTime, caster, _, nameplateShowPersonal, spellId, _, _, _, nameplateShowAll = UnitAura ("player", i, "HARMFUL")
Tercio@41 574 if (name) then
Tercio@41 575 ALL_DEBUFFS [spellId] = true
Tercio@41 576 end
Tercio@41 577 end
Tercio@41 578
Tercio@58 579 buff_tracked:Refresh()
Tercio@58 580 debuff_tracked:Refresh()
Tercio@58 581 buff_ignored:Refresh()
Tercio@41 582 debuff_ignored:Refresh()
Tercio@41 583
Tercio@41 584 end)
Tercio@41 585 f_auto:SetScript ("OnHide", function()
Tercio@58 586 --
Tercio@41 587 end)
Tercio@58 588
Tercio@41 589 --show the frame selecton on the f.db
Tercio@58 590
Tercio@58 591 if (f.db.aura_tracker.track_method == 0x1) then
Tercio@58 592 on_switch_tracking_method (automatic_tracking_checkbox)
Tercio@58 593 elseif (f.db.aura_tracker.track_method == 0x2) then
Tercio@58 594 on_switch_tracking_method (manual_tracking_checkbox)
Tercio@58 595 end
Tercio@41 596
Tercio@41 597 -------manual
Tercio@41 598
Tercio@41 599 --> build the two aura scrolls for buff and debuff
Tercio@41 600
Tercio@41 601 local scroll_width = width
Tercio@41 602 local scroll_height = height
Tercio@41 603 local scroll_lines = 15
Tercio@41 604 local scroll_line_height = 20
Tercio@41 605
Tercio@41 606 local backdrop_color = {.8, .8, .8, 0.2}
Tercio@41 607 local backdrop_color_on_enter = {.8, .8, .8, 0.4}
Tercio@41 608
Tercio@41 609 local line_onenter = function (self)
Tercio@41 610 self:SetBackdropColor (unpack (backdrop_color_on_enter))
Tercio@41 611 local spellid = select (7, GetSpellInfo (self.value))
Tercio@41 612 if (spellid) then
Tercio@41 613 GameTooltip:SetOwner (self, "ANCHOR_RIGHT");
Tercio@41 614 GameTooltip:SetSpellByID (spellid)
Tercio@41 615 GameTooltip:AddLine (" ")
Tercio@41 616 GameTooltip:Show()
Tercio@41 617 end
Tercio@41 618 end
Tercio@41 619
Tercio@41 620 local line_onleave = function (self)
Tercio@41 621 self:SetBackdropColor (unpack (backdrop_color))
Tercio@41 622 GameTooltip:Hide()
Tercio@41 623 end
Tercio@58 624
Tercio@58 625 local onclick_remove_button = function (self)
Tercio@58 626 local spell = self:GetParent().value
Tercio@58 627 local data = self:GetParent():GetParent():GetData()
Tercio@41 628
Tercio@41 629 for i = 1, #data do
Tercio@41 630 if (data[i] == spell) then
Tercio@41 631 tremove (data, i)
Tercio@41 632 break
Tercio@41 633 end
Tercio@41 634 end
Tercio@41 635
Tercio@58 636 self:GetParent():GetParent():Refresh()
Tercio@41 637 end
Tercio@41 638
Tercio@41 639 local scroll_createline = function (self, index)
Tercio@41 640 local line = CreateFrame ("button", "$parentLine" .. index, self)
Tercio@58 641 line:SetPoint ("topleft", self, "topleft", 1, -((index-1)*(scroll_line_height+1)) - 1)
Tercio@58 642 line:SetSize (scroll_width - 2, scroll_line_height)
Tercio@41 643 line:SetScript ("OnEnter", line_onenter)
Tercio@41 644 line:SetScript ("OnLeave", line_onleave)
Tercio@41 645
Tercio@41 646 line:SetBackdrop ({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
Tercio@41 647 line:SetBackdropColor (unpack (backdrop_color))
Tercio@41 648
Tercio@41 649 local icon = line:CreateTexture ("$parentIcon", "overlay")
Tercio@58 650 icon:SetSize (scroll_line_height - 2, scroll_line_height - 2)
Tercio@58 651
Tercio@41 652 local name = line:CreateFontString ("$parentName", "overlay", "GameFontNormal")
Tercio@58 653
Tercio@58 654 local remove_button = CreateFrame ("button", "$parentRemoveButton", line, "UIPanelCloseButton")
Tercio@58 655 remove_button:SetSize (16, 16)
Tercio@58 656 remove_button:SetScript ("OnClick", onclick_remove_button)
Tercio@58 657 remove_button:SetPoint ("topright", line, "topright")
Tercio@58 658 remove_button:GetNormalTexture():SetDesaturated (true)
Tercio@58 659
Tercio@41 660 icon:SetPoint ("left", line, "left", 2, 0)
Tercio@41 661 name:SetPoint ("left", icon, "right", 2, 0)
Tercio@58 662
Tercio@41 663 line.icon = icon
Tercio@41 664 line.name = name
Tercio@58 665 line.removebutton = remove_button
Tercio@41 666
Tercio@41 667 return line
Tercio@41 668 end
Tercio@41 669
Tercio@41 670 local scroll_refresh = function (self, data, offset, total_lines)
Tercio@41 671 for i = 1, total_lines do
Tercio@41 672 local index = i + offset
Tercio@41 673 local aura = data [index]
Tercio@41 674 if (aura) then
Tercio@41 675 local line = self:GetLine (i)
Tercio@41 676 local name, _, icon = GetSpellInfo (aura)
Tercio@41 677 line.value = aura
Tercio@41 678 if (name) then
Tercio@41 679 line.name:SetText (name)
Tercio@41 680 line.icon:SetTexture (icon)
Tercio@58 681 line.icon:SetTexCoord (.1, .9, .1, .9)
Tercio@41 682 else
Tercio@41 683 line.name:SetText (aura)
Tercio@41 684 line.icon:SetTexture ([[Interface\InventoryItems\WoWUnknownItem01]])
Tercio@41 685 end
Tercio@41 686 end
Tercio@41 687 end
Tercio@41 688 end
Tercio@41 689
Tercio@41 690 local buffs_added = self:CreateScrollBox (f_manual, "$parentBuffsAdded", scroll_refresh, f.db.aura_tracker.buff, scroll_width, scroll_height, scroll_lines, scroll_line_height)
Tercio@41 691 buffs_added:SetPoint ("topleft", f_manual, "topleft", 0, y)
Tercio@58 692 DF:ReskinSlider (buffs_added)
Tercio@58 693
Tercio@41 694 for i = 1, scroll_lines do
Tercio@41 695 buffs_added:CreateLine (scroll_createline)
Tercio@41 696 end
Tercio@41 697
Tercio@41 698 local debuffs_added = self:CreateScrollBox (f_manual, "$parentDebuffsAdded", scroll_refresh, f.db.aura_tracker.debuff, scroll_width, scroll_height, scroll_lines, scroll_line_height)
Tercio@41 699 debuffs_added:SetPoint ("topleft", f_manual, "topleft", width+30, y)
Tercio@58 700 DF:ReskinSlider (debuffs_added)
Tercio@58 701
Tercio@41 702 for i = 1, scroll_lines do
Tercio@41 703 debuffs_added:CreateLine (scroll_createline)
Tercio@41 704 end
Tercio@41 705
Tercio@41 706 f.buffs_added = buffs_added
Tercio@41 707 f.debuffs_added = debuffs_added
Tercio@41 708
Tercio@41 709 local buffs_added_name = DF:CreateLabel (buffs_added, "Buffs", 12, "silver")
Tercio@41 710 buffs_added_name:SetTemplate (DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
Tercio@41 711 buffs_added_name:SetPoint ("bottomleft", buffs_added, "topleft", 0, 2)
Tercio@41 712 buffs_added.Title = buffs_added_name
Tercio@58 713
Tercio@41 714 local debuffs_added_name = DF:CreateLabel (debuffs_added, "Debuffs", 12, "silver")
Tercio@41 715 debuffs_added_name:SetTemplate (DF:GetTemplate ("font", "OPTIONS_FONT_TEMPLATE"))
Tercio@41 716 debuffs_added_name:SetPoint ("bottomleft", debuffs_added, "topleft", 0, 2)
Tercio@41 717 debuffs_added.Title = debuffs_added_name
Tercio@41 718
Tercio@41 719 --> build the text entry to type the spellname
Tercio@41 720 local new_buff_string = self:CreateLabel (f_manual, "Add Buff")
Tercio@41 721 local new_debuff_string = self:CreateLabel (f_manual, "Add Debuff")
Tercio@41 722 local new_buff_entry = self:CreateTextEntry (f_manual, function()end, 200, 20, "NewBuffTextBox", _, _, options_dropdown_template)
Tercio@41 723 local new_debuff_entry = self:CreateTextEntry (f_manual, function()end, 200, 20, "NewDebuffTextBox", _, _, options_dropdown_template)
Tercio@41 724
Tercio@58 725 new_buff_entry:SetHook ("OnEditFocusGained", load_all_spells)
Tercio@58 726 new_debuff_entry:SetHook ("OnEditFocusGained", load_all_spells)
Tercio@58 727 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."
Tercio@58 728 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."
Tercio@58 729
Tercio@41 730 new_buff_entry:SetJustifyH ("left")
Tercio@41 731 new_debuff_entry:SetJustifyH ("left")
Tercio@41 732
Tercio@58 733 local add_buff_button = self:CreateButton (f_manual, function()
Tercio@41 734
Tercio@41 735 local text = new_buff_entry.text
Tercio@41 736 new_buff_entry:SetText ("")
Tercio@41 737 new_buff_entry:ClearFocus()
Tercio@58 738
Tercio@41 739 if (text ~= "") then
Tercio@41 740 --> check for more than one spellname
Tercio@41 741 if (text:find (";")) then
Tercio@58 742 for _, spellName in ipairs ({strsplit (";", text)}) do
Tercio@58 743 spellName = self:trim (spellName)
Tercio@58 744 spellName = lower (spellName)
Tercio@58 745 if (string.len (spellName) > 0) then
Tercio@58 746 local spellId = AllSpellsMap [spellName]
Tercio@58 747 if (spellId) then
Tercio@58 748 tinsert (f.db.aura_tracker.buff, spellId)
Tercio@58 749 else
Tercio@58 750 print ("spellId not found for spell:", spellName)
Tercio@58 751 end
Tercio@41 752 end
Tercio@41 753 end
Tercio@41 754 else
Tercio@58 755 --get the spellId
Tercio@58 756 local spellName = lower (text)
Tercio@58 757 local spellId = AllSpellsMap [spellName]
Tercio@58 758 if (not spellId) then
Tercio@58 759 print ("spellIs for spell ", spellName, "not found")
Tercio@58 760 return
Tercio@58 761 end
Tercio@58 762
Tercio@58 763 tinsert (f.db.aura_tracker.buff, spellId)
Tercio@41 764 end
Tercio@41 765
Tercio@41 766 buffs_added:Refresh()
Tercio@41 767 end
Tercio@58 768
Tercio@41 769 end, 100, 20, "Add Buff", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
Tercio@58 770
Tercio@41 771 local add_debuff_button = self:CreateButton (f_manual, function()
Tercio@41 772 local text = new_debuff_entry.text
Tercio@41 773 new_debuff_entry:SetText ("")
Tercio@41 774 new_debuff_entry:ClearFocus()
Tercio@41 775 if (text ~= "") then
Tercio@41 776 --> check for more than one spellname
Tercio@41 777 if (text:find (";")) then
Tercio@58 778 for _, spellName in ipairs ({strsplit (";", text)}) do
Tercio@58 779 spellName = self:trim (spellName)
Tercio@58 780 spellName = lower (spellName)
Tercio@58 781 if (string.len (spellName) > 0) then
Tercio@58 782 local spellId = AllSpellsMap [spellName]
Tercio@58 783 if (spellId) then
Tercio@58 784 tinsert (f.db.aura_tracker.debuff, spellId)
Tercio@58 785 else
Tercio@58 786 print ("spellId not found for spell:", spellName)
Tercio@58 787 end
Tercio@41 788 end
Tercio@41 789 end
Tercio@41 790 else
Tercio@58 791 --get the spellId
Tercio@58 792 local spellName = lower (text)
Tercio@58 793 local spellId = AllSpellsMap [spellName]
Tercio@58 794 if (not spellId) then
Tercio@58 795 print ("spellIs for spell ", spellName, "not found")
Tercio@58 796 return
Tercio@58 797 end
Tercio@58 798
Tercio@58 799 tinsert (f.db.aura_tracker.debuff, spellId)
Tercio@41 800 end
Tercio@58 801
Tercio@41 802 debuffs_added:Refresh()
Tercio@41 803 end
Tercio@41 804 end, 100, 20, "Add Debuff", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
Tercio@41 805
Tercio@41 806 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")
Tercio@58 807 multiple_spells_label:SetSize (350, 24)
Tercio@41 808 multiple_spells_label:SetJustifyV ("top")
Tercio@41 809
Tercio@41 810 local export_box = self:CreateTextEntry (f_manual, function()end, 242, 20, "ExportAuraTextBox", _, _, options_dropdown_template)
Tercio@41 811
Tercio@41 812 local export_buff_button = self:CreateButton (f_manual, function()
Tercio@41 813 local str = ""
Tercio@58 814 for _, spellId in ipairs (f.db.aura_tracker.buff) do
Tercio@58 815 local spellName = GetSpellInfo (spellId)
Tercio@58 816 if (spellName) then
Tercio@58 817 str = str .. spellName .. "; "
Tercio@58 818 end
Tercio@41 819 end
Tercio@41 820 export_box.text = str
Tercio@41 821 export_box:SetFocus (true)
Tercio@41 822 export_box:HighlightText()
Tercio@41 823
Tercio@41 824 end, 120, 20, "Export Buffs", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
Tercio@41 825
Tercio@41 826 local export_debuff_button = self:CreateButton (f_manual, function()
Tercio@41 827 local str = ""
Tercio@58 828 for _, spellId in ipairs (f.db.aura_tracker.debuff) do
Tercio@58 829 local spellName = GetSpellInfo (spellId)
Tercio@58 830 if (spellName) then
Tercio@58 831 str = str .. spellName .. "; "
Tercio@58 832 end
Tercio@41 833 end
Tercio@58 834
Tercio@41 835 export_box.text = str
Tercio@41 836 export_box:SetFocus (true)
Tercio@41 837 export_box:HighlightText()
Tercio@41 838
Tercio@41 839 end, 120, 20, "Export Debuffs", nil, nil, nil, nil, nil, nil, DF:GetTemplate ("button", "OPTIONS_BUTTON_TEMPLATE"))
Tercio@41 840
Tercio@58 841 new_buff_entry:SetPoint ("topleft", f_manual, "topleft", 480, y)
Tercio@58 842 new_buff_string:SetPoint ("bottomleft", new_buff_entry, "topleft", 0, 2)
Tercio@41 843 add_buff_button:SetPoint ("left", new_buff_entry, "right", 2, 0)
Tercio@41 844 add_buff_button.tooltip = "Add the aura to be tracked.\n\nClick an aura on the list to remove it."
Tercio@41 845
Tercio@58 846 new_debuff_string:SetPoint ("topleft", new_buff_entry, "bottomleft", 0, -6)
Tercio@41 847 new_debuff_entry:SetPoint ("topleft", new_debuff_string, "bottomleft", 0, -2)
Tercio@41 848 add_debuff_button:SetPoint ("left", new_debuff_entry, "right", 2, 0)
Tercio@41 849 add_debuff_button.tooltip = "Add the aura to be tracked.\n\nClick an aura on the list to remove it."
Tercio@58 850
Tercio@58 851 multiple_spells_label:SetPoint ("topleft", new_debuff_entry, "bottomleft", 0, -6)
Tercio@58 852
Tercio@58 853 export_buff_button:SetPoint ("topleft", multiple_spells_label, "bottomleft", 0, -12)
Tercio@58 854 export_debuff_button:SetPoint ("left",export_buff_button, "right", 2, 0)
Tercio@58 855 export_box:SetPoint ("topleft", export_buff_button, "bottomleft", 0, -6)
Tercio@41 856
Tercio@41 857 buffs_added:Refresh()
Tercio@41 858 debuffs_added:Refresh()
Tercio@41 859
Tercio@41 860 return f
Tercio@41 861 end
Tercio@41 862
Tercio@41 863
Tercio@41 864 function DF:GetAllPlayerSpells (include_lower_case)
Tercio@41 865 local playerSpells = {}
Tercio@41 866 local tab, tabTex, offset, numSpells = GetSpellTabInfo (2)
Tercio@41 867 for i = 1, numSpells do
Tercio@41 868 local index = offset + i
Tercio@41 869 local spellType, spellId = GetSpellBookItemInfo (index, "player")
Tercio@41 870 if (spellType == "SPELL") then
Tercio@41 871 local spellName = GetSpellInfo (spellId)
Tercio@41 872 tinsert (playerSpells, spellName)
Tercio@41 873 if (include_lower_case) then
Tercio@41 874 tinsert (playerSpells, lower (spellName))
Tercio@41 875 end
Tercio@41 876 end
Tercio@41 877 end
Tercio@41 878 return playerSpells
Tercio@41 879 end
Tercio@41 880
Tercio@41 881 function DF:SetAutoCompleteWithSpells (textentry)
Tercio@41 882 textentry:SetHook ("OnEditFocusGained", function()
Tercio@41 883 local playerSpells = DF:GetAllPlayerSpells (true)
Tercio@41 884 textentry.WordList = playerSpells
Tercio@41 885 end)
Tercio@41 886 textentry:SetAsAutoComplete ("WordList")
Tercio@41 887 end
Tercio@41 888
Tercio@41 889 --check for aura
Tercio@41 890
Tercio@41 891
Tercio@41 892 -- add aura
Tercio@41 893
Tercio@41 894
Tercio@41 895 --handle savedvariables
Tercio@41 896
Tercio@41 897
Tercio@41 898 --remove a aura
Tercio@41 899
Tercio@41 900
Tercio@41 901
Tercio@41 902
Tercio@41 903
Tercio@41 904 --handle UNIT_AURA event
Tercio@41 905
Tercio@41 906