Fix flag editor validation bugs

This commit is contained in:
pizzaboxer 2024-07-08 19:13:29 +04:00
parent b05aced721
commit b2f6fc753a
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8

View File

@ -234,6 +234,12 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
if (App.FastFlags.Prop.ContainsKey(pair.Key) && !overwriteConflicting) if (App.FastFlags.Prop.ContainsKey(pair.Key) && !overwriteConflicting)
continue; continue;
// TODO - error message, i just had to hastily add this in
// as i'm currently testing 2.7.0 for release and all translations
// are already done
if (pair.Value is not string)
continue;
if (!ValidateFlagEntry(pair.Key, (string)pair.Value)) if (!ValidateFlagEntry(pair.Key, (string)pair.Value))
continue; continue;
@ -252,10 +258,10 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidPrefix; errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidPrefix;
else if (!name.All(x => char.IsLetterOrDigit(x) || x == '_')) else if (!name.All(x => char.IsLetterOrDigit(x) || x == '_'))
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidCharacter; errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidCharacter;
else if (name[..6].Contains("FFlag") && lowerValue != "true" && lowerValue != "false") else if ((name.StartsWith("FInt") || name.StartsWith("DFInt")) && !Int32.TryParse(value, out _))
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidBoolValue;
else if (name[..5].Contains("FInt") && !Int32.TryParse(value, out _))
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidNumberValue; errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidNumberValue;
else if ((name.StartsWith("FFlag") || name.StartsWith("DFFlag")) && lowerValue != "true" && lowerValue != "false")
errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidBoolValue;
if (!String.IsNullOrEmpty(errorMessage)) if (!String.IsNullOrEmpty(errorMessage))
{ {