// TODO: Test all checks again
        internal static GameType GetGameType(GameDetection result)
        {
            if (result.IsError)
            {
                return(GameType.Undefined);
            }
            if (CheckSteam(result.FocExe))
            {
                return(GameType.SteamGold);
            }
            if (CheckGoG(result.FocExe))
            {
                return(GameType.GoG);
            }
            Logger.Info("Checking CheckOrigin...");
            if (CheckOrigin(result, out var fixedFileInfo))
            {
                Logger.Info("End Checking CheckOrigin: Result TRUE");
                if (fixedFileInfo != null)
                {
                    Logger.Info($"Replacing result data to: {fixedFileInfo.FullName}");
                    result.FocExe = fixedFileInfo;
                }

                return(GameType.Origin);
            }
            Logger.Info("End Checking CheckOrigin: Result FALSE");

            // TODO: Check DiskGold (just to have them all)
            return(GameType.Disk);
        }
        private static bool CheckOrigin(GameDetection result, out FileInfo?fixedFileInfo)
        {
            fixedFileInfo = default;

            var focExe = result.FocExe;
            var exists = CheckOrigin(focExe);

            if (exists)
            {
                return(true);
            }

            Logger.Info("Try to check again with with applied");
            var fixedFocExe = CreateOriginFileInfo(focExe);

            if (fixedFocExe is null)
            {
                return(false);
            }

            var fixWorked = CheckOrigin(fixedFocExe);

            if (fixWorked)
            {
                fixedFileInfo = fixedFocExe;
                return(true);
            }

            return(false);
        }
        private static void CloseApplication(GameDetection gameDetection)
        {
            var message = string.Empty;

            if (gameDetection.EawExe == null || !gameDetection.EawExe.Exists)
            {
                message = "Could not find Empire at War!\r\n";
            }
            else if (gameDetection.FocExe == null || !gameDetection.FocExe.Exists)
            {
                message += "Could not find Forces of Corruption\r\n";
            }
            MessageBox.Show(message + "\r\nThe launcher will now be closed", "FoC Launcher",
                            MessageBoxButton.OK,
                            MessageBoxImage.Error);
            Application.Current.Shutdown();
        }
        private Task SetupGamesAsync(GameDetection e)
        {
            var gameManager = LauncherGameManager.Instance;

            gameManager.Initialize(e);
            var foc = gameManager.ForcesOfCorruption;
            var eaw = gameManager.EmpireAtWar;

            RegisterEvents();

            new TaskFactory().StartNew(() =>
            {
                foc !.Setup(GameSetupOptions.ResolveModDependencies);
                //eaw!.Setup(GameSetupOptions.ResolveModDependencies);
            }).Forget();

            return(Task.CompletedTask);
        }