Abstract preset flags

centralize where flag names are stored, and hide from editor list by default
This commit is contained in:
pizzaboxer 2023-07-23 15:45:25 +01:00
parent 44c9d490b0
commit e5d6ac0e0a
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
5 changed files with 144 additions and 140 deletions

View File

@ -1,4 +1,7 @@
namespace Bloxstrap using System.Windows.Input;
using System.Windows.Media.Animation;
namespace Bloxstrap
{ {
public class FastFlagManager : JsonManager<Dictionary<string, string>> public class FastFlagManager : JsonManager<Dictionary<string, string>>
{ {
@ -7,22 +10,57 @@
// this is the value of the 'FStringPartTexturePackTablePre2022' flag // this is the value of the 'FStringPartTexturePackTablePre2022' flag
public const string OldTexturesFlagValue = "{\"foil\":{\"ids\":[\"rbxassetid://7546645012\",\"rbxassetid://7546645118\"],\"color\":[255,255,255,255]},\"brick\":{\"ids\":[\"rbxassetid://7546650097\",\"rbxassetid://7546645118\"],\"color\":[204,201,200,232]},\"cobblestone\":{\"ids\":[\"rbxassetid://7546652947\",\"rbxassetid://7546645118\"],\"color\":[212,200,187,250]},\"concrete\":{\"ids\":[\"rbxassetid://7546653951\",\"rbxassetid://7546654144\"],\"color\":[208,208,208,255]},\"diamondplate\":{\"ids\":[\"rbxassetid://7547162198\",\"rbxassetid://7546645118\"],\"color\":[170,170,170,255]},\"fabric\":{\"ids\":[\"rbxassetid://7547101130\",\"rbxassetid://7546645118\"],\"color\":[105,104,102,244]},\"glass\":{\"ids\":[\"rbxassetid://7547304948\",\"rbxassetid://7546645118\"],\"color\":[254,254,254,7]},\"granite\":{\"ids\":[\"rbxassetid://7547164710\",\"rbxassetid://7546645118\"],\"color\":[113,113,113,255]},\"grass\":{\"ids\":[\"rbxassetid://7547169285\",\"rbxassetid://7546645118\"],\"color\":[165,165,159,255]},\"ice\":{\"ids\":[\"rbxassetid://7547171356\",\"rbxassetid://7546645118\"],\"color\":[255,255,255,255]},\"marble\":{\"ids\":[\"rbxassetid://7547177270\",\"rbxassetid://7546645118\"],\"color\":[199,199,199,255]},\"metal\":{\"ids\":[\"rbxassetid://7547288171\",\"rbxassetid://7546645118\"],\"color\":[199,199,199,255]},\"pebble\":{\"ids\":[\"rbxassetid://7547291361\",\"rbxassetid://7546645118\"],\"color\":[208,208,208,255]},\"corrodedmetal\":{\"ids\":[\"rbxassetid://7547184629\",\"rbxassetid://7546645118\"],\"color\":[159,119,95,200]},\"sand\":{\"ids\":[\"rbxassetid://7547295153\",\"rbxassetid://7546645118\"],\"color\":[220,220,220,255]},\"slate\":{\"ids\":[\"rbxassetid://7547298114\",\"rbxassetid://7547298323\"],\"color\":[193,193,193,255]},\"wood\":{\"ids\":[\"rbxassetid://7547303225\",\"rbxassetid://7547298786\"],\"color\":[227,227,227,255]},\"woodplanks\":{\"ids\":[\"rbxassetid://7547332968\",\"rbxassetid://7546645118\"],\"color\":[212,209,203,255]},\"asphalt\":{\"ids\":[\"rbxassetid://9873267379\",\"rbxassetid://9438410548\"],\"color\":[123,123,123,234]},\"basalt\":{\"ids\":[\"rbxassetid://9873270487\",\"rbxassetid://9438413638\"],\"color\":[154,154,153,238]},\"crackedlava\":{\"ids\":[\"rbxassetid://9438582231\",\"rbxassetid://9438453972\"],\"color\":[74,78,80,156]},\"glacier\":{\"ids\":[\"rbxassetid://9438851661\",\"rbxassetid://9438453972\"],\"color\":[226,229,229,243]},\"ground\":{\"ids\":[\"rbxassetid://9439044431\",\"rbxassetid://9438453972\"],\"color\":[114,114,112,240]},\"leafygrass\":{\"ids\":[\"rbxassetid://9873288083\",\"rbxassetid://9438453972\"],\"color\":[121,117,113,234]},\"limestone\":{\"ids\":[\"rbxassetid://9873289812\",\"rbxassetid://9438453972\"],\"color\":[235,234,230,250]},\"mud\":{\"ids\":[\"rbxassetid://9873319819\",\"rbxassetid://9438453972\"],\"color\":[130,130,130,252]},\"pavement\":{\"ids\":[\"rbxassetid://9873322398\",\"rbxassetid://9438453972\"],\"color\":[142,142,144,236]},\"rock\":{\"ids\":[\"rbxassetid://9873515198\",\"rbxassetid://9438453972\"],\"color\":[154,154,154,248]},\"salt\":{\"ids\":[\"rbxassetid://9439566986\",\"rbxassetid://9438453972\"],\"color\":[220,220,221,255]},\"sandstone\":{\"ids\":[\"rbxassetid://9873521380\",\"rbxassetid://9438453972\"],\"color\":[174,171,169,246]},\"snow\":{\"ids\":[\"rbxassetid://9439632387\",\"rbxassetid://9438453972\"],\"color\":[218,218,218,255]}}"; public const string OldTexturesFlagValue = "{\"foil\":{\"ids\":[\"rbxassetid://7546645012\",\"rbxassetid://7546645118\"],\"color\":[255,255,255,255]},\"brick\":{\"ids\":[\"rbxassetid://7546650097\",\"rbxassetid://7546645118\"],\"color\":[204,201,200,232]},\"cobblestone\":{\"ids\":[\"rbxassetid://7546652947\",\"rbxassetid://7546645118\"],\"color\":[212,200,187,250]},\"concrete\":{\"ids\":[\"rbxassetid://7546653951\",\"rbxassetid://7546654144\"],\"color\":[208,208,208,255]},\"diamondplate\":{\"ids\":[\"rbxassetid://7547162198\",\"rbxassetid://7546645118\"],\"color\":[170,170,170,255]},\"fabric\":{\"ids\":[\"rbxassetid://7547101130\",\"rbxassetid://7546645118\"],\"color\":[105,104,102,244]},\"glass\":{\"ids\":[\"rbxassetid://7547304948\",\"rbxassetid://7546645118\"],\"color\":[254,254,254,7]},\"granite\":{\"ids\":[\"rbxassetid://7547164710\",\"rbxassetid://7546645118\"],\"color\":[113,113,113,255]},\"grass\":{\"ids\":[\"rbxassetid://7547169285\",\"rbxassetid://7546645118\"],\"color\":[165,165,159,255]},\"ice\":{\"ids\":[\"rbxassetid://7547171356\",\"rbxassetid://7546645118\"],\"color\":[255,255,255,255]},\"marble\":{\"ids\":[\"rbxassetid://7547177270\",\"rbxassetid://7546645118\"],\"color\":[199,199,199,255]},\"metal\":{\"ids\":[\"rbxassetid://7547288171\",\"rbxassetid://7546645118\"],\"color\":[199,199,199,255]},\"pebble\":{\"ids\":[\"rbxassetid://7547291361\",\"rbxassetid://7546645118\"],\"color\":[208,208,208,255]},\"corrodedmetal\":{\"ids\":[\"rbxassetid://7547184629\",\"rbxassetid://7546645118\"],\"color\":[159,119,95,200]},\"sand\":{\"ids\":[\"rbxassetid://7547295153\",\"rbxassetid://7546645118\"],\"color\":[220,220,220,255]},\"slate\":{\"ids\":[\"rbxassetid://7547298114\",\"rbxassetid://7547298323\"],\"color\":[193,193,193,255]},\"wood\":{\"ids\":[\"rbxassetid://7547303225\",\"rbxassetid://7547298786\"],\"color\":[227,227,227,255]},\"woodplanks\":{\"ids\":[\"rbxassetid://7547332968\",\"rbxassetid://7546645118\"],\"color\":[212,209,203,255]},\"asphalt\":{\"ids\":[\"rbxassetid://9873267379\",\"rbxassetid://9438410548\"],\"color\":[123,123,123,234]},\"basalt\":{\"ids\":[\"rbxassetid://9873270487\",\"rbxassetid://9438413638\"],\"color\":[154,154,153,238]},\"crackedlava\":{\"ids\":[\"rbxassetid://9438582231\",\"rbxassetid://9438453972\"],\"color\":[74,78,80,156]},\"glacier\":{\"ids\":[\"rbxassetid://9438851661\",\"rbxassetid://9438453972\"],\"color\":[226,229,229,243]},\"ground\":{\"ids\":[\"rbxassetid://9439044431\",\"rbxassetid://9438453972\"],\"color\":[114,114,112,240]},\"leafygrass\":{\"ids\":[\"rbxassetid://9873288083\",\"rbxassetid://9438453972\"],\"color\":[121,117,113,234]},\"limestone\":{\"ids\":[\"rbxassetid://9873289812\",\"rbxassetid://9438453972\"],\"color\":[235,234,230,250]},\"mud\":{\"ids\":[\"rbxassetid://9873319819\",\"rbxassetid://9438453972\"],\"color\":[130,130,130,252]},\"pavement\":{\"ids\":[\"rbxassetid://9873322398\",\"rbxassetid://9438453972\"],\"color\":[142,142,144,236]},\"rock\":{\"ids\":[\"rbxassetid://9873515198\",\"rbxassetid://9438453972\"],\"color\":[154,154,154,248]},\"salt\":{\"ids\":[\"rbxassetid://9439566986\",\"rbxassetid://9438453972\"],\"color\":[220,220,221,255]},\"sandstone\":{\"ids\":[\"rbxassetid://9873521380\",\"rbxassetid://9438453972\"],\"color\":[174,171,169,246]},\"snow\":{\"ids\":[\"rbxassetid://9439632387\",\"rbxassetid://9438453972\"],\"color\":[218,218,218,255]}}";
public static IReadOnlyDictionary<string, string> PresetFlags = new Dictionary<string, string>
{
{ "HTTP.Log", "DFLogHttpTraceLight" },
{ "HTTP.Proxy.Enable", "DFFlagDebugEnableHttpProxy" },
{ "HTTP.Proxy.Address.1", "DFStringDebugPlayerHttpProxyUrl" },
{ "HTTP.Proxy.Address.2", "DFStringHttpCurlProxyHostAndPort" },
{ "HTTP.Proxy.Address.3", "DFStringHttpCurlProxyHostAndPortForExternalUrl" },
{ "Rendering.Framerate", "DFIntTaskSchedulerTargetFps" },
{ "Rendering.Fullscreen", "FFlagHandleAltEnterFullscreenManually" },
{ "Rendering.TexturePack", "FStringPartTexturePackTable2022" },
{ "Rendering.DPI.Disable", "DFFlagDisableDPIScale" },
{ "Rendering.DPI.Variable", "DFFlagVariableDPIScale2" },
{ "Rendering.Mode.D3D11", "FFlagDebugGraphicsPreferD3D11" },
{ "Rendering.Mode.D3D10", "FFlagDebugGraphicsPreferD3D11FL10" },
{ "Rendering.Mode.Vulkan", "FFlagDebugGraphicsPreferVulkan" },
{ "Rendering.Mode.Vulkan.Fix", "FFlagRenderVulkanFixMinimizeWindow" },
{ "Rendering.Mode.OpenGL", "FFlagDebugGraphicsPreferOpenGL" },
{ "Rendering.Lighting.Voxel", "DFFlagDebugRenderForceTechnologyVoxel" },
{ "Rendering.Lighting.ShadowMap", "FFlagDebugForceFutureIsBrightPhase2" },
{ "Rendering.Lighting.Future", "FFlagDebugForceFutureIsBrightPhase3" },
{ "UI.Hide", "DFIntCanHideGuiGroupId" },
{ "UI.FlagState", "FStringDebugShowFlagState" },
{ "UI.Menu.GraphicsSlider", "FFlagFixGraphicsQuality" },
{ "UI.Menu.Style.DisableV2", "FFlagDisableNewIGMinDUA" },
{ "UI.Menu.Style.EnableV4", "FFlagEnableInGameMenuControls" }
};
// only one missing here is Metal because lol // only one missing here is Metal because lol
public static IReadOnlyDictionary<string, string> RenderingModes => new Dictionary<string, string> public static IReadOnlyDictionary<string, string> RenderingModes => new Dictionary<string, string>
{ {
{ "Automatic", "" }, { "Automatic", "None" },
{ "Vulkan", "FFlagDebugGraphicsPreferVulkan" }, { "Vulkan", "Vulkan" },
{ "Direct3D 11", "FFlagDebugGraphicsPreferD3D11" }, { "Direct3D 11", "D3D11" },
{ "Direct3D 10", "FFlagDebugGraphicsPreferD3D11FL10" }, { "Direct3D 10", "D3D10" },
{ "OpenGL", "FFlagDebugGraphicsPreferOpenGL" } { "OpenGL", "OpenGL" }
}; };
public static IReadOnlyDictionary<string, string> LightingTechnologies => new Dictionary<string, string> public static IReadOnlyDictionary<string, string> LightingModes => new Dictionary<string, string>
{ {
{ "Chosen by game", "" }, { "Chosen by game", "None" },
{ "Voxel (Phase 1)", "DFFlagDebugRenderForceTechnologyVoxel" }, { "Voxel (Phase 1)", "Voxel" },
{ "ShadowMap (Phase 2)", "FFlagDebugForceFutureIsBrightPhase2" }, { "ShadowMap (Phase 2)", "ShadowMap" },
{ "Future (Phase 3)", "FFlagDebugForceFutureIsBrightPhase3" } { "Future (Phase 3)", "Future" }
}; };
// this is one hell of a dictionary definition lmao // this is one hell of a dictionary definition lmao
@ -33,8 +71,8 @@
"Default", "Default",
new Dictionary<string, string?> new Dictionary<string, string?>
{ {
{ "FFlagDisableNewIGMinDUA", null }, { "DisableV2", null },
{ "FFlagEnableInGameMenuControls", null } { "EnableV4", null }
} }
}, },
@ -42,8 +80,8 @@
"Version 1 (2015)", "Version 1 (2015)",
new Dictionary<string, string?> new Dictionary<string, string?>
{ {
{ "FFlagDisableNewIGMinDUA", "True" }, { "DisableV2", "True" },
{ "FFlagEnableInGameMenuControls", "False" } { "EnableV4", "False" }
} }
}, },
@ -51,8 +89,8 @@
"Version 2 (2020)", "Version 2 (2020)",
new Dictionary<string, string?> new Dictionary<string, string?>
{ {
{ "FFlagDisableNewIGMinDUA", "False" }, { "DisableV2", "False" },
{ "FFlagEnableInGameMenuControls", "False" } { "EnableV4", "False" }
} }
}, },
@ -60,8 +98,8 @@
"Version 4 (2023)", "Version 4 (2023)",
new Dictionary<string, string?> new Dictionary<string, string?>
{ {
{ "FFlagDisableNewIGMinDUA", "True" }, { "DisableV2", "True" },
{ "FFlagEnableInGameMenuControls", "True" } { "EnableV4", "True" }
} }
} }
}; };
@ -82,22 +120,6 @@
} }
} }
// this will set the flag to the corresponding value if the condition is true
// if the condition is not true, the flag will be erased
public void SetValueIf(bool condition, string key, object? value)
{
if (condition)
SetValue(key, value);
else if (GetValue(key) is not null)
SetValue(key, null);
}
public void SetValueOnce(string key, object? value)
{
if (GetValue(key) is null)
SetValue(key, value);
}
// this returns null if the fflag doesn't exist // this returns null if the fflag doesn't exist
public string? GetValue(string key) public string? GetValue(string key)
{ {
@ -108,15 +130,54 @@
return null; return null;
} }
public void SetPreset(string prefix, object? value)
{
foreach (var pair in PresetFlags.Where(x => x.Key.StartsWith(prefix)))
SetValue(pair.Value, value);
}
public void SetPresetOnce(string key, object? value)
{
if (GetPreset(key) is null)
SetPreset(key, value);
}
public void SetPresetEnum(string prefix, string target, object? value)
{
foreach (var pair in PresetFlags.Where(x => x.Key.StartsWith(prefix)))
{
if (pair.Key.StartsWith($"{prefix}.{target}"))
SetValue(pair.Value, value);
else
SetValue(pair.Value, null);
}
}
public string? GetPreset(string name) => GetValue(PresetFlags[name]);
public string GetPresetEnum(IReadOnlyDictionary<string, string> mapping, string prefix, string value)
{
foreach (var mode in mapping)
{
if (mode.Key == mapping.First().Key)
continue;
if (App.FastFlags.GetPreset($"{prefix}.{mode.Value}") == value)
return mode.Key;
}
return mapping.First().Key;
}
public override void Load() public override void Load()
{ {
base.Load(); base.Load();
// set to 9999 by default if it doesnt already exist SetPresetOnce("Rendering.Framerate", 9999);
SetValueOnce("DFIntTaskSchedulerTargetFps", 9999); SetPresetOnce("Rendering.Fullscreen", "False");
SetValueOnce("FFlagHandleAltEnterFullscreenManually", "False");
SetValueOnce("DFFlagDisableDPIScale", "True"); SetPresetOnce("Rendering.DPI.Disable", "True");
SetValueOnce("DFFlagVariableDPIScale2", "False"); SetPresetOnce("Rendering.DPI.Variable", "False");
} }
} }
} }

