diff --git a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
index 06e7cc0..3a47528 100644
--- a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
+++ b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
@@ -33,10 +33,10 @@
-
+
-
+
diff --git a/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml
new file mode 100644
index 0000000..4cef49f
--- /dev/null
+++ b/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Paste in your JSON here...
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml.cs b/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml.cs
new file mode 100644
index 0000000..eccf4fe
--- /dev/null
+++ b/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace Bloxstrap.UI.Elements.Dialogs
+{
+ ///
+ /// Interaction logic for BulkAddFastFlagDialog.xaml
+ ///
+ public partial class BulkAddFastFlagDialog
+ {
+ public MessageBoxResult Result = MessageBoxResult.Cancel;
+
+ public BulkAddFastFlagDialog()
+ {
+ InitializeComponent();
+ }
+
+ private void OKButton_Click(object sender, RoutedEventArgs e)
+ {
+ Result = MessageBoxResult.OK;
+ Close();
+ }
+ }
+}
diff --git a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
index fec43ed..8b88fdf 100644
--- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
+++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
@@ -215,58 +215,65 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
private void ImportJSONButton_Click(object sender, RoutedEventArgs e)
{
- var dialog = new OpenFileDialog
- {
- Filter = "JSON files|*.json|All files|*.*"
- };
+ string json = "";
+ Dictionary? list = null;
- if (dialog.ShowDialog() != true)
- return;
+ while (list is null)
+ {
+ var dialog = new BulkAddFastFlagDialog();
+ dialog.JsonTextBox.Text = json;
+ dialog.ShowDialog();
- try
- {
- var list = JsonSerializer.Deserialize>(File.ReadAllText(dialog.FileName));
+ if (dialog.Result != MessageBoxResult.OK)
+ return;
- if (list is null)
- throw new Exception("JSON deserialization returned null");
+ json = dialog.JsonTextBox.Text;
- var conflictingFlags = App.FastFlags.Prop.Where(x => list.ContainsKey(x.Key)).Select(x => x.Key);
- bool overwriteConflicting = false;
-
- if (conflictingFlags.Any())
+ try
{
- var result = Controls.ShowMessageBox(
- "Some of the flags you are attempting to import already have set values. Would you like to overwrite their current values with the ones defined in the import?\n" +
+ list = JsonSerializer.Deserialize>(json);
+
+ if (list is null)
+ throw new Exception("JSON deserialization returned null");
+ }
+ catch (Exception ex)
+ {
+ Controls.ShowMessageBox(
+ "The JSON you've entered does not appear to be valid. Please double check it and try again.\n" +
"\n" +
- "Conflicting flags:\n" +
- String.Join(", ", conflictingFlags),
- MessageBoxImage.Question,
- MessageBoxButton.YesNo
+ "More information:\n" +
+ $"{ex.Message}",
+ MessageBoxImage.Error
);
-
- overwriteConflicting = result == MessageBoxResult.Yes;
}
-
- foreach (var pair in list)
- {
- if (App.FastFlags.Prop.ContainsKey(pair.Key) && !overwriteConflicting)
- continue;
-
- App.FastFlags.SetValue(pair.Key, pair.Value);
- }
-
- ClearSearch();
}
- catch (Exception ex)
+
+ var conflictingFlags = App.FastFlags.Prop.Where(x => list.ContainsKey(x.Key)).Select(x => x.Key);
+ bool overwriteConflicting = false;
+
+ if (conflictingFlags.Any())
{
- Controls.ShowMessageBox(
- "The file you've selected does not appear to be valid JSON. Please double check the file contents and try again.\n" +
- "\n" +
- "More information:\n" +
- $"{ex.Message}",
- MessageBoxImage.Error
+ var result = Controls.ShowMessageBox(
+ "Some of the flags you are attempting to import already have set values. Would you like to overwrite their current values with the ones defined in the import?\n" +
+ "\n" +
+ "Conflicting flags:\n" +
+ String.Join(", ", conflictingFlags),
+ MessageBoxImage.Question,
+ MessageBoxButton.YesNo
);
+
+ overwriteConflicting = result == MessageBoxResult.Yes;
}
+
+ foreach (var pair in list)
+ {
+ if (App.FastFlags.Prop.ContainsKey(pair.Key) && !overwriteConflicting)
+ continue;
+
+ App.FastFlags.SetValue(pair.Key, pair.Value);
+ }
+
+ ClearSearch();
}
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)