예제 #1
0
    public IEnumerable UpdateCoroutine()
    {
        //exp_af_SetCopyBackupFilePackage(false);
        if (!Settings.skipProgramUpdate)
        {
        }

        Patcher.SPatcherConfig config;
        config.MinVersion   = MinimumResourceVersion;
        config.ResourcePath = Settings.externalPath;

        TextAsset stringtableAsset   = Resources.Load("patcher/stringtable", typeof(TextAsset)) as TextAsset;
        String    stringTableContent = stringtableAsset ? stringtableAsset.text : "";

        if (stringTableContent.Length == 0 || stringTableContent[0] != 0xfeff)  //add bom utf-8 unnecessary
        {
            stringTableContent = '\xfeff' + stringTableContent;
        }

        UIPanelUpdate updatePanel = UpdateUIManager.Instance.CreatePanel <UIPanelUpdate>("Panel_Update");

        ExpansionPackManager.Instance.Prepare(); // 保证在主线程中初始化


        yield return(1);
    }
예제 #2
0
	public static IEnumerable ShowMaintenanceInfo(UIPanelUpdate updatePanel, ProgramUpdate.MaintenanceInfo maintenanceInfo)
	{
		if (maintenanceInfo.status)
		{
			updatePanel.gameObject.SetActive(false);

			//add ui
			UIPanelMaintenanceInfo panel = ECUpdateUIManagerInstance.Value.CreateDialog("ui/prefab/panel_maintenanceinfo").AddComponent<UIPanelMaintenanceInfo>();
			UpdateMsgBoxSleepControl.AddSleepControl(panel.gameObject, 30, (Int32)SleepTimeoutManager.Priority.MessageBox);

			panel.reason_text.text = maintenanceInfo.reason;

			yield return new WaitForSeconds(Single.MaxValue);
		}
	}
예제 #3
0
	private IEnumerable PopYYBCoroutineInner(ProgramUpdate.VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramUpdate.ProgramsUpdateRetcode> result)
	{
		result.value_0 = ProgramUpdate.ProgramsUpdateRetcode.NotSuccess;

		StartSaveUpdate();

		foreach (var item in ShowProgressCoroutine(versionParam, updatePanel, result))
			yield return item;
	}
예제 #4
0
	public static IEnumerable PopYYBCoroutine(ProgramUpdate.VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramUpdate.ProgramsUpdateRetcode> result)
	{
		Debug.Log("PopYYBCoroutine");

		var self = Instance;
		foreach (var item in self.PopYYBCoroutineInner(versionParam, updatePanel, result))
			yield return item;
		self.CleanupCallbacks();

	}
