Example #1
0
 private void SetupOrdering()
 {
     orderingMenu.menu.MenuItems().Clear();
     orderingMenu.ShowTextTooltipOnSizeChange(-16);
     UIUtils.SetElementDisplay(orderingMenu, false);
 }
Example #2
0
        private void RefreshSelection(IPackageVersion version = null)
        {
            var selectedDependencyPackageId = m_PackageManagerPrefs.selectedFeatureDependency;

            if (version == null)
            {
                var dependencies = m_FeatureVersion?.dependencies;
                if (dependencies?.Any() != true)
                {
                    return;
                }

                if (string.IsNullOrEmpty(selectedDependencyPackageId) || !dependencies.Any(d => d.name == selectedDependencyPackageId))
                {
                    selectedDependencyPackageId = dependencies[0].name;
                    m_PackageManagerPrefs.selectedFeatureDependency = selectedDependencyPackageId;
                }
                version = m_PackageDatabase.GetPackageInFeatureVersion(selectedDependencyPackageId);
            }

            // If the package is not installed and undiscoverable, we have to display the package's ID name (ex: com.unity.adaptiveperformance.samsung.android)
            // and hide other elements in the package view
            var showElementsInDetailsView = version != null;

            UIUtils.SetElementDisplay(dependencyVersion, showElementsInDetailsView);
            UIUtils.SetElementDisplay(dependencyLink, showElementsInDetailsView);
            UIUtils.SetElementDisplay(dependencyInfoBox, showElementsInDetailsView);

            foreach (var item in dependencyList.Children().OfType <FeatureDependencyItem>())
            {
                item.EnableInClassList(k_SelectedClassName, item.packageName == selectedDependencyPackageId);
            }

            dependencyTitle.value = version?.displayName ?? selectedDependencyPackageId;
            dependencyDesc.value  = version?.description ?? L10n.Tr("This package will be automatically installed with this feature.");

            if (!showElementsInDetailsView)
            {
                return;
            }

            var installedPackageVersion = m_PackageDatabase.GetPackage(version)?.versions.installed;

            dependencyVersion.value = installedPackageVersion != null && installedPackageVersion.versionId != version?.versionId ? string.Format(L10n.Tr("Version {0} (Installed {1})"), version.versionString, installedPackageVersion.versionString) : string.Format(L10n.Tr("Version {0}"), version.versionString);

            var featureState = GetFeatureState(version);

            versionState.ClearClassList();
            if (featureState == FeatureState.Info)
            {
                versionState.AddToClassList(featureState.ToString().ToLower());
                versionState.tooltip = string.Format(L10n.Tr("Using version {0} because at least one other package or feature depends on it"), installedPackageVersion.versionString);
            }

            var tab = PackageFilterTab.UnityRegistry;

            if (version.isDirectDependency || m_SettingsProxy.enablePackageDependencies)
            {
                tab = PackageFilterTab.InProject;
            }
            dependencyLink.clickable.clicked += () => PackageManagerWindow.SelectPackageAndFilterStatic(version.name, tab);

            UIUtils.SetElementDisplay(dependencyInfoBox, featureState == FeatureState.Customized);
            if (installedPackageVersion?.HasTag(PackageTag.Custom) ?? false)
            {
                m_Link = "fs-details.html";
                dependencyInfoBox.text = L10n.Tr("This package has been customized.");
            }
            else
            {
                m_Link = "upm-ui-remove.html";
                dependencyInfoBox.text = L10n.Tr("This package has been manually changed.");
            }
        }
