private void CreateSlidersFromGroup(bool hasChildren, ref SliderNode curSliderNode, ref SliderGroupContainer curGroup, string curDir, string curNodeName, int layer, bool tab = false)
        {
            List <SliderHandler> sliderHandlerList = new List <SliderHandler>();
            //create the list of sliders from the current slider group and add them to the modify window.
            var    enum2 = curSliderNode.sliderList.GetEnumerator();
            Slider s     = null;

            try
            {
                while (enum2.MoveNext())
                {
                    s = enum2.Current.Value;
                    string _sName = enum2.Current.Key;
                    if (s.sliderID.Contains(M3DHandler._neg))
                    {
                        continue;
                    }
                    if (curSliderNode.sliderList.ContainsKey(s.sliderName + M3DHandler._neg)) // does the slider have a negative counterpart?
                    {
                        //Debug.Log("Found negative for slider: " + s.sliderName);
                        Slider _temp;

                        if (curSliderNode.sliderList.TryGetValue(s.sliderName + M3DHandler._neg, out _temp)) //access the _temp value.
                        {
                            sliderHandlerList.Add(modifyWindow.AddSlider(curGroup, s, _temp, Convert.ToSingle(s.sliderValue) - Convert.ToSingle(_temp.sliderValue)));
                        }
                        else// temp value doesn't exist, skipping.
                        {
                            sliderHandlerList.Add(modifyWindow.AddSlider(curGroup, s, Convert.ToSingle(s.sliderValue)));
                        }
                        //Debug.Log("negative slider name: " + _temp.sliderName);
                    }
                    else
                    {
                        sliderHandlerList.Add(modifyWindow.AddSlider(curGroup, s, Convert.ToSingle(s.sliderValue)));
                    }
                    //Debug.Log("Created a Slider.");
                }
            }
            catch (Exception e)
            {
                Debug.Log(e.ToString());
                Debug.Log(s.sliderValue.GetType().ToString());
            }
            finally
            {
                enum2.Dispose();
            }

            if (hasChildren)// if it has children, start creating a list of slider-groups under the current directory, after adding the sliders to the modify window.
            {
                CreateSliderGroupTree(curSliderNode.sliderNodeList, curDir + curNodeName + "/", layer + 1, curGroup.AddSliderGroup(sliderGroupPrefab, curDir + curNodeName + "/", curNodeName, curSliderNode.sliderNodeList.Count).SetSliders(sliderHandlerList.ToArray(), modifyWindow));
            }
            else //just add the sliders to the modify window.
            {
                curGroup.AddSliderGroup(sliderGroupPrefab, curDir + curNodeName + "/", curNodeName).SetSliders(sliderHandlerList.ToArray(), modifyWindow);
            }
            sliderHandlerList.Clear();
        }
        /// <summary>
        /// Creates the Slider group GUI elements in their proper hierarchy.
        /// </summary>
        /// <param name="dict">Provide this with the appropriate Slider Tree's Dictionary.</param>
        private void CreateSliderGroupTree(Dictionary <String, SliderNode> dict, string curDir = ">/", int layer = 0, SliderGroupContainer curGroup = null)
        {
            if (curGroup != null)
            {
                curGroup.EnableExpanding();
            }
            var enumerator = dict.GetEnumerator();
            int i          = 0;

            try
            {
                while (enumerator.MoveNext())
                {
                    numTimes += 1;
                    SliderNode curSliderNode = enumerator.Current.Value;
                    string     curNodeName   = enumerator.Current.Key;

                    if (layer == 0)
                    {
                        //start by running through the list of lists, and apply to tabs.
                        if (groupContainers.Length >= dict.Count)//assume this is true for now.
                        {
                            if (curSliderNode.sliderNodeList.Count > 0)
                            {
                                CreateSlidersFromGroup(false, ref curSliderNode, ref groupContainers[i], curDir, curNodeName, layer);
                                CreateSliderGroupTree(curSliderNode.sliderNodeList, curDir + curNodeName + "/", 1, groupContainers[i]);
                                //curGroup.AddSliderGroup(sliderGroupPrefab, curDir + curNodeName + "/", curNodeName).SetSliders(sliderHandlerList.ToArray(), modifyWindow)
                            }

                            i++;
                        }
                    }
                    else
                    {
                        if (curSliderNode.sliderNodeList.Count > 0)// if the slider node list has sub slider groups...
                        {
                            CreateSlidersFromGroup(true, ref curSliderNode, ref curGroup, curDir, curNodeName, layer);
                        }
                        else
                        {
                            CreateSlidersFromGroup(false, ref curSliderNode, ref curGroup, curDir, curNodeName, layer);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Debug.Log(e.ToString());
            }
            finally
            {
                enumerator.Dispose();
            }
        }
Beispiel #3
0
        internal List <Slider> CreateAndReturnCompleteSliderList()
        {
            List <Slider> newList = new List <Slider>();

            // build the list:

            newList = sliderList.Values.ToList();



            var enumerator = sliderNodeList.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    SliderNode value = enumerator.Current.Value;
                    string     key   = enumerator.Current.Key;
                    //var element = enumerator.Current;
                    // loop body goes here



                    //create the list from each subnode
                    List <Slider> listFromNode = value.CreateAndReturnCompleteSliderList();

                    // then, add the objects from the list to our big list.
                    for (int i = 0; i < listFromNode.Count; i++)
                    {
                        newList.Add(listFromNode[i]);
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
            }

            return(newList);
        }
Beispiel #4
0
        // to-do: add function that lets us grab values from the tree and write values to the tree, with a provided DIR.
        // also need to be able to get a list of all subnodes, or a list of subnodes in a specific DIR.

        /// <summary>
        /// Iterative creation of a list by walking through each subnode and adding it to a list. Returns the list of Sliders.
        /// </summary>
        /// <returns></returns>
        public void UpdateCompleteSliderList()
        {
            List <Slider> newList = new List <Slider>();

            // build the list:

            var enumerator = sliderNodeList.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    SliderNode value = enumerator.Current.Value;
                    string     key   = enumerator.Current.Key;
                    //var element = enumerator.Current;
                    // loop body goes here

                    //create the list from each subnode
                    List <Slider> listFromNode = value.CreateAndReturnCompleteSliderList();

                    // then, add the objects from the list to our big list.
                    for (int i = 0; i < listFromNode.Count; i++)
                    {
                        newList.Add(listFromNode[i].SetIndexInTree(i));
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError(e.ToString());
            }
            finally
            {
                enumerator.Dispose();
            }

            completeSliderList = newList;
        }
Beispiel #5
0
 public void AddSliderNode(string name, SliderNode newSliderNode)
 {
     sliderNodeList.Add(name, newSliderNode);
 }