Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var  parsedArgs     = new Dictionary <string, string>();
            bool forceInstall   = false;
            bool forceUninstall = false;

            foreach (var arg in args)
            {
                if (arg.Contains("="))
                {
                    parsedArgs = args.Select(s => s.Split(new[] { '=' }, 1)).ToDictionary(s => s[0], s => s[1]);
                }
                else if (arg.StartsWith("-"))
                {
                    if (arg == "-i")
                    {
                        forceInstall = true;
                    }

                    if (arg == "-u")
                    {
                        forceUninstall = true;
                    }
                }
            }

            string config = @"QModManagerConfig.txt";
            string GraveyardKeeperDirectory = "";

            /* Check the config file for alternate installation location - make this nicer later*/
            try
            {
                System.IO.StreamReader file = new System.IO.StreamReader(config);
                string line = file.ReadLine();
                Console.WriteLine(line);
                GraveyardKeeperDirectory = line;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            if (GraveyardKeeperDirectory == "" || GraveyardKeeperDirectory == "default")
            {
                string steamPath = "";
                try
                {
                    using (RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node\\Valve\\Steam"))
                    {
                        if (key != null)
                        {
                            Object o = key.GetValue("InstallPath");
                            if (o != null)
                            {
                                steamPath = o as String;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR accessing registry key for steam path: " + ex);
                }

                GraveyardKeeperDirectory = steamPath + @"\steamapps\common\Graveyard Keeper";
            }
            Logger.StartNewLog(GraveyardKeeperDirectory);
            Logger.WriteLog("\n" + DateTime.Now + "\n");

            string ManagedDirectory = Path.Combine(GraveyardKeeperDirectory, @"\Graveyard Keeper_Data\Managed");

            if (parsedArgs.Keys.Contains("GraveyardKeeperDirectory"))
            {
                GraveyardKeeperDirectory = parsedArgs["GraveyardKeeperDirectory"];
            }

            QModInjector injector = new QModInjector(GraveyardKeeperDirectory);

            bool isInjected = injector.IsPatcherInjected();

            if (forceInstall)
            {
                if (!isInjected)
                {
                    Console.WriteLine("Installing QMods...");
                    injector.Inject();
                }
                else
                {
                    Console.WriteLine("Tried to Force Install, was already injected. Skipping installation.");
                    return;
                }
            }
            else if (forceUninstall)
            {
                if (isInjected)
                {
                    Console.WriteLine("Uninstalling QMods...");
                    injector.Remove();
                }
                else
                {
                    Console.WriteLine("Tried to Force Uninstall, was not injected. Skipping uninstallation.");
                    return;
                }
            }
            else
            {
                if (!injector.IsPatcherInjected())
                {
                    Console.WriteLine("No patch detected, type 'yes' to install: ");
                    string consent = Console.ReadLine().Replace("'", "");
                    if (consent == "yes" || consent == "YES")
                    {
                        if (injector.Inject())
                        {
                            Console.WriteLine("QMods was installed!");
                        }
                        else
                        {
                            Console.WriteLine("Error installed QMods. Please contact us on Discord");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Patch already installed! Type 'yes' to remove: ");
                    string consent = Console.ReadLine().Replace("'", "");
                    if (consent == "yes" || consent == "YES")
                    {
                        if (injector.Remove())
                        {
                            Console.WriteLine("QMods was removed!");
                        }
                        else
                        {
                            Console.WriteLine("Error removing QMods. Please contact us on Discord");
                        }
                    }
                }

                Console.WriteLine("Press any key to exit ...");

                Console.ReadKey();
            }
        }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            bool flag  = false;
            bool flag2 = false;

            foreach (string text in args)
            {
                if (text.Contains("="))
                {
                    dictionary = (from s in args
                                  select s.Split(new char[]
                    {
                        '='
                    }, 1)).ToDictionary((string[] s) => s[0], (string[] s) => s[1]);
                }
                else if (text.StartsWith("-"))
                {
                    if (text == "-i")
                    {
                        flag = true;
                    }
                    if (text == "-u")
                    {
                        flag2 = true;
                    }
                }
            }
            string dir = Path.Combine(Environment.CurrentDirectory, "../..");
            string currentDirectory = Environment.CurrentDirectory;

            if (dictionary.Keys.Contains("SubnauticaDirectory"))
            {
                dir = dictionary["SubnauticaDirectory"];
            }
            QModInjector qmodInjector = new QModInjector(dir, currentDirectory);
            bool         flag3        = qmodInjector.IsPatcherInjected();

            if (flag)
            {
                if (!flag3)
                {
                    Console.WriteLine("Installing QMods...");
                    qmodInjector.Inject();
                    return;
                }
                Console.WriteLine("Tried to Force Install, was already injected. Skipping installation.");
                return;
            }
            else
            {
                if (!flag2)
                {
                    if (!qmodInjector.IsPatcherInjected())
                    {
                        Console.WriteLine("No patch detected, type 'yes' to install: ");
                        string a = Console.ReadLine().Replace("'", "");
                        if (a == "yes" || a == "YES")
                        {
                            if (qmodInjector.Inject())
                            {
                                Console.WriteLine("QMods was installed!");
                            }
                            else
                            {
                                Console.WriteLine("Error installed QMods. Please contact us on Discord");
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("Patch already installed! Type 'yes' to remove: ");
                        string a2 = Console.ReadLine().Replace("'", "");
                        if (a2 == "yes" || a2 == "YES")
                        {
                            if (qmodInjector.Remove())
                            {
                                Console.WriteLine("QMods was removed!");
                            }
                            else
                            {
                                Console.WriteLine("Error removing QMods. Please contact us on Discord");
                            }
                        }
                    }
                    Console.WriteLine("Press any key to exit ...");
                    Console.ReadKey();
                    return;
                }
                if (flag3)
                {
                    Console.WriteLine("Uninstalling QMods...");
                    qmodInjector.Remove();
                    return;
                }
                Console.WriteLine("Tried to Force Uninstall, was not injected. Skipping uninstallation.");
                return;
            }
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            //Dictionary<string, string> parsedArgs = new Dictionary<string, string>();
            bool forceInstall = false;
            bool forceUninstall = false;
            string arg = "";

            if (args.Length > 0)
                arg = args[0];

            if (arg == "-i")
                forceInstall = true;
            else if (arg == "-u")
                forceUninstall = true;

            string Directory = Path.Combine(Environment.CurrentDirectory, @"../..");

            //if (parsedArgs.Keys.Contains("TerraTechDirectory"))
            //    TerraTechDirectory = parsedArgs["TerraTechDirectory"];
            //if (parsedArgs.Keys.Contains("Directory"))
            //    TerraTechDirectory = parsedArgs["Directory"];

            string ManagedDirectory = Environment.CurrentDirectory;

            if (!File.Exists(ManagedDirectory + @"/Assembly-CSharp.dll"))
            {
                Console.WriteLine("Could not find the assembly file.");
                Console.WriteLine("Please make sure you have installed QModManager in the right folder");
                Console.WriteLine();
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
                return;
            }

            QModInjector injector = new QModInjector(Directory, ManagedDirectory);

            bool isInjected = injector.IsInjected();

            if (forceInstall)
            {
                if (!isInjected)
                {
                    Console.WriteLine("Installing QModManager...");
                    injector.Inject();
                }
                else
                {
                    Console.WriteLine("Tried to force install, but it was already injected");
                    Console.WriteLine("Skipping installation");
                    Console.WriteLine();
                    Console.WriteLine("Press any key to exit...");
                    Console.ReadKey();
                    return;
                }
            }
            else if (forceUninstall)
            {
                if (isInjected)
                {
                    Console.WriteLine("Uninstalling QModManager...");
                    injector.Remove();
                }
                else
                {
                    Console.WriteLine("Tried to force uninstall, but it was not injected");
                    Console.WriteLine("Skipping uninstallation");
                    Console.WriteLine();
                    Console.WriteLine("Press any key to exit...");
                    return;
                }
            }
            else
            {
                if (!isInjected)
                {
                    Console.Write("No patch detected, install? [Y/N] > ");
                    var key = Console.ReadKey().Key;
                    Console.WriteLine();
                    if (key == ConsoleKey.Y)
                    {
                        Console.WriteLine("Installing QModManager...");
                        injector.Inject();
                        //if (injector.Inject())
                        //    Console.WriteLine("QMods was installed!");
                        //else
                        //    Console.WriteLine("There was a problem installing QMods.\nPlease contact us on Discord (discord.gg/WsvbVrP)");
                    }
                    else if (key == ConsoleKey.N)
                    {
                        Console.WriteLine("Press any key to exit...");
                        Console.ReadKey();
                        return;
                    }
                }
                else
                {
                    Console.Write("Patch already installed, remove? [Y/N] > ");
                    var key = Console.ReadKey().Key;
                    Console.WriteLine();
                    if (key == ConsoleKey.Y)
                    {
                        Console.Write("Removing QModManager...");
                        injector.Remove();
                        //if (injector.Remove())
                        //    Console.WriteLine("QMods was removed!");
                        //else
                        //    Console.WriteLine("There was a problem removing QMods. You may have to reinstall / verify the game's files\nPlease contact us on Discord (discord.gg/WsvbVrP)");
                    }
                    else if (key == ConsoleKey.N)
                    {
                        Console.WriteLine("Press any key to exit...");
                        Console.ReadKey();
                        return;
                    }
                }
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var  parsedArgs     = new Dictionary <string, string>();
            bool forceInstall   = false;
            bool forceUninstall = false;

            foreach (var arg in args)
            {
                if (arg.Contains("="))
                {
                    parsedArgs = args.Select(s => s.Split(new[] { '=' }, 1)).ToDictionary(s => s[0], s => s[1]);
                }
                else if (arg.StartsWith("-"))
                {
                    if (arg == "-i")
                    {
                        forceInstall = true;
                    }

                    if (arg == "-u")
                    {
                        forceUninstall = true;
                    }
                }
            }

            //string SubnauticaDirectory = @"C:\Program Files (x86)\Steam\steamapps\common\Subnautica";
            string SubnauticaDirectory = Path.Combine(Environment.CurrentDirectory, @"..\..");
            string ManagedDirectory    = Environment.CurrentDirectory;

            if (parsedArgs.Keys.Contains("SubnauticaDirectory"))
            {
                SubnauticaDirectory = parsedArgs["SubnauticaDirectory"];
            }

            QModInjector injector = new QModInjector(SubnauticaDirectory, ManagedDirectory);

            bool isInjected = injector.IsPatcherInjected();

            if (forceInstall)
            {
                if (!isInjected)
                {
                    Console.WriteLine("Installing QMods...");
                    injector.Inject();
                }
                else
                {
                    Console.WriteLine("Tried to Force Install, was already injected. Skipping installation.");
                    return;
                }
            }
            else if (forceUninstall)
            {
                if (isInjected)
                {
                    Console.WriteLine("Uninstalling QMods...");
                    injector.Remove();
                }
                else
                {
                    Console.WriteLine("Tried to Force Uninstall, was not injected. Skipping uninstallation.");
                    return;
                }
            }
            else
            {
                if (!injector.IsPatcherInjected())
                {
                    Console.WriteLine("No patch detected, type 'yes' to install: ");
                    string consent = Console.ReadLine().Replace("'", "");
                    if (consent == "yes" || consent == "YES")
                    {
                        if (injector.Inject())
                        {
                            Console.WriteLine("QMods was installed!");
                        }
                        else
                        {
                            Console.WriteLine("Error installed QMods. Please contact us on Discord");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Patch already installed! Type 'yes' to remove: ");
                    string consent = Console.ReadLine().Replace("'", "");
                    if (consent == "yes" || consent == "YES")
                    {
                        if (injector.Remove())
                        {
                            Console.WriteLine("QMods was removed!");
                        }
                        else
                        {
                            Console.WriteLine("Error removing QMods. Please contact us on Discord");
                        }
                    }
                }

                Console.WriteLine("Press any key to exit ...");

                Console.ReadKey();
            }
        }