From 25866849c019f22545303b92d07cb4251f65dcdd Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Tue, 2 Jul 2024 15:01:22 +0400 Subject: [PATCH] Add ability to import flag JSON from file (#1092) --- Bloxstrap/Resources/Strings.Designer.cs | 24 ++++++++++++++--- Bloxstrap/Resources/Strings.resx | 12 ++++++--- .../Elements/Dialogs/AddFastFlagDialog.xaml | 9 +++++-- .../Dialogs/AddFastFlagDialog.xaml.cs | 27 ++++++++++--------- .../UI/Elements/Menu/Pages/AboutPage.xaml | 1 + 5 files changed, 53 insertions(+), 20 deletions(-) diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 34f202a..5be51b7 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -368,6 +368,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Import from file. + /// + public static string Common_ImportFromFile { + get { + return ResourceManager.GetString("Common.ImportFromFile", resourceCulture); + } + } + /// /// Looks up a localized string similar to Import JSON. /// @@ -595,7 +604,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Add FastFlag. + /// Looks up a localized string similar to Add Fast Flag. /// public static string Dialog_AddFastFlag_Title { get { @@ -1242,6 +1251,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to JSON files. + /// + public static string FileTypes_JSONFiles { + get { + return ResourceManager.GetString("FileTypes.JSONFiles", resourceCulture); + } + } + /// /// Looks up a localized string similar to Bloxstrap has detected a drive letter change and has reconfigured its install location from the {0} drive to the {1} drive. /// @@ -1807,7 +1825,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to Manage your own FastFlags. Double click a column to edit.. + /// Looks up a localized string similar to Manage your own Fast Flags. Double click a column to edit.. /// public static string Menu_FastFlagEditor_Description { get { @@ -2783,7 +2801,7 @@ namespace Bloxstrap.Resources { } /// - /// Looks up a localized string similar to After installation has finished, the Bloxstrap Menu will be registered as an application in the Start menu. If you ever need to access it again to re-adjust your settings, or access resources such as FastFlag management, you can find it there.. + /// Looks up a localized string similar to After installation has finished, the Bloxstrap Menu will be registered as an application in the Start menu. If you ever need to access it again to re-adjust your settings, or access resources such as Fast Flag management, you can find it there.. /// public static string Menu_PreInstall_Info_1 { get { diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index 6f42350..b930fba 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -301,7 +301,7 @@ Click for more information Type - Add FastFlag + Add Fast Flag More information: @@ -667,7 +667,7 @@ There are {0} conflicting flag definitions: Delete selected - Manage your own FastFlags. Double click a column to edit. + Manage your own Fast Flags. Double click a column to edit. Export JSON @@ -965,7 +965,7 @@ Selecting 'No' will ignore this warning and continue installation. There's just a few things you first should know about. - After installation has finished, the Bloxstrap Menu will be registered as an application in the Start menu. If you ever need to access it again to re-adjust your settings, or access resources such as FastFlag management, you can find it there. + After installation has finished, the Bloxstrap Menu will be registered as an application in the Start menu. If you ever need to access it again to re-adjust your settings, or access resources such as Fast Flag management, you can find it there. If you ever need help or guidance with anything, be sure to check the [Wiki]({0}). If you still need something, open an [issue]({1}) on GitHub, or join our [Discord server]({2}). @@ -1066,4 +1066,10 @@ Selecting 'No' will ignore this warning and continue installation. Roblox cannot be downloaded at this time. Please read the following help page for more information: {0} + + Import from file + + + JSON files + \ No newline at end of file diff --git a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml index 9a1a215..669dc7c 100644 --- a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml +++ b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml @@ -50,8 +50,12 @@ - - + + + + + + + diff --git a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs index 42a850c..e2f3348 100644 --- a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs +++ b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs @@ -1,16 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Win32; 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; +using Bloxstrap.Resources; namespace Bloxstrap.UI.Elements.Dialogs { @@ -26,6 +16,19 @@ namespace Bloxstrap.UI.Elements.Dialogs InitializeComponent(); } + private void ImportButton_Click(object sender, RoutedEventArgs e) + { + var dialog = new OpenFileDialog + { + Filter = $"{Strings.FileTypes_JSONFiles}|*.json" + }; + + if (dialog.ShowDialog() != true) + return; + + JsonTextBox.Text = File.ReadAllText(dialog.FileName); + } + private void OKButton_Click(object sender, RoutedEventArgs e) { Result = MessageBoxResult.OK; diff --git a/Bloxstrap/UI/Elements/Menu/Pages/AboutPage.xaml b/Bloxstrap/UI/Elements/Menu/Pages/AboutPage.xaml index 7696731..bd3ce0b 100644 --- a/Bloxstrap/UI/Elements/Menu/Pages/AboutPage.xaml +++ b/Bloxstrap/UI/Elements/Menu/Pages/AboutPage.xaml @@ -580,6 +580,7 @@ +