Skip to content

Commit

Permalink
Added a Ignore field into the Spell List so users can blacklist spell…
Browse files Browse the repository at this point in the history
…s from there
  • Loading branch information
Tercioo committed May 29, 2020
1 parent 646732e commit 8667265
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Libs/DF/fw.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

local dversion = 181
local dversion = 183

local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary (major, minor)
Expand Down Expand Up @@ -1991,7 +1991,7 @@ end
end

------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> templates
--> ~templates

--fonts

Expand Down
109 changes: 102 additions & 7 deletions Libs/DF/panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,30 @@ local align_rows = function (self)
entry.onleave_func = row.onleave
end
end

elseif (type == "checkbox") then
for i = 1, #self.scrollframe.lines do
local line = self.scrollframe.lines [i]
local checkbox = tremove (line.checkbox_available)
if (not checkbox) then
self:CreateCheckbox (line)
checkbox = tremove (line.checkbox_available)
end

tinsert (line.checkbox_inuse, checkbox)

checkbox:SetPoint ("left", line, "left", self._anchors [#self._anchors] + ((row.width - 20) / 2), 0)
if (sindex == rows_shown) then
checkbox:SetWidth (20)
--checkbox:SetWidth (row.width - 25)
else
checkbox:SetWidth (20)
end

checkbox.onenter_func = nil
checkbox.onleave_func = nil
end

elseif (type == "button") then
for i = 1, #self.scrollframe.lines do
local line = self.scrollframe.lines [i]
Expand Down Expand Up @@ -976,6 +1000,13 @@ local update_rows = function (self, updated_rows)
for i = 1, #row.button_available do
row.button_available[i]:Hide()
end

for i = #row.checkbox_inuse, 1, -1 do
tinsert (row.checkbox_available, tremove (row.checkbox_inuse, i))
end
for i = 1, #row.checkbox_available do
row.checkbox_available[i]:Hide()
end

for i = #row.icon_inuse, 1, -1 do
tinsert (row.icon_available, tremove (row.icon_inuse, i))
Expand Down Expand Up @@ -1037,6 +1068,17 @@ local create_panel_entry = function (self, row)
tinsert (row.entry_available, editbox)
end

local create_panel_checkbox = function (self, row)
--row.checkbox_available
row.checkbox_total = row.checkbox_total + 1

local switch = DF:NewSwitch (row, nil, "$parentCheckBox" .. row.checkbox_total, nil, 20, 20, nil, nil, false)
switch:SetAsCheckBox()
switch:SetTemplate(DF:GetTemplate ("switch", "OPTIONS_CHECKBOX_TEMPLATE"))

tinsert (row.checkbox_available, switch)
end

local create_panel_button = function (self, row)
row.button_total = row.button_total + 1
local button = DF:NewButton (row, nil, "$parentButton" .. row.button_total, "button" .. row.button_total, 120, 20)
Expand Down Expand Up @@ -1131,6 +1173,7 @@ function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_ro
panel.CreateRowText = create_panel_text
panel.CreateRowEntry = create_panel_entry
panel.CreateRowButton = create_panel_button
panel.CreateCheckbox = create_panel_checkbox
panel.CreateRowIcon = create_panel_icon
panel.CreateRowTexture = create_panel_texture
panel.SetFillFunction = set_fill_function
Expand Down Expand Up @@ -1170,7 +1213,7 @@ function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_ro
if (results and results [1]) then
row:Show()

local text, entry, button, icon, texture = 1, 1, 1, 1, 1
local text, entry, button, icon, texture, checkbox = 1, 1, 1, 1, 1, 1

for index, t in ipairs (panel.rows) do
if (not t.hidden) then
Expand Down Expand Up @@ -1198,7 +1241,19 @@ function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_ro
entrywidget:SetCursorPosition(0)

entrywidget:Show()


elseif (t.type == "checkbox") then
local checkboxwidget = row.checkbox_inuse [button]
checkbox = checkbox + 1
checkboxwidget.index = real_index
checkboxwidget:SetValue(results [index])

local func = function()
t.func (real_index, index)
panel:Refresh()
end
checkboxwidget.OnSwitch = func

elseif (t.type == "button") then
local buttonwidget = row.button_inuse [button]
button = button + 1
Expand Down Expand Up @@ -1248,11 +1303,28 @@ function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_ro

iconwidget.line = index
iconwidget.index = real_index

--print (index, results [index])

if (type (results [index]) == "string") then
local result = results [index]:gsub (".-%\\", "")
iconwidget._icon.texture = results [index]

elseif (type (results [index]) == "table") then
iconwidget._icon:SetTexture (results [index].texture)

local textCoord = results [index].texcoord
if (textCoord) then
iconwidget._icon:SetTexCoord (unpack(textCoord))
else
iconwidget._icon:SetTexCoord (0, 1, 0, 1)
end

local color = results [index].color
if (color) then
local r, g, b, a = DF:ParseColors(color)
iconwidget._icon:SetVertexColor(r, g, b, a)
else
iconwidget._icon:SetVertexColor(1, 1, 1, 1)
end
else
iconwidget._icon:SetTexture (results [index])
end
Expand All @@ -1269,6 +1341,25 @@ function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_ro
if (type (results [index]) == "string") then
local result = results [index]:gsub (".-%\\", "")
texturewidget.texture = results [index]

elseif (type (results [index]) == "table") then
texturewidget:SetTexture (results [index].texture)

local textCoord = results [index].texcoord
if (textCoord) then
texturewidget:SetTexCoord (unpack(textCoord))
else
texturewidget:SetTexCoord (0, 1, 0, 1)
end

local color = results [index].color
if (color) then
local r, g, b, a = DF:ParseColors(color)
texturewidget:SetVertexColor(r, g, b, a)
else
texturewidget:SetVertexColor(1, 1, 1, 1)
end

else
texturewidget:SetTexture (results [index])
end
Expand Down Expand Up @@ -1346,6 +1437,10 @@ function DF:NewFillPanel (parent, rows, name, member, w, h, total_lines, fill_ro
row.button_inuse = {}
row.button_total = 0

row.checkbox_available = {}
row.checkbox_inuse = {}
row.checkbox_total = 0

row.icon_available = {}
row.icon_inuse = {}
row.icon_total = 0
Expand Down Expand Up @@ -7167,9 +7262,9 @@ DF.StatusBarFunctions = {

if (self.Settings.ShowHealingPrediction) then
--incoming heal on the unit from all sources
local unitHealIncoming = UnitGetIncomingHeals (self.displayedUnit) or 0
local unitHealIncoming = self.displayedUnit and UnitGetIncomingHeals (self.displayedUnit) or 0
--heal absorbs
local unitHealAbsorb = UnitGetTotalHealAbsorbs (self.displayedUnit) or 0
local unitHealAbsorb = self.displayedUnit and UnitGetTotalHealAbsorbs (self.displayedUnit) or 0

if (unitHealIncoming > 0) then
--calculate what is the percent of health incoming based on the max health the player has
Expand All @@ -7195,7 +7290,7 @@ DF.StatusBarFunctions = {

if (self.Settings.ShowShields) then
--damage absorbs
local unitDamageAbsorb = UnitGetTotalAbsorbs (self.displayedUnit) or 0
local unitDamageAbsorb = self.displayedUnit and UnitGetTotalAbsorbs (self.displayedUnit) or 0

if (unitDamageAbsorb > 0) then
local damageAbsorbPercent = unitDamageAbsorb / currentHealthMax
Expand Down
27 changes: 20 additions & 7 deletions functions/link.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3309,15 +3309,26 @@

-----------------------------------------------

local spell_ignore_spell_func = function(row)
local data = all_modules [1].data [row]
local spellid = data[1]

if (not _detalhes.spellid_ignored[spellid]) then
_detalhes.spellid_ignored[spellid] = true
else
_detalhes.spellid_ignored[spellid] = nil
end
end

local spell_open_aura_creator = function (row)
local data = all_modules [2].data [row]
local data = all_modules [1].data [row]
local spellid = data[1]
local spellname, _, spellicon = GetSpellInfo (spellid)
_detalhes:OpenAuraPanel (spellid, spellname, spellicon, data[3])
end

local spell_encounter_open_aura_creator = function (row)
local data = all_modules [1].data [row]
local data = all_modules [2].data [row]
local spellID = data[1]
local encounterID = data [2]
local enemyName = data [3]
Expand Down Expand Up @@ -3418,8 +3429,9 @@
{name = L["STRING_FORGE_HEADER_NAME"], width = 150, type = "entry", func = no_func, onenter = function(self) GameTooltip:SetOwner (self.widget, "ANCHOR_TOPLEFT"); _detalhes:GameTooltipSetSpellByID (self.id); GameTooltip:Show() end, onleave = function(self) GameTooltip:Hide() end},
{name = L["STRING_FORGE_HEADER_SPELLID"], width = 60, type = "entry", func = no_func},
{name = L["STRING_FORGE_HEADER_SCHOOL"], width = 60, type = "entry", func = no_func},
{name = L["STRING_FORGE_HEADER_CASTER"], width = 120, type = "entry", func = no_func},
{name = L["STRING_FORGE_HEADER_EVENT"], width = 180, type = "entry", func = no_func},
{name = L["STRING_FORGE_HEADER_CASTER"], width = 100, type = "entry", func = no_func},
{name = L["STRING_FORGE_HEADER_EVENT"], width = 140, type = "entry", func = no_func},
{name = "Ignore", width = 50, type = "checkbox", func = spell_ignore_spell_func, icon = [[Interface\Glues\LOGIN\Glues-CheckBox-Check]], notext = true, iconalign = "center"},
{name = L["STRING_FORGE_HEADER_CREATEAURA"], width = 86, type = "button", func = spell_open_aura_creator, icon = [[Interface\AddOns\WeakAuras\Media\Textures\icon]], notext = true, iconalign = "center"},
},
fill_panel = false,
Expand All @@ -3439,12 +3451,13 @@
local classColor = RAID_CLASS_COLORS [data[2]] and RAID_CLASS_COLORS [data[2]].colorStr or "FFFFFFFF"
return {
index,
spellIcon,
{texture = spellIcon, texcoord = {.1, .9, .1, .9}},
{text = spellName or "", id = data[1] or 1},
data[1] or "",
_detalhes:GetSpellSchoolFormatedName (_detalhes.spell_school_cache [spellName]) or "",
"|c" .. classColor .. data[2] .. "|r",
events
events,
_detalhes.spellid_ignored[data[1]]
}
else
return nothing_to_show
Expand Down Expand Up @@ -4005,8 +4018,8 @@
f.SelectModule = select_module
f.AllModules = all_modules

f:InstallModule (encounter_spells_module)
f:InstallModule (all_spells_module)
f:InstallModule (encounter_spells_module)

f:InstallModule (npc_ids_module)

Expand Down
2 changes: 2 additions & 0 deletions functions/profiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,8 @@ local default_global_data = {

--> store all npcids blacklisted by the user
npcid_ignored = {},
--> store all spellids blacklisted by the user
spellid_ignored = {},
}

_detalhes.default_global_data = default_global_data
Expand Down

0 comments on commit 8667265

Please sign in to comment.