Skip to content

Commit

Permalink
Code as of September 18th 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Nov 29, 2024
1 parent 0b20720 commit 82d0175
Show file tree
Hide file tree
Showing 15 changed files with 681 additions and 473 deletions.
1 change: 1 addition & 0 deletions Bloxstrap/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
</Setter>
</Style>

<converters:StringResourceConverter x:Key="StringResourceConverter" />
<converters:StringFormatConverter x:Key="StringFormatConverter" />
<converters:RangeConverter x:Key="RangeConverter" />
<converters:EnumNameConverter x:Key="EnumNameConverter" />
Expand Down
30 changes: 30 additions & 0 deletions Bloxstrap/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,36 @@ protected override void OnStartup(StartupEventArgs e)
State.Load();
FastFlags.Load();

//List<string> tests = new()
//{
// "UI.FullscreenTitlebarDelay == null || true",
// "UI.FullscreenTitlebarDelay == null && true",
// "UI.FullscreenTitlebarDelay == null || false",
// "UI.FullscreenTitlebarDelay == null && false",
// "UI.FullscreenTitlebarDelay == null && false || true",
// "UI.FullscreenTitlebarDelay == null && true || false",
// "false && false || true",
// "(false && false) || true",
// "false && (false || true)",
// "FFlagDisableNewIGMinDUA != True",
// "FStringDebugFlagState == 'hi'",
// "FStringDebugFlagState == 'wassup'",
// "FStringDebugFlagState == FStringDebugFlagState",
// "FStringDebugFlagState != FStringDebugFlagState",
// "FLogNetwork == 7",
// "FLogNetwork > 9",
// "FLogNetwork < 9"
//};


//foreach (string test in tests)
//{
// bool result = new FlexParser(test).Evaluate();
// App.Logger.WriteLine(LOG_IDENT, $"'{test}' evaluated to {result}");
//}

//Debugger.Break();