예제 #5
0
	private IEnumerable ShowProgressCoroutine(ProgramUpdate.VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramUpdate.ProgramsUpdateRetcode> result)
	{
		updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("preparing to update");

		//显示下载进度
		Boolean bFailed = false;
		String failMsg = "";

		m_OnDownloadAppStateChangedEvent = (state, errorCode, errorMsg) =>
		{
			if (state == (Int32)TMAssistantDownloadSDKTaskState.DownloadSDKTaskState_FAILED)
			{
				Debug.LogWarning(String.Format("DownloadApp failed, state={0}, errorCode={1}, errorMsg={2}", state, errorCode, errorMsg));
				CleanupCallbacks();

				failMsg = String.Format(GameUpdateManager.Instance.GetString("download error: {0}"), errorMsg);
				bFailed = true;
			}
			else if (state == (Int32)TMAssistantDownloadSDKTaskState.DownloadSDKTaskState_SUCCEED)
			{
				updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("waiting for finish install");
				updatePanel.sub_progress.value = 1.0f;
				updatePanel.sub_progressText.text = "";
			}
		};

		m_OnDownloadAppProgressChangedEvent = (receiveDataLen, totalDataLen) =>
		{
			updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("downloading installer");
			updatePanel.sub_progress.value = (float)receiveDataLen / Math.Max((float)totalDataLen, 1.0f);
			updatePanel.sub_progressText.text = FormatProgressSize(receiveDataLen, totalDataLen);
		};

		m_OnDownloadYYBStateChangedEvent = (url, state, errorCode, errorMsg) =>
		{
			if (state == (Int32)TMAssistantDownloadSDKTaskState.DownloadSDKTaskState_FAILED)
			{
				Debug.LogWarning(String.Format("DownloadYYB failed, state={0}, errorCode={1}, errorMsg={2}", state, errorCode, errorMsg));
				CleanupCallbacks();

				failMsg = String.Format(GameUpdateManager.Instance.GetString("download error: {0}"), errorMsg);
				bFailed = true;
			}
			else if (state == (Int32)TMAssistantDownloadSDKTaskState.DownloadSDKTaskState_SUCCEED)
			{
				updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("waiting for finish install");
				updatePanel.sub_progress.value = 1.0f;
				updatePanel.sub_progressText.text = "";
			}
		};

		m_OnDownloadYYBProgressChangedEvent = (url, receiveDataLen, totalDataLen) =>
		{
			updatePanel.sub_statusText.text = GameUpdateManager.Instance.GetString("downloading yyb");
			updatePanel.sub_progress.value = (float)receiveDataLen / Math.Max((float)totalDataLen, 1.0f);
			updatePanel.sub_progressText.text = FormatProgressSize(receiveDataLen, totalDataLen);
		};

		while (!bFailed)
			yield return null;

		foreach (var item in UpdateMessageBox.Pop(String.IsNullOrEmpty(failMsg) ? GameUpdateManager.Instance.GetString("update failed") : failMsg, UpdateMessageBox.MessageBoxType.None))
			yield return item;

		yield return new WaitForSeconds(Single.MaxValue);
	}
예제 #6
0
	private IEnumerable UpdateCoroutineInner(ProgramUpdate.VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramUpdate.ProgramsUpdateRetcode> result)
	{
		result.value_0 = ProgramUpdate.ProgramsUpdateRetcode.NotSuccess;

		//load string table
		var stringTable = GameUpdateManager.Instance.StringTable;

		//check runtime platform ? Not quite needed

		var checkNeedUpdateResult = new ReturnTuple<Boolean, Int64, String, Int64, Int32, String, Int32>();
		foreach (var item in CheckNeedUpdateCoroutine(10.0f, checkNeedUpdateResult))
			yield return item;

		if (!checkNeedUpdateResult.value_0)
		{
			Debug.LogWarning("CheckNeedUpdate timeout");
			foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("update failed"), UpdateMessageBox.MessageBoxType.None))
				yield return item;
			yield return new WaitForSeconds(Single.MaxValue);
		}

		Debug.Log("CheckNeedUpdate success");


		//Boolean hasPatch = false;

		var updateMethod = checkNeedUpdateResult.value_6;
		if (updateMethod == (Int32)TMSelfUpdateSDKUpdateInfo.UpdateMethod_NoUpdate)
		{
			//判断有更新,但应用宝无更新可下载
			Debug.LogWarning("No Update Available");
			foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("no update available"), UpdateMessageBox.MessageBoxType.None))
				yield return item;
			yield return new WaitForSeconds(Single.MaxValue);
		}
		//else if (updateMethod == (Int32)TMSelfUpdateSDKUpdateInfo.UpdateMethod_Normal)
		//{
		//    hasPatch = false;
		//}
		//else if (updateMethod == (Int32)TMSelfUpdateSDKUpdateInfo.UpdateMethod_ByPatch)
		//{
		//    hasPatch = true;
		//}
		//else
		//{
		//    Debug.LogWarning("Invalid update method");
		//    foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("update failed"), UpdateMessageBox.MessageBoxType.None))
		//        yield return item;

		//    yield return new WaitForSeconds(Single.MaxValue);
		//}

		var chooseYYBUpdateStyleResult = new ReturnTuple<UpdateChooseBox.YYBUpdateStyle>();
		foreach (var item in UpdateChooseBox.ChooseYYBUpdateStyle(chooseYYBUpdateStyleResult))
			yield return item;

		if (chooseYYBUpdateStyleResult.value_0 == UpdateChooseBox.YYBUpdateStyle.InGame)
		{
			//游戏内更新且没用wifi需要提示
			ReturnTuple<Boolean> confirmWirelessDownloadingResult = new ReturnTuple<Boolean>();
			foreach (var item in GameUpdateManager.Instance.ConfirmWirelessDownloading(confirmWirelessDownloadingResult))
				yield return item;

			if (!confirmWirelessDownloadingResult.value_0)
			{
				result.value_0 = ProgramUpdate.ProgramsUpdateRetcode.Fail;	//用户取消
				yield break;
			}
		}

		if (chooseYYBUpdateStyleResult.value_0 == UpdateChooseBox.YYBUpdateStyle.PopYYB)
		{
			StartSaveUpdate();
		}
		else if (chooseYYBUpdateStyleResult.value_0 == UpdateChooseBox.YYBUpdateStyle.InGame)
		{
			StartCommonUpdate();
		}
		else
		{
			result.value_0 = ProgramUpdate.ProgramsUpdateRetcode.Fail;	//用户取消
			yield break;
		}

		foreach (var item in ShowProgressCoroutine(versionParam, updatePanel, result))
			yield return item;
	}
