private IEnumerator CheckForUpdates(MultiGameLauncherGameHolder gameHolder) { if (string.IsNullOrEmpty(gameHolder.Configuration.VersionInfoURL)) { yield break; } // Check if there are any updates for the game SimplePatchTool patcher = InitializePatcher(Path.Combine(gamesDirectory, gameHolder.Configuration.Subdirectory), gameHolder.Configuration.VersionInfoURL); // = checkVersionOnly = // true (default): only version number (e.g. 1.0) is compared against VersionInfo to see if there is an update // false: hashes and sizes of the local files are compared against VersionInfo (if there are any different/missing files, we'll patch the app) if (patcher.CheckForUpdates(true)) { while (patcher.IsRunning) { yield return(null); } if (patcher.Result == PatchResult.Success) { Debug.Log("There is an update for " + gameHolder.Configuration.Name); gameHolder.PatchButtonSetVisible(true); } } else { Debug.LogWarning("Operation could not be started; maybe it is already executing?"); } }
private void ExecutePatch(MultiGameLauncherGameHolder gameHolder) { if (string.IsNullOrEmpty(gameHolder.Configuration.VersionInfoURL)) { return; } SimplePatchTool patcher = InitializePatcher(Path.Combine(gamesDirectory, gameHolder.Configuration.Subdirectory), gameHolder.Configuration.VersionInfoURL); PatcherListener patcherListener = new PatcherListener(); patcherListener.OnLogReceived += (log) => { if (logToConsole) { Debug.Log(log); } patcherLogText.text = log; }; patcherListener.OnProgressChanged += (progress) => { if (logToConsole) { Debug.Log(string.Concat(progress.Percentage, "% ", progress.ProgressInfo)); } patcherProgressText.text = progress.ProgressInfo; patcherProgressbar.value = progress.Percentage; }; patcherListener.OnOverallProgressChanged += (progress) => patcherOverallProgressbar.value = progress.Percentage; patcherListener.OnFinish += () => { HidePatcherProgressPanel(); for (int i = 0; i < gameHolders.Length; i++) { gameHolders[i].PatchButtonSetEnabled(true); } if (patcher.Result == PatchResult.Success || patcher.Result == PatchResult.AlreadyUpToDate) { Debug.Log(gameHolder.Configuration.Name + " is " + (patcher.Result == PatchResult.Success ? "patched!" : "already up-to-date")); gameHolder.PlayButtonSetEnabled(true); gameHolder.PatchButtonSetVisible(false); } else { Debug.LogError("Something went wrong with " + gameHolder.Configuration.Name + "'s patch: " + patcher.FailDetails); } }; if (patcher.SetListener(patcherListener).Run(false)) // false: Not self patching { ShowPatcherProgressPanel(); for (int i = 0; i < gameHolders.Length; i++) { gameHolders[i].PatchButtonSetEnabled(false); } gameHolder.PlayButtonSetEnabled(false); } else { Debug.LogWarning("Operation could not be started; maybe it is already executing?"); } }