private void DrawThemePopup(ThemesDatabase database, ThemeData themeData, string[] themeNames, int themeIndex, ColorName componentColorName, Action updateIds, Action updateLists) { GUILayout.BeginHorizontal(); { DGUI.Line.Draw(false, componentColorName, true, () => { GUILayout.Space(DGUI.Properties.Space(2)); DGUI.Label.Draw(UILabels.TargetTheme, Size.S, componentColorName, DGUI.Properties.SingleLineHeight); GUILayout.Space(DGUI.Properties.Space()); GUILayout.BeginVertical(GUILayout.Height(DGUI.Properties.SingleLineHeight)); { GUILayout.Space(0); GUI.color = DGUI.Colors.PropertyColor(componentColorName); EditorGUI.BeginChangeCheck(); themeIndex = EditorGUILayout.Popup(GUIContent.none, themeIndex, themeNames); GUI.color = InitialGUIColor; } GUILayout.EndVertical(); if (EditorGUI.EndChangeCheck()) { DoozyUtils.UndoRecordObject(TargetNode, UILabels.UpdateValue); themeData = database.Themes[themeIndex]; TargetNode.ThemeId = themeData.Id; updateIds.Invoke(); updateLists.Invoke(); } }); GUILayout.Space(DGUI.Properties.Space()); ThemeTargetEditorUtils.DrawButtonTheme(themeData, componentColorName); } GUILayout.EndHorizontal(); }
private void InitViewThemes() { ThemesDatabase.InitializeThemes(); bool renamedThemeData = false; foreach (ThemeData themeData in ThemesDatabase.Themes) { if (themeData == null) { continue; } if (themeData.name == ThemesDatabase.GetThemeDataFilename(themeData.ThemeName)) { continue; } AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(themeData), ThemesDatabase.GetThemeDataFilename(themeData.ThemeName)); themeData.SetDirty(false); renamedThemeData = true; } if (EditorPrefs.HasKey(DoozyWindowSettings.Instance.EditorPrefsKeyWindowCurrentTheme)) { m_currentThemeId = new Guid(EditorPrefs.GetString(DoozyWindowSettings.Instance.EditorPrefsKeyWindowCurrentTheme)); if (!ThemesDatabase.Contains(m_currentThemeId)) { CurrentThemeId = ThemesDatabase.GetThemeData(ThemesDatabase.GENERAL_THEME_NAME).Id; } } else { ThemeData generalTheme = ThemesDatabase.GetThemeData(ThemesDatabase.GENERAL_THEME_NAME); CurrentThemeId = generalTheme.Id; } if (renamedThemeData) { Save(); } }
private void UpdateLists() { ThemesNames = ThemesDatabase.GetThemesNames(Database); }
private void UpdateLists() { #if dUI_TextMeshPro ThemesNames = ThemesDatabase.GetThemesNames(Database); #endif }
private void UpdateLists() { ThemesNames = ThemesDatabase.GetThemesNames(Database); VariantsNames = ThemesDatabase.GetVariantNames(m_theme); }
public static void DrawThemePopup(ThemesDatabase database, ThemeData themeData, string[] themeNames, int themeIndex, ColorName componentColorName, SerializedObject serializedObject, Object[] targets, ThemeTarget target, Color initialGUIColor, Action updateIds, Action updateLists) { GUILayout.BeginHorizontal(); { DGUI.Line.Draw(false, componentColorName, true, () => { GUILayout.Space(DGUI.Properties.Space(2)); DGUI.Label.Draw(UILabels.SelectedTheme, Size.S, componentColorName, DGUI.Properties.SingleLineHeight); GUILayout.Space(DGUI.Properties.Space()); GUILayout.BeginVertical(GUILayout.Height(DGUI.Properties.SingleLineHeight)); { GUILayout.Space(0); GUI.color = DGUI.Colors.PropertyColor(componentColorName); EditorGUI.BeginChangeCheck(); themeIndex = EditorGUILayout.Popup(GUIContent.none, themeIndex, themeNames); GUI.color = initialGUIColor; } GUILayout.EndVertical(); if (EditorGUI.EndChangeCheck()) { if (serializedObject.isEditingMultipleObjects) { DoozyUtils.UndoRecordObjects(targets, UILabels.UpdateValue); themeData = database.Themes[themeIndex]; foreach (Object o in targets) { var themeTarget = (ThemeTarget)o; if (themeTarget == null) { continue; } themeTarget.ThemeId = themeData.Id; } updateIds.Invoke(); updateLists.Invoke(); foreach (Object o in targets) { var themeTarget = (ThemeTarget)o; if (themeTarget == null) { continue; } if (!themeData.ContainsColorProperty(themeTarget.PropertyId)) { themeTarget.PropertyId = themeData.ColorLabels.Count > 0 ? themeData.ColorLabels[0].Id : Guid.Empty; } themeTarget.UpdateTarget(themeData); } } else { DoozyUtils.UndoRecordObject(target, UILabels.UpdateValue); themeData = database.Themes[themeIndex]; target.ThemeId = themeData.Id; updateIds.Invoke(); updateLists.Invoke(); target.UpdateTarget(themeData); } } }); GUILayout.Space(DGUI.Properties.Space()); ThemeTargetEditorUtils.DrawButtonTheme(themeData, componentColorName); } GUILayout.EndHorizontal(); }
private void UpdateLists() { ThemesNames = ThemesDatabase.GetThemesNames(Database); // PropertyNames = ThemesDatabase.GetPropertyNames(m_theme); // Colors = ThemesDatabase.GetColors(m_theme); }
private void DrawViewThemesHeader(ThemeData themeData) { GUILayout.BeginArea(ThemesHeaderAreaRect); { #region Theme Name GUILayout.Space(DGUI.Properties.Space(8) * CurrentViewExpanded.faded); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (EditMode.faded > 0.01f) { string themeName = themeData.ThemeName; GUI.enabled = !themeData.IsGeneralTheme; { EditorGUI.BeginChangeCheck(); themeName = EditorGUILayout.TextField(themeName); if (EditorGUI.EndChangeCheck()) { if (!ThemesDatabase.Contains(themeName) && !ThemesDatabase.Contains(themeName.Trim())) { themeData.UndoRecord(UILabels.UpdateValue); themeData.ThemeName = themeName; themeData.SetDirty(false); } } } GUI.enabled = true; } else { DGUI.Label.Draw(themeData.ThemeName, ThemeNameStyle, DGUI.Colors.DisabledTextColorName); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); if (EditMode.faded > 0.01f) { GUILayout.Space(3f); } GUILayout.Space(DGUI.Properties.Space(6) * CurrentViewExpanded.faded); #endregion #region Tabs - Color, Image, Sound... GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); var toolbarButtons = new List <DGUI.Toolbar.ToolbarButton> { ThemeColorTab, ThemeSpriteTab, ThemeTextureTab, ThemeFontTab }; #if dUI_TextMeshPro toolbarButtons.Add(ThemeFontAssetTab); #endif m_selectedThemeTab = DGUI.Toolbar.Draw(m_selectedThemeTab, toolbarButtons, DGUI.Properties.SingleLineHeight + DGUI.Properties.Space(8)); } GUILayout.EndHorizontal(); if (EditMode.faded > 0.01f) { GUILayout.Space(-4f); } GUILayout.Space(DGUI.Properties.Space(8) * CurrentViewExpanded.faded); #endregion } GUILayout.EndArea(); }
private void DrawViewThemesLeftMenu() { ThemeData deleteTheme = null; BeginDrawViewLeftMenuArea(); { ColorName viewColorName = CurrentViewColorName; GUI.enabled = !NewDatabase.target; GUILayout.BeginHorizontal(); { GUILayout.Space(DGUI.Properties.Space(2)); GUILayout.BeginVertical(); { GUILayout.Space(DGUI.Properties.Space(8) * CurrentViewExpanded.faded); foreach (ThemeData theme in ThemesDatabase.Themes) { if (theme == null) { continue; } bool isSelected = GUI.enabled && CurrentThemeId == theme.Id; string themeName = theme.ThemeName; int maxLength = 14 + (int)(3 * (1 - EditMode.faded)); if (themeName.Length > maxLength) { themeName = themeName.Substring(0, maxLength - 1) + "..."; } GUILayout.BeginHorizontal(); { if (EditMode.faded > 0.01f) { GUILayout.Space(DGUI.Properties.Space(1 - EditMode.faded)); bool enabled = GUI.enabled; GUI.enabled = !theme.ThemeName.Equals(ThemesDatabase.GENERAL_THEME_NAME); if (DGUI.Button.IconButton.Minus(BarHeight)) { deleteTheme = theme; } GUI.enabled = enabled; GUILayout.Space(DGUI.Properties.Space(2 * (1 - EditMode.faded))); } if (DGUI.Button.Draw(themeName, Size.M, TextAlign.Left, isSelected ? viewColorName : DGUI.Colors.DisabledBackgroundColorName, isSelected ? viewColorName : DGUI.Colors.DisabledTextColorName, GUI.enabled && CurrentThemeId == theme.Id, BarHeight)) { CurrentThemeId = theme.Id; } } GUILayout.EndHorizontal(); GUILayout.Space(DGUI.Properties.Space(2) * CurrentViewExpanded.faded); } GUILayout.Space(DGUI.Properties.Space(2) * CurrentViewExpanded.faded); } GUILayout.EndVertical(); GUILayout.Space(DGUI.Properties.Space(2)); } GUILayout.EndHorizontal(); GUI.enabled = true; } EndDrawViewLeftMenuArea(); if (deleteTheme == null) { return; } if (ThemesDatabase.DeleteThemeData(deleteTheme)) { InitViewThemes(); } }
private void DrawViewThemesTopMenu() { BeginDrawViewTopMenuArea(); { GUILayout.Space((m_viewTopMenuHeight - BarHeight) / 2 - m_viewTopMenuHeight * (1 - CurrentViewExpanded.faded)); GUILayout.BeginHorizontal(); { DrawDefaultViewHorizontalSpacing(); { GUILayout.Space((m_viewTopMenuHeight - BarHeight) / 3); //New Database GUI.enabled = !NewDatabase.target && !EditMode.target; { if (ButtonNew(NewDatabase.target, UILabels.NewTheme)) { NewDatabase.target = !NewDatabase.target; if (NewDatabase.target) { DoozyUtils.SaveAssets(); m_newDatabaseName = string.Empty; } } } GUI.enabled = true; DrawDefaultViewHorizontalSpacing(); if (NewDatabase.target) { GUILayout.Space(DGUI.Properties.Space()); GUILayout.BeginVertical(); { GUILayout.Space(DGUI.Properties.Space(2)); GUILayout.BeginHorizontal(GUILayout.Height(DGUI.Properties.SingleLineHeight + DGUI.Properties.Space(2))); { GUI.color = DGUI.Colors.GetDColor(ColorName.Green).Normal.WithAlpha(GUI.color.a); DGUI.Properties.SetNextControlName("m_newDatabaseName"); m_newDatabaseName = EditorGUILayout.TextField(GUIContent.none, m_newDatabaseName, GUILayout.Width(NewCategoryNameTextFieldWidth)); DGUI.Properties.FocusTextInControl("m_newDatabaseName"); GUI.color = InitialGUIColor; if (DGUI.KeyMapper.DetectKeyUp(Event.current, KeyCode.Return) || DGUI.KeyMapper.DetectKeyUp(Event.current, KeyCode.KeypadEnter) || DGUI.Button.IconButton.Ok()) //OK - New Database { DGUI.Properties.ResetKeyboardFocus(); NewDatabase.target = false; if (ThemesDatabase.CreateTheme(m_newDatabaseName, true, true)) { CurrentThemeId = ThemesDatabase.GetThemeData(m_newDatabaseName).Id; ThemesDatabase.Sort(false); ThemesDatabase.UpdateThemesNames(true); } } if (DGUI.Button.IconButton.Cancel()) //CANCEL - New Database { DGUI.Properties.ResetKeyboardFocus(); NewDatabase.target = false; } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } else { bool enabled = GUI.enabled; GUI.enabled = !EditMode.target; { if (ButtonSortDatabase()) { ThemesDatabase.Sort(true, true); //Sort Database } DrawDefaultViewHorizontalSpacing(); if (ButtonRefreshDatabase()) { ThemesDatabase.RefreshDatabase(false, true); //Refresh Database } DrawDefaultViewHorizontalSpacing(); if (ButtonSaveDatabase()) { ThemesDatabase.SetDirty(true); //Save Database } DrawDefaultViewHorizontalSpacing(); if (ButtonSearchFor(UILabels.SearchForThemes)) { ThemesDatabase.SearchForUnregisteredThemes(true); //Search for themes } GUILayout.FlexibleSpace(); DrawDefaultViewHorizontalSpacing(); if (ButtonAutoSave(ThemesSettings.Instance.AutoSave)) { if (DoozyUtils.DisplayDialog(UILabels.AutoSave, (!ThemesSettings.Instance.AutoSave ? UILabels.ThemesEnableAutoSave : UILabels.ThemesDisableAutoSave), UILabels.Ok, UILabels.Cancel)) { ThemesSettings.Instance.UndoRecord(UILabels.SetValue); ThemesSettings.Instance.AutoSave = !ThemesSettings.Instance.AutoSave; ThemesSettings.Instance.SetDirty(true); DoozyUtils.DisplayDialog(ThemesSettings.Instance.AutoSave ? UILabels.AutoSaveEnabled : UILabels.AutoSaveDisabled, ThemesSettings.Instance.AutoSave ? UILabels.ThemesAutoSaveEnabled : UILabels.ThemesAutoSaveDisabled, UILabels.Ok); } } DrawDefaultViewHorizontalSpacing(); if (ButtonResetDatabase()) { ThemesDatabase.ResetDatabase(); //Reset Database } } GUI.enabled = enabled; DrawDefaultViewHorizontalSpacing(); if (ButtonEditMode(EditMode.target)) { EditMode.target = !EditMode.target; //Edit Mode } } } GUILayout.Space((m_viewTopMenuHeight - BarHeight) / 3); } GUILayout.EndHorizontal(); } EndDrawViewTopMenuArea(); }