Пример #1
0
        /// <summary>Displays a set of tags.</summary>
        public void DisplayTags(IEnumerable <string> tags)
        {
            // copy tags
            if (this.m_tags != tags)
            {
                if (tags == null)
                {
                    tags = new string[0];
                }

                // copy tags
                List <string> newTagList = new List <string>();
                foreach (string tagName in tags)
                {
                    newTagList.Add(tagName);
                }
                this.m_tags = newTagList.ToArray();
            }

            // display
            if (this.m_itemTemplate != null)
            {
                int tagCount = this.m_tags.Length;
                UIUtilities.SetInstanceCount(this.m_container, this.m_itemTemplate,
                                             "Tag", tagCount,
                                             ref this.m_displays);

                // display categories?
                if (m_itemTemplate.categoryName.displayComponent != null &&
                    this.m_tagCategoryMap.Count > 0)
                {
                    for (int i = 0;
                         i < tagCount;
                         ++i)
                    {
                        string categoryName;
                        if (this.m_tagCategoryMap.TryGetValue(this.m_tags[i], out categoryName))
                        {
                            this.m_displays[i].categoryName.text = categoryName;
                        }
                    }
                }

                // display tag names
                for (int i = 0;
                     i < tagCount;
                     ++i)
                {
                    this.m_displays[i].tagName.text = this.m_tags[i];
                }

                this.m_templateClone.SetActive(tagCount > 0 || !this.hideIfEmpty);
            }
        }
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays a set of modfiles.</summary>
        public virtual void DisplayModfiles(IList <Modfile> modfiles)
        {
            // copy data
            if (this.m_modfiles != modfiles)
            {
                int modfileCount = 0;
                if (modfiles != null)
                {
                    modfileCount = modfiles.Count;
                }

                this.m_modfiles = new Modfile[modfileCount];
                for (int i = 0; i < modfileCount; ++i)
                {
                    this.m_modfiles[i] = modfiles[i];
                }
            }

            // display
            if (this.m_itemTemplate != null)
            {
                // set instance count
                int itemCount = this.m_modfiles.Length;;
                if (this.m_itemLimit >= 0 &&
                    this.m_itemLimit < itemCount)
                {
                    itemCount = this.m_itemLimit;
                }

                // set view count
                UIUtilities.SetInstanceCount(this.m_container, this.m_itemTemplate,
                                             "Modfile View", itemCount,
                                             ref this.m_views);

                // display data
                for (int i = 0; i < itemCount; ++i)
                {
                    this.m_views[i].modfile = this.m_modfiles[i];
                }

                // hide if necessary
                this.m_templateClone.SetActive(itemCount > 0 || !this.hideIfEmpty);
            }
        }
        /// <summary>Displays a set of YouTube thumbnails.</summary>
        public virtual void DisplayThumbnails(int modId, IList <string> youTubeIds)
        {
            this.m_modId = modId;

            // copy ids
            if (this.m_youTubeIds != youTubeIds)
            {
                int thumbCount = 0;
                if (youTubeIds != null)
                {
                    thumbCount = youTubeIds.Count;
                }

                this.m_youTubeIds = new string[thumbCount];
                for (int i = 0; i < thumbCount; ++i)
                {
                    this.m_youTubeIds[i] = youTubeIds[i];
                }
            }

            // display
            if (this.m_itemTemplate != null)
            {
                // set view count
                UIUtilities.SetInstanceCount(this.m_container, this.m_itemTemplate,
                                             "YouTube Thumbnail", this.m_youTubeIds.Length,
                                             ref this.m_displays);

                // display data
                for (int i = 0;
                     i < this.m_youTubeIds.Length;
                     ++i)
                {
                    this.m_displays[i].DisplayThumbnail(this.m_modId, this.m_youTubeIds[i]);
                }

                // hide if necessary
                this.m_templateClone.SetActive(this.m_youTubeIds.Length > 0 || !this.hideIfEmpty);
            }
        }
Пример #4
0
        /// <summary>Displays a set of gallery images.</summary>
        public virtual void DisplayImages(int modId, IList <GalleryImageLocator> locators)
        {
            this.m_modId = modId;

            // copy locators
            if (this.m_locators != locators)
            {
                int imageCount = 0;
                if (locators != null)
                {
                    imageCount = locators.Count;
                }

                this.m_locators = new GalleryImageLocator[imageCount];
                for (int i = 0; i < imageCount; ++i)
                {
                    this.m_locators[i] = locators[i];
                }
            }

            // display
            if (this.m_itemTemplate != null)
            {
                // set view count
                UIUtilities.SetInstanceCount(this.m_container, this.m_itemTemplate,
                                             "Gallery Image", this.m_locators.Length,
                                             ref this.m_displays);

                // display data
                for (int i = 0; i < this.m_locators.Length; ++i)
                {
                    this.m_displays[i].DisplayGalleryImage(modId, this.m_locators[i]);
                }

                // hide if necessary
                this.m_templateClone.SetActive(this.m_locators.Length > 0 || !this.hideIfEmpty);
            }
        }
