mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
105 lines
3.9 KiB
C#
105 lines
3.9 KiB
C#
using LinePutScript;
|
|
using Steamworks.Ugc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Controls.Primitives;
|
|
using System.Windows.Media;
|
|
using VPet_Simulator.Core;
|
|
using static VPet_Simulator.Core.GraphCore;
|
|
|
|
namespace VPet_Simulator.Windows
|
|
{
|
|
public class CoreMOD
|
|
{
|
|
public static string NowLoading = null;
|
|
public string Name;
|
|
public string Author;
|
|
/// <summary>
|
|
/// 如果是上传至Steam,则为SteamUserID
|
|
/// </summary>
|
|
public long AuthorID;
|
|
/// <summary>
|
|
/// 上传至Steam的ItemID
|
|
/// </summary>
|
|
public ulong ItemID;
|
|
public string Intro;
|
|
public DirectoryInfo Path;
|
|
public int GameVer;
|
|
public int Ver;
|
|
public string Content = "";
|
|
public bool SuccessLoad = true;
|
|
public static string INTtoVER(int ver) => $"{ver / 100}.{ver % 100:00}";
|
|
public CoreMOD(DirectoryInfo directory, MainWindow mw)
|
|
{
|
|
Path = directory;
|
|
LpsDocument modlps = new LpsDocument(File.ReadAllText(directory.FullName + @"\info.lps"));
|
|
Name = modlps.FindLine("vupmod").Info;
|
|
NowLoading = Name;
|
|
Intro = modlps.FindLine("intro").Info;
|
|
GameVer = modlps.FindSub("gamever").InfoToInt;
|
|
Ver = modlps.FindSub("ver").InfoToInt;
|
|
Author = modlps.FindSub("author").Info;
|
|
if (modlps.FindLine("authorid") != null)
|
|
AuthorID = modlps.FindLine("authorid").InfoToInt64;
|
|
else
|
|
AuthorID = 0;
|
|
if (modlps.FindLine("itemid") != null)
|
|
ItemID = Convert.ToUInt64(modlps.FindLine("itemid").info);
|
|
else
|
|
ItemID = 0;
|
|
if (IsBanMOD(mw))
|
|
{
|
|
Content = "该模组已停用";
|
|
return;
|
|
}
|
|
|
|
foreach (DirectoryInfo di in Path.EnumerateDirectories())
|
|
{
|
|
switch (di.Name.ToLower())
|
|
{
|
|
case "pet":
|
|
//宠物模型
|
|
Content += "宠物形象\n";
|
|
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
|
|
{
|
|
LpsDocument lps = new LpsDocument(File.ReadAllText(fi.FullName));
|
|
if (lps.First().Name.ToLower() == "pet")
|
|
{
|
|
var name = lps.First().Info;
|
|
var p = mw.Pets.FirstOrDefault(x => x.Name == name);
|
|
if (p == null)
|
|
mw.Pets.Add(new PetLoader(lps, di));
|
|
else
|
|
{
|
|
p.path.Add(di.FullName + "\\" + lps.First()["path"].Info);
|
|
p.Config.Set(lps);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
public bool IsBanMOD(MainWindow mw) => mw.Set.IsBanMod(Name);
|
|
public bool IsPassMOD(MainWindow mw) => mw.Set.IsPassMOD(Name);
|
|
|
|
public void WriteFile()
|
|
{
|
|
LpsDocument modlps = new LpsDocument(File.ReadAllText(Path.FullName + @"\info.lps"));
|
|
modlps.FindLine("vupmod").Info = Name;
|
|
modlps.FindLine("intro").Info = Intro;
|
|
modlps.FindSub("gamever").InfoToInt = GameVer;
|
|
modlps.FindSub("ver").InfoToInt = Ver;
|
|
modlps.FindSub("author").Info = Author;
|
|
modlps.FindorAddLine("authorid").InfoToInt64 = AuthorID;
|
|
modlps.FindorAddLine("itemid").info = ItemID.ToString();
|
|
File.WriteAllText(Path.FullName + @"\info.lps", modlps.ToString());
|
|
}
|
|
}
|
|
}
|