protected void OnPatchBuildingContext() { try { #region Create new version EditorGUILayout.LabelField("New version builder", EditorStyles.boldLabel); EditorGUILayout.Space(); _newVersionWindowScrollPosition = EditorGUILayout.BeginScrollView(_newVersionWindowScrollPosition, GUILayout.MaxHeight(450), GUILayout.ExpandHeight(false)); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Last version:", GUILayout.MaxWidth(100)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(_lastVersion, _lastVersionStyle); EditorGUILayout.EndVertical(); /*EditorGUILayout.BeginVertical(); * IsIntegrated = EditorGUILayout.ToggleLeft("Is integrated?", IsIntegrated); * EditorGUILayout.EndVertical();*/ EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("New version", GUILayout.MaxWidth(100)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _majorVersionNumber = EditorGUILayout.IntField(_majorVersionNumber, GUILayout.MaxWidth(25)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _minorVersionNumber = EditorGUILayout.IntField(_minorVersionNumber, GUILayout.MaxWidth(25)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _maintenanceNumber = EditorGUILayout.IntField(_maintenanceNumber, GUILayout.MaxWidth(25)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _buildNumber = EditorGUILayout.IntField(_buildNumber, GUILayout.MaxWidth(25)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); GUI.enabled = _patchBuilderStatus == PatchBuilderStatus.IDLE; if (GUILayout.Button("New version")) { string newVersion = _majorVersionNumber + "." + _minorVersionNumber + "." + _maintenanceNumber + "." + _buildNumber; m_patchManager.SetOnSetMainProgressBarAction(OnSetMainProgressBar); m_patchManager.SetOnSetDetailProgressBarAction(OnSetDetailProgressBar); m_patchManager.SetOnIncreaseMainProgressBarAction(OnIncreaseMainProgressBar); m_patchManager.SetOnIncreaseDetailProgressBarAction(OnIncreaseDetailProgressBar); m_patchManager.SetOnLogAction(OnLog); m_patchManager.SetOnErrorAction(OnError); m_patchManager.SetOnFatalErrorAction(OnFatalError); m_patchManager.SetOnTaskStartedAction(OnTaskStarted); m_patchManager.SetOnTaskCompletedAction(OnTaskCompleted); //m_patchManager.BuildNewVersion(newVersion); IEnumerable <string> files = FileManager.GetFiles(SettingsManager.PATCHER_FILES_PATH, "*", SearchOption.AllDirectories); foreach (string entry in files) { string currentFile = entry.Replace(SettingsManager.PATCHER_FILES_PATH, SettingsManager.CURRENT_BUILD_PATH); if (!FileManager.FileExists(currentFile)) { if (!FileManager.DirectoryExists(Path.GetDirectoryName(currentFile))) { FileManager.CreateDirectory(Path.GetDirectoryName(currentFile)); } } FileManager.FileCopy(entry, currentFile, false); } _patchBuilderThread = new Thread(() => m_patchManager.BuildNewVersion(newVersion)); _patchBuilderThread.Start(); } GUI.enabled = true; EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); /*EditorGUILayout.BeginHorizontal(); * * EditorGUILayout.BeginVertical(); * EditorGUI.ProgressBar(new Rect(3, 45, position.width - 6, 20), _detailProgress / _detailProgressBarMax, _detailLog); * EditorGUI.ProgressBar(new Rect(3, 70, position.width - 6, 20), _mainProgress / _mainProgressBarMax, _mainLog); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.EndVertical(); * * EditorGUILayout.EndHorizontal(); * * EditorGUILayout.Separator();*/ EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(_endLog, _endLogStyle); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); #endregion #region Create patch EditorGUILayout.LabelField("Patch builder", EditorStyles.boldLabel); EditorGUILayout.Space(); _patchesBuilderWindowScrollPosition = EditorGUILayout.BeginScrollView(_patchesBuilderWindowScrollPosition, GUILayout.MaxHeight(450), GUILayout.ExpandHeight(false)); if (_currentVersions != null && _currentVersions.Length > 1) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Compression type:", GUILayout.MaxWidth(150)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _compressionTypeDropdownIndex = EditorGUILayout.Popup(_compressionTypeDropdownIndex, _compressionTypes, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Version from:", GUILayout.MaxWidth(100)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _versionFromDropdownIndex = EditorGUILayout.Popup(_versionFromDropdownIndex, _currentVersions, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Version to:", GUILayout.MaxWidth(100)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _versionToDropdownIndex = EditorGUILayout.Popup(_versionToDropdownIndex, _currentVersions, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUI.enabled = _patchBuilderStatus == PatchBuilderStatus.IDLE; if (GUILayout.Button("Build patch")) { m_patchManager.SetOnSetMainProgressBarAction(OnSetMainProgressBarPatchBuild); m_patchManager.SetOnSetDetailProgressBarAction(OnSetDetailProgressBarPatchBuild); m_patchManager.SetOnIncreaseMainProgressBarAction(OnIncreaseMainProgressBarPatchBuild); m_patchManager.SetOnIncreaseDetailProgressBarAction(OnIncreaseDetailProgressBarPatchBuild); m_patchManager.SetOnLogAction(OnLogPatchBuild); m_patchManager.SetOnErrorAction(OnErrorPatchBuild); m_patchManager.SetOnFatalErrorAction(OnFatalErrorPatchBuild); m_patchManager.SetOnTaskStartedAction(OnTaskStartedPatchBuild); m_patchManager.SetOnTaskCompletedAction(OnTaskCompletedPatchBuild); //m_patchManager.BuildPatch(_currentVersions[_versionFromDropdownIndex], _currentVersions[_versionToDropdownIndex], (CompressionType)Enum.Parse(typeof(CompressionType), _compressionTypes[_compressionTypeDropdownIndex])); _patchBuilderThread = new Thread( () => m_patchManager.BuildPatch(_currentVersions[_versionFromDropdownIndex], _currentVersions[_versionToDropdownIndex], (MHLab.PATCH.Compression.CompressionType)Enum.Parse(typeof(MHLab.PATCH.Compression.CompressionType), _compressionTypes[_compressionTypeDropdownIndex])) ); _patchBuilderThread.Start(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); /*EditorGUILayout.BeginHorizontal(); * * EditorGUILayout.BeginVertical(); * EditorGUI.ProgressBar(new Rect(3, 60, position.width - 6, 20), _detailProgressPatchBuild / _detailProgressBarMaxPatchBuild, _detailLogPatchBuild); * EditorGUI.ProgressBar(new Rect(3, 85, position.width - 6, 20), _mainProgressPatchBuild / _mainProgressBarMaxPatchBuild, _mainLogPatchBuild); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.Space(); * EditorGUILayout.EndVertical(); * * EditorGUILayout.EndHorizontal();*/ EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(_endLogPatchBuild, _endLogStyle); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("There are not enough builds to create patches!"); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); #endregion #region Deploy EditorGUILayout.LabelField("Deploy", EditorStyles.boldLabel); EditorGUILayout.Space(); _deployWindowScrollPosition = EditorGUILayout.BeginScrollView(_deployWindowScrollPosition, GUILayout.MaxHeight(450), GUILayout.ExpandHeight(false)); if (_currentVersions != null && _currentVersions.Length > 0) { if (_scenesInBuildSettings.Count > 0) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Compression type:", GUILayout.MaxWidth(150)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _deployCompressionTypeDropdownIndex = EditorGUILayout.Popup(_deployCompressionTypeDropdownIndex, _compressionTypes, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Version to deploy:", GUILayout.MaxWidth(150)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _versionToDeployDropdownIndex = EditorGUILayout.Popup(_versionToDeployDropdownIndex, _currentVersions, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Platform to deploy:", GUILayout.MaxWidth(150)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _platformToDeployDropdownIndex = EditorGUILayout.Popup(_platformToDeployDropdownIndex, _platformsAvailable, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Launcher scene:", GUILayout.MaxWidth(150)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _launcherSceneToDeployDropdownIndex = EditorGUILayout.Popup(_launcherSceneToDeployDropdownIndex, _scenesInBuildSettings.ToArray(), GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Launcher custom name:", GUILayout.MaxWidth(150)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _launcherCustomName = EditorGUILayout.TextField(_launcherCustomName, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(GUI.skin.box); GUI.enabled = _patchBuilderStatus == PatchBuilderStatus.IDLE; EditorGUILayout.BeginVertical(); if (GUILayout.Button("Update scenes", GUILayout.MaxWidth(150))) { UpdateScenesToBuild(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Deploy", GUILayout.MaxWidth(300))) { Deploy(); } EditorGUILayout.EndVertical(); GUI.enabled = true; EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("There are no available scenes to build your Launcher!"); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("There are no available builds to deploy your game!"); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); #endregion #region Upload to FTP/SFTP EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Upload to FTP", EditorStyles.boldLabel, GUILayout.MaxWidth(280)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Save prefs", GUILayout.MaxWidth(150))) { SaveEditorPrefs(); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Delete prefs", GUILayout.MaxWidth(150))) { DeleteEditorPrefs(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); _uploadWindowScrollPosition = EditorGUILayout.BeginScrollView(_uploadWindowScrollPosition, GUILayout.MaxHeight(450), GUILayout.ExpandHeight(false)); /*EditorGUILayout.BeginHorizontal(); * * EditorGUILayout.BeginVertical(); * EditorGUILayout.LabelField("Use SFTP:", GUILayout.MaxWidth(150)); * EditorGUILayout.EndVertical(); * * EditorGUILayout.BeginVertical(); * _isSFTP = EditorGUILayout.Toggle(_isSFTP, GUILayout.MaxWidth(60)); * EditorGUILayout.EndVertical(); * * EditorGUILayout.EndHorizontal();*/ EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Host:", GUILayout.MaxWidth(150)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _uploadHost = EditorGUILayout.TextField(_uploadHost, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Port:", GUILayout.MaxWidth(150)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _uploadHostPort = EditorGUILayout.IntField(_uploadHostPort, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Username:"******"Password:"******"Remote path:", GUILayout.MaxWidth(80)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _buildsRemotePath = EditorGUILayout.TextField(_buildsRemotePath, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Select build:", GUILayout.MaxWidth(80)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _versionToUploadDropdownIndex = EditorGUILayout.Popup(_versionToUploadDropdownIndex, _currentVersions, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Upload", GUILayout.MaxWidth(150))) { EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Instantiating uploader...", 0); FileUploader uploader = new FileUploader( Protocol.FTP, _uploadHost, _uploadHostPort, _uploadUsername, _uploadPassword ); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Setting up credentials...", 0.1f); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Retrieving files to upload...", 0.2f); string version = Path.Combine(SettingsManager.BUILDS_PATH, _currentVersions[_versionToUploadDropdownIndex]); List <string> files = FileManager.GetFiles(version).ToList(); float singleProgress = 0.7f / files.Count; float progress = 0.2f; foreach (string file in files) { string relativeFile = file.Replace(SettingsManager.BUILDS_PATH, ""); string remoteDirectory = Path.Combine(_buildsRemotePath, relativeFile.Replace(Path.GetFileName(file), "")).Replace("\\", "/"); uploader.UploadFile(file, remoteDirectory); progress += singleProgress; EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Uploaded " + relativeFile + "!", progress); } EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Uploading indexes...", 0.95f); string index = Path.Combine(SettingsManager.BUILDS_PATH, "index"); string patchIndex = Path.Combine(SettingsManager.BUILDS_PATH, "index_" + _currentVersions[_versionToUploadDropdownIndex] + ".bix"); uploader.UploadFile(index, _buildsRemotePath); uploader.UploadFile(patchIndex, _buildsRemotePath); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Done!", 1f); EditorUtility.ClearProgressBar(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); #endregion #region Patcher EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Remote path:", GUILayout.MaxWidth(80)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _patcherRemotePath = EditorGUILayout.TextField(_patcherRemotePath, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Remote path for your launcher", GUILayout.MaxWidth(290), GUILayout.MinWidth(140)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Upload", GUILayout.MaxWidth(150))) { EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Instantiating uploader...", 0); FileUploader uploader = new FileUploader( Protocol.FTP, _uploadHost, _uploadHostPort, _uploadUsername, _uploadPassword ); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Setting up credentials...", 0.1f); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Building launcher...", 0.2f); DeployLauncher(); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Uploading launcher...", 0.95f); uploader.UploadFile(Path.Combine(SettingsManager.DEPLOY_PATH, "patcher.zip"), _patcherRemotePath); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Done!", 1f); EditorUtility.ClearProgressBar(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); #endregion } else { EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("There are no available builds to upload!"); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } if (_currentPatches != null && _currentPatches.Length > 0) { EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Remote path:", GUILayout.MaxWidth(80)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _patchesRemotePath = EditorGUILayout.TextField(_patchesRemotePath, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("Select patch:", GUILayout.MaxWidth(80)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); _patchToUploadDropdownIndex = EditorGUILayout.Popup(_patchToUploadDropdownIndex, _currentPatches, GUILayout.MinWidth(60)); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Upload", GUILayout.MaxWidth(150))) { try { EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Instantiating uploader...", 0); FileUploader uploader = new FileUploader(Protocol.FTP, _uploadHost, _uploadHostPort, _uploadUsername, _uploadPassword ); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Setting up credentials...", 0.1f); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Retrieving files to upload...", 0.2f); string archive = Path.Combine(SettingsManager.FINAL_PATCHES_PATH, _currentPatches[_patchToUploadDropdownIndex]) + ".archive"; string pix = Path.Combine(SettingsManager.FINAL_PATCHES_PATH, _currentPatches[_patchToUploadDropdownIndex]) + ".pix"; string versions = Path.Combine(SettingsManager.FINAL_PATCHES_PATH, "versions.txt"); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Uploading patch index...", 0.3f); uploader.UploadFile(pix, _patchesRemotePath); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Uploading patch archive...", 0.6f); uploader.UploadFile(archive, _patchesRemotePath); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Uploading versions indexer...", 0.9f); uploader.UploadFile(versions, _patchesRemotePath); EditorUtility.DisplayProgressBar("P.A.T.C.H.", "Done!", 1f); EditorUtility.ClearProgressBar(); } catch (Exception e) { Debug.Log(e.Message); EditorUtility.ClearProgressBar(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.BeginHorizontal(GUI.skin.box); EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField("There are no available patches to upload!"); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); #endregion } catch (Exception e) { Debug.Log(e.Message); } }