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

Dependencies Update, New Tray Behavior, and some random improvements :) #278

Merged
merged 33 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
40afb67
Add optimization for DevDrive
bagusnl Sep 18, 2023
275d0b6
Add git commit description on console
bagusnl Sep 18, 2023
4babf9e
There was an attempt to update CommandLine to beta4
bagusnl Sep 18, 2023
5945272
ArgumentParser fixes
bagusnl Sep 18, 2023
f065b6c
Rebase to main at 7d3637
bagusnl Sep 23, 2023
c31aa0e
Add a3b1c6
bagusnl Sep 23, 2023
57abe9d
Bump to origin at 9d86c0
bagusnl Sep 25, 2023
74de602
Bump to origin at 39dea6
bagusnl Sep 26, 2023
983b247
Update nuget lock file
bagusnl Sep 26, 2023
f2b51e3
Bump to origin at 90cd51
bagusnl Sep 29, 2023
b4e2f11
[VULN] Update Http and Regex NuGet
bagusnl Sep 29, 2023
40299e7
Early implementation for Taskbar
bagusnl Sep 29, 2023
5294d1c
Make Taskbar toggle text change on condition
bagusnl Sep 29, 2023
be911bd
Add argument to start Collapse in tray
bagusnl Sep 29, 2023
2bffb85
Bump to origin at b714d5
bagusnl Oct 2, 2023
7b100ca
Taskbar Improvements
bagusnl Oct 2, 2023
436c26c
Use locales for TrayIcon
bagusnl Oct 2, 2023
309c188
Bump to origin at f463aa
bagusnl Oct 7, 2023
f33787b
Update Package References
bagusnl Oct 7, 2023
33a5fa1
Eliminate Flipflop Situation for ToggleAllVisibility
bagusnl Oct 7, 2023
6fd4f57
TrayIcon.xaml.cs Cleanup
bagusnl Oct 7, 2023
c7918a9
Also hide console when StartOnTray
bagusnl Oct 7, 2023
ab28521
Fix main window not being brought up when its minimized
bagusnl Oct 7, 2023
2790cd7
Update packages lock file
bagusnl Oct 7, 2023
c4750b2
Disable single file publishing
bagusnl Oct 7, 2023
fa1e9a5
Move text handler outside if bracket
bagusnl Oct 7, 2023
8d6baaa
NICE workaround for console not showing up to foreground
bagusnl Oct 7, 2023
a957640
Remove unused directive & typo fixes
Cryotechnic Oct 9, 2023
61285bf
Added `VersionIndicator` to Tray
Cryotechnic Oct 9, 2023
42efb6e
Added commit information to Settings page
Cryotechnic Oct 9, 2023
70c6bc7
Fixed version string not being correct in debug
Cryotechnic Oct 9, 2023
89d986a
updated copyright holders
Cryotechnic Oct 9, 2023
02e7901
Fix indentation in CollapseLauncher.csproj
bagusnl Oct 9, 2023
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
2 changes: 1 addition & 1 deletion CollapseLauncher/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -415,4 +415,4 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
</Application>
14 changes: 14 additions & 0 deletions CollapseLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using H.NotifyIcon;
using Hi3Helper;
using Hi3Helper.Shared.Region;
using Microsoft.UI.Xaml;
Expand Down Expand Up @@ -39,11 +40,24 @@ public App()
m_window = new MainWindow();
((MainWindow)m_window).InitializeWindowProperties(true);
break;
case AppMode.StartOnTray:
m_window = new MainWindow();
((MainWindow)m_window).InitializeWindowProperties();
LogWriteLine("Running Collapse in Tray Mode!", LogType.Scheme);
break;
}

