diff --git a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorPage.xaml.cs b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorPage.xaml.cs index e6efa2a4..b9bc7474 100644 --- a/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorPage.xaml.cs +++ b/Bloxstrap/UI/Elements/Settings/Pages/FastFlagEditorPage.xaml.cs @@ -137,7 +137,7 @@ private void AddSingle(string name, string value) } else { - Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information); + Frontend.ShowMessageBox(Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information); bool refresh = false; @@ -175,7 +175,14 @@ private void ImportJSON(string json) json = '{' + json; if (!json.EndsWith('}')) - json += '}'; + { + int lastIndex = json.LastIndexOf('}'); + + if (lastIndex == -1) + json += '}'; + else + json = json.Substring(0, lastIndex+1); + } try { @@ -193,7 +200,7 @@ private void ImportJSON(string json) catch (Exception ex) { Frontend.ShowMessageBox( - String.Format(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidJSON, ex.Message), + String.Format(Strings.Menu_FastFlagEditor_InvalidJSON, ex.Message), MessageBoxImage.Error ); @@ -205,7 +212,7 @@ private void ImportJSON(string json) if (list.Count > 16) { var result = Frontend.ShowMessageBox( - Bloxstrap.Resources.Strings.Menu_FastFlagEditor_LargeConfig, + Strings.Menu_FastFlagEditor_LargeConfig, MessageBoxImage.Warning, MessageBoxButton.YesNo ); @@ -222,7 +229,7 @@ private void ImportJSON(string json) int count = conflictingFlags.Count(); string message = String.Format( - Bloxstrap.Resources.Strings.Menu_FastFlagEditor_ConflictingImport, + Strings.Menu_FastFlagEditor_ConflictingImport, count, String.Join(", ", conflictingFlags.Take(25)) ); @@ -263,16 +270,16 @@ private bool ValidateFlagEntry(string name, string value) string errorMessage = ""; if (!_validPrefixes.Any(name.StartsWith)) - errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidPrefix; + errorMessage = Strings.Menu_FastFlagEditor_InvalidPrefix; else if (!name.All(x => char.IsLetterOrDigit(x) || x == '_')) - errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidCharacter; + errorMessage = Strings.Menu_FastFlagEditor_InvalidCharacter; if (name.EndsWith("_PlaceFilter") || name.EndsWith("_DataCenterFilter")) - errorMessage = !ValidateFilter(name, value) ? Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidPlaceFilter : ""; + errorMessage = !ValidateFilter(name, value) ? Strings.Menu_FastFlagEditor_InvalidPlaceFilter : ""; else if ((name.StartsWith("FInt") || name.StartsWith("DFInt")) && !Int32.TryParse(value, out _)) - errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidNumberValue; + errorMessage = Strings.Menu_FastFlagEditor_InvalidNumberValue; else if ((name.StartsWith("FFlag") || name.StartsWith("DFFlag")) && lowerValue != "true" && lowerValue != "false") - errorMessage = Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidBoolValue; + errorMessage = Strings.Menu_FastFlagEditor_InvalidBoolValue; if (!String.IsNullOrEmpty(errorMessage)) { @@ -319,7 +326,7 @@ private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventA if (App.FastFlags.GetValue(newName) is not null) { - Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information); + Frontend.ShowMessageBox(Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information); e.Cancel = true; textbox.Text = oldName; return; @@ -387,7 +394,7 @@ private void ExportJSONButton_Click(object sender, RoutedEventArgs e) { string json = JsonSerializer.Serialize(App.FastFlags.Prop, new JsonSerializerOptions { WriteIndented = true }); Clipboard.SetDataObject(json); - Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_JsonCopiedToClipboard, MessageBoxImage.Information); + Frontend.ShowMessageBox(Strings.Menu_FastFlagEditor_JsonCopiedToClipboard, MessageBoxImage.Information); } private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)