Skip to content

Commit

Permalink
Add debug flags, fix mod preset bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Jul 15, 2023
1 parent 258746f commit d8842cc
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 13 deletions.
18 changes: 11 additions & 7 deletions Bloxstrap/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,22 +1110,26 @@ private async Task ApplyModifications()
private static async Task CheckModPreset(bool condition, string location, string name)
{
string fullLocation = Path.Combine(Directories.Modifications, location);
byte[] embeddedData = string.IsNullOrEmpty(name) ? Array.Empty<byte>() : await Resource.Get(name);

string fileHash = File.Exists(fullLocation) ? Utility.MD5Hash.FromFile(fullLocation) : "";

if (!condition)
{
if (fileHash != "")
File.Delete(fullLocation);

return;
}

byte[] embeddedData = string.IsNullOrEmpty(name) ? Array.Empty<byte>() : await Resource.Get(name);
string embeddedHash = Utility.MD5Hash.FromBytes(embeddedData);

if (condition && fileHash != embeddedHash)
if (fileHash != embeddedHash)
{
Directory.CreateDirectory(Path.GetDirectoryName(fullLocation)!);
File.Delete(fullLocation);

await File.WriteAllBytesAsync(fullLocation, embeddedData);
}
else if (!condition && fileHash != "")
{
File.Delete(fullLocation);
}
}

private async Task DownloadPackage(Package package)
Expand Down
4 changes: 2 additions & 2 deletions Bloxstrap/Extensions/CursorTypeEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ static class CursorTypeEx
public static IReadOnlyDictionary<string, CursorType> Selections => new Dictionary<string, CursorType>
{
{ "Default", CursorType.Default },
{ "Before 2022", CursorType.From2013 },
{ "Before 2013", CursorType.From2006 },
{ "2013 - 2022", CursorType.From2013 },
{ "2006 - 2013", CursorType.From2006 },
};
}
}
1 change: 1 addition & 0 deletions Bloxstrap/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Settings
public bool CheckForUpdates { get; set; } = true;
public bool CreateDesktopIcon { get; set; } = true;
public bool MultiInstanceLaunching { get; set; } = false;
public bool OhHeyYouFoundMe { get; set; } = false;

// channel configuration
public string Channel { get; set; } = RobloxDeployment.DefaultChannel;
Expand Down
31 changes: 31 additions & 0 deletions Bloxstrap/UI/Elements/Menu/Pages/FastFlagsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,37 @@
</StackPanel>
</ui:CardAction>

<StackPanel Visibility="{Binding ShowDebugFlags, Mode=OneTime}">
<TextBlock Text="Debug" FontSize="16" FontWeight="Medium" Margin="0,16,0,0" />
<ui:CardControl Margin="0,8,0,0">
<ui:CardControl.Header>
<StackPanel>
<TextBlock FontSize="14" Text="HTTP request logging" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Enables logging of HTTP requests (DFLogHttpTraceLight=12)." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch IsChecked="{Binding HttpRequestLogging, Mode=TwoWay}" />
</ui:CardControl>
<ui:CardControl Margin="0,8,0,0">
<ui:CardControl.Header>
<StackPanel>
<TextBlock FontSize="14" Text="HTTP proxy address" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Set blank if not using a proxy. Don't forget to add cacert.pem as a mod." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
</ui:CardControl.Header>
<ui:TextBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" Text="{Binding HttpRequestProxy, Mode=TwoWay}" />
</ui:CardControl>
<ui:CardControl Margin="0,8,0,0">
<ui:CardControl.Header>
<StackPanel>
<TextBlock FontSize="14" Text="Flag state overlay" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Show values of specified flags during runtime. Each flag is comma separated." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
</ui:CardControl.Header>
<ui:TextBox Margin="5,0,0,0" Padding="10,5,10,5" Width="200" Text="{Binding StateOverlayFlags, Mode=TwoWay}" />
</ui:CardControl>
</StackPanel>

<TextBlock Text="Presets" FontSize="16" FontWeight="Medium" Margin="0,16,0,0" />
<ui:CardControl Margin="0,8,0,0">
<ui:CardControl.Header>
Expand Down
47 changes: 43 additions & 4 deletions Bloxstrap/UI/ViewModels/Menu/FastFlagsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Input;

using CommunityToolkit.Mvvm.Input;
Expand All @@ -16,6 +19,42 @@ public class FastFlagsViewModel : INotifyPropertyChanged

private void OpenClientSettings() => Utilities.ShellExecute(Path.Combine(Directories.Modifications, "ClientSettings\\ClientAppSettings.json"));

public Visibility ShowDebugFlags => App.Settings.Prop.OhHeyYouFoundMe ? Visibility.Visible : Visibility.Collapsed;

public bool HttpRequestLogging
{
get => App.FastFlags.GetValue("DFLogHttpTraceLight") is not null;
set => App.FastFlags.SetValue("DFLogHttpTraceLight", value ? 12 : null);
}

public string HttpRequestProxy
{
get => App.FastFlags.GetValue("DFStringDebugPlayerHttpProxyUrl") ?? "";

set
{
bool? boolValue = null;
string? stringValue = null;

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
{
get => App.FastFlags.GetValue("FStringDebugShowFlagState") ?? "";
set => App.FastFlags.SetValue("FStringDebugShowFlagState", String.IsNullOrEmpty(value) ? null : value);
}

public int FramerateLimit
{
get => int.TryParse(App.FastFlags.GetValue("DFIntTaskSchedulerTargetFps"), out int x) ? x : 60;
Expand Down Expand Up @@ -111,18 +150,18 @@ public string SelectedLightingTechnology
return mode.Key;
}

return "Automatic";
return LightingTechnologies.First().Key;
}

set
{
foreach (var mode in LightingTechnologies)
{
if (mode.Key != "Automatic")
if (mode.Key != LightingTechnologies.First().Key)
App.FastFlags.SetValue(mode.Value, null);
}

if (value != "Automatic")
if (value != LightingTechnologies.First().Key)
App.FastFlags.SetValue(LightingTechnologies[value], "True");
}
}
Expand Down

0 comments on commit d8842cc

Please sign in to comment.