Exemple #1
0
    public static bool GetBool(string strName, bool strDefault)
    {
        bool   num;
        object obj;
        string str = ConVar.GetString(strName, (!strDefault ? bool.FalseString : bool.TrueString));

        try
        {
            num = bool.Parse(str);
        }
        catch
        {
            string str1 = strName;
            if (!strDefault)
            {
                obj = null;
            }
            else
            {
                obj = 1;
            }
            num = ConVar.GetInt(str1, (float)obj) != 0;
        }
        return(num);
    }
Exemple #2
0
    public static float GetFloat(string strName, float strDefault)
    {
        string str = ConVar.GetString(strName, string.Empty);

        if (str.Length == 0)
        {
            return(strDefault);
        }
        float single = strDefault;

        if (float.TryParse(str, out single))
        {
            return(single);
        }
        return(strDefault);
    }
Exemple #3
0
    public void UpdateFromConVar()
    {
        dfSlider component = base.GetComponent <dfSlider>();

        if (component != null)
        {
            component.Value = ConVar.GetFloat(this.convarName, component.Value);
        }
        dfDropdown _dfDropdown = base.GetComponent <dfDropdown>();

        if (_dfDropdown != null)
        {
            if (!this.useValuesNotNumbers)
            {
                int num = ConVar.GetInt(this.convarName, -1f);
                if (num != -1)
                {
                    _dfDropdown.SelectedIndex = num;
                }
            }
            else
            {
                string str = ConVar.GetString(this.convarName, string.Empty);
                if (!string.IsNullOrEmpty(str))
                {
                    int selectedIndex = _dfDropdown.SelectedIndex;
                    _dfDropdown.SelectedValue = str;
                    if (_dfDropdown.SelectedIndex == -1)
                    {
                        _dfDropdown.SelectedIndex = selectedIndex;
                    }
                }
            }
        }
        dfCheckbox flag = base.GetComponent <dfCheckbox>();

        if (flag != null)
        {
            flag.IsChecked = ConVar.GetBool(this.convarName, flag.IsChecked);
        }
    }
Exemple #4
0
    public void UpdateFromConVar()
    {
        dfSlider component = base.GetComponent <dfSlider>();

        if (component != null)
        {
            component.Value = ConVar.GetFloat(this.convarName, component.Value);
        }
        dfDropdown dropdown = base.GetComponent <dfDropdown>();

        if (dropdown != null)
        {
            if (this.useValuesNotNumbers)
            {
                string str = ConVar.GetString(this.convarName, string.Empty);
                if (!string.IsNullOrEmpty(str))
                {
                    int selectedIndex = dropdown.SelectedIndex;
                    dropdown.SelectedValue = str;
                    if (dropdown.SelectedIndex == -1)
                    {
                        dropdown.SelectedIndex = selectedIndex;
                    }
                }
            }
            else
            {
                int @int = ConVar.GetInt(this.convarName, -1f);
                if (@int != -1)
                {
                    dropdown.SelectedIndex = @int;
                }
            }
        }
        dfCheckbox checkbox = base.GetComponent <dfCheckbox>();

        if (checkbox != null)
        {
            checkbox.IsChecked = ConVar.GetBool(this.convarName, checkbox.IsChecked);
        }
    }