Beispiel #1
0
        internal InputOption(GameObject parentGO, ModSettingInt modSettingInt) : this(parentGO, (ModSetting)modSettingInt)
        {
            InputField.SetText(modSettingInt.GetValue().ToString());

            InputField.characterValidation = InputField.CharacterValidation.Integer;
            InputField.AddOnValueChangedEvent(value =>
            {
                //InputField.SetText(value);
                if (!long.TryParse(value, out var i))
                {
                    i = 0;
                }
                if (modSettingInt.maxValue.HasValue && i > modSettingInt.maxValue.Value)
                {
                    i = modSettingInt.maxValue.Value;
                }
                else if (modSettingInt.minValue.HasValue && i < modSettingInt.minValue.Value)
                {
                    i = modSettingInt.minValue.Value;
                }
                modSettingInt.SetValue(i);
            });
            modSettingInt.OnInitialized.InvokeAll(this);
            Button.AddOnClick(() =>
            {
                InputField.SetText(modSettingInt.GetDefaultValue().ToString());
            });
        }
        public SliderOption(GameObject parentGO, ModSettingInt modSettingInt) : this(parentGO, (ModSetting)modSettingInt)
        {
            slider.value    = modSettingInt.value;
            slider.minValue = (long)modSettingInt.minValue;
            slider.maxValue = (long)modSettingInt.maxValue;

            slider.onValueChanged.AddListener(value => modSettingInt.SetValue((long)value));
        }
 public InputOption(GameObject parentGO, ModSettingInt modSettingInt) : this(parentGO, (ModSetting)modSettingInt)
 {
     inputField.characterValidation = InputField.CharacterValidation.Integer;
     inputField.AddSubmitEvent(value =>
     {
         var i = int.Parse(value);
         if (modSettingInt.maxValue.HasValue && i > modSettingInt.maxValue.Value)
         {
             i = (int)modSettingInt.maxValue.Value;
         }
         else if (modSettingInt.minValue.HasValue && i < modSettingInt.minValue.Value)
         {
             i = (int)modSettingInt.minValue.Value;
         }
         inputField.SetText(i.ToString());
         modSettingInt.SetValue(i);
     });
 }
Beispiel #4
0
        internal SliderOption(GameObject parentGO, ModSettingInt modSettingInt) : this(parentGO, (ModSetting)modSettingInt)
        {
            Slider.value    = modSettingInt.value;
            InputField.text = modSettingInt.value.ToString();
            Slider.minValue = (long)modSettingInt.minValue;
            Slider.maxValue = (long)modSettingInt.maxValue;

            Slider.onValueChanged.AddListener(value =>
            {
                var l = (long)value;
                modSettingInt.SetValue(l);
                if (long.TryParse(InputField.text, out var num) && num != l)
                {
                    InputField.SetText(l.ToString());
                }
            });
            InputField.onValueChanged.AddListener(value =>
            {
                if (long.TryParse(InputField.text, out var l))
                {
                    if (l > modSettingInt.maxValue)
                    {
                        l = (long)modSettingInt.maxValue;
                    }
                    else if (l < modSettingInt.minValue)
                    {
                        l = (long)modSettingInt.minValue;
                    }
                    modSettingInt.SetValue(l);
                    if ((long)Slider.value != l)
                    {
                        Slider.Set(l);
                    }
                }
            });
            InputField.characterValidation = InputField.CharacterValidation.Integer;

            Button.AddOnClick(() =>
            {
                InputField.SetText(modSettingInt.GetDefaultValue().ToString());
            });

            modSettingInt.OnInitialized.InvokeAll(this);
        }