private void SetProjFilterBtnStates() { ViRMA_UIScrollable[] scrollableUis = ui_projectedFilters.GetComponentsInChildren <ViRMA_UIScrollable>(); for (int i = 0; i < scrollableUis.Length; i++) { Button[] buttons = scrollableUis[i].GetComponentsInChildren <Button>(); for (int j = 0; j < buttons.Length; j++) { GameObject buttonObj = buttons[j].gameObject; buttonObj.transform.localScale = Vector3.one * 0.9f; ViRMA_UiElement vrUiElement = buttonObj.GetComponent <ViRMA_UiElement>(); if (i == 0) { // x if (j == buttons.Length - 1) { buttonObj.transform.localScale = Vector3.one; vrUiElement.GenerateBtnDefaults(ViRMA_Colors.axisRed, Color.white); buttonObj.GetComponent <Button>().onClick.AddListener(() => RemoveAxis(buttonObj)); } else { vrUiElement.GenerateBtnDefaults(ViRMA_Colors.BrightenColor(ViRMA_Colors.axisRed), Color.white); buttonObj.GetComponent <Button>().onClick.AddListener(() => RollUpAxis(buttonObj)); } } else if (i == 1) { // y if (j == buttons.Length - 1) { buttonObj.transform.localScale = Vector3.one; vrUiElement.GenerateBtnDefaults(ViRMA_Colors.axisGreen, Color.white); buttonObj.GetComponent <Button>().onClick.AddListener(() => RemoveAxis(buttonObj)); } else { vrUiElement.GenerateBtnDefaults(ViRMA_Colors.BrightenColor(ViRMA_Colors.axisGreen), Color.white); buttonObj.GetComponent <Button>().onClick.AddListener(() => RollUpAxis(buttonObj)); } } else if (i == 2) { // z if (j == buttons.Length - 1) { buttonObj.transform.localScale = Vector3.one; vrUiElement.GenerateBtnDefaults(ViRMA_Colors.axisBlue, Color.white); buttonObj.GetComponent <Button>().onClick.AddListener(() => RemoveAxis(buttonObj)); } else { vrUiElement.GenerateBtnDefaults(ViRMA_Colors.BrightenColor(ViRMA_Colors.axisBlue), Color.white); buttonObj.GetComponent <Button>().onClick.AddListener(() => RollUpAxis(buttonObj)); } } } } }
public void ToggleTimeOption(ViRMA_UiElement uiElement) { if (uiElement.buttonData != null) { Tag timeTagData = (Tag)uiElement.buttonData; if (uiElement.isToggled) { globals.queryController.buildingQuery.RemoveFilter(timeTagData.Id, "tag", timeTagData.Parent.Id); } else { globals.queryController.buildingQuery.AddFilter(timeTagData.Id, "tag", timeTagData.Parent.Id); } } }
public void SetBtnDefaultState() { foreach (Button key in keys) { key.onClick.AddListener(() => SubmitKey(key)); Text keyText = key.GetComponentInChildren<Text>(); Image keyBackground = key.GetComponent<Image>(); ViRMA_UiElement virmaBtn = key.GetComponent<ViRMA_UiElement>(); Color32 bgCol; Color32 textCol; if (key.name == "CLEAR") { bgCol = ViRMA_Colors.flatOrange; textCol = Color.white; } else if (key.name == "CLOSE") { bgCol = new Color32(192, 57, 43, 255); textCol = Color.white; } else if (key.name == "BACKSPACE") { bgCol = ViRMA_Colors.darkBlue; textCol = Color.white; } else if (key.name == "MOVE") { bgCol = ViRMA_Colors.grey; textCol = Color.white; } else if (key.name == "SUBMIT") { bgCol = new Color32(39, 174, 96, 255); textCol = Color.white; } else { bgCol = ViRMA_Colors.darkBlue; textCol = Color.white; } virmaBtn.GenerateBtnDefaults(bgCol, textCol); } }
// time picker private IEnumerator SetupTimePicker() { // current targset time picker tagsets List <string> timeTagsets = new List <string> { "Day of week (string)", "Month (string)", "Year", "Hour", "Day within month" }; // get all time tagsets corresponding to list above List <Tag> timeTagsetsData = new List <Tag>(); yield return(StartCoroutine(ViRMA_APIController.GetTagset("", (tagsetsData) => { for (int i = tagsetsData.Count - 1; i > -1; i--) { if (!timeTagsets.Contains(tagsetsData[i].Label)) { tagsetsData.RemoveAt(i); } } timeTagsetsData = tagsetsData; }))); // populate tagsets with their children foreach (Tag tagsetData in timeTagsetsData) { yield return(StartCoroutine(ViRMA_APIController.GetTagset(tagsetData.Id.ToString(), (tagData) => { tagsetData.Children = tagData; }))); } foreach (Tag timeTagset in timeTagsetsData) { // generate day of the week options if (timeTagset.Label == "Day of week (string)") { foreach (Transform weekdayObj in ui_weekdays.transform) { ViRMA_UiElement uiElement = weekdayObj.GetComponent <ViRMA_UiElement>(); allTimeOptions.Add(uiElement); string weekdayLabel = weekdayObj.GetComponentInChildren <Text>().text; foreach (Tag weekdayTag in timeTagset.Children) { if (weekdayTag.Label.Substring(0, 3) == weekdayLabel) { uiElement.buttonData = weekdayTag; weekdayObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement)); } } } } // generate hour options if (timeTagset.Label == "Hour") { foreach (Transform hourObj in ui_hours.transform) { ViRMA_UiElement uiElement = hourObj.GetComponent <ViRMA_UiElement>(); allTimeOptions.Add(uiElement); string hourLabel = hourObj.GetComponentInChildren <Text>().text; int hour = int.Parse(hourLabel.Substring(0, hourLabel.IndexOf(":"))); foreach (Tag hourTag in timeTagset.Children) { if (hourTag.Label == hour.ToString()) { uiElement.buttonData = hourTag; hourObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement)); } } } } // generate date options if (timeTagset.Label == "Day within month") { foreach (Transform dateObj in ui_dates.transform) { ViRMA_UiElement uiElement = dateObj.GetComponent <ViRMA_UiElement>(); allTimeOptions.Add(uiElement); string dateLabel = dateObj.GetComponentInChildren <Text>().text; int date = int.Parse(dateLabel); foreach (Tag dateTag in timeTagset.Children) { if (dateTag.Label == date.ToString()) { uiElement.buttonData = dateTag; dateObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement)); } } } } // generate month options if (timeTagset.Label == "Month (string)") { foreach (Transform monthObj in ui_months.transform) { ViRMA_UiElement uiElement = monthObj.GetComponent <ViRMA_UiElement>(); allTimeOptions.Add(uiElement); string monthLabel = monthObj.GetComponentInChildren <Text>().text; foreach (Tag monthTag in timeTagset.Children) { string shortMonthLabel = monthTag.Label.Substring(0, 3); if (shortMonthLabel == monthLabel) { uiElement.buttonData = monthTag; monthObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement)); } } } } // generate year options if (timeTagset.Label == "Year") { foreach (Transform yearObj in ui_years.transform) { ViRMA_UiElement uiElement = yearObj.GetComponent <ViRMA_UiElement>(); allTimeOptions.Add(uiElement); string yearLabel = yearObj.GetComponentInChildren <Text>().text; foreach (Tag yearTag in timeTagset.Children) { if (yearLabel == yearTag.Label) { uiElement.buttonData = yearTag; yearObj.GetComponent <Button>().onClick.AddListener(() => ToggleTimeOption(uiElement)); } } } } // if any time options do not exist in the DB, then reflect that in the button style foreach (ViRMA_UiElement timeOption in allTimeOptions) { if (timeOption.buttonData == null) { timeOption.GenerateBtnDefaults(ViRMA_Colors.lightGrey, Color.white, true); } } } }