private void FindReferencedMods(BuildProperties properties, Dictionary <string, LocalMod> mods, bool requireWeak) { foreach (var refName in properties.RefNames(true)) { if (mods.ContainsKey(refName)) { continue; } bool isWeak = properties.weakReferences.Any(r => r.mod == refName); LocalMod mod; try { var modFile = new TmodFile(Path.Combine(ModPath, refName + ".tmod")); modFile.Read(); mod = new LocalMod(modFile); modFile.Close(); } catch (FileNotFoundException) when(isWeak && !requireWeak) { // don't recursively require weak deps, if the mod author needs to compile against them, they'll have them installed continue; } catch (Exception ex) { throw new Exception(Language.GetTextValue("tModLoader.BuildErrorModReference", refName), ex); } mods[refName] = mod; FindReferencedMods(mod.properties, mods, false); } }
private static bool FindReferencedMods(BuildProperties properties, Dictionary <string, LocalMod> mods) { foreach (var refName in properties.RefNames(true)) { if (mods.ContainsKey(refName)) { continue; } var modFile = new TmodFile(Path.Combine(ModPath, refName + ".tmod")); try { modFile.Read(TmodFile.LoadedState.Code); } catch (Exception ex) { ErrorLogger.LogBuildError("Mod reference " + refName + " " + ex); return(false); } var mod = new LocalMod(modFile); mods[refName] = mod; FindReferencedMods(mod.properties, mods); } return(true); }
private void FindReferencedMods(BuildProperties properties, Dictionary <string, LocalMod> mods) { foreach (var refName in properties.RefNames(true)) { if (mods.ContainsKey(refName)) { continue; } LocalMod mod; try { var modFile = new TmodFile(Path.Combine(ModPath, refName + ".tmod")); modFile.Read(); mod = new LocalMod(modFile); modFile.Close(); } catch (Exception ex) { throw new Exception(Language.GetTextValue("tModLoader.BuildErrorModReference", refName), ex); } mods[refName] = mod; FindReferencedMods(mod.properties, mods); } }
private static bool FindReferencedMods(BuildProperties properties, Dictionary <string, LoadingMod> mods) { foreach (var refName in properties.RefNames(true)) { if (mods.ContainsKey(refName)) { continue; } var modFile = new TmodFile(Path.Combine(ModPath, refName + ".tmod")); modFile.Read(); var ex = modFile.ValidMod(); if (ex != null) { ErrorLogger.LogBuildError("Mod reference " + refName + " " + ex); return(false); } var mod = new LoadingMod(modFile, BuildProperties.ReadModFile(modFile)); mods[refName] = mod; FindReferencedMods(mod.properties, mods); } return(true); }
internal static BuildProperties ReadBuildFile(string modDir) { string propertiesFile = modDir + Path.DirectorySeparatorChar + "build.txt"; string descriptionfile = modDir + Path.DirectorySeparatorChar + "description.txt"; BuildProperties properties = new BuildProperties(); if (!File.Exists(propertiesFile)) { return(properties); } if (File.Exists(descriptionfile)) { properties.description = File.ReadAllText(descriptionfile); } string[] lines = File.ReadAllLines(propertiesFile); foreach (string line in lines) { if (line.Length == 0) { continue; } int split = line.IndexOf('='); string property = line.Substring(0, split).Trim(); string value = line.Substring(split + 1).Trim(); if (value.Length == 0) { continue; } switch (property) { case "dllReferences": properties.dllReferences = ReadList(value).ToArray(); break; case "modReferences": properties.modReferences = ReadList(value).Select(ModReference.Parse).ToArray(); break; case "weakReferences": properties.weakReferences = ReadList(value).Select(ModReference.Parse).ToArray(); break; case "sortBefore": properties.sortAfter = ReadList(value).ToArray(); break; case "sortAfter": properties.sortBefore = ReadList(value).ToArray(); break; case "author": properties.author = value; break; case "version": properties.version = new Version(value); break; case "displayName": properties.displayName = value; break; case "homepage": properties.homepage = value; break; case "noCompile": properties.noCompile = value.ToLower() == "true"; break; case "hideCode": properties.hideCode = value.ToLower() != "false"; break; case "hideResources": properties.hideResources = value.ToLower() != "false"; break; case "includeSource": properties.includeSource = value.ToLower() == "true"; break; case "includePDB": properties.includePDB = value.ToLower() == "true"; break; case "buildIgnore": properties.buildIgnores = value.Split(',').Select(s => s.Trim()).Where(s => s.Length > 0).ToArray(); break; case "languageVersion": if (!int.TryParse(value, out properties.languageVersion)) { throw new Exception("languageVersion not an int: " + value); } if (properties.languageVersion < 4 || properties.languageVersion > 6) { throw new Exception("languageVersion (" + properties.languageVersion + ") must be between 4 and 6"); } break; case "side": if (!Enum.TryParse(value, true, out properties.side)) { throw new Exception("side is not one of (Both, Client, Server, NoSync): " + value); } break; } } var refs = properties.RefNames(true).ToList(); if (refs.Count != refs.Distinct().Count()) { throw new Exception("Duplicate mod/weak reference"); } //add (mod|weak)References that are not in sortBefore to sortAfter properties.sortAfter = properties.RefNames(true).Where(dep => !properties.sortBefore.Contains(dep)) .Concat(properties.sortAfter).Distinct().ToArray(); return(properties); }
private static bool FindReferencedMods(BuildProperties properties, Dictionary<string, LoadingMod> mods) { foreach (var refName in properties.RefNames(true)) { if (mods.ContainsKey(refName)) continue; var modFile = new TmodFile(Path.Combine(ModPath, refName + ".tmod")); modFile.Read(); var ex = modFile.ValidMod(); if (ex != null) { ErrorLogger.LogBuildError("Mod reference " + refName + " " + ex); return false; } var mod = new LoadingMod(modFile, BuildProperties.ReadModFile(modFile)); mods[refName] = mod; FindReferencedMods(mod.properties, mods); } return true; }