View File

@ -39,6 +39,7 @@
</Style> </Style>
</ui:Button.Style> </ui:Button.Style>
</ui:Button> </ui:Button>
<ToggleButton Content="Show preset flags" Click="ToggleButton_Click" Margin="12,0,0,0" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</ui:UiPage> </ui:UiPage>

View File

@ -1,20 +1,7 @@
using System; using System.Collections.ObjectModel;
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;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Controls.Primitives;
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; using Bloxstrap.UI.Elements.Dialogs;
@ -35,14 +22,17 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
InitializeComponent(); InitializeComponent();
} }
private void Page_Loaded(object sender, RoutedEventArgs e) private void ReloadList(bool showPresets = false)
{ {
// refresh list on page load to synchronize with preset page
_fastFlagList.Clear(); _fastFlagList.Clear();
var presetFlags = FastFlagManager.PresetFlags.Values;
foreach (var pair in App.FastFlags.Prop) foreach (var pair in App.FastFlags.Prop)
{ {
if (!showPresets && presetFlags.Contains(pair.Key))
continue;
var entry = new FastFlag var entry = new FastFlag
{ {
Enabled = true, Enabled = true,
@ -62,6 +52,9 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
DataGrid.ItemsSource = _fastFlagList; DataGrid.ItemsSource = _fastFlagList;
} }
// refresh list on page load to synchronize with preset page
private void Page_Loaded(object sender, RoutedEventArgs e) => ReloadList();
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{ {
int index = e.Row.GetIndex(); int index = e.Row.GetIndex();
@ -135,5 +128,11 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
App.FastFlags.SetValue(entry.Name, null); App.FastFlags.SetValue(entry.Name, null);
} }
} }
private void ToggleButton_Click(object sender, RoutedEventArgs e)
{
if (sender is ToggleButton button)
ReloadList(button.IsChecked ?? false);
}
} }
} }

