Write all FastFlag values strictly as strings

this is how roblox does it, and it just makes things easier
This commit is contained in:
pizzaboxer 2023-04-11 23:54:03 +02:00
parent a95ce870db
commit 7a305c6bd2
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
3 changed files with 45 additions and 32 deletions

View File

@ -23,10 +23,23 @@ namespace Bloxstrap.Helpers
{ "Vulkan", "FFlagDebugGraphicsPreferVulkan" } { "Vulkan", "FFlagDebugGraphicsPreferVulkan" }
}; };
// all fflags are stored as strings
// to delete a flag, set the value as null
public void SetValue(string key, object? value)
{
if (value == null)
{
Changes[key] = null;
App.Logger.WriteLine($"[FastFlagManager::SetValue] Deletion of '{key}' is pending");
}
else
{
Changes[key] = value.ToString();
App.Logger.WriteLine($"[FastFlagManager::SetValue] Value change for '{key}' to '{value}' is pending");
}
}
// this returns null if the fflag doesn't exist // this returns null if the fflag doesn't exist
// this also returns as a string because deserializing an object doesn't
// deserialize back into the original object type, it instead deserializes
// as a "JsonElement" which is annoying
public string? GetValue(string key) public string? GetValue(string key)
{ {
// check if we have an updated change for it pushed first // check if we have an updated change for it pushed first
@ -44,11 +57,11 @@ namespace Bloxstrap.Helpers
foreach (var mode in RenderingModes) foreach (var mode in RenderingModes)
{ {
if (mode.Key != "Automatic") if (mode.Key != "Automatic")
App.FastFlags.Changes[mode.Value] = null; SetValue(mode.Value, null);
} }
if (value != "Automatic") if (value != "Automatic")
App.FastFlags.Changes[RenderingModes[value]] = true; SetValue(RenderingModes[value], "True");
} }
public override void Save() public override void Save()
@ -73,7 +86,7 @@ namespace Bloxstrap.Helpers
continue; continue;
} }
App.Logger.WriteLine($"[FastFlagManager::Save] Setting '{change.Key}' to {change.Value}"); App.Logger.WriteLine($"[FastFlagManager::Save] Setting '{change.Key}' to '{change.Value}'");
Prop[change.Key] = change.Value; Prop[change.Key] = change.Value;
} }

View File

@ -39,22 +39,6 @@ namespace Bloxstrap.ViewModels
public IReadOnlyDictionary<string, string> RenderingModes => FastFlagManager.RenderingModes; public IReadOnlyDictionary<string, string> RenderingModes => FastFlagManager.RenderingModes;
// this flag has to be set to false to work, weirdly enough
public bool ExclusiveFullscreenEnabled
{
get => App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") == "False";
set
{
App.FastFlags.Changes["FFlagHandleAltEnterFullscreenManually"] = value ? false : null;
if (value)
{
App.FastFlags.SetRenderingMode("Direct3D 11");
OnPropertyChanged(nameof(SelectedRenderingMode));
}
}
}
public string SelectedRenderingMode public string SelectedRenderingMode
{ {
get get
@ -71,6 +55,22 @@ namespace Bloxstrap.ViewModels
set => App.FastFlags.SetRenderingMode(value); set => App.FastFlags.SetRenderingMode(value);
} }
// this flag has to be set to false to work, weirdly enough
public bool ExclusiveFullscreenEnabled
{
get => App.FastFlags.GetValue("FFlagHandleAltEnterFullscreenManually") == "False";
set
{
App.FastFlags.Changes["FFlagHandleAltEnterFullscreenManually"] = value ? false : null;
if (value)
{
App.FastFlags.SetRenderingMode("Direct3D 11");
OnPropertyChanged(nameof(SelectedRenderingMode));
}
}
}
public bool DisableFullscreenOptimizationsEnabled public bool DisableFullscreenOptimizationsEnabled
{ {
get => App.Settings.Prop.DisableFullscreenOptimizations; get => App.Settings.Prop.DisableFullscreenOptimizations;

View File

@ -6,7 +6,7 @@
xmlns:models="clr-namespace:Bloxstrap.ViewModels" xmlns:models="clr-namespace:Bloxstrap.ViewModels"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DesignHeight="800" d:DesignWidth="800"
Title="ModsPage" Title="ModsPage"
Scrollable="True"> Scrollable="True">
<StackPanel Margin="0,0,14,14"> <StackPanel Margin="0,0,14,14">
@ -102,15 +102,6 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ui:CardControl Grid.Row="0" Margin="0,8,0,0" Padding="16,13,16,12"> <ui:CardControl Grid.Row="0" Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl.Header>
<StackPanel>
<TextBlock FontSize="14" Text="Use exclusive fullscreen" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Enables using Alt + Enter to enter exclusive fullscreen. Only works with Direct3D 11." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ExclusiveFullscreenEnabled, Mode=TwoWay}" />
</ui:CardControl>
<ui:CardControl Grid.Row="1" Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl.Header> <ui:CardControl.Header>
<StackPanel> <StackPanel>
<TextBlock FontSize="14" Text="Rendering mode" /> <TextBlock FontSize="14" Text="Rendering mode" />
@ -119,6 +110,15 @@
</ui:CardControl.Header> </ui:CardControl.Header>
<ComboBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" ItemsSource="{Binding RenderingModes.Keys, Mode=OneTime}" Text="{Binding SelectedRenderingMode, Mode=TwoWay}" /> <ComboBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" ItemsSource="{Binding RenderingModes.Keys, Mode=OneTime}" Text="{Binding SelectedRenderingMode, Mode=TwoWay}" />
</ui:CardControl> </ui:CardControl>
<ui:CardControl Grid.Row="1" Margin="0,8,0,0" Padding="16,13,16,12">
<ui:CardControl.Header>
<StackPanel>
<TextBlock FontSize="14" Text="Use exclusive fullscreen" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Enables using Alt + Enter to enter exclusive fullscreen. Only works with Direct3D 11." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding ExclusiveFullscreenEnabled, Mode=TwoWay}" />
</ui:CardControl>
</Grid> </Grid>
<StackPanel x:Name="MiscellaneousOptions"> <StackPanel x:Name="MiscellaneousOptions">