From 0977eddd6dcdb5faed91db02748830bfff8a34b8 Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Wed, 8 Jan 2025 10:52:09 -0800 Subject: [PATCH] add player filter --- Localization.lua | 6 +++++- filter.lua | 8 ++++++++ settings.lua | 22 +++++++++++++++++----- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Localization.lua b/Localization.lua index faeef48..093df43 100644 --- a/Localization.lua +++ b/Localization.lua @@ -15,7 +15,7 @@ L:RegisterTranslations("enUS", function() ["Ignore targets with the specified spell texture already on them. Useful for ignoring targets that already have a shared debuff."] = true, ["Time threshold at which to allow refreshing a curse. Default is 0 seconds."] = true, ["Ignore the current target when choosing target for multicurse. Does not affect 'curse' command."] = true, - ["Only choose players and ignore npcs when choosing target for multicurse. Does not affect 'curse' command."] = true, + ["Only choose players and ignore npcs when choosing target for multicurse. Does not affect 'curse' command."] = true, ["/cursive curse ||>: Casts spell if not already on target/guid"] = true, ["/cursive multicurse ||>: Picks target based on priority and casts spell if not already on target"] = true, ["Target with the highest HP."] = true, @@ -51,6 +51,8 @@ L:RegisterTranslations("enUS", function() ["Text Size"] = true, ["Scale"] = true, ["In Combat"] = true, + ["Player"] = true, + ["Player Desc"] = "Only show player units", ["Hostile"] = true, ["Attackable"] = true, ["Within 28 Range"] = true, @@ -223,6 +225,8 @@ L:RegisterTranslations("zhCN", function() ["Text Size"] = "文本大小", ["Scale"] = "缩放", ["In Combat"] = "战斗中", + ["Player"] = "玩家", + ["Player Desc"] = "只显示玩家单位", ["Hostile"] = "敌对", ["Attackable"] = "可攻击", ["Within 28 Range"] = "在28范围内", diff --git a/filter.lua b/filter.lua index 65624fb..94ae982 100644 --- a/filter.lua +++ b/filter.lua @@ -8,6 +8,10 @@ filter.attackable = function(unit) return UnitCanAttack("player", unit) and true or false end +filter.player = function(unit) + return UnitIsPlayer(unit) and true or false +end + filter.infight = function(unit) return UnitAffectingCombat(unit) and true or false end @@ -103,5 +107,9 @@ function Cursive:ShouldDisplayGuid(guid) shouldDisplay = shouldDisplay and filter.icon(guid) end + if Cursive.db.profile.filterplayer then + shouldDisplay = shouldDisplay and filter.player(guid) + end + return shouldDisplay end diff --git a/settings.lua b/settings.lua index 8faab45..0d80821 100644 --- a/settings.lua +++ b/settings.lua @@ -266,7 +266,7 @@ local mobFilters = { type = "toggle", name = L["Hostile"], desc = L["Hostile"], - order = 2, + order = 11, get = function() return Cursive.db.profile.filterhostile end, @@ -278,7 +278,7 @@ local mobFilters = { type = "toggle", name = L["Attackable"], desc = L["Attackable"], - order = 3, + order = 22, get = function() return Cursive.db.profile.filterattackable end, @@ -286,11 +286,23 @@ local mobFilters = { Cursive.db.profile.filterattackable = v end, }, + ["player"] = { + type = "toggle", + name = L["Player"], + desc = L["Player Desc"], + order = 33, + get = function() + return Cursive.db.profile.filterplayer + end, + set = function(v) + Cursive.db.profile.filterplayer = v + end, + }, ["range"] = { type = "toggle", name = IsSpellInRange and L["Within 45 Range"] or L["Within 28 Range"], desc = IsSpellInRange and L["Within 45 Range"] or L["Within 28 Range"], - order = 4, + order = 44, get = function() return Cursive.db.profile.filterrange end, @@ -302,7 +314,7 @@ local mobFilters = { type = "toggle", name = L["Has Raid Mark"], desc = L["Has Raid Mark"], - order = 5, + order = 55, get = function() return Cursive.db.profile.filterraidmark end, @@ -314,7 +326,7 @@ local mobFilters = { type = "toggle", name = L["Has Curse"], desc = L["Only show units you have cursed"], - order = 6, + order = 66, get = function() return Cursive.db.profile.filterhascurse end,