VPet.Solution 修复已损坏模组不会显示名称的问题

This commit is contained in:
Hakoyu
2024-01-19 04:13:27 +08:00
parent 94e34d2aaf
commit 440d2fdda7
3 changed files with 27 additions and 7 deletions

View File

@ -83,14 +83,15 @@ public class ModLoader
public ModLoader(string path)
{
ModPath = path;
var infoFile = Path.Combine(path, "info.lps");
if (File.Exists(infoFile) is false)
{
Name = Path.GetFileName(path);
IsSuccesses = false;
return;
}
var modlps = new LpsDocument(File.ReadAllText(infoFile));
ModPath = path;
Name = modlps.FindLine("vupmod").Info;
Intro = modlps.FindLine("intro").Info;
GameVer = modlps.FindSub("gamever").InfoToInt;

View File

@ -1,5 +1,6 @@
using HKW.HKWUtils.Observable;
using LinePutScript;
using LinePutScript.Localization.WPF;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@ -49,13 +50,24 @@ public class ModSettingModel : ObservableClass<ModSettingModel>
Mods.Add(modModel);
}
else
Mods.Add(new());
{
Mods.Add(
new()
{
Name = modName,
ModPath = "未知, 可能是{0}".Translate(Path.Combine(ModDirectory, modName))
}
);
}
}
foreach (var modPath in setting[WorkShopLineName])
{
var loader = new ModLoader(modPath.Name);
if (loader.IsSuccesses is false)
{
Mods.Add(new() { Name = loader.Name, ModPath = loader.ModPath });
return;
}
var modModel = new ModModel(loader);
modModel.IsPass = setting[PassModLineName].Contains(modModel.Name);
modModel.IsMsg = setting[MsgModLineName].Contains(modModel.Name);
@ -264,8 +276,8 @@ public class ModModel : ObservableClass<ModModel>
public ModModel()
{
PropertyChanged += ModModel_PropertyChanged;
IsEnabled = null;
RefreshState();
}
private void ModModel_PropertyChanged(
@ -289,10 +301,10 @@ public class ModModel : ObservableClass<ModModel>
public void RefreshState()
{
if (IsEnabled is true)
State = "已启用";
State = "已启用".Translate();
else if (IsEnabled is false)
State = "已关闭";
State = "已关闭".Translate();
else
State = "已损坏";
State = "已损坏".Translate();
}
}

View File

@ -137,7 +137,14 @@ public class ModSettingPageVM : ObservableClass<ModSettingPageVM>
private void OpenModPathCommand_ExecuteCommand(ModModel parameter)
{
Utils.OpenLink(parameter.ModPath);
try
{
Utils.OpenLink(parameter.ModPath);
}
catch
{
MessageBox.Show("未在路径\n{0}\n中找到模组".Translate(parameter.ModPath));
}
}
private void Current_PropertyChangedX(SettingWindowVM sender, PropertyChangedXEventArgs e)