/// <summary> /// Pouplates the list from new parent node. /// </summary> /// <param name="parentNode">Parent node.</param> /// <param name="newStepIndex">Step index stored in the Entry struct. This is used to find the corresponding scene in the AcquireModuleManager.</param> /// <param name="currentIndex">Number used solely to display the a number next to the name of the step in the List View.</param> private void PopulateListFromNewParent(XmlNode parentNode, ref int newStepIndex, ref int currentIndex) { XmlNodeList stepList = parentNode.ChildNodes; foreach (XmlNode item in stepList) { StepsListEntry newEntry = new StepsListEntry(); string shownStepIndex = ""; if (showListViewIndex) { shownStepIndex = currentIndex.ToString() + ". "; } switch (item.Name) { case "step": newEntry.isSectionParent = false; newEntry.stepIndex = newStepIndex; newEntry.uiText.listViewText = shownStepIndex + item.SelectSingleNode("listText").InnerText; newEntry.uiText.descriptionViewText = item.SelectSingleNode("descriptionText").InnerText; acquireStepList.Add(newEntry); currentIndex++; newStepIndex++; break; case "section": newEntry.isSectionParent = true; newEntry.stepIndex = -1; newEntry.uiText.listViewText = item.SelectSingleNode("listText").InnerText; acquireStepList.Add(newEntry); PopulateListFromNewParent(item, ref newStepIndex, ref currentIndex); break; case "moduleTitle": newEntry.isSectionParent = true; newEntry.stepIndex = -1; newEntry.uiText.listViewText = item.InnerText; acquireStepList.Add(newEntry); break; case "listText": case "popupWindow": break; default: Debug.LogError("Unrecognized XmlNode value. Program doesn't support value of :" + item.Name); break; } } }
private void InitializeAcquireListView() { int acquireListCount = acquireStepList.Count; // Setting the height of the list view to match the amount of buttons I will add to it. RectTransform listViewVerticalLayoutGroup = UIManager.s_instance.listViewContentParent; Vector2 newWidthHeight = listViewVerticalLayoutGroup.sizeDelta; //newWidthHeight.x = defaultListViewButton.GetComponent<RectTransform>().sizeDelta.x; newWidthHeight.y = UIManager.s_instance.defaultListViewButton.GetComponent <RectTransform>().sizeDelta.y *acquireListCount; listViewVerticalLayoutGroup.sizeDelta = newWidthHeight; // Creating new buttons out the dictionary and stuffing them in the vertical layout group for (int i = 0; i < acquireListCount; i++) { // Index 0 is special because it is the title for our list view if (i == 0) { ListViewButton newListViewSectionTitle = Instantiate(UIManager.s_instance.defaultListViewModuleTitle).GetComponent <ListViewButton>(); newListViewSectionTitle.listIndex = 0; newListViewSectionTitle.transform.SetParent(listViewVerticalLayoutGroup, false); newListViewSectionTitle.childText.text = acquireStepList[0].uiText.listViewText; continue; } StepsListEntry temp = acquireStepList[i]; if (temp.isSectionParent) { ListViewButton newListViewSectionTitle = Instantiate(defaultListViewSectionTitle).GetComponent <ListViewButton>(); newListViewSectionTitle.listIndex = i; newListViewSectionTitle.transform.SetParent(listViewVerticalLayoutGroup, false); newListViewSectionTitle.childText.text = /*contextIndentation + contextIndentation +*/ temp.uiText.listViewText; } else { ListViewButton newListViewButton = Instantiate(UIManager.s_instance.defaultListViewButton).GetComponent <ListViewButton>(); newListViewButton.listIndex = i; newListViewButton.transform.SetParent(listViewVerticalLayoutGroup, false); newListViewButton.childText.text = temp.uiText.listViewText; newListViewButton.childText.color = Color.grey; newListViewButton.GetComponent <Button>().interactable = false; } } }