Example #1
0
        public override void RunGame(string gameDir, string args)
        {
            Log.Info("Starting XCOM Chimera Squad");

            if (!SteamAPIWrapper.Init())
            {
                MessageBox.Show("Could not connect to steam.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var p = new Process
            {
                StartInfo =
                {
                    Arguments        = args,
                    FileName         = gameDir + @"\Binaries\Win64\xcom.exe",
                    WorkingDirectory = gameDir
                }
            };

            try
            {
                p.Start();
            }
            catch (Win32Exception ex)
            {
                Log.Warn("Failed to start game process", ex);
                MessageBox.Show("An error occured while trying to run the game. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            SteamAPIWrapper.Shutdown();
        }
Example #2
0
        /// <summary>
        /// Runs War of the Chosen with the selected arguments
        /// </summary>
        /// <param name="gameDir"></param>
        /// <param name="args"></param>
        public static void RunWotC(string gameDir, string args)
        {
            Log.Info("Starting WotC");

            if (!SteamAPIWrapper.Init())
            {
                MessageBox.Show("Could not connect to steam.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var p = new Process
            {
                StartInfo =
                {
                    Arguments        = args,
                    FileName         = gameDir + @"\XCom2-WarOfTheChosen\Binaries\Win64\XCom2.exe",
                    WorkingDirectory = gameDir + @"\XCom2-WarOfTheChosen"
                }
            };

            try
            {
                p.Start();
            }
            catch (Win32Exception ex)
            {
                Log.Warn("Failed to start game process", ex);
                MessageBox.Show("An error occured while trying to run the game. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            SteamAPIWrapper.Shutdown();
        }
Example #3
0
        // OnApplicationQuit gets called too early to shutdown the SteamAPIWrapper.
        // Because the SteamManager should be persistent and never disabled or destroyed we can shutdown the SteamAPI here.
        // Thus it is not recommended to perform any Steamworks work in other OnDestroy functions as the order of execution can not be garenteed upon Shutdown. Prefer OnDisable().
        private void OnDestroy()
        {
            if (s_instance != this)
            {
                return;
            }

            s_instance = null;

            if (!m_bInitialized)
            {
                return;
            }

            SteamAPIWrapper.Shutdown();
        }
Example #4
0
        /// <summary>
        /// Runs War of the Chosen with the selected arguments
        /// </summary>
        /// <param name="gameDir"></param>
        /// <param name="args"></param>
        public static void RunWotC(string gameDir, string args)
        {
            if (!SteamAPIWrapper.Init())
            {
                MessageBox.Show("Could not connect to steam.");
            }


            var p = new Process
            {
                StartInfo =
                {
                    Arguments        = args,
                    FileName         = gameDir + @"\XCom2-WarOfTheChosen\Binaries\Win64\XCom2.exe",
                    WorkingDirectory = gameDir + @"\XCom2-WarOfTheChosen"
                }
            };

            p.Start();

            SteamAPIWrapper.Shutdown();
        }
Example #5
0
        /// <summary>
        /// Runs the game with the selected arguments
        /// </summary>
        /// <param name="gameDir"></param>
        /// <param name="args"></param>
        public static void RunGame(string gameDir, string args)
        {
            Log.Info("Starting XCOM 2 (vanilla)");

            if (!SteamAPIWrapper.Init())
            {
                MessageBox.Show("Could not connect to steam.");
            }

            var p = new Process
            {
                StartInfo =
                {
                    Arguments        = args,
                    FileName         = gameDir + @"\Binaries\Win64\XCom2.exe",
                    WorkingDirectory = gameDir
                }
            };

            p.Start();

            SteamAPIWrapper.Shutdown();
        }
Example #6
0
        private static void Main()
        {
#if !DEBUG
            try
            {
#endif
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!CheckDotNet4_6() && MessageBox.Show("This program requires .NET v4.6 or newer.\r\nDo you want to install it now?", "Error", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Process.Start(@"https://www.microsoft.com/de-de/download/details.aspx?id=49981");
            }

            if (!SteamAPIWrapper.Init())
            {
                MessageBox.Show("Please start steam first!");
                return;
            }
            // SteamWorkshop.StartCallbackService();


            // Load settings
            var settings = InitializeSettings();
            if (settings == null)
            {
                return;
            }

#if !DEBUG
            // Check for update
            if (settings.CheckForUpdates)
            {
                try
                {
                    using (var client = new System.Net.WebClient())
                    {
                        client.Headers.Add("User-Agent: Other");
                        var json           = client.DownloadString("https://api.github.com/repos/aEnigmatic/xcom2-launcher/releases/latest");
                        var release        = Newtonsoft.Json.JsonConvert.DeserializeObject <GitHub.Release>(json);
                        var currentVersion = GetCurrentVersion();

                        if (currentVersion != release.tag_name)
                        {
                            // New version available
                            new UpdateAvailableDialog(release, currentVersion).ShowDialog();
                        }
                    }
                }
                catch (System.Net.WebException)
                {
                    // No internet?
                }
            }
#endif

            // clean up old files
            if (File.Exists(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak"))
            {
                // Restore backup
                File.Copy(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak", XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini", true);
                File.Delete(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak");
            }

            Application.Run(new MainForm(settings));

            SteamAPIWrapper.Shutdown();
#if !DEBUG
        }

        catch (Exception e)
        {
            MessageBox.Show("An exception occured. See error.log for additional details.");
            File.WriteAllText("error.log", e.Message + "\r\nStack:\r\n" + e.StackTrace);
        }
#endif
        }
Example #7
0
        private static void Main()
        {
            if (!IsDebugBuild)
            {
                // Capture all unhandled Exceptions
                AppDomain.CurrentDomain.UnhandledException += (sender, args) => HandleUnhandledException(args.ExceptionObject as Exception, "UnhandledException");
                Application.ThreadException += (sender, args) => HandleUnhandledException(args.Exception, "ThreadException");
            }

            // Mutex is used to check if another instance of AML is already running
            Mutex       mutex             = new Mutex(true, "E3241D27-3DD8-4615-888A-502252B9E2A1", out var isFirstInstance);
            IDisposable sentrySdkInstance = null;

            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                InitAppSettings();
                sentrySdkInstance = InitSentry();

                if (!CheckDotNet4_7_2())
                {
                    Log.Warn(".NET Framework v4.7.2 required");

                    var result = MessageBox.Show("This program requires Microsoft .NET Framework v4.7.2 or newer. Do you want to open the download page now?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);

                    if (result == DialogResult.Yes)
                    {
                        Tools.StartProcess("https://dotnet.microsoft.com/download/dotnet-framework");
                    }

                    return;
                }

                if (!SteamAPIWrapper.Init())
                {
                    Log.Warn("Failed to detect Steam");

                    StringBuilder message = new StringBuilder();
                    message.AppendLine("Please make sure that:");
                    message.AppendLine("- Steam is running");
                    message.AppendLine("- the file steam_appid.txt exists in the AML folder");
                    message.AppendLine("- neither (or both) of Steam and AML are running\n  with admin privileges");
                    MessageBox.Show(message.ToString(), "Error - unable to detect Steam!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                // Load settings
                var settings = InitializeSettings();
                if (settings == null)
                {
                    Log.Error("Failed to initialize settings");
                    return;
                }

                // Exit if another instance of AML is already running and multiple instances are disabled.
                if (!settings.AllowMultipleInstances && !isFirstInstance)
                {
                    MessageBox.Show("Another instance of AML is already running.", "AML already started", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                // Check for update
                if (!IsDebugBuild && settings.CheckForUpdates)
                {
                    CheckForUpdate();
                }

                // clean up old files
                if (File.Exists(Program.XEnv.DefaultConfigDir + @"\DefaultModOptions.ini.bak"))
                {
                    // Restore backup
                    File.Copy(Program.XEnv.DefaultConfigDir + @"\DefaultModOptions.ini.bak", Program.XEnv.DefaultConfigDir + @"\DefaultModOptions.ini", true);
                    File.Delete(Program.XEnv.DefaultConfigDir + @"\DefaultModOptions.ini.bak");
                }

                Application.Run(new MainForm(settings));
                SteamAPIWrapper.Shutdown();
            }
            finally
            {
                Log.Info("Shutting down...");
                sentrySdkInstance?.Dispose();
                GlobalSettings.Instance.Save();
                GC.KeepAlive(mutex);    // prevent the mutex from being garbage collected early
                mutex.Dispose();
            }
        }
Example #8
0
        private static void Main()
        {
#if !DEBUG
            try
            {
#endif
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!CheckDotNet4_6())
            {
                var result = MessageBox.Show("This program requires Microsoft .NET Framework v4.6 or newer. Do you want to open the download page now?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error);

                if (result == DialogResult.Yes)
                {
                    Process.Start("https://www.microsoft.com/en-us/download/details.aspx?id=56115");
                }

                return;
            }

            if (!SteamAPIWrapper.Init())
            {
                MessageBox.Show("Please start steam first!");
                return;
            }
            // SteamWorkshop.StartCallbackService();

            // Load settings
            var settings = InitializeSettings();
            if (settings == null)
            {
                return;
            }

#if !DEBUG
            // Check for update
            if (settings.CheckForUpdates)
            {
                CheckForUpdate();
            }
#endif

            // clean up old files
            if (File.Exists(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak"))
            {
                // Restore backup
                File.Copy(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak", XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini", true);
                File.Delete(XCOM2.DefaultConfigDir + @"\DefaultModOptions.ini.bak");
            }

            Application.Run(new MainForm(settings));

            SteamAPIWrapper.Shutdown();
#if !DEBUG
        }

        catch (Exception e)
        {
            MessageBox.Show("An exception occured. See error.log for additional details.");
            File.WriteAllText("error.log", e.Message + "\r\nStack:\r\n" + e.StackTrace);
        }
#endif
        }