Esempio n. 1
0
        internal static void ServerModMenu()
        {
            bool exit = false;

            while (!exit)
            {
                Console.WriteLine("Terraria Server " + Main.versionNumber2 + " - " + ModLoader.versionedName);
                Console.WriteLine();
                var mods = ModLoader.FindMods();
                for (int k = 0; k < mods.Length; k++)
                {
                    Console.Write((k + 1) + "\t\t" + mods[k].DisplayName);
                    Console.WriteLine(" (" + (ModLoader.IsEnabled(mods[k].Name) ? "enabled" : "disabled") + ")");
                }
                if (mods.Length == 0)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine($"No mods were found in: \"{ModLoader.ModPath}\"\nIf you are running a dedicated server, you may wish to use the 'modpath' command line switch or server config setting to specify a custom mods directory.\n");
                    Console.ResetColor();
                }
                Console.WriteLine("e\t\tEnable All");
                Console.WriteLine("d\t\tDisable All");
                Console.WriteLine("r\t\tReload and return to world menu");
                Console.WriteLine("Type a number to switch between enabled/disabled");
                Console.WriteLine();
                Console.WriteLine("Type a command: ");
                string command = Console.ReadLine();
                if (command == null)
                {
                    command = "";
                }
                command = command.ToLower();
                Console.Clear();
                if (command == "e")
                {
                    foreach (var mod in mods)
                    {
                        mod.Enabled = true;
                    }
                }
                else if (command == "d")
                {
                    foreach (var mod in mods)
                    {
                        mod.Enabled = false;
                    }
                }
                else if (command == "r")
                {
                    Console.WriteLine("Unloading mods...");
                    ModLoader.Unload();
                    ModLoader.do_Load(null);
                    exit = true;
                }
                else if (int.TryParse(command, out int value) && value > 0 && value <= mods.Length)
                {
                    mods[value - 1].Enabled ^= true;
                }
            }
        }
Esempio n. 2
0
        public static List <Mod> LoadMods()
        {
            CommandLineModPackOverride();

            Interface.loadMods.SetLoadStage("tModLoader.MSFinding");
            var modsToLoad = FindMods().Where(mod => ModLoader.IsEnabled(mod.Name) && LoadSide(mod.properties.side)).ToList();

            // Press shift while starting up tModLoader or while trapped in a reload cycle to skip loading all mods.
            if (Main.oldKeyState.PressingShift() || ModLoader.skipLoad)
            {
                ModLoader.skipLoad = false;
                modsToLoad.Clear();
                Interface.loadMods.SetLoadStage("Loading Cancelled");
            }

            VerifyNames(modsToLoad);

            try
            {
                EnsureDependenciesExist(modsToLoad, false);
                EnsureTargetVersionsMet(modsToLoad);
                modsToLoad = Sort(modsToLoad);
            }
            catch (ModSortingException e)
            {
                e.Data["mods"]           = e.errored.Select(m => m.Name).ToArray();
                e.Data["hideStackTrace"] = true;
                throw;
            }

            return(AssemblyManager.InstantiateMods(modsToLoad));
        }
Esempio n. 3
0
        public static List <Mod> LoadMods()
        {
            //load all referenced assemblies before mods for compiling
            ModCompile.LoadReferences();

            if (!CommandLineModPackOverride())
            {
                return(null);
            }

            Interface.loadMods.SetLoadStage("tModLoader.MSFinding");
            var modsToLoad = FindMods().Where(mod => ModLoader.IsEnabled(mod.Name) && LoadSide(mod.properties.side)).ToList();

            // Press shift while starting up tModLoader or while trapped in a reload cycle to skip loading all mods.
            if (Main.oldKeyState.PressingShift())
            {
                modsToLoad.Clear();
            }

            if (!VerifyNames(modsToLoad))
            {
                return(null);
            }

            try
            {
                EnsureDependenciesExist(modsToLoad, false);
                EnsureTargetVersionsMet(modsToLoad);
                modsToLoad = Sort(modsToLoad);
            }
            catch (ModSortingException e)
            {
                foreach (var mod in e.errored)
                {
                    mod.Enabled = false;
                }

                ErrorLogger.LogDependencyError(e.Message);
                Main.menuMode = Interface.errorMessageID;
                return(null);
            }

            return(AssemblyManager.InstantiateMods(modsToLoad));
        }
