コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }