예제 #1
0
파일: RecordsTab.cs 프로젝트: s1gurd/W-Hub
        private void DeleteRecords()
        {
            for (var i = recordsToDeleteIndexes.Length - 1; i >= 0; i--)
            {
                var index  = recordsToDeleteIndexes[i];
                var record = filteredRecords[index];
                records = CSArrayTools.RemoveAt(records, Array.IndexOf(records, record));

                GetState().selection.RemoveAt(index);
                GetState().compaction.RemoveAt(index);
            }

            recordsToDeleteIndexes = null;

            ApplySorting();

            if (filteredRecords.Length > 0)
            {
                recordsTotalPages = (int)Math.Ceiling((double)filteredRecords.Length / RecordsPerPage);
            }
            else
            {
                recordsTotalPages = 1;
            }

            if (recordsCurrentPage + 1 > recordsTotalPages)
            {
                recordsCurrentPage = recordsTotalPages - 1;
            }

            SaveSearchResults();
            window.Repaint();
        }
예제 #2
0
        protected virtual void DeleteRecord()
        {
            T record = filteredRecords[recordToDeleteIndex];

            records = CSArrayTools.RemoveAt(records, Array.IndexOf(records, record));
            ApplySorting();

            if (filteredRecords.Length > 0)
            {
                recordsTotalPages = (int)Math.Ceiling((double)filteredRecords.Length / RECORDS_PER_PAGE);
            }
            else
            {
                recordsTotalPages = 1;
            }

            if (recordsCurrentPage + 1 > recordsTotalPages)
            {
                recordsCurrentPage = recordsTotalPages - 1;
            }

            SaveSearchResults();
            window.Repaint();
        }
예제 #3
0
        protected override void DrawRecord(int recordIndex, out bool recordRemoved)
        {
            recordRemoved = false;
            RecordBase record = records[recordIndex];

            UIHelpers.Separator();

            using (UIHelpers.Horizontal())
            {
                DrawSeverityIcon(record);
                if (record.location == RecordLocation.Prefab)
                {
                    UIHelpers.DrawPrefabIcon();
                }
                GUILayout.Label(record.GetHeader(), UIHelpers.richLabel, GUILayout.ExpandWidth(false));
            }

            GUILayout.Label(record.GetBody(), UIHelpers.richLabel);

            using (UIHelpers.Horizontal(UIHelpers.panelWithBackground))
            {
                AddShowButtonIfPossible(record);

                if (GUILayout.Button(new GUIContent("Copy", "Copies record text to the clipboard."), UIHelpers.recordButton))
                {
                    EditorGUIUtility.systemCopyBuffer = record.ToString(true);
                    MaintainerWindow.ShowNotification("Issue record copied to clipboard!");
                }

                if (GUILayout.Button(new GUIContent("Hide", "Hide this issue from the results list.\nUseful when you fixed issue and wish to hide it away."), UIHelpers.recordButton))
                {
                    // ReSharper disable once CoVariantArrayConversion
                    records = CSArrayTools.RemoveAt(records as IssueRecord[], recordIndex);
                    SearchResultsStorage.IssuesSearchResults = (IssueRecord[])records;
                    recordRemoved = true;
                    return;
                }

                //UIHelpers.VerticalSeparator();
                GameObjectIssueRecord objectIssue = record as GameObjectIssueRecord;
                if (objectIssue != null)
                {
                    if (GUILayout.Button("More ...", UIHelpers.recordButton))
                    {
                        GenericMenu menu = new GenericMenu();
                        if (!string.IsNullOrEmpty(objectIssue.path))
                        {
                            menu.AddItem(new GUIContent("Ignore/Add path to ignores"), false, () =>
                            {
                                if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.pathIgnores, objectIssue.path))
                                {
                                    MaintainerSettings.Save();
                                    MaintainerWindow.ShowNotification("Ignore added: " + objectIssue.path);
                                    IssuesIgnoresWindow.Refresh();
                                }
                                else
                                {
                                    MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                }
                            });

                            DirectoryInfo dir = Directory.GetParent(objectIssue.path);
                            if (dir.Name != "Assets")
                            {
                                menu.AddItem(new GUIContent("Ignore/Add parent directory to ignores"), false, () =>
                                {
                                    if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.pathIgnores, dir.ToString()))
                                    {
                                        MaintainerSettings.Save();
                                        MaintainerWindow.ShowNotification("Ignore added: " + dir);
                                        IssuesIgnoresWindow.Refresh();
                                    }
                                    else
                                    {
                                        MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                    }
                                });
                            }
                        }

                        if (!string.IsNullOrEmpty(objectIssue.component))
                        {
                            menu.AddItem(new GUIContent("Ignore/Add component to ignores"), false, () =>
                            {
                                if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.componentIgnores, objectIssue.component))
                                {
                                    MaintainerSettings.Save();
                                    MaintainerWindow.ShowNotification("Ignore added: " + objectIssue.component);
                                    IssuesIgnoresWindow.Refresh();
                                }
                                else
                                {
                                    MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                }
                            });
                        }
                        menu.ShowAsContext();
                    }
                }
            }
        }