예제 #1
0
        void DrawCard(Issue issue)
        {
            Color color = GUI.backgroundColor;

            if (issue.isChecked || issue.isCached)
            {
                GUI.backgroundColor = Color.Lerp(color, (issue.isFixed || issue.isCached)? Color.green : Color.yellow, 0.3f);
            }
            if (issue.errors.Count > 0)
            {
                GUI.backgroundColor = Color.Lerp(color, Color.red, 0.3f);
            }
            EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.ExpandWidth(true));
            GUI.backgroundColor = color;

            if (!string.IsNullOrEmpty(issue.alias))
            {
                GUILayout.Label(string.Format("Alias: {0}", issue.alias), EditorStyles.boldLabel);
            }
            GUILayout.Label(string.Format("Issue #{0} ({1})", issue.number, issue.type), EditorStyles.boldLabel);
            EditorGUILayout.HelpBox(issue.desription, MessageType.None);

            List <string> messages = new List <string>();

            if (issue.fixer != "" || issue.codefixes.Count > 0)
            {
                bool isLocked = !GUI.enabled;
                if (!isLocked)
                {
                    messages.AddRange(issue.GetProblems());
                    if (messages.Count > 0)
                    {
                        GUI.enabled = false;
                    }
                }
                if (!issue.isChecked)
                {
                    if (GUILayout.Button("Check it", EditorStyles.miniButton, GUILayout.Width(80)))
                    {
                        issue.Check();
                    }
                }
                else if (!issue.isFixed)
                {
                    messages.Add("Unfixed");
                    if (GUILayout.Button("Fix it", EditorStyles.miniButton, GUILayout.Width(80)))
                    {
                        issue.Fix();
                    }
                }
                else
                {
                    messages.Add("Fixed");
                }

                if (issue.isCached && !issue.isFixed)
                {
                    messages.Add("Fixed (Cache)");
                }
                if (messages.Count > 0)
                {
                    GUILayout.Label(string.Join("\n", messages.ToArray()), EditorStyles.boldLabel);
                }

                GUI.enabled = !isLocked;
            }

            foreach (string error in issue.errors)
            {
                EditorGUILayout.HelpBox(error, MessageType.Error);
            }

            if (issue.filesReport.Count > 0)
            {
                if (GUILayout.Button("Report it", EditorStyles.miniButton, GUILayout.Width(80)))
                {
                    new PrefVariable("ContactForm_Attachments").String = string.Join(";", issue.filesReport.ToArray());
                    new PrefVariable("ContactForm_AppealType").Int     = (int)ContactForm.AppealType.BugReport;
                    new PrefVariable("ContactForm_Subject").String     = "Problem with Fixer";
                    new PrefVariable("ContactForm_Body").String        = string.Format("Project: {0} v{1} ({2})\nFixer v{3}\nIssue #{4} ({5})\n{6}", project, project_version.ToString("F2"), sub, fixer_version.ToString("F2"), issue.number, issue.type, issue.desription);
                    new PrefVariable("ContactForm_Log").String         = string.Join("\n\n", issue.errors.ToArray());
                    BerryPanel panel = BerryPanel.CreateBerryPanel();
                    panel.editor      = null;
                    panel.editorTitle = "Contact";
                }
            }

            EditorGUILayout.EndVertical();
        }