示例#1
0
 void DrawNewsArticle(List <NewsArticleData> articles, int index, Object targetObject, bool showDeleteButton, float width)
 {
     QLabel.text  = articles[index].title;
     QLabel.style = Style.Text.Subtitle;
     QUI.Box(QStyles.GetBackgroundStyle(Style.BackgroundType.Low, QColors.Color.Gray), width, 20);
     QUI.Space(-20);
     QUI.BeginHorizontal(width);
     {
         QUI.Space(6);
         QUI.Label(QLabel);
         QUI.FlexibleSpace();
         if (showDeleteButton)
         {
             if (QUI.ButtonMinus())
             {
                 if (QUI.DisplayDialog("Delete Article", "Delete the '" + QLabel.text + "' article?", "Ok", "Cancel"))
                 {
                     articles.RemoveAt(index);
                     QUI.SetDirty(targetObject);
                     AssetDatabase.SaveAssets();
                     QUI.ExitGUI();
                 }
             }
         }
         QUI.Space(SPACE_4);
     }
     QUI.EndHorizontal();
     QLabel.text  = articles[index].content;
     QLabel.style = Style.Text.Normal;
     QUI.Space(-8 + (showDeleteButton ? 2 : 0));
     EditorGUILayout.LabelField(articles[index].content, QStyles.GetInfoMessageMessageStyle(Style.InfoMessage.Help), GUILayout.Width(width));
     QUI.Space(SPACE_4);
 }