m_window.Activate();
bool IsAcrylicEnabled = LauncherConfig.GetAppConfigValue("EnableAcrylicEffect").ToBool();
if (!IsAcrylicEnabled) ToggleBlurBackdrop(false);
if (m_appMode == AppMode.StartOnTray)
{
WindowExtensions.Hide(m_window);
if (LauncherConfig.GetAppConfigValue("EnableConsole").ToBool())
{
LoggerConsole.DisposeConsole();
}
}
}
catch (Exception ex)
{
Expand Down
128 changes: 75 additions & 53 deletions CollapseLauncher/Classes/Properties/ArgumentParser.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.CommandLine;

using System.CommandLine.NamingConventionBinder;
using static CollapseLauncher.InnerLauncherConfig;

namespace CollapseLauncher
Expand Down Expand Up @@ -50,6 +50,10 @@ public static void ParseArguments(params string[] args)
m_appMode = AppMode.OOBEState;
ParseOOBEArguments(args);
break;
case "tray":
m_appMode = AppMode.StartOnTray;
ParseStartOnTrayArguments(args);
break;
}

if (rootCommand.Invoke(args) > 0)
Expand Down Expand Up @@ -87,31 +91,34 @@ public static void AddHi3CacheUpdaterOptions()

public static void AddUpdaterOptions()
{
Option o_Input, o_Channel;
rootCommand.AddOption(o_Input = new Option<string>(new string[] { "--input", "-i" }, "Path of the app") { IsRequired = true });
rootCommand.AddOption(o_Channel = new Option<AppReleaseChannel>(new string[] { "--channel", "-c" }, "Release channel of the app") { IsRequired = true }.FromAmong());
rootCommand.SetHandler((string Input, AppReleaseChannel ReleaseChannel) =>
Option<string> o_Input = new Option<string>(new string[] { "--input", "-i" }, "App path") { IsRequired = true };
Option<AppReleaseChannel> o_Channel = new Option<AppReleaseChannel>(new string[] { "--channel", "-c" }, "App release channel") { IsRequired = true }.FromAmong();
rootCommand.AddOption(o_Input);
rootCommand.AddOption(o_Channel);
rootCommand.Handler = CommandHandler.Create((string Input, AppReleaseChannel ReleaseChannel) =>
{
m_arguments.Updater = new ArgumentUpdater
{
AppPath = Input,
UpdateChannel = ReleaseChannel
};
}, o_Input, o_Channel);
});
}

public static void ParseTakeOwnershipArguments(params string[] args)
{
Option o_Input;
rootCommand.AddArgument(new Argument<string>("takeownership", "Take ownership of the folder") { HelpName = null });
rootCommand.AddOption(o_Input = new Option<string>(new string[] { "--input", "-i" }, "Path of the folder to be taken") { IsRequired = true });
rootCommand.SetHandler((string Input) =>
var inputOption = new Option<string>(new string[] { "--input", "-i" }, description: "Folder path to claim") { IsRequired = true };
var command = new Command("takeownership", "Take ownership of the folder");
command.AddOption(inputOption);
command.Handler = CommandHandler.Create<string>((string Input) =>
{
m_arguments.TakeOwnership = new ArgumentReindexer
{
AppPath = Input
};
}, o_Input);
});
var rootCommand = new RootCommand();
rootCommand.AddCommand(command);
}

public static void ParseMigrateArguments(bool isBHI3L = false, params string[] args)
Expand All @@ -128,62 +135,77 @@ public static void ParseOOBEArguments(params string[] args)
rootCommand.AddArgument(new Argument<string>("oobesetup", "Starts Collapse in OOBE mode, to simulate first-time setup") { HelpName = null });
}

public static void ParseStartOnTrayArguments(params string[] args)
{
rootCommand.AddArgument(new Argument<string>("tray", "Start Collapse in system tray") { HelpName = null });
}

