Terraria.ModLoader.ErrorLogger.LogDependencyError C# (CSharp) Method

LogDependencyError() static private method

static private LogDependencyError ( string error ) : void
error string
return void
		internal static void LogDependencyError(string error)
		{
			Directory.CreateDirectory(LogPath);
			string file = Path.Combine(LogPath, "Loading Errors.txt");
			File.WriteAllText(file, error);
			Console.WriteLine(error);

			Interface.errorMessage.SetMessage(error);
			Interface.errorMessage.SetGotoMenu(Interface.reloadModsID);
			Interface.errorMessage.SetFile(file);
		}

Usage Example

Ejemplo n.º 1
0
        internal static bool BuildAll(string[] modFolders, IBuildStatus status)
        {
            var modList = new List <LocalMod>();

            //read mod sources folder
            foreach (var modFolder in modFolders)
            {
                var mod = ReadProperties(modFolder, status);
                if (mod == null)
                {
                    return(false);
                }

                modList.Add(mod);
            }

            //figure out which of the installed mods are required for building
            var installedMods = ModOrganizer.FindMods().Where(mod => !modList.Exists(m => m.Name == mod.Name)).ToList();

            var requiredFromInstall = new HashSet <LocalMod>();

            void Require(LocalMod mod)
            {
                foreach (var dep in mod.properties.RefNames(true))
                {
                    var depMod = installedMods.SingleOrDefault(m => m.Name == dep);
                    if (depMod != null && requiredFromInstall.Add(depMod))
                    {
                        Require(depMod);
                    }
                }
            }

            foreach (var mod in modList)
            {
                Require(mod);
            }

            modList.AddRange(requiredFromInstall);

            //sort and version check
            List <BuildingMod> modsToBuild;

            try
            {
                ModOrganizer.EnsureDependenciesExist(modList, true);
                ModOrganizer.EnsureTargetVersionsMet(modList);
                var sortedModList = ModOrganizer.Sort(modList);
                modsToBuild = sortedModList.OfType <BuildingMod>().ToList();
            }
            catch (ModSortingException e)
            {
                ErrorLogger.LogDependencyError(e.Message);
                return(false);
            }

            //build
            int num = 0;

            foreach (var mod in modsToBuild)
            {
                status.SetProgress(num++, modsToBuild.Count);
                if (!Build(mod, status))
                {
                    return(false);
                }
            }

            return(true);
        }