Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable 1.82.19 Hotfix Release #701

Merged
merged 40 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c3dcd83
[skip ci] Update README.md
Cryotechnic Feb 19, 2025
9deeb8b
Fix GamePresetProperty log header format
neon-nyan Feb 20, 2025
b602a1d
[GenshinRepair] Ignore "StreamingAssets\ctable.dat" on clean-up
neon-nyan Feb 20, 2025
71bf1bf
Fix carousel keep running while minimized
neon-nyan Feb 20, 2025
0d94581
[ZZZ GSP] Fix Windowed resolution in wrong order
neon-nyan Feb 21, 2025
22dc020
Always use UI Thread to spawn background activity notification
neon-nyan Feb 21, 2025
08df17c
[StarRailRepair] Fix #672 - Mark files being detected as "Unused"
neon-nyan Feb 21, 2025
1dcf138
[CI][QD] Run QD on staging branch
bagusnl Feb 23, 2025
8db60cf
FIx compile error on SIMULATEAPPLYPRELOAD
neon-nyan Feb 26, 2025
485ab73
Fix H.NotifyIcon popup not bringing window after click
neon-nyan Feb 26, 2025
f5638c7
Simplify invocation of WaitForRetryAsync
neon-nyan Mar 5, 2025
04e5b47
Update NuGet
neon-nyan Mar 5, 2025
9336a35
[Win32] Decouple ToastCOM into WinRT subproject
neon-nyan Mar 6, 2025
3f6e135
Downgrade WinSDK TFM to 22621
neon-nyan Mar 6, 2025
12e71db
Downgrade .NET SDK version
bagusnl Mar 7, 2025
2356d00
Remove explicit ILC reference
bagusnl Mar 7, 2025
c6d67d6
Downgrade nugets
bagusnl Mar 7, 2025
f750673
Fix NativeAOT failing build
bagusnl Mar 7, 2025
cf7617d
Manually sync SLNX file
bagusnl Mar 7, 2025
4a93c1c
Fix dependency mayhem
bagusnl Mar 7, 2025
83801be
[skip ci] Use merge on submodules update config
bagusnl Mar 7, 2025
d126972
[skip ci] Update plj
bagusnl Mar 7, 2025
81d8eb7
[skip ci] Revert "[skip ci] Use merge on submodules update config"
bagusnl Mar 7, 2025
7e0aa9e
Deprecating HSR Mobile mode
bagusnl Mar 8, 2025
0a78927
Update Copyright/License year
bagusnl Mar 8, 2025
d9fd677
Update THIRD_PARTY_NOTICES
bagusnl Mar 8, 2025
ca24060
[skip ci] Sync translation Translate en_US.json in es_419
transifex-integration[bot] Mar 8, 2025
53f675b
[skip ci] Sync translation Translate en_US.json in zh_CN
transifex-integration[bot] Mar 9, 2025
4910668
[skip ci] Sync translation Translate en_US.json in uk_UA [Manual Sync]
transifex-integration[bot] Mar 9, 2025
8c9d51d
[skip ci] Sync translation Translate en_US.json in id_ID [Manual Sync]
transifex-integration[bot] Mar 9, 2025
bb06efe
[skip ci] Sync translation Translate en_US.json in ru_RU [Manual Sync]
transifex-integration[bot] Mar 9, 2025
2a1652d
[skip ci] Sync translation Translate en_US.json in ja_JP [Manual Sync]
transifex-integration[bot] Mar 9, 2025
bd08c94
[skip ci] Sync translation Translate en_US.json in fr_FR [Manual Sync]
transifex-integration[bot] Mar 9, 2025
2d6ad96
[skip ci] Sync translation Translate en_US.json in ko_KR [Manual Sync]
transifex-integration[bot] Mar 9, 2025
3858465
[skip ci] Sync translation Translate en_US.json in pt_BR [Manual Sync]
transifex-integration[bot] Mar 9, 2025
51a6ffe
[skip ci] Sync translation Translate en_US.json in vi_VN [Manual Sync]
transifex-integration[bot] Mar 9, 2025
075dc7d
[skip ci] Sync translation Translate en_US.json in ja_JP
transifex-integration[bot] Mar 9, 2025
6ddbd37
Fix App AUMID conflict between H.NotifyIcon and ToastCOM
neon-nyan Mar 9, 2025
6b55512
Push un-pushed fix for ToastCOM
neon-nyan Mar 11, 2025
69745c6
Downgrade package
bagusnl Mar 11, 2025
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
3 changes: 2 additions & 1 deletion .github/workflows/qodana-scan-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- main
- '*staging'
paths-ignore:
- '**.md'
- 'Hi3Helper.Core/Lang/**.json'
Expand Down Expand Up @@ -51,7 +52,7 @@ jobs:

