예제 #1
0
        private void PatchButtonClicked()
        {
            bool isPatcherActive = runningPatcher != null && !runningPatcher.Equals(null);

            if (!isPatcherActive || !runningPatcher.Patcher.IsRunning)
            {
#if UNITY_EDITOR
                if (selfPatchingInput.isOn)
                {
                    Debug.LogWarning("Can't self patch while testing on editor");
                    selfPatchingInput.isOn = false;
                }
#endif

                SimplePatchTool patcher = new SimplePatchTool(rootPathInput.text, versionInfoURLInput.text).
                                          UseRepair(repairInput.isOn).UseIncrementalPatch(incrementalPatchInput.isOn).
                                          UseCustomDownloadHandler(() => new CookieAwareWebClient()). // to support https in Unity
                                          UseCustomFreeSpaceCalculator((drive) => long.MaxValue).     // DriveInfo.AvailableFreeSpace is not supported on Unity
                                          LogProgress(true);

                if (versionInfoVerifier != null)
                {
                    string versionInfoRSA = versionInfoVerifier.text;
                    patcher.UseVersionInfoVerifier(( ref string xml ) => XMLSigner.VerifyXMLContents(xml, versionInfoRSA));
                }

                if (patchInfoVerifier != null)
                {
                    string patchInfoRSA = patchInfoVerifier.text;
                    patcher.UsePatchInfoVerifier(( ref string xml ) => XMLSigner.VerifyXMLContents(xml, patchInfoRSA));
                }

                if (patcher.Run(selfPatchingInput.isOn))
                {
                    Debug.Log("Started patching...");
                    if (!isPatcherActive)
                    {
                        runningPatcher = Instantiate(patcherUiPrefab);
                    }

                    runningPatcher.Initialize(patcher);
                }
                else
                {
                    Debug.Log("Operation could not be started; maybe it is already executing?");
                }
            }
            else
            {
                Debug.LogWarning("An instance of SimplePatchTool is already running, cancel/dismiss it first!");
            }
        }
예제 #2
0
        private void PatchButtonClicked()
        {
            bool isPatcherActive = runningPatcher != null && !runningPatcher.Equals(null);

            if (!isPatcherActive || !runningPatcher.Patcher.IsRunning)
            {
#if UNITY_EDITOR
                if (selfPatchingInput.isOn)
                {
                    Debug.LogWarning("Can't self patch while testing on editor");
                    selfPatchingInput.isOn = false;
                }
#endif

                SimplePatchTool patcher = SPTUtils.CreatePatcher(rootPathInput.text, versionInfoURLInput.text).
                                          UseRepairPatch(repairPatchInput.isOn).UseIncrementalPatch(incrementalPatchInput.isOn).UseInstallerPatch(installerPatchInput.isOn).
                                          VerifyFilesOnServer(verifyServerFilesInput.isOn).CheckForMultipleRunningInstances(checkMultipleInstancesInput.isOn);

                if (!string.IsNullOrEmpty(versionInfoRSA))
                {
                    patcher.UseVersionInfoVerifier(( ref string xml ) => XMLSigner.VerifyXMLContents(xml, versionInfoRSA));
                }

                if (!string.IsNullOrEmpty(patchInfoRSA))
                {
                    patcher.UsePatchInfoVerifier(( ref string xml ) => XMLSigner.VerifyXMLContents(xml, patchInfoRSA));
                }

                if (patcher.Run(selfPatchingInput.isOn))
                {
                    Debug.Log("Started patching...");
                    if (!isPatcherActive)
                    {
                        runningPatcher = Instantiate(patcherUiPrefab);
                    }

                    runningPatcher.Initialize(patcher, selfPatcherExecutable);
                }
                else
                {
                    Debug.Log("Operation could not be started; maybe it is already executing?");
                }
            }
            else
            {
                Debug.LogWarning("An instance of SimplePatchTool is already running, cancel/dismiss it first!");
            }
        }