MOD制作器兼容

This commit is contained in:
ZouJin 2024-03-30 17:08:50 +08:00
parent a04d590533
commit 07196d20e9
6 changed files with 52 additions and 50 deletions

View File

@ -26,7 +26,7 @@
<PackageReference Include="LinePutScript" Version="1.11.6" />
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.6" />
<PackageReference Include="Panuon.WPF" Version="1.1.0" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">

View File

@ -19,6 +19,6 @@
<PackageReference Include="LinePutScript" Version="1.11.6" />
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.6" />
<PackageReference Include="Panuon.WPF" Version="1.1.0" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.1" />
</ItemGroup>
</Project>

View File

@ -19,7 +19,7 @@ namespace VPet_Simulator.Windows
/// <summary>
/// 自动启用MOD名称
/// </summary>
public static readonly string[] OnModDefList = new string[] { "Core", "PCat", };//"ModMaker" 暂时移除MODMaker
public static readonly string[] OnModDefList = new string[] { "Core", "PCat", "ModMaker" };
public static HashSet<string> LoadedDLL { get; } = new HashSet<string>()
{
@ -279,63 +279,65 @@ namespace VPet_Simulator.Windows
continue;
}
#endif
#if !DEBUG5
try
{
var path = tmpfi.Name;
if (LoadedDLL.Contains(path))
#endif
var path = tmpfi.Name;
if (LoadedDLL.Contains(path))
continue;
LoadedDLL.Add(path);
X509Certificate2 certificate;
try
{
certificate = new X509Certificate2(tmpfi.FullName);
}
catch
{
certificate = null;
}
if (certificate != null)
{
if (certificate.Subject == "CN=\"Shenzhen Lingban Computer Technology Co., Ltd.\", O=\"Shenzhen Lingban Computer Technology Co., Ltd.\", L=Shenzhen, S=Guangdong Province, C=CN, SERIALNUMBER=91440300MA5H8REU3K, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.1=Shenzhen, OID.1.3.6.1.4.1.311.60.2.1.2=Guangdong Province, OID.1.3.6.1.4.1.311.60.2.1.3=CN"
&& certificate.Issuer == "CN=DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1, O=\"DigiCert, Inc.\", C=US")
{//LBGame 信任的证书
if (authtype != "FAIL")
authtype = "[认证]".Translate();
}
else if (!(certificate.Subject.Contains("Microsoft Corporation") &&
certificate.Issuer.Contains("Microsoft Corporation")) && !IsPassMOD(mw))
{//不是通过模组,不加载
SuccessLoad = false;
continue;
LoadedDLL.Add(path);
X509Certificate2 certificate;
try
{
certificate = new X509Certificate2(tmpfi.FullName);
}
catch
{
certificate = null;
}
else
{
authtype = "FAIL";
if (!IsPassMOD(mw))
{//不是通过模组,不加载
SuccessLoad = false;
Author = modlps.FindSub("author").Info.Split('[').First();
continue;
}
if (certificate != null)
}
Assembly dll = Assembly.LoadFrom(tmpfi.FullName);
var v = dll.GetExportedTypes();
foreach (Type exportedType in v)
{
if (exportedType.BaseType == typeof(MainPlugin))
{
if (certificate.Subject == "CN=\"Shenzhen Lingban Computer Technology Co., Ltd.\", O=\"Shenzhen Lingban Computer Technology Co., Ltd.\", L=Shenzhen, S=Guangdong Province, C=CN, SERIALNUMBER=91440300MA5H8REU3K, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.1=Shenzhen, OID.1.3.6.1.4.1.311.60.2.1.2=Guangdong Province, OID.1.3.6.1.4.1.311.60.2.1.3=CN"
&& certificate.Issuer == "CN=DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1, O=\"DigiCert, Inc.\", C=US")
{//LBGame 信任的证书
if (authtype != "FAIL")
authtype = "[认证]".Translate();
}
else if (certificate.Subject != "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" && !IsPassMOD(mw))
{//不是通过模组,不加载
SuccessLoad = false;
continue;
}
mw.Plugins.Add((MainPlugin)Activator.CreateInstance(exportedType, mw));
}
else
{
authtype = "FAIL";
if (!IsPassMOD(mw))
{//不是通过模组,不加载
SuccessLoad = false;
Author = modlps.FindSub("author").Info.Split('[').First();
continue;
}
}
Assembly dll = Assembly.LoadFrom(tmpfi.FullName);
var v = dll.GetExportedTypes();
foreach (Type exportedType in v)
{
if (exportedType.BaseType == typeof(MainPlugin))
{
mw.Plugins.Add((MainPlugin)Activator.CreateInstance(exportedType, mw));
}
}
}
#if !DEBUG5
}
catch (Exception e)
{
ErrorMessage = e.Message;
SuccessLoad = false;
}
#endif
}
if (authtype != "FAIL")
Author += authtype;

View File

@ -2042,7 +2042,7 @@ namespace VPet_Simulator.Windows
if (!cm.SuccessLoad)
if (cm.Tag.Contains("该模组已损坏"))
MessageBoxX.Show("模组 {0} 插件损坏\n虚拟桌宠模拟器未能成功加载该插件\n请联系作者修复该问题".Translate(cm.Name) + '\n' + cm.ErrorMessage, "该模组已损坏".Translate());
else if (Set.IsPassMOD(cm.Name))
else if (Set.IsPassMOD(cm.Name) || !string.IsNullOrEmpty(cm.ErrorMessage))
MessageBoxX.Show("模组 {0} 的代码插件损坏\n虚拟桌宠模拟器未能成功加载该插件\n请联系作者修复该问题".Translate(cm.Name) + '\n' + cm.ErrorMessage, "{0} 未加载代码插件".Translate(cm.Name));
else if (Set.IsMSGMOD(cm.Name))
MessageBoxX.Show("由于 {0} 包含代码插件\n虚拟桌宠模拟器已自动停止加载该插件\n请手动前往设置允许启用该mod 代码插件".Translate(cm.Name), "{0} 未加载代码插件".Translate(cm.Name));

View File

@ -223,7 +223,7 @@
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="Panuon.WPF" Version="1.1.0" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VPet-Simulator.Core\VPet-Simulator.Core.csproj" />

View File

@ -23,7 +23,7 @@
<PackageReference Include="LinePutScript.Localization.WPF" Version="1.0.6" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Panuon.WPF" Version="1.1.0" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1" />
<PackageReference Include="Panuon.WPF.UI" Version="1.2.1.1" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
</Project>