public bool FollowToPhaseTwo()
 {
     if (Directory.Exists(_doorstopManager.TempDirName))
     {
         Directory.Delete(_doorstopManager.TempDirName, true);
         if (Directory.Exists(_doorstopManager.TempDirName))
         {
             return(false);
         }
         _doorstopManager.Install();
         return(true);
     }
     return(false);
 }
Beispiel #2
0
        public void OnEnabled()
        {
            _pluginInfo = PluginManager.instance.FindPluginInfo(Assembly.GetExecutingAssembly());
            EnsureLogsDirectoryCreated();
            _logger = new Utils.Logger(Path.Combine(Path.Combine(Application.dataPath, "Logs"), "PatchLoaderMod.log"));
            _patchLoaderConfigFilePath = Path.Combine(DataLocation.applicationBase, "PatchLoader.Config.xml");
            _configManager             = new ConfigManager <Config>(_patchLoaderConfigFilePath, _logger);

            var expectedTargetAssemblyPath = PathExtensions.Combine(
                _pluginInfo.modPath,
                "PatchLoader",
                "PatchLoader.dll"
                );

            _doorstopManager = DoorstopManager.Create(expectedTargetAssemblyPath, _logger);

            if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                ShowExceptionModal($"The '{Name}'\nMacOS platform is not supported yet.\n\n" +
                                   "Mod will disable itself.\n" +
                                   "Follow FPS Booster and PatchLoader mod development to stay informed about changes.\n" +
                                   "MacOS support will be added in one of the next major updates for PatchLoader mod.",
                                   () => {
                    _pluginInfo.isEnabled = false;
                });
                return;
            }

            if (!_doorstopManager.IsInstalled())
            {
                _doorstopManager.Install();
                SaveOrUpdateWorkshopPath();
            }

            if (_doorstopManager.CanEnable && !_doorstopManager.IsEnabled())
            {
                _doorstopManager.Enable();
            }

            if (_doorstopManager.RequiresRestart)
            {
                ShowRestartGameModal($"The '{Name}' was installed.\n{_doorstopManager.InstallMessage}");
            }

            Debug.Log("PatchLoader enabled");
        }
Beispiel #3
0
        public void OnEnabled()
        {
            gameVersionSupported = true;
            _pluginInfo          = PluginManager.instance.FindPluginInfo(Assembly.GetExecutingAssembly());
            EnsureLogsDirectoryCreated();
            _logger = new Utils.Logger(Path.Combine(Path.Combine(Application.dataPath, "Logs"), "PatchLoaderMod.log"));
            Version gameVersion = GameVersionCheck.GetVersion(BuildConfig.applicationVersion);

            _logger.Info($"Detected game version {gameVersion} from string [{BuildConfig.applicationVersion}]");
            if (!GameVersionCheck.IsGameVersionSupported(gameVersion))
            {
                _logger.Error($"Game version is not supported! ({BuildConfig.applicationVersion})");
                gameVersionSupported = false;
                ShowExceptionModal($"The '{Name}'\nGame version is not supported!\n\n" +
                                   "Mod will disable itself.\n" +
                                   "Update game to the latest version and try again or remove/unsubscribe mod.\n",
                                   () => {
                    _pluginInfo.isEnabled = false;
                });
                return;
            }

            _patchLoaderConfigFilePath = Path.Combine(DataLocation.applicationBase, "PatchLoader.Config.xml");
            _configManager             = new ConfigManager <Config>(_patchLoaderConfigFilePath, _logger);
            _configManager.EnsureCreated(Config.InitialValues());

            var expectedTargetAssemblyPath = PathExtensions.Combine(
                _pluginInfo.modPath,
                "PatchLoader",
                "PatchLoader.dll"
                );

            _doorstopManager = DoorstopManager.Create(expectedTargetAssemblyPath, _logger, _configManager);

            if (!_doorstopManager.PlatformSupported)
            {
                ShowExceptionModal($"The '{Name}'\nPlatform(MacOS) is not supported yet.\n\n" +
                                   "Mod will disable itself.\n" +
                                   "Follow FPS Booster and PatchLoader mod development to stay informed about changes.\n" +
                                   "Platform(MacOS) support will be added in one of the next major updates for PatchLoader mod.",
                                   () => {
                    _pluginInfo.isEnabled = false;
                });
                return;
            }
            SaveOrUpdateWorkshopPath();

            var config = _configManager.Load();

            if (config.UpgradeInProgress)
            {
                Debug.Log("PatchLoader enabled. Upgrade in progress");
                UpdateUpgradeStage();
                return;
            }

            if (!_doorstopManager.IsInstalled())
            {
                _doorstopManager.Install();
                UpdateUpgradeStage();
            }
            else if (_doorstopManager.IsInstalled() &&
                     _doorstopManager.UpgradeManager.State == UpgradeState.Latest &&
                     _doorstopManager.CanEnable &&
                     !_doorstopManager.IsEnabled()
                     )
            {
                _doorstopManager.Enable();
            }
            else
            {
                UpdateUpgradeStage();
            }

            if (_doorstopManager.RequiresRestart)
            {
                ShowRestartGameModal($"The '{Name}' was installed.\n{_doorstopManager.InstallMessage}", logger: _logger);
                Debug.Log($"The '{Name}' was installed.\n{_doorstopManager.InstallMessage}");
            }
            Debug.Log("PatchLoader enabled");
        }