mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Merge branch 'main' of https://github.com/pizzaboxer/bloxstrap
This commit is contained in:
commit
4106c3cb59
1
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
1
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
@ -19,6 +19,7 @@ body:
|
||||
options:
|
||||
- label: I have read the preliminary instructions, and I am certain that my problem has not already been addressed.
|
||||
required: true
|
||||
- label: My answer given in the checkbox above is a lie.
|
||||
- type: textarea
|
||||
id: what-happened
|
||||
attributes:
|
||||
|
10
Bloxstrap/Resources/Strings.Designer.cs
generated
10
Bloxstrap/Resources/Strings.Designer.cs
generated
@ -1,7 +1,6 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@ -1703,6 +1702,15 @@ namespace Bloxstrap.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The entry for '{0}' is not valid as the place filter is not formatted correctly..
|
||||
/// </summary>
|
||||
public static string Menu_FastFlagEditor_InvalidPlaceFilter {
|
||||
get {
|
||||
return ResourceManager.GetString("Menu.FastFlagEditor.InvalidPlaceFilter", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The entry for '{0}' is not valid as the name must start with FFlag, DFInt, etc.
|
||||
/// </summary>
|
||||
|
@ -1021,4 +1021,7 @@ Selecting 'No' will ignore this warning and continue installation.</value>
|
||||
<data name="Common.SystemDefault" xml:space="preserve">
|
||||
<value>System default</value>
|
||||
</data>
|
||||
<data name="Menu.FastFlagEditor.InvalidPlaceFilter" xml:space="preserve">
|
||||
<value>The entry for '{0}' is not valid as the place filter is not formatted correctly.</value>
|
||||
</data>
|
||||
</root>
|
@ -22,9 +22,15 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
||||
private readonly ObservableCollection<FastFlag> _fastFlagList = new();
|
||||
private readonly List<string> _validPrefixes = new()
|
||||
{
|
||||
"FFlag", "DFFlag", "SFFlag", "FInt", "DFInt", "FString", "DFString", "FLog", "DFlog"
|
||||
"FFlag", "DFFlag", "SFFlag", "FInt", "DFInt", "FString", "DFString", "FLog", "DFLog"
|
||||
};
|
||||
|
||||
// values must match the entire string to avoid cases where half the string
|
||||
// matches but the filter would still be invalid
|
||||
private readonly Regex _boolFilterPattern = new("(?:true|false)(;[\\d]{1,})+$");
|
||||
private readonly Regex _intFilterPattern = new("([\\d]{1,})?(;[\\d]{1,})+$");
|
||||
private readonly Regex _stringFilterPattern = new("^[^;]*(;[\\d]{1,})+$");
|
||||
|
||||
private bool _showPresets = false;
|
||||
private string _searchFilter = "";
|
||||
|
||||
@ -253,10 +259,13 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
||||
string lowerValue = value.ToLowerInvariant();
|
||||
string errorMessage = "";
|
||||
|
||||
if (!_validPrefixes.Where(x => name.StartsWith(x)).Any())
|
||||
if (!_validPrefixes.Any(name.StartsWith))
|
||||
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidPrefix;
|
||||
else if (!name.All(x => char.IsLetterOrDigit(x) || x == '_'))
|
||||
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidCharacter;
|
||||
|
||||
if (name.EndsWith("_PlaceFilter") || name.EndsWith("_DataCenterFilter"))
|
||||
errorMessage = !ValidateFilter(name, value) ? Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidPlaceFilter : "";
|
||||
else if ((name.StartsWith("FInt") || name.StartsWith("DFInt")) && !Int32.TryParse(value, out _))
|
||||
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidNumberValue;
|
||||
else if ((name.StartsWith("FFlag") || name.StartsWith("DFFlag")) && lowerValue != "true" && lowerValue != "false")
|
||||
@ -271,6 +280,18 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool ValidateFilter(string name, string value)
|
||||
{
|
||||
if(name.StartsWith("FFlag") || name.StartsWith("DFFlag"))
|
||||
return _boolFilterPattern.IsMatch(value);
|
||||
if (name.StartsWith("FInt") || name.StartsWith("DFInt"))
|
||||
return _intFilterPattern.IsMatch(value);
|
||||
if (name.StartsWith("FString") || name.StartsWith("DFString") || name.StartsWith("FLog") || name.StartsWith("DFLog"))
|
||||
return _stringFilterPattern.IsMatch(value);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// refresh list on page load to synchronize with preset page
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e) => ReloadList();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user