示例#2
0
 /// <summary>
 /// Displays a modal dialog.
 /// </summary>
 /// <param name="title"> The title of the message box.</param>
 /// <param name="message">The text of the message.</param>
 /// <param name="ok">Label displayed on the OK dialog button.</param>
 protected bool DisplayDialog(string title, string message, string ok, bool enableEditorLock = true)
 {
     if (enableEditorLock)
     {
         LockEditor();
     }
     return(QUI.DisplayDialog(title, message, ok));
 }
        void ValidateCanvasName()
        {
            if (customTargetCanvasName.boolValue) //check if customCanvasName is true
            {
                return;                           //custom customCanvasName is true --> it is no longer needed to continue any further
            }

            if (!DUIData.Instance.DatabaseUICanvases.Contains(targetCanvasName.stringValue)) //canvas name does not exist in canvas datatabase -> ask if it should be added
            {
                if (!string.IsNullOrEmpty(targetCanvasName.stringValue.Trim()) &&
                    QUI.DisplayDialog("Action Required",
                                      "The '" + targetCanvasName.stringValue + "' canvas name does not exist in the canvas names database." +
                                      "\n\n" +
                                      "Do you want to add it now?",
                                      "Yes",
                                      "No"))
                {
                    DUIData.Instance.AddUICanvas(targetCanvasName.stringValue); //add a new canvas name to the generated database
                    DUIData.Instance.ScanForUICanvases(true);                   //add a new canvas name to the static database
                    customTargetCanvasName.boolValue = false;                   //set customCanvasName to false, as this no longer is a custom canvas name
                }
                else if (QUI.DisplayDialog("Action Required",
                                           "Reset canvas name to the default value of '" + UICanvas.MASTER_CANVAS_NAME + "'?",
                                           "Yes",
                                           "No"))
                {
                    targetCanvasName.stringValue     = UICanvas.MASTER_CANVAS_NAME;
                    customTargetCanvasName.boolValue = false;
                }
                else
                {
                    QUI.DisplayDialog("Information",
                                      "The canvas name was left unchanged and this UICanvas was set to use a custom canvas name." +
                                      "\n\n" +
                                      "Having a custom canvas name means that the name is not in the Canvas Database.",
                                      "Ok");

                    customTargetCanvasName.boolValue = true; //set customCanvasName as true, as the dev did not want to add the custom canvas name to the database
                    return;
                }
            }
            canvasNameIndex = DUIData.Instance.DatabaseUICanvases.IndexOf(targetCanvasName.stringValue); //find the canvas name in the database and return its index
        }
        void DrawButtonName(float width)
        {
            QUI.BeginHorizontal(width);
            {
                if (EditorApplication.isPlayingOrWillChangePlaymode)
                {
                    QLabel.text  = buttonName.stringValue;
                    QLabel.style = Style.Text.Help;
                    QUI.Label(QLabel);
                }
                else
                {
                    if (buttonCategory.stringValue.Equals(DUI.CUSTOM_NAME))
                    {
                        QUI.PropertyField(buttonName, width - 5);
                    }
                    else
                    {
                        if (!DatabaseUIButtons.ContainsCategoryName(buttonCategory.stringValue)) //the category does not exist -> reset category and name
                        {
                            QUI.DisplayDialog("Info",
                                              "Button category has been reset to the default '" + DUI.UNCATEGORIZED_CATEGORY_NAME + "' value." +
                                              "\n\n" +
                                              "Button name has been reset to the default '" + DUI.DEFAULT_BUTTON_NAME + "' value.",
                                              "Ok");                                                                                          //inform the dev that becuase he did not add the name to the database, it has been reset to its default value
                            buttonCategory.stringValue = DUI.UNCATEGORIZED_CATEGORY_NAME;                                                     //reset the category
                            buttonCategoryIndex        = DatabaseUIButtons.CategoryNameIndex(buttonCategory.stringValue);                     //set the index
                            buttonName.stringValue     = DUI.DEFAULT_BUTTON_NAME;                                                             //reset the name
                            buttonNameIndex            = DatabaseUIButtons.ItemNameIndex(buttonCategory.stringValue, buttonName.stringValue); //set the index
                        }
                        else if (!DatabaseUIButtons.Contains(buttonCategory.stringValue, buttonName.stringValue))                             //category does not contain the set name -> ask de dev is it should be added
                        {
                            if (QUI.DisplayDialog("Action Required",
                                                  "The name '" + buttonName.stringValue + "' was not found in the '" + buttonCategory.stringValue + "' category." +
                                                  "\n\n" +
                                                  "Do you want to add it to the database?",
                                                  "Yes",
                                                  "No"))                                                                                       //ask the dev if he wants to add this name to the database
                            {
                                DatabaseUIButtons.GetCategory(buttonCategory.stringValue).AddItemName(buttonName.stringValue, true);           //add the item name to the database and save
                                buttonNameIndex = DatabaseUIButtons.ItemNameIndex(buttonCategory.stringValue, buttonName.stringValue);         //set the index
                            }
                            else if (!DatabaseUIButtons.GetCategory(buttonCategory.stringValue).IsEmpty())                                     //select the first item in the category because it's not empty
                            {
                                buttonNameIndex        = 0;                                                                                    //set the index
                                buttonName.stringValue = DatabaseUIButtons.GetCategory(buttonCategory.stringValue).itemNames[buttonNameIndex]; //get the name
                            }
                            else //reset category and name
                            {
                                QUI.DisplayDialog("Info",
                                                  "Button category has been reset to the default '" + DUI.UNCATEGORIZED_CATEGORY_NAME + "' value." +
                                                  "\n\n" +
                                                  "Button name has been reset to the default '" + DUI.DEFAULT_BUTTON_NAME + "' value.",
                                                  "Ok");                                                                                          //inform the dev that becuase he did not add the name to the database, it has been reset to its default value
                                buttonCategory.stringValue = DUI.UNCATEGORIZED_CATEGORY_NAME;                                                     //reset the category
                                buttonCategoryIndex        = DatabaseUIButtons.CategoryNameIndex(buttonCategory.stringValue);                     //set the index
                                buttonName.stringValue     = DUI.DEFAULT_BUTTON_NAME;                                                             //reset the name
                                buttonNameIndex            = DatabaseUIButtons.ItemNameIndex(buttonCategory.stringValue, buttonName.stringValue); //set the index
                            }
                        }
                        else //category contains the set name -> get its index
                        {
                            buttonNameIndex = DatabaseUIButtons.ItemNameIndex(buttonCategory.stringValue, buttonName.stringValue); //set the index
                        }
                        QUI.BeginChangeCheck();
                        buttonNameIndex = EditorGUILayout.Popup(buttonNameIndex, DatabaseUIButtons.GetCategory(buttonCategory.stringValue).itemNames.ToArray(), GUILayout.Width(width - 5));
                        if (QUI.EndChangeCheck())
                        {
                            buttonName.stringValue = DatabaseUIButtons.GetCategory(buttonCategory.stringValue).itemNames[buttonNameIndex];
                        }
                    }
                }

                QUI.FlexibleSpace();
            }
            QUI.EndHorizontal();
            QUI.Space(SPACE_4);
        }
        void ValidateButtonCategoryAndButtonName()
        {
            if (dispatchAll.boolValue)
            {
                buttonCategory.stringValue = DUI.UNCATEGORIZED_CATEGORY_NAME;
                buttonName.stringValue     = DUI.DISPATCH_ALL;
                return;
            }

            //CHECK FOR CUSTOM NAME
            if (uiTrigger.buttonCategory.Equals(DUI.CUSTOM_NAME))                           //category is set to CUSTOM NAME -> get the index for the category name and set the name index to -1
            {
                buttonCategoryIndex = DatabaseUIButtons.CategoryNameIndex(DUI.CUSTOM_NAME); //set the index
                buttonNameIndex     = -1;                                                   //set the index
                return;                                                                     //stop here as there is a CUSTOM NAME set
            }

            //SANITY CHECK FOR EMPTY CATEGORY NAME
            if (uiTrigger.buttonCategory.IsNullOrEmpty())                                                               //category name is empty (sanity check) -> reset both category and name
            {
                uiTrigger.buttonCategory = DUI.UNCATEGORIZED_CATEGORY_NAME;                                             //reset the value
                buttonCategoryIndex      = DatabaseUIButtons.CategoryNameIndex(uiTrigger.buttonCategory);               //set the index

                uiTrigger.buttonName = DUI.DEFAULT_BUTTON_NAME;                                                         //reset the value
                buttonNameIndex      = DatabaseUIButtons.ItemNameIndex(uiTrigger.buttonCategory, uiTrigger.buttonName); //set the index
                return;
            }

            //CHECK THAT CATEGORY EXISTS IN THE DATABASE
            if (!DatabaseUIButtons.ContainsCategoryName(uiTrigger.buttonCategory)) //the set category does not exist in the database
            {
                if (QUI.DisplayDialog("Action Required",
                                      "The category '" + uiTrigger.buttonCategory + "' was not found in the database." +
                                      "\n\n" +
                                      "Do you want to add it to the database?",
                                      "Yes",
                                      "No"))                                                             //ask the dev if he wants to add this category to the database
                {
                    DatabaseUIButtons.AddCategory(uiTrigger.buttonCategory, true);                       //add the category to the database and save
                    buttonCategoryIndex = DatabaseUIButtons.CategoryNameIndex(uiTrigger.buttonCategory); //set the index
                }
                else
                {
                    QUI.DisplayDialog("Info",
                                      "Button category has been reset to the default '" + DUI.UNCATEGORIZED_CATEGORY_NAME + "' value.",
                                      "Ok");                                                                  //inform the dev that becuase he did not add the category to the database, it has been reset to its default value
                    uiTrigger.buttonCategory = DUI.UNCATEGORIZED_CATEGORY_NAME;                               //reset the value
                    buttonCategoryIndex      = DatabaseUIButtons.CategoryNameIndex(uiTrigger.buttonCategory); //set the index
                }
            }

            //CHECK THAT THE NAME EXISTS IN THE CATEGORY
            if (!DatabaseUIButtons.Contains(uiTrigger.buttonCategory, uiTrigger.buttonName)) //the set element name does not exist under the set category
            {
                if (QUI.DisplayDialog("Action Required",
                                      "The name '" + uiTrigger.buttonName + "' was not found in the '" + uiTrigger.buttonCategory + "' category." +
                                      "\n\n" +
                                      "Do you want to add it to the database?",
                                      "Yes",
                                      "No"))                                                                           //ask the dev if he wants to add this name to the database
                {
                    DatabaseUIButtons.GetCategory(uiTrigger.buttonCategory).AddItemName(uiTrigger.buttonName, true);   //add the item name to the database and save
                    buttonNameIndex = DatabaseUIButtons.ItemNameIndex(uiTrigger.buttonCategory, uiTrigger.buttonName); //set the index
                }
                else
                {
                    QUI.DisplayDialog("Info",
                                      "Button name has been reset to the default '" + DUI.DEFAULT_BUTTON_NAME + "' value.",
                                      "Ok");                                                                                //inform the dev that becuase he did not add the name to the database, it has been reset to its default value
                    uiTrigger.buttonName = DUI.DEFAULT_BUTTON_NAME;                                                         //reset the value
                    buttonNameIndex      = DatabaseUIButtons.ItemNameIndex(uiTrigger.buttonCategory, uiTrigger.buttonName); //set the index
                }
            }
            else
            {
                buttonCategoryIndex = DatabaseUIButtons.CategoryNameIndex(uiTrigger.buttonCategory);
                buttonNameIndex     = DatabaseUIButtons.ItemNameIndex(uiTrigger.buttonCategory, uiTrigger.buttonName);
            }
        }
        void DrawStringList(List <string> list, float width, AnimBool aBool)
        {
            QUI.Space(SPACE_2 * aBool.faded);
            if (list.Count == 0)
            {
                if (SearchPatternAnimBool.value)
                {
                    DrawInfoMessage(InfoMessageName.NoResults.ToString(), width);
                }
                else
                {
                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8 * aBool.faded);
                        DrawInfoMessage(InfoMessageName.EmptyList.ToString(), width - SPACE_8);
                        QUI.Space(-20);
                        QUI.BeginVertical(16, 20);
                        {
                            QUI.Space(SPACE_4);
                            if (QUI.ButtonPlus())
                            {
                                Undo.RecordObject(DUIData.Instance, "Update List");
                                list.Add("");
                                QUI.SetDirty(DUIData.Instance);
                                AssetDatabase.SaveAssets();
                            }
                        }
                        QUI.EndVertical();
                        QUI.FlexibleSpace();
                    }
                    QUI.EndHorizontal();
                }
                return;
            }

            QUI.BeginVertical(width);
            {
                bool matchFoundInThisCategory = false;
                for (int i = 0; i < list.Count; i++)
                {
                    if (SearchPatternAnimBool.target) //a search pattern has been entered in the search box
                    {
                        if (!Regex.IsMatch(list[i], SearchPattern, RegexOptions.IgnoreCase))
                        {
                            continue; //this does not match the search pattern --> we do not show this name it
                        }
                        matchFoundInThisCategory = true;
                    }

                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8 * aBool.faded);
                        if (SearchPatternAnimBool.target) //in search mode, show a Label
                        {
                            QUI.Label(list[i], Style.Text.Normal, (width - SPACE_8));
                        }
                        else //search is disabled, show a text field
                        {
                            string tempString = list[i];
                            QUI.BeginChangeCheck();
                            tempString = EditorGUILayout.DelayedTextField(tempString, GUILayout.Width(width - SPACE_8 - 18));
                            if (QUI.EndChangeCheck())
                            {
                                if (list.Contains(tempString))
                                {
                                    QUI.DisplayDialog("Attention Required",
                                                      "There is another entry in this list with the same name.",
                                                      "Ok");
                                }
                                else
                                {
                                    Undo.RecordObject(DUIData.Instance, "Update List");
                                    list[i] = tempString;
                                    list.Sort();
                                    QUI.SetDirty(DUIData.Instance);
                                    AssetDatabase.SaveAssets();
                                }
                            }

                            if (QUI.ButtonMinus())
                            {
                                Undo.RecordObject(DUIData.Instance, "Update List");
                                list.RemoveAt(i);
                                QUI.SetDirty(DUIData.Instance);
                                AssetDatabase.SaveAssets();
                            }
                        }
                        QUI.FlexibleSpace();
                    }
                    QUI.EndHorizontal();
                    QUI.Space(SPACE_2 * aBool.faded - (SearchPatternAnimBool.target ? SPACE_2 : 0));
                }

                if (SearchPatternAnimBool.target)
                {
                    if (!matchFoundInThisCategory) //if a search pattern is active and no valid names were found for this category we let the developer know
                    {
                        DrawInfoMessage(InfoMessageName.NoResults.ToString(), width);
                    }
                    QUI.Space(18);
                }
                else //because a search pattern is active, we do not give the developer the option to create a new name
                {
                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8 * aBool.faded);
                        QUI.Space(width - SPACE_8 - 14);
                        if (QUI.ButtonPlus())
                        {
                            Undo.RecordObject(DUIData.Instance, "Update List");
                            list.Add("");
                            QUI.SetDirty(DUIData.Instance);
                            AssetDatabase.SaveAssets();
                        }
                    }
                    QUI.EndHorizontal();
                }
            }
            QUI.EndVertical();
        }
        public void DrawDatabase(TargetDatabase databaseType, DUIData.Database database, float width)
        {
            DrawNewCategoryAndSearch(width, databaseType);

            QUI.Space(SPACE_16);

            if (database.categories.Count == 0)
            {
                DrawInfoMessage(InfoMessageName.AddCategoryToStart.ToString(), width);
                return;
            }

            DrawExpandCollapseButtons(width, databaseType);

            QUI.Space(SPACE_8);

            foreach (string categoryName in database.categoryNames)
            {
                if (categoryName.Equals(DUI.CUSTOM_NAME))
                {
                    continue;
                }

                QUI.BeginHorizontal(width);
                {
                    #region Button Bar
                    if (QUI.GhostBar(categoryName, SearchPatternAnimBool.target ? QColors.Color.Orange : QColors.Color.Blue, database.GetCategory(categoryName).isExpanded, width - 15 * database.GetCategory(categoryName).isExpanded.faded *(1 - SearchPatternAnimBool.faded), BarHeight))
                    {
                        database.GetCategory(categoryName).isExpanded.target = !database.GetCategory(categoryName).isExpanded.target;
                    }

                    if (database.GetCategory(categoryName).isExpanded.faded > 0.7f && SearchPatternAnimBool.faded < 0.3f)
                    {
                        QUI.Space(1);

                        if (QUI.ButtonCancel())
                        {
                            if (categoryName.Equals(DUI.UNCATEGORIZED_CATEGORY_NAME))
                            {
                                QUI.DisplayDialog("Info",
                                                  "You cannot and should not try to delete the '" + categoryName + "' category.",
                                                  "Ok");
                            }
                            else if (QUI.DisplayDialog("Delete category?",
                                                       "Are you sure you want to delete the '" + categoryName + "'?",
                                                       "Yes",
                                                       "Cancel"))
                            {
                                Undo.RecordObject(DUIData.Instance, "DeleteCategory");
                                database.RemoveCategory(categoryName, true);
                                QUI.EndHorizontal();
                                break;
                            }
                        }
                    }
                    #endregion
                }
                QUI.EndHorizontal();
                if (QUI.BeginFadeGroup(database.GetCategory(categoryName).isExpanded.faded))
                {
                    DrawStringList(database.GetCategory(categoryName).itemNames, width, database.GetCategory(categoryName).isExpanded);
                    QUI.Space(SPACE_8 * database.GetCategory(categoryName).isExpanded.faded);
                }
                QUI.EndFadeGroup();
                QUI.Space(SPACE_2);
            }
        }
        public void DrawDatabase(TargetDatabase databaseType, DUIData.Database database, float width)
        {
            DrawNewCategoryAndSearch(width, databaseType);

            QUI.Space(SPACE_16);

            if (database.categories.Count == 0)
            {
                DrawInfoMessage(InfoMessageName.AddCategoryToStart.ToString(), width);
                return;
            }

            DrawExpandCollapseButtons(width, databaseType);

            QUI.Space(SPACE_8);

            foreach (string categoryName in database.categoryNames)
            {
                if (categoryName.Equals(DUI.CUSTOM_NAME))
                {
                    continue;
                }

                QUI.BeginHorizontal(width);
                {
                    #region Button Bar
                    if (RenameCategoryAnimBool.target && RenameCategoryTargetCategoryName.Equals(categoryName))
                    {
                        QLabel.text  = "Rename category to";
                        QLabel.style = Style.Text.Normal;
                        QUI.Label(QLabel);
                        QUI.Space(SPACE_2);
                        QUI.SetNextControlName("RenameCategoryName");
                        RenameCategoryName = QUI.TextField(RenameCategoryName, width - QLabel.x - 46);
                        QUI.Space(1);
                        if (QUI.ButtonOk() ||
                            (DetectKey_Return() && QUI.GetNameOfFocusedControl().Equals("RenameCategoryName")))
                        {
                            RenameCategoryName = RenameCategoryName.Trim();
                            if (string.IsNullOrEmpty(RenameCategoryName))
                            {
                                QUI.DisplayDialog("Action Required",
                                                  "Please enter a new category name in order to cotinue.",
                                                  "Ok");
                            }
                            else if (database.categoryNames.Contains(RenameCategoryName))
                            {
                                QUI.DisplayDialog("Action Required",
                                                  "There is another category with the name '" + RenameCategoryName + "' already in the database." +
                                                  "\n\n" +
                                                  "Enter another category name.",
                                                  "Ok");
                            }
                            else
                            {
                                database.RenameCategory(categoryName, RenameCategoryName);
                                RenameCategoryName               = "";
                                RenameCategoryAnimBool.target    = false;
                                RenameCategoryTargetCategoryName = "";
                                break;
                            }
                        }
                        QUI.Space(1);
                        if (QUI.ButtonCancel() ||
                            QUI.DetectKeyDown(Event.current, KeyCode.Escape))
                        {
                            RenameCategoryName               = "";
                            RenameCategoryAnimBool.target    = false;
                            RenameCategoryTargetCategoryName = "";
                        }
                    }
                    else
                    {
                        if (QUI.GhostBar(categoryName, SearchPatternAnimBool.target ? QColors.Color.Orange : QColors.Color.Blue, database.GetCategory(categoryName).isExpanded, width - 70 * database.GetCategory(categoryName).isExpanded.faded *(1 - SearchPatternAnimBool.faded), BarHeight))
                        {
                            database.GetCategory(categoryName).isExpanded.target = !database.GetCategory(categoryName).isExpanded.target;
                        }

                        if (database.GetCategory(categoryName).isExpanded.faded > 0.7f && SearchPatternAnimBool.faded < 0.3f)
                        {
                            QUI.Space(1);

                            if (QUI.GhostButton("rename", QColors.Color.Gray, 52, BarHeight, database.GetCategory(categoryName).isExpanded.value))
                            {
                                if (QUI.DisplayDialog("Information",
                                                      "Note that after you rename this category, all the UI settings (and code references) that use the current category name, will not get automatically changed." +
                                                      "\n\n" +
                                                      "You are responsible to update your code and the UI settings.",
                                                      "Continue",
                                                      "Cancel"))
                                {
                                    RenameCategoryAnimBool.target    = true;
                                    RenameCategoryName               = categoryName;
                                    RenameCategoryTargetCategoryName = categoryName;
                                    QUI.FocusControl("RenameCategoryName");
                                    QUI.FocusTextInControl("RenameCategoryName");
                                }
                            }

                            QUI.Space(3);

                            if (QUI.ButtonCancel())
                            {
                                if (categoryName.Equals(DUI.UNCATEGORIZED_CATEGORY_NAME))
                                {
                                    QUI.DisplayDialog("Info",
                                                      "You cannot and should not try to delete the '" + categoryName + "' category.",
                                                      "Ok");
                                }
                                else if (QUI.DisplayDialog("Delete category?",
                                                           "Are you sure you want to delete the '" + categoryName + "'?",
                                                           "Yes",
                                                           "Cancel"))
                                {
                                    Undo.RecordObject(DUIData.Instance, "DeleteCategory");
                                    database.RemoveCategory(categoryName, true);
                                    QUI.EndHorizontal();
                                    break;
                                }
                            }
                        }
                    }
                    #endregion
                }
                QUI.EndHorizontal();
                if (QUI.BeginFadeGroup(database.GetCategory(categoryName).isExpanded.faded))
                {
                    DrawStringList(database.GetCategory(categoryName).itemNames, width, database.GetCategory(categoryName).isExpanded);
                    QUI.Space(SPACE_8 * database.GetCategory(categoryName).isExpanded.faded);
                }
                QUI.EndFadeGroup();
                QUI.Space(SPACE_2);
            }
        }
        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
            }
        }
