Example #1
0
        public static void DrawEditableLinkButtons(List <LinkButtonData> list, float width)
        {
#if !EZ_SOURCE
            return;
#endif
#pragma warning disable CS0162 // Unreachable code detected
            QUI.Space(SPACE_2);

            QUI.DrawIconBar("Edit Link Buttons", QResources.iconInfo, QColors.Color.Blue, IconPosition.Right, width, 20);
            if (list != null && list.Count > 0)
            {
                QUI.BeginChangeCheck();
                for (int i = 0; i < list.Count; i++)
                {
                    QUI.BeginHorizontal(width);
                    {
                        list[i].text = EditorGUILayout.DelayedTextField(list[i].text, GUILayout.Width(width * 0.4f));
                        QUI.Space(SPACE_2);
                        list[i].url = EditorGUILayout.DelayedTextField(list[i].url);
                        QUI.Space(SPACE_2);
                        list[i].linkButton = (Style.LinkButton)EditorGUILayout.EnumPopup(list[i].linkButton, GUILayout.Width(width * 0.1f));
                        QUI.Space(SPACE_2);
                        if (QUI.ButtonMinus())
                        {
                            list.RemoveAt(i);
                            QUI.SetDirty(EzSourceData.Instance);
                            AssetDatabase.SaveAssets();
                            QUI.ExitGUI();
                        }
                        QUI.Space(10);
                    }
                    QUI.EndHorizontal();
                }


                if (QUI.EndChangeCheck())
                {
                    QUI.SetDirty(EzSourceData.Instance);
                    AssetDatabase.SaveAssets();
                }
            }
            else
            {
                QUI.BeginHorizontal(width);
                {
                    QLabel q = new QLabel("There are no link buttons defined... This is not right!", Style.Text.Help);
                    QUI.Label(q);
                }
                QUI.EndHorizontal();
            }

            QUI.BeginHorizontal(width);
            {
                QUI.FlexibleSpace();
                if (QUI.ButtonPlus())
                {
                    list.Add(new LinkButtonData());
                    QUI.SetDirty(EzSourceData.Instance);
                    AssetDatabase.SaveAssets();
                }
                QUI.Space(6);
            }
            QUI.EndHorizontal();
#pragma warning restore CS0162 // Unreachable code detected
        }
        void DrawHelpModule(string moduleName, Page targetModule, QTexture moduleIcon, List <LinkButtonData> list, float width)
        {
            QUI.DrawIconBar(moduleName, moduleIcon, QColors.Color.Gray, IconPosition.Right, width + 16, 24);
            QUI.Space(SPACE_4);
            QUI.DrawLinkButtonsList(list, SPACE_8, width);

#if EZ_SOURCE
            QUI.Space(SPACE_2);

            QUI.Space(6 * (selectedHelpModuleToEdit == targetModule ? editHelpAnimBool.faded : 0));
            QUI.BeginHorizontal(width + 16);
            {
                QUI.FlexibleSpace();
                if (QUI.GhostButton("Edit Links", QColors.Color.Gray, 100, 16, selectedHelpModuleToEdit == targetModule) ||
                    QUI.DetectKeyUp(Event.current, KeyCode.Escape))
                {
                    if (selectedHelpModuleToEdit == targetModule)
                    {
                        selectedHelpModuleToEdit = Page.None;
                        editHelpAnimBool.target  = false;
                    }
                    else
                    {
                        selectedHelpModuleToEdit = targetModule;
                        editHelpAnimBool.target  = true;
                    }
                }

                if (selectedHelpModuleToEdit == targetModule && editHelpAnimBool.faded > 0.4f)
                {
                    QUI.Space(SPACE_4 * editHelpAnimBool.faded);

                    if (QUI.GhostButton("Save Changes", QColors.Color.Green, 100 * editHelpAnimBool.faded, 16))
                    {
                        QUI.SetDirty(EzSourceData.Instance);
                        AssetDatabase.SaveAssets();
                        selectedHelpModuleToEdit = Page.None;
                        editHelpAnimBool.value   = false;
                    }
                }
            }
            QUI.EndHorizontal();


            if (selectedHelpModuleToEdit == targetModule)
            {
                if (QUI.BeginFadeGroup(editHelpAnimBool.faded))
                {
                    QUI.BeginVertical(width);
                    {
                        DrawEditableLinkButtons(list, width + 16);

                        QUI.Space(SPACE_16 * (selectedHelpModuleToEdit == targetModule ? editHelpAnimBool.faded : 0));
                    }
                    QUI.EndVertical();
                }
                QUI.EndFadeGroup();
            }

            QUI.Space(SPACE_8);
#endif
            QUI.Space(SPACE_8);
        }