コード例 #1
0
        public static void Main(string[] args)
        {
            if (args.Length == 2 && (args[0] == "--clearsymbols" || args[0] == "-cs"))
            {
                InstantClearSymbols = args[1];
                Thread.Sleep(2000);
            }

            if (args.Length == 2 && (args[0] == "--postcompile" || args[0] == "-pc"))
            {
                Console.WriteLine("Running ETGMod.Installer as post compilation task.");
                Console.WriteLine("Version: " + Version);

                args[1] = Path.GetFullPath(args[1]);

                ETGModder.OverridePaths = new List <string>();
                Console.WriteLine("Scanning for builds in " + args[1]);
                string[] files = Directory.GetFiles(args[1]);
                for (int i = 0; i < files.Length; i++)
                {
                    string file = files[i];
                    if (!file.EndsWith(".mm.dll"))
                    {
                        continue;
                    }
                    ETGModder.OverridePaths.Add(file);
                    Console.WriteLine("Added " + file);
                }

                ETGInstallerSettings.SaveEnabled = false;
                ETGFinder.OnExeSelected         += delegate(bool selected) {
                    if (!selected)
                    {
                        throw new InvalidOperationException("ETGMod.Installer not prepared to run as post compilation task! Set up the .exe path first!");
                    }

                    ETGModder.OnInstalled += delegate(bool installed) {
                        if (installed)
                        {
                            Environment.Exit(0);
                        }
                    };
                    Task.Run((Action)Instance.Install);
                };
                new InstallerWindow();

                Instance.ShowDialog();

                return;
            }

            Console.WriteLine("Entering the holy realm of ETGMod.");
            Application.EnableVisualStyles();

            Assembly assembly = Assembly.GetExecutingAssembly();

            string[] manifestResourceNames = assembly.GetManifestResourceNames();
            for (int i = 0; i < manifestResourceNames.Length; i++)
            {
                Console.WriteLine("Asset " + i + ": " + manifestResourceNames[i]);
            }

            Application.VisualStyleState = VisualStyleState.ClientAndNonClientAreasEnabled;
            new InstallerWindow();

#if DEBUG
            Instance.ShowDialog();
#else
ShowDialog:
            try {
                Instance.ShowDialog();
            } catch (Exception e) {
                //Gonna blame X11.
                Console.WriteLine(e.ToString());
                MessageBox.Show("Your window manager has left the building!\nThis simply means the installer crashed,\nbut your window manager caused it.", "ETGMod Installer");
                goto ShowDialog;
            }
#endif
        }