private static void AddMigrateOptions(bool isBHI3L)
{
Option o_Input, o_Output, o_GameVer = null, o_RegLoc = null;
rootCommand.AddOption(o_Input = new Option<string>(new string[] { "--input", "-i" }, "Installation Source") { IsRequired = true });
rootCommand.AddOption(o_Output = new Option<string>(new string[] { "--output", "-o" }, "Installation Target") { IsRequired = true });
var inputOption = new Option<string>(new string[] { "--input", "-i" }, description: "Installation Source") { IsRequired = true };
var outputOption = new Option<string>(new string[] { "--output", "-o" }, description: "Installation Target") { IsRequired = true };
var rootCommand = new RootCommand();
rootCommand.AddOption(inputOption);
rootCommand.AddOption(outputOption);
if (isBHI3L)
{
rootCommand.AddOption(o_GameVer = new Option<string>(new string[] { "--gamever", "-g" }, "Game version string (in x.x.x format)") { IsRequired = true });
rootCommand.AddOption(o_RegLoc = new Option<string>(new string[] { "--regloc", "-r" }, "Location of game registry in BetterHI3Launcher keys") { IsRequired = true });
rootCommand.SetHandler((string Input, string Output, string GameVer, string RegLoc) =>
var gameVerOption = new Option<string>(new string[] { "--gamever", "-g" }, description: "Game version string (Format: x.x.x)") { IsRequired = true };
var regLocOption = new Option<string>(new string[] { "--regloc", "-r" }, description: "Location of game registry for BetterHI3Launcher keys") { IsRequired = true };
rootCommand.AddOption(gameVerOption);
rootCommand.AddOption(regLocOption);
rootCommand.Handler = CommandHandler.Create(
(string Input, string Output, string GameVer, string RegLoc) =>
{
m_arguments.Migrate = new ArgumentMigrate
{
InputPath = Input,
OutputPath = Output,
GameVer = GameVer,
RegLoc = RegLoc,
IsBHI3L = true
};
});
return;
}
rootCommand.Handler = CommandHandler.Create(
(string Input, string Output) =>
{
m_arguments.Migrate = new ArgumentMigrate
{
InputPath = Input,
OutputPath = Output,
GameVer = GameVer,
RegLoc = RegLoc,
IsBHI3L = true
GameVer = null,
RegLoc = null,
IsBHI3L = false
};
}, o_Input, o_Output, o_GameVer, o_RegLoc);

return;
}

rootCommand.SetHandler((string Input, string Output) =>
{
m_arguments.Migrate = new ArgumentMigrate
{
InputPath = Input,
OutputPath = Output,
GameVer = null,
RegLoc = null,
IsBHI3L = false
};
}, o_Input, o_Output);
});
}

public static void ParseMoveSteamArguments(params string[] args)
{
Option o_Input, o_Output, o_KeyName = null, o_RegLoc = null;
rootCommand.AddArgument(new Argument<string>("movesteam", "Migrate Game from Steam to another location") { HelpName = null });
rootCommand.AddOption(o_Input = new Option<string>(new string[] { "--input", "-i" }, "Installation Source") { IsRequired = true });
rootCommand.AddOption(o_Output = new Option<string>(new string[] { "--output", "-o" }, "Installation Target") { IsRequired = true });
rootCommand.AddOption(o_KeyName = new Option<string>(new string[] { "--keyname", "-k" }, "Registry key name") { IsRequired = true });
rootCommand.AddOption(o_RegLoc = new Option<string>(new string[] { "--regloc", "-r" }, "Location of game registry in BetterHI3Launcher keys") { IsRequired = true });
rootCommand.SetHandler((string Input, string Output, string KeyName, string RegLoc) =>
{
m_arguments.Migrate = new ArgumentMigrate
var inputOption = new Option<string>(new string[] { "--input", "-i" }, description: "Installation Source") { IsRequired = true };
var outputOption = new Option<string>(new string[] { "--output", "-o" }, description: "Installation Target") { IsRequired = true };
var keyNameOption = new Option<string>(new string[] { "--keyname", "-k" }, description: "Registry key name") { IsRequired = true };
var regLocOption = new Option<string>(new string[] { "--regloc", "-r" }, description: "Location of game registry for BetterHI3Launcher keys") { IsRequired = true };
var command = new Command("movesteam", "Migrate Game from Steam to another location");
command.AddOption(inputOption);
command.AddOption(outputOption);
command.AddOption(keyNameOption);
command.AddOption(regLocOption);
command.Handler = CommandHandler.Create(
(string Input, string Output, string KeyName, string RegLoc) =>
{
InputPath = Input,
OutputPath = Output,
KeyName = KeyName,
RegLoc = RegLoc,
IsBHI3L = false
};
}, o_Input, o_Output, o_KeyName, o_RegLoc);
m_arguments.Migrate = new ArgumentMigrate
{
InputPath = Input,
OutputPath = Output,
KeyName = KeyName,
RegLoc = RegLoc,
IsBHI3L = false
};
});
var rootCommand = new RootCommand();
rootCommand.AddCommand(command);
}
}

