示例#1
0
        public override void OnInspectorGUI()
        {
            if (EditorApplication.isCompiling)
            {
                StopDownloadIssues();
            }
            if (downloader != null && !downloader.IsPlaying())
            {
                downloader = null;
            }

            GUI.enabled = !EditorApplication.isCompiling && !EditorApplication.isPlaying;
            #region Toolbar 1
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            GUILayout.Label("Alias", EditorStyles.miniLabel);
            string _alias = EditorGUILayout.TextField(alias.String, EditorStyles.textField, GUILayout.Width(120));
            if (_alias != alias.String)
            {
                alias.String = _alias;
            }

            GUILayout.FlexibleSpace();

            if (!update_checked && GUILayout.Button("Check update", EditorStyles.toolbarButton, GUILayout.Width(90)))
            {
                EditorCoroutine.start(DownloadUpdate());
            }

            if (!Berry.Contact.Contact.IsSending() && GUILayout.Button("Bug Report", EditorStyles.toolbarButton, GUILayout.Width(90)))
            {
                new PrefVariable("ContactForm_AppealType").Int = (int)ContactForm.AppealType.BugReport;
                BerryPanel panel = BerryPanel.CreateBerryPanel();
                panel.editor      = null;
                panel.editorTitle = "Contact";
            }

            EditorGUILayout.EndHorizontal();
            #endregion

            #region Info
            GUILayout.Label(string.Format("Project: {0} v{1} ({2}), Fixer Version: v{3}",
                                          project,
                                          project_version.ToString("F2"),
                                          sub,
                                          fixer_version.ToString("F2")),
                            EditorStyles.centeredGreyMiniLabel);
            #endregion

            #region Update
            if (update_checked && new_fixer_version > 0)
            {
                if (new_fixer_version > fixer_version)
                {
                    EditorGUILayout.HelpBox("Fixer v" + new_fixer_version.ToString("F2") + " is avaliable to install.", MessageType.Warning);
                    if (GUILayout.Button("Install", EditorStyles.miniButton, GUILayout.Width(60)))
                    {
                        InstallUpdate();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Last version of Fixer is installed.", MessageType.Info);
                }
            }
            #endregion

            #region Toolbar 2
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            status = (Status)EditorGUILayout.EnumPopup(status, EditorStyles.toolbarPopup, GUILayout.Width(100));

            selected_type = EditorGUILayout.Popup(selected_type, issueTypes.ToArray(), EditorStyles.toolbarPopup, GUILayout.Width(100));

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Refresh", EditorStyles.toolbarButton, GUILayout.Width(60)))
            {
                DownloadIssues();
            }

            if (GUILayout.Button("Check all", EditorStyles.toolbarButton, GUILayout.Width(73)))
            {
                foreach (List <Issue> list in Issue.all.Values)
                {
                    foreach (Issue issue in list)
                    {
                        if (!issue.isChecked && issue.errors.Count == 0)
                        {
                            issue.Check();
                        }
                    }
                }
            }

            EditorGUILayout.EndHorizontal();
            #endregion



            if (downloader != null)
            {
                GUILayout.Label("Downloading...", EditorStyles.centeredGreyMiniLabel);
            }
            if (EditorApplication.isCompiling)
            {
                GUILayout.Label("Compiling...", EditorStyles.centeredGreyMiniLabel);
            }
            if (EditorApplication.isPlaying)
            {
                GUILayout.Label("Playing...", EditorStyles.centeredGreyMiniLabel);
            }

            bool visible;
            foreach (List <Issue> list in Issue.all.Values)
            {
                foreach (Issue issue in list)
                {
                    visible = false;
                    if (issueTypes.Count > 0 && issueTypes[selected_type] != issue.type && issueTypes[selected_type] != "All Types")
                    {
                        continue;
                    }
                    switch (status)
                    {
                    case Status.All:
                        visible = true;
                        break;

                    case Status.Checked:
                        visible = issue.isChecked && !issue.isFixed;
                        break;

                    case Status.Fixed:
                        visible = issue.isFixed;
                        break;

                    case Status.Manual:
                        visible = issue.fixer == "" && issue.codefixes.Count == 0;
                        break;

                    case Status.Problematic:
                        visible = issue.errors.Count > 0;
                        break;

                    case Status.Unchecked:
                        visible = !issue.isChecked;
                        break;
                    }
                    if (!visible)
                    {
                        continue;
                    }
                    DrawCard(issue);
                }
            }

            GUI.enabled = true;
        }