Пример #5
0
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays a set of mods.</summary>
        public virtual void DisplayMods(IList <ModProfile> profiles, IList <ModStatistics> statistics)
        {
            // assert validity
            if (profiles != null &&
                statistics != null &&
                profiles.Count != statistics.Count)
            {
                Debug.LogWarning("[mod.io] Cannot display a collection of profiles"
                                 + " and statistics where the counts are not equal."
                                 + "\n profiles.Count = " + profiles.Count.ToString()
                                 + "\n statistics.Count = " + statistics.Count.ToString(),
                                 this);

                statistics = null;
            }

            int itemCount = 0;

            if (profiles != null)
            {
                itemCount = profiles.Count;
            }
            else if (statistics != null)
            {
                itemCount = statistics.Count;
            }

            // copy arrays
            if (this.m_modProfiles != profiles)
            {
                this.m_modProfiles = new ModProfile[itemCount];
                for (int i = 0; i < itemCount; ++i)
                {
                    this.m_modProfiles[i] = profiles[i];
                }
            }
            if (this.m_modStatistics != statistics)
            {
                this.m_modStatistics = new ModStatistics[itemCount];
                for (int i = 0; i < itemCount; ++i)
                {
                    this.m_modStatistics[i] = statistics[i];
                }
            }

            // display
            if (this.m_itemTemplate != null)
            {
                Debug.Assert(this.m_container != null);

                // set instance count
                int viewCount = itemCount;
                if (this.m_fillToLimit && this.m_itemLimit >= 0)
                {
                    viewCount = this.m_itemLimit;

                    if (viewCount < itemCount)
                    {
                        itemCount = viewCount;
                    }
                }

                UIUtilities.SetInstanceCount(this.m_container, this.m_itemTemplate,
                                             "Mod View", viewCount,
                                             ref this.m_views, true);


                // -- set view visibility --
                if (this.m_fillToLimit && this.m_itemLimit >= 0)
                {
                    int visibleCount = itemCount;

                    for (int i = 0;
                         i < visibleCount;
                         ++i)
                    {
                        CanvasGroup c = this.m_views[i].GetComponent <CanvasGroup>();
                        c.alpha          = 1f;
                        c.interactable   = true;
                        c.blocksRaycasts = true;
                    }

                    for (int i = visibleCount;
                         i < viewCount;
                         ++i)
                    {
                        CanvasGroup c = this.m_views[i].GetComponent <CanvasGroup>();
                        c.alpha          = 0f;
                        c.interactable   = false;
                        c.blocksRaycasts = false;
                    }
                }

                // display data
                if (this.m_modProfiles != null)
                {
                    for (int i = 0;
                         i < this.m_modProfiles.Length && i < viewCount;
                         ++i)
                    {
                        this.m_views[i].profile = this.m_modProfiles[i];
                    }
                }
                if (this.m_modStatistics != null)
                {
                    for (int i = 0;
                         i < this.m_modStatistics.Length && i < viewCount;
                         ++i)
                    {
                        this.m_views[i].statistics = this.m_modStatistics[i];
                    }
                }

                // hide if necessary
                this.m_templateClone.SetActive(itemCount > 0 || !this.hideIfEmpty);
            }
        }
Пример #6
0
        // ---------[ UI FUNCTIONALITY ]---------
        /// <summary>Displays a collection of tag categories.</summary>
        public void DisplayTagCategories(IEnumerable <ModTagCategory> tagCategories)
        {
            // copy categories
            if (this.m_tagCategories != tagCategories)
            {
                if (tagCategories == null)
                {
                    tagCategories = new ModTagCategory[0];
                }

                // copy categories
                List <ModTagCategory> categories = new List <ModTagCategory>();
                foreach (ModTagCategory category in tagCategories)
                {
                    if (category != null &&
                        category.tags != null &&
                        category.tags.Length > 0 &&
                        (displayHidden || !category.isHidden))
                    {
                        categories.Add(category);
                    }
                }
                this.m_tagCategories = categories.ToArray();
            }

            // display
            if (this.isActiveAndEnabled)
            {
                int categoryCount = this.m_tagCategories.Length;

                // create/destroy category displays
                UIUtilities.SetInstanceCount(this.m_container, this.m_itemTemplate,
                                             "Tag Category", categoryCount,
                                             ref this.m_itemInstances);

                // set category labels
                if (this.template.categoryLabel.displayComponent != null)
                {
                    for (int i = 0; i < categoryCount; ++i)
                    {
                        this.m_itemInstances[i].label.text = this.m_tagCategories[i].name;
                    }
                }

                // tag displays
                for (int cat_i = 0; cat_i < categoryCount; ++cat_i)
                {
                    ModTagCategory category     = this.m_tagCategories[cat_i];
                    CategoryItem   categoryItem = this.m_itemInstances[cat_i];

                    // create/destroy
                    UIUtilities.SetInstanceCount(categoryItem.tagContainer,
                                                 this.template.tagTemplate,
                                                 "Tag",
                                                 category.tags.Length,
                                                 ref categoryItem.tagInstances);

                    // set category name
                    if (this.template.tagTemplate.categoryName.displayComponent != null)
                    {
                        for (int tag_i = 0; tag_i < category.tags.Length; ++tag_i)
                        {
                            categoryItem.tagInstances[tag_i].categoryName.text = category.name;
                        }
                    }

                    // set tag name
                    for (int tag_i = 0; tag_i < category.tags.Length; ++tag_i)
                    {
                        categoryItem.tagInstances[tag_i].tagName.text = category.tags[tag_i];
                    }
                }

                // fire event
                if (this.onTagsChanged != null)
                {
                    this.onTagsChanged(this.tagItems);
                }
            }
        }