Expand Down Expand Up @@ -216,4 +238,4 @@ public class ArgumentMigrate
public string KeyName { get; set; }
public bool IsBHI3L { get; set; }
}
}
}
3 changes: 2 additions & 1 deletion CollapseLauncher/Classes/Properties/InnerLauncherConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public enum AppMode
InvokerTakeOwnership,
InvokerMoveSteam,
Hi3CacheUpdater,
OOBEState
OOBEState,
StartOnTray
}

public static AppMode m_appMode;
Expand Down
21 changes: 19 additions & 2 deletions CollapseLauncher/CollapseLauncher.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows10.0.22000.0</TargetFramework>
Expand All @@ -20,6 +20,7 @@
<TieredCompilationQuickJitForLoops>true</TieredCompilationQuickJitForLoops>
<TieredPGO>true</TieredPGO>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<GitVersion>false</GitVersion>
</PropertyGroup>
<!--
Constants List:
Expand All @@ -37,21 +38,30 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DefineConstants>DISABLE_XAML_GENERATED_MAIN;ENABLEHTTPREPAIR;DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION;PREVIEW</DefineConstants>
<Optimize>True</Optimize>
<GitSkipCache>true</GitSkipCache>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Publish|x64'">
<DefineConstants>DISABLE_XAML_GENERATED_MAIN;ENABLEHTTPREPAIR;DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION</DefineConstants>
<Optimize>True</Optimize>
<GitSkipCache>true</GitSkipCache>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Clowd.Squirrel" Version="2.9.42" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls" Version="7.1.2" />
<PackageReference Include="GitInfo" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="H.NotifyIcon.WinUI" Version="2.0.115" />
<PackageReference Include="Dongle.Windows.CsWinRT" Version="3.0.0-wux.2" />
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.5.1" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.3.230724000" />
<PackageReference Include="PhotoSauce.MagicScaler" Version="0.13.2" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.CommandLine.NamingConventionBinder" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
Expand Down Expand Up @@ -94,6 +104,7 @@
<TrimmableAssembly Include="Hi3Helper.EncTool" />
<TrimmableAssembly Include="Hi3Helper.Http" />
<TrimmableAssembly Include="Hi3Helper.SharpHDiffPatch" />
<TrimmableAssembly Include="CommunityToolkit.Mvvm" />
<TrimmableAssembly Include="CommunityToolkit.WinUI" />
<TrimmableAssembly Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" />
<TrimmableAssembly Include="CommunityToolkit.WinUI.UI.Controls.Input" />
Expand All @@ -102,7 +113,9 @@
<TrimmableAssembly Include="CommunityToolkit.WinUI.UI.Controls.Media" />
<TrimmableAssembly Include="CommunityToolkit.WinUI.UI.Controls.Primitives" />
<TrimmableAssembly Include="CommunityToolkit.WinUI.UI" />
<TrimmableAssembly Include="GitInfo" />
<TrimmableAssembly Include="Google.Protobuf" />
<TrimmableAssembly Include="H.NotifyIcon.WinUI" />
<TrimmableAssembly Include="Microsoft.Graphics.Canvas" />
<TrimmableAssembly Include="Microsoft.Graphics.Canvas.Interop" />
<TrimmableAssembly Include="Microsoft.InteractiveExperiences.Projection" />
Expand All @@ -122,11 +135,15 @@
<TrimmableAssembly Include="PhotoSauce.MagicScaler" />
<TrimmableAssembly Include="SquirrelLib" />
<TrimmableAssembly Include="SharpCompress" />
<TrimmableAssembly Include="System.CommandLine" />
<TrimmableAssembly Include="System.CommandLine.NamingConventionBinder" />
<TrimmableAssembly Include="System.Drawing" />
<TrimmableAssembly Include="System.Drawing.Common" />
<TrimmableAssembly Include="System.Drawing.Primitives" />
<TrimmableAssembly Include="System.IO.Compression.Brotli" />
<TrimmableAssembly Include="System.IO.Compression" />
<TrimmableAssembly Include="System.Net.HTTP" />
<TrimmableAssembly Include="System.Text.RegularExpression" />
<TrimmableAssembly Include="WinRT.Runtime" />
</ItemGroup>
</Target>
Expand Down
4 changes: 4 additions & 0 deletions CollapseLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public static void Main(params string[] args)
FileVersionInfo winappSDKver = FileVersionInfo.GetVersionInfo("Microsoft.ui.xaml.dll");
LogWriteLine(string.Format("Runtime: {0} - WindowsAppSDK {1}", RuntimeInformation.FrameworkDescription, winappSDKver.ProductVersion), LogType.Scheme, true);

