Add ability to import flag JSON from file (#1092)

This commit is contained in:
pizzaboxer 2024-07-02 15:01:22 +04:00
parent 2cc2373830
commit 25866849c0
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
5 changed files with 53 additions and 20 deletions

View File

@ -368,6 +368,15 @@ namespace Bloxstrap.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Import from file.
/// </summary>
public static string Common_ImportFromFile {
get {
return ResourceManager.GetString("Common.ImportFromFile", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Import JSON. /// Looks up a localized string similar to Import JSON.
/// </summary> /// </summary>
@ -595,7 +604,7 @@ namespace Bloxstrap.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Add FastFlag. /// Looks up a localized string similar to Add Fast Flag.
/// </summary> /// </summary>
public static string Dialog_AddFastFlag_Title { public static string Dialog_AddFastFlag_Title {
get { get {
@ -1242,6 +1251,15 @@ namespace Bloxstrap.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to JSON files.
/// </summary>
public static string FileTypes_JSONFiles {
get {
return ResourceManager.GetString("FileTypes.JSONFiles", resourceCulture);
}
}
/// <summary> /// <summary>
/// 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. /// 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 {
} }
/// <summary> /// <summary>
/// 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..
/// </summary> /// </summary>
public static string Menu_FastFlagEditor_Description { public static string Menu_FastFlagEditor_Description {
get { get {
@ -2783,7 +2801,7 @@ namespace Bloxstrap.Resources {
} }
/// <summary> /// <summary>
/// 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..
/// </summary> /// </summary>
public static string Menu_PreInstall_Info_1 { public static string Menu_PreInstall_Info_1 {
get { get {

View File

@ -301,7 +301,7 @@ Click for more information</value>
<value>Type</value> <value>Type</value>
</data> </data>
<data name="Dialog.AddFastFlag.Title" xml:space="preserve"> <data name="Dialog.AddFastFlag.Title" xml:space="preserve">
<value>Add FastFlag</value> <value>Add Fast Flag</value>
</data> </data>
<data name="Dialog.Connectivity.MoreInfo" xml:space="preserve"> <data name="Dialog.Connectivity.MoreInfo" xml:space="preserve">
<value>More information:</value> <value>More information:</value>
@ -667,7 +667,7 @@ There are {0} conflicting flag definitions:
<value>Delete selected</value> <value>Delete selected</value>
</data> </data>
<data name="Menu.FastFlagEditor.Description" xml:space="preserve"> <data name="Menu.FastFlagEditor.Description" xml:space="preserve">
<value>Manage your own FastFlags. Double click a column to edit.</value> <value>Manage your own Fast Flags. Double click a column to edit.</value>
</data> </data>
<data name="Menu.FastFlagEditor.ExportJson" xml:space="preserve"> <data name="Menu.FastFlagEditor.ExportJson" xml:space="preserve">
<value>Export JSON</value> <value>Export JSON</value>
@ -965,7 +965,7 @@ Selecting 'No' will ignore this warning and continue installation.</value>
<value>There's just a few things you first should know about.</value> <value>There's just a few things you first should know about.</value>
</data> </data>
<data name="Menu.PreInstall.Info.1" xml:space="preserve"> <data name="Menu.PreInstall.Info.1" xml:space="preserve">
<value>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.</value> <value>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.</value>
</data> </data>
<data name="Menu.PreInstall.Info.2" xml:space="preserve"> <data name="Menu.PreInstall.Info.2" xml:space="preserve">
<value>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}).</value> <value>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}).</value>
@ -1066,4 +1066,10 @@ Selecting 'No' will ignore this warning and continue installation.</value>
<data name="Dialog.Connectivity.UnableToDownloadReason" xml:space="preserve"> <data name="Dialog.Connectivity.UnableToDownloadReason" xml:space="preserve">
<value>Roblox cannot be downloaded at this time. Please read the following help page for more information: {0}</value> <value>Roblox cannot be downloaded at this time. Please read the following help page for more information: {0}</value>
</data> </data>
<data name="Common.ImportFromFile" xml:space="preserve">
<value>Import from file</value>
</data>
<data name="FileTypes.JSONFiles" xml:space="preserve">
<value>JSON files</value>
</data>
</root> </root>

View File

@ -50,8 +50,12 @@
</TabItem> </TabItem>
<TabItem Header="{x:Static resources:Strings.Common_ImportJson}"> <TabItem Header="{x:Static resources:Strings.Common_ImportJson}">
<Grid Margin="11"> <Grid Margin="11">
<TextBox x:Name="JsonTextBox" Margin="5" AcceptsTab="True" AcceptsReturn="True" MinHeight="80" MaxHeight="480" /> <Grid.RowDefinitions>
<TextBlock IsHitTestVisible="False" Margin="18,14,0,0" Foreground="DarkGray" Text="{}{&#10; &quot;FFlagDebugDisplayFPS&quot;: &quot;True&quot;&#10;}"> <RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBox Grid.Row="0" x:Name="JsonTextBox" Margin="5" AcceptsTab="True" AcceptsReturn="True" MinHeight="80" MaxHeight="480" />
<TextBlock Grid.Row="0" IsHitTestVisible="False" Margin="18,14,0,0" Foreground="DarkGray" Text="{}{&#10; &quot;FFlagDebugDisplayFPS&quot;: &quot;True&quot;&#10;}">
<TextBlock.Style> <TextBlock.Style>
<Style TargetType="{x:Type TextBlock}"> <Style TargetType="{x:Type TextBlock}">
<Setter Property="Visibility" Value="Collapsed"/> <Setter Property="Visibility" Value="Collapsed"/>
@ -63,6 +67,7 @@
</Style> </Style>
</TextBlock.Style> </TextBlock.Style>
</TextBlock> </TextBlock>
<ui:Button Grid.Row="1" Margin="4" Icon="DocumentArrowUp16" Content="{x:Static resources:Strings.Common_ImportFromFile}" HorizontalAlignment="Stretch" Click="ImportButton_Click" />
</Grid> </Grid>
</TabItem> </TabItem>
</TabControl> </TabControl>

View File

@ -1,16 +1,6 @@
using System; using Microsoft.Win32;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using Bloxstrap.Resources;
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 namespace Bloxstrap.UI.Elements.Dialogs
{ {
@ -26,6 +16,19 @@ namespace Bloxstrap.UI.Elements.Dialogs
InitializeComponent(); 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) private void OKButton_Click(object sender, RoutedEventArgs e)
{ {
Result = MessageBoxResult.OK; Result = MessageBoxResult.OK;

View File

@ -580,6 +580,7 @@
<controls:MarkdownTextBlock MarkdownText="[CfwSky](https://www.roblox.com/users/129425241/profile)" /> <controls:MarkdownTextBlock MarkdownText="[CfwSky](https://www.roblox.com/users/129425241/profile)" />
<controls:MarkdownTextBlock MarkdownText="[ruubloo](https://www.roblox.com/users/158082266/profile)" /> <controls:MarkdownTextBlock MarkdownText="[ruubloo](https://www.roblox.com/users/158082266/profile)" />
<controls:MarkdownTextBlock MarkdownText="[toyoda165](https://www.roblox.com/users/923416649/profile)" /> <controls:MarkdownTextBlock MarkdownText="[toyoda165](https://www.roblox.com/users/923416649/profile)" />
<controls:MarkdownTextBlock MarkdownText="[ShadowCodeX](https://github.com/ShadowCodeX-debug)" />
</StackPanel> </StackPanel>
</controls:Expander> </controls:Expander>