void DrawPageAnimatorPresetsPunchData(DUIData.PunchDatabase database, string relativePath, float width) { if (database == null || database.categories == null || database.categories.Count == 0) { //ToDo - draw info message telling the dev that the database is empty return; } for (int categoryIndex = 0; categoryIndex < database.categories.Count; categoryIndex++) { if (QUI.GhostBar(database.categories[categoryIndex].categoryName, QColors.Color.Blue, database.categories[categoryIndex].isExpanded, width, ANIMATOR_PRESETS_CATEGORY_BAR_HEIGHT)) { database.categories[categoryIndex].isExpanded.target = !database.categories[categoryIndex].isExpanded.target; database.categories[categoryIndex].ExpandOrCollapseAllAnimData(false); } QUI.BeginHorizontal(width); { QUI.Space(SPACE_8 * database.categories[categoryIndex].isExpanded.faded); if (QUI.BeginFadeGroup(database.categories[categoryIndex].isExpanded.faded)) { QUI.BeginVertical(width - SPACE_8); { QUI.Space(SPACE_2); for (int presetIndex = 0; presetIndex < database.categories[categoryIndex].presets.Count; presetIndex++) { QUI.BeginHorizontal(width - SPACE_8); { if (DUIUtils.PresetGhostBar(database.categories[categoryIndex].presets[presetIndex].presetName, QColors.Color.Blue, database.categories[categoryIndex].presets[presetIndex].isExpanded, width - SPACE_8 - SPACE_2 - SPACE_16, ANIMATOR_PRESETS_PRESET_BAR_HEIGHT)) { database.categories[categoryIndex].presets[presetIndex].isExpanded.target = !database.categories[categoryIndex].presets[presetIndex].isExpanded.target; } QUI.Space(SPACE_2); if (QUI.ButtonCancel()) { if (QUI.DisplayDialog("Delete the '" + database.categories[categoryIndex].presets[presetIndex].presetName + "' preset?", "Are you sure you want to delete this preset?" + "\n\n" + "Operation cannot be undone!", "Yes", "No")) { database.categories[categoryIndex].DeletePunchData(database.categories[categoryIndex].presets[presetIndex].presetName, relativePath + database.categories[categoryIndex].categoryName + "/"); if (database.categories[categoryIndex].presets.Count == 0) //category is empty -> remove it { database.RemoveCategory(database.categories[categoryIndex].categoryName, relativePath, true); } QUI.ExitGUI(); } } } QUI.EndHorizontal(); QUI.BeginHorizontal(width - SPACE_8); { QUI.Space(SPACE_8 * database.categories[categoryIndex].presets[presetIndex].isExpanded.faded); if (QUI.BeginFadeGroup(database.categories[categoryIndex].presets[presetIndex].isExpanded.faded)) { QUI.BeginVertical(width - SPACE_16); { DUIUtils.DrawPunch(database.categories[categoryIndex].presets[presetIndex].data, database.categories[categoryIndex].presets[presetIndex], width - SPACE_16); QUI.Space(SPACE_8 * database.categories[categoryIndex].presets[presetIndex].isExpanded.faded); //space added if preset is opened } QUI.EndVertical(); } QUI.EndFadeGroup(); } QUI.EndHorizontal(); QUI.Space(SPACE_4); //space between presets } QUI.Space(SPACE_4 * database.categories[categoryIndex].isExpanded.faded); //space added if category is opened } QUI.EndVertical(); } QUI.EndFadeGroup(); } QUI.EndHorizontal(); QUI.Space(SPACE_4); //space between categories } }
void DrawSoundsDatabase(float width) { DrawNewUISoundAndSearch(width); QUI.Space(SPACE_8); DrawUISoundsFilterButtons(width); QUI.Space(SPACE_8); for (int i = 0; i < DUIData.Instance.DatabaseUISounds.sounds.Count; i++) { if (DUIData.Instance.DatabaseUISounds.sounds[i] == null) { continue; } if (WindowSettings.selectedUISoundsFilter == SoundType.UIButtons && DUIData.Instance.DatabaseUISounds.sounds[i].soundType == SoundType.UIElements) { continue; } if (WindowSettings.selectedUISoundsFilter == SoundType.UIElements && DUIData.Instance.DatabaseUISounds.sounds[i].soundType == SoundType.UIButtons) { continue; } QUI.BeginHorizontal(width, 20); { if (SearchPatternAnimBool.target)//a search pattern has been entered in the search box { try { if (!Regex.IsMatch(DUIData.Instance.DatabaseUISounds.sounds[i].soundName, SearchPattern, RegexOptions.IgnoreCase)) { QUI.EndHorizontal(); continue; //this does not match the search pattern --> we do not show this name it } } catch (Exception) { } } QUI.Space(-1); QUI.Box(QStyles.GetBackgroundStyle(Style.BackgroundType.Low, SearchPatternAnimBool.target ? QColors.Color.Orange : QColors.Color.Gray), width + 2, 20); QUI.Space(-2); QUI.Space(-width); SoundType soundType = DUIData.Instance.DatabaseUISounds.sounds[i].soundType; QUI.BeginChangeCheck(); soundType = (SoundType)EditorGUILayout.EnumPopup(soundType, GUILayout.Width(PAGE_UISOUNDS_SOUNDTYPE_BUTTON_WIDTH)); if (QUI.EndChangeCheck()) { Undo.RecordObject(DUIData.Instance, "UpdateSoundType"); DUIData.Instance.DatabaseUISounds.sounds[i].soundType = soundType; QUI.SetDirty(DUIData.Instance.DatabaseUISounds.sounds[i]); QUI.SetDirty(DUIData.Instance); AssetDatabase.SaveAssets(); } QLabel.text = DUIData.Instance.DatabaseUISounds.sounds[i].soundName; #if dUI_MasterAudio QLabel.text = "Controlled by MasterAudio"; #endif QUI.Label(QLabel.text, Style.Text.Normal, (width - PAGE_UISOUNDS_SOUNDTYPE_BUTTON_WIDTH - PAGE_UISOUNDS_HORIZONTAL_SPACE * 3 - PAGE_UISOUNDS_BUTTONS_WIDTH * (1 - SearchPatternAnimBool.faded) - 16) * PAGE_UISOUNDS_SOUNDNAME_FIELD_WIDTH_PERCENT); AudioClip audioClip = DUIData.Instance.DatabaseUISounds.sounds[i].audioClip; QUI.BeginChangeCheck(); audioClip = (AudioClip)EditorGUILayout.ObjectField("", audioClip, typeof(AudioClip), false, GUILayout.Width((width - PAGE_UISOUNDS_SOUNDTYPE_BUTTON_WIDTH - PAGE_UISOUNDS_HORIZONTAL_SPACE * 3 - PAGE_UISOUNDS_BUTTONS_WIDTH * (1 - SearchPatternAnimBool.faded) - 16) * PAGE_UISOUNDS_AUDIOCLIP_FIELD_WIDTH_PERCENT)); if (QUI.EndChangeCheck()) { Undo.RecordObject(DUIData.Instance, "UpdateAudioClipReferene"); DUIData.Instance.DatabaseUISounds.sounds[i].audioClip = audioClip; QUI.SetDirty(DUIData.Instance.DatabaseUISounds.sounds[i]); QUI.SetDirty(DUIData.Instance); AssetDatabase.SaveAssets(); } if (SearchPatternAnimBool.faded < 0.6f) { QUI.Space(PAGE_UISOUNDS_HORIZONTAL_SPACE); if (QUI.ButtonPlay()) { DUIUtils.PreviewSound(DUIData.Instance.DatabaseUISounds.sounds[i].soundName); } } if (SearchPatternAnimBool.faded < 0.4f) { QUI.Space(PAGE_UISOUNDS_HORIZONTAL_SPACE); if (QUI.ButtonStop()) { DUIUtils.StopSoundPreview(DUIData.Instance.DatabaseUISounds.sounds[i].soundName); } QUI.Space(PAGE_UISOUNDS_HORIZONTAL_SPACE); } if (SearchPatternAnimBool.faded < 0.2f) { if (QUI.ButtonCancel()) { if (EditorUtility.DisplayDialog("Delete the '" + DUIData.Instance.DatabaseUISounds.sounds[i].soundName + "' UISound?", "Are you sure you want to proceed?" + "\n\n" + "Operation cannot be undone!", "Yes", "Cancel")) { DUIData.Instance.DatabaseUISounds.DeleteUISound(DUIData.Instance.DatabaseUISounds.sounds[i].soundName); QUI.SetDirty(DUIData.Instance); AssetDatabase.SaveAssets(); QUI.EndHorizontal(); continue; } } } QUI.FlexibleSpace(); } QUI.EndHorizontal(); QUI.Space(SPACE_2); } }
void DrawUISounds() { QUI.DrawTexture(DUIResources.headerUISoundsDatabase.texture, 552, 64); float sectionWidth = PAGE_WIDTH - SIDE_BAR_SHADOW_WIDTH * 2; QUI.BeginHorizontal(sectionWidth); { #region New UISound if (!NewUISoundAnimBool.value) { if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonNewUISound), 100 * (1 - SearchPatternAnimBool.faded), 20)) { NewUISoundName = ""; NewUISoundAnimBool.target = true; SearchPatternAnimBool.target = false; } } else { SearchPatternAnimBool.target = false; QUI.DrawTexture(DUIResources.pageButtonNewUISound.active, 100, 20); QUI.Space(80); SaveColors(); QUI.SetGUIBackgroundColor(DUIColors.GreenLight.Color); NewUISoundName = EditorGUILayout.TextField(NewUISoundName, GUILayout.Width((sectionWidth - 149) * NewUISoundAnimBool.faded)); RestoreColors(); if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonOk), 20, 20)) { if (string.IsNullOrEmpty(NewUISoundName)) { EditorUtility.DisplayDialog("Info", "Cannot create an unnamed ui sound. Try again.", "Ok"); } else if (DUI.UISoundNameExists(NewUISoundName)) { EditorUtility.DisplayDialog("Info", "An ui sound named '" + NewUISoundName + "' already exists in the database. Try again.", "Ok"); } else { DUI.CreateUISound(NewUISoundName, soundTypeFilter); NewUISoundAnimBool.target = false; RefreshUISoundsDatabase(true); } } QUI.Space(1); if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonCancel), 20, 20)) { NewUISoundName = ""; NewUISoundAnimBool.target = false; } } #endregion QUI.Space(342 * (1 - NewUISoundAnimBool.faded) * (1 - SearchPatternAnimBool.faded)); #region Search if (!SearchPatternAnimBool.value) { QUI.FlexibleSpace(); if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonSearch), 100 * (1 - NewUISoundAnimBool.faded), 20)) { SearchPattern = string.Empty; SearchPatternAnimBool.target = true; NewUISoundAnimBool.target = false; } } else { NewUISoundAnimBool.target = false; if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonClearSearch), 100 * SearchPatternAnimBool.faded, 20)) { SearchPattern = string.Empty; SearchPatternAnimBool.target = false; } GUILayout.Space(1); SaveColors(); QUI.SetGUIBackgroundColor(DUIColors.BlueLight.Color); SearchPattern = EditorGUILayout.TextField(SearchPattern, GUILayout.Width((sectionWidth - 210) * SearchPatternAnimBool.faded)); RestoreColors(); QUI.DrawTexture(DUIResources.pageButtonSearch.active, 100, 20); } #endregion } QUI.EndHorizontal(); QUI.Space(16); #region Filter QUI.BeginHorizontal(sectionWidth); { QUI.Space(8); QUI.FlexibleSpace(); QUI.DrawTexture(DUIResources.pageButtonFilterHeader.texture, 302, 10); QUI.Space(302); QUI.FlexibleSpace(); } QUI.EndHorizontal(); QUI.Space(10); QUI.BeginHorizontal(sectionWidth); { QUI.Space(-2); QUI.FlexibleSpace(); if (soundTypeFilter == SoundType.All) { QUI.DrawTexture(DUIResources.pageButtonFilterAll.active, 100, 20); QUI.Space(80); } else { if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonFilterAll), 100, 20)) { soundTypeFilter = SoundType.All; } } QUI.Space(1); if (soundTypeFilter == SoundType.UIButtons) { QUI.DrawTexture(DUIResources.pageButtonFilterUIButton.active, 100, 20); QUI.Space(80); } else { if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonFilterUIButton), 100, 20)) { soundTypeFilter = SoundType.UIButtons; } } QUI.Space(1); if (soundTypeFilter == SoundType.UIElements) { QUI.DrawTexture(DUIResources.pageButtonFilterUIElement.active, 100, 20); QUI.Space(80); } else { if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonFilterUIElement), 100, 20)) { soundTypeFilter = SoundType.UIElements; } } QUI.FlexibleSpace(); } QUI.EndHorizontal(); #endregion QUI.Space(16); if (DUI.UISoundsDatabase.Count == 0) { QUI.DrawTexture(DUIResources.pageImageEmptyDatabase.texture, 552, 256); return; } QUI.DrawTexture(DUIResources.pageUISoundsTableTop.texture, 552, 12); for (int i = 0; i < DUI.UISoundsDatabase.Count; i++) { if (DUI.UISoundsDatabase[i] == null) { continue; } if (soundTypeFilter == SoundType.UIButtons && DUI.UISoundsDatabase[i].soundType == SoundType.UIElements) { continue; } if (soundTypeFilter == SoundType.UIElements && DUI.UISoundsDatabase[i].soundType == SoundType.UIButtons) { continue; } QUI.BeginHorizontal(sectionWidth); { if (SearchPatternAnimBool.target)//a search pattern has been entered in the search box { try { if (!Regex.IsMatch(DUI.UISoundsDatabase[i].soundName, SearchPattern, RegexOptions.IgnoreCase)) { QUI.EndHorizontal(); continue; //this does not match the search pattern --> we do not show this name it } } catch (Exception) { } } DUI.UISoundsDatabase[i].soundType = (SoundType)EditorGUILayout.EnumPopup(DUI.UISoundsDatabase[i].soundType, GUILayout.Width(80)); if (SearchPatternAnimBool.target) { QUI.Label(DUI.UISoundsDatabase[i].soundName, DUIStyles.GetStyle(DUIStyles.BlackTextStyle.BlackLabelNormalItalic), 174); } else { QUI.Label(DUI.UISoundsDatabase[i].soundName, DUIStyles.GetStyle(DUIStyles.BlackTextStyle.BlackLabelNormal), 174); } #if dUI_MasterAudio QUI.Label("Controlled by MasterAudio", DUIStyles.GetStyle(DUIStyles.BlackTextStyle.BlackLabelSmallItalic), 140); #else QUI.BeginChangeCheck(); { DUI.UISoundsDatabase[i].audioClip = (AudioClip)EditorGUILayout.ObjectField("", DUI.UISoundsDatabase[i].audioClip, typeof(AudioClip), false, GUILayout.Width(140)); } if (QUI.EndChangeCheck()) { Undo.RecordObject(DUI.DUISettings, "Updated UISound"); EditorUtility.SetDirty(DUI.UISoundsDatabase[i]); AssetDatabase.SaveAssets(); } #endif QUI.Space(50 * SearchPatternAnimBool.faded); if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonPlay), 20, 20)) { DUIUtils.PreviewSound(DUI.UISoundsDatabase[i].soundName); } QUI.Space(1); if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonStop), 20, 20)) { DUIUtils.StopSoundPreview(DUI.UISoundsDatabase[i].soundName); } QUI.Space(1); if (QUI.Button(DUIStyles.GetStyle(DUIStyles.ControlPanel.PageButtonDelete), 100 * (1 - SearchPatternAnimBool.faded), 20)) { if (EditorUtility.DisplayDialog("Delete the '" + DUI.UISoundsDatabase[i].soundName + "' ui sound?", "Are you sure you want to proceed?\nOperation cannot be undone!", "Yes", "Cancel")) { DUI.DeleteUISound(DUI.UISoundsDatabase[i].soundName); RefreshUISoundsDatabase(true); QUI.EndHorizontal(); continue; } } } QUI.EndHorizontal(); QUI.Space(2); } QUI.Space(-2); QUI.DrawTexture(DUIResources.pageUISoundsTableBottom.texture, 552, 12); }