Skip to content

Commit 7347de5

Browse files
committed
Build editor improvements (Closes #776) (#986)
1 parent f1ee932 commit 7347de5

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

Daybreak.Shared/Models/Guildwars/Skill.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ public sealed class Skill
14941494
public static readonly Skill WeaponsofThreeForges = new() { Id = 3429, Name = "Weapons of Three Forges", Profession = Profession.Ritualist };
14951495
public static readonly Skill VowofRevolution = new() { Id = 3430, Name = "Vow of Revolution", Profession = Profession.Dervish };
14961496
public static readonly Skill HeroicRefrain = new() { Id = 3431, Name = "Heroic Refrain", Profession = Profession.Paragon };
1497-
public static IEnumerable<Skill> Skills = new List<Skill>
1497+
public static readonly IReadOnlyCollection<Skill> Skills = new List<Skill>
14981498
{
14991499
NoSkill,
15001500
ResurrectionSignet,

Daybreak/Controls/Templates/BuildTemplate.xaml.cs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,21 @@ buildEntry.Primary is null ||
147147

148148
private async void LoadSkills()
149149
{
150-
var filteredSkills = await this.FilterSkills(this.SkillSearchText).ToListAsync().ConfigureAwait(true);
151-
this.PrepareSkillListCache(filteredSkills);
150+
var searchTerm = this.SkillSearchText;
151+
var buildEntry = this.BuildEntry;
152+
if (buildEntry is null)
153+
{
154+
return;
155+
}
156+
157+
await Task.Factory.StartNew(() =>
158+
{
159+
var filteredSkills = this.FilterSkills(searchTerm, buildEntry).ToList();
160+
this.Dispatcher.InvokeAsync(() =>
161+
{
162+
this.PrepareSkillListCache(filteredSkills);
163+
}, System.Windows.Threading.DispatcherPriority.Background, CancellationToken.None);
164+
}, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Current);
152165
}
153166

154167
private void BrowseToInfo(string infoName)
@@ -215,7 +228,7 @@ private void PrepareSkillListCache(List<Skill> skills)
215228
}
216229
}
217230

218-
private async IAsyncEnumerable<Skill> FilterSkills(string searchTerm)
231+
private IEnumerable<Skill> FilterSkills(string searchTerm, SingleBuildEntry buildEntry)
219232
{
220233
// Replace symbols to ease search
221234
searchTerm = searchTerm?.Replace("\"", "").Replace("!", "")!;
@@ -227,21 +240,25 @@ private async IAsyncEnumerable<Skill> FilterSkills(string searchTerm)
227240
continue;
228241
}
229242

230-
if (skill.Profession != this.BuildEntry!.Primary &&
231-
skill.Profession != this.BuildEntry!.Secondary &&
243+
if (skill.Profession != buildEntry.Primary &&
244+
skill.Profession != buildEntry.Secondary &&
232245
skill.Profession != Profession.None)
233246
{
234247
continue;
235248
}
236249

250+
if (skill.Name?.Contains("(PvP)") is true)
251+
{
252+
continue;
253+
}
254+
237255
if (searchTerm.IsNullOrWhiteSpace())
238256
{
239257
yield return skill;
240258
continue;
241259
}
242260

243-
var matchesName = await Task.Run(() => StringUtils.MatchesSearchString(skill.Name!.Replace("\"", "").Replace("!", ""), searchTerm!));
244-
if (matchesName)
261+
if (StringUtils.MatchesSearchString(skill.Name!.Replace("\"", "").Replace("!", ""), searchTerm!))
245262
{
246263
yield return skill;
247264
continue;

0 commit comments

Comments
 (0)