Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion CollapseLauncher/XAMLs/MainApp/MainPage.Navigation.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using CollapseLauncher.Extension;
using CollapseLauncher.Helper.Loading;
using CollapseLauncher.Helper.Metadata;
using CollapseLauncher.Interfaces;
using CollapseLauncher.Pages;
using CommunityToolkit.WinUI;
using Hi3Helper;
using Hi3Helper.SentryHelper;
using Microsoft.UI;
using Microsoft.UI.Input;
using Microsoft.UI.Xaml;
Expand All @@ -15,6 +17,7 @@
using System.Threading.Tasks;
using static CollapseLauncher.InnerLauncherConfig;
using static CollapseLauncher.Statics.GamePropertyVault;
using static Hi3Helper.Locale;
using static Hi3Helper.Logger;
using static Hi3Helper.Shared.Region.LauncherConfig;

Expand Down Expand Up @@ -51,6 +54,7 @@ void Impl()
FontIcon IconCaches = new FontIcon { Glyph = m_isWindows11 ? "" : "" };
FontIcon IconGameSettings = new FontIcon { Glyph = "" };
FontIcon IconAppSettings = new FontIcon { Glyph = "" };
FontIcon IconFilesCleanup = new FontIcon { Glyph = "" };

if (m_appMode == AppMode.Hi3CacheUpdater)
{
Expand Down Expand Up @@ -109,6 +113,10 @@ void Impl()
break;
}

NavigationViewControl.FooterMenuItems.Add(new NavigationViewItem
{ Icon = IconFilesCleanup, Tag = "filescleanup"}
.BindNavigationViewItemText("_FileCleanupPage", "Title"));

if (NavigationViewControl.SettingsItem is NavigationViewItem SettingsItem)
{
SettingsItem.Icon = IconAppSettings;
Expand Down Expand Up @@ -246,7 +254,7 @@ private void NavView_ItemInvoked(NavigationView sender, NavigationViewItemInvoke
NavigateInnerSwitch(itemTag);
}

private void NavigateInnerSwitch(string itemTag)
private async void NavigateInnerSwitch(string itemTag)
{
if (itemTag == PreviousTag) return;
switch (itemTag)
Expand All @@ -255,6 +263,30 @@ private void NavigateInnerSwitch(string itemTag)
Navigate(typeof(HomePage), itemTag);
break;

case "filescleanup":
LoadingMessageHelper.ShowLoadingFrame();
// Initialize and get game state, then get the latest package info
LoadingMessageHelper.SetMessage(Lang._FileCleanupPage.LoadingTitle,
Lang._FileCleanupPage.LoadingSubtitle2);

try
{
if (CurrentGameProperty?.GameInstall != null)
await CurrentGameProperty.GameInstall.CleanUpGameFiles();
}
catch (Exception ex)
{
LoadingMessageHelper.HideLoadingFrame();
LogWriteLine($"[NavigateInnerSwitch(filescleanup] Error while calling the CleanUpGameFiles method!\r\n{ex}", LogType.Error, true);

ErrorSender.SendException(ex);
}

// Manually reselect last item in toolbar as CleanUp is an overlay
NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems.OfType<NavigationViewItem>()
.FirstOrDefault(x => x.Tag is string tag && tag == PreviousTag);
break;

case "repair":
if (!(GetCurrentGameProperty().GameVersion?.GamePreset.IsRepairEnabled ?? false))
Navigate(typeof(UnavailablePage), itemTag);
Expand Down
Loading