public void OnDisabled() { if (Application.platform == RuntimePlatform.OSXPlayer) { Debug.Log("PatchLoader disabled"); return; } if (_doorstopManager.IsInstalled() && !_pluginInfo.isEnabled) { _doorstopManager.Disable(); } if (_doorstopManager.RequiresRestart) { ShowRestartGameModal($"The '{Name}' was uninstalled.\n{_doorstopManager.UninstallMessage}"); } _doorstopManager = null; _pluginInfo = null; _logger = null; _patchLoaderConfigFilePath = null; _configManager = null; Debug.Log("PatchLoader disabled"); }
public void CreateUi(UIHelperBase helper, DoorstopManager manager) { _manager = manager; var uiHelper = helper as UIHelper; var panel = uiHelper.self as UIScrollablePanel; var label = panel.AddUIComponent <UILabel>(); label.relativePosition = new Vector3(10, 0, 10); label.processMarkup = true; StringBuilder builder = new StringBuilder(); StringBuilder internalBuilder = new StringBuilder(); bool anyError = false; foreach (KeyValuePair <string, PatchStatus> patchStatus in PatchLoaderStatusInfo.Statuses) { if (patchStatus.Value.HasError) { anyError = true; builder.Append(" ") .Append(patchStatus.Key) .Append(": <color ").Append(colorError).Append(">") .Append("Error (").Append(patchStatus.Value.ErrorMessage).AppendLine(") </color>"); } internalBuilder.Append(" ") .Append(patchStatus.Key) .Append(patchStatus.Value.HasError ? ": Error (" : ": OK") .Append(patchStatus.Value.HasError ? patchStatus.Value.ErrorMessage : "") .AppendLine(patchStatus.Value.HasError ? ")" : ""); } if (!anyError && PatchLoaderStatusInfo.Statuses.Count > 0) { builder.Append(" ") .Append("<color").Append(colorOk).Append(">").Append("All patches applied correctly").AppendLine("</color>").AppendLine(); } label.text = "Statuses:\n\n" + (PatchLoaderStatusInfo.Statuses.Count > 0 ? builder.ToString() : "No patches processed.\n"); _logger?.Info("Statuses:\n" + internalBuilder); UIHelper loaderGroup = helper.AddGroup("Loader") as UIHelper; var uiPanel = loaderGroup.self as UIPanel; _statusLabel = uiPanel.AddUIComponent <UILabel>(); _statusLabel.processMarkup = true; _upgradeButton = loaderGroup.AddButton("Upgrade", OnUpgrade) as UIButton; UpdateStatus(); }
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"); }
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"); }
public void SetDoorstopManager(DoorstopManager manager) { _doorstopManager = manager; }