Example #1
0
        // Integer
        public static bool DataINIReadWrite(this IniData _Data, string _Section, string _Key, ref int _Value, bool _Write = true, bool _Clamp = false, int _Min = 0, int _Max = 9999)
        {
            IniData data   = _Data;
            bool    status = false;
            int     value  = _Value;

            if (!HEVText.TryParse(data[_Section][_Key], out value, false))
            {
                value = _Value;
                if (_Clamp)
                {
                    value = HEVMath.Clamp(value, _Min, _Max);
                }
                if (_Write)
                {
                    data[_Section][_Key] = value.ToString();
                }
                status = false;
            }
            else
            {
                if (HEVMath.Validate(_Min, _Max, value))
                {
                    status = true;
                }
                else
                {
                    if (_Clamp)
                    {
                        value  = HEVMath.Clamp(value, _Min, _Max);
                        status = false;
                    }
                    else
                    {
                        status = true;
                    }
                }
            }
            _Data  = data;
            _Value = value;
            return(status);
        }
Example #2
0
        // Returns false if need to save the file
        // Bool
        public static bool DataINIReadWrite(this IniData _Data, string _Section, string _Key, ref bool _Value, bool _Write = true)
        {
            IniData data      = _Data;
            bool    status    = false;
            bool    value     = _Value;
            bool    dataValue = _Value;

            if (!HEVText.TryParse(data[_Section][_Key], out dataValue))
            {
                if (_Write)
                {
                    data[_Section][_Key] = value.ToString();
                }
                status = false;
            }
            else
            {
                value  = dataValue;
                status = true;
            }
            _Data  = data;
            _Value = value;
            return(status);
        }