Skip to content

Commit

Permalink
Changes from Code Review and fixing install notification never changi…
Browse files Browse the repository at this point in the history
…ng to complete
  • Loading branch information
gablm committed Mar 13, 2024
1 parent 6d0306d commit 68fc916
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,18 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac

settingsButton.Click += async (_, _) => await Dialogs.SimpleDialogs.Dialog_DownloadSettings(_parentContainer, CurrentGameProperty);

StackPanel controlButtons = new StackPanel
{
Orientation = Orientation.Horizontal,
HorizontalAlignment = HorizontalAlignment.Right,
Children =
{
settingsButton,
cancelButton
}
};
_parentContainer.Children.Add(controlButtons);

EventHandler<TotalPerfileProgress> ProgressChangedEventHandler = (_, args) => activity?.Dispatch(() =>
{
progressBar.Value = args!.ProgressTotalPercentage;
Expand All @@ -247,7 +259,8 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
if (args.IsCanceled)
{
cancelButton.IsEnabled = false;
cancelButton.Visibility = Visibility.Collapsed;
settingsButton.IsEnabled = false;
controlButtons.Visibility = Visibility.Collapsed;
_parentNotifUI.Severity = InfoBarSeverity.Error;
_parentNotifUI.Title = string.Format(Lang._BackgroundNotification.NotifBadge_Error!, activityTitle);
_parentNotifUI.IsClosable = true;
Expand All @@ -256,7 +269,8 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
if (args.IsCompleted)
{
cancelButton.IsEnabled = false;
cancelButton.Visibility = Visibility.Collapsed;
settingsButton.IsEnabled = false;
controlButtons.Visibility = Visibility.Collapsed;
_parentNotifUI.Severity = InfoBarSeverity.Success;
_parentNotifUI.Title = string.Format(Lang._BackgroundNotification.NotifBadge_Completed!, activityTitle);
_parentNotifUI.IsClosable = true;
Expand All @@ -265,7 +279,8 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
if (args.IsRunning)
{
cancelButton.IsEnabled = true;
cancelButton.Visibility = Visibility.Visible;
settingsButton.IsEnabled = true;
controlButtons.Visibility = Visibility.Visible;
_parentNotifUI.Severity = InfoBarSeverity.Informational;
_parentNotifUI.Title = activityTitle;
_parentNotifUI.IsClosable = false;
Expand All @@ -289,17 +304,6 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
Detach(hashID);
};

_parentContainer.Children.Add(new StackPanel
{
Orientation = Orientation.Horizontal,
HorizontalAlignment = HorizontalAlignment.Right,
Children =
{
settingsButton,
cancelButton
}
});

NotificationSender.SendCustomNotification(hashID, _parentNotifUI);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected enum MigrateFromLauncherType { Official, BetterHi3Launcher, Steam, Unk
#region Public Properties
public bool IsRunning { get; protected set; }
public event EventHandler FlushingTrigger;
public bool StartAfterInstall { get; set; } = false;
public bool StartAfterInstall { get; set; }
#endregion

public InstallManagerBase(UIElement parentUI, IGameVersionCheck GameVersionManager)
Expand Down
30 changes: 15 additions & 15 deletions CollapseLauncher/XAMLs/MainApp/Pages/Dialogs/SimpleDialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -741,13 +741,13 @@ public static async Task<Tuple<ContentDialogResult, bool>> Dialog_ShortcutCreati
{
StackPanel panel = new StackPanel { Orientation = Orientation.Vertical, MaxWidth = 500 };
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.ShortcutCreationConfirmSubtitle1, Margin = new Thickness(0, 2, 0, 4), HorizontalAlignment = HorizontalAlignment.Center });
TextBlock pathText = new TextBlock { HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 4, 0, 4) };
TextBlock pathText = new TextBlock { HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 4, 0, 4) };
pathText.Inlines.Add(new Run() { Text = path, FontWeight = FontWeights.Bold });
panel.Children.Add(pathText);
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.ShortcutCreationConfirmSubtitle2, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 4, 0, 4), HorizontalAlignment = HorizontalAlignment.Center });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.ShortcutCreationConfirmSubtitle2, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 4, 0, 4), HorizontalAlignment = HorizontalAlignment.Center });

CheckBox playOnLoad = new CheckBox() {
Content = new TextBlock { Text = Lang._Dialogs.ShortcutCreationConfirmCheckBox, TextWrapping = TextWrapping.Wrap },
Content = new TextBlock { Text = Lang._Dialogs.ShortcutCreationConfirmCheckBox, TextWrapping = TextWrapping.WrapWholeWords },
Margin = new Thickness(0, 4, 0, -8),
HorizontalAlignment = HorizontalAlignment.Center
};
Expand All @@ -769,16 +769,16 @@ public static async Task<ContentDialogResult> Dialog_ShortcutCreationSuccess(UIE
{
StackPanel panel = new StackPanel { Orientation = Orientation.Vertical, MaxWidth = 500 };
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.ShortcutCreationSuccessSubtitle1, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, 2, 0, 4) });
TextBlock pathText = new TextBlock { HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 4, 0, 4) };
TextBlock pathText = new TextBlock { HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 4, 0, 4) };
pathText.Inlines.Add(new Run() { Text = Lang._Dialogs.ShortcutCreationSuccessSubtitle2 });
pathText.Inlines.Add(new Run() { Text = path, FontWeight = FontWeights.Bold });
panel.Children.Add(pathText);

