Example #1
0
        /// <summary>
        ///     This function installs a mod based off the parameters provided. The first parameter is the an 5-length array which
        ///     represents the file info. The second parameter is a bool which determines if the archive will be deleted after
        ///     installation.
        /// </summary>
        /// <param name="fileinfo">ModFile class, gets the <c>rawname</c> from it</param>
        /// <param name="delArchive">Defines if the archive should be deleted after installation</param>
        /// <returns>Boolean</returns>
        public static bool InstallMod(ModFile fileinfo, bool delArchive = true)
        {
            fileinfo.Arguments.Replace("BACKSLASH", @"\");

            if (fileinfo.Arguments == "")
            {
                fileinfo.Arguments = "unzipToDir?";
            }
            var args = fileinfo.Arguments.Split('?');

            ModInstallerCommon.DebugLog("");
            for (var i = 0; i < args.Length; i++)
            {
                ModInstallerCommon.DebugLog(args[i] + ", ");
            }

            for (var i = 0; i < args.Length; i++)
            {
                if (args[i] == "moveToFolder")
                {
                    MoveToFolder(args[i + 1], args[i + 2], args[i + 3]);
                }

                if (args[i] == "unzipToDir")
                {
                    ModInstallerCommon.DebugLog("Unzipping to " + args[i + 1]);

                    var ArchiveType = Archives.ArchiveType.Zip;

                    if (fileinfo.RawName.ToLower().EndsWith(".rar"))
                    {
                        ArchiveType = Archives.ArchiveType.RAR;
                        Console.WriteLine("Archive is rar!");
                    }

                    if (fileinfo.RawName.ToLower().EndsWith(".7z"))
                    {
                        ArchiveType = Archives.ArchiveType.SevenZip;
                        Console.WriteLine("Archive is 7z!");
                    }

                    Archives.UnArchive(fileinfo.RawName, Path.Combine(Utilities.GameDirectoryOrThrow, args[i + 1]),
                                       delArchive, ArchiveType);
                }

                if (args[i] == "addFolder")
                {
                    ModInstallerCommon.DebugLog("Creating Directory " + args[i + 1]);
                    Directory.CreateDirectory(Path.Combine(Utilities.GameDirectoryOrThrow, args[i + 1]));
                }

                if (args[i] == "break")
                {
                    break;
                }
            }

            Console.WriteLine("Installed " + fileinfo.Name);
            return(true);
        }
Example #2
0
        /// <summary>
        ///     This function installs a mod based off the parameters provided. The first parameter is the an 5-length array which
        ///     represents the file info. The second parameter is a bool which determines if the archive will be deleted after
        ///     installation.
        /// </summary>
        /// <param name="fileinfo">ModFile class, gets the <c>rawname</c> from it</param>
        /// <param name="delArchive">Defines if the archive should be deleted after installation</param>
        /// <returns>Boolean</returns>
        public static bool InstallMod(ModFile fileinfo, bool delArchive = false)
        {
            fileinfo.Arguments.Replace("BACKSLASH", @"\");

            if (fileinfo.Arguments == "")
            {
                fileinfo.Arguments = "unzipToDir?";
            }
            var args = fileinfo.Arguments.Split('?');

            ModInstallerCommon.DebugLog("");
            for (var i = 0; i < args.Length; i++)
            {
                ModInstallerCommon.DebugLog(args[i] + ", ");
            }

            for (var i = 0; i < args.Length; i++)
            {
                if (args[i] == "moveToFolder")
                {
                    MoveToFolder(args[i + 1], args[i + 2], args[i + 3]);
                }
                if (args[i] == "unzipToDir")
                {
                    ModInstallerCommon.DebugLog("Unzipping to " + args[i + 1]);

                    var ArchiveType = Archives.ArchiveType.Zip;

                    if (fileinfo.RawName.EndsWith(".rar") || fileinfo.RawName.EndsWith(".RAR"))
                    {
                        ArchiveType = Archives.ArchiveType.RAR;
                    }

                    if (fileinfo.RawName.EndsWith(".7z") || fileinfo.RawName.EndsWith(".7Z"))
                    {
                        ArchiveType = Archives.ArchiveType.SevenZip;
                    }

                    Archives.UnArchive(fileinfo.RawName, ModInstallerCommon.Files.MainFiledir + "/" + args[i + 1],
                                       delArchive, ArchiveType);
                    File.Delete(fileinfo.RawName);
                }

                if (args[i] == "addFolder")
                {
                    ModInstallerCommon.DebugLog("Creating Directory " + args[i + 1]);
                    Directory.CreateDirectory(ModInstallerCommon.Files.MainFiledir + args[i + 1]);
                }

                if (args[i] == "break")
                {
                    break;
                }
            }

            Console.WriteLine("Installed " + fileinfo.Name);
            return(true);
        }
Example #3
0
 void Form_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Control && e.KeyCode == Keys.R)
     {
         AllocConsole();
         Thread t = new Thread(startdebugconsole);
         t.Start();
         ModInstallerCommon.DebugLog("STARTED DEBUG CONSOLE");
     }
 }
