mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-18 16:41:36 -07:00
Graphical FastFlag editor - initial prototype
This commit is contained in:
parent
049b340823
commit
cc39ee6e8a
15
Bloxstrap/Models/FastFlag.cs
Normal file
15
Bloxstrap/Models/FastFlag.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bloxstrap.Models
|
||||
{
|
||||
public class FastFlag
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public string Name { get; set; } = null!;
|
||||
public string Value { get; set; } = null!;
|
||||
}
|
||||
}
|
60
Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
Normal file
60
Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml
Normal file
@ -0,0 +1,60 @@
|
||||
<ui:UiWindow x:Class="Bloxstrap.UI.Elements.Dialogs.AddFastFlagDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Dialogs"
|
||||
mc:Ignorable="d"
|
||||
Title="Add FastFlag"
|
||||
MinHeight="0"
|
||||
Width="480"
|
||||
SizeToContent="Height"
|
||||
ResizeMode="NoResize"
|
||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ui:TitleBar Grid.Row="0" Grid.ColumnSpan="2" Padding="8" Title="Add FastFlag" ShowMinimize="False" ShowMaximize="False" CanMaximize="False" KeyboardNavigation.TabNavigation="None" />
|
||||
|
||||
<Grid Grid.Row="1" Margin="15">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" MinWidth="100" Text="Flag name" Margin="0,0,0,12" />
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Name="FlagNameTextBox" Margin="0,0,0,12" />
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" MinWidth="100" Text="Flag value" />
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Name="FlagValueTextBox" />
|
||||
</Grid>
|
||||
|
||||
<Border Grid.Row="2" Margin="0,10,0,0" Padding="15" Background="{ui:ThemeResource SolidBackgroundFillColorSecondaryBrush}">
|
||||
<StackPanel Orientation="Horizontal" FlowDirection="LeftToRight" HorizontalAlignment="Right">
|
||||
<Button MinWidth="100" Content="OK" Click="OKButton_Click">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=FlagNameTextBox, Path=Text.Length}" Value="0">
|
||||
<Setter Property="IsEnabled" Value="False" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
<Button MinWidth="100" Margin="12,0,0,0" Content="Cancel" IsCancel="True" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ui:UiWindow>
|
35
Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs
Normal file
35
Bloxstrap/UI/Elements/Dialogs/AddFastFlagDialog.xaml.cs
Normal file
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AddFlagDialog.xaml
|
||||
/// </summary>
|
||||
public partial class AddFastFlagDialog
|
||||
{
|
||||
public MessageBoxResult Result = MessageBoxResult.Cancel;
|
||||
|
||||
public AddFastFlagDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OKButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Result = MessageBoxResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -45,6 +45,7 @@
|
||||
<ui:NavigationItem Content="About" PageType="{x:Type pages:AboutPage}" Icon="QuestionCircle48" Tag="about" />
|
||||
|
||||
<ui:NavigationItem Content="Before you install..." PageType="{x:Type pages:PreInstallPage}" Tag="preinstall" Visibility="Collapsed" />
|
||||
<ui:NavigationItem Content="FastFlag Editor" PageType="{x:Type pages:FastFlagEditorPage}" Tag="fastflageditor" />
|
||||
</ui:NavigationFluent.Items>
|
||||
</ui:NavigationFluent>
|
||||
|
||||
|
44
Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml
Normal file
44
Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml
Normal file
@ -0,0 +1,44 @@
|
||||
<ui:UiPage x:Class="Bloxstrap.UI.Elements.Menu.Pages.FastFlagEditorPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Menu.Pages"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Title="FastFlagEditorPage"
|
||||
Loaded="Page_Loaded">
|
||||
<Grid Margin="0,0,14,14">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Margin="0,0,0,16" Text="Manage your own FastFlags. Press the delete key to delete a selected entry." FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
||||
|
||||
<DataGrid Name="DataGrid" Grid.Row="1" Style="{x:Null}" HeadersVisibility="Column" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CellEditEnding="DataGrid_CellEditEnding">
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Header="Enabled" Binding="{Binding Enabled}" />
|
||||
<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True" />
|
||||
<DataGridTextColumn Header="Value" Binding="{Binding Value}" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<StackPanel Grid.Row="2" Margin="0,16,0,0" Orientation="Horizontal">
|
||||
<ui:Button Icon="Add28" Content="Add new" Click="AddButton_Click" />
|
||||
<ui:Button Icon="Delete48" Content="Delete selected" Click="DeleteButton_Click" Appearance="Danger" Margin="12,0,0,0">
|
||||
<ui:Button.Style>
|
||||
<Style TargetType="ui:Button" BasedOn="{StaticResource {x:Type ui:Button}}">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=DataGrid, Path=SelectedItems.Count}" Value="0">
|
||||
<Setter Property="IsEnabled" Value="False" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ui:Button.Style>
|
||||
</ui:Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:UiPage>
|
142
Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
Normal file
142
Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
Normal file
@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
using Bloxstrap.UI.Elements.Dialogs;
|
||||
|
||||
namespace Bloxstrap.UI.Elements.Menu.Pages
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FastFlagEditorPage.xaml
|
||||
/// </summary>
|
||||
public partial class FastFlagEditorPage
|
||||
{
|
||||
// believe me when i say there is absolutely zero point to using mvvm for this
|
||||
// using a datagrid is a codebehind thing only and thats it theres literally no way around it
|
||||
|
||||
private readonly ObservableCollection<FastFlag> _fastFlagList = new();
|
||||
|
||||
public FastFlagEditorPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_fastFlagList.Clear();
|
||||
|
||||
foreach (string flagName in App.FastFlags.Prop.Keys)
|
||||
{
|
||||
string? flagValue = App.FastFlags.GetValue(flagName);
|
||||
|
||||
if (flagValue is null)
|
||||
continue;
|
||||
|
||||
var entry = new FastFlag
|
||||
{
|
||||
Enabled = true,
|
||||
Name = flagName,
|
||||
Value = flagValue
|
||||
};
|
||||
|
||||
if (entry.Name.StartsWith("Disable"))
|
||||
{
|
||||
entry.Enabled = false;
|
||||
entry.Name = entry.Name[7..];
|
||||
}
|
||||
|
||||
_fastFlagList.Add(entry);
|
||||
}
|
||||
|
||||
DataGrid.ItemsSource = _fastFlagList;
|
||||
}
|
||||
|
||||
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
||||
{
|
||||
int index = e.Row.GetIndex();
|
||||
FastFlag entry = _fastFlagList[index];
|
||||
|
||||
switch (e.Column.Header)
|
||||
{
|
||||
case "Enabled":
|
||||
bool enabled = (bool)((CheckBox)e.EditingElement).IsChecked!;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
App.FastFlags.SetValue(entry.Name, entry.Value);
|
||||
App.FastFlags.SetValue($"Disable{entry.Name}", null);
|
||||
}
|
||||
else
|
||||
{
|
||||
App.FastFlags.SetValue(entry.Name, null);
|
||||
App.FastFlags.SetValue($"Disable{entry.Name}", entry.Value);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "Name":
|
||||
string newName = ((TextBox)e.EditingElement).Text;
|
||||
|
||||
App.FastFlags.SetValue(entry.Name, null);
|
||||
App.FastFlags.SetValue(newName, entry.Value);
|
||||
|
||||
break;
|
||||
|
||||
case "Value":
|
||||
string newValue = ((TextBox)e.EditingElement).Text;
|
||||
|
||||
App.FastFlags.SetValue(entry.Name, newValue);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new AddFastFlagDialog();
|
||||
dialog.ShowDialog();
|
||||
|
||||
if (dialog.Result != MessageBoxResult.OK)
|
||||
return;
|
||||
|
||||
var entry = new FastFlag
|
||||
{
|
||||
Enabled = true,
|
||||
Name = dialog.FlagNameTextBox.Text,
|
||||
Value = dialog.FlagValueTextBox.Text
|
||||
};
|
||||
|
||||
_fastFlagList.Add(entry);
|
||||
|
||||
App.FastFlags.SetValue(entry.Name, entry.Value);
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var tempList = new List<FastFlag>();
|
||||
|
||||
foreach (FastFlag entry in DataGrid.SelectedItems)
|
||||
tempList.Add(entry);
|
||||
|
||||
foreach (FastFlag entry in tempList)
|
||||
{
|
||||
_fastFlagList.Remove(entry);
|
||||
App.FastFlags.SetValue(entry.Name, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,8 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="1000" d:DesignWidth="800"
|
||||
Title="FastFlagsPage"
|
||||
Scrollable="True">
|
||||
Scrollable="True"
|
||||
Loaded="Page_Loaded">
|
||||
<StackPanel Margin="0,0,14,14">
|
||||
<TextBlock Margin="0,0,0,16" Text="Control how specific Roblox engine parameters and features are configured." FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Windows.Input;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
using Bloxstrap.UI.ViewModels.Menu;
|
||||
|
||||
@ -11,10 +12,14 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
||||
{
|
||||
public FastFlagsPage()
|
||||
{
|
||||
DataContext = new FastFlagsViewModel();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DataContext = new FastFlagsViewModel();
|
||||
}
|
||||
|
||||
private void ValidateInt32(object sender, TextCompositionEventArgs e) => e.Handled = !Int32.TryParse(e.Text, out int _);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user