mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-15 13:14:17 +01:00
Allow filtering for None in certain cases.
This commit is contained in:
parent
b4b104f919
commit
0583cc5bfc
1 changed files with 37 additions and 25 deletions
|
|
@ -214,7 +214,8 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
||||||
+ "Enter t:[string] to filter for designs set to specific tags.\n"
|
+ "Enter t:[string] to filter for designs set to specific tags.\n"
|
||||||
+ "Enter c:[string] to filter for designs set to specific colors.\n"
|
+ "Enter c:[string] to filter for designs set to specific colors.\n"
|
||||||
+ "Enter i:[string] to filter for designs containing specific items.\n"
|
+ "Enter i:[string] to filter for designs containing specific items.\n"
|
||||||
+ "Enter n:[string] to filter only for design names and no paths.";
|
+ "Enter n:[string] to filter only for design names and no paths.\n\n"
|
||||||
|
+ "Use None as a placeholder value that only matches empty lists or names.";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Appropriately identify and set the string filter and its type. </summary>
|
/// <summary> Appropriately identify and set the string filter and its type. </summary>
|
||||||
|
|
@ -228,10 +229,10 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
||||||
{
|
{
|
||||||
'n' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 1),
|
'n' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 1),
|
||||||
'N' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 1),
|
'N' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 1),
|
||||||
'm' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 2),
|
'm' => filterValue.Length == 2 ? (LowerString.Empty, -1) : ParseFilter(filterValue, 2),
|
||||||
'M' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 2),
|
'M' => filterValue.Length == 2 ? (LowerString.Empty, -1) : ParseFilter(filterValue, 2),
|
||||||
't' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 3),
|
't' => filterValue.Length == 2 ? (LowerString.Empty, -1) : ParseFilter(filterValue, 3),
|
||||||
'T' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 3),
|
'T' => filterValue.Length == 2 ? (LowerString.Empty, -1) : ParseFilter(filterValue, 3),
|
||||||
'i' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 4),
|
'i' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 4),
|
||||||
'I' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 4),
|
'I' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 4),
|
||||||
'c' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 5),
|
'c' => filterValue.Length == 2 ? (LowerString.Empty, -1) : (new LowerString(filterValue[2..]), 5),
|
||||||
|
|
@ -244,6 +245,15 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const int EmptyOffset = 128;
|
||||||
|
|
||||||
|
private static (LowerString, int) ParseFilter(string value, int id)
|
||||||
|
{
|
||||||
|
value = value[2..];
|
||||||
|
var lower = new LowerString(value);
|
||||||
|
return (lower, lower.Lower is "none" ? id + EmptyOffset : id);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The overwritten filter method also computes the state.
|
/// The overwritten filter method also computes the state.
|
||||||
/// Folders have default state and are filtered out on the direct string instead of the other options.
|
/// Folders have default state and are filtered out on the direct string instead of the other options.
|
||||||
|
|
@ -273,6 +283,8 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
||||||
3 => !design.Tags.Any(_designFilter.IsContained),
|
3 => !design.Tags.Any(_designFilter.IsContained),
|
||||||
4 => !design.DesignData.ContainsName(_designFilter),
|
4 => !design.DesignData.ContainsName(_designFilter),
|
||||||
5 => !_designFilter.IsContained(design.Color.Length == 0 ? DesignColors.AutomaticName : design.Color),
|
5 => !_designFilter.IsContained(design.Color.Length == 0 ? DesignColors.AutomaticName : design.Color),
|
||||||
|
2 + EmptyOffset => design.AssociatedMods.Count > 0,
|
||||||
|
3 + EmptyOffset => design.Tags.Length > 0,
|
||||||
_ => false, // Should never happen
|
_ => false, // Should never happen
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue