Skip to content

Commit 59286ed

Browse files
authored
Merge pull request #257 from smasherprog/Beta
New Feature: Adaptive Spell Grouping
2 parents 4d74b5e + fc810b2 commit 59286ed

21 files changed

+811
-100
lines changed

EQTool/DI.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public static IContainer Init()
4949
_ = builder.RegisterType<Services.AppDispatcher>().As<Services.IAppDispatcher>().SingleInstance();
5050
_ = builder.RegisterType<Services.SpellIcons>().AsSelf().SingleInstance();
5151
_ = builder.RegisterType<Services.ParseSpells_spells_us>().AsSelf().SingleInstance();
52+
_ = builder.RegisterType<Services.SpellGroupingEngine>().AsSelf().SingleInstance();
5253
_ = builder.RegisterType<Services.PlayerTrackerService>().AsSelf().SingleInstance();
5354
_ = builder.RegisterType<Services.ZoneActivityTrackingService>().AsSelf().SingleInstance();
5455
_ = builder.RegisterType<Services.TimersService>().AsSelf().SingleInstance();

EQTool/EQTool.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@
387387
<Compile Include="Services\Parsing\FactionParser.cs" />
388388
<Compile Include="Services\SavePlayerStateService.cs" />
389389
<Compile Include="Services\SortingPrefixes.cs" />
390+
<Compile Include="Services\SpellGroupingEngine.cs" />
390391
<Compile Include="Services\TypeConverters\EnumDescriptionTypeConverter.cs" />
391392
<Compile Include="Services\UIRunner.cs" />
392393
<Compile Include="Services\UpdateRunner.cs" />

EQTool/Models/EQToolSettings.cs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,36 +138,50 @@ public WindowState SettingsWindowState
138138

139139
public List<PlayerInfo> Players { get; set; } = new List<PlayerInfo>();
140140
public List<Trigger> Triggers { get; set; } = new List<Trigger>();
141-
public SpellsFilterType SpellsFilter { get; set; }
141+
public SpellsFilterType _SpellsFilter = SpellsFilterType.ByClass;
142+
public SpellsFilterType SpellsFilter
143+
{
144+
get => _SpellsFilter;
145+
set
146+
{
147+
if (value == _SpellsFilter)
148+
{
149+
return;
150+
}
151+
152+
_SpellsFilter = value;
153+
OnPropertyChanged();
154+
}
155+
}
142156

143-
private SpellGroupingType _BeneficialSpellGroupingType = SpellGroupingType.ByTarget;
144-
public SpellGroupingType BeneficialSpellGroupingType
157+
private SpellGroupingType _PlayerSpellGroupingType = SpellGroupingType.ByTarget;
158+
public SpellGroupingType PlayerSpellGroupingType
145159
{
146-
get => _BeneficialSpellGroupingType;
160+
get => _PlayerSpellGroupingType;
147161
set
148162
{
149-
if (value == _BeneficialSpellGroupingType)
163+
if (value == _PlayerSpellGroupingType)
150164
{
151165
return;
152166
}
153167

154-
_BeneficialSpellGroupingType = value;
168+
_PlayerSpellGroupingType = value;
155169
OnPropertyChanged();
156170
}
157171
}
158172

159-
private SpellGroupingType _DetrimentalSpellGroupingType = SpellGroupingType.ByTarget;
160-
public SpellGroupingType DetrimentalSpellGroupingType
173+
private SpellGroupingType _NpcSpellGroupingType = SpellGroupingType.ByTarget;
174+
public SpellGroupingType NpcSpellGroupingType
161175
{
162-
get => _DetrimentalSpellGroupingType;
176+
get => _NpcSpellGroupingType;
163177
set
164178
{
165-
if (value == _DetrimentalSpellGroupingType)
179+
if (value == _NpcSpellGroupingType)
166180
{
167181
return;
168182
}
169183

170-
_DetrimentalSpellGroupingType = value;
184+
_NpcSpellGroupingType = value;
171185
OnPropertyChanged();
172186
}
173187
}

EQTool/Models/PlayerInfo.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.ComponentModel;
66
using System.Runtime.CompilerServices;
77
using System.Windows;
8+
using EQTool.Services.TypeConverters;
89