예제 #7
0
파일: ProgramUpdate.cs 프로젝트: fengqk/Art
	public static IEnumerable GetDirInfoCoroutine(UIPanelUpdate updatePanel, ReturnTuple<ProgramsUpdateRetcode> result)
	{
		result.value_0 = ProgramsUpdateRetcode.NotSuccess;

		//load string table
		var stringTable = GameUpdateManager.Instance.StringTable;

		{	//init update ui
			updatePanel.sub_programTextGroup.SetActive(false);
			updatePanel.sub_resourceTextGroup.SetActive(false);

			updatePanel.sub_progress.value = 0;
			updatePanel.sub_progressText.text = "";
			updatePanel.sub_programLocalVersion.text = "";
			updatePanel.sub_programNewestVersion.text = "";
			updatePanel.sub_statusText.text = "";
		}

		SecurityElement dir_server = PlatformConfig.GetConfig("dir_server");
		String dir_server_address = dir_server.Attributes["address"].ToString();
		Int32 dir_server_port = Convert.ToInt32(dir_server.Attributes["port"].ToString());
		Boolean hasBackupAddress = true;
		//此时还未取得远程版本信息,所以 resource_update 从本地取,而不调用 GetResourceUpdateConfig
		var importantlist_address = PlatformConfig.GetConfig("resource_update").Attributes["importantlist"];
		if (importantlist_address == null || importantlist_address.ToString() == "")
			hasBackupAddress = false;

		if (String.IsNullOrEmpty(dir_server_address) || dir_server_port == 0)	//no dir server
		{
			result.value_0 = ProgramsUpdateRetcode.Success;
			yield break;
		}

		updatePanel.sub_statusText.text = stringTable["checking for update"];
		do
		{
			var dirSession = GNET.DirClient.RequestInfo(dir_server_address, dir_server_port);

			Single startWaitTime = Time.realtimeSinceStartup;
			Single timeOut = 10f;
			while (!GNET.DirClient.GetInstance().HasGotInfo())
			{
				if (Time.realtimeSinceStartup - startWaitTime > timeOut)
				{
					if (!hasBackupAddress)	//失败时无备选则提示重试
					{
						var msgBoxRet = new ReturnTuple<UpdateMessageBox.MessageBoxResult>();
						foreach (var item in UpdateMessageBox.Pop(stringTable["failed to check for update. click confirm to retry"], UpdateMessageBox.MessageBoxType.OK, msgBoxRet))
							yield return item;
					}

					GNET.DirClient.AbortRequest(dirSession);
					Debug.LogWarning("get dir info time out");

					break;
				}
				yield return null;
			}

			if (GNET.DirClient.GetInstance().HasGotInfo())
				break;
		}
		while (!hasBackupAddress);	//失败时无备选则重试

		EntryPoint.Instance.StartCoroutine(GetDirInfoLoopCoroutine(dir_server_address, dir_server_port));

		result.value_0 = ProgramsUpdateRetcode.Success;
	}
