private ConditionalHighlight[] HighlightItemPicker(ItemPicker itemPicker, ItemID targetItem) { // Get the item dropdown for this category ItemDropdown categoryDropdown = itemPicker.GetDropdown(targetItem.Category); return(HighlightItemDropdownUtility(categoryDropdown, targetItem, () => itemPicker.SelectedItem)); }
private ConditionalHighlight[] HighlightItemDropdownUtility(ItemDropdown itemDropdown, ItemID targetItem, Func <ItemID> selectedItem) { // Get the dropdown of the target category RectTransform itemDropdownTransform = itemDropdown.GetComponent <RectTransform>(); int itemIndex = itemDropdown.DropdownIndex(targetItem); // Local function used to get the rect transform of the particular item in the dropdown RectTransform DropdownItemGetter() { Transform dropdownList = itemDropdownTransform.Find("Dropdown List"); Toggle templateItem = dropdownList.GetComponentInChildren <Toggle>(true); // Search all the template item's children for the item with the same index in the name Transform itemParent = templateItem.transform.parent; for (int i = 0; i < itemParent.childCount; i++) { Transform currentChild = itemParent.GetChild(i); if (currentChild.name.Contains($"Item {itemIndex}: ")) { return(currentChild as RectTransform); } } return(null); } return(new ConditionalHighlight[] { // Highlight the dropdown in the picker new ConditionalHighlight() { predicate = () => !itemDropdown.Dropdown.IsExpanded && selectedItem.Invoke() != targetItem, target = () => itemDropdownTransform }, // Highlight the single option button in the dropdown list new ConditionalHighlight() { predicate = () => selectedItem.Invoke() != targetItem, target = DropdownItemGetter } }); }
private void FreezeUntilResourceRequestSubmitted(ItemID requestedItem, int requestQuantity) { // Grab a bunch of references to various scripts in the Notebook NotebookUI notebook = GameManager.Instance.NotebookUI; ConceptsUI concepts = notebook.GetComponentInChildren <ConceptsUI>(true); ResourceRequestEditor requestEditor = notebook.ResourceRequestEditor; ReviewedResourceRequestDisplay reviewDisplay = notebook.GetComponentInChildren <ReviewedResourceRequestDisplay>(true); TMP_InputField quantityInput = requestEditor.QuantityInput; ItemDropdown itemRequestedDropdown = requestEditor.ItemRequestedDropdown; // Freeze conversation until correct review was confirmed FreezingScheduler.FreezeUntilConditionIsMet(() => ResourceRequestWasSubmitted(requestedItem, requestQuantity), HighlightingScheduler.ClearHighlights); HighlightingScheduler.SetHighlights(HighlightNotebookButton(), HighlightNotebookTabButton(NotebookTab.Concepts), HighlightItemDropdown(itemRequestedDropdown, requestedItem)[0], HighlightItemDropdown(itemRequestedDropdown, requestedItem)[1], HighlightInputField(quantityInput, requestQuantity.ToString()), new ConditionalHighlight() { predicate = () => !reviewDisplay.gameObject.activeInHierarchy, target = () => concepts.RequestButton.transform as RectTransform }); }
private ConditionalHighlight[] HighlightItemDropdown(ItemDropdown itemDropdown, ItemID targetItem) { return(HighlightItemDropdownUtility(itemDropdown, targetItem, () => itemDropdown.SelectedItem)); }