对代码插件MOD作者提供部分MOD信息

This commit is contained in:
ZouJin 2024-05-10 16:04:08 +08:00
parent 31bed95a43
commit 6d523d464d
4 changed files with 93 additions and 12 deletions

View File

@ -1,6 +1,7 @@
using LinePutScript.Dictionary; using LinePutScript.Dictionary;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
@ -212,6 +213,19 @@ namespace VPet_Simulator.Windows.Interface
/// UI线程调用位置 /// UI线程调用位置
/// </summary> /// </summary>
Dispatcher Dispatcher { get; } Dispatcher Dispatcher { get; }
/// <summary>
/// 获取当前所有MOD信息
/// </summary>
IEnumerable<IModInfo> ModInfo { get; }
/// <summary>
/// 获取当前所有已启用的MOD信息
/// </summary>
IEnumerable<IModInfo> OnModInfo { get; }
/// <summary>
/// 所有MOD文件位置
/// </summary>
public List<DirectoryInfo> MODPath { get; }
} }
} }

View File

@ -0,0 +1,58 @@
using LinePutScript.Converter;
using LinePutScript.Dictionary;
using LinePutScript.Localization.WPF;
using LinePutScript;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using VPet_Simulator.Core;
namespace VPet_Simulator.Windows.Interface;
/// <summary>
/// 模组信息接口
/// </summary>
public interface IModInfo
{
/// <summary>
/// 模组名称
/// </summary>
public string Name { get; }
/// <summary>
/// 模组作者
/// </summary>
public string Author { get; }
/// <summary>
/// 如果是上传至Steam,则为SteamUserID
/// </summary>
public long AuthorID { get; }
/// <summary>
/// 上传至Steam的ItemID
/// </summary>
public ulong ItemID { get; }
/// <summary>
/// 介绍
/// </summary>
public string Intro { get; }
/// <summary>
/// 模组路径
/// </summary>
public DirectoryInfo Path { get; }
/// <summary>
/// 游戏版本
/// </summary>
public int GameVer { get; }
/// <summary>
/// 模组版本
/// </summary>
public int Ver { get; }
/// <summary>
/// 模组标签
/// </summary>
public HashSet<string> Tag { get; }
}

View File

@ -14,7 +14,7 @@ using VPet_Simulator.Windows.Interface;
namespace VPet_Simulator.Windows namespace VPet_Simulator.Windows
{ {
internal class CoreMOD internal class CoreMOD : IModInfo
{ {
/// <summary> /// <summary>
/// 自动启用MOD名称 /// 自动启用MOD名称
@ -29,21 +29,21 @@ namespace VPet_Simulator.Windows
"CSCore.dll" "CSCore.dll"
}; };
public static string NowLoading = null; public static string NowLoading = null;
public string Name; public string Name { get; set; }
public string Author; public string Author { get; set; }
/// <summary> /// <summary>
/// 如果是上传至Steam,则为SteamUserID /// 如果是上传至Steam,则为SteamUserID
/// </summary> /// </summary>
public long AuthorID; public long AuthorID { get; set; }
/// <summary> /// <summary>
/// 上传至Steam的ItemID /// 上传至Steam的ItemID
/// </summary> /// </summary>
public ulong ItemID; public ulong ItemID { get; set; }
public string Intro; public string Intro { get; set; }
public DirectoryInfo Path; public DirectoryInfo Path { get; set; }
public int GameVer; public int GameVer { get; set; }
public int Ver; public int Ver { get; set; }
public HashSet<string> Tag = new HashSet<string>(); public HashSet<string> Tag { get; set; } = new HashSet<string>();
public bool SuccessLoad = true; public bool SuccessLoad = true;
public DateTime CacheDate; public DateTime CacheDate;
public string ErrorMessage; public string ErrorMessage;

View File

@ -1390,16 +1390,25 @@ namespace VPet_Simulator.Windows
Task.Run(() => GameLoad(Path)); Task.Run(() => GameLoad(Path));
} }
/// <summary>
/// MOD地址
/// </summary>
public List<DirectoryInfo> MODPath { get; private set; }
public IEnumerable<IModInfo> ModInfo => CoreMODs;
public IEnumerable<IModInfo> OnModInfo => CoreMODs.FindAll(x => x.IsOnMOD(this));
/// <summary> /// <summary>
/// 加载游戏 /// 加载游戏
/// </summary> /// </summary>
/// <param name="Path">MOD地址</param> /// <param name="Path">MOD地址</param>
public async Task GameLoad(List<DirectoryInfo> Path) public async Task GameLoad(List<DirectoryInfo> Path)
{ {
Path = Path.Distinct().ToList(); MODPath = Path.Distinct().ToList();
await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "Loading MOD")); await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "Loading MOD"));
//加载mod //加载mod
foreach (DirectoryInfo di in Path) foreach (DirectoryInfo di in MODPath)
{ {
if (!File.Exists(di.FullName + @"\info.lps")) if (!File.Exists(di.FullName + @"\info.lps"))
continue; continue;