diff --git a/Class/Helper/SystemInfoHelper.cs b/Class/Helper/SystemInfoHelper.cs index 5efd7c9e..8732185e 100644 --- a/Class/Helper/SystemInfoHelper.cs +++ b/Class/Helper/SystemInfoHelper.cs @@ -1,6 +1,10 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; +using System.Management.Automation; +using System.Management.Automation.Runspaces; +using System.Text; using Microsoft.Win32; namespace ProjBobcat.Class.Helper @@ -8,9 +12,10 @@ namespace ProjBobcat.Class.Helper public static class SystemInfoHelper { /// + /// Detect javaw.exe via reg. /// 从注册表中查找可能的javaw.exe位置 /// - /// JAVA地址列表 + /// A list, containing all possible path of javaw.exe. JAVA地址列表。 public static IEnumerable FindJava() { try @@ -67,8 +72,25 @@ public static string GetSystemVersion() "6.0" => "2008", "5.2" => "2003", "5.1" => "XP", - _ => "unknow" + _ => "unknown" }; } + + public static bool IsMinecraftUWPInstalled() + { + Runspace rs = RunspaceFactory.CreateRunspace(); + rs.Open(); + Pipeline pl = rs.CreatePipeline(); + pl.Commands.AddScript("Get-AppxPackage -Name \"Microsoft.MinecraftUWP\""); + pl.Commands.Add("Out-String"); + Collection result = pl.Invoke(); + rs.Close(); + rs.Dispose(); + if (result == null || String.IsNullOrEmpty(result[0].ToString())) + { + return false; + } + return true; + } } } \ No newline at end of file diff --git a/DefaultComponent/Launch/DefaultGameCore.cs b/DefaultComponent/Launch/DefaultGameCore.cs index 71360647..86210500 100644 --- a/DefaultComponent/Launch/DefaultGameCore.cs +++ b/DefaultComponent/Launch/DefaultGameCore.cs @@ -38,6 +38,11 @@ public string RootPath public event EventHandler GameLogEventDelegate; public event EventHandler LaunchLogEventDelegate; + public LaunchResult Launch(LaunchSettings settings) + { + throw new NotImplementedException(); + } + /// /// 启动游戏。 /// Launch the game. diff --git a/DefaultComponent/Launch/DefaultMinecraftUWPCore.cs b/DefaultComponent/Launch/DefaultMinecraftUWPCore.cs new file mode 100644 index 00000000..16b7a9d3 --- /dev/null +++ b/DefaultComponent/Launch/DefaultMinecraftUWPCore.cs @@ -0,0 +1,95 @@ +using ProjBobcat.Class.Helper; +using System; +using System.Diagnostics; +using ProjBobcat.Interface; +using ProjBobcat.Event; +using System.Threading.Tasks; +using ProjBobcat.Class.Model; + +namespace ProjBobcat.DefaultComponent.Launch +{ + public class DefaultMinecraftUWPCore : IGameCore, IDisposable + { + [Obsolete("UWP 版本的Minecraft不需要该字段。")] + public string RootPath { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + [Obsolete("UWP 版本的Minecraft不需要该字段。")] + public Guid ClientToken { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + [Obsolete("UWP 版本的Minecraft不需要该字段。")] + public IVersionLocator VersionLocator { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + + [Obsolete("UWP 版本的Minecraft不需要该字段。")] + public event EventHandler GameExitEventDelegate; + [Obsolete("UWP 版本的Minecraft不需要该字段。")] + public event EventHandler GameLogEventDelegate; + [Obsolete("UWP 版本的Minecraft不需要该字段。")] + public event EventHandler LaunchLogEventDelegate; + + public LaunchResult Launch(LaunchSettings launchSettings) + { + if (SystemInfoHelper.IsMinecraftUWPInstalled() == false) + { + throw new InvalidOperationException(); + } + + using var process = new Process + {StartInfo = new ProcessStartInfo {UseShellExecute = true, FileName = "minecraft:"}}; + process.Start(); + + return default; + } + + [Obsolete("UWP启动核心并不支持异步启动")] + public Task LaunchTaskAsync(LaunchSettings settings) + { + throw new NotImplementedException(); + } + + private static void GameExit(object sender, EventArgs e) + { + throw new NotImplementedException(); + } + + public void LogGameData(object sender, GameLogEventArgs e) + { + throw new NotImplementedException(); + } + + public void LogLaunchData(object sender, LaunchLogEventArgs e) + { + throw new NotImplementedException(); + } + + public void GameExit(object sender, GameExitEventArgs e) + { + throw new NotImplementedException(); + } + + #region IDisposable Support + + // Dispose() calls Dispose(true) + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + // NOTE: Leave out the finalizer altogether if this class doesn't + // own unmanaged resources, but leave the other methods + // exactly as they are. + ~DefaultMinecraftUWPCore() + { + // Finalizer calls Dispose(false) + Dispose(false); + } + + // The bulk of the clean-up code is implemented in Dispose(bool) + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + } + } + + #endregion + } +} diff --git a/Interface/IGameCore.cs b/Interface/IGameCore.cs index 973a8cae..18cf2654 100644 --- a/Interface/IGameCore.cs +++ b/Interface/IGameCore.cs @@ -13,6 +13,7 @@ public interface IGameCore string RootPath { get; set; } Guid ClientToken { get; set; } IVersionLocator VersionLocator { get; set; } + LaunchResult Launch(LaunchSettings settings); Task LaunchTaskAsync(LaunchSettings settings); /// diff --git a/ProjBobcat.csproj b/ProjBobcat.csproj index 62b82b2b..cc81f1ad 100644 --- a/ProjBobcat.csproj +++ b/ProjBobcat.csproj @@ -64,6 +64,9 @@ + + ..\packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.1.0\lib\net4\System.Management.Automation.dll + @@ -145,6 +148,7 @@ + @@ -167,6 +171,7 @@ + @@ -181,7 +186,6 @@ - diff --git a/ProjBobcat.nuspec b/ProjBobcat.nuspec index 7bbdfe9a..ba53b0bc 100644 --- a/ProjBobcat.nuspec +++ b/ProjBobcat.nuspec @@ -2,7 +2,7 @@ ProjBobcat - 1.0.1.4 + 1.0.1.5 ProjBobcat Corona Studio Corona Studio @@ -13,12 +13,13 @@ Bobcat.png The next-generation Minecraft launcher core written in C# providing the freest, fastest and the most complete experience. The next-generation Minecraft launcher core written in C# providing the freest, fastest and the most complete experience. - Fix critical bugs. + Add MinecraftUWP support. Copyright © 2020 Corona Studio minecraft-launcher minecraft launcher csharp + diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 52655f9c..184e4e29 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.1.4")] -[assembly: AssemblyFileVersion("1.0.1.4")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.1.5")] +[assembly: AssemblyFileVersion("1.0.1.5")] \ No newline at end of file diff --git a/README.md b/README.md index 98694ab7..8f53d954 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ For Chinese version of README.md, see README_zh_cn.md. | Old Forge Installation Model | ✅ | | New Forge Installation Model | ✅ | | Resource Auto Completion (Multi-thread downloader) | ✅ | +| Minecraft: Windows 10 Edition Support (Detector and launcher) | ✅ | ## Instruction diff --git a/README_zh_cn.md b/README_zh_cn.md index 35f0fe8b..3b96464b 100644 --- a/README_zh_cn.md +++ b/README_zh_cn.md @@ -51,6 +51,7 @@ | 旧版Forge安装模型 | ✅ | | 新版Forge安装模型 | ✅ | | 资源自动补全(多线程下载) | ✅ | +| Windows 10版Minecraft支持(检测和启动) | ✅ | ## 使用说明 diff --git a/app.config b/app.config new file mode 100644 index 00000000..1f0610e0 --- /dev/null +++ b/app.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + True + + + + \ No newline at end of file diff --git a/packages.config b/packages.config index b0e254ec..5eaa453d 100644 --- a/packages.config +++ b/packages.config @@ -5,6 +5,7 @@ + \ No newline at end of file