예제 #8
0
파일: ProgramUpdate.cs 프로젝트: fengqk/Art
	private static IEnumerable InstallCoroutine(VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramsUpdateRetcode> result)
	{
		result.value_0 = ProgramsUpdateRetcode.NotSuccess;

		//load string table
		var stringTable = GameUpdateManager.Instance.StringTable;

		//check runtime platform
		if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.Android)		//supported
		{
		}
		else if (Application.platform == RuntimePlatform.WindowsEditor)		//方便测试用
		{}
		else
		{
			updatePanel.sub_statusText.text = stringTable["auto update not supported"];
			foreach (var item in UpdateMessageBox.Pop(stringTable["auto update not supported, please update manually"], UpdateMessageBox.MessageBoxType.OK))
			    yield return item;

		    result.value_0 = ProgramsUpdateRetcode.Fail;
		    yield break;
		}

		yield return null;

		PatcherSpace.LauncherConfig launcherConfig;
		launcherConfig.resourcePath = EntryPointParam.AssetsPath;
		launcherConfig.stringTable = stringTable;
		launcherConfig.targetVersion = versionParam.newestVersion;
		launcherConfig.packAddress = versionParam.updateUrl;
		launcherConfig.packMd5 = versionParam.updateMd5;
		launcherConfig.tempDir = makeLauncherTempDir();

		PatcherSpace.Launcher launcher = PatcherSpace.Launcher.instance();
		launcher.init(launcherConfig);
		launcher.startInstall((e) => { Debug.LogException(e); });

		Int32 toFinish = 2;
		while (toFinish > 0)
		{
			if (!launcher.isBusy())	//这样能在结束后更新状态
				--toFinish;

			updatePanel.sub_progress.value = (float)launcher.getTotalProgress();
			updatePanel.sub_statusText.text = launcher.getStatusText();

			Int64 totalUpdateSize = launcher.getUpdateTotalSize();
			if (totalUpdateSize > 0)
			{
				updatePanel.sub_progressText.text = FormatFileSize((Int64)(totalUpdateSize * launcher.getTotalProgress())) + "/" + FormatFileSize(totalUpdateSize);
			}
			else
			{
				updatePanel.sub_progressText.text = "";
			}

			yield return null;
		}

		PatcherSpace.Launcher.ErrorCode errorCode = launcher.getErrorCode();
		Boolean bSuccess = (errorCode == PatcherSpace.Launcher.ErrorCode.OK);
		result.value_0 = ProgramsUpdateRetcode.Success;

		if (errorCode == PatcherSpace.Launcher.ErrorCode.OK)
		{
			if (Application.platform == RuntimePlatform.WindowsPlayer)
			{
				EntryPoint.ExitGame();
			}
			else if (Application.platform == RuntimePlatform.WindowsEditor)		//方便测试用
			{
				foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("waiting for finish install"), UpdateMessageBox.MessageBoxType.None))
					yield return item;
				yield return new WaitForSeconds(Single.MaxValue);
			}
			else if (Application.platform == RuntimePlatform.Android)
			{
				foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("waiting for finish install"), UpdateMessageBox.MessageBoxType.None))
					yield return item;
				yield return new WaitForSeconds(Single.MaxValue);
			}
		}
		else if (errorCode == PatcherSpace.Launcher.ErrorCode.Fail)
		{
			foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("update failed"), UpdateMessageBox.MessageBoxType.None))
				yield return item;
			yield return new WaitForSeconds(Single.MaxValue);
		}
		else if (errorCode == PatcherSpace.Launcher.ErrorCode.NoSpace)
		{
			foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("no disk space"), UpdateMessageBox.MessageBoxType.None))
				yield return item;
			yield return new WaitForSeconds(Single.MaxValue);
		}
	}