View File

@ -122,7 +122,7 @@
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Choose which lighting technology should be forced enabled in all games." Foreground="{DynamicResource TextFillColorTertiaryBrush}" /> <TextBlock Margin="0,2,0,0" FontSize="12" Text="Choose which lighting technology should be forced enabled in all games." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel> </StackPanel>
</ui:CardControl.Header> </ui:CardControl.Header>
<ComboBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" ItemsSource="{Binding LightingTechnologies.Keys, Mode=OneTime}" Text="{Binding SelectedLightingTechnology, Mode=TwoWay}" /> <ComboBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" ItemsSource="{Binding LightingModes.Keys, Mode=OneTime}" Text="{Binding SelectedLightingMode, Mode=TwoWay}" />
</ui:CardControl> </ui:CardControl>
<ui:CardControl Margin="0,8,0,0"> <ui:CardControl Margin="0,8,0,0">
<ui:CardControl.Header> <ui:CardControl.Header>

View File

@ -15,85 +15,51 @@ namespace Bloxstrap.UI.ViewModels.Menu
public bool HttpRequestLogging public bool HttpRequestLogging
{ {
get => App.FastFlags.GetValue("DFLogHttpTraceLight") is not null; get => App.FastFlags.GetPreset("HTTP.Log") is not null;
set => App.FastFlags.SetValue("DFLogHttpTraceLight", value ? 12 : null); set => App.FastFlags.SetPreset("HTTP.Log", value ? 12 : null);
} }
public string HttpRequestProxy public string HttpRequestProxy
{ {
get => App.FastFlags.GetValue("DFStringDebugPlayerHttpProxyUrl") ?? ""; get => App.FastFlags.GetPreset("HTTP.Proxy.Address.1") ?? "";
set set
{ {
bool? boolValue = null; App.FastFlags.SetPreset("HTTP.Proxy.Enable", String.IsNullOrEmpty(value) ? null : true);
string? stringValue = null; App.FastFlags.SetPreset("HTTP.Proxy.Address", String.IsNullOrEmpty(value) ? null : value);
if (!String.IsNullOrEmpty(value))
{
boolValue = true;
stringValue = value;
}
App.FastFlags.SetValue("DFFlagDebugEnableHttpProxy", boolValue);
App.FastFlags.SetValue("DFStringDebugPlayerHttpProxyUrl", stringValue);
App.FastFlags.SetValue("DFStringHttpCurlProxyHostAndPort", stringValue);
App.FastFlags.SetValue("DFStringHttpCurlProxyHostAndPortForExternalUrl", stringValue);
} }
} }
public string StateOverlayFlags public string StateOverlayFlags
{ {
get => App.FastFlags.GetValue("FStringDebugShowFlagState") ?? ""; get => App.FastFlags.GetPreset("UI.FlagState") ?? "";
set => App.FastFlags.SetValue("FStringDebugShowFlagState", String.IsNullOrEmpty(value) ? null : value); set => App.FastFlags.SetPreset("UI.FlagState", String.IsNullOrEmpty(value) ? null : value);
} }
public int FramerateLimit public int FramerateLimit
{ {
get => int.TryParse(App.FastFlags.GetValue("DFIntTaskSchedulerTargetFps"), out int x) ? x : 60; get => int.TryParse(App.FastFlags.GetPreset("Rendering.Framerate"), out int x) ? x : 60;
set => App.FastFlags.SetValue("DFIntTaskSchedulerTargetFps", value); set => App.FastFlags.SetPreset("Rendering.Framerate", value);
} }
public IReadOnlyDictionary<string, string> RenderingModes => FastFlagManager.RenderingModes; public IReadOnlyDictionary<string, string> RenderingModes => FastFlagManager.RenderingModes;
public string SelectedRenderingMode public string SelectedRenderingMode
{ {
get get => App.FastFlags.GetPresetEnum(RenderingModes, "Rendering.Mode", "True");
{ set => App.FastFlags.SetPresetEnum("Rendering.Mode", RenderingModes[value], "True");
foreach (var mode in RenderingModes)
{
if (App.FastFlags.GetValue(mode.Value) == "True")
return mode.Key;
}
return "Automatic";
}
set
{
foreach (var mode in RenderingModes)
{
if (mode.Key != "Automatic")
App.FastFlags.SetValue(mode.Value, null);
}
if (value == "Automatic")
return;
App.FastFlags.SetValue(RenderingModes[value], "True");
App.FastFlags.SetValueIf(value == "Vulkan", "FFlagRenderVulkanFixMinimizeWindow", "True");
}
} }
public bool AlternateGraphicsSelectorEnabled public bool AlternateGraphicsSelectorEnabled
{ {
get => App.FastFlags.GetValue("FFlagFixGraphicsQuality") == "True"; get => App.FastFlags.GetPreset("UI.Menu.GraphicsSlider") == "True";
set => App.FastFlags.SetValue("FFlagFixGraphicsQuality", value ? "True" : null); set => App.FastFlags.SetPreset("UI.Menu.GraphicsSlider", value ? "True" : null);
} }
public bool Pre2022TexturesEnabled public bool Pre2022TexturesEnabled
{ {
get => App.FastFlags.GetValue("FStringPartTexturePackTable2022") == FastFlagManager.OldTexturesFlagValue; get => App.FastFlags.GetPreset("Rendering.TexturePack") == FastFlagManager.OldTexturesFlagValue;
set => App.FastFlags.SetValue("FStringPartTexturePackTable2022", value ? FastFlagManager.OldTexturesFlagValue : null); set => App.FastFlags.SetPreset("Rendering.TexturePack", value ? FastFlagManager.OldTexturesFlagValue : null);
} }
public IReadOnlyDictionary<string, Dictionary<string, string?>> IGMenuVersions => FastFlagManager.IGMenuVersions; public IReadOnlyDictionary<string, Dictionary<string, string?>> IGMenuVersions => FastFlagManager.IGMenuVersions;
@ -109,7 +75,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
foreach (var flag in version.Value) foreach (var flag in version.Value)
{ {
if (App.FastFlags.GetValue(flag.Key) != flag.Value) if (App.FastFlags.GetPreset($"UI.Menu.Style.{flag.Key}") != flag.Value)
flagsMatch = false; flagsMatch = false;
} }
@ -117,51 +83,28 @@ namespace Bloxstrap.UI.ViewModels.Menu
return version.Key; return version.Key;
} }
return "Default"; return IGMenuVersions.First().Key;
} }
set set
{ {
foreach (var flag in IGMenuVersions[value]) foreach (var flag in IGMenuVersions[value])
{ App.FastFlags.SetPreset($"UI.Menu.Style.{flag.Key}", flag.Value);
App.FastFlags.SetValue(flag.Key, flag.Value);
}
} }
} }
public IReadOnlyDictionary<string, string> LightingTechnologies => FastFlagManager.LightingTechnologies; public IReadOnlyDictionary<string, string> LightingModes => FastFlagManager.LightingModes;
// this is basically the same as the code for rendering selection, maybe this could be abstracted in some way? public string SelectedLightingMode
public string SelectedLightingTechnology
{ {
get get => App.FastFlags.GetPresetEnum(LightingModes, "Rendering.Lighting", "True");
{ set => App.FastFlags.SetPresetEnum("Rendering.Lighting", LightingModes[value], "True");
foreach (var mode in LightingTechnologies)
{
if (App.FastFlags.GetValue(mode.Value) == "True")
return mode.Key;
}
return LightingTechnologies.First().Key;
}
set
{
foreach (var mode in LightingTechnologies)
{
if (mode.Key != LightingTechnologies.First().Key)
App.FastFlags.SetValue(mode.Value, null);
}
if (value != LightingTechnologies.First().Key)
App.FastFlags.SetValue(LightingTechnologies[value], "True");
}
} }
public bool GuiHidingEnabled public bool GuiHidingEnabled
{ {
get => App.FastFlags.GetValue("DFIntCanHideGuiGroupId") == "32380007"; get => App.FastFlags.GetPreset("UI.Hide") == "32380007";
set => App.FastFlags.SetValue("DFIntCanHideGuiGroupId", value ? "32380007" : null); set => App.FastFlags.SetPreset("UI.Hide", value ? "32380007" : null);
} }
} }
} }