mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
VPet.Solution 新增 setting-workshop支持
This commit is contained in:
@ -15,6 +15,7 @@ using System.Threading.Tasks;
|
|||||||
using VPet_Simulator.Core;
|
using VPet_Simulator.Core;
|
||||||
using VPet_Simulator.Windows.Interface;
|
using VPet_Simulator.Windows.Interface;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
using LinePutScript.Localization.WPF;
|
||||||
|
|
||||||
namespace VPet.Solution.Models;
|
namespace VPet.Solution.Models;
|
||||||
|
|
||||||
@ -75,10 +76,21 @@ public class ModLoader
|
|||||||
|
|
||||||
public BitmapImage? Image { get; } = null;
|
public BitmapImage? Image { get; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取成功
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSuccesses { get; } = true;
|
||||||
|
|
||||||
public ModLoader(string path)
|
public ModLoader(string path)
|
||||||
{
|
{
|
||||||
|
var infoFile = Path.Combine(path, "info.lps");
|
||||||
|
if (File.Exists(infoFile) is false)
|
||||||
|
{
|
||||||
|
IsSuccesses = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var modlps = new LpsDocument(File.ReadAllText(infoFile));
|
||||||
ModPath = path;
|
ModPath = path;
|
||||||
var modlps = new LpsDocument(File.ReadAllText(Path.Combine(path + @"\info.lps")));
|
|
||||||
Name = modlps.FindLine("vupmod").Info;
|
Name = modlps.FindLine("vupmod").Info;
|
||||||
Intro = modlps.FindLine("intro").Info;
|
Intro = modlps.FindLine("intro").Info;
|
||||||
GameVer = modlps.FindSub("gamever").InfoToInt;
|
GameVer = modlps.FindSub("gamever").InfoToInt;
|
||||||
@ -104,7 +116,8 @@ public class ModLoader
|
|||||||
}
|
}
|
||||||
foreach (var dir in Directory.EnumerateDirectories(path))
|
foreach (var dir in Directory.EnumerateDirectories(path))
|
||||||
{
|
{
|
||||||
switch (dir.ToLower())
|
var dirName = Path.GetFileName(dir);
|
||||||
|
switch (dirName.ToLower())
|
||||||
{
|
{
|
||||||
case "pet":
|
case "pet":
|
||||||
//宠物模型
|
//宠物模型
|
||||||
@ -121,6 +134,23 @@ public class ModLoader
|
|||||||
break;
|
break;
|
||||||
case "lang":
|
case "lang":
|
||||||
Tags.Add("lang");
|
Tags.Add("lang");
|
||||||
|
foreach (var langFile in Directory.EnumerateFiles(dir, "*.lps"))
|
||||||
|
{
|
||||||
|
LocalizeCore.AddCulture(
|
||||||
|
Path.GetFileNameWithoutExtension(dir),
|
||||||
|
new LPS_D(File.ReadAllText(langFile))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
foreach (var langDir in Directory.EnumerateDirectories(dir))
|
||||||
|
{
|
||||||
|
foreach (var langFile in Directory.EnumerateFiles(langDir, "*.lps"))
|
||||||
|
{
|
||||||
|
LocalizeCore.AddCulture(
|
||||||
|
Path.GetFileNameWithoutExtension(langDir),
|
||||||
|
new LPS_D(File.ReadAllText(langFile))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ public class ModSettingModel : ObservableClass<ModSettingModel>
|
|||||||
public const string ModLineName = "onmod";
|
public const string ModLineName = "onmod";
|
||||||
public const string PassModLineName = "passmod";
|
public const string PassModLineName = "passmod";
|
||||||
public const string MsgModLineName = "msgmod";
|
public const string MsgModLineName = "msgmod";
|
||||||
|
public const string WorkShopLineName = "workshop";
|
||||||
public static string ModDirectory = Path.Combine(Environment.CurrentDirectory, "mod");
|
public static string ModDirectory = Path.Combine(Environment.CurrentDirectory, "mod");
|
||||||
public static Dictionary<string, ModLoader> LocalMods = Directory.Exists(ModDirectory) is false
|
public static Dictionary<string, ModLoader> LocalMods = Directory.Exists(ModDirectory) is false
|
||||||
? new(StringComparer.OrdinalIgnoreCase)
|
? new(StringComparer.OrdinalIgnoreCase)
|
||||||
@ -40,7 +41,7 @@ public class ModSettingModel : ObservableClass<ModSettingModel>
|
|||||||
foreach (var item in setting[ModLineName])
|
foreach (var item in setting[ModLineName])
|
||||||
{
|
{
|
||||||
var modName = item.Name;
|
var modName = item.Name;
|
||||||
if (LocalMods.TryGetValue(modName, out var loader))
|
if (LocalMods.TryGetValue(modName, out var loader) && loader.IsSuccesses)
|
||||||
{
|
{
|
||||||
var modModel = new ModModel(loader);
|
var modModel = new ModModel(loader);
|
||||||
modModel.IsPass = setting[PassModLineName].Contains(modName);
|
modModel.IsPass = setting[PassModLineName].Contains(modName);
|
||||||
@ -50,6 +51,16 @@ public class ModSettingModel : ObservableClass<ModSettingModel>
|
|||||||
else
|
else
|
||||||
Mods.Add(new());
|
Mods.Add(new());
|
||||||
}
|
}
|
||||||
|
foreach (var modPath in setting[WorkShopLineName])
|
||||||
|
{
|
||||||
|
var loader = new ModLoader(modPath.Name);
|
||||||
|
if (loader.IsSuccesses is false)
|
||||||
|
return;
|
||||||
|
var modModel = new ModModel(loader);
|
||||||
|
modModel.IsPass = setting[PassModLineName].Contains(modModel.Name);
|
||||||
|
modModel.IsMsg = setting[MsgModLineName].Contains(modModel.Name);
|
||||||
|
Mods.Add(modModel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
Reference in New Issue
Block a user