- name: 'Qodana Scan'
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
uses: JetBrains/qodana-action@latest
uses: JetBrains/qodana-action@next
with:
args: --ide,QDNET
pr-mode: true
Expand Down
8 changes: 8 additions & 0 deletions CollapseLauncher.sln
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H.GeneratedIcons.System.Dra
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hi3Helper.Win32", "Hi3Helper.Win32\Hi3Helper.Win32.csproj", "{F65C6DAC-CC04-214B-9430-2C4AE31448E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hi3Helper.Win32.WinRT", "Hi3Helper.Win32\WinRT\Hi3Helper.Win32.WinRT.csproj", "{5CA5A261-1D5B-8A4D-EA87-B031CFFD4DDD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -152,6 +154,12 @@ Global
{F65C6DAC-CC04-214B-9430-2C4AE31448E2}.Publish|x64.Build.0 = Release|x64
{F65C6DAC-CC04-214B-9430-2C4AE31448E2}.Release|x64.ActiveCfg = Release|x64
{F65C6DAC-CC04-214B-9430-2C4AE31448E2}.Release|x64.Build.0 = Release|x64
{5CA5A261-1D5B-8A4D-EA87-B031CFFD4DDD}.Debug|x64.ActiveCfg = Debug|x64
{5CA5A261-1D5B-8A4D-EA87-B031CFFD4DDD}.Debug|x64.Build.0 = Debug|x64
{5CA5A261-1D5B-8A4D-EA87-B031CFFD4DDD}.Publish|x64.ActiveCfg = Release|x64
{5CA5A261-1D5B-8A4D-EA87-B031CFFD4DDD}.Publish|x64.Build.0 = Release|x64
{5CA5A261-1D5B-8A4D-EA87-B031CFFD4DDD}.Release|x64.ActiveCfg = Release|x64
{5CA5A261-1D5B-8A4D-EA87-B031CFFD4DDD}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 4 additions & 0 deletions CollapseLauncher.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@
<BuildType Solution="Publish|*" Project="Release" />
<Platform Project="x64" />
</Project>
<Project Path="Hi3Helper.Win32\WinRT\Hi3Helper.Win32.WinRT.csproj" Id="5CA5A261-1D5B-8A4D-EA87-B031CFFD4DDD">
<BuildType Solution="Publish|*" Project="Release" />
<Platform Project="x64" />
</Project>
</Solution>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CollapseLauncher.Dialogs;
using CollapseLauncher.Extension;
using CollapseLauncher.Helper;
using CollapseLauncher.Helper.Metadata;
using CollapseLauncher.Interfaces;
using CollapseLauncher.Statics;
Expand Down Expand Up @@ -29,7 +30,8 @@ public static void Attach(int hashID, IBackgroundActivity activity, string activ
return;
}

AttachEventToNotification(hashID, activity, activityTitle, activitySubtitle);
WindowUtility.CurrentDispatcherQueue?
.TryEnqueue(() => AttachEventToNotification(hashID, activity, activityTitle, activitySubtitle));
BackgroundActivities.Add(hashID, activity);
#if DEBUG
Logger.LogWriteLine($"Background activity with ID: {hashID} has been attached", LogType.Debug, true);
Expand Down
30 changes: 4 additions & 26 deletions CollapseLauncher/Classes/Extension/TaskExtensions.TaskAwaitable.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
// ReSharper disable UnusedMember.Global
// ReSharper disable CheckNamespace

#nullable enable
namespace CollapseLauncher.Extension
Expand All @@ -11,35 +11,13 @@ namespace CollapseLauncher.Extension

internal static partial class TaskExtensions
{
internal static Task<TResult?>
internal static async Task<TResult?>
WaitForRetryAsync<TResult>(this ActionTimeoutTaskAwaitableCallback<TResult?> funcCallback,
int? timeout = null,
int? timeoutStep = null,
int? retryAttempt = null,
ActionOnTimeOutRetry? actionOnRetry = null,
CancellationToken fromToken = default)
=> WaitForRetryAsync(() => funcCallback, timeout, timeoutStep, retryAttempt, actionOnRetry, fromToken);

internal static async Task<TResult?>
WaitForRetryAsync<TResult>(Func<ActionTimeoutTaskAwaitableCallback<TResult?>> funcCallback,
int? timeout = null,
int? timeoutStep = null,
int? retryAttempt = null,
ActionOnTimeOutRetry? actionOnRetry = null,
CancellationToken fromToken = default)
=> await WaitForRetryAsync(funcCallback.AsTaskCallback,
timeout,
timeoutStep,
retryAttempt,
actionOnRetry,
fromToken);

private static ActionTimeoutTaskCallback<TResult?> AsTaskCallback<TResult>(this Func<ActionTimeoutTaskAwaitableCallback<TResult?>> func) =>
async ctx =>
{
ActionTimeoutTaskAwaitableCallback<TResult?> callback = func.Invoke();
ConfiguredTaskAwaitable<TResult?> callbackAwaitable = callback.Invoke(ctx);
return await callbackAwaitable;
};
=> await funcCallback.Invoke(fromToken);
}
}
276 changes: 276 additions & 0 deletions CollapseLauncher/Classes/Extension/VelopackLocatorExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
using CollapseLauncher.Helper;
using CollapseLauncher.Helper.Update;
using Hi3Helper;
using Hi3Helper.Data;
using Hi3Helper.SentryHelper;
using Hi3Helper.Shared.Region;
using Hi3Helper.Win32.ShellLinkCOM;
using Microsoft.Extensions.Logging;
using NuGet.Versioning;
using System;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Velopack;
using Velopack.Locators;
// ReSharper disable IdentifierTypo
// ReSharper disable StringLiteralTypo
// ReSharper disable CommentTypo

#nullable enable
namespace CollapseLauncher.Classes.Extension
{
internal static class VelopackLocatorExtension
{
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<AppId>k__BackingField")]
internal static extern ref string? GetLocatorAumidField(this WindowsVelopackLocator locator);

internal static void StartUpdaterHook(string aumid)
{
#if !USEVELOPACK
// Add Squirrel Hooks
SquirrelAwareApp.HandleEvents(
// Add shortcut and uninstaller entry on first start-up
// ReSharper disable UnusedParameter.Local
(_, sqr) =>
{
Console
.WriteLine("Please do not close this console window while Collapse is preparing the installation via Squirrel...");
},
(_, sqr) =>
{
Console
.WriteLine("Please do not close this console window while Collapse is updating via Squirrel...");
},
onAppUninstall: (_, sqr) =>
{
Console
.WriteLine("Uninstalling Collapse via Squirrel...\r\n" +
"Please do not close this console window while action is being performed!");
},
// ReSharper restore UnusedParameter.Local
onEveryRun: (_, _, _) => { }
);
#else
// Allocate the Velopack locator manually to avoid Velopack from re-assigning
// its custom AUMID
ILogger logger = ILoggerHelper.GetILogger("Velopack");
WindowsVelopackLocator locator = new WindowsVelopackLocator(logger);
// HACK: Always ensure to set the AUMID field null so it won't
// set the AUMID to its own.
locator.GetLocatorAumidField() = null;

VelopackApp builder = VelopackApp.Build()
.WithRestarted(TryCleanupFallbackUpdate)
.WithAfterUpdateFastCallback(TryCleanupFallbackUpdate)
.WithFirstRun(TryCleanupFallbackUpdate)
.SetLocator(locator);

builder.Run(logger);

_ = Task.Run(DeleteVelopackLock);

GenerateVelopackMetadata(aumid);

void DeleteVelopackLock()
{
// Get the current application directory
string currentAppDir = AppDomain.CurrentDomain.BaseDirectory;

// Construct the path to the .velopack_lock file
string velopackLockPath = Path.Combine(currentAppDir, "..", "packages", ".velopack_lock");

// Normalize the path
velopackLockPath = Path.GetFullPath(velopackLockPath);

// Check if the file exists
if (!File.Exists(velopackLockPath))
{
return;
}

// Delete the file
File.Delete(velopackLockPath);
Logger.LogWriteLine(".velopack_lock file deleted successfully.");
}
#endif
}

#if USEVELOPACK
public static void TryCleanupFallbackUpdate(SemanticVersion newVersion)
{
string currentExecutedAppFolder = LauncherConfig.AppExecutableDir.TrimEnd('\\');
string currentExecutedPath = LauncherConfig.AppExecutablePath;

// If the path is not actually running under "current" velopack folder, then return
#if !DEBUG
if (!currentExecutedAppFolder.EndsWith("current", StringComparison.OrdinalIgnoreCase)) // Expecting "current"
{
Logger.LogWriteLine("[TryCleanupFallbackUpdate] The launcher does not run from \"current\" folder");
return;
}
#endif

try
{
// Otherwise, start cleaning-up process
string? currentExecutedParentFolder = Path.GetDirectoryName(currentExecutedAppFolder);
if (currentExecutedParentFolder != null)
{
DirectoryInfo directoryInfo = new DirectoryInfo(currentExecutedParentFolder);
foreach (DirectoryInfo childLegacyAppSemVerFolder in
directoryInfo.EnumerateDirectories("app-*", SearchOption.TopDirectoryOnly))
{
// Removing the "app-*" folder
childLegacyAppSemVerFolder.Delete(true);
Logger.LogWriteLine($"[TryCleanupFallbackUpdate] Removed {childLegacyAppSemVerFolder.FullName} folder!",
LogType.Default, true);
}

// Try to remove squirrel temp clowd folder
string squirrelTempPackagesFolder = Path.Combine(currentExecutedParentFolder, "SquirrelClowdTemp");
DirectoryInfo squirrelTempPackagesFolderInfo = new DirectoryInfo(squirrelTempPackagesFolder);
if (squirrelTempPackagesFolderInfo.Exists)
{
squirrelTempPackagesFolderInfo.Delete(true);
Logger.LogWriteLine($"[TryCleanupFallbackUpdate] Removed package temp folder: {squirrelTempPackagesFolder}!",
LogType.Default, true);
}

// Try to remove stub executable
string squirrelLegacyStubPath = Path.Combine(currentExecutedParentFolder, "CollapseLauncher.exe");
RemoveSquirrelFilePath(squirrelLegacyStubPath);

// Try to remove createdump executable
string squirrelLegacyDumpPath = Path.Combine(currentExecutedParentFolder, "createdump.exe");
RemoveSquirrelFilePath(squirrelLegacyDumpPath);

// Try to remove RestartAgent executable
string squirrelLegacyRestartAgentPath =
Path.Combine(currentExecutedParentFolder, "RestartAgent.exe");
RemoveSquirrelFilePath(squirrelLegacyRestartAgentPath);
}

// Try to remove legacy shortcuts
string? currentWindowsPathDrive = Path.GetPathRoot(Environment.SystemDirectory);
if (!string.IsNullOrEmpty(currentWindowsPathDrive))
{
string squirrelLegacyStartMenuGlobal =
Path.Combine(currentWindowsPathDrive,
@"ProgramData\Microsoft\Windows\Start Menu\Programs\Collapse\Collapse Launcher");
string? squirrelLegacyStartMenuGlobalParent = Path.GetDirectoryName(squirrelLegacyStartMenuGlobal);
if (Directory.Exists(squirrelLegacyStartMenuGlobalParent) &&
Directory.Exists(squirrelLegacyStartMenuGlobal))
{
Directory.Delete(squirrelLegacyStartMenuGlobalParent, true);
}
}

// Try to delete all possible shortcuts on any users (since the shortcut used will be the global one)
// Only do this if shortcut path is not same as current path tho... It pain to re-pin the shortcut again...
string currentUsersDirPath = Path.Combine(currentWindowsPathDrive!, "Users");
foreach (string userDirInfoPath in Directory
.EnumerateDirectories(currentUsersDirPath, "*",
SearchOption.TopDirectoryOnly)
.Where(ConverterTool.IsUserHasPermission))
{
// Get the shortcut file
string thisUserStartMenuShortcut = Path.Combine(userDirInfoPath,
@"AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Collapse.lnk");
if (!File.Exists(thisUserStartMenuShortcut))
{
continue;
}

// Try open the shortcut and check whether this shortcut is actually pointing to
// CollapseLauncher.exe file
using ShellLink shellLink = new ShellLink(thisUserStartMenuShortcut);
// Try to get the target path and its filename
string shortcutTargetPath = shellLink.Target;
if (!shortcutTargetPath.Equals(currentExecutedPath, StringComparison.OrdinalIgnoreCase))
{
continue;
}

// Compare if the filename is equal, then delete it.
File.Delete(thisUserStartMenuShortcut);
Logger.LogWriteLine($"[TryCleanupFallbackUpdate] Deleted old shortcut located at: " +
$"{thisUserStartMenuShortcut} -> {shortcutTargetPath}",
LogType.Default, true);
}

// Try to recreate shortcuts
TaskSchedulerHelper.RecreateIconShortcuts();
}
catch (Exception ex)
{
SentryHelper.ExceptionHandler(ex, SentryHelper.ExceptionType.UnhandledOther);
Logger.LogWriteLine($"[TryCleanupFallbackUpdate] Failed while operating clean-up routines...\r\n{ex}");
}

return;

void RemoveSquirrelFilePath(string filePath)
{
if (!File.Exists(filePath))
{
return;
}

File.Delete(filePath);
Logger.LogWriteLine($"[TryCleanupFallbackUpdate] Removed old squirrel executables: {filePath}!",
LogType.Default, true);
}
}
#endif

public static string FindCollapseStubPath()
{
var collapseMainPath = LauncherConfig.AppExecutablePath;

#if USEVELOPACK
const string collapseExecName = "CollapseLauncher.exe";
var collapseStubPath = Path.Combine(Directory.GetParent(Path.GetDirectoryName(collapseMainPath)!)!.FullName,
collapseExecName);
if (File.Exists(collapseStubPath))
{
Logger.LogWriteLine($"Found stub at {collapseStubPath}", LogType.Default, true);
return collapseStubPath;
}
#endif

Logger.LogWriteLine($"Collapse stub is not used anymore, returning current executable path!\r\n\t{collapseMainPath}",
LogType.Default, true);
return collapseMainPath;
}

internal static void GenerateVelopackMetadata(string aumid)
{
const string xmlTemplate = """
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>CollapseLauncher</id>
<title>Collapse</title>
<description>Collapse</description>
<authors>Collapse Project Team</authors>
<version>{0}</version>
<channel>{1}</channel>
<mainExe>CollapseLauncher.exe</mainExe>
<os>win</os>
<rid>win</rid>
<shortcutLocations>Desktop,StartMenuRoot</shortcutLocations>
<shortcutAmuid>{2}</shortcutAmuid>
<shortcutAumid>{2}</shortcutAumid>
</metadata>
</package>
"""; // Adding shortcutAumid for future use, since they typo-ed the XML tag LMAO
string currentVersion = LauncherUpdateHelper.LauncherCurrentVersionString;
string xmlPath = Path.Combine(LauncherConfig.AppExecutableDir, "sq.version");
string xmlContent = string.Format(xmlTemplate, currentVersion, LauncherConfig.IsPreview ? "preview" : "stable", aumid);
File.WriteAllText(xmlPath, xmlContent.ReplaceLineEndings("\n"));
Logger.LogWriteLine($"Velopack metadata has been successfully written!\r\n{xmlContent}", LogType.Default, true);
}
}
}
Loading
Loading