/// <summary> /// Adds a navigation item to the end of Navigation History (FILO - First In Last Out). /// </summary> public static void AddItemToHistory(NavigationPointerData data) { if (!IsNavigationEnabled) { Debug.Log("[DoozyUI] You are trying to add a navigation item to the Navigation History, but the system is disabled. Nothing happened."); return; } InitNavigationHistory(); History.Add(data); }
public NavigationPointerData Copy() { NavigationPointerData copy = new NavigationPointerData(); copy.addToNavigationHistory = addToNavigationHistory; for (int i = 0; i < show.Count; i++) { copy.show.Add(show[i].Copy()); } for (int j = 0; j < hide.Count; j++) { copy.hide.Add(hide[j].Copy()); } return(copy); }
private void Reset() { if (DUI.DUISettings == null) { return; } allowMultipleClicks = DUI.DUISettings.UIToggle_allowMultipleClicks; disableButtonInterval = DUI.DUISettings.UIToggle_disableButtonInterval; deselectButtonOnClick = DUI.DUISettings.UIToggle_deselectButtonOnClick; useOnPointerEnter = DUI.DUISettings.UIToggle_useOnPointerEnter; onPointerEnterDisableInterval = DUI.DUISettings.UIToggle_onPointerEnterDisableInterval; onPointerEnterSoundToggleOn = DUI.DUISettings.UIToggle_onPointerEnterSoundToggleOn; onPointerEnterSoundToggleOff = DUI.DUISettings.UIToggle_onPointerEnterSoundToggleOff; customOnPointerEnterSoundToggleOn = DUI.DUISettings.UIToggle_customOnPointerEnterSoundToggleOn; customOnPointerEnterSoundToggleOff = DUI.DUISettings.UIToggle_customOnPointerEnterSoundToggleOff; onPointerEnterPunchPresetCategory = DUI.DUISettings.UIToggle_onPointerEnterPunchPresetCategory; onPointerEnterPunchPresetName = DUI.DUISettings.UIToggle_onPointerEnterPunchPresetName; loadOnPointerEnterPunchPresetAtRuntime = DUI.DUISettings.UIToggle_loadOnPointerEnterPunchPresetAtRuntime; useOnPointerExit = DUI.DUISettings.UIToggle_useOnPointerExit; onPointerExitDisableInterval = DUI.DUISettings.UIToggle_onPointerExitDisableInterval; onPointerExitSoundToggleOn = DUI.DUISettings.UIToggle_onPointerExitSoundToggleOn; onPointerExitSoundToggleOff = DUI.DUISettings.UIToggle_onPointerExitSoundToggleOff; customOnPointerExitSoundToggleOn = DUI.DUISettings.UIToggle_customOnPointerExitSoundToggleOn; customOnPointerExitSoundToggleOff = DUI.DUISettings.UIToggle_customOnPointerExitSoundToggleOff; onPointerExitPunchPresetCategory = DUI.DUISettings.UIToggle_onPointerExitPunchPresetCategory; onPointerExitPunchPresetName = DUI.DUISettings.UIToggle_onPointerExitPunchPresetName; loadOnPointerExitPunchPresetAtRuntime = DUI.DUISettings.UIToggle_loadOnPointerExitPunchPresetAtRuntime; useOnClick = DUI.DUISettings.UIToggle_useOnClickAnimations; waitForOnClick = DUI.DUISettings.UIToggle_waitForOnClickAnimation; onClickSoundToggleOn = DUI.DUISettings.UIToggle_onClickSoundToggleOn; onClickSoundToggleOff = DUI.DUISettings.UIToggle_onClickSoundToggleOff; customOnClickSoundToggleOn = DUI.DUISettings.UIToggle_customOnClickSoundToggleOn; customOnClickSoundToggleOff = DUI.DUISettings.UIToggle_customOnClickSoundToggleOff; onClickPunchPresetCategory = DUI.DUISettings.UIToggle_onClickPunchPresetCategory; onClickPunchPresetName = DUI.DUISettings.UIToggle_onClickPunchPresetName; loadOnClickPunchPresetAtRuntime = DUI.DUISettings.UIToggle_loadOnClickPunchPresetAtRuntime; onPointerEnterNavigationToggleOn = new NavigationPointerData(); onPointerEnterNavigationToggleOff = new NavigationPointerData(); onPointerExitNavigationToggleOn = new NavigationPointerData(); onPointerExitNavigationToggleOff = new NavigationPointerData(); onClickNavigationToggleOn = new NavigationPointerData(); onClickNavigationToggleOff = new NavigationPointerData(); }
/// <summary> /// Pops to specific UIElement. /// </summary> /// <param name="elementCategory">The element category.</param> /// <param name="elementName">The element name.</param> public static void PopToSpecificUIElement(string elementCategory, string elementName, bool showAndHideElements = false) { if (!IsNavigationEnabled) //check that the UINavigation is enabled { Debug.Log("[DoozyUI] You are trying to get a navigation item to the Navigation History, but the system is disabled. Nothing happened."); return; } InitNavigationHistory(); //initialize it if needed int count = History.Count; if (count == 0) { return; } //check that the History is not empty bool found = false; for (int historyIndex = History.Count; historyIndex <= 0; historyIndex--) //iterate through the History { if (History[historyIndex].show == null || History[historyIndex].show.Count == 0) { continue; } //check that this item has items that need to be shown found = false; //mark that the UIElement category and name pair have not been found in this NavigationPointerData for (int i = 0; i < History[historyIndex].show.Count; i++) { if (History[historyIndex].show[i].category.Equals(elementCategory) && History[historyIndex].show[i].name.Equals(elementName)) { found = true; //the category and name pair has been found break; //break this loop on the show list } } if (!found) //a pair has not been found in this entry --> pop it { History.RemoveAt(historyIndex); //remove the last entry from the History as it does not contain the category and name pair we are looking for } else { break; //break from the History loop as we found a pair and we no longer need to pop NavigationPointers } if (showAndHideElements) { NavigationPointerData data = UINavigation.GetLastItemFromNavigationHistory(false); UINavigation.Show(data.show); } } }
/// <summary> /// Returns the last item in the Navigation History. It removes the data from History by default. /// </summary> public static NavigationPointerData GetLastItemFromNavigationHistory(bool removeFromHistory = true) { if (!IsNavigationEnabled) { Debug.Log("[DoozyUI] You are trying to get a navigation item to the Navigation History, but the system is disabled. Nothing happened."); return(null); } InitNavigationHistory(); if (History.Count == 0) { return(new NavigationPointerData()); } NavigationPointerData data = History[History.Count - 1].Copy(); if (removeFromHistory) { History.RemoveAt(History.Count - 1); } return(data); }
/// <summary> /// Updates the Navigation History while showing and hiding the relevant UIElements. /// </summary> public static void UpdateTheNavigationHistory(NavigationPointerData navData) { if (navData == null) { return; } for (int i = 0; i < navData.show.Count; i++) { if (navData.show[i].category.Equals(DUI.CUSTOM_NAME)) { navData.show[i].category = DUI.UNCATEGORIZED_CATEGORY_NAME; } } for (int j = 0; j < navData.hide.Count; j++) { if (navData.hide[j].category.Equals(DUI.CUSTOM_NAME)) { navData.hide[j].category = DUI.UNCATEGORIZED_CATEGORY_NAME; } } visibleHideElementsList.Clear(); navData.hide = navData.hide.Where(navPointer => !navPointer.name.Equals(DUI.DEFAULT_ELEMENT_NAME)).ToList(); navData.hide = navData.hide.Where(navPointer => UIManager.GetUiElements(navPointer.name, navPointer.category).Any(element => element.isVisible)).ToList(); if (tempUIElementsList == null) { tempUIElementsList = new List <UIElement>(); } tempUIElementsList.Clear(); for (int i = 0; i < navData.hide.Count; i++) { tempUIElementsList = UIManager.GetUiElements(navData.hide[i].name, navData.hide[i].category); for (int j = 0; j < tempUIElementsList.Count; j++) { visibleHideElementsList.Add(tempUIElementsList[j]); } } Show(navData.show); Hide(navData.hide); if (navData.addToNavigationHistory) { NavigationPointerData historyNavData = new NavigationPointerData() { show = new List <NavigationPointer>(), hide = new List <NavigationPointer>() }; count = visibleHideElementsList != null ? visibleHideElementsList.Count : 0; if (count > 0) { for (int i = 0; i < count; i++) { historyNavData.show.Add(new NavigationPointer(visibleHideElementsList[i].elementCategory, visibleHideElementsList[i].elementName)); } } if (tempUIElementsList == null) { tempUIElementsList = new List <UIElement>(); } tempUIElementsList.Clear(); for (int i = 0; i < navData.show.Count; i++) { tempUIElementsList = UIManager.GetUiElements(navData.show[i].name, navData.show[i].category); for (int j = 0; j < tempUIElementsList.Count; j++) { historyNavData.hide.Add(new NavigationPointer(tempUIElementsList[j].elementCategory, tempUIElementsList[j].elementName)); } } AddItemToHistory(historyNavData); } }