Add info prompt before initial installation

Also fixed a bug with config saving being handled incorrectly
This commit is contained in:
pizzaboxer 2023-02-05 10:18:32 +00:00
parent 3143b17666
commit d468157488
4 changed files with 35 additions and 14 deletions

View File

@ -118,7 +118,6 @@ namespace Bloxstrap
// just in case the user decides to cancel the install // just in case the user decides to cancel the install
if (!IsFirstRun) if (!IsFirstRun)
{ {
ShouldSaveConfigs = true;
Settings.Load(); Settings.Load();
State.Load(); State.Load();
} }
@ -142,7 +141,6 @@ namespace Bloxstrap
} }
#endif #endif
//new Preferences().ShowDialog();
new MainWindow().ShowDialog(); new MainWindow().ShowDialog();
} }
else if (LaunchArgs[0].StartsWith("roblox-player:")) else if (LaunchArgs[0].StartsWith("roblox-player:"))
@ -165,6 +163,9 @@ namespace Bloxstrap
if (!String.IsNullOrEmpty(commandLine)) if (!String.IsNullOrEmpty(commandLine))
{ {
if (!IsFirstRun)
ShouldSaveConfigs = true;
DeployManager.Channel = Settings.Prop.Channel; DeployManager.Channel = Settings.Prop.Channel;
Settings.Prop.BootstrapperStyle.Show(new Bootstrapper(commandLine)); Settings.Prop.BootstrapperStyle.Show(new Bootstrapper(commandLine));
} }

View File

@ -1,17 +1,18 @@
using System.IO; using System;
using System; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Input; using System.Windows.Input;
using Bloxstrap.Views;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Win32; using Microsoft.Win32;
using CommunityToolkit.Mvvm.Input;
using Wpf.Ui.Controls.Interfaces;
using Wpf.Ui.Mvvm.Contracts;
namespace Bloxstrap.ViewModels namespace Bloxstrap.ViewModels
{ {
public class MainWindowViewModel public class MainWindowViewModel
{ {
private readonly Window _window; private readonly Window _window;
private readonly IDialogService _dialogService;
private readonly string _originalBaseDirectory = App.BaseDirectory; // we need this to check if the basedirectory changes private readonly string _originalBaseDirectory = App.BaseDirectory; // we need this to check if the basedirectory changes
public ICommand CloseWindowCommand => new RelayCommand(CloseWindow); public ICommand CloseWindowCommand => new RelayCommand(CloseWindow);
@ -19,9 +20,10 @@ namespace Bloxstrap.ViewModels
public string ConfirmButtonText => App.IsFirstRun ? "Install" : "Save"; public string ConfirmButtonText => App.IsFirstRun ? "Install" : "Save";
public MainWindowViewModel(Window window) public MainWindowViewModel(Window window, IDialogService dialogService)
{ {
_window = window; _window = window;
_dialogService = dialogService;
} }
private void CloseWindow() => _window.Close(); private void CloseWindow() => _window.Close();
@ -83,15 +85,29 @@ namespace Bloxstrap.ViewModels
// preserve settings // preserve settings
// we don't need to copy the bootstrapper over since the install process will do that automatically // we don't need to copy the bootstrapper over since the install process will do that automatically
App.Settings.Save(); // App.Settings.Save();
// File.Copy(Path.Combine(App.BaseDirectory, "Settings.json"), Path.Combine(App.BaseDirectory, "Settings.json")); // File.Copy(Path.Combine(App.BaseDirectory, "Settings.json"), Path.Combine(App.BaseDirectory, "Settings.json"));
} }
}
App.IsSetupComplete = true;
CloseWindow(); CloseWindow();
} }
else
{
IDialogControl dialogControl = _dialogService.GetDialogControl();
dialogControl.ButtonRightClick += (_, _) =>
{
dialogControl.Hide();
App.IsSetupComplete = true;
CloseWindow();
};
dialogControl.ShowAndWaitAsync(
"Before you install",
"After installation, you can open the menu again by searching for it in the Start menu.\n" +
"If you want to revert back to the original Roblox launcher, just uninstall Bloxstrap and it will automatically revert."
);
}
}
} }
} }

View File

@ -97,5 +97,7 @@
<ui:Button Content="Cancel" Command="{Binding CloseWindowCommand, Mode=OneWay}" /> <ui:Button Content="Cancel" Command="{Binding CloseWindowCommand, Mode=OneWay}" />
</StatusBarItem> </StatusBarItem>
</StatusBar> </StatusBar>
<ui:Dialog x:Name="RootDialog" Title="WPF UI" Grid.Row="1" Grid.RowSpan="2" ButtonLeftVisibility="Collapsed" ButtonRightName="Continue" DialogHeight="225" DialogWidth="430" />
</Grid> </Grid>
</ui:UiWindow> </ui:UiWindow>

View File

@ -15,12 +15,14 @@ namespace Bloxstrap.Views
public partial class MainWindow : INavigationWindow public partial class MainWindow : INavigationWindow
{ {
private readonly IThemeService _themeService = new ThemeService(); private readonly IThemeService _themeService = new ThemeService();
private readonly IDialogService _dialogService = new DialogService();
public MainWindow() public MainWindow()
{ {
DataContext = new MainWindowViewModel(this); DataContext = new MainWindowViewModel(this, _dialogService);
SetTheme(); SetTheme();
InitializeComponent(); InitializeComponent();
_dialogService.SetDialogControl(RootDialog);
} }
public void SetTheme() public void SetTheme()