示例#1
0
        public static string GetVersionText(IPackageVersion version, bool simplified = false)
        {
            if (version == null || version.version == null)
            {
                return(version?.versionString);
            }

            var label = version.version?.StripTag();

            if (!simplified)
            {
                if (version.HasTag(PackageTag.Local))
                {
                    label = "local - " + label;
                }
                if (version.HasTag(PackageTag.Git))
                {
                    label = "git - " + label;
                }
                if (version.HasTag(PackageTag.Verified))
                {
                    label = "verified - " + label;
                }
                if (version.isInstalled)
                {
                    label = "current - " + label;
                }
            }
            if (version.HasTag(PackageTag.Preview))
            {
                var previewLabel = string.IsNullOrEmpty(version.version?.Prerelease) ? "preview" : version.version?.Prerelease;
                label = $"{previewLabel} - {label}";
            }
            return(label);
        }
        public static string GetVersionText(IPackageVersion version, bool simplified = false)
        {
            if (version?.version == null)
            {
                return(version?.versionString);
            }

            var label = version.version?.StripTag();

            if (!simplified)
            {
                if (version.HasTag(PackageTag.Local))
                {
                    label = string.Format(ApplicationUtil.instance.GetTranslationForText("local - {0}"), label);
                }
                if (version.HasTag(PackageTag.Git))
                {
                    label = string.Format(ApplicationUtil.instance.GetTranslationForText("git - {0}"), label);
                }
                if (version.HasTag(PackageTag.Verified))
                {
                    label = string.Format(ApplicationUtil.instance.GetTranslationForText("verified - {0}"), label);
                }
                if (version.isInstalled)
                {
                    label = string.Format(ApplicationUtil.instance.GetTranslationForText("current - {0}"), label);
                }
            }
            if (version.HasTag(PackageTag.Preview))
            {
                var previewLabel = string.IsNullOrEmpty(version.version?.Prerelease) ? ApplicationUtil.instance.GetTranslationForText("preview") : version.version?.Prerelease;
                label = $"{previewLabel} - {label}";
            }
            return(label);
        }