LogWriteLine(string.Format("Built from repo {0}\r\n\t" +
"Branch {1} - Commit {2} at {3}",
ThisAssembly.Git.RepositoryUrl, ThisAssembly.Git.Branch, ThisAssembly.Git.Commit, ThisAssembly.Git.CommitDate), LogType.Scheme, true);

Process.GetCurrentProcess().PriorityBoostEnabled = true;

InitializeAppSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<EventSourceSupport>false</EventSourceSupport>
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport>
<InvariantGlobalization>true</InvariantGlobalization>
<PublishSingleFile>false</PublishSingleFile>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<TargetFramework>net7.0-windows10.0.22000.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>partial</TrimMode>
Expand Down
5 changes: 5 additions & 0 deletions CollapseLauncher/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
"commandName": "Project",
"commandLineArgs": "hi3cacheupdate",
"nativeDebugging": true
},
"Start on Tray": {
"commandName": "Project",
"commandLineArgs": "tray",
"nativeDebugging": false
}
}
}
4 changes: 2 additions & 2 deletions CollapseLauncher/XAMLs/MainApp/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Page
<Page
x:Class="CollapseLauncher.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down Expand Up @@ -216,4 +216,4 @@
</ScrollViewer>
<Frame x:Name="WebView2Frame"/>
</Grid>
</Page>
</Page>
3 changes: 2 additions & 1 deletion CollapseLauncher/XAMLs/MainApp/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Window
<Window
x:Class="CollapseLauncher.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Expand Down Expand Up @@ -32,5 +32,6 @@
Style="{StaticResource WindowCaptionButton}"
Click="MinimizeButton_Click"
Content="M 0 0 H 10"/>
<local:TrayIcon x:Name="TrayIcon"/>
</Grid>
</Window>
1 change: 1 addition & 0 deletions CollapseLauncher/XAMLs/MainApp/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
</TextBlock>
<TextBlock TextWrapping="Wrap" Text="{x:Bind helper:Locale.Lang._SettingsPage.About_Copyright4}" Style="{ThemeResource BodyTextBlockStyle}"/>
</StackPanel>
<TextBlock x:Name="GitVersionIndicator" TextWrapping="Wrap" Style="{ ThemeResource BodyTextBlockStyle}" IsTextSelectionEnabled="True"></TextBlock>
</StackPanel>
</Grid>
<StackPanel Margin="0,8,0,0">
Expand Down
Loading
Loading