示例#1
0
        private void StartLauncherPatch()
        {
            if (string.IsNullOrEmpty(launcherVersionInfoURL))
            {
                return;
            }

            SimplePatchTool patcher         = InitializePatcher(launcherDirectory, launcherVersionInfoURL);
            PatcherListener patcherListener = new PatcherListener();

            patcherListener.OnVersionInfoFetched += (versionInfo) => versionInfo.AddIgnoredPath(gamesSubdirectory + "/");
            patcherListener.OnVersionFetched     += (currVersion, newVersion) => versionCodeText.text = "v" + currVersion;
            patcherListener.OnFinish             += () =>
            {
                if (patcher.Result == PatchResult.Success)
                {
                    updateLauncherPanel.gameObject.SetActive(true);
                    updateLauncherButton.onClick.AddListener(() => patcher.ApplySelfPatch(selfPatcherPath, PatchUtils.GetCurrentExecutablePath()));
                }
                else if (patcher.Result == PatchResult.AlreadyUpToDate)
                {
                    Debug.Log("Launcher is up-to-date!");
                }
                else
                {
                    Debug.LogError("Something went wrong with launcher's patch: " + patcher.FailDetails);
                }
            };

            if (!patcher.SetListener(patcherListener).Run(true))                  // true: Self patching
            {
                Debug.LogWarning("Operation could not be started; maybe it is already executing?");
            }
        }
示例#2
0
        private IEnumerator ExecutePatch()
        {
            patchButton.interactable = false;
            playButton.interactable  = false;

            patcher.LogProgress(true);
            if (patcher.Run(isPatchingLauncher))
            {
                Debug.Log("Executing patch...");

                while (patcher.IsRunning)
                {
                    FetchLogsFromPatcher();
                    yield return(null);
                }

                FetchLogsFromPatcher();
                playButton.interactable = true;

                if (patcher.Result == PatchResult.AlreadyUpToDate)
                {
                    // If launcher is already up-to-date, check if there is an update for the main app
                    if (isPatchingLauncher)
                    {
                        StartMainAppPatch(true);
                    }
                }
                else if (patcher.Result == PatchResult.Success)
                {
                    // If patcher was self patching the launcher, start the self patcher executable
                    // Otherwise, we have just updated the main app successfully!
                    if (patcher.Operation == PatchOperation.SelfPatching)
                    {
                        string selfPatcherPath = SPTUtils.SelfPatcherExecutablePath;
                        if (!string.IsNullOrEmpty(selfPatcherPath) && File.Exists(selfPatcherPath))
                        {
                            patcher.ApplySelfPatch(selfPatcherPath, PatchUtils.GetCurrentExecutablePath());
                        }
                        else
                        {
                            patcherLogText.text = "Self patcher does not exist!";
                        }
                    }
                }
                else
                {
                    // An error occurred, user can click the Patch button to try again
                    patchButton.interactable = true;
                }
            }
            else
            {
                Debug.LogWarning("Operation could not be started; maybe it is already executing?");
            }
        }
示例#3
0
        private void ExecutePatch()
        {
            StartThread(() =>
            {
                ButtonSetEnabled(patchButton, false);
                ButtonSetEnabled(playButton, false);

                patcher.LogProgress(true);
                if (patcher.Run(isPatchingLauncher))
                {
                    while (patcher.IsRunning)
                    {
                        FetchLogsFromPatcher();
                        Thread.Sleep(500);
                    }

                    FetchLogsFromPatcher();
                    ButtonSetEnabled(playButton, true);

                    if (patcher.Result == PatchResult.AlreadyUpToDate)
                    {
                        // If launcher is already up-to-date, check if there is an update for the main app
                        if (isPatchingLauncher)
                        {
                            StartMainAppPatch(true);
                        }
                    }
                    else if (patcher.Result == PatchResult.Success)
                    {
                        // If patcher was self patching the launcher, start the self patcher executable
                        // Otherwise, we have just updated the main app successfully!
                        if (patcher.Operation == PatchOperation.SelfPatching)
                        {
                            if (!string.IsNullOrEmpty(selfPatcherExecutablePath) && File.Exists(selfPatcherExecutablePath))
                            {
                                patcher.ApplySelfPatch(selfPatcherExecutablePath, PatchUtils.GetCurrentExecutablePath());
                            }
                            else
                            {
                                UpdateLabel(progressText, "Self patcher does not exist!");
                            }
                        }
                    }
                    else
                    {
                        // An error occurred, user can click the Patch button to try again
                        ButtonSetEnabled(patchButton, true);
                    }
                }
            });
        }
 private void ApplySelfPatch()
 {
     patcher.ApplySelfPatch(selfPatcherPath, PatchUtils.GetCurrentExecutablePath());
 }