Skip to content

Commit

Permalink
Promote code from main
Browse files Browse the repository at this point in the history
Update installer banner

Fix preload version issues (#230)

* Fix preload version issues

* Delete unused method

As per comment #230 (comment)

Increase HDiffPatch performance by using buffered patch

Adding SIMULATEAPPLYPRELOAD to simulate update from preload data

[Test] Temp. removing deconstruct for some classes

Regarding to the background activity disposing issue

switch to proper buffering

Update Hi3Helper.SharpHDiffPatch

Update Hi3Helper.SharpHDiffPatch

``SharpHDiffPatch`` performance improvements

+ Using SSE2 Vector128 for RLE and data copy
+ Vectorize _TBytesRle_load_stream_mem_add()'s copy process
+ Replace each struct and class's integer props type from ulong to long and int
+ Use its own independent VarInt decoder for int and long
+ Preload Cover Header values
+ Enumerate covers instead of buffering it
+ Reducing event update frequency
+ Using Stream.CopyTo() to copy result buffer to output stream
+ Using long integer for UpdateEvent()

Fix the progress not achieving 100% while completed

Fix Genshin preload not detecting completed packages in chunk

Fix disposing issue with paused preload in background (pt. 2)

Use ``PaimonWhat.png`` sprite for unknown game logo

Fix disposing issue with paused preload in background

Revert back preload box top margin value

Fix crash while back to previous page from ReturnToHomePage

Fix failure on "Release" compilation

Still forgot about this :terikms:

Move game logos to Assets/Images/GameLogo

Fix notif logo went missing :PaimonAngry:

Remove unused ``None`` prop in project file

Making preload to resume back. activity

Return empty list if source is null in ``List<T>.Copy()``

Avoid undisposed events while closing _GameInstall

Use ``GetStreamLength()`` to check preload length

Simplified logo assignment for background activity notif

Avoid potential crash while getting null diffs in preload

Adding SIMULATEPRELOAD constant to simulate preload

Adding ``GetStreamLength()`` to get length via FileInfo

Add ToString() and Increment getter for GameVersion

Add locale for background notif badge

Localize background activity notification strings

+ Rename PageStatics -> GamePropertyVault

Unsubscribe event handler once background activity closes

Making HomePage to resume background install progress

Update Banner

Update feature_request.md

forgot to change this :NotLikeThis:

basically BG folder doesn't exist now and changed to Images, but I apparently forgot to change this one string :derp:

Changes to CDN

- Change Cloudflare URI to be direct to bucket instead of through worker
- Deprecate Statically and jsDelivr as it has problems with Launcher updates and index downloads

Update SECURITY.md

small typo fix for en

Update locales

Change default Collapse DiscordAppID

To fix consistency between Normal and Game Specific logo

added launch target to launch in OOBE mode

Build version indicator (#220)

* added visual indicator for app version

* added temp indicator to distinguish preview from stable

* typo fix

* Complete Version Indicator by Cry0 (#225)

* typo fix

---------

Update README.md

- Add pl Translation Badge
- Added Crowdin and Trello logo/hyperlink

Add missing localization for navigation sidebar

Read byte to string in Discord RPC Activity logger

Rename ``StrToPtrUtf8()`` to ``StrToByteUtf8()``

Fix Discord RPC displays Unicode chars incorrectly

This is due to the string used in .NET is a UTF-16 ones and not UTF-8. To workaround this, we changed the marshal type of the strings in each struct as byte[] with fixed-length: 128 bytes.

This commit also contains a few changes:
- Remove partial modifier on struct
- Change the CharSet of the struct from CharSet.Ansi to CharSet.Unicode
- Use TypeExtensions.IsInstancePropertyEqual<T>() to compare Activity struct

Move TypeExtensions to ``EncTool``

Update locale

Rewrite GameUninstall Method (#222)

* Rewrite GameUninstall Method

In the hope of ACTUALLY fixing #141

* Update GameUninstall Method

- Use Array.Empty instead of null
- Added more documentations (thanks @Cryotechnic)
- Added more logging
- Fixed empty folder checks for folderGameData not working
- Adjusted variable names
- Changed Get to Enumerate (thanks @neon-nyan)

* Use ``override``s to assign delete targets

* Throw on unsupported GI region instead of returning

* Switch global config with local one

* Use Compiled Regex to avoid issues on publish trimming

* Throw on ``AssignUninstallFolders`` if override is unavailable

---------

Co-authored-by: Scald <[email protected]>
Co-authored-by: Iskandar Montano <[email protected]>
Co-authored-by: Cryotechnic <[email protected]>

Force the app to use its own folder as working directory

Rebuild Hi3Helper.Core everytime language file is updated

Update Borderless Screen Settings

- Change name to "Use Borderless Windowed Mode"
- Disable fullscreen when its on and vice versa

Update README.md

Disable Squirrel update on DEBUG builds

Reason: to not have multiple log lines about squirrel not being able to update on debug builds

Merge branch 'main' of https://github.com/neon-nyan/Collapse

Don't throw when invalid launch argument is present

:teriderp:

Fix background disappeared after cancelling update

Bump version

Fix Hi3 Game Repair failed to obtain CG files

Fix ``CGMetadata`` unable to be parsed

Update README.md

Force IsRepairEnabled and IsCacheUpdateEnabled to true on Debug builds

For easier debugging

Co-Authored-By: Iskandar Montano <[email protected]>
Co-Authored-By: Scald <[email protected]>
Co-Authored-By: Cryotechnic <[email protected]>
Co-Authored-By: Kemal Setya Adhi <[email protected]>
  • Loading branch information
5 people committed Aug 15, 2023
1 parent 2208a0b commit b93a333
Show file tree
Hide file tree
Showing 75 changed files with 2,923 additions and 790 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Feature request
about: Suggest an idea for this project
name: Feature/Enhancement request
about: Suggest an idea for new feature or changes
title: "[Request]"
labels: Enhancement
assignees: ''
Expand Down
6 changes: 5 additions & 1 deletion CollapseLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Hi3Helper;
using Hi3Helper;
using Hi3Helper.Shared.Region;
using Microsoft.UI;
using Microsoft.UI.Xaml;
Expand Down Expand Up @@ -40,6 +40,10 @@ public App()
m_window = new MainWindow();
((MainWindow)m_window).InitializeWindowProperties();
break;
case AppMode.OOBEState:
m_window = new MainWindow();
((MainWindow)m_window).InitializeWindowProperties(true);
break;
}

m_window.Activate();
Expand Down
106 changes: 42 additions & 64 deletions CollapseLauncher/Classes/EventsManagement/BackgroundActivityManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using CollapseLauncher.Interfaces;
using CollapseLauncher.Statics;
using Hi3Helper;
using Hi3Helper.Data;
using Hi3Helper.Preset;
using Hi3Helper.Shared.Region;
using Microsoft.UI.Text;
using Microsoft.UI.Xaml;
Expand All @@ -9,20 +11,15 @@
using Microsoft.UI.Xaml.Media.Imaging;
using System;
using System.Collections.Generic;
using CollapseLauncher.Statics;
using Hi3Helper.Preset;
using static Hi3Helper.Locale;

namespace CollapseLauncher
{
internal class BackgroundActivityManager
{
private static ThemeShadow _infoBarShadow = new ThemeShadow();

public static Dictionary<int, IBackgroundActivity> BackgroundActivities = new Dictionary<int, IBackgroundActivity>();

private static GamePresetProperty CurrentGameProperty;

public static void Attach(int hashID, IBackgroundActivity activity, string activityTitle, string activitySubtitle)
{
if (!BackgroundActivities.ContainsKey(hashID))
Expand Down Expand Up @@ -93,56 +90,22 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
};
_parentGrid.Children.Add(progressLogoContainer);
Grid.SetColumn(progressLogoContainer, 0);
CurrentGameProperty = GamePropertyVault.GetCurrentGameProperty();
switch (CurrentGameProperty._GameVersion.GameType)

GamePresetProperty CurrentGameProperty = GamePropertyVault.GetCurrentGameProperty();
Image processLogo = new Image()
{
case GameType.Honkai:
Image progressLogoHonkai = new Image()
{
Source = new BitmapImage(new Uri("ms-appx:///XAMLs/Prototype/honkai-logo.png")),
Width = 64,
Height = 64
};
progressLogoContainer.Children.Add(progressLogoHonkai);
break;
case GameType.Genshin:
Image progressLogoGenshin = new Image()
{
Source = new BitmapImage(new Uri("ms-appx:///XAMLs/Prototype/genshin-logo.png")),
Width = 64,
Height = 64
};
progressLogoContainer.Children.Add(progressLogoGenshin);
break;
case GameType.StarRail:
Image progressLogoStarRail = new Image()
{
Source = new BitmapImage(new Uri("ms-appx:///XAMLs/Prototype/starrail-logo.png")),
Width = 64,
Height = 64
};
progressLogoContainer.Children.Add(progressLogoStarRail);
break;
case GameType.Zenless:
Image progressLogoZenless = new Image()
{
Source = new BitmapImage(new Uri("ms-appx:///XAMLs/Prototype/zenless-logo.png")),
Width = 64,
Height = 64
};
progressLogoContainer.Children.Add(progressLogoZenless);
break;
case GameType.Unknown:
Image progressLogoUnknown = new Image()
{
Source = new BitmapImage(new Uri("ms-appx:///XAMLs/Prototype/honkai-logo.png")),
Width = 64,
Height = 64
};
progressLogoContainer.Children.Add(progressLogoUnknown);
break;
}
Source = new BitmapImage(new Uri(CurrentGameProperty._GameVersion.GameType switch
{
GameType.Honkai => "ms-appx:///Assets/Images/GameLogo/honkai-logo.png",
GameType.Genshin => "ms-appx:///Assets/Images/GameLogo/genshin-logo.png",
GameType.StarRail => "ms-appx:///Assets/Images/GameLogo/zenless-logo.png",
GameType.Zenless => "ms-appx:///Assets/Images/GameLogo/honkai-logo.png",
_ => "ms-appx:///Assets/Images/PaimonWhat.png"
})),
Width = 64,
Height = 64
};
progressLogoContainer.Children.Add(processLogo);

StackPanel progressStatusContainer = new StackPanel()
{
Expand Down Expand Up @@ -171,24 +134,24 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
TextBlock progressLeftTitle = new TextBlock()
{
Style = Application.Current.Resources["BodyStrongTextBlockStyle"] as Style,
Text = "Downloading Package: 1 / 3"
Text = Lang._BackgroundNotification.LoadingTitle,
};
TextBlock progressLeftSubtitle = new TextBlock()
{
Style = Application.Current.Resources["CaptionTextBlockStyle"] as Style,
Text = "Speed: 69.42 MB/s"
Text = Lang._BackgroundNotification.Placeholder,
};

TextBlock progressRightTitle = new TextBlock()
{
Style = Application.Current.Resources["BodyStrongTextBlockStyle"] as Style,
Text = "Estimated Time: 0h 32m left",
Text = Lang._BackgroundNotification.Placeholder,
HorizontalAlignment = HorizontalAlignment.Right
};
TextBlock progressRightSubtitle = new TextBlock()
{
Style = Application.Current.Resources["CaptionTextBlockStyle"] as Style,
Text = "Progress: 69.42%",
Text = Lang._BackgroundNotification.Placeholder,
HorizontalAlignment = HorizontalAlignment.Right
};
progressStatusGrid.Children.Add(progressLeftTitle);
Expand All @@ -200,7 +163,7 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
Grid.SetColumn(progressRightTitle, 1); Grid.SetRow(progressRightTitle, 0);
Grid.SetColumn(progressRightSubtitle, 1); Grid.SetRow(progressRightSubtitle, 1);

ProgressBar progressBar = new ProgressBar() { Minimum = 0, Maximum = 100, Value = 69.42 };
ProgressBar progressBar = new ProgressBar() { Minimum = 0, Maximum = 100, Value = 0, IsIndeterminate = true };
progressStatusContainer.Children.Add(progressBar);

Button cancelButton = new Button()
Expand Down Expand Up @@ -239,23 +202,24 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
_parentNotifUI.IsOpen = false;
};

activity.ProgressChanged += (_, args) => activity.Dispatch(() =>
EventHandler<TotalPerfileProgress> ProgressChangedEventHandler = (_, args) => activity?.Dispatch(() =>
{
progressBar.Value = args.ProgressTotalPercentage;
progressLeftSubtitle.Text = string.Format(Lang._Misc.Speed, ConverterTool.SummarizeSizeSimple(args.ProgressTotalSpeed));
progressRightTitle.Text = string.Format(Lang._Misc.TimeRemainHMSFormat, args.ProgressTotalTimeLeft);
progressRightSubtitle.Text = string.Format(Lang._UpdatePage.UpdateHeader1 + " {0}%", args.ProgressTotalPercentage);
});

activity.StatusChanged += (_, args) => activity.Dispatch(() =>
EventHandler<TotalPerfileStatus> StatusChangedEventHandler = (_, args) => activity?.Dispatch(() =>
{
progressBar.IsIndeterminate = args.IsProgressTotalIndetermined;
progressLeftTitle.Text = args.ActivityStatus;
if (args.IsCanceled)
{
cancelButton.IsEnabled = false;
cancelButton.Visibility = Visibility.Collapsed;
_parentNotifUI.Severity = InfoBarSeverity.Error;
_parentNotifUI.Title = "[Error] " + activityTitle;
_parentNotifUI.Title = string.Format(Lang._BackgroundNotification.NotifBadge_Error, activityTitle);
_parentNotifUI.IsClosable = true;
_parentContainer.Margin = containerClosableMargin;
}
Expand All @@ -264,7 +228,7 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
cancelButton.IsEnabled = false;
cancelButton.Visibility = Visibility.Collapsed;
_parentNotifUI.Severity = InfoBarSeverity.Success;
_parentNotifUI.Title = "[Completed] " + activityTitle;
_parentNotifUI.Title = string.Format(Lang._BackgroundNotification.NotifBadge_Completed, activityTitle);
_parentNotifUI.IsClosable = true;
_parentContainer.Margin = containerClosableMargin;
}
Expand All @@ -279,7 +243,21 @@ private static void AttachEventToNotification(int hashID, IBackgroundActivity ac
}
});

_parentNotifUI.Closing += (_, _) => Detach(hashID);
activity.ProgressChanged += ProgressChangedEventHandler;
activity.StatusChanged += StatusChangedEventHandler;

activity.FlushingTrigger += (obj, sender) =>
{
activity.ProgressChanged -= ProgressChangedEventHandler;
activity.StatusChanged -= StatusChangedEventHandler;
};

_parentNotifUI.Closing += (_, _) =>
{
activity.ProgressChanged -= ProgressChangedEventHandler;
activity.StatusChanged -= StatusChangedEventHandler;
Detach(hashID);
};
_parentContainer.Children.Add(cancelButton);

NotificationSender.SendCustomNotification(hashID, _parentNotifUI);
Expand Down
10 changes: 6 additions & 4 deletions CollapseLauncher/Classes/EventsManagement/EventsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
using Squirrel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using Windows.Foundation;
#if !DEBUG
using Squirrel;
using static CollapseLauncher.InnerLauncherConfig;
#endif
using static Hi3Helper.Locale;
using static Hi3Helper.Logger;
using static Hi3Helper.Shared.Region.LauncherConfig;
Expand Down Expand Up @@ -67,8 +69,8 @@ public static async void StartCheckUpdate()
LogWriteLine($"Update check has failed! Will retry in 15 mins.\r\n{ex}", LogType.Error, true);
}
}
// Delay for 15 minutes
await Task.Delay(900 * 1000);
// Delay for 15 minutes
await Task.Delay(900 * 1000);
}
#endif
}
Expand Down Expand Up @@ -120,7 +122,7 @@ internal class LauncherUpdateProperty
public GameVersion NewVersionName { get; set; }
public bool QuitFromUpdateMenu { get; set; } = false;
}
#endregion
#endregion
#region ThemeChangeRegion
internal static class ThemeChanger
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CollapseLauncher.GameSettings.Genshin.Context;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CollapseLauncher.GameSettings.Base;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Hi3Helper.Screen;
using Microsoft.Win32;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CollapseLauncher.GameSettings.Honkai.Context;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CollapseLauncher.GameSettings.Honkai.Context;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CollapseLauncher.GameSettings.Honkai.Enums;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CollapseLauncher.GameSettings.Honkai.Context;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Hi3Helper.Screen;
using Microsoft.Win32;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using static CollapseLauncher.GameSettings.Base.SettingsBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using static CollapseLauncher.GameSettings.Base.SettingsBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CollapseLauncher.GameSettings.StarRail.Context;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CollapseLauncher.GameSettings.StarRail.Context;
using CollapseLauncher.Interfaces;
using Hi3Helper;
using Hi3Helper.EncTool;
using Hi3Helper.Screen;
using Microsoft.Win32;
using System;
Expand Down
Loading

0 comments on commit b93a333

Please sign in to comment.