コード例 #1
0
        public void SetValue(string value)
        {
            switch (Type)
            {
            case SettingType.STRING:
            case SettingType.ENUM:
                Value = value;
                break;

            case SettingType.BOOLEAN:
                Value = (value != null && value.Length > 0 && value != "0") ? "1" : "0";
                break;

            case SettingType.SPEED:
            case SettingType.DISTANCE:
            case SettingType.FACTOR:
                if (I18N.TryParseFloat(value, out float fvalue))
                {
                    Value = I18N.FloatToString(fvalue);
                }
                else
                {
                    Value = "0";
                }
                break;

            case SettingType.COUNT:
                if (I18N.TryParseInt(value, out int ivalue))
                {
                    Value = I18N.IntToString(ivalue);
                }
                else
                {
                    Value = "0";
                }
                break;
            }
        }