예제 #9
0
파일: ProgramUpdate.cs 프로젝트: fengqk/Art
	/// <param name="targetVersion">应设为 GetProgramNewestVersion 所得结果</param>
	/// <param name="result">第一个元素表示是否成功</param>
	private static IEnumerable UpdateProgram(VersionParam versionParam, UIPanelUpdate updatePanel, ReturnTuple<ProgramsUpdateRetcode> result)
	{
		//init
		result.value_0 = ProgramsUpdateRetcode.NotSuccess;

		String method = versionParam.updateMethod;
		if (method == "install")
		{
			foreach (var item in InstallCoroutine(versionParam, updatePanel, result))
				yield return item;
		}
		else if (method == "open_url")
		{
			OpenUrl(versionParam.updateUrl);
			var stringTable = GameUpdateManager.Instance.StringTable;
			foreach (var item in UpdateMessageBox.Pop(stringTable["waiting for finish update"], UpdateMessageBox.MessageBoxType.None))
				yield return item;
			yield return new WaitForSeconds(Single.MaxValue);
		}
		else if (method == "yyb")
		{
			foreach (var item in ProgramUpdateYYB.UpdateCoroutine(versionParam, updatePanel, result))
				yield return item;
		}
		else if (method == "pop_yyb")
		{
			foreach (var item in ProgramUpdateYYB.PopYYBCoroutine(versionParam, updatePanel, result))
				yield return item;
		}
		else if (method == "msg")	//实在没辙了可以显示一条消息
		{
			foreach (var item in UpdateMessageBox.Pop(versionParam.updateUrl, UpdateMessageBox.MessageBoxType.None))
				yield return item;

			yield return new WaitForSeconds(Single.MaxValue);
		}
		else
		{
			throw new Exception("unsupported program_update method: " + method);
		}
	}
