/// <summary>Creates the display elements for the given ModTagCategory.</summary>
        private GameObject CreateCategoryDisplayInstance(ModTagCategory category,
                                                         GameObject prefab,
                                                         RectTransform container)
        {
            GameObject displayGO = GameObject.Instantiate(prefab,
                                                          container);
            displayGO.name = category.name;

            ModTagCategoryDisplay display = displayGO.GetComponent<ModTagCategoryDisplay>();
            display.Initialize();
            display.DisplayCategory(category);

            ToggleGroup toggleGroup = null;
            if(!category.isMultiTagCategory)
            {
                toggleGroup = display.gameObject.AddComponent<ToggleGroup>();
                toggleGroup.allowSwitchOff = true;
            }

            ModTagContainer tagContainer = displayGO.GetComponent<ModTagContainer>();
            foreach(ModTagDisplay tagDisplay in tagContainer.tagDisplays)
            {
                Toggle tagToggle = tagDisplay.GetComponent<Toggle>();
                tagToggle.isOn = this.m_selectedTags.Contains(tagDisplay.data.tagName);
                tagToggle.group = toggleGroup;
            }

            return displayGO;
        }
Пример #2
0
        // ---------[ INITIALIZATION ]---------
        private void Start()
        {
            // asserts
            Debug.Assert(tagCategoryContainer != null);
            Debug.Assert(tagCategoryPrefab != null);
            Debug.Assert(tagCategoryPrefab.GetComponent <ModTagCategoryDisplay>() != null);

            ModTagContainer tagContainer = tagCategoryPrefab.GetComponent <ModTagContainer>();

            Debug.Assert(tagContainer != null,
                         "[mod.io] ModTagFilterViews require the TagCategoryPrefab to have a "
                         + "ModTagContainer component. (Any other TagCollectionDisplay type "
                         + "is incompatible.)");

            Debug.Assert(tagContainer.tagDisplayPrefab != null);

            Debug.Assert(tagContainer.tagDisplayPrefab.GetComponent <Toggle>() != null,
                         "[mod.io] ModTagFilterViews require the TagDisplayPrefab in the "
                         + "FilterView.tagCategoryPrefab to have a Toggle Component.");

            // init tag selection
            this.view.onTagFilterUpdated += (t) =>
            {
                this.selectedTags = t;
            };

            var viewFilter = this.view.GetTagFilter();

            if (viewFilter == null)
            {
                this.m_selectedTags = new List <string>();
            }
            else
            {
                this.m_selectedTags = new List <string>(viewFilter);
            }

            // init tag categories
            var tagCategories = ModBrowser.instance.gameProfile.tagCategories;

            if (tagCategories != null)
            {
                this.m_tagCategories = tagCategories;
            }

            // update display
            this.Refresh();
        }
        /// <summary>Updates the selected element display.</summary>
        private void UpdateSelectionDisplay()
        {
            foreach(ModTagCategoryDisplay categoryDisplay in m_categoryDisplays)
            {
                ModTagContainer tagContainer = categoryDisplay.tagDisplay as ModTagContainer;
                tagContainer.tagClicked -= TagClickHandler;

                foreach(ModTagDisplay tagDisplay in tagContainer.tagDisplays)
                {
                    Toggle tagToggle = tagDisplay.GetComponent<Toggle>();
                    tagToggle.isOn = m_selectedTags.Contains(tagDisplay.data.tagName);
                }

                tagContainer.tagClicked += TagClickHandler;
            }
        }
Пример #4
0
        // ---------[ INITIALIZATION ]---------
        public void Initialize()
        {
            Debug.Assert(tagCategoryContainer != null);
            Debug.Assert(tagCategoryPrefab != null);
            Debug.Assert(tagCategoryPrefab.GetComponent <ModTagCategoryDisplay>() != null);

            ModTagContainer tagContainer = tagCategoryPrefab.GetComponent <ModTagContainer>();

            Debug.Assert(tagContainer != null,
                         "[mod.io] ModTagFilterViews require the TagCategoryPrefab to have a "
                         + "ModTagContainer component. (Any other TagCollectionDisplay type "
                         + "is incompatible.)");

            Debug.Assert(tagContainer.tagDisplayPrefab != null);

            Debug.Assert(tagContainer.tagDisplayPrefab.GetComponent <Toggle>() != null,
                         "[mod.io] ModTagFilterViews require the TagDisplayPrefab in the "
                         + "FilterView.tagCategoryPrefab to have a Toggle Component.");
        }
Пример #5
0
        // ---------[ UI FUNCTIONALITY ]---------
        private static GameObject CreateCategoryDisplayInstance(ModTagCategory category,
                                                                List <string> selectedTags,
                                                                GameObject prefab,
                                                                RectTransform container)
        {
            GameObject displayGO = GameObject.Instantiate(prefab,
                                                          new Vector3(),
                                                          Quaternion.identity,
                                                          container);

            displayGO.name = category.name;

            ModTagCategoryDisplay display = displayGO.GetComponent <ModTagCategoryDisplay>();

            display.Initialize();
            display.DisplayCategory(category);

            ToggleGroup toggleGroup = null;

            if (!category.isMultiTagCategory)
            {
                toggleGroup = display.gameObject.AddComponent <ToggleGroup>();
                toggleGroup.allowSwitchOff = true;
            }

            ModTagContainer tagContainer = displayGO.GetComponent <ModTagContainer>();

            foreach (ModTagDisplay tagDisplay in tagContainer.tagDisplays)
            {
                Toggle tagToggle = tagDisplay.GetComponent <Toggle>();
                tagToggle.isOn  = selectedTags.Contains(tagDisplay.data.tagName);
                tagToggle.group = toggleGroup;
                // TODO(@jackson): Need to register?
            }

            return(displayGO);
        }