private void UpdateMenu(List <string> uncollapsedObjects = null) { Dictionary <IActionProvider, List <Base.ActionMetadata> > actionsMetadata = Base.ActionsManager.Instance.GetAllActions(); foreach (KeyValuePair <IActionProvider, List <Base.ActionMetadata> > keyval in actionsMetadata) { CollapsableMenu collapsableMenu = Instantiate(CollapsablePrefab, Content.transform).GetComponent <CollapsableMenu>(); collapsableMenu.SetLabel(keyval.Key.GetProviderName()); if (uncollapsedObjects != null && uncollapsedObjects.Contains(keyval.Key.GetProviderName())) { collapsableMenu.Collapsed = false; } else { collapsableMenu.Collapsed = true; } foreach (Base.ActionMetadata am in keyval.Value) { ActionButtonWithIcon btn = Instantiate(ButtonPrefab, collapsableMenu.Content.transform).GetComponent <ActionButtonWithIcon>(); ButtonWithTooltip btnTooltip = btn.GetComponent <ButtonWithTooltip>(); btn.transform.localScale = new Vector3(1, 1, 1); btn.SetLabel(am.Name); btn.Icon.sprite = AREditorResources.Instance.Action; if (am.Disabled) { btn.SetInteractable(false); btnTooltip.SetInteractivity(false, am.Problem); } else { RequestResult result = CheckActionParameters(am); if (!result.Success) { btn.SetInteractable(false); btnTooltip.SetInteractivity(false, $"Action {am.Name} could not be created\n{result.Message}"); } else if (!string.IsNullOrEmpty(am.Description)) { btnTooltip.SetDescription(am.Description); } } btn.Button.onClick.AddListener(() => CreateNewAction(am.Name, keyval.Key)); } } }
public async void UpdateMenu() { scrollableContent.GetComponent <VerticalLayoutGroup>().enabled = true; Base.ActionPoint actionPoint; if (CurrentActionPoint == null) { return; } else { actionPoint = CurrentActionPoint.GetComponent <Base.ActionPoint>(); } foreach (RectTransform o in dynamicContent.GetComponentsInChildren <RectTransform>()) { if (o.gameObject.tag != "Persistent") { Destroy(o.gameObject); } } SetHeader(actionPoint.Data.Name); if (actionPoint.Parent != null) { ActionObjectType.text = actionPoint.Parent.GetName(); } else { ActionObjectType.text = "Global action point"; } Dictionary <IActionProvider, List <Base.ActionMetadata> > actionsMetadata; if (actionPoint.Parent == null) { actionsMetadata = Base.ActionsManager.Instance.GetAllFreeActions(); } else { Base.ActionObject parentActionObject = actionPoint.Parent.GetActionObject(); if (parentActionObject == null) { actionsMetadata = Base.ActionsManager.Instance.GetAllFreeActions(); } else { actionsMetadata = Base.ActionsManager.Instance.GetAllActionsOfObject(parentActionObject); } } foreach (KeyValuePair <IActionProvider, List <Base.ActionMetadata> > keyval in actionsMetadata) { CollapsableMenu collapsableMenu = Instantiate(CollapsablePrefab, dynamicContent.transform).GetComponent <CollapsableMenu>(); collapsableMenu.SetLabel(keyval.Key.GetProviderName()); collapsableMenu.Collapsed = true; foreach (Base.ActionMetadata am in keyval.Value) { ActionButton btn = Instantiate(Base.GameManager.Instance.ButtonPrefab, collapsableMenu.Content.transform).GetComponent <ActionButton>(); btn.transform.localScale = new Vector3(1, 1, 1); btn.SetLabel(am.Name); if (am.Disabled) { CreateTooltip(am.Problem, btn); btn.Button.interactable = false; } else if (!string.IsNullOrEmpty(am.Description)) { CreateTooltip(am.Description, btn); } btn.Button.onClick.AddListener(() => ShowAddNewActionDialog(am.Name, keyval.Key)); } } UpdateLockedBtns(CurrentActionPoint.Locked); if (CurrentActionPoint.Parent == null) { UntieBtn.onClick.RemoveAllListeners(); UntieBtn.onClick.AddListener(() => AssignToParent()); UntieBtnTooltip.ShowAlternativeDescription(); } else { UntieBtn.onClick.RemoveAllListeners(); UntieBtn.onClick.AddListener(() => ShowUntieActionPointDialog()); UntieBtnTooltip.ShowDefaultDescription(); } RemoveBtn.SetInteractivity(await GameManager.Instance.RemoveActionPoint(CurrentActionPoint.Data.Id, true)); ExpandBtn.gameObject.SetActive(CurrentActionPoint.ActionsCollapsed); CollapseBtn.gameObject.SetActive(!CurrentActionPoint.ActionsCollapsed); }