예제 #10
0
파일: ProgramUpdate.cs 프로젝트: fengqk/Art
	public static IEnumerable UpdateCoroutine(UIPanelUpdate updatePanel, ReturnTuple<ProgramsUpdateRetcode> result, ReturnTuple<MaintenanceInfo> maintenanceInfo)
	{
		result.value_0 = ProgramsUpdateRetcode.NotSuccess;
		maintenanceInfo.value_0.status = false;
		maintenanceInfo.value_0.reason = "";

		//load string table
		var stringTable = GameUpdateManager.Instance.StringTable;

		{	//init update ui
			updatePanel.sub_programTextGroup.SetActive(true);
			updatePanel.sub_resourceTextGroup.SetActive(false);

			updatePanel.sub_progress.value = 0;
			updatePanel.sub_progressText.text = "";
			updatePanel.sub_programLocalVersion.text = "";
			updatePanel.sub_programNewestVersion.text = "";
			updatePanel.sub_statusText.text = "";
		}

		//local version
		ProgramVersionInfo localVersionInfo = GetProgramCurrentVersionInfo();
		
		updatePanel.sub_programLocalVersion.text = localVersionInfo.descriptionName;
		Debug.Log(String.Format("local version: {0}", localVersionInfo.version));

		////Test message box
		//{
		//    var msgBoxRet = new ReturnTuple<UpdateMessageBox.MessageBoxResult>();
		//    foreach (var item in UpdateMessageBox.Pop("Are you sure to update program ?", UpdateMessageBox.MessageBoxType.YES_NO, msgBoxRet))
		//        yield return item;

		//    if (msgBoxRet.value_0 == UpdateMessageBox.MessageBoxResult.NO)
		//    {
		//        result.value_0 = false;
		//        yield break;
		//    }
		//}

		updatePanel.sub_statusText.text = stringTable["checking for update"];
		var getVersionResult = new ReturnTuple<Boolean, String>();		//bSucc, content

		String newestVersionInfo = null;
		if (GNET.DirClient.GetInstance().HasGotInfo())
		{
			newestVersionInfo = GNET.DirClient.GetInstance().GetVersion();
		}
		else
		{
			while (true)
			{
				foreach (var item in GetProgramNewestVersionInfo(getVersionResult))
					yield return item;

				if (getVersionResult.value_0)
				{
					break;
				}
				else	//未取得版本号
				{
					var msgBoxRet = new ReturnTuple<UpdateMessageBox.MessageBoxResult>();
					foreach (var item in UpdateMessageBox.Pop(stringTable["failed to check for update. click confirm to retry"], UpdateMessageBox.MessageBoxType.OK, msgBoxRet))
						yield return item;
				}
			}
			newestVersionInfo = getVersionResult.value_1;
		}

		//分析取得的版本信息
		Exception error = null;
		VersionParam versionParam = new VersionParam();
		try
		{
			SecurityElement versionDoc = SecurityElement.FromString(newestVersionInfo);
			SecurityElement verNode = versionDoc;

			//如果有 specialRegion,按 specialRegion 再找一级
			String specialRegion = PlatformConfig.GetSpecialRegion();
			if (specialRegion != "")
				verNode = verNode.SearchForChildByTag(specialRegion);

			versionParam.newestVersion = Convert.ToInt32(verNode.Attributes["value"].ToString());
			Int32.TryParse(verNode.Attributes["compatible_version"].ToString(), out versionParam.compatibleVersion);

			if (verNode.Attributes["evaluation"] != null && verNode.Attributes["evaluation"].ToString() == "true")
				m_isEvaluation = true;
				
			if (verNode.Attributes["evaluation_version"] != null)
			{
				String evaluation_version_str = verNode.Attributes["evaluation_version"].ToString();
				if (evaluation_version_str.Length > 0)
				{
					Int32 evaluation_version = Convert.ToInt32(verNode.Attributes["evaluation_version"].ToString());
					if (localVersionInfo.version >= evaluation_version)
						m_isEvaluation = true;
				}
			}

			if (verNode.Attributes["evaluation_update"] != null && verNode.Attributes["evaluation_update"].ToString() == "true")
				m_isEvaluationUpdate = true;


			versionParam.minimumResourceVersion = verNode.Attributes["minimum_resource_version"].ToString();
			versionParam.updateMethod = verNode.SearchForChildByTag("update").Attributes["method"].ToString();
			String url = "";
			if (verNode.SearchForChildByTag("update").Attributes.Contains("url"))
				url = verNode.SearchForChildByTag("update").Attributes["url"].ToString();
			versionParam.updateUrl = url;

			if (verNode.SearchForChildByTag("update").Attributes.Contains("md5"))
				versionParam.updateMd5 = verNode.SearchForChildByTag("update").Attributes["md5"].ToString();

			versionParam.newestVersionShowName = verNode.SearchForChildByTag("description").Attributes["name"].ToString();
			versionParam.newestVersionContent = verNode.SearchForChildByTag("description").Attributes["content"].ToString();

			maintenanceInfo.value_0.status = verNode.SearchForChildByTag("maintenance").Attributes["status"].ToString() == "true";
			maintenanceInfo.value_0.reason = verNode.SearchForChildByTag("maintenance").Attributes["reason"].ToString();
			
			PlatformConfig.SetResourceUpdateConfig(verNode.SearchForChildByTag("resource_update"));
		}
		catch (XmlSyntaxException e)
		{	error = e;	}
		catch (NullReferenceException e)
		{	error = e;	}
		catch (FormatException e)
		{	error = e;	}
		catch (OverflowException e)
		{	error = e;	}

		if (error != null)
		{
			Debug.LogWarning("version.xml has format error");
			Debug.LogException(error);
			foreach (var item in UpdateMessageBox.Pop(stringTable["update server has error"], UpdateMessageBox.MessageBoxType.None))
			    yield return item;

			yield return new WaitForSeconds(Single.MaxValue);
		}

		if (IsEvaluation() && !IsEvaluationUpdate())
		{
			result.value_0 = ProgramsUpdateRetcode.Skip;
			yield break;
		}

		//已取得最低资源版本,记下来
		GameUpdateManager.Instance.MinimumResourceVersion = PatcherSpace.Patcher.VersionInfo.FromString(versionParam.minimumResourceVersion);

		updatePanel.sub_programNewestVersion.text = versionParam.newestVersionShowName;

		if (versionParam.newestVersion > localVersionInfo.version)
		{
			PatcherSpace.Launcher.instance().ClearTempDir(versionParam.newestVersion, makeLauncherTempDir());

			Debug.Log(String.Format("has new version: {0}", versionParam.newestVersion));

			while (true)
			{
				ReturnTuple<Boolean> chooseWhetherUpdateResult = new ReturnTuple<Boolean>();
				String title = String.Format(stringTable["newest version is {0}"], versionParam.newestVersionShowName);
				foreach (var item in UpdateChooseBox.ChooseWhetherUpdate(title, versionParam.newestVersionContent, chooseWhetherUpdateResult))
					yield return item;

				if (chooseWhetherUpdateResult.value_0)	//选了“是”
				{
					break;
				}
				else
				{
					//选了“否”
					if (versionParam.compatibleVersion > localVersionInfo.version)	//必须更新
					{
						var msgBoxRet = new ReturnTuple<UpdateMessageBox.MessageBoxResult>();
						foreach (var item in UpdateMessageBox.Pop(stringTable["must update"], UpdateMessageBox.MessageBoxType.OK, msgBoxRet))
							yield return item;
					}
					else	//跳过更新
					{
						result.value_0 = ProgramsUpdateRetcode.Success;
						yield break;
					}
				}
			}

			foreach (var item in UpdateProgram(versionParam, updatePanel, result))
				yield return item;

			if (result.value_0 == ProgramsUpdateRetcode.Fail)
			{
				Debug.Log("UpdateCoroutine failed");
				foreach (var item in UpdateMessageBox.Pop(stringTable["update failed"], UpdateMessageBox.MessageBoxType.None))
					yield return item;
				yield return new WaitForSeconds(Single.MaxValue);
			}
		}
		else
		{
			PatcherSpace.Launcher.instance().ClearTempDir(makeLauncherTempDir());
		}
	}
