diff --git a/VPet-Simulator.Windows/MutiPlayer/MPMOD.cs b/VPet-Simulator.Windows/MutiPlayer/MPMOD.cs index 5e02283..517f103 100644 --- a/VPet-Simulator.Windows/MutiPlayer/MPMOD.cs +++ b/VPet-Simulator.Windows/MutiPlayer/MPMOD.cs @@ -46,84 +46,86 @@ public class MPMOD try { #endif - var Path = directory; - LpsDocument modlps = new LpsDocument(File.ReadAllText(directory.FullName + @"\info.lps")); - Name = modlps.FindLine("vupmod").Info; + var Path = directory; + LpsDocument modlps = new LpsDocument(File.ReadAllText(directory.FullName + @"\info.lps")); + Name = modlps.FindLine("vupmod").Info; - //MOD未加载时支持翻译 - foreach (var line in modlps.FindAllLine("lang")) + //MOD未加载时支持翻译 + foreach (var line in modlps.FindAllLine("lang")) + { + List ls = new List(); + foreach (var sub in line) { - List ls = new List(); - foreach (var sub in line) - { - ls.Add(new Line(sub.Name, sub.info)); - } - LocalizeCore.AddCulture(line.info, ls); - } - if (!IsOnMOD(mw)) - { - return; + ls.Add(new Line(sub.Name, sub.info)); } + LocalizeCore.AddCulture(line.info, ls); + } + if (!IsOnMOD(mw)) + { + return; + } - foreach (DirectoryInfo di in Path.EnumerateDirectories()) + foreach (DirectoryInfo di in Path.EnumerateDirectories()) + { + switch (di.Name.ToLower()) { - switch (di.Name.ToLower()) - { - case "pet": - //宠物模型 - foreach (FileInfo fi in di.EnumerateFiles("*.lps")) + case "pet": + //宠物模型 + foreach (FileInfo fi in di.EnumerateFiles("*.lps")) + { + LpsDocument lps = new LpsDocument(File.ReadAllText(fi.FullName)); + if (lps.First().Name.ToLower() == "pet") { - LpsDocument lps = new LpsDocument(File.ReadAllText(fi.FullName)); - if (lps.First().Name.ToLower() == "pet") + var name = lps.First().Info; + if (name == "默认虚拟桌宠") + name = "vup";//旧版本名称兼容 + var p = mw.Pets.FirstOrDefault(x => x.Name == name); + if (p == null) { - var name = lps.First().Info; - var p = mw.Pets.FirstOrDefault(x => x.Name == name); - if (p == null) - { - p = new PetLoader(lps, di); - mw.Pets.Add(p); - } - else - { - var dis = new DirectoryInfo(di.FullName + "\\" + lps.First()["path"].Info); - p.path.Add(di.FullName + "\\" + lps.First()["path"].Info); - p.Config.Set(lps); - } + p = new PetLoader(lps, di); + mw.Pets.Add(p); + } + else + { + var dis = new DirectoryInfo(di.FullName + "\\" + lps.First()["path"].Info); + p.path.Add(di.FullName + "\\" + lps.First()["path"].Info); + p.Config.Set(lps); } } - break; - case "food": - foreach (FileInfo fi in di.EnumerateFiles("*.lps")) + } + break; + case "food": + foreach (FileInfo fi in di.EnumerateFiles("*.lps")) + { + var tmp = new LpsDocument(File.ReadAllText(fi.FullName)); + foreach (ILine li in tmp) { - var tmp = new LpsDocument(File.ReadAllText(fi.FullName)); - foreach (ILine li in tmp) - { - if (li.Name != "food") - continue; - string tmps = li.Find("name").info; - mw.Foods.RemoveAll(x => x.Name == tmps); - mw.Foods.Add(LPSConvert.DeserializeObject(li)); - } + if (li.Name != "food") + continue; + string tmps = li.Find("name").info; + mw.Foods.RemoveAll(x => x.Name == tmps); + mw.Foods.Add(LPSConvert.DeserializeObject(li)); } - break; - case "image": - LoadImage(mw, di); - break; - case "lang": - foreach (FileInfo fi in di.EnumerateFiles("*.lps")) + } + break; + case "image": + LoadImage(mw, di); + break; + case "lang": + foreach (FileInfo fi in di.EnumerateFiles("*.lps")) + { + LocalizeCore.AddCulture(fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length), new LPS_D(File.ReadAllText(fi.FullName))); + } + foreach (DirectoryInfo dis in di.EnumerateDirectories()) + { + foreach (FileInfo fi in dis.EnumerateFiles("*.lps")) { - LocalizeCore.AddCulture(fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length), new LPS_D(File.ReadAllText(fi.FullName))); + LocalizeCore.AddCulture(dis.Name, new LPS_D(File.ReadAllText(fi.FullName))); } - foreach (DirectoryInfo dis in di.EnumerateDirectories()) - { - foreach (FileInfo fi in dis.EnumerateFiles("*.lps")) - { - LocalizeCore.AddCulture(dis.Name, new LPS_D(File.ReadAllText(fi.FullName))); - } - } - break; - } + } + break; } + } #if !DEBUG } catch