Beispiel #1
0
        protected static void PushFloatSetting(
            SettingScope scope,
            SettingProtection protectionLevel,
            string label,
            string name,
            float defaultVal,
            float minVal = float.MinValue,
            float maxVal = float.MaxValue,
            Func <float, string> translator = null,
            string postFix    = "",
            string maskerName = "",
            Func <SettingBase, bool> maskingEvaluator = null)
        {
            SettingBase newSetting = new FloatSetting(
                scope,
                protectionLevel,
                label,
                name,
                defaultVal,
                minVal: minVal,
                maxVal: maxVal,
                translator: translator,
                postFix: postFix);

            settings.Add(newSetting);
            nameSettingsMap.Add(name, newSetting);

            if (!string.IsNullOrEmpty(maskerName))
            {
                AddToMaskerMap(maskerName, name, maskingEvaluator);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Appends a <paramref name="setting"/> in the form <code>SettingName = SettingValue</code>.
        /// The setting will be written only if the value is different from the default value in the
        /// corresponding <paramref name="parameter"/>.
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="parameter"></param>
        public LoliCodeWriter AppendSetting(BlockSetting setting, BlockParameter parameter = null, int spaces = 2)
        {
            if (parameter == null)
            {
                AppendLine($"{setting.Name} = {GetSettingValue(setting)}", spaces);
                return(this);
            }

            var isDefaultValue = setting.FixedSetting switch
            {
                StringSetting x => x.Value == (parameter as StringParameter).DefaultValue,
                IntSetting x => x.Value == (parameter as IntParameter).DefaultValue,
                FloatSetting x => x.Value == (parameter as FloatParameter).DefaultValue,
                BoolSetting x => x.Value == (parameter as BoolParameter).DefaultValue,
                ByteArraySetting x => Compare(x.Value, (parameter as ByteArrayParameter).DefaultValue),
                ListOfStringsSetting x => Compare(x.Value, (parameter as ListOfStringsParameter).DefaultValue),
                DictionaryOfStringsSetting x =>
                Compare(x.Value.Keys, (parameter as DictionaryOfStringsParameter).DefaultValue.Keys) &&
                Compare(x.Value.Values, (parameter as DictionaryOfStringsParameter).DefaultValue.Values),
                EnumSetting x => x.Value == (parameter as EnumParameter).DefaultValue,
                _ => throw new NotImplementedException(),
            };

            if (setting.InputMode != SettingInputMode.Fixed || !isDefaultValue)
            {
                AppendLine($"{parameter.Name} = {GetSettingValue(setting)}", spaces);
            }

            return(this);
        }
Beispiel #3
0
 private static float SetScaling(FloatSetting set)
 {
     if (!UIManager.HUDAutoScaleGUI.Value)
     {
         return(set.Value);
     }
     return((float)System.Math.Round(set.DefaultValue * UIManager.HUDScaleGUI.Value, 0));
 }
Beispiel #4
0
    public void WeatherLerpSpeedSettingChanged()
    {
        FloatSetting weatherLerpSpeedSetting = Settings.Instance.GetSetting <FloatSetting>("audio_weather_lerp_speed");

        if (weatherLerpSpeedSetting != null)
        {
            m_weatherLerpSpeed = weatherLerpSpeedSetting.Value;
        }
    }
Beispiel #5
0
 protected override void Dispose(bool disposing)
 {
     if (disposing && (this.setting != null))
     {
         this.setting.ValueChangedT -= new ValueChangedEventHandler <float>(this.OnSettingValueChanged);
         this.setting = null;
     }
     base.Dispose(disposing);
 }
Beispiel #6
0
 public SliderControl(FloatSetting setting) : base(CreateControlInstance())
 {
     Validate.IsNotNull <FloatSetting>(setting, "setting");
     this.setting = setting;
     this.setting.ValueChangedT    += new ValueChangedEventHandler <float>(this.OnSettingValueChanged);
     this.Control.ToleranceChanged += new EventHandler(this.OnToleranceChanged);
     base.Control.Size              = new Size(0xaf, 0x10);
     base.Control.Size              = UIUtil.ScaleSize(base.Control.Size);
     base.AutoSize = false;
 }
Beispiel #7
0
        public void SettingTestIntToString()
        {
            string    expextedString = "mySetting=345";
            const int value          = 345;
            var       setting        = new FloatSetting()
            {
                Category           = "none",
                Description        = "none",
                HumanReadableName  = "Test setting",
                IdentificationName = "mySetting",
                Value = value
            };

            Assert.AreEqual(expextedString, setting.ToString());
        }
Beispiel #8
0
        public void SettingTestFloatString()
        {
            const float value   = 555.444f;
            var         setting = new FloatSetting()
            {
                Category           = "none",
                Description        = "none",
                HumanReadableName  = "Test setting",
                IdentificationName = "mySetting",
                Value = value
            };

            string convSetting = (string)setting;

            Assert.AreEqual(value.ToString(), convSetting);
        }
Beispiel #9
0
        public void SettingTestFloatBoolFalse()
        {
            const float value   = 0.0f;
            var         setting = new FloatSetting()
            {
                Category           = "none",
                Description        = "none",
                HumanReadableName  = "Test setting",
                IdentificationName = "mySetting",
                Value = value
            };

            bool convSetting = (bool)setting;

            Assert.AreEqual(false, convSetting);
        }
Beispiel #10
0
        public void SettingTestFloatFloat()
        {
            const float value   = 1234.56f;
            var         setting = new FloatSetting()
            {
                Category           = "none",
                Description        = "none",
                HumanReadableName  = "Test setting",
                IdentificationName = "mySetting",
                Value = value
            };

            float convSetting = (float)setting;

            Assert.AreEqual(value, convSetting);
        }
Beispiel #11
0
    // Find the instance of the AudioManager and cache it for later.
    void Start()
    {
        m_audioManager = FindObjectOfType <AudioManager>();

        FloatSetting pitchSetting  = Settings.Instance.GetSetting <FloatSetting>("audio_outdoor_pitch");
        FloatSetting volumeSetting = Settings.Instance.GetSetting <FloatSetting>("audio_outdoor_volume");

        if (pitchSetting != null)
        {
            m_outdoorDefaultPitch = pitchSetting.Value;
        }
        if (volumeSetting != null)
        {
            m_outdoorDefaultVolume = volumeSetting.Value;
        }
    }
Beispiel #12
0
    void Start()
    {
        if (WeatherAudioSource == null)
        {
            Logger.LogWarning("AudioManager: WeatherAudioSource not set!", LogChannel.Audio);
        }
        if (Player == null)
        {
            Logger.LogWarning("AudioManager: Player not set!", LogChannel.Audio);
        }

        FloatSetting weatherLerpSpeedSetting = Settings.Instance.GetSetting <FloatSetting>("audio_weather_lerp_speed");

        if (weatherLerpSpeedSetting != null)
        {
            weatherLerpSpeedSetting.AddChangedCallback(WeatherLerpSpeedSettingChanged);
            m_weatherLerpSpeed = weatherLerpSpeedSetting.Value;
        }
    }
Beispiel #13
0
 public FloatSettingViewModel(FloatSetting setting)
     : base(setting)
 {
     Text = setting.DefaultValue.ToString();
 }