if (play)
{
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.ShortcutCreationSuccessSubtitle3, FontWeight = FontWeights.Bold, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 8, 0, 4) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.ShortcutCreationSuccessSubtitle4, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.ShortcutCreationSuccessSubtitle5, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.ShortcutCreationSuccessSubtitle4, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.ShortcutCreationSuccessSubtitle5, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 2, 0, 2) });
}

return await SpawnDialog(
Expand All @@ -794,8 +794,8 @@ public static async Task<Tuple<ContentDialogResult, bool>> Dialog_SteamShortcutC
{
StackPanel panel = new StackPanel { Orientation = Orientation.Vertical, MaxWidth = 500 };

panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationConfirmSubtitle1, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 4, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationConfirmSubtitle2, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 4) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationConfirmSubtitle1, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 4, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationConfirmSubtitle2, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 2, 0, 4) });

CheckBox playOnLoad = new CheckBox()
{
Expand All @@ -820,16 +820,16 @@ public static async Task<Tuple<ContentDialogResult, bool>> Dialog_SteamShortcutC
public static async Task<ContentDialogResult> Dialog_SteamShortcutCreationSuccess(UIElement Content, bool play = false)
{
StackPanel panel = new StackPanel { Orientation = Orientation.Vertical, MaxWidth = 500 };
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle1, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 4) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle2, FontWeight = FontWeights.Bold, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 8, 0, 4) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle1, HorizontalAlignment = HorizontalAlignment.Center, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 2, 0, 4) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle2, FontWeight = FontWeights.Bold, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 8, 0, 4) });
if (play)
{
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle3, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle7, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle3, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle7, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 2, 0, 2) });
}
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle5, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle4, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle6, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 2, 0, 4) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle5, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle4, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 2, 0, 2) });
panel.Children.Add(new TextBlock { Text = Lang._Dialogs.SteamShortcutCreationSuccessSubtitle6, TextWrapping = TextWrapping.WrapWholeWords, Margin = new Thickness(0, 2, 0, 4) });

return await SpawnDialog(
Lang._Dialogs.SteamShortcutCreationSuccessTitle,
Expand Down
6 changes: 4 additions & 2 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ private async void InstallGameDialog(object sender, RoutedEventArgs e)

await CurrentGameProperty._GameInstall.StartPackageInstallation();
CurrentGameProperty._GameInstall.ApplyGameConfig(true);
if (CurrentGameProperty._GameInstall.StartAfterInstall)
if (CurrentGameProperty._GameInstall.StartAfterInstall && CurrentGameProperty._GameVersion.IsGameInstalled())
StartGame(null, null);
}
catch (TaskCanceledException)
Expand Down Expand Up @@ -1159,6 +1159,7 @@ private async void InstallGameDialog(object sender, RoutedEventArgs e)
CurrentGameProperty._GameInstall.StartAfterInstall = false;
CurrentGameProperty._GameInstall.ProgressChanged -= GameInstall_ProgressChanged;
CurrentGameProperty._GameInstall.StatusChanged -= GameInstall_StatusChanged;
await Task.Delay(200);
CurrentGameProperty._GameInstall.Flush();
ReturnToHomePage();
}
Expand Down Expand Up @@ -1969,7 +1970,7 @@ private async void UpdateGameDialog(object sender, RoutedEventArgs e)

await CurrentGameProperty._GameInstall.StartPackageInstallation();
CurrentGameProperty._GameInstall.ApplyGameConfig(true);
if (CurrentGameProperty._GameInstall.StartAfterInstall)
if (CurrentGameProperty._GameInstall.StartAfterInstall && CurrentGameProperty._GameVersion.IsGameInstalled())
StartGame(null, null);
}
catch (TaskCanceledException)
Expand Down Expand Up @@ -1998,6 +1999,7 @@ private async void UpdateGameDialog(object sender, RoutedEventArgs e)
CurrentGameProperty._GameInstall.StartAfterInstall = false;
CurrentGameProperty._GameInstall.ProgressChanged -= GameInstall_ProgressChanged;
CurrentGameProperty._GameInstall.StatusChanged -= GameInstall_StatusChanged;
await Task.Delay(200);
CurrentGameProperty._GameInstall.Flush();
ReturnToHomePage();
}
Expand Down

0 comments on commit 68fc916

Please sign in to comment.