diff --git a/Bloxstrap/App.xaml b/Bloxstrap/App.xaml
index 22d731b..63d723d 100644
--- a/Bloxstrap/App.xaml
+++ b/Bloxstrap/App.xaml
@@ -36,6 +36,7 @@
+
diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs
index e5e2ae9..8680873 100644
--- a/Bloxstrap/Resources/Strings.Designer.cs
+++ b/Bloxstrap/Resources/Strings.Designer.cs
@@ -613,7 +613,9 @@ namespace Bloxstrap.Resources {
}
///
- /// Looks up a localized string similar to Paste in your JSON here....
+ /// Looks up a localized string similar to {
+ /// "FFlagDebugDisplayFPS": "True"
+ ///}.
///
public static string Dialog_BulkAddFastFlag_Paste {
get {
@@ -1803,6 +1805,15 @@ namespace Bloxstrap.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to An entry for this flag name already exists..
+ ///
+ public static string Menu_FastFlagEditor_AlreadyExists {
+ get {
+ return ResourceManager.GetString("Menu.FastFlagEditor.AlreadyExists", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Back.
///
@@ -1812,6 +1823,35 @@ namespace Bloxstrap.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Misusing this can lead to instability or unexpected things happening..
+ ///
+ public static string Menu_FastFlagEditor_BannerText {
+ get {
+ return ResourceManager.GetString("Menu.FastFlagEditor.BannerText", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Use with caution..
+ ///
+ public static string Menu_FastFlagEditor_BannerTitle {
+ get {
+ return ResourceManager.GetString("Menu.FastFlagEditor.BannerTitle", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to 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?
+ ///
+ ///.
+ ///
+ public static string Menu_FastFlagEditor_ConflictingImport {
+ get {
+ return ResourceManager.GetString("Menu.FastFlagEditor.ConflictingImport", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Delete selected.
///
@@ -1822,7 +1862,7 @@ namespace Bloxstrap.Resources {
}
///
- /// Looks up a localized string similar to Manage your own FastFlags. Use with caution. Double click a column to edit..
+ /// Looks up a localized string similar to Manage your own FastFlags. Double click a column to edit..
///
public static string Menu_FastFlagEditor_Description {
get {
@@ -1840,7 +1880,37 @@ namespace Bloxstrap.Resources {
}
///
- /// Looks up a localized string similar to Copied JSON to clipboard..
+ /// Looks up a localized string similar to The name of this flag is not valid as names can only contain letters, numbers, and underscores.
+ ///
+ public static string Menu_FastFlagEditor_InvalidCharacter {
+ get {
+ return ResourceManager.GetString("Menu.FastFlagEditor.InvalidCharacter", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The JSON you've entered does not appear to be valid. Please double check it and try again.
+ ///
+ ///More information:
+ ///{0}.
+ ///
+ public static string Menu_FastFlagEditor_InvalidJSON {
+ get {
+ return ResourceManager.GetString("Menu.FastFlagEditor.InvalidJSON", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to The name of this flag is not valid as names must start with FFlag, DFInt, etc.
+ ///
+ public static string Menu_FastFlagEditor_InvalidPrefix {
+ get {
+ return ResourceManager.GetString("Menu.FastFlagEditor.InvalidPrefix", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Copied to clipboard..
///
public static string Menu_FastFlagEditor_JsonCopiedToClipboard {
get {
@@ -1848,6 +1918,17 @@ namespace Bloxstrap.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to You appear to be importing a very large configuration. You should only be importing configurations that you fully understand. Do NOT blindly paste in configurations made by other people. If you continue, you will very likely end up with stability issues and encounter unexpected changes.
+ ///
+ ///Are you sure you want to continue?.
+ ///
+ public static string Menu_FastFlagEditor_LargeConfig {
+ get {
+ return ResourceManager.GetString("Menu.FastFlagEditor.LargeConfig", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Search.
///
diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx
index e5da224..98c90fe 100644
--- a/Bloxstrap/Resources/Strings.resx
+++ b/Bloxstrap/Resources/Strings.resx
@@ -306,7 +306,9 @@ Your ReShade configuration files will still be saved, and you can locate them by
Add FastFlag
- Paste in your JSON here...
+ {
+ "FFlagDebugDisplayFPS": "True"
+}More information:
@@ -704,20 +706,51 @@ Would you like to upgrade your currently installed version?
Add new
+
+ An entry for this flag name already exists.
+
Back
+
+ Misusing this can lead to instability or unexpected things happening.
+
+
+ Use with caution.
+
+
+ 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?
+
+
+
Delete selected
- Manage your own FastFlags. Use with caution. Double click a column to edit.
+ Manage your own FastFlags. Double click a column to edit.Export JSON
+
+ The name of this flag is not valid as names can only contain letters, numbers, and underscores
+
+
+ The JSON you've entered does not appear to be valid. Please double check it and try again.
+
+More information:
+{0}
+
+
+ The name of this flag is not valid as names must start with FFlag, DFInt, etc
+
- Copied JSON to clipboard.
+ Copied to clipboard.
+
+
+ You appear to be importing a very large configuration. You should only be importing configurations that you fully understand. Do NOT blindly paste in configurations made by other people. If you continue, you will very likely end up with stability issues and encounter unexpected changes.
+
+Are you sure you want to continue?Search
diff --git a/Bloxstrap/UI/Converters/RangeConverter.cs b/Bloxstrap/UI/Converters/RangeConverter.cs
new file mode 100644
index 0000000..64f382a
--- /dev/null
+++ b/Bloxstrap/UI/Converters/RangeConverter.cs
@@ -0,0 +1,29 @@
+using System.Windows.Data;
+
+namespace Bloxstrap.UI.Converters
+{
+ internal class RangeConverter : IValueConverter
+ {
+ public int? From { get; set; }
+
+ public int? To { get; set; }
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ int numvalue = (int)value;
+
+ if (From is null)
+ return numvalue < To;
+
+ if (To is null)
+ return numvalue > From;
+
+ return numvalue > From && numvalue < To;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
index 0e153b9..e7f2a0f 100644
--- a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
+++ b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
@@ -6,6 +6,7 @@
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs"
xmlns:resources="clr-namespace:Bloxstrap.Resources"
+ xmlns:converters="clr-namespace:Bloxstrap.UI.Converters"
mc:Ignorable="d"
Title="{x:Static resources:Strings.Dialog_AddFastFlag_Title}"
MinHeight="0"
@@ -15,6 +16,10 @@
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowStartupLocation="CenterScreen">
+
+
+
+
@@ -24,22 +29,43 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -47,10 +73,22 @@
diff --git a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs
index efff5e4..42a850c 100644
--- a/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs
+++ b/Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs
@@ -15,7 +15,7 @@ using System.Windows.Shapes;
namespace Bloxstrap.UI.Elements.Dialogs
{
///
- /// Interaction logic for AddFlagDialog.xaml
+ /// Interaction logic for AddFastFlagDialog.xaml
///
public partial class AddFastFlagDialog
{
diff --git a/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml
deleted file mode 100644
index 55ae515..0000000
--- a/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml.cs b/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml.cs
deleted file mode 100644
index eccf4fe..0000000
--- a/Bloxstrap/UI/Elements/Dialogs/BulkAddFastFlagDialog.xaml.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-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 b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml
index 44f1f63..fc92dde 100644
--- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml
+++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml
@@ -18,10 +18,12 @@
-
+
-
+
+
+
@@ -35,11 +37,7 @@
-
-
-
-
-
+
diff --git a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
index fb1caa4..751a79e 100644
--- a/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
+++ b/Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
@@ -1,14 +1,11 @@
-using System.Collections.ObjectModel;
-using System.Windows;
+using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
-
-using Microsoft.Win32;
+using System.Collections.ObjectModel;
using Wpf.Ui.Mvvm.Contracts;
using Bloxstrap.UI.Elements.Dialogs;
-using System.Xml.Linq;
namespace Bloxstrap.UI.Elements.Menu.Pages
{
@@ -21,6 +18,11 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
// using a datagrid is a codebehind thing only and thats it theres literally no way around it
private readonly ObservableCollection _fastFlagList = new();
+ private readonly List _validPrefixes = new()
+ {
+ "FFlag", "DFFlag", "SFFlag", "FInt", "DFInt", "FString", "DFString", "FLog", "DFlog"
+ };
+
private bool _showPresets = false;
private string _searchFilter = "";
@@ -85,6 +87,165 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
ReloadList();
}
+ private void ShowAddDialog()
+ {
+ var dialog = new AddFastFlagDialog();
+ dialog.ShowDialog();
+
+ if (dialog.Result != MessageBoxResult.OK)
+ return;
+
+ if (dialog.Tabs.SelectedIndex == 0)
+ AddEntry(dialog.FlagNameTextBox.Text, dialog.FlagValueTextBox.Text);
+ else if (dialog.Tabs.SelectedIndex == 1)
+ ImportJSON(dialog.JsonTextBox.Text);
+ }
+
+ private void AddEntry(string name, string value)
+ {
+ FastFlag? entry;
+
+ if (App.FastFlags.GetValue(name) is null)
+ {
+ if (!_validPrefixes.Where(x => name.StartsWith(x)).Any())
+ {
+ Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidPrefix, MessageBoxImage.Error);
+ ShowAddDialog();
+ return;
+ }
+
+ if (!name.All(x => char.IsLetterOrDigit(x) || x == '_'))
+ {
+ Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidCharacter, MessageBoxImage.Error);
+ ShowAddDialog();
+ return;
+ }
+
+ entry = new FastFlag
+ {
+ // Enabled = true,
+ Name = name,
+ Value = value
+ };
+
+ if (!name.Contains(_searchFilter))
+ ClearSearch();
+
+ _fastFlagList.Add(entry);
+
+ App.FastFlags.SetValue(entry.Name, entry.Value);
+ }
+ else
+ {
+ Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information);
+
+ bool refresh = false;
+
+ if (!_showPresets && FastFlagManager.PresetFlags.Values.Contains(name))
+ {
+ TogglePresetsButton.IsChecked = true;
+ _showPresets = true;
+ refresh = true;
+ }
+
+ if (!name.Contains(_searchFilter))
+ {
+ ClearSearch(false);
+ refresh = true;
+ }
+
+ if (refresh)
+ ReloadList();
+
+ entry = _fastFlagList.Where(x => x.Name == name).FirstOrDefault();
+ }
+
+ DataGrid.SelectedItem = entry;
+ DataGrid.ScrollIntoView(entry);
+ }
+
+ private void ImportJSON(string json)
+ {
+ Dictionary? list = null;
+
+ json = json.Trim();
+
+ // autocorrect where possible
+ if (!json.StartsWith('{'))
+ json = '{' + json;
+
+ if (!json.EndsWith('}'))
+ json += '}';
+
+ try
+ {
+ var options = new JsonSerializerOptions
+ {
+ ReadCommentHandling = JsonCommentHandling.Skip,
+ AllowTrailingCommas = true
+ };
+
+ list = JsonSerializer.Deserialize>(json, options);
+
+ if (list is null)
+ throw new Exception("JSON deserialization returned null");
+ }
+ catch (Exception ex)
+ {
+ Frontend.ShowMessageBox(
+ String.Format(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_InvalidJSON, ex.Message),
+ MessageBoxImage.Error
+ );
+
+ ShowAddDialog();
+
+ return;
+ }
+
+ if (list.Count > 16)
+ {
+ var result = Frontend.ShowMessageBox(
+ Bloxstrap.Resources.Strings.Menu_FastFlagEditor_LargeConfig,
+ MessageBoxImage.Warning,
+ MessageBoxButton.YesNo
+ );
+
+ if (result != MessageBoxResult.Yes)
+ return;
+ }
+
+ var conflictingFlags = App.FastFlags.Prop.Where(x => list.ContainsKey(x.Key)).Select(x => x.Key);
+ bool overwriteConflicting = false;
+
+ if (conflictingFlags.Any())
+ {
+ int count = conflictingFlags.Count();
+
+ string message = String.Format(
+ Bloxstrap.Resources.Strings.Menu_FastFlagEditor_ConflictingImport,
+ count,
+ String.Join(", ", conflictingFlags.Take(25))
+ );
+
+ if (count > 25)
+ message += "...";
+
+ var result = Frontend.ShowMessageBox(message, 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();
+ }
+
// refresh list on page load to synchronize with preset page
private void Page_Loaded(object sender, RoutedEventArgs e) => ReloadList();
@@ -122,7 +283,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
if (App.FastFlags.GetValue(newName) is not null)
{
- Frontend.ShowMessageBox("A FastFlag with this name already exists.", MessageBoxImage.Information);
+ Frontend.ShowMessageBox(Bloxstrap.Resources.Strings.Menu_FastFlagEditor_AlreadyExists, MessageBoxImage.Information);
e.Cancel = true;
textbox.Text = oldName;
return;
@@ -153,62 +314,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
window.Navigate(typeof(FastFlagsPage));
}
- private void AddButton_Click(object sender, RoutedEventArgs e)
- {
- var dialog = new AddFastFlagDialog();
- dialog.ShowDialog();
-
- if (dialog.Result != MessageBoxResult.OK)
- return;
-
- string name = dialog.FlagNameTextBox.Text;
-
- FastFlag? entry;
-
- if (App.FastFlags.GetValue(name) is null)
- {
- entry = new FastFlag
- {
- // Enabled = true,
- Name = dialog.FlagNameTextBox.Text,
- Value = dialog.FlagValueTextBox.Text
- };
-
- if (!name.Contains(_searchFilter))
- ClearSearch();
-
- _fastFlagList.Add(entry);
-
- App.FastFlags.SetValue(entry.Name, entry.Value);
- }
- else
- {
- Frontend.ShowMessageBox("An entry for this FastFlag already exists.", MessageBoxImage.Information);
-
- bool refresh = false;
-
- if (!_showPresets && FastFlagManager.PresetFlags.Values.Contains(name))
- {
- TogglePresetsButton.IsChecked = true;
- _showPresets = true;
- refresh = true;
- }
-
- if (!name.Contains(_searchFilter))
- {
- ClearSearch(false);
- refresh = true;
- }
-
- if (refresh)
- ReloadList();
-
- entry = _fastFlagList.Where(x => x.Name == name).FirstOrDefault();
- }
-
- DataGrid.SelectedItem = entry;
- DataGrid.ScrollIntoView(entry);
- }
+ private void AddButton_Click(object sender, RoutedEventArgs e) => ShowAddDialog();
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
@@ -233,79 +339,6 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
ReloadList();
}
- private void ImportJSONButton_Click(object sender, RoutedEventArgs e)
- {
- string json = "";
- Dictionary? list = null;
-
- while (list is null)
- {
- var dialog = new BulkAddFastFlagDialog();
- dialog.JsonTextBox.Text = json;
- dialog.ShowDialog();
-
- if (dialog.Result != MessageBoxResult.OK)
- return;
-
- json = dialog.JsonTextBox.Text.Trim();
-
- // autocorrect where possible
- if (!json.StartsWith('{'))
- json = '{' + json;
-
- if (!json.EndsWith('}'))
- json += '}';
-
- try
- {
- list = JsonSerializer.Deserialize>(json);
-
- if (list is null)
- throw new Exception("JSON deserialization returned null");
- }
- catch (Exception ex)
- {
- Frontend.ShowMessageBox(
- "The JSON you've entered does not appear to be valid. Please double check it and try again.\n" +
- "\n" +
- "More information:\n" +
- $"{ex.Message}",
- MessageBoxImage.Error
- );
- }
- }
-
- var conflictingFlags = App.FastFlags.Prop.Where(x => list.ContainsKey(x.Key)).Select(x => x.Key);
- bool overwriteConflicting = false;
-
- if (conflictingFlags.Any())
- {
- int count = conflictingFlags.Count();
-
- string message = "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" +
- $"There are {count} conflicting flag definitions:\n" +
- String.Join(", ", conflictingFlags.Take(25));
-
- if (count > 25)
- message += "...";
-
- var result = Frontend.ShowMessageBox(message, 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 ExportJSONButton_Click(object sender, RoutedEventArgs e)
{
string json = JsonSerializer.Serialize(App.FastFlags.Prop, new JsonSerializerOptions { WriteIndented = true });