// ------------------------------------------------------------------------------------
        // Initialization

        // Set up the selection toggle
        public void Setup(MenuListEntry input)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Setting up selection toggle"); // Write to console
            owner = input;                                                                            // Set owner as list entry
            toggleButton.onClick.RemoveAllListeners();                                                // Remove listeners
            toggleButton.onClick.AddListener(delegate { OnButtonClick(); });                          // Add listener
        }
Exemple #2
0
        // ------------------------------------------------------------------------------------
        // Buttons

        // Called every time a list entry is clicked (button listener)
        public void OnListEntryClick(MenuListEntry clicked)
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Clicked: List entry"); // Write to console
            if (clicked.entryData.id.currentLevel < 3)                                        // Selecting any level with children
            {
                ClearList();                                                                  // Clear the list
                GenerateBreadcrumb(clicked.entryData);                                        // Generate a new breadcrumb
                MenuTestEntry id = CloneMenuTestEntry(clicked.entryData.id);                  // Clone the entry data of the clicked entry
                id.currentLevel++;                                                            // Increment current level
                selectedId = id;                                                              // Set selected id
                GenerateList();                                                               // Generate a new list
                CheckRunButtonStatus();                                                       // Check run button status
            }
            else // Selecting a single test (no children)
            {
                MenuTestEntry id = CloneMenuTestEntry(clicked.entryData.id);          // Clone the entry data of the clicked entry
                id.currentLevel++;                                                    // Increment current level
                selectedId = id;                                                      // Set selected id
                if (selectedTest != null)                                             // If there is a selected test
                {
                    selectedTest.mainButton.GetComponent <Image>().color = colors[2]; // Reset its color
                }
                selectedTest = clicked;                                               // Set this as selected test
                selectedTest.mainButton.GetComponent <Image>().color = colors[1];     // Set its color
                CheckViewButtonStatus();                                              // Check view button status
            }
        }
Exemple #3
0
        // ------------------------------------------------------------------------------------
        // List Management

        // Generate a new list
        public void GenerateList()
        {
            MenuEntryData[] itemList = TestStructure.Instance.GetEntries(selectedId); // Get entries based on selected
            if (itemList != null)
            {
                list.scrollRect.enabled = false;                                              // Disable scrollRect to update transform correctly
                Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Generating list"); // Write to console
                for (int i = 0; i < itemList.Length; i++)
                {
                    GameObject go = Instantiate(menuListEntryPrefab, list.contentRect, false);         // Create instance
                    list.entryList.Add(go);                                                            // Add to object list
                    RectTransform goRect = go.GetComponent <RectTransform>();                          // Get rect
                    goRect.anchoredPosition = new Vector2(0, entryHeight);                             // Set position
                    MenuListEntry newEntry = go.GetComponent <MenuListEntry>();                        // Get script reference
                    newEntry.Setup(itemList[i]);                                                       // Setup
                    entryHeight -= goRect.sizeDelta.y;                                                 // Add to position tracker
                }
                list.contentRect.sizeDelta = new Vector2(list.contentRect.sizeDelta.x, -entryHeight);  // Set content rect size
                list.scrollRect.enabled    = true;                                                     // Enable scrollRect to update transform correctly
                Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Finished generating list"); // Write to console
            }
            else
            {
                Console.Instance.Write(DebugLevel.Critical, MessageLevel.Log, "Failed to generate list"); // Write to console
            }
            RefreshMenu();
        }
Exemple #4
0
 // Check status of view button and update (called when navigating breadcrumb and selecting at level4 (test))
 public void CheckViewButtonStatus()
 {
     Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Checking view button status"); // Write to console
     if (selectedId.currentLevel == 4)                                                         // If selecting a test
     {
         actions.view.interactable = true;                                                     // Set view button active
     }
     else
     {
         actions.view.interactable = false; // Set view button inactive
         selectedTest = null;               // Null selected test
     }
 }