예제 #11
0
	public static IEnumerable UpdateCoroutine(UIPanelUpdate updatePanel, Boolean bSkipResourceUpdate, ReturnTuple<Boolean> result)
	{
		PatcherSpace.Patcher.PatcherConfig config;
		config.minimumVersion = GameUpdateManager.Instance.MinimumResourceVersion;
		config.resourcePath = EntryPointParam.AssetsPath;
		TextAsset stringtableAsset = Resources.Load("patcher/stringtable", typeof(TextAsset)) as TextAsset;
		String stringTableContent = stringtableAsset ? stringtableAsset.text : "";
		if (stringTableContent.Length == 0 || stringTableContent[0] != 0xfeff)	//add bom
			stringTableContent = '\xfeff' + stringTableContent;

		SecurityElement configXml = PlatformConfig.GetResourceUpdateConfig();

		config.resBaseVersion = LoadResBaseVersion();
		config.resBasePath = EntryPoint.Instance.BackupAssetsPath;
		config.cachePath = EntryPointParam.AssetsPath + "/cache";
		config.stringTableContent = stringTableContent;
		config.packext = configXml.Attributes["packext"].ToString();
		config.project = configXml.Attributes["project"].ToString();
		config.address = configXml.Attributes["address"].ToString();
		config.importantlist = configXml.Attributes["importantlist"].ToString();
		var packdownloadurlNode = configXml.Attributes["packdownloadurl"];
		config.packdownloadurl = packdownloadurlNode != null ? packdownloadurlNode.ToString() : "";
        config.newVersionFromDirInfo = GNET.DirClient.GetInstance().GetVersionList() ?? "";

		PatcherSpace.Patcher patcher = PatcherSpace.Patcher.instance();
		patcher.setup(config, EntryPoint.GetResBaseRelativePath());

		////D test message box (and wait for debugger)
		//var msgBoxRet = new ReturnTuple<UpdateMessageBox.MessageBoxResult>();
		//foreach (var item in UpdateMessageBox.Pop("Are you sure to update resource ?", UpdateMessageBox.MessageBoxType.YES_NO, msgBoxRet))
		//    yield return item;

		//if (msgBoxRet.value_0 == UpdateMessageBox.MessageBoxResult.NO)
		//{
		//    result.value_0 = false;
		//    yield break;
		//}

		//init ui
		{
			updatePanel.sub_programTextGroup.SetActive(false);
			updatePanel.sub_resourceTextGroup.SetActive(true);

			updatePanel.sub_resourceLocalVersion.text = "";
			updatePanel.sub_resourceNewestVersion.text = "";
			updatePanel.sub_progress.value = 0;
			updatePanel.sub_statusText.text = "";
			updatePanel.sub_progressText.text = "";
		}
		updatePanel.gameObject.SetActive(true);

		do
		{
			Debug.Log("Start update stages");

			ExpansionPackManager.Instance.Touch();	//保证在主线程中初始化

			foreach (var item in RunPatcherStage(updatePanel, () => patcher.startInitResource((e) => { Debug.LogException(e); }), result))
				yield return item;

			if (patcher.getErrorCode() != PatcherSpace.Patcher.ErrorCode.OK)
				continue;

			if (!bSkipResourceUpdate)
			{
				Debug.Log("expansion dir: " + ExpansionPackManager.Instance.GetDownloadedDir());
				foreach (var item in RunPatcherStage(updatePanel, () => patcher.startExpansionPackUpdate((e) => { Debug.LogException(e); }), result))
					yield return item;

				if (patcher.getErrorCode() != PatcherSpace.Patcher.ErrorCode.OK)
					continue;

				foreach (var item in RunPatcherStage(updatePanel, () => patcher.startAutoUpdate((e) => { Debug.LogException(e); }), result))
					yield return item;

				if (patcher.getErrorCode() != PatcherSpace.Patcher.ErrorCode.OK)
					continue;
			}
		}
		while (patcher.getErrorCode() == PatcherSpace.Patcher.ErrorCode.Restart);

		{
			//updatePanel.sub_groupAll.SetActive(false);
			//yield return null;
			ECUpdateUIManagerInstance.Value.DestroyDialog(updatePanel);
		}
	}