示例#10
0
        void DrawDefineSymbolsSymbolsPreset(float width)
        {
            QUI.BeginVertical(width);
            {
                QUI.GhostTitle("SYMBOLS PRESET", QColors.Color.Green, width);
                QUI.Space(SPACE_4);
                QUI.BeginHorizontal(width);
                {
                    QUI.Space(SPACE_8);
                    if (QUI.GhostButton("<<<   Copy to Build Target Group", QColors.Color.Green, width - SPACE_8, 24))
                    {
                        List <string> tempList = presetSymbols;
                        tempList = QUtils.CleanList(tempList);
                        presetSymbols.Clear();
                        presetSymbols.AddRange(tempList);
                        symbols.Clear();
                        symbols.AddRange(presetSymbols);
                        QUtils.SetScriptingDefineSymbolsForGroup(selectedBuildTargetGroup, symbols);
                        if (presetSymbols.Count == 0)
                        {
                            presetSymbols.Add("");
                        }
                    }
                    QUI.FlexibleSpace();
                }
                QUI.EndHorizontal();
                QUI.Space(SPACE_4);
                if (defineSymbolsNewPreset.value) //NEW PRESET
                {
                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8);
                        QUI.Label("Enter a new preset name...", Style.Text.Small, width - SPACE_8);
                    }
                    QUI.EndHorizontal();

                    QUI.Space(-SPACE_4);

                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8);
                        GUI.SetNextControlName("newPresetName");
                        newPresetName = QUI.TextField(newPresetName, EditorGUIUtility.isProSkin ? QColors.Green.Color : QColors.GreenLight.Color, (width - SPACE_8 - 16 - 2 - 16) * defineSymbolsNewPreset.faded);

                        //if the user hits Enter while either the key or value fields were being edited
                        bool keyboardReturnPressed = Event.current.isKey &&
                                                     Event.current.keyCode == KeyCode.Return &&
                                                     Event.current.type == EventType.KeyUp &&
                                                     (GUI.GetNameOfFocusedControl() == "newPresetName");

                        QUI.Space(-2);
                        if (QUI.ButtonOk() || keyboardReturnPressed)
                        {
                            newPresetName = newPresetName.Trim();
                            if (newPresetName.Equals(DEFAULT_PRESET_NAME))
                            {
                                QUI.DisplayDialog("Enter a new preset name", "You are trying to save a preset with the defaut preset name '" + DEFAULT_PRESET_NAME + "'. Please enter another preset name.", "Ok");
                            }
                            else if (string.IsNullOrEmpty(newPresetName))
                            {
                                QUI.DisplayDialog("Enter a new preset name", "You are trying to save a preset with no name. Please enter a name.", "Ok");
                            }
                            else if (Q.GetResource <DefineSymbols.DefineSymbolsPreset>(EZT.RESOURCES_PATH_DEFINE_SYMBOLS_PRESETS, newPresetName) != null)
                            {
                                if (QUI.DisplayDialog("Overwrite preset?", "There is a preset with the same name '" + newPresetName + "' in the presets list. Are you sure you want to overwrite it?", "Overwrite", "Cancel"))
                                {
                                    AssetDatabase.MoveAssetToTrash(EZT.RELATIVE_PATH_DEFINE_SYMBOLS_PRESETS + newPresetName + ".asset");
                                    SavePreset(presetSymbols, newPresetName);
                                    selectedPresetName = newPresetName;
                                    RefreshPresetNames();
                                    defineSymbolsNewPreset.target = false;
                                    newPresetName = "";
                                }
                            }
                            else
                            {
                                SavePreset(presetSymbols, newPresetName);
                                selectedPresetName = newPresetName;
                                RefreshPresetNames();
                                defineSymbolsNewPreset.target = false;
                                newPresetName = "";
                            }
                        }
                        QUI.Space(2);

                        //if the user hits Escape while either the key or value fields were being edited
                        bool keyboardEscapePressed = Event.current.isKey &&
                                                     Event.current.keyCode == KeyCode.Escape &&
                                                     Event.current.type == EventType.KeyUp &&
                                                     (GUI.GetNameOfFocusedControl() == "newPresetName");

                        if (QUI.ButtonCancel() || keyboardEscapePressed)
                        {
                            defineSymbolsNewPreset.target = false;
                            newPresetName = "";
                        }
                        QUI.FlexibleSpace();
                    }
                    QUI.EndHorizontal();
                    QUI.Space(5);
                }
                else //NORMAL VIEW
                {
                    QUI.BeginHorizontal(width);
                    {
                        QUI.Space(SPACE_8);
                        QUI.BeginChangeCheck();
                        QUI.SetGUIBackgroundColor(EditorGUIUtility.isProSkin ? QColors.Green.Color : QColors.GreenLight.Color);
                        selectedPresetIndex = EditorGUILayout.Popup(selectedPresetIndex, presets, GUILayout.Width(width - SPACE_8));
                        QUI.ResetColors();
                        if (QUI.EndChangeCheck())
                        {
                            Undo.RecordObject(this, "Select Preset");
                            selectedPresetName = presets[selectedPresetIndex];
                        }
                        QUI.FlexibleSpace();
                    }
                    QUI.EndHorizontal();

                    QUI.Space(SPACE_2);

                    if (loadedPresetName.Equals(selectedPresetName) || selectedPresetName.Equals(DEFAULT_PRESET_NAME))
                    {
                        QUI.BeginHorizontal(width);
                        {
                            QUI.Space(SPACE_8);
                            if (selectedPresetName.Equals(DEFAULT_PRESET_NAME))
                            {
                                if (QUI.GhostButton("Create a New Preset with current symbols", QColors.Color.Green, width - SPACE_8))
                                {
                                    defineSymbolsNewPreset.target = true;
                                    newPresetName = "";
                                }
                            }
                            else
                            {
                                if (QUI.GhostButton("NEW", QColors.Color.Green, ((width - SPACE_8) / 4) - SPACE_2))
                                {
                                    defineSymbolsNewPreset.target = true;
                                    newPresetName = "";
                                }
                                QUI.Space(SPACE_2);
                                if (QUI.GhostButton("RELOAD", QColors.Color.Green, ((width - SPACE_8) / 4) - SPACE_2))
                                {
                                    LoadPreset(selectedPresetName);
                                }
                                QUI.Space(SPACE_2);
                                if (QUI.GhostButton("SAVE", QColors.Color.Green, ((width - SPACE_8) / 4) - SPACE_2))
                                {
                                    SavePreset(presetSymbols, selectedPresetName);
                                }
                                QUI.Space(SPACE_2);
                                if (QUI.GhostButton("DELETE", QColors.Color.Red, ((width - SPACE_8) / 4) - SPACE_2))
                                {
                                    if (QUI.DisplayDialog("Delete preset?", "Are you sure you want to delete the '" + selectedPresetName + "' preset?", "Yes", "No"))
                                    {
                                        DeletePreset(selectedPresetName);
                                    }
                                }
                            }
                            QUI.FlexibleSpace();
                        }
                        QUI.EndHorizontal();
                    }
                    else
                    {
                        QUI.BeginHorizontal(width);
                        {
                            QUI.Space(SPACE_8);
                            if (QUI.GhostButton("Load Preset", QColors.Color.Green, width - SPACE_8))
                            {
                                LoadPreset(selectedPresetName);
                            }
                            QUI.FlexibleSpace();
                        }
                        QUI.EndHorizontal();
                    }
                }

                QUI.Space(-SPACE_8 - SPACE_4);
                DrawSelectedPresetsList(width);
            }
            QUI.EndVertical();
        }