Skip to content

Commit

Permalink
Merge pull request #2 from Corona-Studio/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tyanyuy3125 authored Mar 5, 2020
2 parents b43d964 + 4d6c551 commit dd4f40f
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 7 deletions.
26 changes: 24 additions & 2 deletions Class/Helper/SystemInfoHelper.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
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
{
public static class SystemInfoHelper
{
/// <summary>
/// Detect javaw.exe via reg.
/// 从注册表中查找可能的javaw.exe位置
/// </summary>
/// <returns>JAVA地址列表</returns>
/// <returns>A list, containing all possible path of javaw.exe. JAVA地址列表</returns>
public static IEnumerable<string> FindJava()
{
try
Expand Down Expand Up @@ -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<PSObject> result = pl.Invoke();
rs.Close();
rs.Dispose();
if (result == null || String.IsNullOrEmpty(result[0].ToString()))
{
return false;
}
return true;
}
}
}
5 changes: 5 additions & 0 deletions DefaultComponent/Launch/DefaultGameCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public string RootPath
public event EventHandler<GameLogEventArgs> GameLogEventDelegate;
public event EventHandler<LaunchLogEventArgs> LaunchLogEventDelegate;

public LaunchResult Launch(LaunchSettings settings)
{
throw new NotImplementedException();
}

/// <summary>
/// 启动游戏。
/// Launch the game.
Expand Down
95 changes: 95 additions & 0 deletions DefaultComponent/Launch/DefaultMinecraftUWPCore.cs
Original file line number Diff line number Diff line change
@@ -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<GameExitEventArgs> GameExitEventDelegate;
[Obsolete("UWP 版本的Minecraft不需要该字段。")]
public event EventHandler<GameLogEventArgs> GameLogEventDelegate;
[Obsolete("UWP 版本的Minecraft不需要该字段。")]
public event EventHandler<LaunchLogEventArgs> 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<LaunchResult> 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
}
}
1 change: 1 addition & 0 deletions Interface/IGameCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface IGameCore
string RootPath { get; set; }
Guid ClientToken { get; set; }
IVersionLocator VersionLocator { get; set; }
LaunchResult Launch(LaunchSettings settings);
Task<LaunchResult> LaunchTaskAsync(LaunchSettings settings);

/// <summary>
Expand Down
6 changes: 5 additions & 1 deletion ProjBobcat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.1.0\lib\net4\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -145,6 +148,7 @@
<Compile Include="DefaultComponent\Launch\DefaultGameCore.cs" />
<Compile Include="DefaultComponent\Launch\DefaultLauncherProfileParser.cs" />
<Compile Include="DefaultComponent\Launch\DefaultVersionLocator.cs" />
<Compile Include="DefaultComponent\Launch\DefaultMinecraftUWPCore.cs" />
<Compile Include="DefaultComponent\ResourceInfoResolver\AssetInfoResolver.cs" />
<Compile Include="DefaultComponent\ResourceInfoResolver\LibraryInfoResolver.cs" />
<Compile Include="Event\DownloadFileChangedEventArgs.cs" />
Expand All @@ -167,6 +171,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="app.manifest" />
<None Include="packages.config" />
</ItemGroup>
Expand All @@ -181,7 +186,6 @@
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.NetFramework.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.NetFramework.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.NetFramework.CSharp.Analyzers.dll" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand Down
5 changes: 3 additions & 2 deletions ProjBobcat.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>ProjBobcat</id>
<version>1.0.1.4</version>
<version>1.0.1.5</version>
<title>ProjBobcat</title>
<authors>Corona Studio</authors>
<owners>Corona Studio</owners>
Expand All @@ -13,12 +13,13 @@
<icon>Bobcat.png</icon>
<description>The next-generation Minecraft launcher core written in C# providing the freest, fastest and the most complete experience.</description>
<summary>The next-generation Minecraft launcher core written in C# providing the freest, fastest and the most complete experience.</summary>
<releaseNotes>Fix critical bugs.</releaseNotes>
<releaseNotes>Add MinecraftUWP support.</releaseNotes>
<copyright>Copyright © 2020 Corona Studio</copyright>
<tags>minecraft-launcher minecraft launcher csharp</tags>
<dependencies>
<dependency id="Newtonsoft.Json" version="12.0.3" />
<dependency id="sharpcompress" version="0.24.0" />
<dependency id="Microsoft.PowerShell.5.ReferenceAssemblies" version="1.1.0" />
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.1.4")]
[assembly: AssemblyFileVersion("1.0.1.4")]
[assembly: AssemblyVersion("1.0.1.5")]
[assembly: AssemblyFileVersion("1.0.1.5")]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions README_zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
| 旧版Forge安装模型 ||
| 新版Forge安装模型 ||
| 资源自动补全(多线程下载) ||
| Windows 10版Minecraft支持(检测和启动) ||

## 使用说明

Expand Down
15 changes: 15 additions & 0 deletions app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ProjBobcat.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<ProjBobcat.Properties.Settings>
<setting name="IsAnalysisEnabled" serializeAs="String">
<value>True</value>
</setting>
</ProjBobcat.Properties.Settings>
</userSettings>
</configuration>
1 change: 1 addition & 0 deletions packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<package id="Microsoft.CodeQuality.Analyzers" version="2.9.8" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.NetCore.Analyzers" version="2.9.8" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.NetFramework.Analyzers" version="2.9.8" targetFramework="net472" developmentDependency="true" />
<package id="Microsoft.PowerShell.5.ReferenceAssemblies" version="1.1.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
<package id="SharpCompress" version="0.24.0" targetFramework="net472" />
</packages>

0 comments on commit dd4f40f

Please sign in to comment.