コード例 #1
0
        private void SetupFilters()
        {
            filtersMenu.ShowTextTooltipOnSizeChange(-16);

            filtersMenu.clicked += () =>
            {
                if (PackageManagerFiltersWindow.instance != null)
                {
                    PackageManagerFiltersWindow.instance.Close();
                }

                var page = m_PageManager.GetCurrentPage();
                if (page != null && PackageManagerFiltersWindow.ShowAtPosition(GUIUtility.GUIToScreenRect(filtersMenu.worldBound), page))
                {
                    filtersMenu.pseudoStates |= PseudoStates.Active;
                    PackageManagerFiltersWindow.instance.OnFiltersChanged += filters =>
                    {
                        if (page.UpdateFilters(filters))
                        {
                            PackageManagerFiltersAnalytics.SendEvent(filters);
                        }
                    };
                    PackageManagerFiltersWindow.instance.OnClose += () =>
                    {
                        filtersMenu.pseudoStates &= ~PseudoStates.Active;
                    };
                }
            };

            clearFiltersButton.clicked += () =>
            {
                var page = m_PageManager.GetCurrentPage();
                page.ClearFilters();
            };
        }
コード例 #2
0
        private bool AddOrdering(IPage page, PageCapability.Ordering ordering)
        {
            var matchCurrentFilter = false;

            orderingMenu.menu.AppendAction($"{L10n.Tr(ordering.displayName)}", a =>
            {
                orderingMenu.text = $"{L10n.Tr("Sort: ")} {a.name}";

                var filters            = page.filters.Clone();
                filters.orderBy        = ordering.orderBy;
                filters.isReverseOrder = ordering.order == PageCapability.Order.Descending;
                if (page.UpdateFilters(filters))
                {
                    PackageManagerFiltersAnalytics.SendEvent(filters);
                }
            }, a =>
            {
                return(page.filters.orderBy == ordering.orderBy &&
                       (page.filters.isReverseOrder ? ordering.order == PageCapability.Order.Descending : ordering.order != PageCapability.Order.Descending)
                    ? DropdownMenuAction.Status.Checked
                    : DropdownMenuAction.Status.Normal);
            });

            if (page.filters?.orderBy == ordering.orderBy &&
                (page.filters?.isReverseOrder ?? false ? ordering.order == PageCapability.Order.Descending : ordering.order != PageCapability.Order.Descending)
                )
            {
                matchCurrentFilter = true;
                orderingMenu.text  = $"Sort: {L10n.Tr(ordering.displayName)}";
            }

            return(matchCurrentFilter);
        }
コード例 #3
0
        private void UpdateOrdering(IPage page)
        {
            orderingMenu.menu.MenuItems().Clear();

            var shouldDisplayOrdering = page?.capability.orderingValues?.Any() ?? false;

            if (!shouldDisplayOrdering)
            {
                UIUtils.SetElementDisplay(orderingMenu, false);
                return;
            }

            UIUtils.SetElementDisplay(orderingMenu, true);

            var matchCurrentFilter = false;

            if (shouldDisplayOrdering)
            {
                foreach (var ordering in page.capability.orderingValues)
                {
                    matchCurrentFilter |= AddOrdering(page, ordering);
                }
            }

            if (!matchCurrentFilter)
            {
                var filters       = page.filters?.Clone();
                var firstOrdering = page.capability?.orderingValues?.FirstOrDefault();
                if (filters != null && firstOrdering != null)
                {
                    orderingMenu.text      = $"Sort: {L10n.Tr(firstOrdering.displayName)}";
                    filters.orderBy        = firstOrdering.orderBy;
                    filters.isReverseOrder = firstOrdering.order == PageCapability.Order.Descending;

                    if (page.UpdateFilters(filters))
                    {
                        PackageManagerFiltersAnalytics.SendEvent(filters);
                    }
                }
            }
        }
コード例 #4
0
        public static void SendEvent(PageFilters filters)
        {
            var servicesContainer    = ServicesContainer.instance;
            var editorAnalyticsProxy = servicesContainer.Resolve <EditorAnalyticsProxy>();

            if (!editorAnalyticsProxy.RegisterEvent(k_EventName))
            {
                return;
            }

            var filterTab  = PackageManagerWindowAnalytics.GetFilterNameWithSubPage(servicesContainer.Resolve <PackageFiltering>(), servicesContainer.Resolve <PageManager>());
            var orderBy    = filters.isReverseOrder ? $"{filters.orderBy} (reversed)" : filters.orderBy;
            var parameters = new PackageManagerFiltersAnalytics
            {
                filter_tab = filterTab,
                order_by   = orderBy,
                status     = filters.status,
                categories = filters.categories.ToArray(),
                labels     = filters.labels.ToArray()
            };

            editorAnalyticsProxy.SendEventWithLimit(k_EventName, parameters);
        }