예제 #12
0
	private static IEnumerable RunPatcherStage(UIPanelUpdate updatePanel, Action stageAction, ReturnTuple<Boolean> result)
	{
		result.value_0 = false;

		PatcherSpace.Patcher patcher = PatcherSpace.Patcher.instance();

		stageAction();

		yield return null;

		Int32 toFinish = 2;
		while (toFinish > 0)
		{
			if (!patcher.isBusy())	//这样能在结束后更新状态
				--toFinish;

			updatePanel.sub_resourceLocalVersion.text = patcher.getLocalVersion().ToString();
			updatePanel.sub_resourceNewestVersion.text = patcher.getServerVersion().ToString();

			Double progress = patcher.getTotalProgress();
			updatePanel.sub_progress.value = (float)patcher.getTotalProgress();

			updatePanel.sub_statusText.text = patcher.getStatusText();

			Int64 totalUpdateSize = patcher.getUpdateTotalSize();
			if (totalUpdateSize > 0 && patcher.getUpdateStage() == PatcherSpace.Patcher.UpdateStage.Update)
			{
			    updatePanel.sub_progressText.text = FormatFileSize((Int64)(totalUpdateSize * progress)) + "/" + FormatFileSize(totalUpdateSize);
			}
			else
			{
			    updatePanel.sub_progressText.text = "";
			}

			yield return null;
		}
		
		PatcherSpace.Patcher.ErrorCode errorCode = patcher.getErrorCode();
		if (errorCode == PatcherSpace.Patcher.ErrorCode.OK
			|| errorCode == PatcherSpace.Patcher.ErrorCode.Cancel
			|| errorCode == PatcherSpace.Patcher.ErrorCode.Restart)
		{
			//updatePanel.sub_progress.sliderValue = 1;
			Debug.Log("Status: " + patcher.getStatusText());

			result.value_0 = true;
		}
		else
		{
			result.value_0 = false;

			Debug.Log(patcher.getErrorCode());
			Debug.Log("Status: " + patcher.getStatusText());
			Debug.Log("Error message: " + patcher.getErrorText());
			foreach (var item in UpdateMessageBox.Pop(GameUpdateManager.Instance.GetString("update failed"), UpdateMessageBox.MessageBoxType.None))
				yield return item;
			yield return new WaitForSeconds(Single.MaxValue);
		}

	}