mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Remove install location changing post installation
This commit is contained in:
parent
cf09956258
commit
517546087c
@ -178,8 +178,6 @@ namespace Bloxstrap
|
|||||||
|
|
||||||
await CheckLatestVersion();
|
await CheckLatestVersion();
|
||||||
|
|
||||||
CheckInstallMigration();
|
|
||||||
|
|
||||||
// install/update roblox if we're running for the first time, needs updating, or the player location doesn't exist
|
// install/update roblox if we're running for the first time, needs updating, or the player location doesn't exist
|
||||||
if (App.IsFirstRun || _latestVersionGuid != App.State.Prop.VersionGuid || !File.Exists(_playerLocation))
|
if (App.IsFirstRun || _latestVersionGuid != App.State.Prop.VersionGuid || !File.Exists(_playerLocation))
|
||||||
await InstallLatestVersion();
|
await InstallLatestVersion();
|
||||||
@ -477,71 +475,6 @@ namespace Bloxstrap
|
|||||||
App.Logger.WriteLine(LOG_IDENT, $"Registered as {totalSize} KB");
|
App.Logger.WriteLine(LOG_IDENT, $"Registered as {totalSize} KB");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckInstallMigration()
|
|
||||||
{
|
|
||||||
const string LOG_IDENT = "Bootstrapper::CheckInstallMigration";
|
|
||||||
|
|
||||||
// check if we've changed our install location since the last time we started
|
|
||||||
// in which case, we'll have to copy over all our folders so we don't lose any mods and stuff
|
|
||||||
|
|
||||||
using RegistryKey? applicationKey = Registry.CurrentUser.OpenSubKey($@"Software\{App.ProjectName}", true);
|
|
||||||
|
|
||||||
string? oldInstallLocation = (string?)applicationKey?.GetValue("OldInstallLocation");
|
|
||||||
|
|
||||||
if (applicationKey is null || oldInstallLocation is null || oldInstallLocation == Paths.Base)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SetStatus("Migrating install location...");
|
|
||||||
|
|
||||||
if (Directory.Exists(oldInstallLocation))
|
|
||||||
{
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, $"Moving all files in {oldInstallLocation} to {Paths.Base}...");
|
|
||||||
|
|
||||||
foreach (string oldFileLocation in Directory.GetFiles(oldInstallLocation, "*.*", SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
string relativeFile = oldFileLocation.Substring(oldInstallLocation.Length + 1);
|
|
||||||
string newFileLocation = Path.Combine(Paths.Base, relativeFile);
|
|
||||||
string? newDirectory = Path.GetDirectoryName(newFileLocation);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!String.IsNullOrEmpty(newDirectory))
|
|
||||||
Directory.CreateDirectory(newDirectory);
|
|
||||||
|
|
||||||
File.Move(oldFileLocation, newFileLocation, true);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, $"Failed to move {oldFileLocation} to {newFileLocation}! {ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Directory.Delete(oldInstallLocation, true);
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, "Deleted old install location");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, $"Failed to delete old install location! {ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
applicationKey.DeleteValue("OldInstallLocation");
|
|
||||||
|
|
||||||
// allow shortcuts to be re-registered
|
|
||||||
if (Directory.Exists(Paths.StartMenu))
|
|
||||||
Directory.Delete(Paths.StartMenu, true);
|
|
||||||
|
|
||||||
if (File.Exists(DesktopShortcutLocation))
|
|
||||||
{
|
|
||||||
File.Delete(DesktopShortcutLocation);
|
|
||||||
App.Settings.Prop.CreateDesktopIcon = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
App.Logger.WriteLine(LOG_IDENT, "Finished migrating install location!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void CheckInstall()
|
public static void CheckInstall()
|
||||||
{
|
{
|
||||||
const string LOG_IDENT = "Bootstrapper::CheckInstall";
|
const string LOG_IDENT = "Bootstrapper::CheckInstall";
|
||||||
@ -746,7 +679,7 @@ namespace Bloxstrap
|
|||||||
// if the folder we're installed to does not end with "Bloxstrap", we're installed to a user-selected folder
|
// if the folder we're installed to does not end with "Bloxstrap", we're installed to a user-selected folder
|
||||||
// in which case, chances are they chose to install to somewhere they didn't really mean to (prior to the added warning in 2.4.0)
|
// in which case, chances are they chose to install to somewhere they didn't really mean to (prior to the added warning in 2.4.0)
|
||||||
// if so, we're walking on eggshells and have to ensure we only clean up what we need to clean up
|
// if so, we're walking on eggshells and have to ensure we only clean up what we need to clean up
|
||||||
bool cautiousUninstall = !Paths.Base.EndsWith(App.ProjectName);
|
bool cautiousUninstall = !Paths.Base.ToLower().EndsWith(App.ProjectName.ToLower());
|
||||||
|
|
||||||
var cleanupSequence = new List<Action>
|
var cleanupSequence = new List<Action>
|
||||||
{
|
{
|
||||||
@ -1418,7 +1351,8 @@ namespace Bloxstrap
|
|||||||
App.Logger.WriteLine(LOG_IDENT, $"An exception occurred after downloading {totalBytesRead} bytes. ({i}/{maxTries})");
|
App.Logger.WriteLine(LOG_IDENT, $"An exception occurred after downloading {totalBytesRead} bytes. ({i}/{maxTries})");
|
||||||
App.Logger.WriteException(LOG_IDENT, ex);
|
App.Logger.WriteException(LOG_IDENT, ex);
|
||||||
|
|
||||||
File.Delete(packageLocation);
|
if (File.Exists(packageLocation))
|
||||||
|
File.Delete(packageLocation);
|
||||||
|
|
||||||
if (i >= maxTries)
|
if (i >= maxTries)
|
||||||
throw;
|
throw;
|
||||||
|
@ -59,26 +59,24 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<StatusBar x:Name="RootStatusBar" Grid.Row="2" Padding="14,10" Background="{ui:ThemeResource ApplicationBackgroundBrush}" BorderThickness="0,1,0,0">
|
<StatusBar x:Name="RootStatusBar" Grid.Row="2" Padding="14,10" Background="{ui:ThemeResource ApplicationBackgroundBrush}" BorderThickness="0,1,0,0">
|
||||||
<StatusBar.ItemsPanel>
|
<StatusBar.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
</Grid>
|
</Grid>
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</StatusBar.ItemsPanel>
|
</StatusBar.ItemsPanel>
|
||||||
<StatusBarItem Grid.Column="1" Padding="0,0,4,0">
|
<StatusBarItem Grid.Column="1" Padding="0,0,4,0">
|
||||||
<ui:Button Content="{Binding ConfirmButtonText, Mode=OneTime}" Appearance="Primary" Command="{Binding ConfirmSettingsCommand, Mode=OneWay}" IsEnabled="{Binding ConfirmButtonEnabled, Mode=OneWay}" />
|
<ui:Button Content="{Binding ConfirmButtonText, Mode=OneTime}" Appearance="Primary" Command="{Binding ConfirmSettingsCommand, Mode=OneWay}" IsEnabled="{Binding ConfirmButtonEnabled, Mode=OneWay}" />
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
<StatusBarItem Grid.Column="2" Padding="4,0,0,0">
|
<StatusBarItem Grid.Column="2" Padding="4,0,0,0">
|
||||||
<ui:Button Content="Cancel" Command="{Binding CloseWindowCommand, Mode=OneWay}" />
|
<ui:Button Content="Cancel" Command="{Binding CloseWindowCommand, Mode=OneWay}" />
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
</StatusBar>
|
</StatusBar>
|
||||||
|
</Grid>
|
||||||
<ui:Dialog x:Name="RootDialog" Title="WPF UI" Grid.Row="1" Grid.RowSpan="2" ButtonLeftVisibility="Collapsed" ButtonRightName="Continue" DialogHeight="225" DialogWidth="430" />
|
|
||||||
</Grid>
|
|
||||||
</ui:UiWindow>
|
</ui:UiWindow>
|
||||||
|
@ -15,16 +15,14 @@ namespace Bloxstrap.UI.Elements.Menu
|
|||||||
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()
|
||||||
{
|
{
|
||||||
App.Logger.WriteLine("MainWindow::MainWindow", "Initializing menu");
|
App.Logger.WriteLine("MainWindow::MainWindow", "Initializing menu");
|
||||||
|
|
||||||
DataContext = new MainWindowViewModel(this, _dialogService);
|
DataContext = new MainWindowViewModel(this);
|
||||||
SetTheme();
|
SetTheme();
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_dialogService.SetDialogControl(RootDialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTheme()
|
public void SetTheme()
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Bloxstrap.UI.ViewModels.Menu;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -14,6 +13,8 @@ using System.Windows.Media.Imaging;
|
|||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
using Bloxstrap.UI.ViewModels.Menu;
|
||||||
|
|
||||||
namespace Bloxstrap.UI.Elements.Menu.Pages
|
namespace Bloxstrap.UI.Elements.Menu.Pages
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -3,64 +3,77 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels"
|
|
||||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||||
|
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Menu.Pages"
|
||||||
|
xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels"
|
||||||
|
xmlns:viewmodels="clr-namespace:Bloxstrap.UI.ViewModels.Menu"
|
||||||
|
d:DataContext="{d:DesignInstance Type=viewmodels:InstallationViewModel}"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
Title="InstallationPage"
|
Title="InstallationPage">
|
||||||
Scrollable="True">
|
|
||||||
<StackPanel Margin="0,0,14,14">
|
|
||||||
<TextBlock Text="Configure how Bloxstrap/Roblox is installed." FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
|
||||||
|
|
||||||
<ui:CardExpander Margin="0,16,0,0" IsExpanded="True">
|
<StackPanel Margin="0,0,14,14">
|
||||||
<ui:CardExpander.Header>
|
<TextBlock Text="Configure how Bloxstrap/Roblox is installed." FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
||||||
<StackPanel>
|
|
||||||
<TextBlock FontSize="14" Text="Install Location" />
|
|
||||||
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Choose where Bloxstrap should be installed to." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
|
||||||
</StackPanel>
|
|
||||||
</ui:CardExpander.Header>
|
|
||||||
<Grid>
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<TextBox Grid.Column="0" Margin="0,0,4,0" Text="{Binding InstallLocation, Mode=TwoWay}" />
|
|
||||||
<ui:Button Grid.Column="1" Margin="4,0,4,0" Height="35" Icon="Folder24" Content="Browse" Command="{Binding BrowseInstallLocationCommand}" />
|
|
||||||
<ui:Button Grid.Column="2" Margin="4,0,0,0" Height="35" Icon="ArrowCounterclockwise24" Content="Reset" Command="{Binding ResetInstallLocationCommand}" />
|
|
||||||
</Grid>
|
|
||||||
</ui:CardExpander>
|
|
||||||
|
|
||||||
<Grid Margin="0,8,0,0">
|
<ui:CardExpander Margin="0,16,0,0" IsExpanded="True">
|
||||||
<Grid.Style>
|
<ui:CardExpander.Style>
|
||||||
<Style TargetType="Grid">
|
<Style TargetType="ui:CardExpander" BasedOn="{StaticResource {x:Type ui:CardExpander}}">
|
||||||
<Setter Property="Visibility" Value="Collapsed" />
|
<Setter Property="Visibility" Value="Collapsed" />
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<DataTrigger Binding="{Binding Source={x:Static models:GlobalViewModel.IsNotFirstRun}}" Value="True">
|
<DataTrigger Binding="{Binding Source={x:Static models:GlobalViewModel.IsNotFirstRun}}" Value="False">
|
||||||
<Setter Property="Visibility" Value="Visible" />
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
</Grid.Style>
|
</ui:CardExpander.Style>
|
||||||
|
<ui:CardExpander.Header>
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock FontSize="14" Text="Install Location" />
|
||||||
|
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Choose where Bloxstrap should be installed to." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||||
|
</StackPanel>
|
||||||
|
</ui:CardExpander.Header>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBox Grid.Column="0" Margin="0,0,4,0" Text="{Binding InstallLocation, Mode=TwoWay}" />
|
||||||
|
<ui:Button Grid.Column="1" Margin="4,0,4,0" Height="35" Icon="Folder24" Content="Browse" Command="{Binding BrowseInstallLocationCommand}" />
|
||||||
|
<ui:Button Grid.Column="2" Margin="4,0,0,0" Height="35" Icon="ArrowCounterclockwise24" Content="Reset" Command="{Binding ResetInstallLocationCommand}" />
|
||||||
|
</Grid>
|
||||||
|
</ui:CardExpander>
|
||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid Margin="0,8,0,0">
|
||||||
<ColumnDefinition Width="*" />
|
<Grid.Style>
|
||||||
<ColumnDefinition Width="*" />
|
<Style TargetType="Grid">
|
||||||
</Grid.ColumnDefinitions>
|
<Setter Property="Visibility" Value="Collapsed" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding Source={x:Static models:GlobalViewModel.IsNotFirstRun}}" Value="True">
|
||||||
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Grid.Style>
|
||||||
|
|
||||||
<ui:CardAction Grid.Column="0" x:Name="OpenFolderCardAction" Margin="0,0,4,0" Icon="Folder24" Command="{Binding OpenFolderCommand}" >
|
<Grid.ColumnDefinitions>
|
||||||
<StackPanel>
|
<ColumnDefinition Width="*" />
|
||||||
<TextBlock FontSize="14" Text="Open Installation Folder" />
|
<ColumnDefinition Width="*" />
|
||||||
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Where Bloxstrap is currently installed to." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
</Grid.ColumnDefinitions>
|
||||||
</StackPanel>
|
|
||||||
</ui:CardAction>
|
|
||||||
|
|
||||||
<ui:CardAction Grid.Column="1" Margin="4,0,0,0" Icon="UninstallApp24" Command="models:GlobalViewModel.OpenWebpageCommand" CommandParameter="https://github.com/pizzaboxer/bloxstrap/wiki/Uninstalling-Bloxstrap">
|
<ui:CardAction Grid.Column="0" x:Name="OpenFolderCardAction" Margin="0,0,4,0" Icon="Folder24" Command="{Binding OpenFolderCommand}" >
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock FontSize="14" Text="Looking to uninstall?" />
|
<TextBlock FontSize="14" Text="Open Installation Folder" />
|
||||||
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Here's a guide on how to uninstall Bloxstrap." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Where Bloxstrap is currently installed to." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ui:CardAction>
|
</ui:CardAction>
|
||||||
</Grid>
|
|
||||||
</StackPanel>
|
<ui:CardAction Grid.Column="1" Margin="4,0,0,0" Icon="UninstallApp24" Command="models:GlobalViewModel.OpenWebpageCommand" CommandParameter="https://github.com/pizzaboxer/bloxstrap/wiki/Uninstalling-Bloxstrap">
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock FontSize="14" Text="Looking to uninstall?" />
|
||||||
|
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Here's a guide on how to uninstall Bloxstrap." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||||
|
</StackPanel>
|
||||||
|
</ui:CardAction>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
</ui:UiPage>
|
</ui:UiPage>
|
||||||
|
@ -1,4 +1,19 @@
|
|||||||
using Bloxstrap.UI.ViewModels.Menu;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
using Bloxstrap.UI.ViewModels.Menu;
|
||||||
|
|
||||||
namespace Bloxstrap.UI.Elements.Menu.Pages
|
namespace Bloxstrap.UI.Elements.Menu.Pages
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,6 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
public class MainWindowViewModel : NotifyPropertyChangedViewModel
|
public class MainWindowViewModel : NotifyPropertyChangedViewModel
|
||||||
{
|
{
|
||||||
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
|
|
||||||
|
|
||||||
public ICommand CloseWindowCommand => new RelayCommand(CloseWindow);
|
public ICommand CloseWindowCommand => new RelayCommand(CloseWindow);
|
||||||
public ICommand ConfirmSettingsCommand => new RelayCommand(ConfirmSettings);
|
public ICommand ConfirmSettingsCommand => new RelayCommand(ConfirmSettings);
|
||||||
@ -24,25 +22,31 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
public string ConfirmButtonText => App.IsFirstRun ? "Install" : "Save";
|
public string ConfirmButtonText => App.IsFirstRun ? "Install" : "Save";
|
||||||
public bool ConfirmButtonEnabled { get; set; } = true;
|
public bool ConfirmButtonEnabled { get; set; } = true;
|
||||||
|
|
||||||
public MainWindowViewModel(Window window, IDialogService dialogService)
|
public MainWindowViewModel(Window window)
|
||||||
{
|
{
|
||||||
_window = window;
|
_window = window;
|
||||||
_dialogService = dialogService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseWindow() => _window.Close();
|
private void CloseWindow() => _window.Close();
|
||||||
|
|
||||||
private void ConfirmSettings()
|
private void ConfirmSettings()
|
||||||
{
|
{
|
||||||
|
if (!App.IsFirstRun)
|
||||||
|
{
|
||||||
|
App.ShouldSaveConfigs = true;
|
||||||
|
App.FastFlags.Save();
|
||||||
|
CloseWindow();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(App.BaseDirectory))
|
if (string.IsNullOrEmpty(App.BaseDirectory))
|
||||||
{
|
{
|
||||||
Controls.ShowMessageBox("You must set an install location", MessageBoxImage.Error);
|
Controls.ShowMessageBox("You must set an install location", MessageBoxImage.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldCheckInstallLocation = App.IsFirstRun || App.BaseDirectory != _originalBaseDirectory;
|
if (NavigationVisibility == Visibility.Visible)
|
||||||
|
|
||||||
if (shouldCheckInstallLocation && NavigationVisibility == Visibility.Visible)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -105,52 +109,27 @@ namespace Bloxstrap.UI.ViewModels.Menu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App.IsFirstRun)
|
if (NavigationVisibility == Visibility.Visible)
|
||||||
{
|
{
|
||||||
if (NavigationVisibility == Visibility.Visible)
|
((INavigationWindow)_window).Navigate(typeof(PreInstallPage));
|
||||||
|
|
||||||
|
NavigationVisibility = Visibility.Collapsed;
|
||||||
|
OnPropertyChanged(nameof(NavigationVisibility));
|
||||||
|
|
||||||
|
ConfirmButtonEnabled = false;
|
||||||
|
OnPropertyChanged(nameof(ConfirmButtonEnabled));
|
||||||
|
|
||||||
|
Task.Run(async delegate
|
||||||
{
|
{
|
||||||
((INavigationWindow)_window).Navigate(typeof(PreInstallPage));
|
await Task.Delay(3000);
|
||||||
|
|
||||||
NavigationVisibility = Visibility.Collapsed;
|
ConfirmButtonEnabled = true;
|
||||||
OnPropertyChanged(nameof(NavigationVisibility));
|
|
||||||
|
|
||||||
ConfirmButtonEnabled = false;
|
|
||||||
OnPropertyChanged(nameof(ConfirmButtonEnabled));
|
OnPropertyChanged(nameof(ConfirmButtonEnabled));
|
||||||
|
});
|
||||||
Task.Run(async delegate
|
|
||||||
{
|
|
||||||
await Task.Delay(3000);
|
|
||||||
|
|
||||||
ConfirmButtonEnabled = true;
|
|
||||||
OnPropertyChanged(nameof(ConfirmButtonEnabled));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
App.IsSetupComplete = true;
|
|
||||||
CloseWindow();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App.ShouldSaveConfigs = true;
|
App.IsSetupComplete = true;
|
||||||
App.FastFlags.Save();
|
|
||||||
|
|
||||||
if (shouldCheckInstallLocation)
|
|
||||||
{
|
|
||||||
App.Logger.WriteLine("MainWindowViewModel::ConfirmSettings", $"Changing install location from {_originalBaseDirectory} to {App.BaseDirectory}");
|
|
||||||
|
|
||||||
Controls.ShowMessageBox(
|
|
||||||
$"{App.ProjectName} will install to the new location you've set the next time it runs.",
|
|
||||||
MessageBoxImage.Information
|
|
||||||
);
|
|
||||||
|
|
||||||
using RegistryKey registryKey = Registry.CurrentUser.CreateSubKey($@"Software\{App.ProjectName}");
|
|
||||||
registryKey.SetValue("InstallLocation", App.BaseDirectory);
|
|
||||||
registryKey.SetValue("OldInstallLocation", _originalBaseDirectory);
|
|
||||||
Paths.Initialize(App.BaseDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseWindow();
|
CloseWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user