Skip to content

Commit a190f91

Browse files
authored
Merge pull request #258 from smasherprog/spell-filters-v2
Spell Filtering Setting Rework
2 parents 59286ed + 72a6464 commit a190f91

File tree

7 files changed

+48
-17
lines changed

7 files changed

+48
-17
lines changed

EQTool/Models/EQToolSettings.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.ComponentModel;
34
using System.Runtime.CompilerServices;
45
using System.Windows;
@@ -138,12 +139,18 @@ public WindowState SettingsWindowState
138139

139140
public List<PlayerInfo> Players { get; set; } = new List<PlayerInfo>();
140141
public List<Trigger> Triggers { get; set; } = new List<Trigger>();
142+
141143
public SpellsFilterType _SpellsFilter = SpellsFilterType.ByClass;
142144
public SpellsFilterType SpellsFilter
143145
{
144146
get => _SpellsFilter;
145147
set
146148
{
149+
if ((int) value == 3) // Legacy setting. Lazy Migration. We should avoid adding a new 3 in the future, but if we do, we can just delete this block.
150+
{
151+
value = SpellsFilterType.CastByYou;
152+
}
153+
147154
if (value == _SpellsFilter)
148155
{
149156
return;
@@ -153,7 +160,22 @@ public SpellsFilterType SpellsFilter
153160
OnPropertyChanged();
154161
}
155162
}
163+
164+
private bool _SpellsFilterAlwaysShowCastOnYou = true;
165+
public bool SpellsFilterAlwaysShowCastOnYou
166+
{
167+
get => _SpellsFilterAlwaysShowCastOnYou;
168+
set
169+
{
170+
if (value == _SpellsFilterAlwaysShowCastOnYou)
171+
{
172+
return;
173+
}
156174

175+
_SpellsFilterAlwaysShowCastOnYou = value;
176+
OnPropertyChanged();
177+
}
178+
}
157179
private SpellGroupingType _PlayerSpellGroupingType = SpellGroupingType.ByTarget;
158180
public SpellGroupingType PlayerSpellGroupingType
159181
{
@@ -210,7 +232,6 @@ public bool? RaidModeDetection
210232
}
211233
public bool LoginMiddleMand { get; set; }
212234
public bool IsClickThroughMode { get; set; }
213-
214235
public event PropertyChangedEventHandler PropertyChanged;
215236

216237
protected void OnPropertyChanged([CallerMemberName] string name = null)

EQTool/Models/SpellsFilterType.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ namespace EQTool.Models
66
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
77
public enum SpellsFilterType
88
{
9-
[Description("By Class")]
10-
ByClass,
11-
[Description("Cast On You")]
12-
CastOnYou,
9+
[Description("Allowed Classes")]
10+
ByClass = 0,
1311
[Description("Cast By You")]
14-
CastByYou,
15-
[Description("Cast By or On You")]
16-
CastByOrOnYou
12+
CastByYou = 1,
13+
[Description("Cast By Your Class")]
14+
CastByYourClass = 4,
1715
}
1816
}

EQTool/Services/SpellGroupingEngine.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ namespace EQTool.Services
99
{
1010
public class SpellGroupingEngine
1111
{
12-
private readonly object _lock = new object();
13-
1412
private readonly PlayerInfo activePlayer;
1513
private readonly EQToolSettings settings;
1614

EQTool/UI/SettingsComponents/SettingsGeneral.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@
366366
</ComboBox>
367367
</StackPanel>
368368
<StackPanel Orientation="Horizontal">
369+
<TextBlock Text="Always show spells cast on you?" VerticalAlignment="Center" FontWeight="Bold" MinWidth="100"/>
370+
<CheckBox IsChecked="{Binding SpellsFilterAlwaysShowCastOnYou}" Click="Savesettings" MinWidth="75" Margin="7,0,0,0"/>
371+
</StackPanel>
372+
<StackPanel Orientation="Horizontal" Margin="0,8,0,0">
369373
<TextBlock Text="Spell Filters" VerticalAlignment="Center" FontWeight="Bold" MinWidth="100"/>
370374
<ComboBox SelectedItem="{Binding SpellsFilter}" ItemsSource="{Binding Source={markupExtensions:EnumBindingSource {x:Type models:SpellsFilterType}}}" MinWidth="100"></ComboBox>
371375
</StackPanel>

EQTool/ViewModels/SettingsWindowViewModel.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ public SpellGroupingType NpcSpellGroupingType
283283
}
284284
}
285285

