private void DrawChannel(ChannelData channelData) { if (channelData == null) { return; } if (!string.IsNullOrEmpty(m_searchText) && channelData.Name?.Contains(m_searchText) == false) { return; } bool delete = false; bool save = false; bool edit = false; bool discard = false; EditorGUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.BeginHorizontal(); { channelData.Foldout = EditorGUILayout.Foldout(channelData.Foldout, $"{channelData.Name}: {channelData.Build}[{channelData.Version}]") || channelData.IsEdit; } EditorGUILayout.EndHorizontal(); if (channelData.Foldout) { if (channelData.IsEdit) { bool canSave = true; if (string.IsNullOrEmpty(channelData.Name) || m_deployData.Channels.Find((c) => c != channelData && c.Name == channelData.Name) != null) { canSave = false; channelData.Name = BBGoGUI.ErrorTextField(Localization.GetString("deploy_tab_channel_name"), channelData.Name)?.Trim(); } else { channelData.Name = EditorGUILayout.TextField(Localization.GetString("deploy_tab_channel_name"), channelData.Name)?.Trim(); } if (string.IsNullOrEmpty(channelData.URL)) { canSave = false; channelData.URL = BBGoGUI.ErrorTextField(Localization.GetString("deploy_tab_channel_url"), channelData.URL)?.Trim(); } else { channelData.URL = EditorGUILayout.TextField(Localization.GetString("deploy_tab_channel_url"), channelData.URL)?.Trim(); } int buildIndex = m_managerWindow.FinalPatchEditorData.builds.FindIndex((buildData) => { return(buildData.name == channelData.Build); }); if (buildIndex < 0) { canSave = false; buildIndex = BBGoGUI.ErrorPopup(Localization.GetString("deploy_tab_channel_build"), buildIndex, m_managerWindow.FinalPatchEditorData.builds.ConvertAll((patchVersion) => { return(patchVersion.name); }).ToArray()); } else { buildIndex = EditorGUILayout.Popup(Localization.GetString("deploy_tab_channel_build"), buildIndex, m_managerWindow.FinalPatchEditorData.builds.ConvertAll((patchVersion) => { return(patchVersion.name); }).ToArray()); } BuildVersion buildVersion = null; if (buildIndex >= 0) { buildVersion = m_managerWindow.FinalPatchEditorData.builds[buildIndex]; channelData.Build = buildVersion.name; } else { channelData.Build = null; } BBGoGUI.BeginEnable(!string.IsNullOrEmpty(channelData.Build)); { if (buildVersion != null) { channelData.Version = EditorGUILayout.IntSlider(Localization.GetString("deploy_tab_channel_version"), channelData.Version, 0, buildVersion.version); } else { channelData.Version = EditorGUILayout.IntSlider(Localization.GetString("deploy_tab_channel_version"), 0, 0, 0); } } BBGoGUI.EndEnable(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.Space(); BBGoGUI.BeginEnable(canSave); { save = GUILayout.Button(m_contentSave, BBGoGUI.styleCompactButton, m_contentOptions); } BBGoGUI.EndEnable(); discard = GUILayout.Button(m_contentDiscard, BBGoGUI.styleCompactButton, m_contentOptions); } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.LabelField(Localization.GetString("deploy_tab_channel_name"), channelData.Name); EditorGUILayout.LabelField(Localization.GetString("deploy_tab_channel_url"), channelData.URL); EditorGUILayout.LabelField(Localization.GetString("deploy_tab_channel_build"), channelData.Build); EditorGUILayout.LabelField(Localization.GetString("deploy_tab_channel_version"), channelData.Version.ToString()); EditorGUILayout.Space(); BBGoGUI.BeginEnable(!m_hasEdit); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.Space(); edit |= GUILayout.Button(m_contentEdit, BBGoGUI.styleCompactButton, m_contentOptions); delete = GUILayout.Button(m_contentDelete, BBGoGUI.styleCompactButton, m_contentOptions); } EditorGUILayout.EndHorizontal(); } BBGoGUI.EndEnable(); } } } EditorGUILayout.EndVertical(); if (edit) { channelData.IsEdit = true; } if (discard) { LoadDeployData(PlayerPrefs.GetString(FinalPatchConst.KEY_DEPLOY_DATA)); GUI.FocusControl(null); } if (save) { channelData.IsEdit = false; SaveData(); GUI.FocusControl(null); } if (delete) { bool comfirmDelete = EditorUtility.DisplayDialog(Localization.GetString("deploy_tab_delete_channel_comfirm_title"), Localization.GetString("deploy_tab_delete_channel_comfirm_message"), Localization.GetString("deploy_tab_delete_channel_comfirm_yes"), Localization.GetString("deploy_tab_delete_channel_comfirm_no")); if (comfirmDelete) { m_deployData.Channels.Remove(channelData); SaveData(); } } }
public static async Task <PatchReport> Collect() { PatchReport patchReport = new PatchReport(); if (s_data.applyEditorMode) { Debug.Log("Patched in Editor Mode"); patchReport.Result = PatchResult.Success; return(patchReport); } DeployData deployData = await DownloadDeployData(); if (deployData == null) { Debug.LogErrorFormat("Deploy Data Not Found"); patchReport.Result = PatchResult.Failure_NotFoundDeployData; return(patchReport); } ChannelData channelData = deployData.Channels.Find(c => c.Name == s_channel); if (channelData == null) { Debug.LogErrorFormat("Channel Not Found:'{0}'", s_channel); patchReport.Result = PatchResult.Failure_NotFoundChannel; return(patchReport); } if (channelData.Version == 0) { Debug.Log("No patch released"); patchReport.Result = PatchResult.Success; return(patchReport); } string patchDataUrl = $"{channelData.URL}/{channelData.Build}/{channelData.Version}/{FinalPatchConst.PATCH_DATA_FILE_NAME}"; PatchData serverPatchData = await PatchData.DownloadFromUrl(patchDataUrl); if (serverPatchData == null) { Debug.LogErrorFormat("Patch Data Not Found:'{0}'", patchDataUrl); patchReport.Result = PatchResult.Failure_NotFoundServerPatchData; return(patchReport); } PatchData persistentPatchData = PatchData.LoadAtPath(FinalPatchUtility.GetPersistentPatchDataPath()); PatchData packagePatchData = PatchData.LoadAtPath(FinalPatchUtility.GetStreamingAssetsPatchDataPath()); if (packagePatchData?.Hash == serverPatchData.Hash) { // use package bundles Debug.LogFormat("Newest Package Version:'{0}[{1}]'", channelData.Build, channelData.Version); if (persistentPatchData != null) { // reset build persistentPatchData.Build = null; persistentPatchData.SaveToPersistent(); // set client data obsolete ClientData persistentClientData = ClientData.LoadAtPath(FinalPatchUtility.GetPersistentClientDataPath()); persistentClientData.IsObsolete = true; persistentClientData.SaveToPersistent(); } patchReport.Result = PatchResult.Success; return(patchReport); } if (persistentPatchData != null) { if (persistentPatchData.Build == null) { persistentPatchData.Build = channelData.Build; } if (persistentPatchData.Build != channelData.Build) { Debug.LogErrorFormat("Current Build Is Out Of Date:'{0}[{1}]'", persistentPatchData.Build, channelData.Version); patchReport.Result = PatchResult.Failure_OutOfDate; return(patchReport); } } ClientData clientData = ClientData.GetOrCreate(true); if (persistentPatchData?.Hash == serverPatchData.Hash) { Debug.LogFormat("Newest Version:'{0}[{1}]'", channelData.Build, channelData.Version); if (clientData.IsObsolete) { clientData.IsObsolete = false; clientData.SaveToPersistent(); } patchReport.Result = PatchResult.Success; return(patchReport); } patchReport.PatchBundles = new List <BundleData>(); foreach (var serverBundle in serverPatchData.Bundles) { BundleData packageBundle = packagePatchData?.Bundles?.Find((bundle) => bundle.Name == serverBundle.Name); if (packageBundle?.Hash == serverBundle.Hash) { continue; } BundleData persistentBundle = persistentPatchData?.Bundles?.Find((bundle) => bundle.Name == serverBundle.Name); if (persistentBundle?.Hash != serverBundle.Hash) { patchReport.PatchBundles.Add(serverBundle); patchReport.TotalSize += serverBundle.Size; } persistentPatchData?.Bundles?.Remove(persistentBundle); } patchReport.DeleteBundles = new List <BundleData>(); if (persistentPatchData != null) { foreach (var persistentBundle in persistentPatchData.Bundles) { patchReport.DeleteBundles.Add(persistentBundle); } } patchReport.ServerPatchData = serverPatchData; patchReport.ClientData = clientData; patchReport.ChannelData = channelData; patchReport.Result = PatchResult.Collected; return(patchReport); }