public void OnDisabled() { if (_doorstopManager != null) { if (_doorstopManager.IsInstalled() && !_pluginInfo.isEnabled) { _doorstopManager.Disable(); } if (_doorstopManager.RequiresRestart) { ShowRestartGameModal($"The '{Name}' was uninstalled.\n{_doorstopManager.UninstallMessage}", logger: _logger); Debug.Log($"The '{Name}' was uninstalled \n{_doorstopManager.InstallMessage}"); } _doorstopManager = null; } _pluginInfo = null; _logger = null; _patchLoaderConfigFilePath = null; _configManager = null; Debug.Log("PatchLoader disabled"); }
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"); }