286+
public bool ShowClassFilters => toolSettings.SpellsFilter == SpellsFilterType.ByClass;
286287
public SpellsFilterType SpellsFilter
287288
{
288289
get => toolSettings.SpellsFilter;
@@ -294,7 +295,15 @@ public SpellsFilterType SpellsFilter
294295
}
295296
}
296297

297-
public bool ShowClassFilters => toolSettings.SpellsFilter == SpellsFilterType.ByClass;
298+
public bool SpellsFilterAlwaysShowCastOnYou
299+
{
300+
get => toolSettings.SpellsFilterAlwaysShowCastOnYou;
301+
set
302+
{
303+
toolSettings.SpellsFilterAlwaysShowCastOnYou = value;
304+
OnPropertyChanged();
305+
}
306+
}
298307

299308
private PetViewModel _PetViewModel;
300309
public PetViewModel PetViewModel
@@ -305,7 +314,6 @@ public PetViewModel PetViewModel
305314
_PetViewModel = value;
306315
OnPropertyChanged();
307316
}
308-
309317
}
310318

311319
private ActivePlayer _ActivePlayer;

EQTool/ViewModels/SpellWindowViewModel.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,14 @@ private bool ShouldFilterSpell(SpellViewModel s, PlayerInfo player)
440440

441441
return true;
442442
}
443+
444+
if (settings.SpellsFilterAlwaysShowCastOnYou && s.CastOnYou())
445+
return false;
443446

444447
switch (settings.SpellsFilter)
445448
{
446-
case SpellsFilterType.CastOnYou when !s.CastOnYou():
447449
case SpellsFilterType.CastByYou when !s.CastByYou():
448-
case SpellsFilterType.CastByOrOnYou when !(s.CastOnYou() || s.CastByYou()):
450+
case SpellsFilterType.CastByYourClass when !s.CastByYourClass(player):
449451
return true;
450452
case SpellsFilterType.ByClass:
451453
return !IsClassSpellAllowed(s.Classes, player.ShowSpellsForClasses);
@@ -789,7 +791,6 @@ public void UpdateAPITimers()
789791
else
790792
{
791793
match.TotalRemainingDuration = TimeSpan.FromHours(24).Subtract(TimeSpan.FromMinutes(30 - match.TotalRemainingDuration.Minutes));
792-
793794
}
794795
}
795796
}
@@ -827,6 +828,7 @@ private void Base_PropertyChanged(object sender, PropertyChangedEventArgs e)
827828
OnPropertyChanged(nameof(GenericButtonVisibility));
828829
}
829830
else if (e.PropertyName == nameof(settings.PlayerSpellGroupingType)
831+
|| e.PropertyName == nameof(settings.SpellsFilterAlwaysShowCastOnYou)
830832
|| e.PropertyName == nameof(settings.NpcSpellGroupingType)
831833
|| e.PropertyName == nameof(settings.SpellsFilter))
832834
{

EQtoolsTests/SpellMatchingTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void TestRangerBindSight()
9292
public void TestBurnoutIII_ForPet()
9393
{
9494
var settings = container.Resolve<EQToolSettings>();
95-
settings.SpellsFilter = SpellsFilterType.CastOnYou;
95+
settings.SpellsFilterAlwaysShowCastOnYou = true;
9696
var pet = container.Resolve<PetViewModel>();
9797
pet.PetName = "Xibab";
9898
var spellname = "Burnout III";

0 commit comments

Comments
 (0)