From 6d523d464d0b61b1095f34a26231c86560246458 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Fri, 10 May 2024 16:04:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E4=BB=A3=E7=A0=81=E6=8F=92=E4=BB=B6MO?= =?UTF-8?q?D=E4=BD=9C=E8=80=85=E6=8F=90=E4=BE=9B=E9=83=A8=E5=88=86MOD?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IMainWindow.cs | 14 +++++ .../Mod/IModInfo.cs | 58 +++++++++++++++++++ VPet-Simulator.Windows/Function/CoreMOD.cs | 20 +++---- VPet-Simulator.Windows/MainWindow.cs | 13 ++++- 4 files changed, 93 insertions(+), 12 deletions(-) create mode 100644 VPet-Simulator.Windows.Interface/Mod/IModInfo.cs diff --git a/VPet-Simulator.Windows.Interface/IMainWindow.cs b/VPet-Simulator.Windows.Interface/IMainWindow.cs index e653beb..f90756d 100644 --- a/VPet-Simulator.Windows.Interface/IMainWindow.cs +++ b/VPet-Simulator.Windows.Interface/IMainWindow.cs @@ -1,6 +1,7 @@ using LinePutScript.Dictionary; using System; using System.Collections.Generic; +using System.IO; using System.Windows; using System.Windows.Controls; using System.Windows.Media; @@ -212,6 +213,19 @@ namespace VPet_Simulator.Windows.Interface /// UI线程调用位置 /// Dispatcher Dispatcher { get; } + /// + /// 获取当前所有MOD信息 + /// + IEnumerable ModInfo { get; } + /// + /// 获取当前所有已启用的MOD信息 + /// + IEnumerable OnModInfo { get; } + + /// + /// 所有MOD文件位置 + /// + public List MODPath { get; } } } diff --git a/VPet-Simulator.Windows.Interface/Mod/IModInfo.cs b/VPet-Simulator.Windows.Interface/Mod/IModInfo.cs new file mode 100644 index 0000000..ce74e61 --- /dev/null +++ b/VPet-Simulator.Windows.Interface/Mod/IModInfo.cs @@ -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; + +/// +/// 模组信息接口 +/// +public interface IModInfo +{ + /// + /// 模组名称 + /// + public string Name { get; } + /// + /// 模组作者 + /// + public string Author { get; } + /// + /// 如果是上传至Steam,则为SteamUserID + /// + public long AuthorID { get; } + /// + /// 上传至Steam的ItemID + /// + public ulong ItemID { get; } + /// + /// 介绍 + /// + public string Intro { get; } + /// + /// 模组路径 + /// + public DirectoryInfo Path { get; } + /// + /// 游戏版本 + /// + public int GameVer { get; } + /// + /// 模组版本 + /// + public int Ver { get; } + /// + /// 模组标签 + /// + public HashSet Tag { get; } +} diff --git a/VPet-Simulator.Windows/Function/CoreMOD.cs b/VPet-Simulator.Windows/Function/CoreMOD.cs index df44624..6807203 100644 --- a/VPet-Simulator.Windows/Function/CoreMOD.cs +++ b/VPet-Simulator.Windows/Function/CoreMOD.cs @@ -14,7 +14,7 @@ using VPet_Simulator.Windows.Interface; namespace VPet_Simulator.Windows { - internal class CoreMOD + internal class CoreMOD : IModInfo { /// /// 自动启用MOD名称 @@ -29,21 +29,21 @@ namespace VPet_Simulator.Windows "CSCore.dll" }; public static string NowLoading = null; - public string Name; - public string Author; + public string Name { get; set; } + public string Author { get; set; } /// /// 如果是上传至Steam,则为SteamUserID /// - public long AuthorID; + public long AuthorID { get; set; } /// /// 上传至Steam的ItemID /// - public ulong ItemID; - public string Intro; - public DirectoryInfo Path; - public int GameVer; - public int Ver; - public HashSet Tag = new HashSet(); + public ulong ItemID { get; set; } + public string Intro { get; set; } + public DirectoryInfo Path { get; set; } + public int GameVer { get; set; } + public int Ver { get; set; } + public HashSet Tag { get; set; } = new HashSet(); public bool SuccessLoad = true; public DateTime CacheDate; public string ErrorMessage; diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index 9943085..1afb437 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -1390,16 +1390,25 @@ namespace VPet_Simulator.Windows Task.Run(() => GameLoad(Path)); } + /// + /// MOD地址 + /// + public List MODPath { get; private set; } + + public IEnumerable ModInfo => CoreMODs; + + public IEnumerable OnModInfo => CoreMODs.FindAll(x => x.IsOnMOD(this)); + /// /// 加载游戏 /// /// MOD地址 public async Task GameLoad(List Path) { - Path = Path.Distinct().ToList(); + MODPath = Path.Distinct().ToList(); await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "Loading MOD")); //加载mod - foreach (DirectoryInfo di in Path) + foreach (DirectoryInfo di in MODPath) { if (!File.Exists(di.FullName + @"\info.lps")) continue;