Example #4
0
        /// <summary>
        ///     This function moves the mod (first parameter) to the second parameter location, and renames it to the third
        ///     parameter
        /// </summary>
        /// <param name="mod">The mod to be moved</param>
        /// <param name="dir">The Directory to be moved to</param>
        /// <param name="renameTo">What the file should be renamed to after</param>
        /// <returns>Boolean, true</returns>
        /// <remarks>
        ///     Honestly, this function needs a lot of work, its disgusting //TODO: fix this shit
        /// </remarks>
        public static bool MoveToFolder(string mod, string dir, string renameTo = "")
        {
            if (renameTo == "")
            {
                renameTo = mod;
            }
            dir = Path.Combine(Utilities.GameDirectoryOrThrow, dir);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            ModInstallerCommon.DebugLog("Moving " + Directory.GetCurrentDirectory() + @"\" + mod + " to dir " + dir +
                                        " as " + renameTo);
            var path = Path.Combine(Utilities.GameDirectoryOrThrow, mod);

            if (File.Exists(path))
            {
                ModInstallerCommon.DebugLog("Moving as file!");
                File.Move(path, dir + renameTo, true);
            }

            if (File.Exists(Directory.GetCurrentDirectory() + @"\" + mod))
            {
                ModInstallerCommon.DebugLog("Moving as file!");
                File.Move(Directory.GetCurrentDirectory() + @"\" + mod, dir + renameTo, true);
            }
            else if (Directory.Exists(path))
            {
                ModInstallerCommon.DebugLog("Moving as directory!");
                Directory.Move(path, dir + renameTo);
            }

            if (Directory.Exists(Directory.GetCurrentDirectory() + @"\" + mod))
            {
                ModInstallerCommon.DebugLog("Moving as directory!");
                Directory.Move(Directory.GetCurrentDirectory() + @"\" + mod, dir + renameTo);
            }
            else
            {
                Console.WriteLine("Cannot find file to move!");
            }

            return(true);
        }
        /// <summary>
        ///     Main function, the args arent used though
        /// </summary>
        /// <param name="args">dunno why these are here</param>
        public static void Main_DEPRECIATED(string[] args)
        {
            JsonCommon.OverrideModInstallerVariables();
            //exe check
            Console.WriteLine("Detecting if " + ModInstallerCommon.Files.execdir + " exists...");
            if (!File.Exists(ModInstallerCommon.Files.execdir) && !ModInstallerCommon.BypassExec)
            {
                ModInstallerCommon.throwexept("H3VR not found!");
                return;
            }

            Console.WriteLine("H3VR found!");
            //online check
            if (!NetCheck.isOnline(ModInstallerCommon.Pingsite))
            {
                ModInstallerCommon.throwexept("Cannot connect to github!");
                return;
            }

            Console.WriteLine("Welcome to the H3VR Mod installer!");
            Console.WriteLine("Please select the mod you would like to install using 'dl [modnamehere]' ");
            Console.WriteLine("ex: 'dl wurstmod'");
            Console.WriteLine("To see a list of downloadable mods, type 'modlists'");
            Console.WriteLine("To see a list of commands, type 'help' \n");
Start:
            var input = Console.ReadLine();

            var inputargs = input.Split(' ');

            Array.Resize(ref inputargs, 10); //ensures no "OUT OF INDEX TIME TO SHIT MYSELF REEEE"


            doCommand(inputargs);

            Console.WriteLine("");
            goto Start;
        }
Example #6
0
        /// <summary>
        ///     This function installs a mod based off the parameters provided. The first parameter is the an 5-length array which
        ///     represents the file info. The second parameter is a bool which determines if the archive will be deleted after
        ///     installation.
        /// </summary>
        /// <param name="fileinfo">ModFile class, gets the <c>rawname</c> from it</param>
        /// <param name="delArchive">Defines if the archive should be deleted after installation</param>
        /// <returns>Boolean</returns>
        public static bool InstallMod(ModFile fileinfo, bool delArchive = true)
        {
            fileinfo.Arguments.Replace("BACKSLASH", @"\");

            if (fileinfo.Arguments == "")
            {
                fileinfo.Arguments = "unzipToDir?";
            }
            var args = fileinfo.Arguments.Split('?');

            ModInstallerCommon.DebugLog("");
            for (var i = 0; i < args.Length; i++)
            {
                ModInstallerCommon.DebugLog(args[i] + ", ");
            }

            for (var i = 0; i < args.Length; i++)
            {
                if (args[i] == "moveToFolder" || args[i] == "moveto")
                {
                    MoveToFolder(args[i + 1], args[i + 2], args[i + 3]);
                }

                if (args[i] == "unzipToDir" || args[i] == "extractto")
                {
                    ModInstallerCommon.DebugLog("Unzipping to " + args[i + 1]);

                    var ArchiveType = Archives.ArchiveType.Zip;

                    if (fileinfo.RawName.ToLower().EndsWith(".rar"))
                    {
                        ArchiveType = Archives.ArchiveType.RAR;
                        Console.WriteLine("Archive is rar!");
                    }

                    if (fileinfo.RawName.ToLower().EndsWith(".7z"))
                    {
                        ArchiveType = Archives.ArchiveType.SevenZip;
                        Console.WriteLine("Archive is 7z!");
                    }

                    Archives.UnArchive(fileinfo.RawName, Path.Combine(Utilities.GameDirectoryOrThrow, args[i + 1]),
                                       delArchive, ArchiveType);
                }

                if (args[i] == "moveAllFromFolderOfType" || args[i] == "moveallfrom")
                {
                    DirectoryInfo d;
                    if (Directory.Exists(args[i + 1]))
                    {
                        d = new DirectoryInfo(args[i + 1]);
                    }
                    else
                    {
                        d = new DirectoryInfo(Utilities.GameDirectory + args[i + 1]);
                    }
                    Console.WriteLine("Moving all files of type {0} from " + d + " to " + args[i + 3], args[i + 2]);
                    foreach (var file in d.GetFiles(args[i + 2]))
                    {
                        Console.WriteLine("Moving file {0} to {1}", file.FullName, d + args[i + 3] + file.Name);
                        var dest = Utilities.GameDirectory + args[i + 3] + file.Name;
                        if (File.Exists(dest))
                        {
                            File.Delete(dest);
                        }                                           //overwrite if exist
                        Directory.Move(file.FullName, dest);
                    }
                }

                if (args[i] == "addFolder")
                {
                    ModInstallerCommon.DebugLog("Creating Directory " + args[i + 1]);
                    Directory.CreateDirectory(Path.Combine(Utilities.GameDirectoryOrThrow, args[i + 1]));
                }

                if (args[i] == "break")
                {
                    break;
                }
            }

            Console.WriteLine("Installed " + fileinfo.Name);
            return(true);
        }