Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            bool   loadGUI    = true;
            string configFile = DefaultConfigFile;

            if (args.Length > 1)
            {
                // Command-line arguments exist.
                for (int i = 0; i < args.Length; ++i)
                {
                    if (args[i] == "-c" || args[i] == "--config-file")
                    {
                        // Argument: custom configuration file.
                        if (args.Length >= i + 1)
                        {
                            PrintUsage("-c", "filename");
                        }

                        configFile = args[i + 1];
                        ++i;
                    }

                    else if (args[i] == "-ng" || args[i] == "--nogui" || args[i] == "nogui")
                    {
                        // Argument: Hide the GUI.
                        loadGUI = false;
                    }
                }
            }


            try
            {
                WeaponLoader.LoadFiles();
                BotRunner runner = new BotRunner();

                if (loadGUI)
                {
                    try
                    {
                        Application.Run(new MainWindow(configFile, runner));
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Error: " + e.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Environment.Exit(1);
                    }
                }
                else
                {
                    runner.Parse(configFile);
                    runner.Start(true);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error!");
                Console.Error.WriteLine(e);
                Console.Error.WriteLine(e.StackTrace);

                throw;
            }
        }