add search to marking editors (#15526)
This commit is contained in:
@@ -73,7 +73,7 @@ public sealed partial class MarkingPicker : Control
|
||||
set
|
||||
{
|
||||
_ignoreSpecies = value;
|
||||
Populate();
|
||||
Populate(CMarkingSearch.Text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public sealed partial class MarkingPicker : Control
|
||||
CurrentSkinColor = skinColor;
|
||||
CurrentEyeColor = eyeColor;
|
||||
|
||||
Populate();
|
||||
Populate(CMarkingSearch.Text);
|
||||
PopulateUsed();
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ public sealed partial class MarkingPicker : Control
|
||||
CurrentSkinColor = skinColor;
|
||||
CurrentEyeColor = eyeColor;
|
||||
|
||||
Populate();
|
||||
Populate(CMarkingSearch.Text);
|
||||
PopulateUsed();
|
||||
}
|
||||
|
||||
@@ -136,6 +136,8 @@ public sealed partial class MarkingPicker : Control
|
||||
|
||||
CMarkingRankUp.OnPressed += _ => SwapMarkingUp();
|
||||
CMarkingRankDown.OnPressed += _ => SwapMarkingDown();
|
||||
|
||||
CMarkingSearch.OnTextChanged += args => Populate(args.Text);
|
||||
}
|
||||
|
||||
private void SetupCategoryButtons()
|
||||
@@ -174,7 +176,7 @@ public sealed partial class MarkingPicker : Control
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Populate()
|
||||
public void Populate(string filter)
|
||||
{
|
||||
CMarkingsUnused.Clear();
|
||||
_selectedUnusedMarking = null;
|
||||
@@ -183,8 +185,12 @@ public sealed partial class MarkingPicker : Control
|
||||
? _markingManager.MarkingsByCategory(_selectedMarkingCategory)
|
||||
: _markingManager.MarkingsByCategoryAndSpecies(_selectedMarkingCategory, _currentSpecies);
|
||||
|
||||
var sortedMarkings = markings.OrderBy(p => Loc.GetString(GetMarkingName(p.Value)));
|
||||
foreach (var (_, marking) in sortedMarkings)
|
||||
var sortedMarkings = markings.Values.Where(m =>
|
||||
m.ID.ToLower().Contains(filter.ToLower()) ||
|
||||
GetMarkingName(m).ToLower().Contains(filter.ToLower())
|
||||
).OrderBy(p => Loc.GetString(GetMarkingName(p)));
|
||||
|
||||
foreach (var marking in sortedMarkings)
|
||||
{
|
||||
if (_currentMarkings.TryGetMarking(_selectedMarkingCategory, marking.ID, out _))
|
||||
{
|
||||
@@ -314,7 +320,7 @@ public sealed partial class MarkingPicker : Control
|
||||
_currentMarkings = new(markingList, speciesPrototype.MarkingPoints, _markingManager, _prototypeManager);
|
||||
_currentMarkings.EnsureSpecies(species, null, _markingManager);
|
||||
|
||||
Populate();
|
||||
Populate(CMarkingSearch.Text);
|
||||
PopulateUsed();
|
||||
}
|
||||
|
||||
@@ -331,7 +337,7 @@ public sealed partial class MarkingPicker : Control
|
||||
{
|
||||
CMarkingCategoryButton.SelectId(category.Id);
|
||||
_selectedMarkingCategory = _markingCategories[category.Id];
|
||||
Populate();
|
||||
Populate(CMarkingSearch.Text);
|
||||
PopulateUsed();
|
||||
UpdatePoints();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user