diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 48099a7..19c7787 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -230,9 +230,9 @@ namespace Bloxstrap process.Close(); } } - catch (Exception e) + catch (Exception ex) { - App.Logger.WriteLine($"[Bootstrapper::CheckIfRunning] Failed to close process! {e}"); + App.Logger.WriteLine($"[Bootstrapper::CheckIfRunning] Failed to close process! {ex}"); } App.Logger.WriteLine($"[Bootstrapper::CheckIfRunning] All Roblox processes closed"); @@ -316,12 +316,20 @@ namespace Bloxstrap foreach (CustomIntegration integration in App.Settings.Prop.CustomIntegrations) { App.Logger.WriteLine($"[Bootstrapper::StartRoblox] Launching custom integration '{integration.Name}' ({integration.Location} {integration.LaunchArgs} - autoclose is {integration.AutoClose})"); - Process process = Process.Start(integration.Location, integration.LaunchArgs); - if (integration.AutoClose) + try { - shouldWait = true; - autocloseProcesses.Add(process); + Process process = Process.Start(integration.Location, integration.LaunchArgs); + + if (integration.AutoClose) + { + shouldWait = true; + autocloseProcesses.Add(process); + } + } + catch (Exception ex) + { + App.Logger.WriteLine($"[Bootstrapper::StartRoblox] Failed to launch integration '{integration.Name}'! ({ex.Message})"); } } @@ -372,10 +380,10 @@ namespace Bloxstrap else if (Directory.Exists(_versionFolder)) Directory.Delete(_versionFolder, true); } - catch (Exception e) + catch (Exception ex) { App.Logger.WriteLine("[Bootstrapper::CancelInstall] Could not fully clean up installation!"); - App.Logger.WriteLine($"[Bootstrapper::CancelInstall] {e}"); + App.Logger.WriteLine($"[Bootstrapper::CancelInstall] {ex}"); } App.Terminate(ERROR_INSTALL_USEREXIT); @@ -532,9 +540,9 @@ namespace Bloxstrap // (should delete everything except bloxstrap itself) Directory.Delete(Directories.Base, true); } - catch (Exception e) + catch (Exception ex) { - App.Logger.WriteLine($"Could not fully uninstall! ({e})"); + App.Logger.WriteLine($"Could not fully uninstall! ({ex})"); } Dialog?.ShowSuccess($"{App.ProjectName} has succesfully uninstalled"); diff --git a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs index 6803c78..71a7278 100644 --- a/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs +++ b/Bloxstrap/Helpers/Integrations/RbxFpsUnlocker.cs @@ -48,9 +48,9 @@ namespace Bloxstrap.Helpers.Integrations process.Close(); } } - catch (Exception e) + catch (Exception ex) { - App.Logger.WriteLine($"[RbxFpsUnlocker::CheckIfRunning] Could not close rbxfpsunlocker process! {e}"); + App.Logger.WriteLine($"[RbxFpsUnlocker::CheckIfRunning] Could not close rbxfpsunlocker process! {ex}"); } } diff --git a/Bloxstrap/Helpers/Protocol.cs b/Bloxstrap/Helpers/Protocol.cs index 8387649..0bcf17b 100644 --- a/Bloxstrap/Helpers/Protocol.cs +++ b/Bloxstrap/Helpers/Protocol.cs @@ -107,9 +107,9 @@ namespace Bloxstrap.Helpers { Registry.CurrentUser.DeleteSubKeyTree($@"Software\Classes\{key}"); } - catch (Exception e) + catch (Exception ex) { - App.Logger.WriteLine($"[Protocol::Unregister] Failed to unregister {key}: {e}"); + App.Logger.WriteLine($"[Protocol::Unregister] Failed to unregister {key}: {ex}"); } } } diff --git a/Bloxstrap/Models/CustomIntegration.cs b/Bloxstrap/Models/CustomIntegration.cs index 998daee..ece4258 100644 --- a/Bloxstrap/Models/CustomIntegration.cs +++ b/Bloxstrap/Models/CustomIntegration.cs @@ -9,14 +9,9 @@ namespace Bloxstrap.Models { public class CustomIntegration { - public string Name { get; set; } = null!; - public string Location { get; set; } = null!; - public string LaunchArgs { get; set; } = null!; - public bool AutoClose { get; set; } = false; - - public override string ToString() - { - return Name; - } + public string Name { get; set; } = ""; + public string Location { get; set; } = ""; + public string LaunchArgs { get; set; } = ""; + public bool AutoClose { get; set; } = true; } } diff --git a/Bloxstrap/Models/Settings.cs b/Bloxstrap/Models/Settings.cs index ff1a6ae..dad9bcc 100644 --- a/Bloxstrap/Models/Settings.cs +++ b/Bloxstrap/Models/Settings.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; using Bloxstrap.Enums; using Bloxstrap.Helpers; @@ -25,7 +27,8 @@ namespace Bloxstrap.Models public bool RFUAutoclose { get; set; } = false; public bool UseReShade { get; set; } = false; public bool UseReShadeExtraviPresets { get; set; } = false; - public List CustomIntegrations { get; set; } = new(); + // ideally should be List but wpf moment so blehhhhh :P + public ObservableCollection CustomIntegrations { get; set; } = new(); // mod preset configuration public bool UseOldDeathSound { get; set; } = true; diff --git a/Bloxstrap/ViewModels/IntegrationsViewModel.cs b/Bloxstrap/ViewModels/IntegrationsViewModel.cs index cb4d06e..e90c966 100644 --- a/Bloxstrap/ViewModels/IntegrationsViewModel.cs +++ b/Bloxstrap/ViewModels/IntegrationsViewModel.cs @@ -1,16 +1,13 @@ -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using System.Diagnostics; using System.IO; -using System.Windows; -using System.Windows.Controls; using System.Windows.Input; using CommunityToolkit.Mvvm.Input; -using Wpf.Ui.Mvvm.Contracts; using Bloxstrap.Helpers; using Bloxstrap.Models; using Bloxstrap.Views.Pages; +using System.Collections.ObjectModel; namespace Bloxstrap.ViewModels { @@ -19,28 +16,46 @@ namespace Bloxstrap.ViewModels public event PropertyChangedEventHandler? PropertyChanged; public void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - private readonly Page _page; - public ICommand OpenReShadeFolderCommand => new RelayCommand(OpenReShadeFolder); + public ICommand AddIntegrationCommand => new RelayCommand(AddIntegration); + public ICommand DeleteIntegrationCommand => new RelayCommand(DeleteIntegration); public bool CanOpenReShadeFolder => App.Settings.Prop.UseReShade; - public IntegrationsViewModel(Page page) - { - _page = page; - - if (CustomIntegrations.Count > 0) - { - CustomIntegrationsVisibility = Visibility.Visible; - OnPropertyChanged(nameof(CustomIntegrationsVisibility)); - } - } - private void OpenReShadeFolder() { Process.Start("explorer.exe", Path.Combine(Directories.Integrations, "ReShade")); } + private void AddIntegration() + { + CustomIntegrations.Add(new CustomIntegration() + { + Name = "New Integration" + }); + + SelectedCustomIntegrationIndex = CustomIntegrations.Count - 1; + + OnPropertyChanged(nameof(SelectedCustomIntegrationIndex)); + OnPropertyChanged(nameof(IsCustomIntegrationSelected)); + } + + private void DeleteIntegration() + { + if (SelectedCustomIntegration is null) + return; + + CustomIntegrations.Remove(SelectedCustomIntegration); + + if (CustomIntegrations.Count > 0) + { + SelectedCustomIntegrationIndex = CustomIntegrations.Count - 1; + OnPropertyChanged(nameof(SelectedCustomIntegrationIndex)); + } + + OnPropertyChanged(nameof(IsCustomIntegrationSelected)); + } + public bool DiscordActivityEnabled { get => App.Settings.Prop.UseDiscordRichPresence; @@ -96,14 +111,14 @@ namespace Bloxstrap.ViewModels set => App.Settings.Prop.RFUAutoclose = value; } - public Visibility CustomIntegrationsVisibility { get; set; } = Visibility.Collapsed; - - public List CustomIntegrations + public ObservableCollection CustomIntegrations { get => App.Settings.Prop.CustomIntegrations; set => App.Settings.Prop.CustomIntegrations = value; } - public CustomIntegration SelectedCustomIntegration { get; set; } = new(); + public CustomIntegration? SelectedCustomIntegration { get; set; } + public int SelectedCustomIntegrationIndex { get; set; } + public bool IsCustomIntegrationSelected => SelectedCustomIntegration is not null; } } diff --git a/Bloxstrap/Views/Pages/BootstrapperPage.xaml b/Bloxstrap/Views/Pages/BootstrapperPage.xaml index a3c4e8a..2870ed3 100644 --- a/Bloxstrap/Views/Pages/BootstrapperPage.xaml +++ b/Bloxstrap/Views/Pages/BootstrapperPage.xaml @@ -18,7 +18,7 @@ - + @@ -45,7 +45,7 @@ - + diff --git a/Bloxstrap/Views/Pages/IntegrationsPage.xaml b/Bloxstrap/Views/Pages/IntegrationsPage.xaml index 71a2eee..cfb8978 100644 --- a/Bloxstrap/Views/Pages/IntegrationsPage.xaml +++ b/Bloxstrap/Views/Pages/IntegrationsPage.xaml @@ -7,7 +7,7 @@ xmlns:models="clr-namespace:Bloxstrap.ViewModels" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" mc:Ignorable="d" - d:DesignHeight="680" d:DesignWidth="800" + d:DesignHeight="1080" d:DesignWidth="800" Title="IntegrationsPage" Scrollable="True"> @@ -107,7 +107,7 @@ - + @@ -116,24 +116,54 @@ - - Using custom integrations, you can have other programs launch with Roblox automatically like how rbxfpsunlocker does. - To manage custom integrations, you'll have to manually edit your Settings.json configuration file in your Bloxstrap folder. If you have any configured, you'll be able to preview them here. - - + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Bloxstrap/Views/Pages/IntegrationsPage.xaml.cs b/Bloxstrap/Views/Pages/IntegrationsPage.xaml.cs index eb5121d..c4066ab 100644 --- a/Bloxstrap/Views/Pages/IntegrationsPage.xaml.cs +++ b/Bloxstrap/Views/Pages/IntegrationsPage.xaml.cs @@ -13,7 +13,7 @@ namespace Bloxstrap.Views.Pages { public IntegrationsPage() { - DataContext = new IntegrationsViewModel(this); + DataContext = new IntegrationsViewModel(); InitializeComponent(); // rbxfpsunlocker does not have 64 bit support