private void UpdateSlider(AgeControlSlider o)
 {
     foreach (ScadMod mod in mods)
     {
         foreach (BepInExSettingsPacket p in VisibleWrappers)
         {
             if (o.transform.parent.parent.name.Equals(Util.GetName(mod, p)))
             {
                 Debug.Log("Setting value of: " + Util.GetName(mod, p) + " to: " + o.CurrentValue + " in mod: " + mod.name);
                 try
                 {
                     ((ConfigWrapper <float>)p.Wrapper).Value = o.CurrentValue;
                 } catch (Exception)
                 {
                     try
                     {
                         ((ConfigWrapper <int>)p.Wrapper).Value = (int)o.CurrentValue;
                     }
                     catch (Exception)
                     {
                         ((ConfigWrapper <double>)p.Wrapper).Value = (double)o.CurrentValue;
                     }
                 }
                 return;
             }
         }
     }
     Debug.Log("A slider exists but it doesn't have a matching field in all mods!");
 }
 private void ResetSlider(AgeControlSlider o)
 {
     foreach (ScadMod m in mods)
     {
         foreach (BepInExSettingsPacket p in VisibleWrappers)
         {
             if (o.transform.parent.parent.name.Equals(Util.GetName(m, p)))
             {
                 object q = DefaultWrappers[m][p];
                 Debug.Log("Reseting slider: " + o + " to: " + q);
                 try
                 {
                     o.CurrentValue = (float)q;
                 }
                 catch (InvalidCastException)
                 {
                     try
                     {
                         o.CurrentValue = (int)q;
                     }
                     catch (InvalidCastException)
                     {
                         o.CurrentValue = (float)(double)q;
                     }
                 }
                 o.transform.parent.parent.FindChild("30-Value").GetComponent <AgePrimitiveLabel>().Text = o.CurrentValue.ToString();
             }
         }
     }
 }
        internal void CreateSlider(ScadMod m, BepInExSettingsPacket w, SliderRange range)
        {
            Debug.Log("Creating Slider with name: " + Util.GetName(m, w));
            DynData <OptionsPanel> d           = new DynData <OptionsPanel>(optionsPanel);
            GameObject             oldObj      = d.Get <AgeControlSlider>("masterVolSlider").transform.parent.parent.gameObject;
            GameObject             sliderGroup = (GameObject)GameObject.Instantiate(oldObj);

            sliderGroup.name = Util.GetName(m, w);
            sliderGroup.transform.SetParent(modSettingsTable.transform);
            Debug.Log("Slider Group Object Created!");

            Debug.Log("OLD:");
            Debug.Log("Slider: " + d.Get <AgeControlSlider>("masterVolSlider").transform);
            Debug.Log("Parent: " + d.Get <AgeControlSlider>("masterVolSlider").transform.parent);
            Debug.Log("Parent's Parent: " + d.Get <AgeControlSlider>("masterVolSlider").transform.parent.parent);
            Debug.Log("Children");
            foreach (Transform t in d.Get <AgeControlSlider>("masterVolSlider").transform.parent.parent)
            {
                Debug.Log("Components:");
                foreach (Component _ in t.GetComponents(typeof(Component)))
                {
                    Debug.Log("- " + _);
                }
            }
            Transform slider = sliderGroup.transform.FindChild("20-SliderContainer").FindChild("10-Slider");

            slider.gameObject.name = Util.GetName(m, w) + "_Slider";
            AgeControlSlider sliderControl = slider.GetComponent <AgeControlSlider>();

            Debug.Log("Created Slider Control!");

            //slider.GetComponent<AgeTooltip>().Content = Util.GetName(m, f);

            Transform label = sliderGroup.transform.FindChild("0-Title");

            label.gameObject.name = Util.GetName(m, w) + "_Label";
            label.GetComponent <AgePrimitiveLabel>().Text = Util.GetName(m, w);

            sliderGroup.GetComponent <AgeTransform>().Position       = d.Get <AgeControlSlider>("masterVolSlider").transform.parent.parent.GetComponent <AgeTransform>().Position;
            sliderGroup.GetComponent <AgeTransform>().PixelMarginTop = VisibleWrappers.Count * (settingSpacing + sliderGroup.GetComponent <AgeTransform>().Height);
            Debug.Log("Setup Slider Location!");

            sliderControl.MinValue  = range.Min;
            sliderControl.MaxValue  = range.Max;
            sliderControl.Increment = range.Increment;
            if (w.Type.Equals(typeof(int)))
            {
                sliderControl.CurrentValue = ((ConfigWrapper <int>)w.Wrapper).Value;
            }
            else if (w.Type.Equals(typeof(float)))
            {
                sliderControl.CurrentValue = ((ConfigWrapper <float>)w.Wrapper).Value;
            }
            else if (w.Type.Equals(typeof(double)))
            {
                sliderControl.CurrentValue = (float)((ConfigWrapper <double>)w.Wrapper).Value;
            }
            Debug.Log("Setup Slider Control!");

            sliderControl.AgeTransform.Position = d.Get <AgeControlSlider>("masterVolSlider").AgeTransform.Position;
            // Set to have same stats as old sliders
            sliderGroup.transform.FindChild("20-SliderContainer").GetComponent <AgeTransform>().PixelMarginLeft   = 36;
            sliderGroup.transform.FindChild("20-SliderContainer").GetComponent <AgeTransform>().PixelMarginRight  = 36;
            sliderGroup.transform.FindChild("20-SliderContainer").GetComponent <AgeTransform>().PixelMarginBottom = 6;
            //sliderGroup.transform.FindChild("20-SliderContainer").GetComponent<AgeTransform>().Width = 612;
            sliderGroup.transform.FindChild("10-SliderBg").GetComponent <AgeTransform>().PixelMarginBottom = 6;
            sliderGroup.transform.FindChild("30-Value").GetComponent <AgePrimitiveLabel>().Text            = sliderControl.CurrentValue.ToString();
            label.GetComponent <AgePrimitiveLabel>().AgeTransform.Height          = 42;
            label.GetComponent <AgePrimitiveLabel>().AgeTransform.PixelMarginLeft = 8;
            sliderControl.AgeTransform.GetParent().X     = 36;
            sliderControl.AgeTransform.GetParent().Y     = 36;
            sliderControl.AgeTransform.GetParent().Width = d.Get <AgeControlSlider>("masterVolSlider").AgeTransform.GetParent().Width;
            sliderGroup.transform.FindChild("30-Value").GetComponent <AgeTransform>().Height = 42;


            sliderControl.OnDragMethod = "OnSliderDragged";
            sliderControl.OnDragObject = transform.gameObject;
            Debug.Log("Arm - Method: " + sliderControl.OnArmMethod + " GameObject: " + sliderControl.OnArmObject);
            Debug.Log("Drag - Method: " + sliderControl.OnDragMethod + " GameObject: " + sliderControl.OnDragObject);
            Debug.Log("Release - Method: " + sliderControl.OnReleaseMethod + " GameObject: " + sliderControl.OnReleaseObject);


            VisibleWrappers.Add(w);

            sliders.Add(sliderControl);
        }