示例#3
0
        /// <summary>
        /// Get the full dependent message string
        /// </summary>
        private string GetDependentMessage(IPackageVersion version, IEnumerable <IPackageVersion> roots, int maxListCount = MaxDependentList)
        {
            var dependentPackages = roots.Where(p => !p.HasTag(PackageTag.BuiltIn)).ToList();
            var dependentModules  = roots.Where(p => p.HasTag(PackageTag.BuiltIn)).ToList();

            var packageType = version.HasTag(PackageTag.BuiltIn) ? "built-in package" : "package";
            var prefix      = string.Format(ApplicationUtil.instance.GetTranslationForText("This {0} is a dependency of the following "), packageType);
            var message     = string.Format("{0}{1}:\n\n", prefix, dependentPackages.Any() ? "packages" : "built-in packages");

            if (dependentPackages.Any())
            {
                message += GetPackageDashList(dependentPackages, maxListCount);
            }
            if (dependentPackages.Any() && dependentModules.Any())
            {
                message += ApplicationUtil.instance.GetTranslationForText("\n\nand the following built-in packages:\n\n");
            }
            if (dependentModules.Any())
            {
                message += GetPackageDashList(dependentModules, maxListCount);
            }

            if (roots.Count() > maxListCount)
            {
                message += ApplicationUtil.instance.GetTranslationForText("\n\n   ... and more (see console for details) ...");
            }

            var actionType = version.HasTag(PackageTag.BuiltIn) ? "disable" : "remove";

            message += string.Format(ApplicationUtil.instance.GetTranslationForText("\n\nYou will need to remove or disable them before being able to {0} this {1}."), actionType, packageType);

            return(message);
        }
 public static PackageTagLabel CreateTagLabel(IPackageVersion version, bool isVersionItem = false)
 {
     if (version != null)
     {
         if (version.HasTag(PackageTag.Custom))
         {
             return(new PackageTagLabel(L10n.Tr("Custom"), string.Empty, PackageTag.Custom));
         }
         if (version.HasTag(PackageTag.PreRelease))
         {
             return(new PackageTagLabel(L10n.Tr("Pre"), L10n.Tr("Pre-release"), PackageTag.PreRelease));
         }
         if (isVersionItem && version.HasTag(PackageTag.Release))
         {
             return(new PackageTagLabel(L10n.Tr("R"), L10n.Tr("Release"), PackageTag.Release));
         }
         if (version.HasTag(PackageTag.Experimental))
         {
             return(new PackageTagLabel(L10n.Tr("Exp"), L10n.Tr("Experimental"), PackageTag.Experimental));
         }
         if (version.HasTag(PackageTag.ReleaseCandidate))
         {
             return(new PackageTagLabel(L10n.Tr("RC"), L10n.Tr("Release Candidate"), PackageTag.ReleaseCandidate));
         }
     }
     return(null);
 }
            private static bool FilterByText(IPackageVersion version, string text)
            {
                if (version == null)
                {
                    return(false);
                }

                if (version.name.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    return(true);
                }

                if (!string.IsNullOrEmpty(version.displayName) && version.displayName.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
                {
                    return(true);
                }

                if (!version.HasTag(PackageTag.BuiltIn))
                {
                    var prerelease = text.StartsWith("-") ? text.Substring(1) : text;
                    if (version.version != null && version.version.Prerelease.IndexOf(prerelease, StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        return(true);
                    }

                    if (version.version.StripTag().StartsWith(text, StringComparison.CurrentCultureIgnoreCase))
                    {
                        return(true);
                    }

                    if (version.HasTag(PackageTag.Preview))
                    {
                        if (PackageTag.Preview.ToString().IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            return(true);
                        }
                    }

                    if (version.HasTag(PackageTag.Verified))
                    {
                        if (PackageTag.Verified.ToString().IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            return(true);
                        }
                    }

                    if (version.HasTag(PackageTag.Core))
                    {
                        if (PackageTag.BuiltIn.ToString().IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
示例#6
0
        protected override bool IsVisible(IPackageVersion version)
        {
            var installed = version?.package.versions.installed;

            return(installed != null &&
                   version.HasTag(PackageTag.Removable) &&
                   !version.HasTag(PackageTag.Custom) &&
                   (installed == version || version.IsRequestedButOverriddenVersion));
        }
        internal static bool FilterByText(IPackage package, IPackageVersion version, string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(true);
            }

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

            if (version.name.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                return(true);
            }

            if (!string.IsNullOrEmpty(version.displayName) && version.displayName.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                return(true);
            }

            var prerelease = text.StartsWith("-") ? text.Substring(1) : text;

            if (version.version != null && version.version.Prerelease.IndexOf(prerelease, StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                return(true);
            }

            if (version.HasTag(PackageTag.Preview) && PackageTag.Preview.ToString().IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                return(true);
            }

            if (version.HasTag(PackageTag.Verified) && PackageTag.Verified.ToString().IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                return(true);
            }

            if (version.version.StripTag().StartsWith(text, StringComparison.CurrentCultureIgnoreCase))
            {
                return(true);
            }

            if (!string.IsNullOrEmpty(version.category))
            {
                var words      = text.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var categories = version.category.Split('/');
                if (words.All(word => word.Length >= 2 && categories.Any(category => category.StartsWith(word, StringComparison.CurrentCultureIgnoreCase))))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#8
0
        public override void Refresh(IPackageVersion version)
        {
            var packageChanged = version.packageUniqueId != m_Version?.packageUniqueId;

            m_Version = version;
            m_Samples = m_Version.isInstalled || m_Version.HasTag(PackageTag.Feature) ? m_PackageDatabase.GetSamples(m_Version) : Enumerable.Empty <Sample>();

            UIUtils.SetElementDisplay(samplesErrorInfoBox, m_Version.HasTag(PackageTag.InDevelopment) && m_Samples.Any(sample => string.IsNullOrEmpty(sample.displayName)));
            ToggleLowWidthSampleView(layout.width, packageChanged);
        }
示例#9
0
        protected override bool IsVisible(IPackageVersion version)
        {
            var installed = version?.package.versions.installed;

            return(installed != null &&
                   installed == version &&
                   version.package.Is(PackageType.Feature) &&
                   !version.HasTag(PackageTag.Custom) &&
                   version.HasTag(PackageTag.Removable) &&
                   m_PackageDatabase.GetCustomizedDependencies(version).Any());
        }
 private static string GetVersionText(IPackageVersion packageVersion)
 {
     if (packageVersion == null || packageVersion.HasTag(PackageTag.Feature))
     {
         return(string.Empty);
     }
     if (packageVersion.HasTag(PackageTag.BuiltIn))
     {
         return("---");
     }
     return(packageVersion.version.ToString());
 }
示例#11
0
        private void RefreshTags()
        {
            foreach (var tag in k_VisibleTags)
            {
                if (tag == PackageTag.Release && m_Version.HasTag(PackageTag.Feature) &&
                    (m_Version.dependencies == null || m_Version.dependencies.Any(dependency => m_PackageDatabase.GetPackageInFeatureVersion(dependency.name)?.HasTag(PackageTag.Release) != true)))
                {
                    UIUtils.SetElementDisplay(GetTagLabel(PackageTag.Release.ToString()), false);
                }
                else
                {
                    UIUtils.SetElementDisplay(GetTagLabel(tag.ToString()), m_Version.HasTag(tag));
                }
            }

            var scopedRegistryTagLabel = GetTagLabel("ScopedRegistry");

            if ((m_Version as UpmPackageVersion)?.isUnityPackage == false && !string.IsNullOrEmpty(m_Version.version?.Prerelease))
            {
                scopedRegistryTagLabel.tooltip = m_Version.version?.Prerelease;
                scopedRegistryTagLabel.text    = m_Version.version?.Prerelease;
                UIUtils.SetElementDisplay(scopedRegistryTagLabel, true);
            }
            else
            {
                UIUtils.SetElementDisplay(scopedRegistryTagLabel, false);
            }
            UIUtils.SetElementDisplay(GetTagLabel(PackageType.AssetStore.ToString()), m_Package.Is(PackageType.AssetStore));
        }
        private void HideNormalDependencies()
        {
            // We only want to do this for packages that are in development, this wouldn't work on other packages anyway
            if (!currentPackage.HasTag(PackageTag.InDevelopment))
            {
                ShowNormalDependencies();
                return;
            }

            PackageDependencies dependencies  = PackageManagerInjectionHelper.InjectedVisualElement.PackageDetails.dependencies;
            VisualElement       visualElement = dependencies.Element.Q("dependenciesContainer");

            visualElement.style.display = new StyleEnum <DisplayStyle>(DisplayStyle.None);
        }
        public void Refresh(IPackageVersion version, bool isVersionItem = false)
        {
            if (m_Tag != PackageTag.None)
            {
                RemoveFromClassList(m_Tag.ToString());
            }

            text    = string.Empty;
            tooltip = string.Empty;
            m_Tag   = PackageTag.None;

            if (version != null)
            {
                if (version.HasTag(PackageTag.Custom))
                {
                    text  = L10n.Tr("Custom");
                    m_Tag = PackageTag.Custom;
                }
                else if (version.HasTag(PackageTag.PreRelease))
                {
                    text    = L10n.Tr("Pre");
                    tooltip = L10n.Tr("Pre-release");
                    m_Tag   = PackageTag.PreRelease;
                }
                else if (isVersionItem && version.HasTag(PackageTag.Release))
                {
                    text    = L10n.Tr("R");
                    tooltip = L10n.Tr("Release");
                    m_Tag   = PackageTag.Release;
                }
                else if (version.HasTag(PackageTag.Experimental))
                {
                    text    = L10n.Tr("Exp");
                    tooltip = L10n.Tr("Experimental");
                    m_Tag   = PackageTag.Experimental;
                }
                else if (version.HasTag(PackageTag.ReleaseCandidate))
                {
                    text    = L10n.Tr("RC");
                    tooltip = L10n.Tr("Release Candidate");
                    m_Tag   = PackageTag.ReleaseCandidate;
                }
            }

            if (m_Tag != PackageTag.None)
            {
                AddToClassList(m_Tag.ToString());
            }
        }
示例#14
0
        private void SetDisplayVersion(IPackageVersion version)
        {
            displayVersion = version;
            detailScrollView.scrollOffset = new Vector2(0, 0);

            var detailVisible = package != null && displayVersion != null;

            if (!detailVisible)
            {
                UIUtils.SetElementDisplay(customContainer, false);
                RefreshExtensions(null);
            }
            else
            {
                var isBuiltIn = package.Is(PackageType.BuiltIn);

                SetUpdateVisibility(true);

                detailTitle.text = displayVersion.displayName;

                UIUtils.SetElementDisplay(detailNameContainer, !string.IsNullOrEmpty(package.name));
                detailName.text = package.name;

                RefreshLinks();

                RefreshDescription();

                string versionString = displayVersion.version?.StripTag() ?? displayVersion.versionString;
                detailVersion.text = string.Format(ApplicationUtil.instance.GetTranslationForText("Version {0}"), versionString);
                UIUtils.SetElementDisplay(detailVersion, !isBuiltIn && !String.IsNullOrEmpty(versionString));

                foreach (var tag in k_VisibleTags)
                {
                    UIUtils.SetElementDisplay(GetTagLabel(tag.ToString()), displayVersion.HasTag(tag));
                }
                UIUtils.SetElementDisplay(GetTagLabel(PackageType.AssetStore.ToString()), package.Is(PackageType.AssetStore));

                sampleList.SetPackageVersion(displayVersion);

                RefreshAuthor();

                RefreshReleaseDetails();

                UIUtils.SetElementDisplay(customContainer, true);
                RefreshExtensions(displayVersion);

                RefreshDependencies();

                RefreshSizeAndSupportedUnityVersions();

                RefreshSupportingImages();

                RefreshPackageActionButtons();
                RefreshImportAndDownloadButtons();
            }

            // Set visibility
            SetContentVisibility(detailVisible);
            RefreshErrorDisplay();
        }
        public override void Refresh(IPackageVersion version)
        {
            m_FeatureVersion = version;

            if (version?.dependencies?.Length <= 0 || version?.HasTag(PackageTag.Feature) != true)
            {
                UIUtils.SetElementDisplay(this, false);
                return;
            }

            UIUtils.SetElementDisplay(this, true);

            dependencyList.Clear();
            foreach (var dependency in version.dependencies)
            {
                var packageVersion = m_PackageDatabase.GetPackageInFeatureVersion(dependency.name);
                var featureState   = GetFeatureState(packageVersion);

                var item = packageVersion != null ? new FeatureDependencyItem(version, packageVersion, featureState) : new FeatureDependencyItem(dependency.name);
                item.OnLeftClick(() =>
                {
                    OnDependencyItemClicked(packageVersion, dependency.name);
                });
                dependencyList.Add(item);
            }

            RefreshSelection();
        }
        private void SelectPackageAndFilter()
        {
            IPackageVersion version = null;
            IPackage        package = null;

            if (!string.IsNullOrEmpty(m_PackageToSelectOnLoaded))
            {
                var packageUniqueId = m_PackageToSelectOnLoaded.Split('@')[0];

                PackageDatabase.instance.GetPackageAndVersion(packageUniqueId, m_PackageToSelectOnLoaded, out package, out version);
                if (package == null)
                {
                    package = PackageDatabase.instance.GetPackage(m_PackageToSelectOnLoaded) ?? PackageDatabase.instance.GetPackageByDisplayName(m_PackageToSelectOnLoaded);
                }
            }

            if (m_FilterToSelectAfterLoad == PackageFilterTab.AssetStore)
            {
                PackageFiltering.instance.currentFilterTab = PackageFilterTab.AssetStore;

                if (!string.IsNullOrEmpty(m_PackageToSelectOnLoaded))
                {
                    if (package == null || package is PlaceholderPackage)
                    {
                        PageManager.instance.Fetch(m_PackageToSelectOnLoaded);
                    }
                    else
                    {
                        PageManager.instance.GetPage(PackageFilterTab.AssetStore).Load(package, version);
                    }
                }

                m_FilterToSelectAfterLoad = null;
                m_PackageToSelectOnLoaded = null;
                return;
            }

            if (package != null || m_FilterToSelectAfterLoad != null)
            {
                var tab = m_FilterToSelectAfterLoad ?? PackageFilterTab.All;
                if (version != null)
                {
                    if (!PackageManagerPrefs.instance.showPreviewPackages && version.HasTag(PackageTag.Preview))
                    {
                        PackageManagerPrefs.instance.showPreviewPackages = true;
                    }
                }

                PackageFiltering.instance.currentFilterTab = tab;
                if (!string.IsNullOrEmpty(m_PackageToSelectOnLoaded))
                {
                    PageManager.instance.GetPage(tab).SetSelected(package, version);
                    packageList.OnFocus();
                }

                m_FilterToSelectAfterLoad = null;
                m_PackageToSelectOnLoaded = null;
            }
        }
示例#17
0
        public void SetPackage(IPackageVersion packageVersion)
        {
            PackageVersion = packageVersion;
            var isInDevelopment = PackageVersion != null && PackageVersion.HasTag(PackageTag.InDevelopment);
            var shouldShow      = isInDevelopment || (MenuExtensions.AlwaysShowDevTools && PackageVersion != null && PackageVersion.isInstalled);

            UIUtils.SetElementDisplay(PublishButton, shouldShow);
        }
示例#18
0
 public virtual void Embed(IPackageVersion packageVersion)
 {
     if (packageVersion == null || !packageVersion.HasTag(PackageTag.Embeddable))
     {
         return;
     }
     m_UpmClient.EmbedByName(packageVersion.name);
 }
 public void Embed(IPackageVersion packageVersion)
 {
     if (packageVersion == null || !packageVersion.HasTag(PackageTag.Embeddable))
     {
         return;
     }
     UpmClient.instance.EmbedByName(packageVersion.name);
 }
示例#20
0
 protected override string GetText(IPackageVersion version, bool isInProgress)
 {
     if (version?.HasTag(PackageTag.BuiltIn) == true)
     {
         return(isInProgress ? L10n.Tr("Disabling") : L10n.Tr("Disable"));
     }
     return(isInProgress ? L10n.Tr("Removing") : L10n.Tr("Remove"));
 }
示例#21
0
        protected override string GetText(IPackageVersion version, bool isInProgress)
        {
            if (version?.HasTag(PackageTag.BuiltIn) == true)
            {
                return(isInProgress ? k_EnablingButtonText : k_EnableButtonText);
            }

            return(isInProgress ? k_InstallingButtonText : k_InstallButtonText);
        }
示例#22
0
        public static bool HasDocs(IPackageVersion version)
        {
            var upmVersion = version as UpmPackageVersion;

            if (!string.IsNullOrEmpty(upmVersion?.documentationUrl))
            {
                return(true);
            }
            return(upmVersion != null && !version.HasTag(PackageTag.Feature));
        }
示例#23
0
        public static bool HasLicenses(IPackageVersion version)
        {
            var upmVersion = version as UpmPackageVersion;

            if (!string.IsNullOrEmpty(upmVersion?.licensesUrl))
            {
                return(true);
            }
            return(upmVersion != null && !version.HasTag(PackageTag.BuiltIn | PackageTag.Feature));
        }
示例#24
0
 public static PackageTagLabel CreateTagLabel(IPackageVersion version, bool isVersionItem = false)
 {
     if (version != null)
     {
         if (version.HasTag(PackageTag.InDevelopment))
         {
             return(new PackageTagLabel(L10n.Tr("In Development"), PackageTag.InDevelopment));
         }
         if (version.HasTag(PackageTag.Preview))
         {
             return(new PackageTagLabel(L10n.Tr("Preview"), PackageTag.Preview));
         }
         if (isVersionItem && version.HasTag(PackageTag.Verified))
         {
             return(new PackageTagLabel(L10n.Tr("Verified"), PackageTag.Verified));
         }
     }
     return(null);
 }
示例#25
0
        public override bool IsValid(IPackageVersion version)
        {
            if (version == null || version.package?.Is(PackageType.AssetStore | PackageType.BuiltIn) == true)
            {
                return(false);
            }

            var samples = version.isInstalled || version.HasTag(PackageTag.Feature) ? m_PackageDatabase.GetSamples(version) : Enumerable.Empty <Sample>();

            return(samples?.Any() == true);
        }
示例#26
0
        protected override bool IsVisible(IPackageVersion version)
        {
            if (version?.HasTag(PackageTag.Downloadable) != true)
            {
                return(false);
            }

            var operation = m_AssetStoreDownloadManager.GetDownloadOperation(version.packageUniqueId);

            return(operation?.isProgressVisible == true);
        }
示例#27
0
        protected override bool IsVisible(IPackageVersion version)
        {
            if (version?.HasTag(PackageTag.Downloadable) != true)
            {
                return(false);
            }

            var operation = m_AssetStoreDownloadManager.GetDownloadOperation(version.packageUniqueId);

            return(operation?.state == DownloadState.Paused || operation?.state == DownloadState.ResumeRequested);
        }
示例#28
0
        protected override bool IsVisible(IPackageVersion version)
        {
            if (version?.HasTag(PackageTag.Downloadable) != true)
            {
                return(false);
            }

            return(version.HasTag(PackageTag.Importable) &&
                   version.isAvailableOnDisk &&
                   version.package.progress == PackageProgress.None &&
                   m_AssetStoreDownloadManager.GetDownloadOperation(version.packageUniqueId)?.isProgressVisible != true);
        }
示例#29
0
 protected override string GetTooltip(IPackageVersion version, bool isInProgress)
 {
     if (isInProgress)
     {
         return(k_InProgressGenericTooltip);
     }
     if (version?.HasTag(PackageTag.BuiltIn) == true)
     {
         return(string.Format(L10n.Tr("Disable the use of this {0} in your project."), version.package.GetDescriptor()));
     }
     return(string.Format(L10n.Tr("Click to remove this {0} from your project."), version.package.GetDescriptor()));
 }
示例#30
0
        protected override bool IsVisible(IPackageVersion version)
        {
            var installed     = version?.package.versions.installed;
            var targetVersion = GetTargetVersion(version);

            return(installed?.HasTag(PackageTag.VersionLocked) == false &&
                   targetVersion?.HasTag(PackageTag.Installable) == true &&
                   installed != targetVersion &&
                   !version.IsRequestedButOverriddenVersion &&
                   !version.HasTag(PackageTag.Local) &&
                   m_PageManager.GetVisualState(version.package)?.isLocked != true);
        }