Example #3
0
        private void BuildMainItem(bool isFeature)
        {
            m_IsFeatureLayout = isFeature;

            m_MainItem = new VisualElement {
                name = "mainItem"
            };
            Add(m_MainItem);

            m_LeftContainer = new VisualElement {
                name = "leftContainer", classList = { "left" }
            };
            m_MainItem.Add(m_LeftContainer);

            m_ArrowExpander = new Toggle {
                name = "arrowExpander", classList = { "expander" }
            };
            m_ArrowExpander.RegisterValueChangedCallback(ToggleExpansion);
            m_LockedIcon = new Label {
                name = "lockedIcon"
            };
            m_LeftContainer.Add(m_ArrowExpander);
            m_LeftContainer.Add(m_LockedIcon);

            m_ExpanderHidden = new Label {
                name = "expanderHidden", classList = { "expanderHidden" }
            };
            m_LeftContainer.Add(m_ExpanderHidden);

            m_NameLabel = new Label {
                name = "packageName", classList = { "name" }
            };
            if (isFeature)
            {
                m_MainItem.AddToClassList("feature");
                m_NumPackagesInFeature = new Label()
                {
                    name = "numPackages"
                };

                var leftMiddleContainer = new VisualElement()
                {
                    name = "leftMiddleContainer"
                };
                leftMiddleContainer.Add(m_NameLabel);
                leftMiddleContainer.Add(m_NumPackagesInFeature);
                m_LeftContainer.Add(leftMiddleContainer);
            }
            else
            {
                m_LeftContainer.Add(m_NameLabel);
            }

            m_EntitlementLabel = new Label {
                name = "entitlementLabel"
            };
            UIUtils.SetElementDisplay(m_EntitlementLabel, false);
            m_LeftContainer.Add(m_EntitlementLabel);

            m_VersionLabel = new Label {
                name = "versionLabel", classList = { "version", "middle" }
            };
            m_MainItem.Add(m_VersionLabel);

            m_RightContainer = new VisualElement {
                name = "rightContainer", classList = { "right" }
            };
            m_MainItem.Add(m_RightContainer);

            m_TagContainer = new VisualElement {
                name = "tagContainer"
            };
            m_RightContainer.Add(m_TagContainer);

            m_Spinner = null;

            m_StateContainer = new VisualElement {
                name = "statesContainer"
            };
            m_MainItem.Add(m_StateContainer);

            m_StateIcon = new VisualElement {
                name = "stateIcon", classList = { "status" }
            };
            m_StateContainer.Add(m_StateIcon);

            if (isFeature)
            {
                m_InfoStateIcon = new VisualElement {
                    name = "versionState"
                };
                m_StateContainer.Add(m_InfoStateIcon);
            }

            m_VersionsContainer = null;
        }
Example #4
0
        public void Refresh(IPackage package, IPackageVersion version)
        {
            m_Package = package;
            m_Version = version;
            Clear();

            if (package == null || version == null)
            {
                return;
            }

            var leftItems = new VisualElement {
                classList = { "left" }
            };

            Add(leftItems);

            // add links from the package
            foreach (var link in package.links)
            {
                if (string.IsNullOrEmpty(link.name) || string.IsNullOrEmpty(link.url))
                {
                    continue;
                }
                AddToLinks(leftItems, new Button(() => { m_Application.OpenURL(link.url); })
                {
                    text      = link.name,
                    tooltip   = link.url,
                    classList = { k_LinkClass }
                }, package.links.First() != link);
            }

            // add links related to the upm version
            if (UpmPackageDocs.HasDocs(version))
            {
                AddToLinks(leftItems, new Button(ViewDocClick)
                {
                    text = k_ViewDocumentationText, classList = { k_LinkClass }
                }, false);
            }

            if (UpmPackageDocs.HasChangelog(version))
            {
                AddToLinks(leftItems, new Button(ViewChangelogClick)
                {
                    text = k_ViewChangelogText, classList = { k_LinkClass }
                });
            }

            if (UpmPackageDocs.HasLicenses(version))
            {
                AddToLinks(leftItems, new Button(ViewLicensesClick)
                {
                    text = k_ViewLicensesText, classList = { k_LinkClass }
                });
            }

            if (UpmPackageDocs.HasUseCases(version))
            {
                AddToLinks(leftItems, new Button(ViewUseCasesClick)
                {
                    text = k_ViewUseCasesText, classList = { k_LinkClass }
                });
            }

            if (UpmPackageDocs.HasDashboard(version))
            {
                AddToLinks(leftItems, new Button(ViewDashboardClick)
                {
                    text = k_ViewDashboardText, classList = { k_LinkClass }
                });
            }

            var topOffset = false;

            if (package.Is(PackageType.Feature) && !string.IsNullOrEmpty(GetQuickStartUrl(m_Version)))
            {
                var quickStartButton = new Button(ViewQuickStartClick)
                {
                    name = "quickStart", classList = { "quickStartButton", "right" }
                };
                quickStartButton.Add(new VisualElement {
                    classList = { "quickStartIcon" }
                });
                quickStartButton.Add(new TextElement {
                    text = k_ViewQuickStartText, classList = { "quickStartText" }
                });

                Add(quickStartButton);

                topOffset = leftItems.childCount == 0;
            }
            // Offset the links container to the top when there are no links and only quick start button visible
            EnableInClassList("topOffset", topOffset);
            UIUtils.SetElementDisplay(this, childCount != 0);
        }
Example #5
0
 private void StopSpinner()
 {
     m_Spinner?.Stop();
     UIUtils.SetElementDisplay(m_StateIcon, true);
 }