private void PopulateCategories(string categoryFilter = null) { newCardCategoryOptions = new List <TMPro.TMP_Dropdown.OptionData>(); categoryFilterOptions = new List <TMPro.TMP_Dropdown.OptionData>(); cardLibraryUI.categoryDropdown.ClearOptions(); newCardUI.newCardCategoryDropdown.ClearOptions(); bool needsCustomCategory = true; foreach (string category in behaviorSystem.GetCategories()) { if (category == BehaviorCards.CUSTOM_CATEGORY) { needsCustomCategory = false; } newCardCategoryOptions.Add(new TMPro.TMP_Dropdown.OptionData(category)); categoryFilterOptions.Add(new TMPro.TMP_Dropdown.OptionData(category)); } if (needsCustomCategory) { newCardCategoryOptions.Add(new TMPro.TMP_Dropdown.OptionData(BehaviorCards.CUSTOM_CATEGORY)); categoryFilterOptions.Add(new TMPro.TMP_Dropdown.OptionData(BehaviorCards.CUSTOM_CATEGORY)); } newCardUI.newCardCategoryDropdown.AddOptions(newCardCategoryOptions); categoryFilterOptions.Insert(0, new TMPro.TMP_Dropdown.OptionData(ALL_CATEGORIES_OPTION)); cardLibraryUI.categoryDropdown.AddOptions(categoryFilterOptions); if (categoryFilter == null) { cardLibraryUI.categoryDropdown.value = 0; } else { cardLibraryUI.categoryDropdown.value = categoryFilterOptions.FindIndex((option) => option.text == categoryFilter); } MatchNewCardCategoryToFilter(); }
public override void Populate(ICardModel card, bool withDetail = true) { if (card == null || !card.IsValid()) { return; } base.Populate(card, withDetail); nameInput.text = card.GetTitle(); descriptionInput.text = card.GetDescription(); categoryDropdown.ClearOptions(); categoryOptions = new List <TMPro.TMP_Dropdown.OptionData>(); bool needsCustomCategory = true; foreach (string category in behaviorSystem.GetCategories()) { if (category == BehaviorCards.CUSTOM_CATEGORY) { needsCustomCategory = false; } categoryOptions.Add(new TMPro.TMP_Dropdown.OptionData(category)); } if (needsCustomCategory) { categoryOptions.Add(new TMPro.TMP_Dropdown.OptionData(BehaviorCards.CUSTOM_CATEGORY)); } categoryDropdown.AddOptions(categoryOptions); // Hack: for now, assume that custom cards only have one category string cardCategory = new List <string>(card.GetCategories())[0]; categoryDropdown.value = categoryOptions.FindIndex((option) => option.text == cardCategory); bool canEdit = !card.GetUnassignedBehaviorItem().IsBehaviorReadOnly(); nameInput.interactable = canEdit; descriptionInput.interactable = canEdit; categoryDropdown.interactable = canEdit; editIconButton.gameObject.SetActive(canEdit); }