if (!Locale.SupportedLocales.ContainsKey(Settings.Prop.Locale))
{
Settings.Prop.Locale = "nil";
Expand Down
28 changes: 28 additions & 0 deletions Bloxstrap/Enums/FlexTokenType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Bloxstrap.Enums
{
public enum FlexTokenType
{
// data types
NULL,
NUMBER,
BOOL,
STRING,
FLAG,

// comparison operators
COMPARE_EQ,
COMPARE_NEQ,
COMPARE_GT,
COMPARE_LT,
COMPARE_GEQ,
COMPARE_LEQ,

// boolean logic operators
LOGIC_AND,
LOGIC_OR,

// yes, "bracket" is technically not the correct term, don't care
BRACKET_OPEN,
BRACKET_CLOSE
}
}
14 changes: 14 additions & 0 deletions Bloxstrap/Exceptions/FlexParseException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Bloxstrap.Exceptions
{
internal class FlexParseException : Exception
{
public FlexParseException(string expression, string message, string? position = null)
: base($"Invalid syntax encountered when parsing '{expression}' at position {position ?? "EOF"} ({message})") { }

public FlexParseException(string expression, string message, int position)
: this(expression, message, position.ToString()) { }

public FlexParseException(string expression, string message, FlexToken? token)
: this(expression, message, token?.Position.ToString()) { }
}
}
191 changes: 25 additions & 166 deletions Bloxstrap/FastFlagManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Bloxstrap.Enums.FlagPresets;

namespace Bloxstrap
namespace Bloxstrap
{
public class FastFlagManager : JsonManager<Dictionary<string, object>>
{
Expand All @@ -12,146 +10,13 @@ public class FastFlagManager : JsonManager<Dictionary<string, object>>

public bool Changed => !OriginalProp.SequenceEqual(Prop);

public static IReadOnlyDictionary<string, string> PresetFlags = new Dictionary<string, string>
{
{ "Network.Log", "FLogNetwork" },

#if DEBUG
{ "HTTP.Log", "DFLogHttpTraceLight" },

{ "HTTP.Proxy.Enable", "DFFlagDebugEnableHttpProxy" },
{ "HTTP.Proxy.Address.1", "DFStringDebugPlayerHttpProxyUrl" },
{ "HTTP.Proxy.Address.2", "DFStringHttpCurlProxyHostAndPort" },
{ "HTTP.Proxy.Address.3", "DFStringHttpCurlProxyHostAndPortForExternalUrl" },
#endif

{ "Rendering.Framerate", "DFIntTaskSchedulerTargetFps" },
{ "Rendering.ManualFullscreen", "FFlagHandleAltEnterFullscreenManually" },
{ "Rendering.DisableScaling", "DFFlagDisableDPIScale" },
{ "Rendering.MSAA", "FIntDebugForceMSAASamples" },
{ "Rendering.DisablePostFX", "FFlagDisablePostFx" },
{ "Rendering.ShadowIntensity", "FIntRenderShadowIntensity" },

{ "Rendering.Mode.D3D11", "FFlagDebugGraphicsPreferD3D11" },
{ "Rendering.Mode.D3D10", "FFlagDebugGraphicsPreferD3D11FL10" },

{ "Rendering.Lighting.Voxel", "DFFlagDebugRenderForceTechnologyVoxel" },
{ "Rendering.Lighting.ShadowMap", "FFlagDebugForceFutureIsBrightPhase2" },
{ "Rendering.Lighting.Future", "FFlagDebugForceFutureIsBrightPhase3" },

{ "Rendering.TextureQuality.OverrideEnabled", "DFFlagTextureQualityOverrideEnabled" },
{ "Rendering.TextureQuality.Level", "DFIntTextureQualityOverride" },
{ "Rendering.TerrainTextureQuality", "FIntTerrainArraySliceSize" },

{ "UI.Hide", "DFIntCanHideGuiGroupId" },
{ "UI.FontSize", "FIntFontSizePadding" },
#if DEBUG
{ "UI.FlagState", "FStringDebugShowFlagState" },
#endif

{ "UI.FullscreenTitlebarDelay", "FIntFullscreenTitleBarTriggerDelayMillis" },

{ "UI.Menu.Style.V2Rollout", "FIntNewInGameMenuPercentRollout3" },
{ "UI.Menu.Style.EnableV4.1", "FFlagEnableInGameMenuControls" },
{ "UI.Menu.Style.EnableV4.2", "FFlagEnableInGameMenuModernization" },
{ "UI.Menu.Style.EnableV4Chrome", "FFlagEnableInGameMenuChrome" },

{ "UI.Menu.Style.ABTest.1", "FFlagEnableMenuControlsABTest" },
{ "UI.Menu.Style.ABTest.2", "FFlagEnableV3MenuABTest3" },
{ "UI.Menu.Style.ABTest.3", "FFlagEnableInGameMenuChromeABTest3" }
};

public static IReadOnlyDictionary<RenderingMode, string> RenderingModes => new Dictionary<RenderingMode, string>
{
{ RenderingMode.Default, "None" },
{ RenderingMode.D3D11, "D3D11" },
{ RenderingMode.D3D10, "D3D10" },
};

public static IReadOnlyDictionary<LightingMode, string> LightingModes => new Dictionary<LightingMode, string>
{
{ LightingMode.Default, "None" },
{ LightingMode.Voxel, "Voxel" },
{ LightingMode.ShadowMap, "ShadowMap" },
{ LightingMode.Future, "Future" }
};

public static IReadOnlyDictionary<MSAAMode, string?> MSAAModes => new Dictionary<MSAAMode, string?>
{
{ MSAAMode.Default, null },
{ MSAAMode.x1, "1" },
{ MSAAMode.x2, "2" },
{ MSAAMode.x4, "4" }
};
public readonly FFlagPresets PresetConfig;

public static IReadOnlyDictionary<TextureQuality, string?> TextureQualityLevels => new Dictionary<TextureQuality, string?>
{
{ TextureQuality.Default, null },
{ TextureQuality.Level0, "0" },
{ TextureQuality.Level1, "1" },
{ TextureQuality.Level2, "2" },
{ TextureQuality.Level3, "3" },
};

// this is one hell of a dictionary definition lmao
// since these all set the same flags, wouldn't making this use bitwise operators be better?
public static IReadOnlyDictionary<InGameMenuVersion, Dictionary<string, string?>> IGMenuVersions => new Dictionary<InGameMenuVersion, Dictionary<string, string?>>
public FastFlagManager()

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.

Check warning on line 15 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Non-nullable field 'PresetConfig' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the field as nullable.
{
{
InGameMenuVersion.Default,
new Dictionary<string, string?>
{
{ "V2Rollout", null },
{ "EnableV4", null },
{ "EnableV4Chrome", null },
{ "ABTest", null }
}
},

{
InGameMenuVersion.V1,
new Dictionary<string, string?>
{
{ "V2Rollout", "0" },
{ "EnableV4", "False" },
{ "EnableV4Chrome", "False" },
{ "ABTest", "False" }
}
},

{
InGameMenuVersion.V2,
new Dictionary<string, string?>
{
{ "V2Rollout", "100" },
{ "EnableV4", "False" },
{ "EnableV4Chrome", "False" },
{ "ABTest", "False" }
}
},

{
InGameMenuVersion.V4,
new Dictionary<string, string?>
{
{ "V2Rollout", "0" },
{ "EnableV4", "True" },
{ "EnableV4Chrome", "False" },
{ "ABTest", "False" }
}
},

{
InGameMenuVersion.V4Chrome,
new Dictionary<string, string?>
{
{ "V2Rollout", "0" },
{ "EnableV4", "True" },
{ "EnableV4Chrome", "True" },
{ "ABTest", "False" }
}
}
};
PresetConfig = JsonSerializer.Deserialize<FFlagPresets>(File.ReadAllText("C:\\Users\\pizzaboxer\\Documents\\Projects\\Bloxstrap\\PrototypeSchema.json"));

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Debug)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Possible null reference assignment.

Check warning on line 17 in Bloxstrap/FastFlagManager.cs

View workflow job for this annotation

GitHub Actions / build (Release)

Possible null reference assignment.
Debug.WriteLine(PresetConfig);
}

// all fflags are stored as strings
// to delete a flag, set the value as null
Expand All @@ -170,7 +35,7 @@ public void SetValue(string key, object? value)
{
if (Prop.ContainsKey(key))
{
if (key == Prop[key].ToString())
if (value.ToString() == Prop[key].ToString())
return;

App.Logger.WriteLine(LOG_IDENT, $"Changing of '{key}' from '{Prop[key]}' to '{value}' is pending");
Expand All @@ -184,10 +49,16 @@ public void SetValue(string key, object? value)
}
}

// this returns null if the fflag doesn't exist
/// <summary>
/// Returns null if the flag has not been set
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public string? GetValue(string key)
{
// check if we have an updated change for it pushed first
if (PresetConfig.Flags.ContainsKey(key))
key = PresetConfig.Flags[key];

if (Prop.TryGetValue(key, out object? value) && value is not null)
return value.ToString();

Expand All @@ -196,37 +67,25 @@ public void SetValue(string key, object? value)

public void SetPreset(string prefix, object? value)
{
foreach (var pair in PresetFlags.Where(x => x.Key.StartsWith(prefix)))
foreach (var pair in PresetConfig.Flags.Where(x => x.Key.StartsWith(prefix)))
SetValue(pair.Value, value);
}

public void SetPresetEnum(string prefix, string target, object? value)
public bool CheckPresetValue(string prefix, string 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);
}
}
var presets = PresetConfig.Flags.Where(x => x.Key.StartsWith(prefix));

public string? GetPreset(string name) => GetValue(PresetFlags[name]);

public T GetPresetEnum<T>(IReadOnlyDictionary<T, string> mapping, string prefix, string value) where T : Enum
{
foreach (var pair in mapping)
foreach (var preset in presets)
{
if (pair.Value == "None")
continue;

if (GetPreset($"{prefix}.{pair.Value}") == value)
return pair.Key;
if (GetValue(preset.Value) != value)
return false;
}

return mapping.First().Key;
return true;
}

public bool CheckPresetValue(KeyValuePair<string, string> entry) => CheckPresetValue(entry.Key, entry.Value);

public override void Save()
{
// convert all flag values to strings before saving
Expand All @@ -248,7 +107,7 @@ public override void Load(bool alertFailure = true)
OriginalProp = new(Prop);

// TODO - remove when activity tracking has been revamped
if (GetPreset("Network.Log") != "7")
if (GetValue("Network.Log") != "7")
SetPreset("Network.Log", "7");
}
}
Expand Down
Loading

0 comments on commit 82d0175

Please sign in to comment.