Remove option to enable/disable flags

:(
This commit is contained in:
pizzaboxer 2023-07-23 18:03:53 +01:00
parent 1b3049fbdb
commit 500b21d601
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
3 changed files with 25 additions and 74 deletions

View File

@ -1,15 +0,0 @@
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!;
}
}

View File

@ -18,15 +18,15 @@
<TextBlock Grid.Row="0" Margin="0,0,0,16" Text="Manage your own FastFlags. Double click the value column to edit." FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<ui:DataGrid Name="DataGrid" Grid.Row="1" HeadersVisibility="Column" GridLinesVisibility="Horizontal" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CellEditEnding="DataGrid_CellEditEnding">
<ui:DataGrid.Style>
<Style TargetType="ui:DataGrid" BasedOn="{StaticResource {x:Type ui:DataGrid}}">
<DataGrid Name="DataGrid" Grid.Row="1" HeadersVisibility="Column" GridLinesVisibility="Horizontal" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CellEditEnding="DataGrid_CellEditEnding">
<DataGrid.Style>
<Style TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
</Style>
</ui:DataGrid.Style>
</DataGrid.Style>
<ui:DataGrid.ColumnHeaderStyle>
<DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="{DynamicResource ControlFillColorTertiaryBrush}" />
<Setter Property="Height" Value="32" />
@ -34,9 +34,9 @@
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
<Setter Property="BorderThickness" Value="1" />
</Style>
</ui:DataGrid.ColumnHeaderStyle>
</DataGrid.ColumnHeaderStyle>
<ui:DataGrid.CellStyle>
<DataGrid.CellStyle>
<Style TargetType="DataGridCell">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
@ -44,6 +44,7 @@
<Setter Property="Background" Value="{DynamicResource PaletteDeepPurpleBrush}" />
</Trigger>
</Style.Triggers>
<Setter Property="Height" Value="32" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
@ -54,14 +55,13 @@
</Setter.Value>
</Setter>
</Style>
</ui:DataGrid.CellStyle>
</DataGrid.CellStyle>
<ui:DataGrid.Columns>
<DataGridCheckBoxColumn Header="Enabled" Binding="{Binding Enabled}" Width="68" />
<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True" />
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Key}" IsReadOnly="True" />
<DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="*" />
</ui:DataGrid.Columns>
</ui:DataGrid>
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Row="2" Margin="0,16,0,0" Orientation="Horizontal">
<ui:Button Icon="Add28" Content="Add new" Click="AddButton_Click" />

View File

@ -15,7 +15,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
// 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();
private readonly ObservableCollection<KeyValuePair<string, string>> _fastFlagList = new();
private bool _showPresets = false;
public FastFlagEditorPage()
@ -29,24 +29,11 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
var presetFlags = FastFlagManager.PresetFlags.Values;
foreach (var pair in App.FastFlags.Prop)
foreach (var entry in App.FastFlags.Prop)
{
if (!_showPresets && presetFlags.Contains(pair.Key))
if (!_showPresets && presetFlags.Contains(entry.Key))
continue;
var entry = new FastFlag
{
Enabled = true,
Name = pair.Key,
Value = pair.Value
};
if (entry.Name.StartsWith("Disable"))
{
entry.Enabled = false;
entry.Name = entry.Name[7..];
}
_fastFlagList.Add(entry);
}
@ -59,30 +46,14 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
int index = e.Row.GetIndex();
FastFlag entry = _fastFlagList[index];
var 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(entry.Key, null);
App.FastFlags.SetValue(newName, entry.Value);
break;
@ -90,7 +61,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
case "Value":
string newValue = ((TextBox)e.EditingElement).Text;
App.FastFlags.SetValue(entry.Name, newValue);
App.FastFlags.SetValue(entry.Key, newValue);
break;
}
@ -104,29 +75,24 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
if (dialog.Result != MessageBoxResult.OK)
return;
var entry = new FastFlag
{
Enabled = true,
Name = dialog.FlagNameTextBox.Text,
Value = dialog.FlagValueTextBox.Text
};
var entry = new KeyValuePair<string, string>(dialog.FlagNameTextBox.Text, dialog.FlagValueTextBox.Text);
_fastFlagList.Add(entry);
App.FastFlags.SetValue(entry.Name, entry.Value);
App.FastFlags.SetValue(entry.Key, entry.Value);
}
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
var tempList = new List<FastFlag>();
var tempList = new List<KeyValuePair<string, string>>();
foreach (FastFlag entry in DataGrid.SelectedItems)
foreach (KeyValuePair<string, string> entry in DataGrid.SelectedItems)
tempList.Add(entry);
foreach (FastFlag entry in tempList)
foreach (var entry in tempList)
{
_fastFlagList.Remove(entry);
App.FastFlags.SetValue(entry.Name, null);
App.FastFlags.SetValue(entry.Key, null);
}
}