Corona-Studio / ProjBobcat

The next generation Minecraft launcher core written in C# providing the freest, fastest and the most complete experience.
https://kb.corona.studio/zhCN/projbobcat/
MIT License
159 stars 21 forks source link

`Optimize UWPMinecraft startup` and `Add GetAppxPackage` #87

Closed imJack6 closed 1 year ago

imJack6 commented 1 year ago

Main modifications: Optimize UWPMinecraft startup and Add GetAppxPackage and some auxiliary methods

Only Available On Windows.

Detect Games Installed

Use the following code to check if UWPMinecraft is installed

ProjBobcat.Platforms.Windows.SystemInfoHelper.IsMinecraftUWPInstalled();

Start Game

  1. Use the following code to initialize the UWPMinecraft game core
    var uwpCore = new DefaultMineCraftUWPCore();
  2. Use the following code to start UWPMinercraft and obtain the return value
    var result = uwpCore.Launch();

Event binding

Use the following code to detect game exit

uwpCore.GameExitEventDelegate += (sender, eventArgs) =>
{
    Console.WriteLine("Game exited");
};

Use the following code to detect game startup

uwpCore.LaunchLogEventDelegate += (sender, eventArgs) =>
{
    Console.WriteLine(eventArgs.Item);
};

Other

Use the following code to obtain UWP program information (replace App Package Name with the package name, such as Microsoft.MinecraftUWP)

var result = ProjBobcat.Platforms.Windows.SystemInfoHelper.GetAppxPackage("App Package Name");

This will return a AppxPackageInfo, use the following code to view the corresponding value

result.Name // The name of the application, for example: Microsoft Minecraft UWP
result.Architecture // The architecture of the application, for example: X64
result.Version // The version number of the application, for example: 1.19.8301.0
...
Detailed information can be viewed in the `Class/Model/AppxPackageInfo.cs` source file