diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 3f6aa9c..dd86c42 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.IO; using System.Net.Http; @@ -46,6 +47,7 @@ namespace Bloxstrap public static readonly DeployManager DeployManager = new(); public static readonly JsonManager Settings = new(); public static readonly JsonManager State = new(); + public static readonly JsonManager> FastFlags = new(); public static readonly HttpClient HttpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.All }); // shorthand @@ -154,6 +156,7 @@ namespace Bloxstrap } Directories.Initialize(BaseDirectory); + FastFlags.AltFileLocation = Path.Combine(Directories.Modifications, "ClientSettings\\ClientAppSettings.json"); // we shouldn't save settings on the first run until the first installation is finished, // just in case the user decides to cancel the install diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 39fa664..dcf87ad 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -153,7 +153,10 @@ namespace Bloxstrap _versionFolder = Path.Combine(Directories.Versions, App.State.Prop.VersionGuid); if (App.IsFirstRun) + { App.ShouldSaveConfigs = true; + App.FastFlags.Save(); + } await ApplyModifications(); @@ -733,6 +736,8 @@ namespace Bloxstrap { SetStatus("Applying Roblox modifications..."); + // set executable flags for fullscreen optimizations + App.Logger.WriteLine("[Bootstrapper::ApplyModifications] Checking executable flags..."); using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers")) { const string flag = " DISABLEDXMAXIMIZEDWINDOWEDMODE"; @@ -757,6 +762,7 @@ namespace Bloxstrap } // handle file mods + App.Logger.WriteLine("[Bootstrapper::ApplyModifications] Checking file mods..."); string modFolder = Path.Combine(Directories.Modifications); // manifest has been moved to State.json @@ -831,7 +837,8 @@ namespace Bloxstrap // package doesn't exist, likely mistakenly placed file string versionFileLocation = Path.Combine(_versionFolder, fileLocation); - File.Delete(versionFileLocation); + if (File.Exists(versionFileLocation)) + File.Delete(versionFileLocation); continue; } diff --git a/Bloxstrap/Helpers/JsonManager.cs b/Bloxstrap/Helpers/JsonManager.cs index 69e86f7..04eddef 100644 --- a/Bloxstrap/Helpers/JsonManager.cs +++ b/Bloxstrap/Helpers/JsonManager.cs @@ -16,15 +16,11 @@ namespace Bloxstrap.Helpers public class JsonManager where T : new() { public T Prop { get; set; } = new(); - //public bool ShouldSave { get; set; } = true; - public string FileLocation => Path.Combine(Directories.Base, $"{typeof(T).Name}.json"); - //public string? FileLocation { get; set; } = null; + public string FileLocation => AltFileLocation ?? Path.Combine(Directories.Base, $"{typeof(T).Name}.json"); + public string? AltFileLocation { get; set; } public void Load() { - //if (String.IsNullOrEmpty(FileLocation)) - // throw new ArgumentNullException("No FileLocation has been set"); - App.Logger.WriteLine($"[JsonManager<{typeof(T).Name}>::Load] Loading JSON from {FileLocation}..."); try @@ -32,7 +28,6 @@ namespace Bloxstrap.Helpers T? settings = JsonSerializer.Deserialize(File.ReadAllText(FileLocation)); Prop = settings ?? throw new ArgumentNullException("Deserialization returned null"); App.Logger.WriteLine($"[JsonManager<{typeof(T).Name}>::Load] JSON loaded successfully!"); - } catch (Exception ex) { @@ -40,25 +35,18 @@ namespace Bloxstrap.Helpers } } - public void Save() + public void Save(bool saveOverride = false) { App.Logger.WriteLine($"[JsonManager<{typeof(T).Name}>::Save] Attempting to save JSON to {FileLocation}..."); - //if (!ShouldSave || String.IsNullOrEmpty(FileLocation)) - //{ - // App.Logger.WriteLine($"[JsonManager<{typeof(T).Name}>] Aborted save (ShouldSave set to false or FileLocation not set)"); - // return; - //} - - //if (!ShouldSave) - if (!App.ShouldSaveConfigs) + if (!App.ShouldSaveConfigs && !saveOverride) { App.Logger.WriteLine($"[JsonManager<{typeof(T).Name}>::Save] Aborted save (ShouldSave set to false)"); return; } - string json = JsonSerializer.Serialize(Prop, new JsonSerializerOptions { WriteIndented = true }); - File.WriteAllText(FileLocation, json); + Directory.CreateDirectory(Path.GetDirectoryName(FileLocation)!); + File.WriteAllText(FileLocation, JsonSerializer.Serialize(Prop, new JsonSerializerOptions { WriteIndented = true })); App.Logger.WriteLine($"[JsonManager<{typeof(T).Name}>::Save] JSON saved!"); } diff --git a/Bloxstrap/Integrations/DiscordRichPresence.cs b/Bloxstrap/Integrations/DiscordRichPresence.cs index 8cfa082..295e647 100644 --- a/Bloxstrap/Integrations/DiscordRichPresence.cs +++ b/Bloxstrap/Integrations/DiscordRichPresence.cs @@ -69,7 +69,7 @@ namespace Bloxstrap.Integrations else if (_logEntriesRead % 100 == 0) App.Logger.WriteLine($"[DiscordRichPresence::ExamineLogEntry] Read {_logEntriesRead} log entries"); - if (entry.Contains(GameJoiningEntry) && !_activityInGame && _activityPlaceId == 0) + if (!_activityInGame && _activityPlaceId == 0 && entry.Contains(GameJoiningEntry)) { Match match = Regex.Match(entry, GameJoiningEntryPattern); @@ -121,7 +121,7 @@ namespace Bloxstrap.Integrations await SetPresence(); } } - else if (entry.Contains(GameDisconnectedEntry) && _activityInGame && _activityPlaceId != 0) + else if (_activityInGame && _activityPlaceId != 0 && entry.Contains(GameDisconnectedEntry)) { App.Logger.WriteLine($"[DiscordRichPresence::ExamineLogEntry] Disconnected from Game ({_activityPlaceId}/{_activityJobId}/{_activityMachineAddress})"); diff --git a/Bloxstrap/ViewModels/MainWindowViewModel.cs b/Bloxstrap/ViewModels/MainWindowViewModel.cs index 52a3a19..870a9e8 100644 --- a/Bloxstrap/ViewModels/MainWindowViewModel.cs +++ b/Bloxstrap/ViewModels/MainWindowViewModel.cs @@ -59,7 +59,6 @@ namespace Bloxstrap.ViewModels if (!App.IsFirstRun) { - //App.Settings.ShouldSave = true; App.ShouldSaveConfigs = true; if (App.BaseDirectory != _originalBaseDirectory) diff --git a/Bloxstrap/ViewModels/ModsViewModel.cs b/Bloxstrap/ViewModels/ModsViewModel.cs index fc35091..e017b54 100644 --- a/Bloxstrap/ViewModels/ModsViewModel.cs +++ b/Bloxstrap/ViewModels/ModsViewModel.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System.Collections.Generic; +using System.Diagnostics; using System.Windows.Input; using Bloxstrap.Helpers; using CommunityToolkit.Mvvm.Input; @@ -32,6 +33,70 @@ namespace Bloxstrap.ViewModels set => App.Settings.Prop.UseDisableAppPatch = value; } + // only one missing here is Metal because lol + public IReadOnlyDictionary RenderingModes { get; set; } = new Dictionary() + { + { "Automatic", "" }, + { "Direct3D 11", "FFlagDebugGraphicsPreferD3D11" }, + { "OpenGL", "FFlagDebugGraphicsPreferOpenGL" }, + { "Vulkan", "FFlagDebugGraphicsPreferVulkan" } + }; + + // if i ever need to do more fflag handling i'll just add an fflag handler that abstracts away all this boilerplate + // but for now this is fine + public bool ExclusiveFullscreenEnabled + { + get + { + return App.FastFlags.Prop.ContainsKey("FFlagHandleAltEnterFullscreenManually") && App.FastFlags.Prop["FFlagHandleAltEnterFullscreenManually"].ToString() == "False"; + } + + set + { + if (!App.IsFirstRun) + App.FastFlags.Load(); + + if (value) + App.FastFlags.Prop["FFlagHandleAltEnterFullscreenManually"] = false; + else + App.FastFlags.Prop.Remove("FFlagHandleAltEnterFullscreenManually"); + + if (!App.IsFirstRun) + App.FastFlags.Save(true); + } + } + + public string SelectedRenderingMode + { + get + { + foreach (var mode in RenderingModes) + { + if (App.FastFlags.Prop.ContainsKey(mode.Value)) + return mode.Key; + } + + return "Automatic"; + } + + set + { + if (!App.IsFirstRun) + App.FastFlags.Load(); + + foreach (var mode in RenderingModes) + { + App.FastFlags.Prop.Remove(mode.Value); + } + + if (value != "Automatic") + App.FastFlags.Prop[RenderingModes[value]] = true; + + if (!App.IsFirstRun) + App.FastFlags.Save(true); + } + } + public bool DisableFullscreenOptimizationsEnabled { get => App.Settings.Prop.DisableFullscreenOptimizations; diff --git a/Bloxstrap/Views/Pages/ModsPage.xaml b/Bloxstrap/Views/Pages/ModsPage.xaml index 3d52339..ac4dc55 100644 --- a/Bloxstrap/Views/Pages/ModsPage.xaml +++ b/Bloxstrap/Views/Pages/ModsPage.xaml @@ -94,6 +94,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -101,7 +129,7 @@ - A Windows feature that can potentially cause problems - see more info.. + A Windows feature that can potentially cause problems - click here for more info. diff --git a/Bloxstrap/Views/Pages/ModsPage.xaml.cs b/Bloxstrap/Views/Pages/ModsPage.xaml.cs index 210eb15..b5c7e43 100644 --- a/Bloxstrap/Views/Pages/ModsPage.xaml.cs +++ b/Bloxstrap/Views/Pages/ModsPage.xaml.cs @@ -11,6 +11,9 @@ namespace Bloxstrap.Views.Pages { public ModsPage() { + if (!App.IsFirstRun) + App.FastFlags.Load(); + DataContext = new ModsViewModel(); InitializeComponent();