Пример #1
0
        public static ClientCommandLineArguments Parse(string[] args)
        {
            var options = new ClientCommandLineArguments();

            Parse(options, args);
            return(options);
        }
Пример #2
0
        private static void StartClient(string[] args)
        {
            ClientCommandLineArguments.Parse(CmdLineArgs, args);

            /* If an instance of the game is already running, then exit. */
            if (!CmdLineArgs.AllowMultipleInstances)
            {
                bool mutexIsNew;
                _singleInstanceMutex = new Mutex(true, "{CC4FD558-0934-451d-A387-738B5DB5619C}", out mutexIsNew);
                if (!mutexIsNew)
                {
                    MessageBox.Show("An instance of Supremacy is already running.");
                    Environment.Exit(Environment.ExitCode);
                }
            }

            if (!string.IsNullOrWhiteSpace(CmdLineArgs.Traces))
            {
                List <string> traces = CmdLineArgs.Traces.Split(',').ToList();
                traces.ForEach(t =>
                               GameLog.SetRepositoryToDebug(t)
                               );
            }

            if (CmdLineArgs.TraceLevel != PresentationTraceLevel.None)
            {
                PresentationTraceSources.Refresh();
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            try
            {
                var errorFile = File.Open("Error.txt", FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
                Console.SetError(new StreamWriter(errorFile));
            }
            catch
            {
                MessageBox.Show(
                    "The error log could not be created.  You may still run the game,\n"
                    + "but error details cannot be logged.",
                    "Warning",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
            }

            VfsWebRequestFactory.EnsureRegistered();

            var app = new ClientApp();

            app.DispatcherUnhandledException += Current_DispatcherUnhandledException;
            app.InitializeComponent();
            app.Run();
        }
Пример #3
0
        public static void Parse(ClientCommandLineArguments options, string[] args)
        {
            try
            {
                CmdArgParser.Parse(options, args);
            }
            catch (Wintellect.Exception <InvalidCmdArgumentExceptionArgs> e)
            {
                if (!options.ShowUsage)
                {
                    options.Usage("Unrecognized command line argument: '" + e.Args.InvalidCmdArg + "'.");
                    ClientApp.Current.Shutdown();
                }
            }

            if (!options.ShowUsage)
            {
                return;
            }

            options.Usage(null);
            ClientApp.Current.Shutdown();
        }