910
namespace EQTool.Models
1011
{
@@ -156,9 +157,12 @@ public class YouSpells
156157
public int TotalSecondsLeft { get; set; }
157158
}
158159

160+
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
159161
public enum TimerRecast
160162
{
163+
[Description("Start New Timer")]
161164
StartNewTimer = 1,
165+
[Description("Restart Current Timer")]
162166
RestartCurrentTimer
163167
}
164168

@@ -177,7 +181,6 @@ public int Level
177181
}
178182

179183
private PlayerDamage _BestPlayerDamage;
180-
181184
public PlayerDamage BestPlayerDamage
182185
{
183186
get

EQTool/Models/SpellGroupingType.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace EQTool.Models
66
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
77
public enum SpellGroupingType
88
{
9+
[Description("Adaptive")]
10+
Adaptive,
911
[Description("By Target")]
1012
ByTarget,
1113
[Description("By Spell")]

EQTool/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Reflection;
2+
using System.Runtime.CompilerServices;
23
using System.Runtime.InteropServices;
34
using System.Windows;
45

@@ -51,3 +52,5 @@
5152
// [assembly: AssemblyVersion("1.0.*")]
5253
[assembly: AssemblyVersion("1.0.0.0")]
5354
[assembly: AssemblyFileVersion("1.0.0.0")]
55+
56+
[assembly: InternalsVisibleTo("EQtoolsTests")]

EQTool/Services/MarkupExtensions/EnumBindingSourceExtension.cs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using System.Windows.Markup;
34

45
namespace EQTool.Services.MarkupExtensions
@@ -12,6 +13,12 @@ public EnumBindingSourceExtension(Type enumType)
1213
{
1314
EnumType = enumType;
1415
}
16+
17+
/// <summary>
18+
/// Comma-separated list of enum names to exclude
19+
/// e.g. "BySpellExceptYou,SomethingElse"
20+
/// </summary>
21+
public string Exclude { get; set; }
1522

1623
private Type _EnumType;
1724
public Type EnumType
@@ -20,11 +27,9 @@ public Type EnumType
2027
set
2128
{
2229
if (value == _EnumType)
23-
{
2430
return;
25-
}
2631

27-
if (null != value)
32+
if (value != null)
2833
{
2934
var enumType = Nullable.GetUnderlyingType(value) ?? value;
3035
if (!enumType.IsEnum)
@@ -39,20 +44,35 @@ public Type EnumType
3944

4045
public override object ProvideValue(IServiceProvider serviceProvider)
4146
{
42-
if (null == _EnumType)
47+
if (_EnumType == null)
4348
{
4449
throw new InvalidOperationException("The EnumType must be specified.");
4550
}
4651

4752
var actualEnumType = Nullable.GetUnderlyingType(_EnumType) ?? _EnumType;
48-
var enumValues = Enum.GetValues(actualEnumType);
49-
if (actualEnumType == _EnumType)
53+
var enumValues = Enum.GetValues(actualEnumType).Cast<object>();
54+
55+
// Handle exclusions
56+
if (!string.IsNullOrWhiteSpace(Exclude))
5057
{
51-
return enumValues;
58+
var excludedNames = Exclude
59+
.Split(',')
60+
.Select(s => s.Trim())
61+
.Where(s => !string.IsNullOrEmpty(s))
62+
.ToHashSet(StringComparer.OrdinalIgnoreCase);
63+
64+
enumValues = enumValues
65+
.Where(v => !excludedNames.Contains(v.ToString()));
5266
}
5367

54-
var tempArray = Array.CreateInstance(actualEnumType, enumValues.Length + 1);
55-
enumValues.CopyTo(tempArray, 1);
68+
var final = enumValues.ToArray();
69+
70+
// Nullable enum support
71+
if (actualEnumType == _EnumType)
72+
return final;
73+
74+
var tempArray = Array.CreateInstance(actualEnumType, final.Length + 1);
75+
final.CopyTo(tempArray, 1);
5676
return tempArray;
5777
}
5878
}

0 commit comments

Comments
 (0)