Esempio n. 4
0
        public static List <Mod> LoadMods()
        {
            CommandLineModPackOverride();

            // Alternate fix for updating enabled mods
            //foreach (string fileName in Directory.GetFiles(ModLoader.ModPath, "*.tmod.update", SearchOption.TopDirectoryOnly)) {
            //	File.Copy(fileName, Path.GetFileNameWithoutExtension(fileName), true);
            //	File.Delete(fileName);
            //}
            Interface.loadMods.SetLoadStage("tModLoader.MSFinding");
            var modsToLoad = FindMods().Where(mod => ModLoader.IsEnabled(mod.Name) && LoadSide(mod.properties.side)).ToList();

            // Press shift while starting up tModLoader or while trapped in a reload cycle to skip loading all mods.
            if (Main.oldKeyState.PressingShift() || ModLoader.skipLoad)
            {
                ModLoader.skipLoad = false;
                modsToLoad.Clear();
                Interface.loadMods.SetLoadStage("Loading Cancelled");
            }

            VerifyNames(modsToLoad);

            try {
                EnsureDependenciesExist(modsToLoad, false);
                EnsureTargetVersionsMet(modsToLoad);
                modsToLoad      = Sort(modsToLoad);
                dependencyCache = modsToLoad.ToDictionary(m => m.Name, m => m.properties.RefNames(false).ToList());
            }
            catch (ModSortingException e) {
                e.Data["mods"]           = e.errored.Select(m => m.Name).ToArray();
                e.Data["hideStackTrace"] = true;
                throw;
            }

            return(AssemblyManager.InstantiateMods(modsToLoad));
        }
Esempio n. 5
0
        internal static void ServerModMenu()
        {
            bool exit = false;

            while (!exit)
            {
                Console.WriteLine("Terraria Server " + Main.versionNumber2 + " - " + ModLoader.versionedName);
                Console.WriteLine();
                TmodFile[] mods = ModLoader.FindMods();
                for (int k = 0; k < mods.Length; k++)
                {
                    BuildProperties properties = BuildProperties.ReadModFile(mods[k]);
                    string          name       = properties.displayName;
                    name = mods[k].name;
                    string line = (k + 1) + "\t\t" + name + "(";
                    line += (ModLoader.IsEnabled(mods[k]) ? "enabled" : "disabled") + ")";
                    Console.WriteLine(line);
                }
                Console.WriteLine("e\t\tEnable All");
                Console.WriteLine("d\t\tDisable All");
                Console.WriteLine("r\t\tReload and return to world menu");
                Console.WriteLine("Type a number to switch between enabled/disabled");
                Console.WriteLine();
                Console.WriteLine("Type a command: ");
                string command = Console.ReadLine();
                if (command == null)
                {
                    command = "";
                }
                command = command.ToLower();
                Console.Clear();
                if (command == "e")
                {
                    foreach (TmodFile mod in mods)
                    {
                        ModLoader.EnableMod(mod);
                    }
                }
                else if (command == "d")
                {
                    foreach (TmodFile mod in mods)
                    {
                        ModLoader.DisableMod(mod);
                    }
                }
                else if (command == "r")
                {
                    Console.WriteLine("Unloading mods...");
                    ModLoader.Unload();
                    ModLoader.do_Load(null);
                    exit = true;
                }
                else
                {
                    int value;
                    if (Int32.TryParse(command, out value))
                    {
                        value--;
                        if (value >= 0 && value < mods.Length)
                        {
                            ModLoader.SetModActive(mods[value], !ModLoader.IsEnabled(mods[value]));
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        internal static void ServerModMenu()
        {
            bool exit = false;

            while (!exit)
            {
                Console.WriteLine("Terraria Server " + Main.versionNumber2 + " - " + ModLoader.versionedName);
                Console.WriteLine();
                TmodFile[] mods = ModLoader.FindMods();
                for (int k = 0; k < mods.Length; k++)
                {
                    BuildProperties properties = BuildProperties.ReadModFile(mods[k]);
                    string          name       = properties.displayName;
                    name = mods[k].name;
                    string line = (k + 1) + "\t\t" + name + "(";
                    line += (ModLoader.IsEnabled(mods[k]) ? "enabled" : "disabled") + ")";
                    Console.WriteLine(line);
                }
                if (mods.Length == 0)
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine($"No mods were found in: \"{ModLoader.ModPath}\"\nIf you are running a dedicated server, you may wish to use the 'modpath' command line switch or server config setting to specify a custom mods directory.\n");
                    Console.ResetColor();
                }
                Console.WriteLine("e\t\tEnable All");
                Console.WriteLine("d\t\tDisable All");
                Console.WriteLine("r\t\tReload and return to world menu");
                Console.WriteLine("Type a number to switch between enabled/disabled");
                Console.WriteLine();
                Console.WriteLine("Type a command: ");
                string command = Console.ReadLine();
                if (command == null)
                {
                    command = "";
                }
                command = command.ToLower();
                Console.Clear();
                if (command == "e")
                {
                    foreach (TmodFile mod in mods)
                    {
                        ModLoader.EnableMod(mod);
                    }
                }
                else if (command == "d")
                {
                    foreach (TmodFile mod in mods)
                    {
                        ModLoader.DisableMod(mod);
                    }
                }
                else if (command == "r")
                {
                    Console.WriteLine("Unloading mods...");
                    ModLoader.Unload();
                    ModLoader.do_Load(null);
                    exit = true;
                }
                else
                {
                    int value;
                    if (Int32.TryParse(command, out value))
                    {
                        value--;
                        if (value >= 0 && value < mods.Length)
                        {
                            ModLoader.SetModActive(mods[value], !ModLoader.IsEnabled(mods[value]));
                        }
                    }
                }
            }
        }