|
|
@ -11,6 +11,7 @@ using StabilityMatrix.Avalonia.Controls; |
|
|
|
using StabilityMatrix.Avalonia.Services; |
|
|
|
using StabilityMatrix.Avalonia.Services; |
|
|
|
using StabilityMatrix.Avalonia.ViewModels.Base; |
|
|
|
using StabilityMatrix.Avalonia.ViewModels.Base; |
|
|
|
using StabilityMatrix.Avalonia.ViewModels.Dialogs; |
|
|
|
using StabilityMatrix.Avalonia.ViewModels.Dialogs; |
|
|
|
|
|
|
|
using StabilityMatrix.Avalonia.ViewModels.Progress; |
|
|
|
using StabilityMatrix.Avalonia.Views; |
|
|
|
using StabilityMatrix.Avalonia.Views; |
|
|
|
using StabilityMatrix.Avalonia.Views.Dialogs; |
|
|
|
using StabilityMatrix.Avalonia.Views.Dialogs; |
|
|
|
using StabilityMatrix.Core.Attributes; |
|
|
|
using StabilityMatrix.Core.Attributes; |
|
|
@ -27,13 +28,13 @@ public partial class MainWindowViewModel : ViewModelBase |
|
|
|
private readonly ITrackedDownloadService trackedDownloadService; |
|
|
|
private readonly ITrackedDownloadService trackedDownloadService; |
|
|
|
private readonly IDiscordRichPresenceService discordRichPresenceService; |
|
|
|
private readonly IDiscordRichPresenceService discordRichPresenceService; |
|
|
|
public string Greeting => "Welcome to Avalonia!"; |
|
|
|
public string Greeting => "Welcome to Avalonia!"; |
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
private PageViewModelBase? currentPage; |
|
|
|
private PageViewModelBase? currentPage; |
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
private object? selectedCategory; |
|
|
|
private object? selectedCategory; |
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
private List<PageViewModelBase> pages = new(); |
|
|
|
private List<PageViewModelBase> pages = new(); |
|
|
|
|
|
|
|
|
|
|
@ -44,16 +45,17 @@ public partial class MainWindowViewModel : ViewModelBase |
|
|
|
public UpdateViewModel UpdateViewModel { get; init; } |
|
|
|
public UpdateViewModel UpdateViewModel { get; init; } |
|
|
|
|
|
|
|
|
|
|
|
public MainWindowViewModel( |
|
|
|
public MainWindowViewModel( |
|
|
|
ISettingsManager settingsManager, |
|
|
|
ISettingsManager settingsManager, |
|
|
|
IDiscordRichPresenceService discordRichPresenceService, |
|
|
|
IDiscordRichPresenceService discordRichPresenceService, |
|
|
|
ServiceManager<ViewModelBase> dialogFactory, |
|
|
|
ServiceManager<ViewModelBase> dialogFactory, |
|
|
|
ITrackedDownloadService trackedDownloadService) |
|
|
|
ITrackedDownloadService trackedDownloadService |
|
|
|
|
|
|
|
) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.settingsManager = settingsManager; |
|
|
|
this.settingsManager = settingsManager; |
|
|
|
this.dialogFactory = dialogFactory; |
|
|
|
this.dialogFactory = dialogFactory; |
|
|
|
this.discordRichPresenceService = discordRichPresenceService; |
|
|
|
this.discordRichPresenceService = discordRichPresenceService; |
|
|
|
this.trackedDownloadService = trackedDownloadService; |
|
|
|
this.trackedDownloadService = trackedDownloadService; |
|
|
|
|
|
|
|
|
|
|
|
ProgressManagerViewModel = dialogFactory.Get<ProgressManagerViewModel>(); |
|
|
|
ProgressManagerViewModel = dialogFactory.Get<ProgressManagerViewModel>(); |
|
|
|
UpdateViewModel = dialogFactory.Get<UpdateViewModel>(); |
|
|
|
UpdateViewModel = dialogFactory.Get<UpdateViewModel>(); |
|
|
|
} |
|
|
|
} |
|
|
@ -61,7 +63,7 @@ public partial class MainWindowViewModel : ViewModelBase |
|
|
|
public override void OnLoaded() |
|
|
|
public override void OnLoaded() |
|
|
|
{ |
|
|
|
{ |
|
|
|
base.OnLoaded(); |
|
|
|
base.OnLoaded(); |
|
|
|
|
|
|
|
|
|
|
|
// Set only if null, since this may be called again when content dialogs open |
|
|
|
// Set only if null, since this may be called again when content dialogs open |
|
|
|
CurrentPage ??= Pages.FirstOrDefault(); |
|
|
|
CurrentPage ??= Pages.FirstOrDefault(); |
|
|
|
SelectedCategory ??= Pages.FirstOrDefault(); |
|
|
|
SelectedCategory ??= Pages.FirstOrDefault(); |
|
|
@ -72,24 +74,25 @@ public partial class MainWindowViewModel : ViewModelBase |
|
|
|
await base.OnLoadedAsync(); |
|
|
|
await base.OnLoadedAsync(); |
|
|
|
|
|
|
|
|
|
|
|
// Skip if design mode |
|
|
|
// Skip if design mode |
|
|
|
if (Design.IsDesignMode) return; |
|
|
|
if (Design.IsDesignMode) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (!await EnsureDataDirectory()) |
|
|
|
if (!await EnsureDataDirectory()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// False if user exited dialog, shutdown app |
|
|
|
// False if user exited dialog, shutdown app |
|
|
|
App.Shutdown(); |
|
|
|
App.Shutdown(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Initialize Discord Rich Presence (this needs LibraryDir so is set here) |
|
|
|
// Initialize Discord Rich Presence (this needs LibraryDir so is set here) |
|
|
|
discordRichPresenceService.UpdateState(); |
|
|
|
discordRichPresenceService.UpdateState(); |
|
|
|
|
|
|
|
|
|
|
|
// Load in-progress downloads |
|
|
|
// Load in-progress downloads |
|
|
|
ProgressManagerViewModel.AddDownloads(trackedDownloadService.Downloads); |
|
|
|
ProgressManagerViewModel.AddDownloads(trackedDownloadService.Downloads); |
|
|
|
|
|
|
|
|
|
|
|
// Index checkpoints if we dont have |
|
|
|
// Index checkpoints if we dont have |
|
|
|
Task.Run(() => settingsManager.IndexCheckpoints()).SafeFireAndForget(); |
|
|
|
Task.Run(() => settingsManager.IndexCheckpoints()).SafeFireAndForget(); |
|
|
|
|
|
|
|
|
|
|
|
if (!settingsManager.Settings.InstalledPackages.Any()) |
|
|
|
if (!settingsManager.Settings.InstalledPackages.Any()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var viewModel = dialogFactory.Get<OneClickInstallViewModel>(); |
|
|
|
var viewModel = dialogFactory.Get<OneClickInstallViewModel>(); |
|
|
@ -98,17 +101,15 @@ public partial class MainWindowViewModel : ViewModelBase |
|
|
|
IsPrimaryButtonEnabled = false, |
|
|
|
IsPrimaryButtonEnabled = false, |
|
|
|
IsSecondaryButtonEnabled = false, |
|
|
|
IsSecondaryButtonEnabled = false, |
|
|
|
IsFooterVisible = false, |
|
|
|
IsFooterVisible = false, |
|
|
|
Content = new OneClickInstallDialog |
|
|
|
Content = new OneClickInstallDialog { DataContext = viewModel }, |
|
|
|
{ |
|
|
|
|
|
|
|
DataContext = viewModel |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
EventManager.Instance.OneClickInstallFinished += (_, skipped) => |
|
|
|
EventManager.Instance.OneClickInstallFinished += (_, skipped) => |
|
|
|
{ |
|
|
|
{ |
|
|
|
dialog.Hide(); |
|
|
|
dialog.Hide(); |
|
|
|
if (skipped) return; |
|
|
|
if (skipped) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
EventManager.Instance.OnTeachingTooltipNeeded(); |
|
|
|
EventManager.Instance.OnTeachingTooltipNeeded(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -125,24 +126,25 @@ public partial class MainWindowViewModel : ViewModelBase |
|
|
|
if (!settingsManager.TryFindLibrary()) |
|
|
|
if (!settingsManager.TryFindLibrary()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var result = await ShowSelectDataDirectoryDialog(); |
|
|
|
var result = await ShowSelectDataDirectoryDialog(); |
|
|
|
if (!result) return false; |
|
|
|
if (!result) |
|
|
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Try to find library again, should be found now |
|
|
|
// Try to find library again, should be found now |
|
|
|
if (!settingsManager.TryFindLibrary()) |
|
|
|
if (!settingsManager.TryFindLibrary()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
throw new Exception("Could not find library after setting path"); |
|
|
|
throw new Exception("Could not find library after setting path"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Tell LaunchPage to load any packages if they selected an existing directory |
|
|
|
// Tell LaunchPage to load any packages if they selected an existing directory |
|
|
|
EventManager.Instance.OnInstalledPackagesChanged(); |
|
|
|
EventManager.Instance.OnInstalledPackagesChanged(); |
|
|
|
|
|
|
|
|
|
|
|
// Check if there are old packages, if so show migration dialog |
|
|
|
// Check if there are old packages, if so show migration dialog |
|
|
|
// TODO: Migration dialog |
|
|
|
// TODO: Migration dialog |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Shows the select data directory dialog. |
|
|
|
/// Shows the select data directory dialog. |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
@ -155,10 +157,7 @@ public partial class MainWindowViewModel : ViewModelBase |
|
|
|
IsPrimaryButtonEnabled = false, |
|
|
|
IsPrimaryButtonEnabled = false, |
|
|
|
IsSecondaryButtonEnabled = false, |
|
|
|
IsSecondaryButtonEnabled = false, |
|
|
|
IsFooterVisible = false, |
|
|
|
IsFooterVisible = false, |
|
|
|
Content = new SelectDataDirectoryDialog |
|
|
|
Content = new SelectDataDirectoryDialog { DataContext = viewModel } |
|
|
|
{ |
|
|
|
|
|
|
|
DataContext = viewModel |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var result = await dialog.ShowAsync(); |
|
|
|
var result = await dialog.ShowAsync(); |
|
|
@ -191,10 +190,7 @@ public partial class MainWindowViewModel : ViewModelBase |
|
|
|
IsPrimaryButtonEnabled = false, |
|
|
|
IsPrimaryButtonEnabled = false, |
|
|
|
IsSecondaryButtonEnabled = false, |
|
|
|
IsSecondaryButtonEnabled = false, |
|
|
|
IsFooterVisible = false, |
|
|
|
IsFooterVisible = false, |
|
|
|
Content = new UpdateDialog |
|
|
|
Content = new UpdateDialog { DataContext = viewModel } |
|
|
|
{ |
|
|
|
|
|
|
|
DataContext = viewModel |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
await dialog.ShowAsync(); |
|
|
|
await dialog.ShowAsync(); |
|
|
|