protected virtual void OnGUI() { this.path = NGEditorGUILayout.OpenFolderField("Path", this.path); if (GUILayout.Button("Generate") == true) { this.Aaa(); } }
private void OnDrawSlave(Rect r, int index, bool isActive, bool isFocused) { if (this.showSlaves == false) { return; } SyncFoldersSettings settings = HQ.Settings.Get <SyncFoldersSettings>(); Project slave = this.profile.slaves[index]; float x = r.x; float width = r.width; EditorGUI.BeginChangeCheck(); r.y += 2F; r.width = NGSyncFoldersWindow.ToggleSlaveWidth; r.height = Constants.SingleLineHeight; string content = index < NGSyncFoldersWindow.CachedSlaveIndexes.Length ? NGSyncFoldersWindow.CachedSlaveIndexes[index] : "#" + (index + 1); bool active = EditorGUI.ToggleLeft(r, content, slave.active); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Toggle slave"); slave.active = active; HQ.InvalidateSettings(); this.cachedSlaves = null; } r.x += r.width; EditorGUI.BeginDisabledGroup(slave.active == false); EditorGUI.BeginChangeCheck(); r.width = width - NGSyncFoldersWindow.ToggleSlaveWidth - NGSyncFoldersWindow.DeleteButtonWidth - 5F; string folderPath = NGEditorGUILayout.OpenFolderField(r, "", slave.folderPath); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Alter slave path"); slave.folderPath = folderPath; HQ.InvalidateSettings(); } EditorGUI.EndDisabledGroup(); r.x += r.width + 5F; r.width = NGSyncFoldersWindow.DeleteButtonWidth; r.y -= 1F; r.height += 1F; if (GUI.Button(r, "X") == true) { Undo.RecordObject(settings, "Delete slave"); this.profile.slaves.RemoveAt(index); HQ.InvalidateSettings(); this.cachedSlaves = null; EditorGUIUtility.ExitGUI(); } r.x = 0F; r.y += r.height + 2F; r.width = x + width; r.height = Constants.SingleLineHeight; this.PreviewPath(r, slave.GetFullPath(this.profile.relativePath)); }
protected virtual void OnGUI() { if (HQ.Settings == null) { GUILayout.Label(string.Format(LC.G("RequiringConfigurationFile"), NGSyncFoldersWindow.Title)); if (GUILayout.Button(LC.G("ShowPreferencesWindow")) == true) { Utility.ShowPreferencesWindowAt(Constants.PreferenceTitle); } return; } FreeLicenseOverlay.First(this, NGAssemblyInfo.Name + " Pro", NGSyncFoldersWindow.FreeAdContent); SyncFoldersSettings settings = HQ.Settings.Get <SyncFoldersSettings>(); // Guarantee there is always one in the list. if (settings.syncProfiles.Count == 0) { settings.syncProfiles.Add(new Profile() { name = "Profile 1" }); } this.currentProfile = Mathf.Clamp(this.currentProfile, 0, settings.syncProfiles.Count - 1); this.profile = settings.syncProfiles[this.currentProfile]; Rect r = default(Rect); if (NGSyncFoldersWindow.cachePath == null) { NGSyncFoldersWindow.cachePath = Path.Combine(Application.persistentDataPath, Path.Combine(Constants.InternalPackageTitle, string.Format(NGSyncFoldersWindow.CachedHashedFile, this.currentProfile))); } this.slavesList.list = this.profile.slaves; this.filtersList.list = this.profile.filters; r.width = this.position.width; r.height = Constants.SingleLineHeight; GUI.Box(r, string.Empty, GeneralStyles.Toolbar); r.width = 20F; if (GUI.Button(r, "", GeneralStyles.ToolbarDropDown) == true) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < settings.syncProfiles.Count; i++) { menu.AddItem(new GUIContent((i + 1) + " - " + settings.syncProfiles[i].name), i == this.currentProfile, this.SwitchProfile, i); } menu.AddSeparator(""); menu.AddItem(new GUIContent(LC.G("Add")), false, this.AddProfile); menu.DropDown(r); GUI.FocusControl(null); } r.x += r.width + 4F; r.width = this.position.width - 20F - 100F - 4F; EditorGUI.BeginChangeCheck(); r.y += 2F; string name = EditorGUI.TextField(r, this.profile.name, GeneralStyles.ToolbarTextField); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Rename profile"); this.profile.name = name; HQ.InvalidateSettings(); } r.y -= 2F; r.x += r.width; r.width = 100F; EditorGUI.BeginDisabledGroup(settings.syncProfiles.Count <= 1); { if (GUI.Button(r, LC.G("Erase"), GeneralStyles.ToolbarButton) == true && ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 || EditorUtility.DisplayDialog(LC.G("NGSyncFolders_EraseSave"), string.Format(LC.G("NGSyncFolders_EraseSaveQuestion"), this.profile.name), LC.G("Yes"), LC.G("No")) == true)) { this.EraseProfile(); this.Focus(); return; } } EditorGUI.EndDisabledGroup(); r.x = 0F; r.y += r.height + 5F; r.width = this.position.width; using (LabelWidthRestorer.Get(85F)) { EditorGUI.BeginChangeCheck(); string folderPath = NGEditorGUILayout.OpenFolderField(r, "Master Folder", this.profile.master.folderPath); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Alter master path"); this.profile.master.folderPath = folderPath; HQ.InvalidateSettings(); } r.y += r.height + NGSyncFoldersWindow.Spacing; EditorGUI.BeginChangeCheck(); string relativePath = NGEditorGUILayout.OpenFolderField(r, "Relative Path", this.profile.relativePath, this.profile.master.folderPath, NGEditorGUILayout.FieldButtons.Open); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Alter relative path"); this.profile.relativePath = relativePath; HQ.InvalidateSettings(); } r.y += r.height + NGSyncFoldersWindow.Spacing; this.PreviewPath(r, this.profile.master.GetFullPath(this.profile.relativePath)); r.y += r.height + NGSyncFoldersWindow.Spacing; r.height = this.slavesList.GetHeight(); this.slavesList.DoList(r); if (this.showSlaves == false) { r.y -= 16F; } r.y += r.height + NGSyncFoldersWindow.Spacing; } r.height = this.filtersList.GetHeight(); this.filtersList.DoList(r); if (this.showFilters == false) { if (Event.current.type == EventType.Repaint) { Rect r2 = r; r2.y += r2.height - 14F; r2.height = 16F; r2.width = 16F; EditorGUI.DrawRect(r2, EditorGUIUtility.isProSkin == true ? new Color(55F / 255F, 55F / 255F, 55F / 255F, 1F) : new Color(162F / 255F, 162F / 255F, 162F / 255F, 1F)); } r.y -= 16F; } r.y += r.height + NGSyncFoldersWindow.Spacing; if (string.IsNullOrEmpty(this.cacheFileSize) == true) { this.UpdateCacheFileSize(); } EditorGUI.BeginChangeCheck(); r.width -= 200F; r.height = 20F; bool useCache = EditorGUI.Toggle(r, this.cacheFileSize, this.profile.useCache); if (EditorGUI.EndChangeCheck() == true) { Undo.RecordObject(settings, "Toggle use cache"); this.profile.useCache = useCache; HQ.InvalidateSettings(); } if (this.cacheFileSize != "Use Cache") { r.x += r.width; r.width = 100F; if (GUI.Button(r, "Open", "ButtonLeft") == true) { EditorUtility.RevealInFinder(NGSyncFoldersWindow.cachePath); } r.x += r.width; if (GUI.Button(r, "Clear", "ButtonRight") == true) { System.IO.File.Delete(NGSyncFoldersWindow.cachePath); this.UpdateCacheFileSize(); } } r.y += r.height + NGSyncFoldersWindow.Spacing; bool hasActiveSlaves = false; for (int i = 0; i < this.profile.slaves.Count; i++) { if (this.profile.slaves[i].active == true) { hasActiveSlaves = true; break; } } EditorGUI.BeginDisabledGroup(hasActiveSlaves == false); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { r.x = 10F; r.width = 150F; r.height = 32F; if (GUI.Button(r, this.mode == ButtonMode.Scan ? "Scan" : "Scan & Watch", "Button" /*"ButtonLeft"*/) == true) { this.Scan(); } //if (GUILayout.Button("☰", "ButtonRight", GUILayoutOptionPool.Height(32F), GUILayoutOptionPool.ExpandWidthFalse) == true) //{ // GenericMenu menu = new GenericMenu(); // menu.AddItem(new GUIContent("Scan"), this.mode == ButtonMode.Scan, () => this.mode = ButtonMode.Scan); // menu.AddItem(new GUIContent("Scan and Watch"), this.mode == ButtonMode.ScanAndWatch, () => this.mode = ButtonMode.ScanAndWatch); // menu.ShowAsContext(); //} } } EditorGUI.EndDisabledGroup(); if (this.profile.master.IsScanned == true) { using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton)) { r.x = this.position.width - r.width - 10F; if (GUI.Button(r, "Sync All", "Button") == true) { this.SyncAll(); } r.y += r.height + NGSyncFoldersWindow.Spacing; } } //if (this.mode == ButtonMode.ScanAndWatch) // EditorGUILayout.HelpBox("Scan and Watch may induce huge freeze after a compilation when watching a lot of files. This mode is not recommended for programmers.", MessageType.Warning); if (this.profile.master.IsScanned == true) { r.x = 0F; r.width = this.position.width; Rect bodyRect = r; bodyRect.height = this.position.height - r.y; Rect viewRect = new Rect { height = this.profile.master.GetHeight() }; for (int i = 0; i < this.profile.slaves.Count; i++) { if (this.profile.slaves[i].active == true) { viewRect.height += this.profile.slaves[i].GetHeight(this.profile.master); } } this.scrollPositionScan = GUI.BeginScrollView(bodyRect, this.scrollPositionScan, viewRect); { r.y = 0F; r.height = this.profile.master.GetHeight(); if (viewRect.height > r.height) { r.width -= 15F; } if (r.yMax > this.scrollPositionScan.y) { this.profile.master.OnGUI(r, 0, this.scrollPositionScan.y, this.scrollPositionScan.y + bodyRect.height); } r.y += r.height; for (int i = 0; i < this.profile.slaves.Count; i++) { if (this.profile.slaves[i].active == false) { continue; } r.height = this.profile.slaves[i].GetHeight(this.profile.master); if (r.yMax > this.scrollPositionScan.y) { this.profile.slaves[i].OnGUI(r, i + 1, this.scrollPositionScan.y, this.scrollPositionScan.y + bodyRect.height, this.profile.master); } r.y += r.height; if (r.y - this.scrollPositionScan.y > bodyRect.height) { break; } } } GUI.EndScrollView(); } FreeLicenseOverlay.Last(NGAssemblyInfo.Name + " Pro"); }